83830 lines
3.1 MiB
83830 lines
3.1 MiB
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
!function(){"use strict";function r(e){if(null===e)return"null";if(void 0===e)return"undefined";var t=typeof e;return"object"==t&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"==t&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":t}function f(o){return m(function(e,t){if(e.length!==t.length)return!1;for(var n=e.length,r=0;r<n;r++)if(!o.eq(e[r],t[r]))return!1;return!0})}function d(l){return m(function(e,t){var n,r,o,i=Object.keys(e),a=Object.keys(t);if(r=f(g),o=function(e){return t=n,Array.prototype.slice.call(e).sort(t);var t},!m(function(e,t){return r.eq(o(e),o(t))}).eq(i,a))return!1;for(var u=i.length,s=0;s<u;s++){var c=i[s];if(!l.eq(e[c],t[c]))return!1}return!0})}function e(r){return function(e){return n=typeof(t=e),(null===t?"null":"object"==n&&(Array.prototype.isPrototypeOf(t)||t.constructor&&"Array"===t.constructor.name)?"array":"object"==n&&(String.prototype.isPrototypeOf(t)||t.constructor&&"String"===t.constructor.name)?"string":n)===r;var t,n}}function t(t){return function(e){return typeof e===t}}function n(t){return function(e){return t===e}}function K(e){return null==e}function V(e){return!K(e)}function te(){}function i(n,r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(r.apply(null,e))}}function a(t,n){return function(e){return t(n(e))}}function J(e){return function(){return e}}function u(e){return e}function o(e,t){return e===t}var m=function(e){return{eq:e}},g=m(function(e,t){return e===t}),p=m(function(e,t){if(e===t)return!0;var n=r(e);return n===r(t)&&(-1!==["undefined","boolean","number","string","function","xml","null"].indexOf(n)?e===t:"array"===n?f(p).eq(e,t):"object"===n&&d(p).eq(e,t))}),X=e("string"),h=e("object"),S=e("array"),l=n(null),v=t("boolean"),b=n(void 0),y=t("function"),E=t("number");function R(r){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=o.concat(e);return r.apply(null,n)}}function s(t){return function(e){return!t(e)}}function C(e){return e()}function x(e){e()}function c(){return k}var D=J(!1),w=J(!0),k={fold:function(e,t){return e()},isSome:D,isNone:w,getOr:u,getOrThunk:N,getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:J(null),getOrUndefined:J(void 0),or:u,orThunk:N,map:c,each:te,bind:c,exists:D,forall:w,filter:function(){return k},toArray:function(){return[]},toString:J("none()")};function N(e){return e()}function _(e,t){return ye.call(e,t)}function T(e,t){return-1<_(e,t)}function F(e,t){for(var n=0,r=e.length;n<r;n++)if(t(e[n],n))return!0;return!1}function A(e,t){for(var n=e.length,r=new Array(n),o=0;o<n;o++){var i=e[o];r[o]=t(i,o)}return r}function Y(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n)}function O(e,t){for(var n=e.length-1;0<=n;n--)t(e[n],n)}function B(e,t){for(var n=[],r=[],o=0,i=e.length;o<i;o++){var a=e[o];(t(a,o)?n:r).push(a)}return{pass:n,fail:r}}function U(e,t){for(var n=[],r=0,o=e.length;r<o;r++){var i=e[r];t(i,r)&&n.push(i)}return n}function P(e,n,r){return O(e,function(e,t){r=n(r,e,t)}),r}function L(e,n,r){return Y(e,function(e,t){r=n(r,e,t)}),r}function I(e,t,n){for(var r=0,o=e.length;r<o;r++){var i=e[r];if(t(i,r))return ve.some(i);if(n(i,r))break}return ve.none()}function M(e,t){return I(e,t,D)}function z(e,t){for(var n=0,r=e.length;n<r;n++)if(t(e[n],n))return ve.some(n);return ve.none()}function H(e,t){return function(e){for(var t=[],n=0,r=e.length;n<r;++n){if(!S(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);Ce.apply(t,e[n])}return t}(A(e,t))}function j(e,t){for(var n=0,r=e.length;n<r;++n)if(!0!==t(e[n],n))return!1;return!0}function q(e){var t=be.call(e,0);return t.reverse(),t}function $(e,t){return U(e,function(e){return!T(t,e)})}function W(e,t){var n=be.call(e,0);return n.sort(t),n}function G(e,t){return 0<=t&&t<e.length?ve.some(e[t]):ve.none()}function Q(e){return G(e,0)}function Z(e){return G(e,e.length-1)}function ee(e,t){for(var n=0;n<e.length;n++){var r=t(e[n],n);if(r.isSome())return r}return ve.none()}function ne(e,t){for(var n=we(e),r=0,o=n.length;r<o;r++){var i=n[r];t(e[i],i)}}function re(e,n){return Ee(e,function(e,t){return{k:t,v:n(e,t)}})}function oe(n){return function(e,t){n[t]=e}}function ie(e,n,r,o){return ne(e,function(e,t){(n(e,t)?r:o)(e,t)}),1}function ae(e,t){var n={};return ie(e,t,oe(n),te),n}function ue(e,t){return ke(e,t)?ve.from(e[t]):ve.none()}function se(e,t){return ke(e,t)&&void 0!==e[t]&&null!==e[t]}function ce(e,t,n){var r,o;if(!e)return!1;if(n=n||e,void 0!==e.length){for(r=0,o=e.length;r<o;r++)if(!1===t.call(n,e[r],r,e))return!1}else for(r in e)if(ke(e,r)&&!1===t.call(n,e[r],r,e))return!1;return!0}function le(n,r){var o=[];return ce(n,function(e,t){o.push(r(e,t,n))}),o}function fe(n,r){var o=[];return ce(n,function(e,t){r&&!r(e,t,n)||o.push(e)}),o}function de(e,t){if(e)for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function me(e,t,n,r){for(var o=b(n)?e[0]:n,i=0;i<e.length;i++)o=t.call(r,o,e[i],i);return o}function ge(e,t,n){for(var r=0,o=e.length;r<o;r++)if(t.call(n,e[r],r,e))return r;return-1}function pe(e){return e[e.length-1]}var he=function(n){function e(){return o}function t(e){return e(n)}var r=J(n),o={fold:function(e,t){return t(n)},isSome:w,isNone:D,getOr:r,getOrThunk:r,getOrDie:r,getOrNull:r,getOrUndefined:r,or:e,orThunk:e,map:function(e){return he(e(n))},each:function(e){e(n)},bind:t,exists:t,forall:t,filter:function(e){return e(n)?o:k},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},ve={some:he,none:c,from:function(e){return null==e?k:he(e)}},be=Array.prototype.slice,ye=Array.prototype.indexOf,Ce=Array.prototype.push,xe=y(Array.from)?Array.from:function(e){return be.call(e)},we=Object.keys,Se=Object.hasOwnProperty,Ee=function(e,r){var o={};return ne(e,function(e,t){var n=r(e,t);o[n.k]=n.v}),o},ke=function(e,t){return Se.call(e,t)},Ne=Array.isArray,_e=function(){return(_e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function Ae(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function Re(n){var r,o=!1;return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o||(o=!0,r=n.apply(null,e)),r}}function De(e,t){var n=String(t).toLowerCase();return M(e,function(e){return e.search(n)})}function Te(e,t){return-1!==e.indexOf(t)}function Oe(t){return function(e){return e.replace(t,"")}}function Be(e){return 0<e.length}function Pe(e){return!Be(e)}function Le(t){return function(e){return Te(e,t)}}function Ie(e){return window.matchMedia(e).matches}function Me(e){return null==e?"":(""+e).replace(wt,"")}function Fe(e,t){return t?!("array"!==t||!Ne(e))||typeof e===t:void 0!==e}function Ue(e,t){for(var n=[],r=function(e){return n.push(e),t(e)},o=t(e);(o=o.bind(r)).isSome(););return n}function ze(e,t){var n=e.dom;if(1!==n.nodeType)return!1;var r=n;if(void 0!==r.matches)return r.matches(t);if(void 0!==r.msMatchesSelector)return r.msMatchesSelector(t);if(void 0!==r.webkitMatchesSelector)return r.webkitMatchesSelector(t);if(void 0!==r.mozMatchesSelector)return r.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}function He(e){return 1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount}function je(e,t){return e.dom===t.dom}function Ve(e,t){return dt().browser.isIE()?(n=e.dom,r=t.dom,o=Node.DOCUMENT_POSITION_CONTAINED_BY,0!=(n.compareDocumentPosition(r)&o)):(i=e.dom)!==(a=t.dom)&&i.contains(a);var n,r,o,i,a}function qe(){return Xe(0,0)}function $e(e){function t(e){return function(){return n===e}}var n=e.current,r=e.version;return{current:n,version:r,isEdge:t("Edge"),isChrome:t("Chrome"),isIE:t("IE"),isOpera:t("Opera"),isFirefox:t(nt),isSafari:t("Safari")}}function We(e){function t(e){return function(){return n===e}}var n=e.current,r=e.version;return{current:n,version:r,isWindows:t(it),isiOS:t("iOS"),isAndroid:t(at),isOSX:t("OSX"),isLinux:t("Linux"),isSolaris:t(ut),isFreeBSD:t(st),isChromeOS:t(ct)}}function Ke(e){if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}}var Xe=function(e,t){return{major:e,minor:t}},Ye={nu:Xe,detect:function(e,t){var n,r,o=String(t).toLowerCase();return 0===e.length?qe():(r=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.test(t))return r}}(e,n=o))?Xe(i(1),i(2)):{major:0,minor:0};function i(e){return Number(n.replace(r,"$"+e))}},unknown:qe},Ge=function(e,t){return""===(n=t)||e.length>=n.length&&e.substr(0,0+n.length)===n;var n},Je=Oe(/^\s+|\s+$/g),Qe=Oe(/^\s+/g),Ze=Oe(/\s+$/g),et=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,tt={browsers:J([{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return Te(e,"edge/")&&Te(e,"chrome")&&Te(e,"safari")&&Te(e,"applewebkit")}},{name:"Chrome",brand:"Chromium",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,et],search:function(e){return Te(e,"chrome")&&!Te(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return Te(e,"msie")||Te(e,"trident")}},{name:"Opera",versionRegexes:[et,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Le("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:Le("firefox")},{name:"Safari",versionRegexes:[et,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(Te(e,"safari")||Te(e,"mobile/"))&&Te(e,"applewebkit")}}]),oses:J([{name:"Windows",search:Le("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return Te(e,"iphone")||Te(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Le("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:Le("mac os x"),versionRegexes:[/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Le("linux"),versionRegexes:[]},{name:"Solaris",search:Le("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Le("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:Le("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}])},nt="Firefox",rt=function(){return $e({current:void 0,version:Ye.unknown()})},ot=$e,it=(J("Edge"),J("Chrome"),J("IE"),J("Opera"),J(nt),J("Safari"),"Windows"),at="Android",ut="Solaris",st="FreeBSD",ct="ChromeOS",lt=function(){return We({current:void 0,version:Ye.unknown()})},ft=We,dt=(J(it),J("iOS"),J(at),J("Linux"),J("OSX"),J(ut),J(st),J(ct),Re(function(){return e=navigator.userAgent,t=ve.from(navigator.userAgentData),n=Ie,p=tt.browsers(),h=tt.oses(),v=t.bind(function(e){return r=p,ee(e.brands,function(t){var n=t.brand.toLowerCase();return M(r,function(e){var t;return n===(null===(t=e.brand)||void 0===t?void 0:t.toLowerCase())}).map(function(e){return{current:e.name,version:Ye.nu(parseInt(t.version,10),0)}})});var r}).orThunk(function(){return De(p,n=e).map(function(e){var t=Ye.detect(e.versionRegexes,n);return{current:e.name,version:t}});var n}).fold(rt,ot),b=De(h,r=e).map(function(e){var t=Ye.detect(e.versionRegexes,r);return{current:e.name,version:t}}).fold(lt,ft),{browser:v,os:b,deviceType:(i=v,a=e,u=n,s=(o=b).isiOS()&&!0===/ipad/i.test(a),c=o.isiOS()&&!s,f=(l=o.isiOS()||o.isAndroid())||u("(pointer:coarse)"),d=s||!c&&l&&u("(min-device-width:768px)"),m=c||l&&!d,g=i.isSafari()&&o.isiOS()&&!1===/safari/i.test(a),{isiPad:J(s),isiPhone:J(c),isTablet:J(d),isPhone:J(m),isTouch:J(f),isAndroid:o.isAndroid,isiOS:o.isiOS,isWebView:J(g),isDesktop:J(!m&&!d&&!g)})};var e,t,n,r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,b})),mt=navigator.userAgent,gt=dt(),pt=gt.browser,ht=gt.os,vt=gt.deviceType,bt=/WebKit/.test(mt)&&!pt.isEdge(),yt="FormData"in window&&"FileReader"in window&&"URL"in window&&!!URL.createObjectURL,Ct=-1!==mt.indexOf("Windows Phone"),xt={opera:pt.isOpera(),webkit:bt,ie:!(!pt.isIE()&&!pt.isEdge())&&pt.version.major,gecko:pt.isFirefox(),mac:ht.isOSX()||ht.isiOS(),iOS:vt.isiPad()||vt.isiPhone(),android:ht.isAndroid(),contentEditable:!0,transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",caretAfter:!0,range:window.getSelection&&"Range"in window,documentMode:pt.isIE()?document.documentMode||7:10,fileApi:yt,ceFalse:!0,cacheSuffix:null,container:null,experimentalShadowDom:!1,canHaveCSP:!pt.isIE(),desktop:vt.isDesktop(),windowsPhone:Ct,browser:{current:pt.current,version:pt.version,isChrome:pt.isChrome,isEdge:pt.isEdge,isFirefox:pt.isFirefox,isIE:pt.isIE,isOpera:pt.isOpera,isSafari:pt.isSafari},os:{current:ht.current,version:ht.version,isAndroid:ht.isAndroid,isChromeOS:ht.isChromeOS,isFreeBSD:ht.isFreeBSD,isiOS:ht.isiOS,isLinux:ht.isLinux,isOSX:ht.isOSX,isSolaris:ht.isSolaris,isWindows:ht.isWindows},deviceType:{isDesktop:vt.isDesktop,isiPad:vt.isiPad,isiPhone:vt.isiPhone,isPhone:vt.isPhone,isTablet:vt.isTablet,isTouch:vt.isTouch,isWebView:vt.isWebView}},wt=/^\s*|\s*$/g,St=function(e,n,r,o){o=o||this,e&&ce(e=r?e[r]:e,function(e,t){return!1!==n.call(o,e,t,r)&&void St(e,n,r,o)})},Et={trim:Me,isArray:Ne,is:Fe,toArray:function(e){if(Ne(e))return e;for(var t=[],n=0,r=e.length;n<r;n++)t[n]=e[n];return t},makeMap:function(e,t,n){var r;for(t=t||",",n=n||{},r=(e="string"==typeof(e=e||[])?e.split(t):e).length;r--;)n[e[r]]={};return n},each:ce,map:le,grep:fe,inArray:de,hasOwn:ke,extend:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];for(var r=0;r<t.length;r++){var o,i,a=t[r];for(o in a)!ke(a,o)||void 0!==(i=a[o])&&(e[o]=i)}return e},create:function(e,t,n){var r,o,i,a=this,u=0,s=(e=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(e))[3].match(/(^|\.)(\w+)$/i)[2],c=a.createNS(e[3].replace(/\.\w+$/,""),n);if(!c[s]){if("static"===e[2])return c[s]=t,void(this.onCreate&&this.onCreate(e[2],e[3],c[s]));t[s]||(t[s]=function(){},u=1),c[s]=t[s],a.extend(c[s].prototype,t),e[5]&&(r=a.resolve(e[5]).prototype,o=e[5].match(/\.(\w+)$/i)[1],i=c[s],c[s]=u?function(){return r[o].apply(this,arguments)}:function(){return this.parent=r[o],i.apply(this,arguments)},c[s].prototype[s]=c[s],a.each(r,function(e,t){c[s].prototype[t]=r[t]}),a.each(t,function(e,t){r[t]?c[s].prototype[t]=function(){return this.parent=r[t],e.apply(this,arguments)}:t!==s&&(c[s].prototype[t]=e)})),a.each(t.static,function(e,t){c[s][t]=e})}},walk:St,createNS:function(e,t){var n,r;for(t=t||window,e=e.split("."),n=0;n<e.length;n++)t[r=e[n]]||(t[r]={}),t=t[r];return t},resolve:function(e,t){var n,r;for(t=t||window,n=0,r=(e=e.split(".")).length;n<r&&(t=t[e[n]]);n++);return t},explode:function(e,t){return!e||Fe(e,"array")?e:le(e.split(t||","),Me)},_addCacheSuffix:function(e){var t=xt.cacheSuffix;return t&&(e+=(-1===e.indexOf("?")?"?":"&")+t),e}},kt={fromHtml:function(e,t){var n=(t||document).createElement("div");if(n.innerHTML=e,!n.hasChildNodes()||1<n.childNodes.length)throw console.error("HTML does not have a single root node",e),new Error("HTML must have a single root node");return Ke(n.childNodes[0])},fromTag:function(e,t){var n=(t||document).createElement(e);return Ke(n)},fromText:function(e,t){var n=(t||document).createTextNode(e);return Ke(n)},fromDom:Ke,fromPoint:function(e,t,n){return ve.from(e.dom.elementFromPoint(t,n)).map(Ke)}};function Nt(e){return e.dom.nodeName.toLowerCase()}function _t(e){return e.dom.nodeType}function At(t){return function(e){return _t(e)===t}}function Rt(e){return kt.fromDom(e.dom.ownerDocument)}function Dt(e){return An(e)?e:Rt(e)}function Tt(e){return kt.fromDom(Dt(e).dom.defaultView)}function Ot(e){return ve.from(e.dom.parentNode).map(kt.fromDom)}function Bt(e){return ve.from(e.dom.previousSibling).map(kt.fromDom)}function Pt(e){return ve.from(e.dom.nextSibling).map(kt.fromDom)}function Lt(e){return q(Ue(e,Bt))}function It(e){return Ue(e,Pt)}function Mt(e,t){var n=e.dom.childNodes;return ve.from(n[t]).map(kt.fromDom)}function Ft(e){return Mt(e,0)}function Ut(e){return Mt(e,e.dom.childNodes.length-1)}function zt(e){return e.dom.childNodes.length}function Ht(e){return Rn(e)&&V(e.dom.host)}function jt(t){return Ht(t)?t:function(){var e=Dt(t).dom.head;if(null==e)throw new Error("Head is not available yet");return kt.fromDom(e)}()}function Vt(e){return kt.fromDom(e.dom.host)}function qt(t,n){Ot(t).each(function(e){e.dom.insertBefore(n.dom,t.dom)})}function $t(e,t){Pt(e).fold(function(){Ot(e).each(function(e){Pn(e,t)})},function(e){qt(e,t)})}function Wt(t,n){Ft(t).fold(function(){Pn(t,n)},function(e){t.dom.insertBefore(n.dom,e.dom)})}function Kt(t,e){Y(e,function(e){Pn(t,e)})}function Xt(e){e.dom.textContent="",Y(Dn(e),function(e){Ln(e)})}function Yt(e){var t,n=Dn(e);0<n.length&&(t=e,Y(n,function(e){qt(t,e)})),Ln(e)}function Gt(e,t){return void 0!==e?e:void 0!==t?t:0}function Jt(e){var t=void 0!==e?e.dom:document,n=t.body.scrollLeft||t.documentElement.scrollLeft,r=t.body.scrollTop||t.documentElement.scrollTop;return Fn(n,r)}function Qt(e,t,n){var r=(void 0!==n?n.dom:document).defaultView;r&&r.scrollTo(e,t)}function Zt(e,t){dt().browser.isSafari()&&y(e.dom.scrollIntoViewIfNeeded)?e.dom.scrollIntoViewIfNeeded(!1):e.dom.scrollIntoView(t)}function en(e,t,n,r){return{x:e,y:t,width:n,height:r,right:e+n,bottom:t+r}}function tn(e){var r=void 0===e?window:e,t=r.document,o=Jt(kt.fromDom(t)),n=void 0===r?window:r;return(dt().browser.isFirefox()?ve.none():ve.from(n.visualViewport)).fold(function(){var e=r.document.documentElement,t=e.clientWidth,n=e.clientHeight;return en(o.left,o.top,t,n)},function(e){return en(Math.max(e.pageLeft,o.left),Math.max(e.pageTop,o.top),e.width,e.height)})}function nn(t){return function(e){return!!e&&e.nodeType===t}}function rn(e){return e&&!Object.getPrototypeOf(e)}function on(e){var n=e.map(function(e){return e.toLowerCase()});return function(e){if(e&&e.nodeName){var t=e.nodeName.toLowerCase();return T(n,t)}return!1}}function an(r,e){var o=e.toLowerCase().split(" ");return function(e){if(zn(e))for(var t=0;t<o.length;t++){var n=e.ownerDocument.defaultView.getComputedStyle(e,null);if((n?n.getPropertyValue(r):null)===o[t])return!0}return!1}}function un(t){return function(e){return zn(e)&&e.hasAttribute(t)}}function sn(e){return zn(e)&&e.hasAttribute("data-mce-bogus")}function cn(e){return zn(e)&&"TABLE"===e.tagName}function ln(t){return function(e){if(zn(e)){if(e.contentEditable===t)return!0;if(e.getAttribute("data-mce-contenteditable")===t)return!0}return!1}}function fn(e,t,n){return void 0===n&&(n=o),e.exists(function(e){return n(e,t)})}function dn(e,t,n){return e.isSome()&&t.isSome()?ve.some(n(e.getOrDie(),t.getOrDie())):ve.none()}function mn(e){return void 0!==e.style&&y(e.style.getPropertyValue)}function gn(e,t,n){if(!(X(n)||v(n)||E(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")}function pn(e,t,n){gn(e.dom,t,n)}function hn(e,t){var n=e.dom;ne(t,function(e,t){gn(n,t,e)})}function vn(e,t){var n=e.dom.getAttribute(t);return null===n?void 0:n}function bn(e,t){return ve.from(vn(e,t))}function yn(e,t){e.dom.removeAttribute(t)}function Cn(e,t){var n=e.dom;ne(t,function(e,t){!function(e,t,n){if(!X(n))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",n,":: Element ",e),new Error("CSS value must be a string: "+n);mn(e)&&e.style.setProperty(t,n)}(n,t,e)})}function xn(e,t){var n=e.dom,r=window.getComputedStyle(n).getPropertyValue(t);return""!==r||In(e)?r:Qn(n,t)}function wn(e,t){var n=e.dom,r=Qn(n,t);return ve.from(r).filter(function(e){return 0<e.length})}function Sn(e){var t={},n=e.dom;if(mn(n))for(var r=0;r<n.style.length;r++){var o=n.style.item(r);t[o]=n.style[o]}return t}function En(e){return M(e,Nn)}function kn(e,t){return e.children&&T(e.children,t)}"undefined"!=typeof window||Function("return this;")();var Nn=At(1),_n=At(3),An=At(9),Rn=At(11),Dn=function(e){return A(e.dom.childNodes,kt.fromDom)},Tn=y(Element.prototype.attachShadow)&&y(Node.prototype.getRootNode),On=J(Tn),Bn=Tn?function(e){return kt.fromDom(e.dom.getRootNode())}:Dt,Pn=function(e,t){e.dom.appendChild(t.dom)},Ln=function(e){var t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},In=function(e){var t=_n(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;var n=t.ownerDocument,r=kt.fromDom(t),o=Bn(r);return(Ht(o)?ve.some(o):ve.none()).fold(function(){return n.body.contains(t)},a(In,Vt))},Mn=function(n,r){return{left:n,top:r,translate:function(e,t){return Mn(n+e,r+t)}}},Fn=Mn,Un=function(e){var t,n=e.dom,r=n.ownerDocument.body;return r===n?Fn(r.offsetLeft,r.offsetTop):In(e)?(t=n.getBoundingClientRect(),Fn(t.left,t.top)):Fn(0,0)},zn=nn(1),Hn=on(["textarea","input"]),jn=nn(3),Vn=nn(8),qn=nn(9),$n=nn(11),Wn=on(["br"]),Kn=on(["img"]),Xn=ln("true"),Yn=ln("false"),Gn=on(["td","th"]),Jn=on(["video","audio","object","embed"]),Qn=function(e,t){return mn(e)?e.style.getPropertyValue(t):""},Zn=dt().browser,er={},tr={exports:er};function nr(e){setTimeout(function(){throw e},0)}!function(){var e=this,t=function(){var e,t,n,r={exports:{}};function o(){}function i(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],f(e,this)}function a(n,r){for(;3===n._state;)n=n._value;0!==n._state?(n._handled=!0,i._immediateFn(function(){var e,t=1===n._state?r.onFulfilled:r.onRejected;if(null!==t){try{e=t(n._value)}catch(e){return void s(r.promise,e)}u(r.promise,e)}else(1===n._state?u:s)(r.promise,n._value)})):n._deferreds.push(r)}function u(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof i)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void f((r=n,o=e,function(){r.apply(o,arguments)}),t)}t._state=1,t._value=e,c(t)}catch(e){s(t,e)}var r,o}function s(e,t){e._state=2,e._value=t,c(e)}function c(e){2===e._state&&0===e._deferreds.length&&i._immediateFn(function(){e._handled||i._unhandledRejectionFn(e._value)});for(var t=0,n=e._deferreds.length;t<n;t++)a(e,e._deferreds[t]);e._deferreds=null}function l(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function f(e,t){var n=!1;try{e(function(e){n||(n=!0,u(t,e))},function(e){n||(n=!0,s(t,e))})}catch(e){if(n)return;n=!0,s(t,e)}}e=r,t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=setTimeout,i.prototype.catch=function(e){return this.then(null,e)},i.prototype.then=function(e,t){var n=new this.constructor(o);return a(this,new l(e,t,n)),n},i.all=function(e){var u=Array.prototype.slice.call(e);return new i(function(o,i){if(0===u.length)return o([]);for(var a=u.length,e=0;e<u.length;e++)!function t(n,e){try{if(e&&("object"==typeof e||"function"==typeof e)){var r=e.then;if("function"==typeof r)return r.call(e,function(e){t(n,e)},i),0}u[n]=e,0==--a&&o(u)}catch(e){i(e)}}(e,u[e])})},i.resolve=function(t){return t&&"object"==typeof t&&t.constructor===i?t:new i(function(e){e(t)})},i.reject=function(n){return new i(function(e,t){t(n)})},i.race=function(o){return new i(function(e,t){for(var n=0,r=o.length;n<r;n++)o[n].then(e,t)})},i._immediateFn="function"==typeof setImmediate?function(e){setImmediate(e)}:function(e){n(e,0)},i._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)},i._setImmediateFn=function(e){i._immediateFn=e},i._setUnhandledRejectionFn=function(e){i._unhandledRejectionFn=e},e.exports?e.exports=i:t.Promise||(t.Promise=i);var d=r.exports;return{boltExport:("undefined"!=typeof window?window:Function("return this;")()).Promise||d}};"object"==typeof er&&void 0!==tr?tr.exports=t():(e="undefined"!=typeof globalThis?globalThis:e||self).EphoxContactWrapper=t()}();function rr(e){return sr(function(){return new ir(e)})}function or(a){if(!S(a))throw new Error("cases must be an array");if(0===a.length)throw new Error("there must be at least one case");var u=[],n={};return Y(a,function(e,r){var t=we(e);if(1!==t.length)throw new Error("one and only one name per case");var o=t[0],i=e[o];if(void 0!==n[o])throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!S(i))throw new Error("case arguments must be an array");u.push(o),n[o]=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=n.length;if(t!==i.length)throw new Error("Wrong number of arguments to case "+o+". Expected "+i.length+" ("+i+"), got "+t);return{fold:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(e.length!==a.length)throw new Error("Wrong number of arguments to fold. Expected "+a.length+", got "+e.length);return e[r].apply(null,n)},match:function(e){var t=we(e);if(u.length!==t.length)throw new Error("Wrong number of arguments to match. Expected: "+u.join(",")+"\nActual: "+t.join(","));if(!j(u,function(e){return T(t,e)}))throw new Error("Not all branches were specified when using match. Specified: "+t.join(", ")+"\nRequired: "+u.join(", "));return e[o].apply(null,n)},log:function(e){console.log(e,{constructors:u,constructor:o,params:n})}}}}),n}var ir=tr.exports.boltExport,ar=function(e){function r(e){o()?i(e):t.push(e)}var n=ve.none(),t=[],o=function(){return n.isSome()},i=function(t){n.each(function(e){setTimeout(function(){t(e)},0)})};return e(function(e){o()||(n=ve.some(e),Y(t,i),t=[])}),{get:r,map:function(n){return ar(function(t){r(function(e){t(n(e))})})},isReady:o}},ur={nu:ar,pure:function(t){return ar(function(e){e(t)})}},sr=function(n){function e(e){n().then(e,nr)}return{map:function(e){return sr(function(){return n().then(e)})},bind:function(t){return sr(function(){return n().then(function(e){return t(e).toPromise()})})},anonBind:function(e){return sr(function(){return n().then(function(){return e.toPromise()})})},toLazy:function(){return ur.nu(e)},toCached:function(){var e=null;return sr(function(){return e=null===e?n():e})},toPromise:n,get:e}},cr=function(n){return{isValue:w,isError:D,getOr:J(n),getOrThunk:J(n),getOrDie:J(n),or:function(e){return cr(n)},orThunk:function(e){return cr(n)},fold:function(e,t){return t(n)},map:function(e){return cr(e(n))},mapError:function(e){return cr(n)},each:function(e){e(n)},bind:function(e){return e(n)},exists:function(e){return e(n)},forall:function(e){return e(n)},toOptional:function(){return ve.some(n)}}},lr=function(n){return{isValue:D,isError:w,getOr:u,getOrThunk:function(e){return e()},getOrDie:function(){return e=String(n),function(){throw new Error(e)}();var e},or:u,orThunk:function(e){return e()},fold:function(e,t){return e(n)},map:function(e){return lr(n)},mapError:function(e){return lr(e(n))},each:te,bind:function(e){return lr(n)},exists:D,forall:w,toOptional:ve.none}},fr={value:cr,error:lr,fromOption:function(e,t){return e.fold(function(){return lr(t)},cr)}};function dr(e){return e.fold(u,u)}function mr(e,t,n,r,o){return e(n,r)?ve.some(n):y(o)&&o(n)?ve.none():t(n,r,o)}function gr(e,t,n){for(var r=e.dom,o=y(n)?n:D;r.parentNode;){var r=r.parentNode,i=kt.fromDom(r);if(t(i))return ve.some(i);if(o(i))break}return ve.none()}function pr(e,t,n){return mr(function(e,t){return t(e)},gr,e,t,n)}function hr(e,t,n){return gr(e,function(e){return ze(e,t)},n)}function vr(e,t){return n=t,He(r=void 0===e?document:e.dom)?ve.none():ve.from(r.querySelector(n)).map(kt.fromDom);var n,r}function br(e,t,n){return mr(ze,hr,e,t,n)}function yr(e,t){return"number"!=typeof t&&(t=0),setTimeout(e,t)}function Cr(e,t){return"number"!=typeof t&&(t=1),setInterval(e,t)}function xr(n,r){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];clearTimeout(o),o=yr(function(){n.apply(this,e)},r)}var o;return e.stop=function(){clearTimeout(o)},e}function wr(m,g){function n(e,t,n){var r,o=Et._addCacheSuffix(e),i=ue(h,o).getOrThunk(function(){return{id:"mce-u"+p++,passed:[],failed:[],count:0}});function a(e,t){for(var n=e.length;n--;)e[n]();i.status=t,i.passed=[],i.failed=[],r&&(r.onload=null,r.onerror=null,r=null)}function u(){return a(i.passed,2),0}function s(){return a(i.failed,3)}(h[o]=i).count++;var c,l,f,d=function(){var e=d;!function(){for(var e=m.styleSheets,t=e.length;t--;){var n=e[t].ownerNode;if(n&&n.id===r.id)return u(),1}}()&&(Date.now()-l<y?_r.setTimeout(e):s())};t&&i.passed.push(t),n&&i.failed.push(n),1!==i.status&&(2!==i.status?3!==i.status?(i.status=1,hn(c=kt.fromTag("link",b.dom),{rel:"stylesheet",type:"text/css",id:i.id}),l=Date.now(),g.contentCssCors&&pn(c,"crossOrigin","anonymous"),g.referrerPolicy&&pn(c,"referrerpolicy",g.referrerPolicy),(r=c.dom).onload=d,r.onerror=s,f=c,Pn(jt(v),f),pn(c,"href",o)):s():u())}function o(t){return rr(function(e){n(t,i(e,J(fr.value(t))),i(e,J(fr.error(t))))})}function t(e){var n=Et._addCacheSuffix(e);ue(h,n).each(function(e){var t;0==--e.count&&(delete h[n],t=e.id,vr(jt(v),"#"+t).each(Ln))})}void 0===g&&(g={});var p=0,h={},v=kt.fromDom(m),b=Dt(v),y=g.maxLoadTime||5e3;return{load:n,loadAll:function(e,n,r){var a,t=A(e,o);a=t,rr(function(r){var o=[],i=0;0===a.length?r([]):Y(a,function(e,t){var n;e.get((n=t,function(e){o[n]=e,++i>=a.length&&r(o)}))})}).get(function(e){var t=B(e,function(e){return e.isValue()});0<t.fail.length?r(t.fail.map(dr)):n(t.pass.map(dr))})},unload:t,unloadAll:function(e){Y(e,function(e){t(e)})},_setReferrerPolicy:function(e){g.referrerPolicy=e}}}or([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]);var Sr,Er,kr=function(e,t){return M(e.dom.childNodes,function(e){return t(kt.fromDom(e))}).map(kt.fromDom)},Nr=window.Promise||ir,_r={requestAnimationFrame:function(e,t){Sr?Sr.then(e):Sr=new Nr(function(e){(function(e,t){for(var n=window.requestAnimationFrame,r=["ms","moz","webkit"],o=0;o<r.length&&!n;o++)n=window[r[o]+"RequestAnimationFrame"];(n=n||function(e){window.setTimeout(e,0)})(e,t)})(e,t=t||document.body)}).then(e)},setTimeout:yr,setInterval:Cr,setEditorTimeout:function(e,t,n){return yr(function(){e.removed||t()},n)},setEditorInterval:function(e,t,n){var r=Cr(function(){e.removed?clearInterval(r):t()},n);return r},debounce:xr,throttle:xr,clearInterval:function(e){return clearInterval(e)},clearTimeout:function(e){return clearTimeout(e)}},Ar=(Er=new WeakMap,{forElement:function(e,t){var n=Bn(e).dom;return ve.from(Er.get(n)).getOrThunk(function(){var e=wr(n,t);return Er.set(n,e),e})}}),Rr=(Dr.prototype.current=function(){return this.node},Dr.prototype.next=function(e){return this.node=this.findSibling(this.node,"firstChild","nextSibling",e),this.node},Dr.prototype.prev=function(e){return this.node=this.findSibling(this.node,"lastChild","previousSibling",e),this.node},Dr.prototype.prev2=function(e){return this.node=this.findPreviousNode(this.node,"lastChild","previousSibling",e),this.node},Dr.prototype.findSibling=function(e,t,n,r){var o,i;if(e){if(!r&&e[t])return e[t];if(e!==this.rootNode){if(o=e[n])return o;for(i=e.parentNode;i&&i!==this.rootNode;i=i.parentNode)if(o=i[n])return o}}},Dr.prototype.findPreviousNode=function(e,t,n,r){var o,i,a;if(e&&(o=e[n],!this.rootNode||o!==this.rootNode)){if(o){if(!r)for(a=o[t];a;a=a[t])if(!a[t])return a;return o}return(i=e.parentNode)&&i!==this.rootNode?i:void 0}},Dr);function Dr(e,t){this.node=e,this.rootNode=t,this.current=this.current.bind(this),this.next=this.next.bind(this),this.prev=this.prev.bind(this),this.prev2=this.prev2.bind(this)}function Tr(t){var n;return function(e){return n=n||function(e,t){for(var n={},r=0,o=e.length;r<o;r++){var i=e[r];n[String(i)]=t(i,r)}return n}(t,w),ke(n,Nt(e))}}function Or(e){return Nn(e)&&!mo(e)}function Br(e){return Nn(e)&&"br"===Nt(e)}function Pr(e){return No(e)&&(e=e.parentNode),ko(e)&&e.hasAttribute("data-mce-caret")}function Lr(e){return No(e)&&So(e.data)}function Ir(e){return Pr(e)||Lr(e)}function Mr(e){return e.firstChild!==e.lastChild||!Wn(e.firstChild)}function Fr(e){var t=e.container();return!!jn(t)&&(t.data.charAt(e.offset())===wo||e.isAtStart()&&Lr(t.previousSibling))}function Ur(e){var t=e.container();return!!jn(t)&&(t.data.charAt(e.offset()-1)===wo||e.isAtEnd()&&Lr(t.nextSibling))}function zr(e){return e&&e.hasAttribute("data-mce-caret")?(sn(n=(t=e.getElementsByTagName("br"))[t.length-1])&&n.parentNode.removeChild(n),e.removeAttribute("data-mce-caret"),e.removeAttribute("data-mce-bogus"),e.removeAttribute("style"),e.removeAttribute("_moz_abspos"),e):null;var t,n}function Hr(e){return Pr(e.startContainer)}function jr(e){return!Io(e)&&(Oo(e)?!Bo(e.parentNode):Po(e)||To(e)||Lo(e)||Mo(e))}function Vr(e,t){return jr(e)&&function(e,t){for(e=e.parentNode;e&&e!==t;e=e.parentNode){if(Mo(e))return!1;if(Ro(e))return!0}return!0}(e,t)}function qr(e){return Fo.test(e)}function $r(e,t){return jr(e)&&!1===(a=t,jn(i=e)&&qr(i.data)&&!1===(n=i,r=kt.fromDom(a),hr(kt.fromDom(n),"pre,code",R(je,r)).isSome()))||zn(o=e)&&"A"===o.nodeName&&!o.hasAttribute("href")&&(o.hasAttribute("name")||o.hasAttribute("id"))||Uo(e);var n,r,o,i,a}function Wr(e,t){return function(e,t){var n=0;if($r(e,e))return!1;var r=e.firstChild;if(!r)return!0;var o=new Rr(r,e);do{if(t){if(Ho(r)){r=o.next(!0);continue}if(zo(r)){r=o.next();continue}}if(Wn(r))n++,r=o.next();else{if($r(r,e))return!1;r=o.next()}}while(r);return n<=1}(e.dom,t=void 0===t||t)}function Kr(e,t){return V(e)&&($r(e,t)||Or(kt.fromDom(e)))}function Xr(e){return"span"===e.nodeName.toLowerCase()&&"bookmark"===e.getAttribute("data-mce-type")}function Yr(e,t){var n,r,o,i={};if(e){for(e=e.split(","),t=t||10,n=0;n<e.length;n+=2)r=String.fromCharCode(parseInt(e[n],t)),Yo[r]||(o="&"+e[n+1]+";",i[r]=o,i[o]=r);return i}}function Gr(e,t){return e.replace(t?qo:$o,function(e){return Yo[e]||e})}function Jr(e,t){return e.replace(t?qo:$o,function(e){return 1<e.length?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":Yo[e]||"&#"+e.charCodeAt(0)+";"})}function Qr(e,t,n){return n=n||Jo,e.replace(t?qo:$o,function(e){return Yo[e]||n[e]||e})}function Zr(e,t){return(e=Et.trim(e))?e.split(t||" "):[]}function eo(e,t){var n=ti(e," ",ti(e.toUpperCase()," "));return ri(n,t)}function to(e){return eo("td th li dt dd figcaption caption details summary",e.getTextBlockElements())}function no(e,n){var r;return e&&(r={},ni(e="string"==typeof e?{"*":e}:e,function(e,t){r[t]=r[t.toUpperCase()]=("map"===n?ti:oi)(e,/[, ]/)})),r}function ro(i){function e(e,t,n){var r=i[e];return r?r=ti(r,/[, ]/,ti(r.toUpperCase(),/[, ]/)):(r=Zo[e])||(r=eo(t,n),Zo[e]=r),r}var t,s,n,r,o,a,u,c,S={},l={},E=[],f={},d={},m=(t=(i=i||{}).schema,c={},Zo[t]||(s="id accesskey class dir lang style tabindex title role",n="address blockquote div dl fieldset form h1 h2 h3 h4 h5 h6 hr menu ol p pre table ul",r="a abbr b bdo br button cite code del dfn em embed i iframe img input ins kbd label map noscript object q s samp script select small span strong sub sup textarea u var #text #comment","html4"!==t&&(s+=" contenteditable contextmenu draggable dropzone hidden spellcheck translate",n+=" article aside details dialog figure main header footer hgroup section nav",r+=" audio canvas command datalist mark meter output picture progress time wbr video ruby bdi keygen"),"html5-strict"!==t&&(s+=" xml:lang",r=[r,u="acronym applet basefont big font strike tt"].join(" "),ni(Zr(u),function(e){g(e,"",r)}),n=[n,a="center dir isindex noframes"].join(" "),o=[n,r].join(" "),ni(Zr(a),function(e){g(e,"",o)})),o=o||[n,r].join(" "),g("html","manifest","head body"),g("head","","base command link meta noscript script style title"),g("title hr noscript br"),g("base","href target"),g("link","href rel media hreflang type sizes hreflang"),g("meta","name http-equiv content charset"),g("style","media type scoped"),g("script","src async defer type charset"),g("body","onafterprint onbeforeprint onbeforeunload onblur onerror onfocus onhashchange onload onmessage onoffline ononline onpagehide onpageshow onpopstate onresize onscroll onstorage onunload",o),g("address dt dd div caption","",o),g("h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn","",r),g("blockquote","cite",o),g("ol","reversed start type","li"),g("ul","","li"),g("li","value",o),g("dl","","dt dd"),g("a","href target rel media hreflang type",r),g("q","cite",r),g("ins del","cite datetime",o),g("img","src sizes srcset alt usemap ismap width height"),g("iframe","src name width height",o),g("embed","src type width height"),g("object","data type typemustmatch name usemap form width height",[o,"param"].join(" ")),g("param","name value"),g("map","name",[o,"area"].join(" ")),g("area","alt coords shape href target rel media hreflang type"),g("table","border","caption colgroup thead tfoot tbody tr"+("html4"===t?" col":"")),g("colgroup","span","col"),g("col","span"),g("tbody thead tfoot","","tr"),g("tr","","td th"),g("td","colspan rowspan headers",o),g("th","colspan rowspan headers scope abbr",o),g("form","accept-charset action autocomplete enctype method name novalidate target",o),g("fieldset","disabled form name",[o,"legend"].join(" ")),g("label","form for",r),g("input","accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate formtarget height list max maxlength min multiple name pattern readonly required size src step type value width"),g("button","disabled form formaction formenctype formmethod formnovalidate formtarget name type value","html4"===t?o:r),g("select","disabled form multiple name required size","option optgroup"),g("optgroup","disabled label","option"),g("option","disabled label selected value"),g("textarea","cols dirname disabled form maxlength name readonly required rows wrap"),g("menu","type label",[o,"li"].join(" ")),g("noscript","",o),"html4"!==t&&(g("wbr"),g("ruby","",[r,"rt rp"].join(" ")),g("figcaption","",o),g("mark rt rp summary bdi","",r),g("canvas","width height",o),g("video","src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered",[o,"track source"].join(" ")),g("audio","src crossorigin preload autoplay mediagroup loop muted controls buffered volume",[o,"track source"].join(" ")),g("picture","","img source"),g("source","src srcset type media sizes"),g("track","kind src srclang label default"),g("datalist","",[r,"option"].join(" ")),g("article section nav aside main header footer","",o),g("hgroup","","h1 h2 h3 h4 h5 h6"),g("figure","",[o,"figcaption"].join(" ")),g("time","datetime",r),g("dialog","open",o),g("command","type label icon disabled checked radiogroup command"),g("output","for form name",r),g("progress","value max",r),g("meter","value min max low high optimum",r),g("details","open",[o,"summary"].join(" ")),g("keygen","autofocus challenge disabled form keytype name")),"html5-strict"!==t&&(p("script","language xml:space"),p("style","xml:space"),p("object","declare classid code codebase codetype archive standby align border hspace vspace"),p("embed","align name hspace vspace"),p("param","valuetype type"),p("a","charset name rev shape coords"),p("br","clear"),p("applet","codebase archive code object alt name width height align hspace vspace"),p("img","name longdesc align border hspace vspace"),p("iframe","longdesc frameborder marginwidth marginheight scrolling align"),p("font basefont","size color face"),p("input","usemap align"),p("select"),p("textarea"),p("h1 h2 h3 h4 h5 h6 div p legend caption","align"),p("ul","type compact"),p("li","type"),p("ol dl menu dir","compact"),p("pre","width xml:space"),p("hr","align noshade size width"),p("isindex","prompt"),p("table","summary width frame rules cellspacing cellpadding align bgcolor"),p("col","width align char charoff valign"),p("colgroup","width align char charoff valign"),p("thead","align char charoff valign"),p("tr","align char charoff valign bgcolor"),p("th","axis align char charoff valign nowrap bgcolor width height"),p("form","accept"),p("td","abbr axis scope align char charoff valign nowrap bgcolor width height"),p("tfoot","align char charoff valign"),p("tbody","align char charoff valign"),p("area","nohref"),p("body","background bgcolor text link vlink alink")),"html4"!==t&&(p("input button select textarea","autofocus"),p("input textarea","placeholder"),p("a","download"),p("link script img","crossorigin"),p("img","loading"),p("iframe","sandbox seamless allowfullscreen loading")),ni(Zr("a form meter progress dfn"),function(e){c[e]&&delete c[e].children[e]}),delete c.caption.children.table,delete c.script,Zo[t]=c));function g(e,t,n){function r(e,t){for(var n={},r=0,o=e.length;r<o;r++)n[e[r]]=t||{};return n}var o,i;t=t||"","string"==typeof(n=n||[])&&(n=Zr(n));for(var a=Zr(e),u=a.length;u--;)i={attributes:r(o=Zr([s,t].join(" "))),attributesOrder:o,children:r(n,ei)},c[a[u]]=i}function p(e,t){for(var n,r,o,i=Zr(e),a=i.length,u=Zr(t);a--;)for(n=c[i[a]],r=0,o=u.length;r<o;r++)n.attributes[u[r]]={},n.attributesOrder.push(u[r])}!1===i.verify_html&&(i.valid_elements="*[*]");var h=no(i.valid_styles),v=no(i.invalid_styles,"map"),b=no(i.valid_classes,"map"),y=e("whitespace_elements","pre script noscript style textarea video audio iframe object code"),C=e("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr"),x=e("short_ended_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr track"),w=e("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls"),k="td th iframe video audio object script code",N=e("non_empty_elements",k+" pre",x),_=e("move_caret_before_on_enter_elements",k+" table",x),A=e("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside main nav figure"),R=e("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex option datalist select optgroup figcaption details summary",A),D=e("text_inline_elements","span strong b em i font s strike u var cite dfn code mark q sup sub samp");function T(e){return new RegExp("^"+e.replace(/([?+*])/g,".$1")+"$")}function O(e){var t,n,r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,b,y=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)])?$/,C=/^([!\-])?(\w+[\\:]:\w+|[^=:<]+)?(?:([=:<])(.*))?$/,x=/[*?+]/;if(e){var w=Zr(e,",");for(S["@"]&&(h=S["@"].attributes,v=S["@"].attributesOrder),t=0,n=w.length;t<n;t++)if(i=y.exec(w[t])){if(g=i[1],c=i[2],p=i[3],s=i[5],a={attributes:d={},attributesOrder:m=[]},"#"===g&&(a.paddEmpty=!0),"-"===g&&(a.removeEmpty=!0),"!"===i[4]&&(a.removeEmptyAttrs=!0),h&&(ne(h,function(e,t){d[t]=e}),m.push.apply(m,v)),s)for(r=0,o=(s=Zr(s,"|")).length;r<o;r++)(i=C.exec(s[r]))&&(u={},f=i[1],l=i[2].replace(/[\\:]:/g,":"),g=i[3],b=i[4],"!"===f&&(a.attributesRequired=a.attributesRequired||[],a.attributesRequired.push(l),u.required=!0),"-"!==f?(g&&("="===g&&(a.attributesDefault=a.attributesDefault||[],a.attributesDefault.push({name:l,value:b}),u.defaultValue=b),":"===g&&(a.attributesForced=a.attributesForced||[],a.attributesForced.push({name:l,value:b}),u.forcedValue=b),"<"===g&&(u.validValues=ti(b,"?"))),x.test(l)?(a.attributePatterns=a.attributePatterns||[],u.pattern=T(l),a.attributePatterns.push(u)):(d[l]||m.push(l),d[l]=u)):(delete d[l],m.splice(ii(m,l),1)));h||"@"!==c||(h=d,v=m),p&&(a.outputName=c,S[p]=a),x.test(c)?(a.pattern=T(c),E.push(a)):S[c]=a}}}function B(e){S={},E=[],O(e),ni(m,function(e,t){l[t]=e.children})}function P(e){var a=/^(~)?(.+)$/;e&&(Zo.text_block_elements=Zo.block_elements=null,ni(Zr(e,","),function(e){var t,n=a.exec(e),r="~"===n[1],o=r?"span":"div",i=n[2];l[i]=l[o],f[i]=o,r||(R[i.toUpperCase()]={},R[i]={}),S[i]||(t=S[o],delete(t=ri({},t)).removeEmptyAttrs,delete t.removeEmpty,S[i]=t),ni(l,function(e,t){e[o]&&(l[t]=e=ri({},l[t]),e[i]=e[o])})}))}function L(e){var o=/^([+\-]?)([A-Za-z0-9_\-.\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd]+)\[([^\]]+)]$/;Zo[i.schema]=null,e&&ni(Zr(e,","),function(e){var t,n,r=o.exec(e);r&&(n=r[1],t=n?l[r[2]]:l[r[2]]={"#comment":{}},t=l[r[2]],ni(Zr(r[3],"|"),function(e){"-"===n?delete t[e]:t[e]={}}))})}function I(e){var t,n=S[e];if(n)return n;for(t=E.length;t--;)if((n=E[t]).pattern.test(e))return n}ni((i.special||"script noscript iframe noframes noembed title style textarea xmp").split(" "),function(e){d[e]=new RegExp("</"+e+"[^>]*>","gi")}),i.valid_elements?B(i.valid_elements):(ni(m,function(e,t){S[t]={attributes:e.attributes,attributesOrder:e.attributesOrder},l[t]=e.children}),"html5"!==i.schema&&ni(Zr("strong/b em/i"),function(e){var t=Zr(e,"/");S[t[1]].outputName=t[0]}),ni(D,function(e,t){S[t]&&(i.padd_empty_block_inline_children&&(S[t].paddInEmptyBlock=!0),S[t].removeEmpty=!0)}),ni(Zr("ol ul blockquote a table tbody"),function(e){S[e]&&(S[e].removeEmpty=!0)}),ni(Zr("p h1 h2 h3 h4 h5 h6 th td pre div address caption li"),function(e){S[e].paddEmpty=!0}),ni(Zr("span"),function(e){S[e].removeEmptyAttrs=!0})),P(i.custom_elements),L(i.valid_children),O(i.extended_valid_elements),L("+ol[ul|ol],+ul[ul|ol]"),ni({dd:"dl",dt:"dl",li:"ul ol",td:"tr",th:"tr",tr:"tbody thead tfoot",tbody:"table",thead:"table",tfoot:"table",legend:"fieldset",area:"map",param:"video audio object"},function(e,t){S[t]&&(S[t].parentsRequired=Zr(e))}),i.invalid_elements&&ni(oi(i.invalid_elements),function(e){S[e]&&delete S[e]}),I("span")||O("span[!data-mce-type|*]");var M=J(h),F=J(v),U=J(b),z=J(w),H=J(R),j=J(A),V=J(D),q=J(x),$=J(C),W=J(N),K=J(_),X=J(y),Y=J(d),G=J(f);return{children:l,elements:S,getValidStyles:M,getValidClasses:U,getBlockElements:H,getInvalidStyles:F,getShortEndedElements:q,getTextBlockElements:j,getTextInlineElements:V,getBoolAttrs:z,getElementRule:I,getSelfClosingElements:$,getNonEmptyElements:W,getMoveCaretBeforeOnEnterElements:K,getWhiteSpaceElements:X,getSpecialElements:Y,isValidChild:function(e,t){var n=l[e.toLowerCase()];return!(!n||!n[t.toLowerCase()])},isValid:function(e,t){var n,r,o=I(e);if(o){if(!t)return!0;if(o.attributes[t])return!0;if(n=o.attributePatterns)for(r=n.length;r--;)if(n[r].pattern.test(e))return!0}return!1},getCustomElements:G,addValidElements:O,setValidElements:B,addCustomElements:P,addValidChildren:L}}function oo(e,t,n,r){function o(e){return 1<(e=parseInt(e,10).toString(16)).length?e:"0"+e}return"#"+o(t)+o(n)+o(r)}function io(b,e){var u,o,y=this,C=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,x=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,w=/\s*([^:]+):\s*([^;]+);?/g,S=/\s+$/,E={},k=Co;b=b||{},e&&(u=e.getValidStyles(),o=e.getInvalidStyles());for(var t=("\\\" \\' \\; \\: ; : "+k).split(" "),N=0;N<t.length;N++)E[t[N]]=k+N,E[k+N]=t[N];return{toHex:function(e){return e.replace(C,oo)},parse:function(e){function t(e,t,n){var r=p[e+"-top"+t];if(r){var o=p[e+"-right"+t];if(o){var i=p[e+"-bottom"+t];if(i){var a=p[e+"-left"+t];if(a){var u=[r,o,i,a];for(N=u.length-1;N--&&u[N]===u[N+1];);-1<N&&n||(p[e+t]=-1===N?u[0]:u.join(" "),delete p[e+"-top"+t],delete p[e+"-right"+t],delete p[e+"-bottom"+t],delete p[e+"-left"+t])}}}}}function n(e){var t,n=p[e];if(n){for(t=(n=n.split(" ")).length;t--;)if(n[t]!==n[0])return;return p[e]=n[0],1}}function r(e){return f=!0,E[e]}function u(e,t){return f&&(e=e.replace(/\uFEFF[0-9]/g,function(e){return E[e]})),t?e:e.replace(/\\([\'\";:])/g,"$1")}function o(e){return String.fromCharCode(parseInt(e.slice(1),16))}function i(e){return e.replace(/\\[0-9a-f]+/gi,o)}function a(e,t,n,r,o,i){if(o=o||i)return"'"+(o=u(o)).replace(/\'/g,"\\'")+"'";if(t=u(t||n||r),!b.allow_script_urls){var a=t.replace(/[\s\r\n]+/g,"");if(/(java|vb)script:/i.test(a))return"";if(!b.allow_svg_data_urls&&/^data:image\/svg/i.test(a))return""}return"url('"+(t=h?h.call(v,t,"style"):t).replace(/\'/g,"\\'")+"')"}var s,c,l,f,d,m,g,p={},h=b.url_converter,v=b.url_converter_scope||y;if(e){for(e=(e=e.replace(/[\u0000-\u001F]/g,"")).replace(/\\[\"\';:\uFEFF]/g,r).replace(/\"[^\"]+\"|\'[^\']+\'/g,function(e){return e.replace(/[;:]/g,r)});s=w.exec(e);)w.lastIndex=s.index+s[0].length,c=s[1].replace(S,"").toLowerCase(),l=s[2].replace(S,""),c&&l&&(c=i(c),l=i(l),-1===c.indexOf(k)&&-1===c.indexOf('"')&&(b.allow_script_urls||"behavior"!==c&&!/expression\s*\(|\/\*|\*\//.test(l))&&("font-weight"===c&&"700"===l?l="bold":"color"!==c&&"background-color"!==c||(l=l.toLowerCase()),l=(l=l.replace(C,oo)).replace(x,a),p[c]=f?u(l,!0):l));t("border","",!0),t("border","-width"),t("border","-color"),t("border","-style"),t("padding",""),t("margin",""),m="border-style",g="border-color",n(d="border-width")&&n(m)&&n(g)&&(p.border=p[d]+" "+p[m]+" "+p[g],delete p[d],delete p[m],delete p[g]),"medium none"===p.border&&delete p.border,"none"===p["border-image"]&&delete p["border-image"]}return p},serialize:function(i,r){function e(e){var t,n=u[e];if(n)for(var r=0,o=n.length;r<o;r++)e=n[r],(t=i[e])&&(a+=(0<a.length?" ":"")+e+": "+t+";")}var a="";return r&&u?(e("*"),e(r)):ne(i,function(e,t){var n;!e||o&&((n=o["*"])&&n[t]||(n=o[r])&&n[t])||(a+=(0<a.length?" ":"")+t+": "+e+";")}),a}}}function ao(e){return e instanceof Event||y(e.initEvent)}function uo(e,t,n,r){var o,i,a=function(e){var t,n=null!=r?r:{};for(t in e)ke(ai,t)||(n[t]=e[t]);return V(n.composedPath)&&(n.composedPath=function(){return e.composedPath()}),n}(t);return a.type=e,K(a.target)&&(a.target=null!==(o=a.srcElement)&&void 0!==o?o:n),(K((i=t).preventDefault)||ao(i))&&(a.preventDefault=function(){a.defaultPrevented=!0,a.isDefaultPrevented=w,y(t.preventDefault)?t.preventDefault():ao(t)&&(t.returnValue=!1)},a.stopPropagation=function(){a.cancelBubble=!0,a.isPropagationStopped=w,y(t.stopPropagation)?t.stopPropagation():ao(t)&&(t.cancelBubble=!0)},a.stopImmediatePropagation=function(){a.isImmediatePropagationStopped=w,a.stopPropagation()},a.isDefaultPrevented!==w&&a.isDefaultPrevented!==D&&(a.isDefaultPrevented=!0===a.defaultPrevented?w:D,a.isPropagationStopped=!0===a.cancelBubble?w:D,a.isImmediatePropagationStopped=D)),a}function so(e,t,n,r){e.addEventListener?e.addEventListener(t,n,r||!1):e.attachEvent&&e.attachEvent("on"+t,n)}function co(e,t,n,r){e.removeEventListener?e.removeEventListener(t,n,r||!1):e.detachEvent&&e.detachEvent("on"+t,n)}function lo(e,t){var n,r,o,i,a=uo(e.type,e,document,t);return V(i=e)&&ui.test(i.type)&&b(e.pageX)&&!b(e.clientX)&&(r=(n=a.target.ownerDocument||document).documentElement,o=n.body,a.pageX=e.clientX+(r&&r.scrollLeft||o&&o.scrollLeft||0)-(r&&r.clientLeft||o&&o.clientLeft||0),a.pageY=e.clientY+(r&&r.scrollTop||o&&o.scrollTop||0)-(r&&r.clientTop||o&&o.clientTop||0)),b(a.metaKey)&&(a.metaKey=!1),a}var fo=Tr(["h1","h2","h3","h4","h5","h6"]),mo=Tr(["article","aside","details","div","dt","figcaption","footer","form","fieldset","header","hgroup","html","main","nav","section","summary","body","p","dl","multicol","dd","figure","address","center","blockquote","h1","h2","h3","h4","h5","h6","listing","xmp","pre","plaintext","menu","dir","ul","ol","li","hr","table","tbody","thead","tfoot","th","tr","td","caption"]),go=Tr(["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"]),po=Tr(["ul","ol","dl"]),ho=Tr(["li","dd","dt"]),vo=Tr(["thead","tbody","tfoot"]),bo=Tr(["td","th"]),yo=Tr(["pre","script","textarea","style"]),Co="\ufeff",xo="\xa0",wo=Co,So=function(e){return e===Co},Eo=function(e){return e.replace(/\uFEFF/g,"")},ko=zn,No=jn,_o=function(e){return No(e)&&e.data[0]===wo},Ao=function(e){return No(e)&&e.data[e.data.length-1]===wo},Ro=Xn,Do=Yn,To=Wn,Oo=jn,Bo=on(["script","style","textarea"]),Po=on(["img","input","textarea","hr","iframe","video","audio","object","embed"]),Lo=on(["table"]),Io=Ir,Mo=function(e){return!1===(zn(t=e)&&"true"===t.getAttribute("unselectable"))&&Do(e);var t},Fo=/^[ \t\r\n]*$/,Uo=un("data-mce-bookmark"),zo=un("data-mce-bogus"),Ho=function(e){return zn(e)&&"all"===e.getAttribute("data-mce-bogus")},jo=function(e,t,n){var r=n||t;if(zn(t)&&Xr(t))return t;for(var o,i,a,u,s,c,l,f,d,m,g,p=t.childNodes,h=p.length-1;0<=h;h--)jo(e,p[h],r);return!zn(t)||1===(o=t.childNodes).length&&Xr(o[0])&&t.parentNode.insertBefore(o[0],t),$n(a=t)||qn(a)||$r(t,r)||zn(i=t)&&0<i.childNodes.length||(s=r,jn(u=t)&&0<u.data.length&&(f=new Rr(c=u,l=s).prev(!1),d=new Rr(c,l).next(!1),m=b(f)||Kr(f,l),g=b(d)||Kr(d,l),m&&g))||e.remove(t),t},Vo=Et.makeMap,qo=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,$o=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Wo=/[<>&\"\']/g,Ko=/&#([a-z0-9]+);?|&([a-z0-9]+);/gi,Xo={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"},Yo={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},Go={"<":"<",">":">","&":"&",""":'"',"'":"'"},Jo=Yr("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32),Qo={encodeRaw:Gr,encodeAllRaw:function(e){return(""+e).replace(Wo,function(e){return Yo[e]||e})},encodeNumeric:Jr,encodeNamed:Qr,getEncodeFunc:function(e,t){var n=Yr(t)||Jo,r=Vo(e.replace(/\+/g,","));return r.named&&r.numeric?function(e,t){return e.replace(t?qo:$o,function(e){return void 0!==Yo[e]?Yo[e]:void 0!==n[e]?n[e]:1<e.length?"&#"+(1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536)+";":"&#"+e.charCodeAt(0)+";"})}:r.named?t?function(e,t){return Qr(e,t,n)}:Qr:r.numeric?Jr:Gr},decode:function(e){return e.replace(Ko,function(e,t){return t?65535<(t="x"===t.charAt(0).toLowerCase()?parseInt(t.substr(1),16):parseInt(t,10))?(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t))):Xo[t]||String.fromCharCode(t):Go[e]||Jo[e]||(n=e,(r=kt.fromTag("div").dom).innerHTML=n,r.textContent||r.innerText||n);var n,r})}},Zo={},ei={},ti=Et.makeMap,ni=Et.each,ri=Et.extend,oi=Et.explode,ii=Et.inArray,ai={keyLocation:!0,layerX:!0,layerY:!0,returnValue:!0,webkitMovementX:!0,webkitMovementY:!0,keyIdentifier:!0,mozPressure:!0},ui=/^(?:mouse|contextmenu)|click/,si=(ci.prototype.bind=function(e,t,n,r){function o(e){f.executeHandlers(lo(e||d.event),i)}var i,a,u,s,c,l,f=this,d=window;if(e&&3!==e.nodeType&&8!==e.nodeType){e[f.expando]?i=e[f.expando]:(i=f.count++,e[f.expando]=i,f.events[i]={}),r=r||e;for(var m=t.split(" "),g=m.length;g--;)c=o,s=l=!1,"DOMContentLoaded"===(u=m[g])&&(u="ready"),f.domLoaded&&"ready"===u&&"complete"===e.readyState?n.call(r,lo({type:u})):(f.hasMouseEnterLeave||(s=f.mouseEnterLeave[u])&&(c=function(e){var t=e.currentTarget,n=e.relatedTarget;if(n&&t.contains)n=t.contains(n);else for(;n&&n!==t;)n=n.parentNode;n||((e=lo(e||d.event)).type="mouseout"===e.type?"mouseleave":"mouseenter",e.target=t,f.executeHandlers(e,i))}),f.hasFocusIn||"focusin"!==u&&"focusout"!==u||(l=!0,s="focusin"===u?"focus":"blur",c=function(e){(e=lo(e||d.event)).type="focus"===e.type?"focusin":"focusout",f.executeHandlers(e,i)}),(a=f.events[i][u])?"ready"===u&&f.domLoaded?n(lo({type:u})):a.push({func:n,scope:r}):(f.events[i][u]=a=[{func:n,scope:r}],a.fakeName=s,a.capture=l,a.nativeHandler=c,"ready"===u?function(e,t,n){var r,o=e.document,i={type:"ready"};n.domLoaded?t(i):(r=function(){co(e,"DOMContentLoaded",r),co(e,"load",r),n.domLoaded||(n.domLoaded=!0,t(i)),e=null},"complete"===o.readyState||"interactive"===o.readyState&&o.body?r():so(e,"DOMContentLoaded",r),n.domLoaded||so(e,"load",r))}(e,c,f):so(e,s||u,c,l)));return e=a=null,n}},ci.prototype.unbind=function(n,e,t){var r,o,i;if(!n||3===n.nodeType||8===n.nodeType)return this;var a=n[this.expando];if(a){if(i=this.events[a],e){for(var u,s,c,l,f=e.split(" "),d=f.length;d--;)if(l=i[o=f[d]]){if(t)for(r=l.length;r--;)l[r].func===t&&(u=l.nativeHandler,s=l.fakeName,c=l.capture,(l=l.slice(0,r).concat(l.slice(r+1))).nativeHandler=u,l.fakeName=s,l.capture=c,i[o]=l);t&&0!==l.length||(delete i[o],co(n,l.fakeName||o,l.nativeHandler,l.capture))}}else ne(i,function(e,t){co(n,e.fakeName||t,e.nativeHandler,e.capture)}),i={};for(o in i)if(ke(i,o))return this;delete this.events[a];try{delete n[this.expando]}catch(e){n[this.expando]=null}}return this},ci.prototype.fire=function(e,t,n){var r;if(!e||3===e.nodeType||8===e.nodeType)return this;for(var o=lo({type:t,target:e},n);(r=e[this.expando])&&this.executeHandlers(o,r),(e=e.parentNode||e.ownerDocument||e.defaultView||e.parentWindow)&&!o.isPropagationStopped(););return this},ci.prototype.clean=function(e){var t,n;if(!e||3===e.nodeType||8===e.nodeType)return this;if(e[this.expando]&&this.unbind(e),(e=e.getElementsByTagName?e:e.document)&&e.getElementsByTagName)for(this.unbind(e),t=(n=e.getElementsByTagName("*")).length;t--;)(e=n[t])[this.expando]&&this.unbind(e);return this},ci.prototype.destroy=function(){this.events={}},ci.prototype.cancel=function(e){return e&&(e.preventDefault(),e.stopImmediatePropagation()),!1},ci.prototype.executeHandlers=function(e,t){var n=this.events[t],r=n&&n[e.type];if(r)for(var o=0,i=r.length;o<i;o++){var a=r[o];if(a&&!1===a.func.call(a.scope,e)&&e.preventDefault(),e.isImmediatePropagationStopped())return}},ci.Event=new ci,ci);function ci(){this.domLoaded=!1,this.events={},this.count=1,this.expando="mce-data-"+(+new Date).toString(32),this.hasMouseEnterLeave="onmouseenter"in document.documentElement,this.hasFocusIn="onfocusin"in document.documentElement,this.count=1}function li(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(65536+r):String.fromCharCode(r>>10|55296,1023&r|56320)}var fi,di,mi,gi,pi,hi,vi,bi,yi,Ci,xi,wi,Si,Ei,ki,Ni,_i,Ai="sizzle"+-new Date,Ri=window.document,Di=0,Ti=0,Oi=ca(),Bi=ca(),Pi=ca(),Li=function(e,t){return e===t&&(Ci=!0),0},Ii="undefined",Mi={}.hasOwnProperty,Fi=[],Ui=Fi.pop,zi=Fi.push,Hi=Fi.push,ji=Fi.slice,Vi=Fi.indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(this[t]===e)return t;return-1},qi="[\\x20\\t\\r\\n\\f]",$i="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",Wi="\\["+qi+"*("+$i+")(?:"+qi+"*([*^$|!~]?=)"+qi+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+$i+"))|)"+qi+"*\\]",Ki=":("+$i+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+Wi+")*)|.*)\\)|)",Xi=new RegExp("^"+qi+"+|((?:^|[^\\\\])(?:\\\\.)*)"+qi+"+$","g"),Yi=new RegExp("^"+qi+"*,"+qi+"*"),Gi=new RegExp("^"+qi+"*([>+~]|"+qi+")"+qi+"*"),Ji=new RegExp("="+qi+"*([^\\]'\"]*?)"+qi+"*\\]","g"),Qi=new RegExp(Ki),Zi=new RegExp("^"+$i+"$"),ea={ID:new RegExp("^#("+$i+")"),CLASS:new RegExp("^\\.("+$i+")"),TAG:new RegExp("^("+$i+"|[*])"),ATTR:new RegExp("^"+Wi),PSEUDO:new RegExp("^"+Ki),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+qi+"*(even|odd|(([+-]|)(\\d*)n|)"+qi+"*(?:([+-]|)"+qi+"*(\\d+)|))"+qi+"*\\)|)","i"),bool:new RegExp("^(?:checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped)$","i"),needsContext:new RegExp("^"+qi+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+qi+"*((?:-\\d)?\\d*)"+qi+"*\\)|)(?=[^-]|$)","i")},ta=/^(?:input|select|textarea|button)$/i,na=/^h\d$/i,ra=/^[^{]+\{\s*\[native \w/,oa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ia=/[+~]/,aa=/'|\\/g,ua=new RegExp("\\\\([\\da-f]{1,6}"+qi+"?|("+qi+")|.)","ig");try{Hi.apply(Fi=ji.call(Ri.childNodes),Ri.childNodes),Fi[Ri.childNodes.length].nodeType}catch(e){Hi={apply:Fi.length?function(e,t){zi.apply(e,ji.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}var sa=function(e,t,n,r){var o,i,a,u,s,c,l,f,d,m;if((t?t.ownerDocument||t:Ri)!==wi&&xi(t),n=n||[],!e||"string"!=typeof e)return n;if(1!==(u=(t=t||wi).nodeType)&&9!==u)return[];if(Ei&&!r){if(o=oa.exec(e))if(a=o[1]){if(9===u){if(!(i=t.getElementById(a))||!i.parentNode)return n;if(i.id===a)return n.push(i),n}else if(t.ownerDocument&&(i=t.ownerDocument.getElementById(a))&&_i(t,i)&&i.id===a)return n.push(i),n}else{if(o[2])return Hi.apply(n,t.getElementsByTagName(e)),n;if((a=o[3])&&fi.getElementsByClassName)return Hi.apply(n,t.getElementsByClassName(a)),n}if(fi.qsa&&(!ki||!ki.test(e))){if(f=l=Ai,d=t,m=9===u&&e,1===u&&"object"!==t.nodeName.toLowerCase()){for(c=pi(e),(l=t.getAttribute("id"))?f=l.replace(aa,"\\$&"):t.setAttribute("id",f),f="[id='"+f+"'] ",s=c.length;s--;)c[s]=f+pa(c[s]);d=ia.test(e)&&ma(t.parentNode)||t,m=c.join(",")}if(m)try{return Hi.apply(n,d.querySelectorAll(m)),n}catch(e){}finally{l||t.removeAttribute("id")}}}return vi(e.replace(Xi,"$1"),t,n,r)};function ca(){var n=[];function r(e,t){return n.push(e+" ")>di.cacheLength&&delete r[n.shift()],r[e+" "]=t}return r}function la(e){return e[Ai]=!0,e}function fa(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||1<<31)-(~e.sourceIndex||1<<31);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function da(a){return la(function(i){return i=+i,la(function(e,t){for(var n,r=a([],e.length,i),o=r.length;o--;)e[n=r[o]]&&(e[n]=!(t[n]=e[n]))})})}function ma(e){return e&&typeof e.getElementsByTagName!=Ii&&e}function ga(){}function pa(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function ha(a,e,t){var u=e.dir,s=t&&"parentNode"===u,c=Ti++;return e.first?function(e,t,n){for(;e=e[u];)if(1===e.nodeType||s)return a(e,t,n)}:function(e,t,n){var r,o,i=[Di,c];if(n){for(;e=e[u];)if((1===e.nodeType||s)&&a(e,t,n))return!0}else for(;e=e[u];)if(1===e.nodeType||s){if((r=(o=e[Ai]||(e[Ai]={}))[u])&&r[0]===Di&&r[1]===c)return i[2]=r[2];if((o[u]=i)[2]=a(e,t,n))return!0}}}function va(o){return 1<o.length?function(e,t,n){for(var r=o.length;r--;)if(!o[r](e,t,n))return!1;return!0}:o[0]}function ba(e,t,n,r,o){for(var i,a=[],u=0,s=e.length,c=null!=t;u<s;u++)(i=e[u])&&(n&&!n(i,r,o)||(a.push(i),c&&t.push(u)));return a}function ya(e){return void 0!==e}function Ca(e){return"string"==typeof e}function xa(e,t){var n,r=(t=t||Aa).createElement("div"),o=t.createDocumentFragment();for(r.innerHTML=e;n=r.firstChild;)o.appendChild(n);return o}function wa(e,t){return e&&t&&-1!==(" "+e.className+" ").indexOf(" "+t+" ")}function Sa(e,t,n){var r,o;return t=Xa(t)[0],e.each(function(){n&&r===this.parentNode||(r=this.parentNode,o=t.cloneNode(!1),this.parentNode.insertBefore(o,this)),o.appendChild(this)}),e}function Ea(e,t){return new Xa.fn.init(e,t)}function ka(e){return null==e?"":(""+e).replace(Ha,"")}function Na(e,t){var n,r,o,i;if(e)if(void 0===(n=e.length)){for(r in e)if(e.hasOwnProperty(r)&&(i=e[r],!1===t.call(i,r,i)))break}else for(o=0;o<n&&(i=e[o],!1!==t.call(i,o,i));o++);return e}function _a(e,n){var r=[];return Na(e,function(e,t){n(t,e)&&r.push(t)}),r}fi=sa.support={},gi=sa.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},xi=sa.setDocument=function(e){var t,s=e?e.ownerDocument||e:Ri,n=s.defaultView;return s!==wi&&9===s.nodeType&&s.documentElement?(Si=(wi=s).documentElement,Ei=!gi(s),n&&n!==function(e){try{return e.top}catch(e){}return null}(n)&&(n.addEventListener?n.addEventListener("unload",function(){xi()},!1):n.attachEvent&&n.attachEvent("onunload",function(){xi()})),fi.attributes=!0,fi.getElementsByTagName=!0,fi.getElementsByClassName=ra.test(s.getElementsByClassName),fi.getById=!0,di.find.ID=function(e,t){if(typeof t.getElementById!=Ii&&Ei){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},di.filter.ID=function(e){var t=e.replace(ua,li);return function(e){return e.getAttribute("id")===t}},di.find.TAG=fi.getElementsByTagName?function(e,t){if(typeof t.getElementsByTagName!=Ii)return t.getElementsByTagName(e)}:function(e,t){var n,r=[],o=0,i=t.getElementsByTagName(e);if("*"!==e)return i;for(;n=i[o++];)1===n.nodeType&&r.push(n);return r},di.find.CLASS=fi.getElementsByClassName&&function(e,t){if(Ei)return t.getElementsByClassName(e)},Ni=[],ki=[],fi.disconnectedMatch=!0,ki=ki.length&&new RegExp(ki.join("|")),Ni=Ni.length&&new RegExp(Ni.join("|")),t=ra.test(Si.compareDocumentPosition),_i=t||ra.test(Si.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},Li=t?function(e,t){return e===t?(Ci=!0,0):(n=!e.compareDocumentPosition-!t.compareDocumentPosition)||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!fi.sortDetached&&t.compareDocumentPosition(e)===n?e===s||e.ownerDocument===Ri&&_i(Ri,e)?-1:t===s||t.ownerDocument===Ri&&_i(Ri,t)?1:yi?Vi.call(yi,e)-Vi.call(yi,t):0:4&n?-1:1);var n}:function(e,t){if(e===t)return Ci=!0,0;var n,r=0,o=e.parentNode,i=t.parentNode,a=[e],u=[t];if(!o||!i)return e===s?-1:t===s?1:o?-1:i?1:yi?Vi.call(yi,e)-Vi.call(yi,t):0;if(o===i)return fa(e,t);for(n=e;n=n.parentNode;)a.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;a[r]===u[r];)r++;return r?fa(a[r],u[r]):a[r]===Ri?-1:u[r]===Ri?1:0},s):wi},sa.matches=function(e,t){return sa(e,null,null,t)},sa.matchesSelector=function(e,t){if((e.ownerDocument||e)!==wi&&xi(e),t=t.replace(Ji,"='$1']"),fi.matchesSelector&&Ei&&(!Ni||!Ni.test(t))&&(!ki||!ki.test(t)))try{var n=(void 0).call(e,t);if(n||fi.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){}return 0<sa(t,wi,null,[e]).length},sa.contains=function(e,t){return(e.ownerDocument||e)!==wi&&xi(e),_i(e,t)},sa.attr=function(e,t){(e.ownerDocument||e)!==wi&&xi(e);var n=di.attrHandle[t.toLowerCase()],r=n&&Mi.call(di.attrHandle,t.toLowerCase())?n(e,t,!Ei):void 0;return void 0!==r?r:fi.attributes||!Ei?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},sa.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},sa.uniqueSort=function(e){var t,n=[],r=0,o=0;if(Ci=!fi.detectDuplicates,yi=!fi.sortStable&&e.slice(0),e.sort(Li),Ci){for(;t=e[o++];)t===e[o]&&(r=n.push(o));for(;r--;)e.splice(n[r],1)}return yi=null,e},mi=sa.getText=function(e){var t,n="",r=0,o=e.nodeType;if(o){if(1===o||9===o||11===o){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=mi(e)}else if(3===o||4===o)return e.nodeValue}else for(;t=e[r++];)n+=mi(t);return n},(di=sa.selectors={cacheLength:50,createPseudo:la,match:ea,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(ua,li),e[3]=(e[3]||e[4]||e[5]||"").replace(ua,li),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||sa.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&sa.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return ea.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&Qi.test(n)&&(t=pi(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(ua,li).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=Oi[e+" "];return t||(t=new RegExp("(^|"+qi+")"+e+"("+qi+"|$)"))&&Oi(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!=Ii&&e.getAttribute("class")||"")})},ATTR:function(n,r,o){return function(e){var t=sa.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===o:"!="===r?t!==o:"^="===r?o&&0===t.indexOf(o):"*="===r?o&&-1<t.indexOf(o):"$="===r?o&&t.slice(-o.length)===o:"~="===r?-1<(" "+t+" ").indexOf(o):"|="===r&&(t===o||t.slice(0,o.length+1)===o+"-"))}},CHILD:function(m,e,t,g,p){var h="nth"!==m.slice(0,3),v="last"!==m.slice(-4),b="of-type"===e;return 1===g&&0===p?function(e){return!!e.parentNode}:function(e,t,n){var r,o,i,a,u,s,c=h!=v?"nextSibling":"previousSibling",l=e.parentNode,f=b&&e.nodeName.toLowerCase(),d=!n&&!b;if(l){if(h){for(;c;){for(i=e;i=i[c];)if(b?i.nodeName.toLowerCase()===f:1===i.nodeType)return!1;s=c="only"===m&&!s&&"nextSibling"}return!0}if(s=[v?l.firstChild:l.lastChild],v&&d){for(u=(r=(o=l[Ai]||(l[Ai]={}))[m]||[])[0]===Di&&r[1],a=r[0]===Di&&r[2],i=u&&l.childNodes[u];i=++u&&i&&i[c]||(a=u=0)||s.pop();)if(1===i.nodeType&&++a&&i===e){o[m]=[Di,u,a];break}}else if(d&&(r=(e[Ai]||(e[Ai]={}))[m])&&r[0]===Di)a=r[1];else for(;(i=++u&&i&&i[c]||(a=u=0)||s.pop())&&((b?i.nodeName.toLowerCase()!==f:1!==i.nodeType)||!++a||(d&&((i[Ai]||(i[Ai]={}))[m]=[Di,a]),i!==e)););return(a-=p)===g||a%g==0&&0<=a/g}}},PSEUDO:function(e,i){var t,a=di.pseudos[e]||di.setFilters[e.toLowerCase()]||sa.error("unsupported pseudo: "+e);return a[Ai]?a(i):1<a.length?(t=[e,e,"",i],di.setFilters.hasOwnProperty(e.toLowerCase())?la(function(e,t){for(var n,r=a(e,i),o=r.length;o--;)e[n=Vi.call(e,r[o])]=!(t[n]=r[o])}):function(e){return a(e,0,t)}):a}},pseudos:{not:la(function(e){var r=[],o=[],u=hi(e.replace(Xi,"$1"));return u[Ai]?la(function(e,t,n,r){for(var o,i=u(e,null,r,[]),a=e.length;a--;)(o=i[a])&&(e[a]=!(t[a]=o))}):function(e,t,n){return r[0]=e,u(r,null,n,o),r[0]=null,!o.pop()}}),has:la(function(t){return function(e){return 0<sa(t,e).length}}),contains:la(function(t){return t=t.replace(ua,li),function(e){return-1<(e.textContent||e.innerText||mi(e)).indexOf(t)}}),lang:la(function(n){return Zi.test(n||"")||sa.error("unsupported lang: "+n),n=n.replace(ua,li).toLowerCase(),function(e){var t;do{if(t=Ei?e.lang:e.getAttribute("xml:lang")||e.getAttribute("lang"))return(t=t.toLowerCase())===n||0===t.indexOf(n+"-")}while((e=e.parentNode)&&1===e.nodeType);return!1}}),target:function(e){var t=window.location&&window.location.hash;return t&&t.slice(1)===e.id},root:function(e){return e===Si},focus:function(e){return e===wi.activeElement&&(!wi.hasFocus||wi.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return!1===e.disabled},disabled:function(e){return!0===e.disabled},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!di.pseudos.empty(e)},header:function(e){return na.test(e.nodeName)},input:function(e){return ta.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:da(function(){return[0]}),last:da(function(e,t){return[t-1]}),eq:da(function(e,t,n){return[n<0?n+t:n]}),even:da(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:da(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:da(function(e,t,n){for(var r=n<0?n+t:n;0<=--r;)e.push(r);return e}),gt:da(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}}).pseudos.nth=di.pseudos.eq,Y(["radio","checkbox","file","password","image"],function(e){var t;di.pseudos[e]=(t=e,function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t})}),Y(["submit","reset"],function(e){var n;di.pseudos[e]=(n=e,function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n})}),ga.prototype=di.filters=di.pseudos,di.setFilters=new ga,pi=sa.tokenize=function(e,t){var n,r,o,i,a,u,s,c=Bi[e+" "];if(c)return t?0:c.slice(0);for(a=e,u=[],s=di.preFilter;a;){for(i in n&&!(r=Yi.exec(a))||(r&&(a=a.slice(r[0].length)||a),u.push(o=[])),n=!1,(r=Gi.exec(a))&&(n=r.shift(),o.push({value:n,type:r[0].replace(Xi," ")}),a=a.slice(n.length)),di.filter)di.filter.hasOwnProperty(i)&&(!(r=ea[i].exec(a))||s[i]&&!(r=s[i](r))||(n=r.shift(),o.push({value:n,type:i,matches:r}),a=a.slice(n.length)));if(!n)break}return t?a.length:a?sa.error(e):Bi(e,u).slice(0)},hi=sa.compile=function(e,t){var n,h,v,b,y,r=[],o=[],i=Pi[e+" "];if(!i){for(n=(t=t||pi(e)).length;n--;)((i=function e(t){for(var o,n,r,i=t.length,a=di.relative[t[0].type],u=a||di.relative[" "],s=a?1:0,c=ha(function(e){return e===o},u,!0),l=ha(function(e){return-1<Vi.call(o,e)},u,!0),f=[function(e,t,n){var r=!a&&(n||t!==bi)||((o=t).nodeType?c:l)(e,t,n);return o=null,r}];s<i;s++)if(n=di.relative[t[s].type])f=[ha(va(f),n)];else{if((n=di.filter[t[s].type].apply(null,t[s].matches))[Ai]){for(r=++s;r<i&&!di.relative[t[r].type];r++);return function e(m,g,p,h,v,t){return h&&!h[Ai]&&(h=e(h)),v&&!v[Ai]&&(v=e(v,t)),la(function(e,t,n,r){var o,i,a,u=[],s=[],c=t.length,l=e||function(e,t,n){for(var r=0,o=t.length;r<o;r++)sa(e,t[r],n);return n}(g||"*",n.nodeType?[n]:n,[]),f=!m||!e&&g?l:ba(l,u,m,n,r),d=p?v||(e?m:c||h)?[]:t:f;if(p&&p(f,d,n,r),h)for(o=ba(d,s),h(o,[],n,r),i=o.length;i--;)(a=o[i])&&(d[s[i]]=!(f[s[i]]=a));if(e){if(v||m){if(v){for(o=[],i=d.length;i--;)(a=d[i])&&o.push(f[i]=a);v(null,d=[],o,r)}for(i=d.length;i--;)(a=d[i])&&-1<(o=v?Vi.call(e,a):u[i])&&(e[o]=!(t[o]=a))}}else d=ba(d===t?d.splice(c,d.length):d),v?v(null,t,d,r):Hi.apply(t,d)})}(1<s&&va(f),1<s&&pa(t.slice(0,s-1).concat({value:" "===t[s-2].type?"*":""})).replace(Xi,"$1"),n,s<r&&e(t.slice(s,r)),r<i&&e(t=t.slice(r)),r<i&&pa(t))}f.push(n)}return va(f)}(t[n]))[Ai]?r:o).push(i);(i=Pi(e,(h=o,b=0<(v=r).length,y=0<h.length,b?la(a):a))).selector=e}function a(e,t,n,r,o){var i,a,u,s=0,c="0",l=e&&[],f=[],d=bi,m=e||y&&di.find.TAG("*",o),g=Di+=null==d?1:Math.random()||.1,p=m.length;for(o&&(bi=t!==wi&&t);c!==p&&null!=(i=m[c]);c++){if(y&&i){for(a=0;u=h[a++];)if(u(i,t,n)){r.push(i);break}o&&(Di=g)}b&&((i=!u&&i)&&s--,e&&l.push(i))}if(s+=c,b&&c!==s){for(a=0;u=v[a++];)u(l,f,t,n);if(e){if(0<s)for(;c--;)l[c]||f[c]||(f[c]=Ui.call(r));f=ba(f)}Hi.apply(r,f),o&&!e&&0<f.length&&1<s+v.length&&sa.uniqueSort(r)}return o&&(Di=g,bi=d),l}return i},vi=sa.select=function(e,t,n,r){var o,i,a,u,s,c="function"==typeof e&&e,l=!r&&pi(e=c.selector||e);if(n=n||[],1===l.length){if(2<(i=l[0]=l[0].slice(0)).length&&"ID"===(a=i[0]).type&&fi.getById&&9===t.nodeType&&Ei&&di.relative[i[1].type]){if(!(t=(di.find.ID(a.matches[0].replace(ua,li),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(i.shift().value.length)}for(o=ea.needsContext.test(e)?0:i.length;o--&&(a=i[o],!di.relative[u=a.type]);)if((s=di.find[u])&&(r=s(a.matches[0].replace(ua,li),ia.test(i[0].type)&&ma(t.parentNode)||t))){if(i.splice(o,1),!(e=r.length&&pa(i)))return Hi.apply(n,r),n;break}}return(c||hi(e,l))(r,t,!Ei,n,ia.test(e)&&ma(t.parentNode)||t),n},fi.sortStable=Ai.split("").sort(Li).join("")===Ai,fi.detectDuplicates=!!Ci,xi(),fi.sortDetached=!0;var Aa=document,Ra=Array.prototype.push,Da=Array.prototype.slice,Ta=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,Oa=si.Event,Ba=Et.makeMap("children,contents,next,prev"),Pa=function(e,t,n,r){var o;if(Ca(t))t=xa(t,ja(e[0]));else if(t.length&&!t.nodeType){if(t=Xa.makeArray(t),r)for(o=t.length-1;0<=o;o--)Pa(e,t[o],n,r);else for(o=0;o<t.length;o++)Pa(e,t[o],n,r);return e}if(t.nodeType)for(o=e.length;o--;)n.call(e[o],t);return e},La=Et.makeMap("fillOpacity fontWeight lineHeight opacity orphans widows zIndex zoom"," "),Ia=Et.makeMap("checked compact declare defer disabled ismap multiple nohref noshade nowrap readonly selected"," "),Ma={for:"htmlFor",class:"className",readonly:"readOnly"},Fa={float:"cssFloat"},Ua={},za={},Ha=/^\s*|\s*$/g,ja=function(e){return e?9===e.nodeType?e:e.ownerDocument:Aa};function Va(e,t,n){var r=[],o=e[t];for("string"!=typeof n&&n instanceof Xa&&(n=n[0]);o&&9!==o.nodeType;){if(void 0!==n){if(o===n)break;if("string"==typeof n&&Xa(o).is(n))break}1===o.nodeType&&r.push(o),o=o[t]}return r}function qa(e,t,n,r){var o=[];for(r instanceof Xa&&(r=r[0]);e;e=e[t])if(!n||e.nodeType===n){if(void 0!==r){if(e===r)break;if("string"==typeof r&&Xa(e).is(r))break}o.push(e)}return o}function $a(e,t,n){for(e=e[t];e;e=e[t])if(e.nodeType===n)return e;return null}function Wa(e,t){var n=t.attr("style"),r=e.serialize(e.parse(n),t[0].nodeName)||null;t.attr("data-mce-style",r)}function Ka(e,t){var n,r,o=0;if(e)for(n=e.nodeType,e=e.previousSibling;e;e=e.previousSibling)r=e.nodeType,(!t||3!==r||r!==n&&e.nodeValue.length)&&(o++,n=r);return o}Ea.fn=Ea.prototype={constructor:Ea,selector:"",context:null,length:0,init:function(e,t){var n,r,o=this;if(!e)return o;if(e.nodeType)return o.context=o[0]=e,o.length=1,o;if(t&&t.nodeType)o.context=t;else{if(t)return Xa(e).attr(t);o.context=t=document}if(Ca(e)){if(!(n="<"===(o.selector=e).charAt(0)&&">"===e.charAt(e.length-1)&&3<=e.length?[null,e,null]:Ta.exec(e)))return Xa(t).find(e);if(n[1])for(r=xa(e,ja(t)).firstChild;r;)Ra.call(o,r),r=r.nextSibling;else{if(!(r=ja(t).getElementById(n[2])))return o;if(r.id!==n[2])return o.find(e);o.length=1,o[0]=r}}else this.add(e,!1);return o},toArray:function(){return Et.toArray(this)},add:function(e,t){var n,r;if(Ca(e))return this.add(Xa(e));if(!1!==t)for(n=Xa.unique(this.toArray().concat(Xa.makeArray(e))),this.length=n.length,r=0;r<n.length;r++)this[r]=n[r];else Ra.apply(this,Xa.makeArray(e));return this},attr:function(t,n){var e,r=this;if("object"==typeof t)Na(t,function(e,t){r.attr(e,t)});else{if(!ya(n)){if(r[0]&&1===r[0].nodeType){if((e=Ua[t])&&e.get)return e.get(r[0],t);if(Ia[t])return r.prop(t)?t:void 0;null===(n=r[0].getAttribute(t,2))&&(n=void 0)}return n}this.each(function(){var e;1===this.nodeType&&((e=Ua[t])&&e.set?e.set(this,n):null===n?this.removeAttribute(t,2):this.setAttribute(t,n,2))})}return r},removeAttr:function(e){return this.attr(e,null)},prop:function(e,t){var n=this;if("object"==typeof(e=Ma[e]||e))Na(e,function(e,t){n.prop(e,t)});else{if(!ya(t))return n[0]&&n[0].nodeType&&e in n[0]?n[0][e]:t;this.each(function(){1===this.nodeType&&(this[e]=t)})}return n},css:function(t,n){function e(e){return e.replace(/-(\D)/g,function(e,t){return t.toUpperCase()})}function r(e){return e.replace(/[A-Z]/g,function(e){return"-"+e})}var o,i,a=this;if("object"==typeof t)Na(t,function(e,t){a.css(e,t)});else if(ya(n))t=e(t),"number"!=typeof n||La[t]||(n=n.toString()+"px"),a.each(function(){var e=this.style;if((i=za[t])&&i.set)i.set(this,n);else{try{this.style[Fa[t]||t]=n}catch(e){}null!==n&&""!==n||(e.removeProperty?e.removeProperty(r(t)):e.removeAttribute(t))}});else{if(o=a[0],(i=za[t])&&i.get)return i.get(o);if(!o.ownerDocument.defaultView)return o.currentStyle?o.currentStyle[e(t)]:"";try{return o.ownerDocument.defaultView.getComputedStyle(o,null).getPropertyValue(r(t))}catch(e){return}}return a},remove:function(){for(var e,t=this.length;t--;)e=this[t],Oa.clean(e),e.parentNode&&e.parentNode.removeChild(e);return this},empty:function(){for(var e,t=this.length;t--;)for(e=this[t];e.firstChild;)e.removeChild(e.firstChild);return this},html:function(t){var n;if(ya(t)){n=this.length;try{for(;n--;)this[n].innerHTML=t}catch(e){Xa(this[n]).empty().append(t)}return this}return this[0]?this[0].innerHTML:""},text:function(e){var t;if(ya(e)){for(t=this.length;t--;)"innerText"in this[t]?this[t].innerText=e:this[0].textContent=e;return this}return this[0]?this[0].innerText||this[0].textContent:""},append:function(){return Pa(this,arguments,function(e){(1===this.nodeType||this.host&&1===this.host.nodeType)&&this.appendChild(e)})},prepend:function(){return Pa(this,arguments,function(e){(1===this.nodeType||this.host&&1===this.host.nodeType)&&this.insertBefore(e,this.firstChild)},!0)},before:function(){return this[0]&&this[0].parentNode?Pa(this,arguments,function(e){this.parentNode.insertBefore(e,this)}):this},after:function(){return this[0]&&this[0].parentNode?Pa(this,arguments,function(e){this.parentNode.insertBefore(e,this.nextSibling)},!0):this},appendTo:function(e){return Xa(e).append(this),this},prependTo:function(e){return Xa(e).prepend(this),this},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){return Sa(this,e)},wrapAll:function(e){return Sa(this,e,!0)},wrapInner:function(e){return this.each(function(){Xa(this).contents().wrapAll(e)}),this},unwrap:function(){return this.parent().each(function(){Xa(this).replaceWith(this.childNodes)})},clone:function(){var e=[];return this.each(function(){e.push(this.cloneNode(!0))}),Xa(e)},addClass:function(e){return this.toggleClass(e,!0)},removeClass:function(e){return this.toggleClass(e,!1)},toggleClass:function(o,i){var e=this;return"string"!=typeof o||(-1!==o.indexOf(" ")?Na(o.split(" "),function(){e.toggleClass(this,i)}):e.each(function(e,t){var n,r=wa(t,o);r!==i&&(n=t.className,r?t.className=ka((" "+n+" ").replace(" "+o+" "," ")):t.className+=n?" "+o:o)})),e},hasClass:function(e){return wa(this[0],e)},each:function(e){return Na(this,e)},on:function(e,t){return this.each(function(){Oa.bind(this,e,t)})},off:function(e,t){return this.each(function(){Oa.unbind(this,e,t)})},trigger:function(e){return this.each(function(){"object"==typeof e?Oa.fire(this,e.type,e):Oa.fire(this,e)})},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},slice:function(){return Xa(Da.apply(this,arguments))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},find:function(e){for(var t=[],n=0,r=this.length;n<r;n++)Xa.find(e,this[n],t);return Xa(t)},filter:function(n){return Xa("function"==typeof n?_a(this.toArray(),function(e,t){return n(t,e)}):Xa.filter(n,this.toArray()))},closest:function(n){var r=[];return n instanceof Xa&&(n=n[0]),this.each(function(e,t){for(;t;){if("string"==typeof n&&Xa(t).is(n)){r.push(t);break}if(t===n){r.push(t);break}t=t.parentNode}}),Xa(r)},offset:function(e){var t,n,r,o,i=0,a=0;return e?this.css(e):((t=this[0])&&(r=(n=t.ownerDocument).documentElement,t.getBoundingClientRect&&(i=(o=t.getBoundingClientRect()).left+(r.scrollLeft||n.body.scrollLeft)-r.clientLeft,a=o.top+(r.scrollTop||n.body.scrollTop)-r.clientTop)),{left:i,top:a})},push:Ra,sort:Array.prototype.sort,splice:Array.prototype.splice},Et.extend(Ea,{extend:Et.extend,makeArray:function(e){return e&&e===e.window||e.nodeType?[e]:Et.toArray(e)},inArray:function(e,t){var n;if(t.indexOf)return t.indexOf(e);for(n=t.length;n--;)if(t[n]===e)return n;return-1},isArray:Et.isArray,each:Na,trim:ka,grep:_a,find:sa,expr:sa.selectors,unique:sa.uniqueSort,text:sa.getText,contains:sa.contains,filter:function(e,t,n){var r=t.length;for(n&&(e=":not("+e+")");r--;)1!==t[r].nodeType&&t.splice(r,1);return 1===t.length?Xa.find.matchesSelector(t[0],e)?[t[0]]:[]:Xa.find.matches(e,t)}}),Na({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return Va(e,"parentNode")},next:function(e){return $a(e,"nextSibling",1)},prev:function(e){return $a(e,"previousSibling",1)},children:function(e){return qa(e.firstChild,"nextSibling",1)},contents:function(e){return Et.toArray(("iframe"===e.nodeName?e.contentDocument||e.contentWindow.document:e).childNodes)}},function(r,o){Ea.fn[r]=function(t){var n=[];this.each(function(){var e=o.call(n,this,t,n);e&&(Xa.isArray(e)?n.push.apply(n,e):n.push(e))}),1<this.length&&(Ba[r]||(n=Xa.unique(n)),0===r.indexOf("parents")&&(n=n.reverse()));var e=Xa(n);return t?e.filter(t):e}}),Na({parentsUntil:function(e,t){return Va(e,"parentNode",t)},nextUntil:function(e,t){return qa(e,"nextSibling",1,t).slice(1)},prevUntil:function(e,t){return qa(e,"previousSibling",1,t).slice(1)}},function(o,i){Ea.fn[o]=function(t,e){var n=[];this.each(function(){var e=i.call(n,this,t,n);e&&(Xa.isArray(e)?n.push.apply(n,e):n.push(e))}),1<this.length&&(n=Xa.unique(n),0!==o.indexOf("parents")&&"prevUntil"!==o||(n=n.reverse()));var r=Xa(n);return e?r.filter(e):r}}),Ea.fn.is=function(e){return!!e&&0<this.filter(e).length},Ea.fn.init.prototype=Ea.fn,Ea.overrideDefaults=function(n){var r,o=function(e,t){return r=r||n(),0===arguments.length&&(e=r.element),t=t||r.context,new o.fn.init(e,t)};return Xa.extend(o,this),o},Ea.attrHooks=Ua,Ea.cssHooks=za;var Xa=Ea,Ya=Et.each,Ga=Et.grep,Ja=xt.ie,Qa=/^([a-z0-9],?)+$/i,Za=function(a,u){function s(e){return e&&a&&X(e)?a.getElementById(e):e}function c(e){return H("string"==typeof e?s(e):e)}function r(e,t,n){var r,o,i=c(e);return void 0===(o=i.length?(r=W[t])&&r.get?r.get(i,t):i.attr(t):o)?n||"":o}function o(e){var t=s(e);return t?t.attributes:[]}function i(e,t,n){""===n&&(n=null);var r,o=c(e),i=o.attr(t);o.length&&((r=W[t])&&r.set?r.set(o,n,t):o.attr(t,n),i!==n&&u.onSetAttrib&&u.onSetAttrib({attrElm:o,attrName:t,attrValue:n}))}function l(){return u.root_element||a.body}function f(e,t){return function(e,t,n){var r,o=0,i=0,a=e.ownerDocument;if(n=n||e,t){if(n===e&&t.getBoundingClientRect&&"static"===xn(kt.fromDom(e),"position")){var u=t.getBoundingClientRect();return{x:o=u.left+(a.documentElement.scrollLeft||e.scrollLeft)-a.documentElement.clientLeft,y:i=u.top+(a.documentElement.scrollTop||e.scrollTop)-a.documentElement.clientTop}}for(var s=t;s&&s!==n&&s.nodeType&&!kn(s,n);){var c=s;o+=c.offsetLeft||0,i+=c.offsetTop||0,s=c.offsetParent}for(s=t.parentNode;s&&s!==n&&s.nodeType&&!kn(s,n);)o-=s.scrollLeft||0,i-=s.scrollTop||0,s=s.parentNode;i+=(r=kt.fromDom(t),Zn.isFirefox()&&"table"===Nt(r)?En(Dn(r)).filter(function(e){return"caption"===Nt(e)}).bind(function(o){return En(It(o)).map(function(e){var t=e.dom.offsetTop,n=o.dom.offsetTop,r=o.dom.offsetHeight;return t<=n?-r:0})}).getOr(0):0)}return{x:o,y:i}}(a.body,s(e),t)}function d(e,t,n){var r=c(e);return n?r.css(t):("float"===(t=t.replace(/-(\D)/g,function(e,t){return t.toUpperCase()}))&&(t=xt.browser.isIE()?"styleFloat":"cssFloat"),r[0]&&r[0].style?r[0].style[t]:void 0)}function m(e){var t=d(e=s(e),"width"),n=d(e,"height");return-1===t.indexOf("px")&&(t=0),-1===n.indexOf("px")&&(n=0),{w:parseInt(t,10)||e.offsetWidth||e.clientWidth,h:parseInt(n,10)||e.offsetHeight||e.clientHeight}}function g(e,t){if(!e)return!1;if(!Array.isArray(e)){if("*"===t)return 1===e.nodeType;if(Qa.test(t)){for(var n=t.toLowerCase().split(/,/),r=e.nodeName.toLowerCase(),o=n.length-1;0<=o;o--)if(n[o]===r)return!0;return!1}if(e.nodeType&&1!==e.nodeType)return!1}var i=Array.isArray(e)?e:[e];return 0<sa(t,i[0].ownerDocument||i[0],null,i).length}function p(e,t,n,r){var o,i=[],a=s(e);for(r=void 0===r,n=n||("BODY"!==l().nodeName?l().parentNode:null),Et.is(t,"string")&&(t="*"===(o=t)?function(e){return 1===e.nodeType}:function(e){return g(e,o)});a&&!(a===n||K(a.nodeType)||qn(a)||$n(a));){if(!t||"function"==typeof t&&t(a)){if(!r)return[a];i.push(a)}a=a.parentNode}return r?i:null}function n(e,t,n){var r=t;if(e)for("string"==typeof t&&(r=function(e){return g(e,t)}),e=e[n];e;e=e[n])if("function"==typeof r&&r(e))return e;return null}function h(e,n,r){var o,t="string"==typeof e?s(e):e;return!!t&&(Et.isArray(t)&&(t.length||0===t.length)?(o=[],Ya(t,function(e,t){e&&o.push(n.call(r,"string"==typeof e?s(e):e,t))}),o):n.call(r||this,t))}function v(e,t){c(e).each(function(e,n){Ya(t,function(e,t){i(n,t,e)})})}function b(e,n){var t=c(e);Ja?t.each(function(e,t){if(!1!==t.canHaveHTML){for(;t.firstChild;)t.removeChild(t.firstChild);try{t.innerHTML="<br>"+n,t.removeChild(t.firstChild)}catch(e){Xa("<div></div>").html("<br>"+n).contents().slice(1).appendTo(t)}return n}}):t.html(n)}function y(e,n,r,o,i){return h(e,function(e){var t="string"==typeof n?a.createElement(n):n;return v(t,r),o&&("string"!=typeof o&&o.nodeType?t.appendChild(o):"string"==typeof o&&b(t,o)),i?t:e.appendChild(t)})}function C(e,t,n){return y(a.createElement(e),e,t,n,!0)}function x(e,t){var n=c(e);return(t?n.each(function(){for(var e;e=this.firstChild;)3===e.nodeType&&0===e.data.length?this.removeChild(e):this.parentNode.insertBefore(e,this)}):n).remove(),1<n.length?n.toArray():n[0]}function w(e,t,n){c(e).toggleClass(t,n).each(function(){""===this.className&&Xa(this).attr("class",null)})}function S(t,e,n){return h(e,function(e){return Et.is(e,"array")&&(t=t.cloneNode(!0)),n&&Ya(Ga(e.childNodes),function(e){t.appendChild(e)}),e.parentNode.replaceChild(t,e)})}function E(e){if(zn(e)){var t="a"===e.nodeName.toLowerCase()&&!r(e,"href")&&r(e,"id");return r(e,"name")||r(e,"data-mce-bookmark")||t?1:void 0}}function k(){return a.createRange()}function N(e){if(e&&zn(e)){var t=e.getAttribute("data-mce-contenteditable");return t&&"inherit"!==t?t:"inherit"!==e.contentEditable?e.contentEditable:null}return null}void 0===u&&(u={});var _,A,R,D,e,t,T={},O=window,B={},P=0,L=Ar.forElement(kt.fromDom(a),{contentCssCors:u.contentCssCors,referrerPolicy:u.referrerPolicy}),I=[],M=u.schema||ro({}),F=io({url_converter:u.url_converter,url_converter_scope:u.url_converter_scope},u.schema),U=u.ownEvents?new si:si.Event,z=M.getBlockElements(),H=Xa.overrideDefaults(function(){return{context:a,element:$.getRoot()}}),j=Qo.encodeAllRaw,V=function(e,t,n,r){if(Et.isArray(e)){for(var o=e.length,i=[];o--;)i[o]=V(e[o],t,n,r);return i}return!u.collect||e!==a&&e!==O||I.push([e,t,n,r]),U.bind(e,t,n,r||$)},q=function(e,t,n){if(Et.isArray(e)){for(var r=e.length,o=[];r--;)o[r]=q(e[r],t,n);return o}if(0<I.length&&(e===a||e===O))for(r=I.length;r--;){var i=I[r];e!==i[0]||t&&t!==i[1]||n&&n!==i[2]||U.unbind(i[0],i[1],i[2])}return U.unbind(e,t,n)},$={doc:a,settings:u,win:O,files:B,stdMode:!0,boxModel:!0,styleSheetLoader:L,boundEvents:I,styles:F,schema:M,events:U,isBlock:function(e){if("string"==typeof e)return!!z[e];if(e){var t=e.nodeType;if(t)return!(1!==t||!z[e.nodeName])}return!1},$:H,$$:c,root:null,clone:function(t,e){if(!Ja||1!==t.nodeType||e)return t.cloneNode(e);var n=a.createElement(t.nodeName);return Ya(o(t),function(e){i(n,e.nodeName,r(t,e.nodeName))}),n},getRoot:l,getViewPort:function(e){var t=tn(e);return{x:t.x,y:t.y,w:t.width,h:t.height}},getRect:function(e){var t=f(e=s(e)),n=m(e);return{x:t.x,y:t.y,w:n.w,h:n.h}},getSize:m,getParent:function(e,t,n){var r=p(e,t,n,!1);return r&&0<r.length?r[0]:null},getParents:p,get:s,getNext:function(e,t){return n(e,t,"nextSibling")},getPrev:function(e,t){return n(e,t,"previousSibling")},select:function(e,t){return sa(e,s(t)||u.root_element||a,[])},is:g,add:y,create:C,createHTML:function(e,t,n){var r,o="";for(r in o+="<"+e,t)se(t,r)&&(o+=" "+r+'="'+j(t[r])+'"');return void 0!==n?o+">"+n+"</"+e+">":o+" />"},createFragment:function(e){var t,n=a.createElement("div"),r=a.createDocumentFragment();for(r.appendChild(n),e&&(n.innerHTML=e);t=n.firstChild;)r.appendChild(t);return r.removeChild(n),r},remove:x,setStyle:function(e,t,n){var r=X(t)?c(e).css(t,n):c(e).css(t);u.update_styles&&Wa(F,r)},getStyle:d,setStyles:function(e,t){var n=c(e).css(t);u.update_styles&&Wa(F,n)},removeAllAttribs:function(e){return h(e,function(e){for(var t=e.attributes,n=t.length-1;0<=n;n--)e.removeAttributeNode(t.item(n))})},setAttrib:i,setAttribs:v,getAttrib:r,getPos:f,parseStyle:function(e){return F.parse(e)},serializeStyle:function(e,t){return F.serialize(e,t)},addStyle:function(e){var t,n;if($!==Za.DOM&&a===document){if(T[e])return;T[e]=!0}(n=a.getElementById("mceDefaultStyles"))||((n=a.createElement("style")).id="mceDefaultStyles",n.type="text/css",(t=a.getElementsByTagName("head")[0]).firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)),n.styleSheet?n.styleSheet.cssText+=e:n.appendChild(a.createTextNode(e))},loadCSS:function(e){Y((e=e||"").split(","),function(e){B[e]=!0,L.load(e,te)})},addClass:function(e,t){c(e).addClass(t)},removeClass:function(e,t){w(e,t,!1)},hasClass:function(e,t){return c(e).hasClass(t)},toggleClass:w,show:function(e){c(e).show()},hide:function(e){c(e).hide()},isHidden:function(e){return"none"===c(e).css("display")},uniqueId:function(e){return(e||"mce_")+P++},setHTML:b,getOuterHTML:function(e){var t="string"==typeof e?s(e):e;return zn(t)?t.outerHTML:Xa("<div></div>").append(Xa(t).clone()).html()},setOuterHTML:function(e,t){c(e).each(function(){try{if("outerHTML"in this)return void(this.outerHTML=t)}catch(e){}x(Xa(this).html(t),!0)})},decode:Qo.decode,encode:j,insertAfter:function(e,t){var r=s(t);return h(e,function(e){var t=r.parentNode,n=r.nextSibling;return n?t.insertBefore(e,n):t.appendChild(e),e})},replace:S,rename:function(t,e){var n;return t.nodeName!==e.toUpperCase()&&(n=C(e),Ya(o(t),function(e){i(n,e.nodeName,r(t,e.nodeName))}),S(n,t,!0)),n||t},findCommonAncestor:function(e,t){for(var n,r=e;r;){for(n=t;n&&r!==n;)n=n.parentNode;if(r===n)break;r=r.parentNode}return!r&&e.ownerDocument?e.ownerDocument.documentElement:r},toHex:function(e){return F.toHex(Et.trim(e))},run:h,getAttribs:o,isEmpty:function(e,t){var n,r,o=0;if(E(e))return!1;if(e=e.firstChild){var i=new Rr(e,e.parentNode),a=M?M.getWhiteSpaceElements():{};t=t||(M?M.getNonEmptyElements():null);do{if(n=e.nodeType,zn(e)){var u=e.getAttribute("data-mce-bogus");if(u){e=i.next("all"===u);continue}if(r=e.nodeName.toLowerCase(),t&&t[r]){if("br"!==r)return!1;o++,e=i.next();continue}if(E(e))return!1}if(8===n)return!1;if(3===n&&!qr(e.nodeValue))return!1;if(3===n&&e.parentNode&&a[e.parentNode.nodeName]&&qr(e.nodeValue))return!1;e=i.next()}while(e)}return o<=1},createRng:k,nodeIndex:Ka,split:function(e,t,n){var r,o,i,a=k();if(e&&t)return a.setStart(e.parentNode,Ka(e)),a.setEnd(t.parentNode,Ka(t)),r=a.extractContents(),(a=k()).setStart(t.parentNode,Ka(t)+1),a.setEnd(e.parentNode,Ka(e)+1),o=a.extractContents(),(i=e.parentNode).insertBefore(jo($,r),e),n?i.insertBefore(n,e):i.insertBefore(t,e),i.insertBefore(jo($,o),e),x(e),n||t},bind:V,unbind:q,fire:function(e,t,n){return U.fire(e,t,n)},getContentEditable:N,getContentEditableParent:function(e){for(var t=l(),n=null;e&&e!==t&&null===(n=N(e));e=e.parentNode);return n},destroy:function(){if(0<I.length)for(var e=I.length;e--;){var t=I[e];U.unbind(t[0],t[1],t[2])}ne(B,function(e,t){L.unload(t),delete B[t]}),sa.setDocument&&sa.setDocument()},isChildOf:function(e,t){if(Ja){for(;e;){if(t===e)return!0;e=e.parentNode}return!1}return e===t||t.contains(e)},dumpRng:function(e){return"startContainer: "+e.startContainer.nodeName+", startOffset: "+e.startOffset+", endContainer: "+e.endContainer.nodeName+", endOffset: "+e.endOffset}},W=(_=F,R=J($),e={set:function(e,t,n){A.url_converter&&null!==t&&(t=A.url_converter.call(A.url_converter_scope||R(),t,n,e[0])),e.attr("data-mce-"+n,t).attr(n,t)},get:function(e,t){return e.attr("data-mce-"+t)||e.attr(t)}},t={style:{set:function(e,t){null===t||"object"!=typeof t?(D&&e.attr("data-mce-style",t),null!==t&&"string"==typeof t?(e.removeAttr("style"),e.css(_.parse(t))):e.attr("style",t)):e.css(t)},get:function(e){var t=e.attr("data-mce-style")||e.attr("style");return _.serialize(_.parse(t),e[0].nodeName)}}},(D=(A=u).keep_values)&&(t.href=t.src=e),t);return $};Za.DOM=Za(document),Za.nodeIndex=Ka;var eu=Za.DOM,tu=Et.each,nu=Et.grep,ru=(ou.prototype._setReferrerPolicy=function(e){this.settings.referrerPolicy=e},ou.prototype.loadScript=function(e,t,n){function r(){o.remove(i),a&&(a.onerror=a.onload=a=null)}var o=eu,i=o.uniqueId(),a=document.createElement("script");a.id=i,a.type="text/javascript",a.src=Et._addCacheSuffix(e),this.settings.referrerPolicy&&o.setAttrib(a,"referrerpolicy",this.settings.referrerPolicy),a.onload=function(){r(),t()},a.onerror=function(){r(),y(n)?n():"undefined"!=typeof console&&console.log&&console.log("Failed to load script: "+e)},(document.getElementsByTagName("head")[0]||document.body).appendChild(a)},ou.prototype.isDone=function(e){return 2===this.states[e]},ou.prototype.markDone=function(e){this.states[e]=2},ou.prototype.add=function(e,t,n,r){var o=this.states[e];this.queue.push(e),void 0===o&&(this.states[e]=0),t&&(this.scriptLoadedCallbacks[e]||(this.scriptLoadedCallbacks[e]=[]),this.scriptLoadedCallbacks[e].push({success:t,failure:r,scope:n||this}))},ou.prototype.load=function(e,t,n,r){return this.add(e,t,n,r)},ou.prototype.remove=function(e){delete this.states[e],delete this.scriptLoadedCallbacks[e]},ou.prototype.loadQueue=function(e,t,n){this.loadScripts(this.queue,e,t,n)},ou.prototype.loadScripts=function(n,e,t,r){function o(t,e){tu(i.scriptLoadedCallbacks[e],function(e){y(e[t])&&e[t].call(e.scope)}),i.scriptLoadedCallbacks[e]=void 0}var i=this,a=[];i.queueLoadedCallbacks.push({success:e,failure:r,scope:t||this});var u=function(){var e,t=nu(n);n.length=0,tu(t,function(e){2!==i.states[e]?3!==i.states[e]?1!==i.states[e]&&(i.states[e]=1,i.loading++,i.loadScript(e,function(){i.states[e]=2,i.loading--,o("success",e),u()},function(){i.states[e]=3,i.loading--,a.push(e),o("failure",e),u()})):o("failure",e):o("success",e)}),i.loading||(e=i.queueLoadedCallbacks.slice(0),i.queueLoadedCallbacks.length=0,tu(e,function(e){0===a.length?y(e.success)&&e.success.call(e.scope):y(e.failure)&&e.failure.call(e.scope,a)}))};u()},ou.ScriptLoader=new ou,ou);function ou(e){void 0===e&&(e={}),this.states={},this.queue=[],this.scriptLoadedCallbacks={},this.queueLoadedCallbacks=[],this.loading=0,this.settings=e}function iu(e){var t=e;return{get:function(){return t},set:function(e){t=e}}}function au(){return ue(uu,su.get())}var uu={},su=iu("en"),cu={getData:function(){return re(uu,function(e){return _e({},e)})},setCode:function(e){e&&su.set(e)},getCode:function(){return su.get()},add:function(e,t){var n=uu[e];n||(uu[e]=n={}),ne(t,function(e,t){n[t.toLowerCase()]=e})},translate:function(e){function n(e){return y(e)?Object.prototype.toString.call(e):u(e)?"":""+e}function t(e){var t=n(e);return ue(a,t.toLowerCase()).map(n).getOr(t)}function r(e){return e.replace(/{context:\w+}$/,"")}var o,i,a=au().getOr({}),u=function(e){return""===e||null==e};if(u(e))return"";if(h(o=e)&&ke(o,"raw"))return n(e.raw);if(S(i=e)&&1<i.length){var s=e.slice(1);return r(t(e[0]).replace(/\{([0-9]+)\}/g,function(e,t){return ke(s,t)?n(s[t]):e}))}return r(t(e))},isRtl:function(){return au().bind(function(e){return ue(e,"_dir")}).exists(function(e){return"rtl"===e})},hasCode:function(e){return ke(uu,e)}},lu=function(){function u(t,n){Y(U(r,function(e){return e.name===t&&e.state===n}),function(e){return e.callback()})}function s(e){var t;return(f[e]?f[e].dependencies:t)||[]}function c(e,t){return"object"==typeof t?t:"string"==typeof e?{prefix:"",resource:t,suffix:""}:{prefix:e.prefix,resource:t,suffix:e.suffix}}function e(e,t,n){void 0===n&&(n="added"),ke(f,e)&&"added"===n||ke(l,e)&&"loaded"===n?t():r.push({name:e,state:n,callback:t})}var o=[],l={},f={},r=[],d=function(r,o,i,a,e){var t,n;l[r]||(0!==(t="string"==typeof o?o:o.prefix+o.resource+o.suffix).indexOf("/")&&-1===t.indexOf("://")&&(t=lu.baseURL+"/"+t),l[r]=t.substring(0,t.lastIndexOf("/")),n=function(){var n,e,t;u(r,"loaded"),n=o,e=i,t=a,Y(s(r),function(e){var t=c(n,e);d(t.resource,t,void 0,void 0)}),e&&(t?e.call(t):e.call(ru))},f[r]?n():ru.ScriptLoader.add(t,n,a,e))};return{items:o,urls:l,lookup:f,_listeners:r,get:function(e){if(f[e])return f[e].instance},dependencies:s,requireLangPack:function(t,n){!1!==lu.languageLoad&&e(t,function(){var e=cu.getCode();!e||n&&-1===(","+(n||"")+",").indexOf(","+e+",")||ru.ScriptLoader.add(l[t]+"/langs/"+e+".js")},"loaded")},add:function(e,t,n){var r=t;return o.push(r),f[e]={instance:r,dependencies:n},u(e,"added"),r},remove:function(e){delete l[e],delete f[e]},createUrl:c,addComponents:function(e,t){var n=l[e];Y(t,function(e){ru.ScriptLoader.add(n+"/"+e)})},load:d,waitFor:e}};function fu(){var e,t,n=(e=te,t=iu(ve.none()),{clear:function(){r(),t.set(ve.none())},isSet:function(){return t.get().isSome()},get:function(){return t.get()},set:function(e){r(),t.set(ve.some(e))}});function r(){return t.get().each(e)}return _e(_e({},n),{on:function(e){return n.get().each(e)}})}function du(n,r){var o=null;return{cancel:function(){l(o)||(clearTimeout(o),o=null)},throttle:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];l(o)&&(o=setTimeout(function(){o=null,n.apply(null,e)},r))}}}function mu(n,r){function o(){l(i)||(clearTimeout(i),i=null)}var i=null;return{cancel:o,throttle:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o(),i=setTimeout(function(){i=null,n.apply(null,e)},r)}}}function gu(e,t){var n=vn(e,t);return void 0===n||""===n?[]:n.split(" ")}function pu(e){return void 0!==e.dom.classList}function hu(e,t){var n,r,o;pu(e)?e.dom.classList.add(t):(r=t,o=gu(n=e,"class").concat([r]),pn(n,"class",o.join(" ")))}function vu(e,t){return pu(e)&&e.dom.classList.contains(t)}function bu(e,t){return He(n=void 0===e?document:e.dom)?[]:A(n.querySelectorAll(t),kt.fromDom);var n}function yu(r,e){function t(e,t){return(n=e.dom)&&n.hasAttribute&&n.hasAttribute(t)?ve.some(vn(e,t)):ve.none();var n}var n=r.selection.getRng(),o=kt.fromDom(n.startContainer),i=kt.fromDom(r.getBody()),a=e.fold(function(){return"."+qu()},function(e){return"["+$u()+'="'+e+'"]'});return br(Mt(o,n.startOffset).getOr(o),a,function(e){return je(e,i)}).bind(function(e){return t(e,""+Wu()).bind(function(n){return t(e,""+$u()).map(function(e){var t=Ku(r,n);return{uid:n,name:e,elements:t}})})})}function Cu(t){function o(){return{listeners:[],previous:fu()}}function c(e,t){n(e,function(e){return t(e),e})}function n(e,t){var n=i.get(),r=t(ue(n,e).getOrThunk(o));n[e]=r,i.set(n)}var i=iu({}),e=mu(function(){var e=i.get();Y(W(we(e)),function(e){n(e,function(u){var s=u.previous.get();return yu(t,ve.some(e)).fold(function(){var t;s.isSome()&&(c(t=e,function(e){Y(e.listeners,function(e){return e(!1,t)})}),u.previous.clear())},function(e){var t,n,r,o=e.uid,i=e.name,a=e.elements;fn(s,o)||(n=o,r=a,c(t=i,function(e){Y(e.listeners,function(e){return e(!0,t,{uid:n,nodes:A(r,function(e){return e.dom})})})}),u.previous.set(o))}),{previous:u.previous,listeners:u.listeners}})})},30);return t.on("remove",function(){e.cancel()}),t.on("NodeChange",function(){e.throttle()}),{addListener:function(e,t){n(e,function(e){return{previous:e.previous,listeners:e.listeners.concat([t])}})}}}function xu(e){var t=(new Date).getTime();return e+"_"+Math.floor(1e9*Math.random())+ ++Xu+String(t)}function wu(e,t){var n,r,o=Rt(e).dom,i=kt.fromDom(o.createDocumentFragment());Kt(i,(n=t,(r=(o||document).createElement("div")).innerHTML=n,Dn(kt.fromDom(r)))),Xt(e),Pn(e,i)}function Su(e,t){return kt.fromDom(e.dom.cloneNode(t))}function Eu(e){return Su(e,!1)}function ku(e){return Su(e,!0)}function Nu(e,t,n){function r(e){for(var t;(t=o[e]())&&!jn(t)&&!n(t););return ve.from(t).filter(jn)}void 0===n&&(n=D);var o=new Rr(e,t);return{current:function(){return ve.from(o.current()).filter(jn)},next:function(){return r("next")},prev:function(){return r("prev")},prev2:function(){return r("prev2")}}}function _u(t,e){var i=e||function(e){return t.isBlock(e)||Wn(e)||Yn(e)},a=function(e,t,n,r){if(jn(e)){var o=r(e,t,e.data);if(-1!==o)return ve.some({container:e,offset:o})}return n().bind(function(e){return a(e.container,e.offset,n,r)})};return{backwards:function(e,t,n,r){var o=Nu(e,r,i);return a(e,t,function(){return o.prev().map(function(e){return{container:e,offset:e.length}})},n).getOrNull()},forwards:function(e,t,n,r){var o=Nu(e,r,i);return a(e,t,function(){return o.next().map(function(e){return{container:e,offset:0}})},n).getOrNull()}}}function Au(e){return e?{left:Yu(e.left),top:Yu(e.top),bottom:Yu(e.bottom),right:Yu(e.right),width:Yu(e.width),height:Yu(e.height)}:{left:0,top:0,bottom:0,right:0,width:0,height:0}}function Ru(e,t){return e=Au(e),t||(e.left=e.left+e.width),e.right=e.left,e.width=0,e}function Du(e,t,n){return 0<=e&&e<=Math.min(t.height,n.height)/2}function Tu(e,t){var n=Math.min(t.height/2,e.height/2);return e.bottom-n<t.top||!(e.top>t.bottom)&&Du(t.top-e.bottom,e,t)}function Ou(e,t){return e.top>t.bottom||!(e.bottom<t.top)&&Du(t.bottom-e.top,e,t)}function Bu(e,t,n){return t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom}function Pu(e){var t=e.startContainer,n=e.startOffset;return t.hasChildNodes()&&e.endOffset===n+1?t.childNodes[n]:null}function Lu(e,t){if(zn(e)&&e.hasChildNodes()){var n=e.childNodes;return n[r=n.length-1,Math.min(Math.max(t,0),r)]}return e;var r}function Iu(e){return"string"==typeof e&&768<=e.charCodeAt(0)&&Gu.test(e)}function Mu(e){return"createRange"in e?e.createRange():Za.DOM.createRng()}function Fu(e){return e&&/[\r\n\t ]/.test(e)}function Uu(e){return e.setStart&&e.setEnd}function zu(e){var t=e.startContainer,n=e.startOffset;if(Fu(e.toString())&&ns(t.parentNode)&&jn(t)){var r=t.data;return Fu(r[n-1])||Fu(r[n+1])?1:void 0}}function Hu(e){return 0===e.left&&0===e.right&&0===e.top&&0===e.bottom}function ju(e,t){var n=Ru(e,t);return n.width=1,n.right=n.left+1,n}lu.languageLoad=!0,lu.baseURL="",lu.PluginManager=lu(),lu.ThemeManager=lu();var Vu=function(e,t){var n=[];return Y(Dn(e),function(e){n=(n=t(e)?n.concat([e]):n).concat(Vu(e,t))}),n},qu=J("mce-annotation"),$u=J("data-mce-annotation"),Wu=J("data-mce-annotation-uid"),Ku=function(e,t){return bu(kt.fromDom(e.getBody()),"["+Wu()+'="'+t+'"]')},Xu=0,Yu=Math.round,Gu=new RegExp("[\u0300-\u036f\u0483-\u0487\u0488-\u0489\u0591-\u05bd\u05bf\u05c1-\u05c2\u05c4-\u05c5\u05c7\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7-\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e3-\u0902\u093a\u093c\u0941-\u0948\u094d\u0951-\u0957\u0962-\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a02\u0a3c\u0a41-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a51\u0a70-\u0a71\u0a75\u0a81-\u0a82\u0abc\u0ac1-\u0ac5\u0ac7-\u0ac8\u0acd\u0ae2-\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62-\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c00\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c62-\u0c63\u0c81\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc-\u0ccd\u0cd5-\u0cd6\u0ce2-\u0ce3\u0d01\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62-\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039-\u103a\u103d-\u103e\u1058-\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108d\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b4-\u17b5\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193b\u1a17-\u1a18\u1a1b\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1ab0-\u1abd\u1abe\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80-\u1b81\u1ba2-\u1ba5\u1ba8-\u1ba9\u1bab-\u1bad\u1be6\u1be8-\u1be9\u1bed\u1bef-\u1bf1\u1c2c-\u1c33\u1c36-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1cf4\u1cf8-\u1cf9\u1dc0-\u1df5\u1dfc-\u1dff\u200c-\u200d\u20d0-\u20dc\u20dd-\u20e0\u20e1\u20e2-\u20e4\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302d\u302e-\u302f\u3099-\u309a\ua66f\ua670-\ua672\ua674-\ua67d\ua69e-\ua69f\ua6f0-\ua6f1\ua802\ua806\ua80b\ua825-\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\ua9e5\uaa29-\uaa2e\uaa31-\uaa32\uaa35-\uaa36\uaa43\uaa4c\uaa7c\uaab0\uaab2-\uaab4\uaab7-\uaab8\uaabe-\uaabf\uaac1\uaaec-\uaaed\uaaf6\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\uff9e-\uff9f]"),Ju=zn,Qu=jr,Zu=an("display","block table"),es=an("float","left right"),ts=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return function(e){for(var t=0;t<n.length;t++)if(!n[t](e))return!1;return!0}}(Ju,Qu,s(es)),ns=s(an("white-space","pre pre-line pre-wrap")),rs=jn,os=Wn,is=Za.nodeIndex,as=function(e,t){if(!(t<0&&zn(e)&&e.hasChildNodes()))return Lu(e,t)},us=function(e){var t=e.getClientRects(),n=0<t.length?Au(t[0]):Au(e.getBoundingClientRect());return!Uu(e)&&os(e)&&Hu(n)?function(e){var t=e.ownerDocument,n=Mu(t),r=t.createTextNode(xo),o=e.parentNode;o.insertBefore(r,e),n.setStart(r,0),n.setEnd(r,1);var i=Au(n.getBoundingClientRect());return o.removeChild(r),i}(e):Hu(n)&&Uu(e)?function(e){var t=e.startContainer,n=e.endContainer,r=e.startOffset,o=e.endOffset;if(t===n&&jn(n)&&0===r&&1===o){var i=e.cloneRange();return i.setEndAfter(n),us(i)}return null}(e):n},ss=function(t,n,e){function r(){return e=e||function(e){function r(e){var t;0!==e.height&&(0<o.length&&(t=o[o.length-1],e.left===t.left&&e.top===t.top&&e.bottom===t.bottom&&e.right===t.right)||o.push(e))}function t(e,t){var n=Mu(e.ownerDocument);if(t<e.data.length){if(Iu(e.data[t]))return o;if(Iu(e.data[t-1])&&(n.setStart(e,t),n.setEnd(e,t+1),!zu(n)))return r(ju(us(n),!1)),o}0<t&&(n.setStart(e,t-1),n.setEnd(e,t),zu(n)||r(ju(us(n),!1))),t<e.data.length&&(n.setStart(e,t),n.setEnd(e,t+1),zu(n)||r(ju(us(n),!0)))}var o=[],n=e.container(),i=e.offset();if(rs(n))return t(n,i),o;if(Ju(n))if(e.isAtEnd()){var a=as(n,i);rs(a)&&t(a,a.data.length),ts(a)&&!os(a)&&r(ju(us(a),!1))}else{if(a=as(n,i),rs(a)&&t(a,0),ts(a)&&e.isAtEnd())return r(ju(us(a),!1)),o;var u=as(e.container(),e.offset()-1);ts(u)&&!os(u)&&(!Zu(u)&&!Zu(a)&&ts(a)||r(ju(us(u),!1))),ts(a)&&r(ju(us(a),!0))}return o}(ss(t,n))}return{container:J(t),offset:J(n),toRange:function(){var e=Mu(t.ownerDocument);return e.setStart(t,n),e.setEnd(t,n),e},getClientRects:r,isVisible:function(){return 0<r().length},isAtStart:function(){return rs(t),0===n},isAtEnd:function(){return rs(t)?n>=t.data.length:n>=t.childNodes.length},isEqual:function(e){return e&&t===e.container()&&n===e.offset()},getNode:function(e){return as(t,e?n-1:n)}}};function cs(e,t){jn(t)&&0===t.data.length&&e.remove(t)}function ls(e,t,n){var r,o,i,a,u,s,c;$n(n)?(i=e,a=t,s=ve.from((u=n).firstChild),c=ve.from(u.lastChild),a.insertNode(u),s.each(function(e){return cs(i,e.previousSibling)}),c.each(function(e){return cs(i,e.nextSibling)})):(r=e,t.insertNode(o=n),cs(r,o.previousSibling),cs(r,o.nextSibling))}function fs(t){return function(e){return t===e}}function ds(e){var t,r,n,o;return(cc(e)?"text()":e.nodeName.toLowerCase())+"["+(r=mc(dc(t=e)),n=ge(r,fs(t),t),o=me(r=r.slice(0,n+1),function(e,t,n){return cc(t)&&cc(r[n-1])&&e++,e},0),ge(r=fe(r,on([t.nodeName])),fs(t),t)-o)+"]"}function ms(e,t){var n,r,o,i=[],a=t.container(),u=t.offset();return cc(a)?n=function(e,t){for(;(e=e.previousSibling)&&cc(e);)t+=e.data.length;return t}(a,u):(u>=(r=a.childNodes).length?(n="after",u=r.length-1):n="before",a=r[u]),i.push(ds(a)),o=fe(function(e,t){var n=[];for(t=t.parentNode;t!==e;t=t.parentNode)n.push(t);return n}(e,a),s(sn)),(i=i.concat(le(o,ds))).reverse().join("/")+","+n}function gs(e,t){if(!t)return null;var n=t.split(","),r=n[0].split("/"),o=1<n.length?n[1]:"before",i=me(r,function(e,t){var n,r,o,i,a=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(t);return a?("text()"===a[1]&&(a[1]="#text"),n=e,r=a[1],o=parseInt(a[2],10),i=fe(i=mc(n),function(e,t){return!cc(e)||!cc(i[t-1])}),(i=fe(i,on([r])))[o]):null},e);return i?cc(i)?function(e,t){for(var n,r=e,o=0;cc(r);){if(n=r.data.length,o<=t&&t<=o+n){e=r,t-=o;break}if(!cc(r.nextSibling)){e=r,t=n;break}o+=n,r=r.nextSibling}return cc(e)&&t>e.data.length&&(t=e.data.length),ss(e,t)}(i,parseInt(o,10)):(o="after"===o?fc(i)+1:fc(i),ss(i.parentNode,o)):null}function ps(e,t,n,r,o){var i,a=r[o?"startContainer":"endContainer"],u=r[o?"startOffset":"endOffset"],s=[],c=0,l=e.getRoot();for(jn(a)?s.push(n?function(e,t,n){for(var r=e(t.data.slice(0,n)).length,o=t.previousSibling;o&&jn(o);o=o.previousSibling)r+=e(o.data).length;return r}(t,a,u):u):(u>=(i=a.childNodes).length&&i.length&&(c=1,u=Math.max(0,i.length-1)),s.push(e.nodeIndex(i[u],n)+c));a&&a!==l;a=a.parentNode)s.push(e.nodeIndex(a,n));return s}function hs(e,t,n){var r=0;return Et.each(e.select(t),function(e){if("all"!==e.getAttribute("data-mce-bogus"))return e!==n&&void r++}),r}function vs(e,t){var n,r=t?"start":"end",o=e[r+"Container"],i=e[r+"Offset"];zn(o)&&"TR"===o.nodeName&&(o=(n=o.childNodes)[Math.min(t?i:i-1,n.length-1)])&&(i=t?0:o.childNodes.length,e["set"+(t?"Start":"End")](o,i))}function bs(e){return vs(e,!0),vs(e,!1),e}function ys(e,t){var n;return zn(e)&&(e=Lu(e,t),gc(e))?e:Ir(e)?(n=(e=jn(e)&&Pr(e)?e.parentNode:e).previousSibling,gc(n)?n:(n=e.nextSibling,gc(n)?n:void 0)):void 0}function Cs(e,t,n){var r=n.getNode(),o=r?r.nodeName:null,i=n.getRng();if(gc(r)||"IMG"===o)return{name:o,index:hs(n.dom,o,r)};var a,u,s,c,l,f,d,m=ys((a=i).startContainer,a.startOffset)||ys(a.endContainer,a.endOffset);return m?{name:o=m.tagName,index:hs(n.dom,o,m)}:(f=(s=n).dom,(d={}).start=ps(f,u=e,c=t,l=i,!0),s.isCollapsed()||(d.end=ps(f,u,c,l,!1)),Hr(l)&&(d.isFakeCaret=!0),d)}function xs(e,t,n){var r={"data-mce-type":"bookmark",id:t,style:"overflow:hidden;line-height:0px"};return n?e.create("span",r,""):e.create("span",r)}function ws(e,t){var n=e.dom,r=e.getRng(),o=n.uniqueId(),i=e.isCollapsed(),a=e.getNode(),u=a.nodeName;if("IMG"===u)return{name:u,index:hs(n,u,a)};var s=bs(r.cloneRange());return i||(s.collapse(!1),ls(n,s,xs(n,o+"_end",t))),(r=bs(r)).collapse(!0),ls(n,r,xs(n,o+"_start",t)),e.moveToBookmark({id:o,keep:!0}),{id:o}}function Ss(e,t,n){var r=e.getParam(t,n);return-1===r.indexOf("=")?r:ue(e.getParam(t,"","hash"),e.id).getOr(n)}function Es(e){return e.getParam("content_security_policy","")}function ks(e){if(e.getParam("force_p_newlines",!1))return"p";var t=e.getParam("forced_root_block","p");return!1===t?"":!0===t?"p":t}function Ns(e){return e.getParam("forced_root_block_attrs",{})}function _s(e){return e.getParam("automatic_uploads",!0,"boolean")}function As(e){return e.getParam("icons","","string")}function Rs(e){return e.getParam("referrer_policy","","string")}function Ds(e){return e.getParam("language","en","string")}function Ts(e){return e.getParam("indent_use_margin",!1)}function Os(e){var t=e.getParam("font_css",[]);return S(t)?t:A(t.split(","),Je)}function Bs(e){var t=e.getParam("object_resizing");return!1!==t&&!xt.iOS&&(X(t)?t:"table,img,figure.image,div,video,iframe")}function Ps(e){return e.getParam("event_root")}function Ls(e){return e.getParam("theme")}function Is(e){return!1!==e.getParam("inline_boundaries")}function Ms(e){return e.getParam("plugins","","string")}function Fs(e){var t=e.parentNode;t&&t.removeChild(e)}function Us(e){var t=Eo(e);return{count:e.length-t.length,text:t}}function zs(e){for(var t;-1!==(t=e.data.lastIndexOf(wo));)e.deleteData(t,1)}function Hs(e,t){return yc(e),t}function js(e,t){var n,r=t.container(),o=(-1===(n=_(xe(r.childNodes),e))?ve.none():ve.some(n)).map(function(e){return e<t.offset()?ss(r,t.offset()-1):t}).getOr(t);return yc(e),o}function Vs(e,t){return ss.isTextPosition(t)?(r=t,bc(n=e)&&r.container()===n?(a=Us((o=n).data.substr(0,(i=r).offset())),u=Us(o.data.substr(i.offset())),0<(a.text+u.text).length?(zs(o),ss(o,i.offset()-a.count)):i):Hs(n,r)):(s=e,((c=t).container()===s.parentNode?js:Hs)(s,c));var n,r,o,i,a,u,s,c}function qs(e,t,n){var r,o,i,a=Ru(t.getBoundingClientRect(),n),u="BODY"===e.tagName?(r=e.ownerDocument.documentElement,o=e.scrollLeft||r.scrollLeft,e.scrollTop||r.scrollTop):(i=e.getBoundingClientRect(),o=e.scrollLeft-i.left,e.scrollTop-i.top);a.left+=o,a.right+=o,a.top+=u,a.bottom+=u,a.width=1;var s=t.offsetWidth-t.clientWidth;return 0<s&&(n&&(s*=-1),a.left+=s,a.right+=s),a}function $s(e,i,a,u){function s(){!function(){for(var e=bu(kt.fromDom(i),"*[contentEditable=false],video,audio,embed,object"),t=0;t<e.length;t++){var n,r=e[t].dom,o=r.previousSibling;Ao(o)&&(1===(n=o.data).length?o.parentNode.removeChild(o):o.deleteData(n.length-1,1)),o=r.nextSibling,_o(o)&&(1===(n=o.data).length?o.parentNode.removeChild(o):o.deleteData(0,1))}}(),l&&(yc(l),l=null),f.on(function(e){Xa(e.caret).remove(),f.clear()}),c&&(_r.clearInterval(c),c=void 0)}var c,l,f=fu(),t=ks(e),d=0<t.length?t:"p";return{show:function(e,t){var n;if(s(),Sc(t))return null;if(!a(t))return l=function(e,t){var n=e.ownerDocument.createTextNode(wo),r=e.parentNode;if(t){if(o=e.previousSibling,No(o)){if(Ir(o))return o;if(Ao(o))return o.splitText(o.data.length-1)}r.insertBefore(n,e)}else{var o=e.nextSibling;if(No(o)){if(Ir(o))return o;if(_o(o))return o.splitText(1),o}e.nextSibling?r.insertBefore(n,e.nextSibling):r.appendChild(n)}return n}(t,e),n=t.ownerDocument.createRange(),Ec(l.nextSibling)?(n.setStart(l,0),n.setEnd(l,0)):(n.setStart(l,1),n.setEnd(l,1)),n;l=function(e,t,n){var r,o=t.ownerDocument.createElement(e);o.setAttribute("data-mce-caret",n?"before":"after"),o.setAttribute("data-mce-bogus","all"),o.appendChild(((r=document.createElement("br")).setAttribute("data-mce-bogus","1"),r));var i=t.parentNode;return n?i.insertBefore(o,t):t.nextSibling?i.insertBefore(o,t.nextSibling):i.appendChild(o),o}(d,t,e);var r=qs(i,t,e);Xa(l).css("top",r.top);var o=Xa('<div class="mce-visual-caret" data-mce-bogus="all"></div>').css(_e({},r)).appendTo(i)[0];return f.set({caret:o,element:t,before:e}),e&&Xa(o).addClass("mce-visual-caret-before"),c=_r.setInterval(function(){u()?Xa("div.mce-visual-caret",i).toggleClass("mce-visual-caret-hidden"):Xa("div.mce-visual-caret",i).addClass("mce-visual-caret-hidden")},500),(n=t.ownerDocument.createRange()).setStart(l,0),n.setEnd(l,0),n},hide:s,getCss:function(){return".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}"},reposition:function(){f.on(function(e){var t=qs(i,e.element,e.before);Xa(e.caret).css(_e({},t))})},destroy:function(){return _r.clearInterval(c)}}}function Ws(){return Cc.isIE()||Cc.isEdge()||Cc.isFirefox()}function Ks(e){return Ec(e)||cn(e)&&Ws()}function Xs(e,t){for(var n;n=e(t);)if(!Rc(n))return n;return null}function Ys(e,t,n,r,o){var i=new Rr(e,r),a=kc(e)||Rc(e);if(t<0){if(a&&n(e=Xs(i.prev.bind(i),!0)))return e;for(;e=Xs(i.prev.bind(i),o);)if(n(e))return e}if(0<t){if(a&&n(e=Xs(i.next.bind(i),!0)))return e;for(;e=Xs(i.next.bind(i),o);)if(n(e))return e}return null}function Gs(e,t){for(;e&&e!==t;){if(_c(e))return e;e=e.parentNode}return null}function Js(e,t,n){return Gs(e.container(),n)===Gs(t.container(),n)}function Qs(e,t){if(!t)return null;var n=t.container(),r=t.offset();return Dc(n)?n.childNodes[r+e]:null}function Zs(e,t){var n=t.ownerDocument.createRange();return e?(n.setStartBefore(t),n.setEndBefore(t)):(n.setStartAfter(t),n.setEndAfter(t)),n}function ec(e,t,n){for(var r,o,i=e?"previousSibling":"nextSibling";n&&n!==t;){var a=n[i];if(Ac(a)&&(a=a[i]),kc(a)||Nc(a)){if(o=n,Gs(a,r=t)===Gs(o,r))return a;break}if(Tc(a))break;n=n.parentNode}return null}function tc(e,t,n){var r,o=R(ec,!0,t),i=R(ec,!1,t),a=n.startContainer,u=n.startOffset;if(Pr(a)){var s=(a=Dc(a)?a:a.parentNode).getAttribute("data-mce-caret");if("before"===s&&Ks(r=a.nextSibling))return Oc(r);if("after"===s&&Ks(r=a.previousSibling))return Bc(r)}if(!n.collapsed)return n;if(jn(a)){if(Ac(a)){if(1===e){if(r=i(a))return Oc(r);if(r=o(a))return Bc(r)}if(-1===e){if(r=o(a))return Bc(r);if(r=i(a))return Oc(r)}return n}if(Ao(a)&&u>=a.data.length-1)return 1===e&&(r=i(a))?Oc(r):n;if(_o(a)&&u<=1)return-1===e&&(r=o(a))?Bc(r):n;if(u===a.data.length)return(r=i(a))?Oc(r):n;if(0===u)return(r=o(a))?Bc(r):n}return n}function nc(e,t){return ve.from(Qs(e?0:-1,t)).filter(kc)}function rc(e,t,n){var r=tc(e,t,n);return-1===e?ss.fromRangeStart(r):ss.fromRangeEnd(r)}function oc(e){return ve.from(e.getNode()).map(kt.fromDom)}function ic(e,t){for(;t=e(t);)if(t.isVisible())return t;return t}function ac(e,t){var n=Js(e,t);return!(n||!Wn(e.getNode()))||n}ss.fromRangeStart=function(e){return ss(e.startContainer,e.startOffset)},ss.fromRangeEnd=function(e){return ss(e.endContainer,e.endOffset)},ss.after=function(e){return ss(e.parentNode,is(e)+1)},ss.before=function(e){return ss(e.parentNode,is(e))},ss.isAbove=function(e,t){return dn(Q(t.getClientRects()),Z(e.getClientRects()),Tu).getOr(!1)},ss.isBelow=function(e,t){return dn(Z(t.getClientRects()),Q(e.getClientRects()),Ou).getOr(!1)},ss.isAtStart=function(e){return!!e&&e.isAtStart()},ss.isAtEnd=function(e){return!!e&&e.isAtEnd()},ss.isTextPosition=function(e){return!!e&&jn(e.container())},ss.isElementPosition=function(e){return!1===ss.isTextPosition(e)};var uc,sc,cc=jn,lc=sn,fc=Za.nodeIndex,dc=function(e){var t=e.parentNode;return lc(t)?dc(t):t},mc=function(e){return e?me(e.childNodes,function(e,t){return lc(t)&&"BR"!==t.nodeName?e=e.concat(mc(t)):e.push(t),e},[]):[]},gc=Yn,pc=R(Cs,u,!0),hc=Za.DOM,vc=zn,bc=jn,yc=function(e){vc(e)&&Ir(e)&&(Mr(e)?e.removeAttribute("data-mce-caret"):Fs(e)),bc(e)&&(zs(e),0===e.data.length&&Fs(e))},Cc=dt().browser,xc=Yn,wc=Jn,Sc=Gn,Ec=function(e){return xc(e)||wc(e)},kc=Yn,Nc=Jn,_c=an("display","block table table-cell table-caption list-item"),Ac=Ir,Rc=Pr,Dc=zn,Tc=jr,Oc=R(Zs,!0),Bc=R(Zs,!1);function Pc(e,t){return e.hasChildNodes()&&t<e.childNodes.length?e.childNodes[t]:null}function Lc(e,t){if(0<e){if(Yl(t.previousSibling)&&!Wl(t.previousSibling))return ss.before(t);if(Wl(t))return ss(t,0)}if(e<0){if(Yl(t.nextSibling)&&!Wl(t.nextSibling))return ss.after(t);if(Wl(t))return ss(t,t.data.length)}return e<0&&!Xl(t)?ss.after(t):ss.before(t)}function Ic(t){return{next:function(e){return Jl(uc.Forwards,e,t)},prev:function(e){return Jl(uc.Backwards,e,t)}}}function Mc(e){return ss.isTextPosition(e)?0===e.offset():jr(e.getNode())}function Fc(e){if(ss.isTextPosition(e)){var t=e.container();return e.offset()===t.data.length}return jr(e.getNode(!0))}function Uc(e,t){return!ss.isTextPosition(e)&&!ss.isTextPosition(t)&&e.getNode()===t.getNode(!0)}function zc(o,i,a){return Ql(o,i,a).bind(function(e){return Js(a,e,i)&&(t=a,n=e,o?!Uc(t,n)&&(ss.isTextPosition(r=t)||!Wn(r.getNode()))&&Fc(t)&&Mc(n):!Uc(n,t)&&Mc(t)&&Fc(n))?Ql(o,i,e):ve.some(e);var t,n,r})}function Hc(e,t){var n,r,o,i,a,u=e?t.firstChild:t.lastChild;return jn(u)?ve.some(ss(u,e?0:u.data.length)):u?jr(u)?ve.some(e?ss.before(u):Wn(a=u)?ss.before(a):ss.after(a)):(r=t,o=u,i=(n=e)?ss.before(o):ss.after(o),Ql(n,r,i)):ve.none()}function jc(e){return zn(e)&&e.id===of}function Vc(e,t){for(;t&&t!==e;){if(t.id===of)return t;t=t.parentNode}return null}function qc(e){return Et.isArray(e.start)}function $c(e,t){return zn(t)&&e.isBlock(t)&&!t.innerHTML&&!xt.ie&&(t.innerHTML='<br data-mce-bogus="1" />'),t}function Wc(e,t,n){return!1===t.hasChildNodes()&&Vc(e,t)&&(o=n,i=(r=t).ownerDocument.createTextNode(wo),r.appendChild(i),o.setStart(i,0),o.setEnd(i,0),1);var r,o,i}function Kc(e,t,n,r){var o,i,a,u,s=n[t?"start":"end"],c=e.getRoot();if(s){for(a=s[0],i=c,o=s.length-1;1<=o;o--){if(u=i.childNodes,Wc(c,i,r))return 1;if(s[o]>u.length-1)return Wc(c,i,r)||function(t){return rf(i).fold(D,function(e){return t.setStart(e.container(),e.offset()),t.setEnd(e.container(),e.offset()),!0})}(r);i=u[s[o]]}3===i.nodeType&&(a=Math.min(s[0],i.nodeValue.length)),1===i.nodeType&&(a=Math.min(s[0],i.childNodes.length)),t?r.setStart(i,a):r.setEnd(i,a)}return 1}function Xc(e){return jn(e)&&0<e.data.length}function Yc(e,t,n){var r,o,i,a,u,s,c=e.get(n.id+"_"+t),l=n.keep;if(c){if(r=c.parentNode,o="start"===t?l?c.hasChildNodes()?(r=c.firstChild,1):Xc(c.nextSibling)?(r=c.nextSibling,0):Xc(c.previousSibling)?(r=c.previousSibling,c.previousSibling.data.length):(r=c.parentNode,e.nodeIndex(c)+1):e.nodeIndex(c):l?c.hasChildNodes()?(r=c.firstChild,1):Xc(c.previousSibling)?(r=c.previousSibling,c.previousSibling.data.length):(r=c.parentNode,e.nodeIndex(c)):e.nodeIndex(c),u=r,s=o,!l){for(a=c.previousSibling,i=c.nextSibling,Et.each(Et.grep(c.childNodes),function(e){jn(e)&&(e.nodeValue=e.nodeValue.replace(/\uFEFF/g,""))});c=e.get(n.id+"_"+t);)e.remove(c,!0);a&&i&&a.nodeType===i.nodeType&&jn(a)&&!xt.opera&&(o=a.nodeValue.length,a.appendData(i.nodeValue),e.remove(i),u=a,s=o)}return ve.some(ss(u,s))}return ve.none()}function Gc(t,e){!function(e,t){var n,r,o,i,a,u,s,c,l,f,d,m,g=e.dom;if(t){if(qc(t))return d=t,m=(f=g).createRng(),Kc(f,!0,d,m)&&Kc(f,!1,d,m)?ve.some(m):ve.none();if(X(t.start))return ve.some((s=t,c=(u=g).createRng(),l=gs(u.getRoot(),s.start),c.setStart(l.container(),l.offset()),l=gs(u.getRoot(),s.end),c.setEnd(l.container(),l.offset()),c));if(ke(t,"id"))return dn(a=Yc(o=g,"start",i=t),Yc(o,"end",i).or(a),function(e,t){var n=o.createRng();return n.setStart($c(o,e.container()),e.offset()),n.setEnd($c(o,t.container()),t.offset()),n});if(ke(t,"name"))return n=g,ve.from(n.select((r=t).name)[r.index]).map(function(e){var t=n.createRng();return t.selectNode(e),t});if(ke(t,"rng"))return ve.some(t.rng)}return ve.none()}(t,e).each(function(e){t.setRng(e)})}function Jc(e){return zn(e)&&"SPAN"===e.tagName&&"bookmark"===e.getAttribute("data-mce-type")}function Qc(e){return""!==e&&-1!==" \f\n\r\t\v".indexOf(e)}function Zc(e){return!Qc(e)&&!uf(e)}function el(e){return e.nodeType}function tl(e,t,n){var r,o=n.startOffset,i=n.startContainer;if((i!==n.endContainer||!(r=i.childNodes[o])||!/^(IMG)$/.test(r.nodeName))&&zn(i)){var a=i.childNodes,u=void 0;o<a.length?(i=a[o],u=new Rr(i,e.getParent(i,e.isBlock))):(i=a[a.length-1],(u=new Rr(i,e.getParent(i,e.isBlock))).next(!0));for(var s=u.current();s;s=u.next())if(jn(s)&&!sf(s))return n.setStart(s,0),t.setRng(n),0}}function nl(e,t,n){if(e){var r=t?"nextSibling":"previousSibling";for(e=n?e:e[r];e;e=e[r])if(zn(e)||!sf(e))return e}}function rl(e,t){return el(t)&&(t=t.nodeName),!!e.schema.getTextBlockElements()[t.toLowerCase()]}function ol(e,t,n){return e.schema.isValidChild(t,n)}function il(e,n){return y(e)?e=e(n):V(n)&&(e=e.replace(/%(\w+)/g,function(e,t){return n[t]||e})),e}function al(e,t){return e=""+((e=e||"").nodeName||e),t=""+((t=t||"").nodeName||t),e.toLowerCase()===t.toLowerCase()}function ul(e,t,n){return"color"!==n&&"backgroundColor"!==n||(t=e.toHex(t)),"fontWeight"===n&&700===t&&(t="bold"),""+("fontFamily"===n?t.replace(/[\'\"]/g,"").replace(/,\s+/g,","):t)}function sl(e,t,n){return ul(e,e.getStyle(t,n),n)}function cl(t,e){var n;return t.getParent(e,function(e){return(n=t.getStyle(e,"text-decoration"))&&"none"!==n}),n}function ll(e,t,n){return e.getParents(t,n,e.getRoot())}function fl(e,t){return F(e.formatter.get(t),function(t){function o(e){return 1<e.length&&"%"===e.charAt(0)}return F(["styles","attributes"],function(e){return ue(t,e).exists(function(e){var n,r;return F(S(e)?e:(n=u,r=[],ne(e,function(e,t){r.push(n(e,t))}),r),o)})})})}function dl(e){return se(e,"block")}function ml(e){return se(e,"selector")}function gl(e){return se(e,"inline")}function pl(e){return ml(e)&&!1!==e.expand&&!gl(e)}function hl(e,t){for(var n=t;n;){if(zn(n)&&e.getContentEditable(n))return"false"===e.getContentEditable(n)?n:t;n=n.parentNode}return t}function vl(e,t,n,r){for(var o=t.data,i=n;e?0<=i:i<o.length;e?i--:i++)if(r(o.charAt(i)))return e?i+1:i;return-1}function bl(e,t,n){return vl(e,t,n,function(e){return uf(e)||Qc(e)})}function yl(e,t,n){return vl(e,t,n,Zc)}function Cl(i,e,t,n,a,r){function o(e,t,n){var r=_u(i),o=a?r.backwards:r.forwards;return ve.from(o(e,t,function(e,t){return cf(e.parentNode)?-1:n(a,u=e,t)},s))}var u,s=i.getParent(t,i.isBlock)||e;return o(t,n,bl).bind(function(e){return r?o(e.container,e.offset+(a?-1:0),yl):ve.some(e)}).orThunk(function(){return u?ve.some({container:u,offset:a?0:u.length}):ve.none()})}function xl(e,t,n,r,o){jn(r)&&Pe(r.data)&&r[o]&&(r=r[o]);for(var i=lf(e,r),a=0;a<i.length;a++)for(var u=0;u<t.length;u++){var s=t[u];if((!V(s.collapsed)||s.collapsed===n.collapsed)&&ml(s)&&e.is(i[a],s.selector))return i[a]}return r}function wl(t,e,n,r){var o,i=n,a=t.dom,u=a.getRoot(),s=e[0];if((i=dl(s)?s.wrapper?null:a.getParent(n,s.block,u):i)||(o=a.getParent(n,"LI,TD,TH"),i=a.getParent(jn(n)?n.parentNode:n,function(e){return e!==u&&df(t,e)},o)),!(i=i&&dl(s)&&s.wrapper&&lf(a,i,"ul,ol").reverse()[0]||i))for(i=n;i[r]&&!a.isBlock(i[r])&&!al(i=i[r],"br"););return i||n}function Sl(e,t,n,r,o){var i,a=n,u=o?"previousSibling":"nextSibling",s=e.getRoot();if(jn(n)&&!ff(n)&&(o?0<r:r<n.data.length))return n;for(;;){if(!t[0].block_expand&&e.isBlock(a))return a;for(var c=a[u];c;c=c[u]){var l=jn(c)&&!mf(e,s,c,u);if(!cf(c)&&(!Wn(i=c)||!i.getAttribute("data-mce-bogus")||i.nextSibling)&&!ff(c,l))return a}if(a===s||a.parentNode===s){n=a;break}a=a.parentNode}return n}function El(e){return cf(e.parentNode)||cf(e)}function kl(e,t,n,r){void 0===r&&(r=!1);var o=t.startContainer,i=t.startOffset,a=t.endContainer,u=t.endOffset,s=e.dom,c=n[0];return zn(o)&&o.hasChildNodes()&&(o=Lu(o,i),jn(o)&&(i=0)),zn(a)&&a.hasChildNodes()&&(a=Lu(a,t.collapsed?u:u-1),jn(a)&&(u=a.nodeValue.length)),o=hl(s,o),a=hl(s,a),El(o)&&(o=cf(o)?o:o.parentNode,o=t.collapsed?o.previousSibling||o:o.nextSibling||o,jn(o)&&(i=t.collapsed?o.length:0)),El(a)&&(a=cf(a)?a:a.parentNode,a=t.collapsed?a.nextSibling||a:a.previousSibling||a,jn(a)&&(u=t.collapsed?0:a.length)),t.collapsed&&(Cl(s,e.getBody(),o,i,!0,r).each(function(e){var t=e.container,n=e.offset;o=t,i=n}),Cl(s,e.getBody(),a,u,!1,r).each(function(e){var t=e.container,n=e.offset;a=t,u=n})),(gl(c)||c.block_expand)&&(gl(c)&&jn(o)&&0!==i||(o=Sl(s,n,o,i,!0)),gl(c)&&jn(a)&&u!==a.nodeValue.length||(a=Sl(s,n,a,u,!1))),pl(c)&&(o=xl(s,n,t,o,"previousSibling"),a=xl(s,n,t,a,"nextSibling")),(dl(c)||ml(c))&&(o=wl(e,n,o,"previousSibling"),a=wl(e,n,a,"nextSibling"),dl(c)&&(s.isBlock(o)||(o=Sl(s,n,o,i,!0)),s.isBlock(a)||(a=Sl(s,n,a,u,!1)))),zn(o)&&(i=s.nodeIndex(o),o=o.parentNode),zn(a)&&(u=s.nodeIndex(a)+1,a=a.parentNode),{startContainer:o,startOffset:i,endContainer:a,endOffset:u}}function Nl(n,e,u){function s(e){var t=e[0];jn(t)&&t===i&&o>=t.data.length&&e.splice(0,1);var n=e[e.length-1];return 0===a&&0<e.length&&n===l&&jn(n)&&e.splice(e.length-1,1),e}function c(e,t,n){for(var r=[];e&&e!==n;e=e[t])r.push(e);return r}function t(e,t){return n.getParent(e,function(e){return e.parentNode===t},t)}function r(e,t,n){var r=n?"nextSibling":"previousSibling",o=e;for(o.parentNode;o&&o!==t;o=i){var i=o.parentNode,a=c(o===e?o:o[r],r);a.length&&(n||a.reverse(),u(s(a)))}}var o=e.startOffset,i=Lu(e.startContainer,o),a=e.endOffset,l=Lu(e.endContainer,a-1);if(i===l)return u(s([i]));var f=n.findCommonAncestor(i,l);if(n.isChildOf(i,l))return r(i,f,!0);if(n.isChildOf(l,i))return r(l,f);var d=t(i,f)||i,m=t(l,f)||l;r(i,d,!0);var g=c(d===i?d:d.nextSibling,"nextSibling",m===l?m.nextSibling:m);g.length&&u(s(g)),r(l,m)}function _l(e){var t=[];if(e)for(var n=0;n<e.rangeCount;n++)t.push(e.getRangeAt(n));return t}function Al(e,t){var n=bu(t,"td[data-mce-selected],th[data-mce-selected]");return 0<n.length?n:U(H(e,function(e){var t=Pu(e);return t?[kt.fromDom(t)]:[]}),bo)}function Rl(e){return Al(_l(e.selection.getSel()),kt.fromDom(e.getBody()))}function Dl(e,t){return hr(e,"table",t)}function Tl(o,e){return dn((r=e.startContainer,i=e.startOffset,jn(r)?0===i?ve.some(kt.fromDom(r)):ve.none():ve.from(r.childNodes[i]).map(kt.fromDom)),(t=e.endContainer,n=e.endOffset,jn(t)?n===t.data.length?ve.some(kt.fromDom(t)):ve.none():ve.from(t.childNodes[n-1]).map(kt.fromDom)),function(e,t){var n=M(gf(o),R(je,e)),r=M(pf(o),R(je,t));return n.isSome()&&r.isSome()}).getOr(!1);var t,n,r,i}function Ol(e,t,n,r){var o=n,i=new Rr(n,o),a=ae(e.schema.getMoveCaretBeforeOnEnterElements(),function(e,t){return!T(["td","th","table"],t.toLowerCase())});do{if(jn(n)&&0!==Et.trim(n.nodeValue).length)return r?t.setStart(n,0):t.setEnd(n,n.nodeValue.length),0;if(a[n.nodeName])return r?t.setStartBefore(n):"BR"===n.nodeName?t.setEndBefore(n):t.setEndAfter(n),0}while(n=r?i.next():i.prev());"BODY"===o.nodeName&&(r?t.setStart(o,0):t.setEnd(o,o.childNodes.length))}function Bl(e){var t=e.selection.getSel();return t&&0<t.rangeCount}function Pl(r,o){var e=Rl(r);0<e.length?Y(e,function(e){var t=e.dom,n=r.dom.createRng();n.setStartBefore(t),n.setEndAfter(t),o(n,!0)}):o(r.selection.getRng(),!1)}function Ll(e,t,n){var r=ws(e,t);n(r),e.moveToBookmark(r)}function Il(e){return hf.get(e)}function Ml(e,t,n,r){var o=t.uid,i=void 0===o?xu("mce-annotation"):o,a=function(e,t){var n={};for(o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);return n}(t,["uid"]),u=kt.fromTag("span",e);hu(u,qu()),pn(u,""+Wu(),i),pn(u,""+$u(),n);var s,c=r(i,a),l=c.attributes,f=c.classes,d=void 0===f?[]:f;return hn(u,void 0===l?{}:l),s=u,Y(d,function(e){hu(s,e)}),u}function Fl(u,e,t,n,r){function s(){d.clear()}function c(e){Y(e,o)}var l=[],f=Ml(u.getDoc(),r,t,n),d=fu(),o=function(e){var t,n,r,o,i,a;switch(r=u,i="span",a=Nt(o=e),Ot(o).fold(function(){return"skipping"},function(e){return"br"===a||_n(n=o)&&Il(n)===wo?"valid":Nn(t=o)&&vu(t,qu())?"existing":jc(o.dom)?"caret":ol(r,i,a)&&ol(r,Nt(e),i)?"valid":"invalid-child";var t,n})){case"invalid-child":s(),c(Dn(e)),s();break;case"valid":qt(t=e,n=d.get().getOrThunk(function(){var e=Eu(f);return l.push(e),d.set(e),e})),Pn(n,t)}};return Nl(u.dom,e,function(e){s(),c(A(e,kt.fromDom))}),l}function Ul(o){var n,e,r,i=(n={},{register:function(e,t){n[e]={name:e,settings:t}},lookup:function(e){return ue(n,e).map(function(e){return e.settings})}});r=i,(e=o).on("init",function(){e.serializer.addNodeFilter("span",function(e){Y(e,function(t){ve.from(t.attr($u())).bind(r.lookup).each(function(e){!1===e.persistent&&t.unwrap()})})})});var a=Cu(o);return{register:function(e,t){i.register(e,t)},annotate:function(t,n){i.lookup(t).each(function(e){var u,s,c,l;s=t,c=e,l=n,(u=o).undoManager.transact(function(){var e,t,n,r,o=u.selection,i=o.getRng(),a=0<Rl(u).length;i.collapsed&&!a&&(n=kl(e=u,t=i,[{inline:"span"}]),t.setStart(n.startContainer,n.startOffset),t.setEnd(n.endContainer,n.endOffset),e.selection.setRng(t)),o.getRng().collapsed&&!a?(wu(r=Ml(u.getDoc(),l,s,c.decorate),xo),o.getRng().insertNode(r.dom),o.select(r.dom)):Ll(o,!1,function(){Pl(u,function(e){Fl(u,e,s,c.decorate,l)})})})})},annotationChanged:function(e,t){a.addListener(e,t)},remove:function(e){yu(o,ve.some(e)).each(function(e){Y(e.elements,Yt)})},getAll:function(e){var t,n,r;return re((t=e,n=bu(kt.fromDom(o.getBody()),"["+$u()+'="'+t+'"]'),r={},Y(n,function(e){var t=vn(e,Wu()),n=ue(r,t).getOr([]);r[t]=n.concat([e])}),r),function(e){return A(e,function(e){return e.dom})})}}}function zl(e){return{getBookmark:R(af,e),moveToBookmark:R(Gc,e)}}(sc=uc=uc||{})[sc.Backwards=-1]="Backwards",sc[sc.Forwards=1]="Forwards";function Hl(e){return Po(e)||!!Mo(t=e)&&!0!==L(xe(t.getElementsByTagName("*")),function(e,t){return e||Ro(t)},!1);var t}var jl,Vl,ql,$l=Yn,Wl=jn,Kl=zn,Xl=Wn,Yl=jr,Gl=Vr,Jl=function(e,t,n){var r,o,i;if(!Kl(n)||!t)return null;if(t.isEqual(ss.after(n))&&n.lastChild){if(i=ss.after(n.lastChild),e<0&&Yl(n.lastChild)&&Kl(n.lastChild))return Xl(n.lastChild)?ss.before(n.lastChild):i}else i=t;var a,u,s,c=i.container(),l=i.offset();if(Wl(c)){if(e<0&&0<l)return ss(c,--l);if(0<e&&l<c.length)return ss(c,++l);r=c}else{if(e<0&&0<l&&(f=Pc(c,l-1),Yl(f)))return!Hl(f)&&(o=Ys(f,e,Gl,f))?Wl(o)?ss(o,o.data.length):ss.after(o):Wl(f)?ss(f,f.data.length):ss.before(f);if(0<e&&l<c.childNodes.length&&(f=Pc(c,l),Yl(f)))return Xl(f)?(a=n,(s=(u=f).nextSibling)&&Yl(s)?Wl(s)?ss(s,0):ss.before(s):Jl(uc.Forwards,ss.after(u),a)):!Hl(f)&&(o=Ys(f,e,Gl,f))?Wl(o)?ss(o,0):ss.before(o):Wl(f)?ss(f,0):ss.after(f);r=f||i.getNode()}if((0<e&&i.isAtEnd()||e<0&&i.isAtStart())&&(r=Ys(r,e,w,n,!0),Gl(r,n)))return Lc(e,r);var f=Ys(r,e,Gl,n),d=pe(U(function(e,t){for(var n=[];e&&e!==t;)n.push(e),e=e.parentNode;return n}(c,n),$l));return!d||f&&d.contains(f)?f?Lc(e,f):null:0<e?ss.after(d):ss.before(d)},Ql=function(e,t,n){var r=Ic(t);return ve.from(e?r.next(n):r.prev(n))},Zl=function(t,n,e,r){return zc(t,n,e).bind(function(e){return r(e)?Zl(t,n,e,r):ve.some(e)})},ef=R(Ql,!0),tf=R(Ql,!1),nf=R(Hc,!0),rf=R(Hc,!1),of="_mce_caret",af=function(e,t,n){return 2===t?Cs(Eo,n,e):3===t?(o=(r=e).getRng(),{start:ms(r.dom.getRoot(),ss.fromRangeStart(o)),end:ms(r.dom.getRoot(),ss.fromRangeEnd(o))}):t?{rng:e.getRng()}:ws(e,!1);var r,o},uf=(jl=xo,function(e){return jl===e}),sf=function(e,t){return void 0===t&&(t=!1),!(!V(e)||!jn(e))&&qr(t?e.data.replace(/ /g,"\xa0"):e.data)},cf=Jc,lf=ll,ff=sf,df=rl,mf=function(e,t,n,r){var o=n.parentNode;return!V(n[r])&&(!(o!==t&&!K(o)&&!e.isBlock(o))||mf(e,t,o,r))},gf=function(t){return Ft(t).fold(J([t]),function(e){return[t].concat(gf(e))})},pf=function(t){return Ut(t).fold(J([t]),function(e){return"br"===Nt(e)?Bt(e).map(function(e){return[t].concat(pf(e))}).getOr([]):[t].concat(pf(e))})},hf=(Vl=_n,{get:function(e){if(!Vl(e))throw new Error("Can only get text value of a text node");return ql(e).getOr("")},getOption:ql=function(e){return Vl(e)?ve.from(e.dom.nodeValue):ve.none()},set:function(e,t){if(!Vl(e))throw new Error("Can only set raw text value of a text node");e.dom.nodeValue=t}});function vf(e,t){for(;t&&t!==e;){if(Xn(t)||Yn(t))return t;t=t.parentNode}return null}function bf(t,n,e){if(!e.collapsed){if(xt.browser.isIE()&&e.startOffset===e.endOffset-1&&e.startContainer===e.endContainer){var r=e.startContainer.childNodes[e.startOffset];if(zn(r))return F(r.getClientRects(),function(e){return Bu(e,t,n)})}return F(e.getClientRects(),function(e){return Bu(e,t,n)})}}function yf(e,t,n){return e.fire(t,n)}function Cf(e,t,n,r){return e.fire("FormatApply",{format:t,node:n,vars:r})}function xf(e,t,n,r){return e.fire("FormatRemove",{format:t,node:n,vars:r})}function wf(r,l){function c(e){return e&&("IMG"===e.nodeName||l.dom.is(e,"figure.image"))}function f(e){return Jn(e)||T.hasClass(e,"mce-preview-object")}function n(e){var t=e.target;!function(e,t){if("longpress"!==e.type&&0!==e.type.indexOf("touch"))return c(e.target)&&!bf(e.clientX,e.clientY,t);var n=e.touches[0];return c(e.target)&&!bf(n.clientX,n.clientY,t)}(e,l.selection.getRng())||e.isDefaultPrevented()||l.selection.select(t)}function d(e){return T.is(e,"figure.image")?[e.querySelector("img")]:T.hasClass(e,"mce-preview-object")&&V(e.firstElementChild)?[e,e.firstElementChild]:[e]}function i(e){var t=Bs(l);return!!t&&"false"!==e.getAttribute("data-mce-resize")&&e!==l.getBody()&&(T.hasClass(e,"mce-preview-object")?ze(kt.fromDom(e.firstElementChild),t):ze(kt.fromDom(e),t))}function a(e,t,n){V(n)&&Y(d(e),function(e){e.style[t]||!l.schema.isValid(e.nodeName.toLowerCase(),t)?T.setStyle(e,t,n):T.setAttrib(e,t,""+n)})}function m(e,t,n){a(e,"width",t),a(e,"height",n)}function g(e){var t,n,r,o,i,a,u=e.screenX-C,s=e.screenY-x;N=u*b[2]+w,_=s*b[3]+S,N=N<5?5:N,_=_<5?5:_,((c(p)||f(p))&&!1!==l.getParam("resize_img_proportional",!0,"boolean")?!Lf.modifierPressed(e):Lf.modifierPressed(e))&&(L(u)>L(s)?(_=I(N*E),N=I(_/E)):(N=I(_/E),_=I(N*E))),m(h,N,_),t=b.startPos.x+u,n=b.startPos.y+s,T.setStyles(v,{left:t=0<t?t:0,top:n=0<n?n:0,display:"block"}),v.innerHTML=N+" × "+_,b[2]<0&&h.clientWidth<=N&&T.setStyle(h,"left",void 0+(w-N)),b[3]<0&&h.clientHeight<=_&&T.setStyle(h,"top",void 0+(S-_)),(u=M.scrollWidth-A)+(s=M.scrollHeight-R)!=0&&T.setStyles(v,{left:t-u,top:n-s}),k||(r=p,o=w,i=S,a="corner-"+b.name,l.fire("ObjectResizeStart",{target:r,width:o,height:i,origin:a}),k=!0)}function o(e){function t(e,t){if(e)do{if(e===t)return 1}while(e=e.parentNode)}var n;k||l.removed||(O(T.select("img[data-mce-selected],hr[data-mce-selected]"),function(e){e.removeAttribute(D)}),n="mousedown"===e.type?e.target:r.getNode(),t(n=T.$(n).closest("table,img,figure.image,hr,video,span.mce-preview-object")[0],M)&&(s(),t(r.getStart(!0),n)&&t(r.getEnd(!0),n))?z(n):H())}function u(e){return If(vf(l.getBody(),e))}function s(){try{l.getDoc().execCommand("enableObjectResizing",!1,"false")}catch(e){}}var p,h,v,b,y,C,x,w,S,E,k,N,_,A,R,D="data-mce-selected",T=l.dom,O=Et.each,B=l.getDoc(),P=document,L=Math.abs,I=Math.round,M=l.getBody(),F={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]},U=function(){var e,t,n,r,o=k;k=!1,o&&(a(p,"width",N),a(p,"height",_)),T.unbind(B,"mousemove",g),T.unbind(B,"mouseup",U),P!==B&&(T.unbind(P,"mousemove",g),T.unbind(P,"mouseup",U)),T.remove(h),T.remove(v),T.remove(y),z(p),o&&(e=p,t=N,n=_,r="corner-"+b.name,l.fire("ObjectResized",{target:e,width:t,height:n,origin:r}),T.setAttrib(p,"style",T.getAttrib(p,"style"))),l.nodeChanged()},z=function(e){j();var t=T.getPos(e,M),a=t.x,u=t.y,n=e.getBoundingClientRect(),s=n.width||n.right-n.left,c=n.height||n.bottom-n.top;p!==e&&(H(),p=e,N=_=0);var r=l.fire("ObjectSelected",{target:e}),o=T.getAttrib(p,D,"1");i(e)&&!r.isDefaultPrevented()?O(F,function(o,i){var e=T.get("mceResizeHandle"+i);e&&T.remove(e),e=T.add(M,"div",{id:"mceResizeHandle"+i,"data-mce-bogus":"all",class:"mce-resizehandle",unselectable:!0,style:"cursor:"+i+"-resize; margin:0; padding:0"}),11===xt.ie&&(e.contentEditable=!1),T.bind(e,"mousedown",function(e){var t,n,r;e.stopImmediatePropagation(),e.preventDefault(),t=e,r=d(p)[0],C=t.screenX,x=t.screenY,w=r.clientWidth,S=r.clientHeight,E=S/w,(b=o).name=i,b.startPos={x:s*o[0]+a,y:c*o[1]+u},A=M.scrollWidth,R=M.scrollHeight,y=T.add(M,"div",{class:"mce-resize-backdrop","data-mce-bogus":"all"}),T.setStyles(y,{position:"fixed",left:"0",top:"0",width:"100%",height:"100%"}),h=f(n=p)?T.create("img",{src:xt.transparentSrc}):n.cloneNode(!0),T.addClass(h,"mce-clonedresizable"),T.setAttrib(h,"data-mce-bogus","all"),h.contentEditable="false",T.setStyles(h,{left:a,top:u,margin:0}),m(h,s,c),h.removeAttribute(D),M.appendChild(h),T.bind(B,"mousemove",g),T.bind(B,"mouseup",U),P!==B&&(T.bind(P,"mousemove",g),T.bind(P,"mouseup",U)),v=T.add(M,"div",{class:"mce-resize-helper","data-mce-bogus":"all"},w+" × "+S)}),o.elm=e,T.setStyles(e,{left:s*o[0]+a-e.offsetWidth/2,top:c*o[1]+u-e.offsetHeight/2})}):H(),T.getAttrib(p,D)||p.setAttribute(D,o)},H=function(){j(),p&&p.removeAttribute(D),ne(F,function(e,t){var n=T.get("mceResizeHandle"+t);n&&(T.unbind(n),T.remove(n))})},j=function(){ne(F,function(e){e.elm&&(T.unbind(e.elm),delete e.elm)})};return l.on("init",function(){var e;s(),(xt.browser.isIE()||xt.browser.isEdge())&&(l.on("mousedown click",function(e){var t=e.target,n=t.nodeName;k||!/^(TABLE|IMG|HR)$/.test(n)||u(t)||(2!==e.button&&l.selection.select(t,"TABLE"===n),"mousedown"===e.type&&l.nodeChanged())}),T.bind(M,"mscontrolselect",e=function(e){function t(e){_r.setEditorTimeout(l,function(){return l.selection.select(e)})}if(u(e.target)||Jn(e.target))return e.preventDefault(),void t(e.target);/^(TABLE|IMG|HR)$/.test(e.target.nodeName)&&(e.preventDefault(),"IMG"===e.target.tagName&&t(e.target))}),l.on("remove",function(){return T.unbind(M,"mscontrolselect",e)}));var t=_r.throttle(function(e){l.composing||o(e)});l.on("NodeChange ResizeEditor ResizeWindow ResizeContent drop",t),l.on("keyup compositionend",function(e){p&&"TABLE"===p.nodeName&&t(e)}),l.on("hide blur",H),l.on("contextmenu longpress",n,!0)}),l.on("remove",j),{isResizable:i,showResizeRect:z,hideResizeRect:H,updateResizeRect:o,destroy:function(){p=h=y=null}}}function Sf(e){return Xn(e)||Yn(e)}function Ef(t,n,r){var o,e,i,a,u,s=r;if(s.caretPositionFromPoint)(e=s.caretPositionFromPoint(t,n))&&((o=r.createRange()).setStart(e.offsetNode,e.offset),o.collapse(!0));else if(s.caretRangeFromPoint)o=s.caretRangeFromPoint(t,n);else if(s.body.createTextRange){o=s.body.createTextRange();try{o.moveToPoint(t,n),o.collapse(!0)}catch(e){o=function(e,n,t){var r,o=t.elementFromPoint(e,n),i=t.body.createTextRange();if(o&&"HTML"!==o.tagName||(o=t.body),i.moveToElementText(o),0<(r=(r=Et.toArray(i.getClientRects())).sort(function(e,t){return(e=Math.abs(Math.max(e.top-n,e.bottom-n)))-Math.abs(Math.max(t.top-n,t.bottom-n))})).length){n=(r[0].bottom+r[0].top)/2;try{return i.moveToPoint(e,n),i.collapse(!0),i}catch(e){}}return null}(t,n,r)}return i=o,a=r.body,u=i&&i.parentElement?i.parentElement():null,Yn(function(e,t,n){for(;e&&e!==t;){if(n(e))return e;e=e.parentNode}return null}(u,a,Sf))?null:i}return o}function kf(e,t){return e&&t&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}function Nf(e,t,n){return null!==function(e,t,n){for(;e&&e!==t;){if(n(e))return e;e=e.parentNode}return null}(e,t,n)}function _f(e){return e&&"TABLE"===e.nodeName}function Af(e,t,n){for(var r=new Rr(t,e.getParent(t.parentNode,e.isBlock)||e.getRoot());t=r[n?"prev":"next"]();)if(Wn(t))return 1}function Rf(e,t,n,r,o){var i,a,u=e.getRoot(),s=e.schema.getNonEmptyElements(),c=e.getParent(o.parentNode,e.isBlock)||u;if(r&&Wn(o)&&t&&e.isEmpty(c))return ve.some(ss(o.parentNode,e.nodeIndex(o)));for(var l,f,d=new Rr(o,c);a=d[r?"prev":"next"]();){if("false"===e.getContentEditableParent(a)||(f=u,Ir(l=a)&&!1===Nf(l,f,jc)))return ve.none();if(jn(a)&&0<a.nodeValue.length)return!1===Nf(a,u,function(e){return"A"===e.nodeName})?ve.some(ss(a,r?a.nodeValue.length:0)):ve.none();if(e.isBlock(a)||s[a.nodeName.toLowerCase()])return ve.none();i=a}return n&&i?ve.some(ss(i,0)):ve.none()}function Df(e,t,n,r){var o,i=e.getRoot(),a=!1,u=r[(n?"start":"end")+"Container"],s=r[(n?"start":"end")+"Offset"],c=zn(u)&&s===u.childNodes.length,l=e.schema.getNonEmptyElements(),f=n;if(Ir(u))return ve.none();if(zn(u)&&s>u.childNodes.length-1&&(f=!1),qn(u)&&(u=i,s=0),u===i){if(f&&(d=u.childNodes[0<s?s-1:0])){if(Ir(d))return ve.none();if(l[d.nodeName]||_f(d))return ve.none()}if(u.hasChildNodes()){if(s=Math.min(!f&&0<s?s-1:s,u.childNodes.length-1),u=u.childNodes[s],s=jn(u)&&c?u.data.length:0,!t&&u===i.lastChild&&_f(u))return ve.none();if(function(e,t){for(;t&&t!==e;){if(Yn(t))return 1;t=t.parentNode}}(i,u)||Ir(u))return ve.none();if(u.hasChildNodes()&&!1===_f(u)){var d=u,m=new Rr(u,i);do{if(Yn(d)||Ir(d)){a=!1;break}if(jn(d)&&0<d.nodeValue.length){s=f?0:d.nodeValue.length,u=d,a=!0;break}if(l[d.nodeName.toLowerCase()]&&(!(o=d)||!/^(TD|TH|CAPTION)$/.test(o.nodeName))){s=e.nodeIndex(d),u=d.parentNode,f||s++,a=!0;break}}while(d=f?m.next():m.prev())}}}return t&&(jn(u)&&0===s&&Rf(e,c,t,!0,u).each(function(e){u=e.container(),s=e.offset(),a=!0}),zn(u)&&(!(d=(d=u.childNodes[s])||u.childNodes[s-1])||!Wn(d)||d.previousSibling&&"A"===d.previousSibling.nodeName||Af(e,d,!1)||Af(e,d,!0)||Rf(e,c,t,!0,d).each(function(e){u=e.container(),s=e.offset(),a=!0}))),f&&!t&&jn(u)&&s===u.nodeValue.length&&Rf(e,c,t,!1,u).each(function(e){u=e.container(),s=e.offset(),a=!0}),a?ve.some(ss(u,s)):ve.none()}function Tf(e,t){var n=t.collapsed,r=t.cloneRange(),o=ss.fromRangeStart(t);return Df(e,n,!0,r).each(function(e){n&&ss.isAbove(o,e)||r.setStart(e.container(),e.offset())}),n||Df(e,n,!1,r).each(function(e){r.setEnd(e.container(),e.offset())}),n&&r.collapse(!0),kf(t,r)?ve.none():ve.some(r)}function Of(e,t){return e.splitText(t)}function Bf(e){var t=e.startContainer,n=e.startOffset,r=e.endContainer,o=e.endOffset;return t===r&&jn(t)?0<n&&n<t.nodeValue.length&&(t=(r=Of(t,n)).previousSibling,n<o?(t=r=Of(r,o-=n).previousSibling,o=r.nodeValue.length,n=0):o=0):(jn(t)&&0<n&&n<t.nodeValue.length&&(t=Of(t,n),n=0),jn(r)&&0<o&&o<r.nodeValue.length&&(o=(r=Of(r,o).previousSibling).nodeValue.length)),{startContainer:t,startOffset:n,endContainer:r,endOffset:o}}function Pf(n){return{walk:function(e,t){return Nl(n,e,t)},split:Bf,normalize:function(t){return Tf(n,t).fold(D,function(e){return t.setStart(e.startContainer,e.startOffset),t.setEnd(e.endContainer,e.endOffset),!0})}}}zl.isBookmarkNode=Jc;var Lf={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,modifierPressed:function(e){return e.shiftKey||e.ctrlKey||e.altKey||Lf.metaKeyPressed(e)},metaKeyPressed:function(e){return xt.mac?e.metaKey:e.ctrlKey&&!e.altKey}},If=Yn;Pf.compareRanges=kf,Pf.getCaretRangeFromPoint=Ef,Pf.getSelectedNode=Pu,Pf.getNode=Lu;var Mf,Ff,Uf=(Mf="height",Ff=function(e){var t=e.dom;return In(e)?t.getBoundingClientRect().height:t.offsetHeight},{set:function(e,t){if(!E(t)&&!t.match(/^[0-9]+$/))throw new Error(Mf+".set accepts only positive integer values. Value was "+t);var n=e.dom;mn(n)&&(n.style[Mf]=t+"px")},get:zf,getOuter:zf,aggregate:Hf,max:function(e,t,n){var r=Hf(e,n);return r<t?t-r:0}});function zf(e){var t=Ff(e);if(t<=0||null===t){var n=xn(e,Mf);return parseFloat(n)||0}return t}function Hf(o,e){return L(e,function(e,t){var n=xn(o,t),r=void 0===n?0:parseInt(n,10);return isNaN(r)?e:e+r},0)}function jf(e){return"textarea"===Nt(e)}function Vf(e,t){var n=function(e){var t=e.dom.ownerDocument,n=t.body,r=t.defaultView,o=t.documentElement;if(n===e.dom)return Fn(n.offsetLeft,n.offsetTop);var i=Gt(null==r?void 0:r.pageYOffset,o.scrollTop),a=Gt(null==r?void 0:r.pageXOffset,o.scrollLeft),u=Gt(o.clientTop,n.clientTop),s=Gt(o.clientLeft,n.clientLeft);return Un(e).translate(a-s,i-u)}(e),r=Uf.get(e);return{element:e,bottom:n.top+r,height:r,pos:n,cleanup:t}}function qf(n,r,o,i){Td(n,function(e,t){return Dd(n,r,o,i)},o)}function $f(e,t,n,r,o){var i={elm:r.element.dom,alignToTop:o};e.fire("ScrollIntoView",i).isDefaultPrevented()||(n(t,Jt(t).top,r,o),e.fire("AfterScrollIntoView",i))}function Wf(e,t,n,r){var o=kt.fromDom(e.getDoc());$f(e,o,n,Vf(kt.fromDom(t),te),r)}function Kf(e,t,n,r){var o,i=e.pos;n?Qt(i.left,i.top,r):(o=i.top-t+e.height,Qt(i.left,o,r))}function Xf(e,t,n,r,o){var i=n+t,a=r.pos.top,u=r.bottom,s=n<=u-a;a<t?Kf(r,n,!1!==o,e):i<a?Kf(r,n,s?!1!==o:!0===o,e):i<u&&!s&&Kf(r,n,!0===o,e)}function Yf(e,t,n,r){Xf(e,t,e.dom.defaultView.innerHeight,n,r)}function Gf(e,t,n,r){Xf(e,t,e.dom.defaultView.innerHeight,n,r);var o,i,a,u,s,c,l,f=(o=n.element,u=Jt(kt.fromDom(document)),a=(i=Rd).owner(o),s=Ad(i,a),c=Un(o),l=P(s,function(e,t){var n=Un(t);return{left:e.left+n.left,top:e.top+n.top}},{left:0,top:0}),Fn(l.left+c.left+u.left,l.top+c.top+u.top)),d=tn(window);f.top<d.y?Zt(n.element,!1!==r):f.top>d.bottom&&Zt(n.element,!0===r)}function Jf(e,t,n){return qf(e,Yf,t,n)}function Qf(e,t,n){return Wf(e,t,Yf,n)}function Zf(e,t,n){return qf(e,Gf,t,n)}function ed(e,t,n){return Wf(e,t,Gf,n)}function td(e,t,n){(e.inline?Jf:Zf)(e,t,n)}function nd(e){var t=Bn(e).dom;return e.dom===t.activeElement}function rd(e){return void 0===e&&(e=kt.fromDom(document)),ve.from(e.dom.activeElement).map(kt.fromDom)}function od(e,t){var n=_n(t)?Il(t).length:Dn(t).length+1;return n<e?n:e<0?0:e}function id(e){return Ld.range(e.start,od(e.soffset,e.start),e.finish,od(e.foffset,e.finish))}function ad(e,t){return!rn(t.dom)&&(Ve(e,t)||je(e,t))}function ud(t){return function(e){return ad(t,e.start)&&ad(t,e.finish)}}function sd(e){return!0===e.inline||Id.isIE()}function cd(e){return Ld.range(kt.fromDom(e.startContainer),e.startOffset,kt.fromDom(e.endContainer),e.endOffset)}function ld(e){var t=document.createRange();try{return t.setStart(e.start.dom,e.soffset),t.setEnd(e.finish.dom,e.foffset),ve.some(t)}catch(e){return ve.none()}}function fd(e){var t,n,r=sd(e)?(t=kt.fromDom(e.getBody()),((n=Tt(t).dom.getSelection())&&0!==n.rangeCount?ve.from(n.getRangeAt(0)):ve.none()).map(cd).filter(ud(t))):ve.none();e.bookmark=r.isSome()?r:e.bookmark}function dd(n){return(n.bookmark||ve.none()).bind(function(e){return t=kt.fromDom(n.getBody()),ve.from(e).filter(ud(t)).map(id);var t}).bind(ld)}function md(u){var s=du(function(){fd(u)},0);u.on("init",function(){function e(){n.throttle()}var t,n,r,o,i,a;u.inline&&(t=u,n=s,Za.DOM.bind(document,"mouseup",e),t.on("remove",function(){Za.DOM.unbind(document,"mouseup",e)})),r=u,o=s,dt().browser.isIE()?(a=r).on("focusout",function(){fd(a)}):(i=o,r.on("mouseup touchend",function(e){i.throttle()})),r.on("keyup NodeChange",function(e){"nodechange"===e.type&&e.selectionChange||fd(r)})}),u.on("remove",function(){s.cancel()})}function gd(t,e){var n=t.getParam("custom_ui_selector","","string");return null!==Fd.getParent(e,function(e){return Md.isEditorUIElement(e)||!!n&&t.dom.is(e,n)})}function pd(n,e){var t=e.editor;md(t),t.on("focusin",function(){var e=n.focusedEditor;e!==t&&(e&&e.fire("blur",{focusedEditor:t}),n.setActive(t),(n.focusedEditor=t).fire("focus",{blurredEditor:e}),t.focus(!0))}),t.on("focusout",function(){_r.setEditorTimeout(t,function(){var e=n.focusedEditor;gd(t,function(e){try{return rd(Bn(kt.fromDom(e.getElement()))).fold(function(){return document.body},function(e){return e.dom})}catch(e){return document.body}}(t))||e!==t||(t.fire("blur",{focusedEditor:null}),n.focusedEditor=null)})}),_d||(_d=function(e){var t=n.activeEditor;t&&!function(e){if(On()&&V(e.target)){var t=kt.fromDom(e.target);if(Nn(t)&&V(t.dom.shadowRoot)&&e.composed&&e.composedPath){var n=e.composedPath();if(n)return Q(n)}}return ve.from(e.target)}(e).each(function(e){e.ownerDocument===document&&(e===document.body||gd(t,e)||n.focusedEditor!==t||(t.fire("blur",{focusedEditor:null}),n.focusedEditor=null))})},Fd.bind(document,"focusin",_d))}function hd(e,t){e.focusedEditor===t.editor&&(e.focusedEditor=null),e.activeEditor||(Fd.unbind(document,"focusin",_d),_d=null)}function vd(t,e){var n,r;n=kt.fromDom(t.getBody()),((r=e).collapsed?ve.from(Lu(r.startContainer,r.startOffset)).map(kt.fromDom):ve.none()).bind(function(e){return vo(e)?ve.some(e):!1===Ve(n,e)?ve.some(n):ve.none()}).bind(function(e){return nf(e.dom)}).fold(function(){t.selection.normalize()},function(e){return t.selection.setRng(e.toRange())})}function bd(t){if(t.setActive)try{t.setActive()}catch(e){t.focus()}else t.focus()}function yd(e){return e.inline?(r=e.getBody())&&(nd(t=kt.fromDom(r))||rd(Bn(n=t)).filter(function(e){return n.dom.contains(e.dom)}).isSome()):e.iframeElement&&nd(kt.fromDom(e.iframeElement));var t,n,r}function Cd(e,t,n,r,o){var i=n?t.startContainer:t.endContainer,a=n?t.startOffset:t.endOffset;return ve.from(i).map(kt.fromDom).map(function(e){return r&&t.collapsed?e:Mt(e,o(e,a)).getOr(e)}).bind(function(e){return Nn(e)?ve.some(e):Ot(e).filter(Nn)}).map(function(e){return e.dom}).getOr(e)}function xd(e,t,n){return Cd(e,t,!0,n,function(e,t){return Math.min(zt(e),t)})}function wd(e,t,n){return Cd(e,t,!1,n,function(e,t){return 0<t?t-1:t})}function Sd(e,t){for(var n=e;e&&jn(e)&&0===e.length;)e=t?e.nextSibling:e.previousSibling;return e||n}function Ed(n,e){return A(e,function(e){var t=n.fire("GetSelectionRange",{range:e});return t.range!==e?t.range:e})}function kd(e,t,n){var r=n?"lastChild":"firstChild",o=n?"prev":"next";if(e[r])return e[r];if(e!==t){var i=e[o];if(i)return i;for(var a=e.parent;a&&a!==t;a=a.parent)if(i=a[o])return i}}function Nd(e){var t="a"===e.name&&!e.attr("href")&&e.attr("id");return e.attr("name")||e.attr("id")&&!e.firstChild||e.attr("data-mce-bookmark")||t}var _d,Ad=function(r,e){return r.view(e).fold(J([]),function(e){var t=r.owner(e),n=Ad(r,t);return[e].concat(n)})},Rd=Object.freeze({__proto__:null,view:function(e){var t;return(e.dom===document?ve.none():ve.from(null===(t=e.dom.defaultView)||void 0===t?void 0:t.frameElement)).map(kt.fromDom)},owner:Dt}),Dd=function(e,t,n,r){var o=kt.fromDom(e.getBody()),i=kt.fromDom(e.getDoc());o.dom.offsetWidth;var a,u,s,c,l=(a=kt.fromDom(n.startContainer),u=n.startOffset,s=function(e,t){var n=Dn(e);if(0===n.length||jf(e))return{element:e,offset:t};if(t<n.length&&!jf(n[t]))return{element:n[t],offset:0};var r=n[n.length-1];return jf(r)?{element:e,offset:t}:"img"===Nt(r)?{element:r,offset:1}:_n(r)?{element:r,offset:Il(r).length}:{element:r,offset:Dn(r).length}}(a,u),c=kt.fromHtml('<span data-mce-bogus="all" style="display: inline-block;">\ufeff</span>'),qt(s.element,c),Vf(c,function(){return Ln(c)}));$f(e,i,t,l,r),l.cleanup()},Td=function(e,t,n){var r=n.startContainer,o=n.startOffset,i=n.endContainer,a=n.endOffset;t(kt.fromDom(r),kt.fromDom(i));var u=e.dom.createRng();u.setStart(r,o),u.setEnd(i,a),e.selection.setRng(n)},Od=or([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Bd=(Od.before,Od.on,Od.after,function(e){return e.fold(u,u,u)}),Pd=or([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Ld={domRange:Pd.domRange,relative:Pd.relative,exact:Pd.exact,exactFromRange:function(e){return Pd.exact(e.start,e.soffset,e.finish,e.foffset)},getWin:function(e){return Tt(e.match({domRange:function(e){return kt.fromDom(e.startContainer)},relative:function(e,t){return Bd(e)},exact:function(e,t,n,r){return e}}))},range:function(e,t,n,r){return{start:e,soffset:t,finish:n,foffset:r}}},Id=dt().browser,Md={isEditorUIElement:function(e){var t=e.className.toString();return-1!==t.indexOf("tox-")||-1!==t.indexOf("mce-")}},Fd=Za.DOM,Ud=function(e){return e.editorManager.setActive(e)},zd={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11},Hd=(jd.create=function(e,t){var n=new jd(e,zd[e]||1);return t&&ne(t,function(e,t){n.attr(t,e)}),n},jd.prototype.replace=function(e){return e.parent&&e.remove(),this.insert(e,this),this.remove(),this},jd.prototype.attr=function(e,t){var n,r=this;if("string"!=typeof e)return null!=e&&ne(e,function(e,t){r.attr(t,e)}),r;if(n=r.attributes){if(void 0===t)return n.map[e];if(null===t){if(e in n.map){delete n.map[e];for(var o=n.length;o--;)if(n[o].name===e)return n.splice(o,1),r}return r}if(e in n.map){for(o=n.length;o--;)if(n[o].name===e){n[o].value=t;break}}else n.push({name:e,value:t});return n.map[e]=t,r}},jd.prototype.clone=function(){var e,t=new jd(this.name,this.type);if(e=this.attributes){var n=[];n.map={};for(var r=0,o=e.length;r<o;r++){var i=e[r];"id"!==i.name&&(n[n.length]={name:i.name,value:i.value},n.map[i.name]=i.value)}t.attributes=n}return t.value=this.value,t.shortEnded=this.shortEnded,t},jd.prototype.wrap=function(e){return this.parent.insert(e,this),e.append(this),this},jd.prototype.unwrap=function(){for(var e=this.firstChild;e;){var t=e.next;this.insert(e,this,!0),e=t}this.remove()},jd.prototype.remove=function(){var e=this.parent,t=this.next,n=this.prev;return e&&(e.firstChild===this?(e.firstChild=t)&&(t.prev=null):n.next=t,e.lastChild===this?(e.lastChild=n)&&(n.next=null):t.prev=n,this.parent=this.next=this.prev=null),this},jd.prototype.append=function(e){e.parent&&e.remove();var t=this.lastChild;return t?((t.next=e).prev=t,this.lastChild=e):this.lastChild=this.firstChild=e,e.parent=this,e},jd.prototype.insert=function(e,t,n){e.parent&&e.remove();var r=t.parent||this;return n?(t===r.firstChild?r.firstChild=e:t.prev.next=e,e.prev=t.prev,(e.next=t).prev=e):(t===r.lastChild?r.lastChild=e:t.next.prev=e,e.next=t.next,(e.prev=t).next=e),e.parent=r,e},jd.prototype.getAll=function(e){for(var t=[],n=this.firstChild;n;n=kd(n,this))n.name===e&&t.push(n);return t},jd.prototype.children=function(){for(var e=[],t=this.firstChild;t;t=t.next)e.push(t);return e},jd.prototype.empty=function(){if(this.firstChild){for(var e=[],t=this.firstChild;t;t=kd(t,this))e.push(t);for(var n=e.length;n--;)(t=e[n]).parent=t.firstChild=t.lastChild=t.next=t.prev=null}return this.firstChild=this.lastChild=null,this},jd.prototype.isEmpty=function(e,t,n){void 0===t&&(t={});var r=this.firstChild;if(Nd(this))return!1;if(r)do{if(1===r.type){if(r.attr("data-mce-bogus"))continue;if(e[r.name])return!1;if(Nd(r))return!1}if(8===r.type)return!1;if(3===r.type&&!function(e){if(qr(e.value)){var t=e.parent;return!t||"span"===t.name&&!t.attr("style")||!/^[ ]+$/.test(e.value)}}(r))return!1;if(3===r.type&&r.parent&&t[r.parent.name]&&qr(r.value))return!1;if(n&&n(r))return!1}while(r=kd(r,this));return!0},jd.prototype.walk=function(e){return kd(this,null,e)},jd);function jd(e,t){this.name=e,1===(this.type=t)&&(this.attributes=[],this.attributes.map={})}function Vd(e,t){return e.replace(t.re,function(e){return ue(t.uris,e).getOr(e)})}var qd=Et.each,$d=Et.trim,Wd="source protocol authority userInfo user password host port relative path directory file query anchor".split(" "),Kd={ftp:21,http:80,https:443,mailto:25},Xd=["img","video"],Yd=(Gd.parseDataUri=function(e){var t,n=decodeURIComponent(e).split(","),r=/data:([^;]+)/.exec(n[0]);return{type:t=r?r[1]:t,data:n[1]}},Gd.isDomSafe=function(e,t,n){if((n=void 0===n?{}:n).allow_script_urls)return!0;var r,o,i,a,u=Qo.decode(e).replace(/[\s\u0000-\u001F]+/g,"");try{u=decodeURIComponent(u)}catch(e){u=unescape(u)}return!(/((java|vb)script|mhtml):/i.test(u)||(o=u,i=t,!(r=n).allow_html_data_urls&&(/^data:image\//i.test(o)?(V(a=r.allow_svg_data_urls)?!a:!V(i)||!T(Xd,i))&&/^data:image\/svg\+xml/i.test(o):/^data:/i.test(o))))},Gd.getDocumentBaseUrl=function(e){var t=0!==e.protocol.indexOf("http")&&"file:"!==e.protocol?e.href:e.protocol+"//"+e.host+e.pathname;return/^[^:]+:\/\/\/?[^\/]+\//.test(t)&&(t=t.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(t)||(t+="/")),t},Gd.prototype.setPath=function(e){var t=/^(.*?)\/?(\w+)?$/.exec(e);this.path=t[0],this.directory=t[1],this.file=t[2],this.source="",this.getURI()},Gd.prototype.toRelative=function(e){var t;if("./"===e)return e;var n=new Gd(e,{base_uri:this});if("mce_host"!==n.host&&this.host!==n.host&&n.host||this.port!==n.port||this.protocol!==n.protocol&&""!==n.protocol)return n.getURI();var r=this.getURI(),o=n.getURI();return r===o||"/"===r.charAt(r.length-1)&&r.substr(0,r.length-1)===o?r:(t=this.toRelPath(this.path,n.path),n.query&&(t+="?"+n.query),n.anchor&&(t+="#"+n.anchor),t)},Gd.prototype.toAbsolute=function(e,t){var n=new Gd(e,{base_uri:this});return n.getURI(t&&this.isSameOrigin(n))},Gd.prototype.isSameOrigin=function(e){if(this.host==e.host&&this.protocol==e.protocol){if(this.port==e.port)return!0;var t=Kd[this.protocol];if(t&&(this.port||t)==(e.port||t))return!0}return!1},Gd.prototype.toRelPath=function(e,t){var n,r,o=0,i="",a=e.substring(0,e.lastIndexOf("/")).split("/"),u=t.split("/");if(a.length>=u.length)for(n=0,r=a.length;n<r;n++)if(n>=u.length||a[n]!==u[n]){o=n+1;break}if(a.length<u.length)for(n=0,r=u.length;n<r;n++)if(n>=a.length||a[n]!==u[n]){o=n+1;break}if(1===o)return t;for(n=0,r=a.length-(o-1);n<r;n++)i+="../";for(n=o-1,r=u.length;n<r;n++)i+=n!==o-1?"/"+u[n]:u[n];return i},Gd.prototype.toAbsPath=function(e,t){var n,r,o=0,i=[],a=/\/$/.test(t)?"/":"",u=e.split("/"),s=t.split("/");for(qd(u,function(e){e&&i.push(e)}),u=i,n=s.length-1,i=[];0<=n;n--)0!==s[n].length&&"."!==s[n]&&(".."!==s[n]?0<o?o--:i.push(s[n]):o++);return 0!==(r=(n=u.length-o)<=0?q(i).join("/"):u.slice(0,n).join("/")+"/"+q(i).join("/")).indexOf("/")&&(r="/"+r),a&&r.lastIndexOf("/")!==r.length-1&&(r+=a),r},Gd.prototype.getURI=function(e){var t;return void 0===e&&(e=!1),this.source&&!e||(t="",e||(this.protocol?t+=this.protocol+"://":t+="//",this.userInfo&&(t+=this.userInfo+"@"),this.host&&(t+=this.host),this.port&&(t+=":"+this.port)),this.path&&(t+=this.path),this.query&&(t+="?"+this.query),this.anchor&&(t+="#"+this.anchor),this.source=t),this.source},Gd);function Gd(e,t){e=$d(e),this.settings=t||{};var n,r,o,i,a=this.settings.base_uri,u=this;/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e)?u.source=e:(n=0===e.indexOf("//"),0!==e.indexOf("/")||n||(e=(a&&a.protocol||"http")+"://mce_host"+e),/^[\w\-]*:?\/\//.test(e)||(r=this.settings.base_uri?this.settings.base_uri.path:new Gd(document.location.href).directory,e=this.settings.base_uri&&""==this.settings.base_uri.protocol?"//mce_host"+u.toAbsPath(r,e):(o=/([^#?]*)([#?]?.*)/.exec(e),(a&&a.protocol||"http")+"://mce_host"+u.toAbsPath(r,o[1])+o[2])),e=e.replace(/@@/g,"(mce_at)"),i=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?(\[[a-zA-Z0-9:.%]+\]|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e),qd(Wd,function(e,t){var n=(n=i[t])&&n.replace(/\(mce_at\)/g,"@@");u[e]=n}),a&&(u.protocol||(u.protocol=a.protocol),u.userInfo||(u.userInfo=a.userInfo),u.port||"mce_host"!==u.host||(u.port=a.port),u.host&&"mce_host"!==u.host||(u.host=a.host),u.source=""),n&&(u.protocol=""))}function Jd(e,t,n){for(var r=/<([!?\/])?([A-Za-z0-9\-_:.]+)/g,o=/(?:\s(?:[^'">]+(?:"[^"]*"|'[^']*'))*[^"'>]*(?:"[^">]*|'[^'>]*)?|\s*|\/)>/g,i=e.getShortEndedElements(),a=1,u=n;0!==a;)for(r.lastIndex=u;;){var s=r.exec(t);if(null===s)return u;if("!"===s[1]){u=Ge(s[2],"--")?tm(t,!1,s.index+"!--".length):tm(t,!0,s.index+1);break}o.lastIndex=r.lastIndex;var c=o.exec(t);if(!l(c)&&c.index===r.lastIndex){"/"===s[1]?--a:ke(i,s[2])||(a+=1),u=r.lastIndex+c[0].length;break}}return u}function Qd(q,$){void 0===$&&($=ro()),q=q||{};var W=em(),K=W.createElement("form");function n(s,e){void 0===e&&(e="html");for(var t,i,n,c,r,o,a,l,u,f,d,m,g,p,h,v,b,y,C,x=s.html,w=0,S=[],E=0,k=Qo.decode,N=Et.makeMap("src,href,data,background,action,formaction,poster,xlink:href"),_="html"===e?0:1,A=function(e){for(var t,n=S.length;n--&&S[n].name!==e;);if(0<=n){for(t=S.length-1;n<=t;t--)(e=S[t]).valid&&Q(e.name);S.length=n}},R=function(e,t){return G(Vd(e,s),t)},D=function(e){""!==e&&(">"===e.charAt(0)&&(e=" "+e),q.allow_conditional_comments||"[if"!==e.substr(0,3).toLowerCase()||(e=" "+e),X(Vd(e,s)))},T=function(e,t){var n=e||"",r=!Ge(n,"--"),o=tm(x,r,t);return e=x.substr(t,o-t),D(r?n+e:e),o+1},O=new RegExp("<(?:(?:!--([\\w\\W]*?)--!?>)|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|(?:![Dd][Oo][Cc][Tt][Yy][Pp][Ee]([\\w\\W]*?)>)|(?:!(--)?)|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|(?:\\/([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)>)|(?:([A-Za-z][A-Za-z0-9\\-_:.]*)(\\s(?:[^'\">]+(?:\"[^\"]*\"|'[^']*'))*[^\"'>]*(?:\"[^\">]*|'[^'>]*)?|\\s*|\\/)>))","g"),B=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g,P=$.getShortEndedElements(),L=q.self_closing_elements||$.getSelfClosingElements(),I=$.getBoolAttrs(),M=q.validate,F=q.remove_internals,U=q.fix_self_closing,z=$.getSpecialElements(),H=x+">";t=O.exec(H);){var j=t[0];if(w<t.index&&R(k(x.substr(w,t.index-w))),i=t[7])A(i=":"===(i=i.toLowerCase()).charAt(0)?i.substr(1):i);else if(i=t[8]){if(t.index+j.length>x.length){R(k(x.substr(t.index))),w=t.index+j.length;continue}u=(i=":"===(i=i.toLowerCase()).charAt(0)?i.substr(1):i)in P,U&&L[i]&&0<S.length&&S[S.length-1].name===i&&A(i);var V=function(e,t){var n=e.exec(t);if(n){var r=n[1],o=n[2];return"string"==typeof r&&"data-mce-bogus"===r.toLowerCase()?o:null}return null}(B,t[9]);if(null!==V){if("all"===V){w=Jd($,x,O.lastIndex),O.lastIndex=w;continue}d=!1}if(!M||(f=$.getElementRule(i))){if(d=!0,M&&(p=f.attributes,h=f.attributePatterns),(g=t[9])?((l=-1!==g.indexOf("data-mce-type"))&&F&&(d=!1),(c=[]).map={},g.replace(B,function(e,t,n,r,o){return function(e,t,n,r,o){var i;if(n=Vd((t=t.toLowerCase())in I?t:k(n||r||o||""),s),M&&!l&&0==(0===(i=t).indexOf("data-")||0===i.indexOf("aria-"))){var a=p[t];if(!a&&h){for(var u=h.length;u--&&!(a=h[u]).pattern.test(t););-1===u&&(a=null)}if(!a)return;if(a.validValues&&!(n in a.validValues))return}("name"===t||"id"===t)&&e in Zd&&(n in W||n in K)||N[t]&&!Yd.isDomSafe(n,e,q)||l&&(t in N||0===t.indexOf("on"))||(c.map[t]=n,c.push({name:t,value:n}))}(i,t,n,r,o),""})):(c=[]).map={},M&&!l){if(v=f.attributesRequired,b=f.attributesDefault,y=f.attributesForced,f.removeEmptyAttrs&&!c.length&&(d=!1),y)for(r=y.length;r--;)a=(m=y[r]).name,"{$uid}"===(C=m.value)&&(C="mce_"+E++),c.map[a]=C,c.push({name:a,value:C});if(b)for(r=b.length;r--;)(a=(m=b[r]).name)in c.map||("{$uid}"===(C=m.value)&&(C="mce_"+E++),c.map[a]=C,c.push({name:a,value:C}));if(v){for(r=v.length;r--&&!(v[r]in c.map););-1===r&&(d=!1)}if(m=c.map["data-mce-bogus"]){if("all"===m){w=Jd($,x,O.lastIndex),O.lastIndex=w;continue}d=!1}}d&&J(i,c,u)}else d=!1;if(n=z[i]){n.lastIndex=w=t.index+j.length,w=(t=n.exec(x))?(d&&(o=x.substr(w,t.index-w)),t.index+t[0].length):(o=x.substr(w),x.length),d&&(0<o.length&&R(o,!0),Q(i)),O.lastIndex=w;continue}u||(g&&g.indexOf("/")===g.length-1?d&&Q(i):S.push({name:i,valid:d}))}else if(i=t[1])D(i);else if(i=t[2]){if(!(1==_||q.preserve_cdata||0<S.length&&$.isValidChild(S[S.length-1].name,"#cdata"))){w=T("",t.index+2),O.lastIndex=w;continue}Y(i)}else if(i=t[3])ee(i);else{if((i=t[4])||"<!"===j){w=T(i,t.index+j.length),O.lastIndex=w;continue}if(i=t[5]){if(1!=_){w=T("?",t.index+2),O.lastIndex=w;continue}Z(i,t[6])}}w=t.index+j.length}for(w<x.length&&R(k(x.substr(w))),r=S.length-1;0<=r;r--)(i=S[r]).valid&&Q(i.name)}!1!==q.fix_self_closing&&(q.fix_self_closing=!0);var X=q.comment||te,Y=q.cdata||te,G=q.text||te,J=q.start||te,Q=q.end||te,Z=q.pi||te,ee=q.doctype||te;return{parse:function(e,t){void 0===t&&(t="html"),n(function(e){for(var t,n=/data:[^;<"'\s]+;base64,([a-z0-9\+\/=\s]+)/gi,r=[],o={},i=xu("img"),a=0,u=0;t=n.exec(e);){var s=t[0],c=i+"_"+u++;o[c]=s,a<t.index&&r.push(e.substr(a,t.index-a)),r.push(c),a=t.index+s.length}var l=new RegExp(i+"_[0-9]+","g");return 0===a?{prefix:i,uris:o,html:e,re:l}:(a<e.length&&r.push(e.substr(a)),{prefix:i,uris:o,html:r.join(""),re:l})}(e),t)}}}var Zd=Et.makeMap("button,fieldset,form,iframe,img,image,input,object,output,select,textarea"),em=Re(function(){return document.implementation.createHTMLDocument("parser")}),tm=function(e,t,n){void 0===n&&(n=0);var r=e.toLowerCase();if(-1!==r.indexOf("[if ",n)&&(u=n,/^\s*\[if [\w\W]+\]>.*<!\[endif\](--!?)?>/.test(r.substr(u)))){var o=r.indexOf("[endif]",n);return r.indexOf(">",o)}if(t){var i=r.indexOf(">",n);return-1!==i?i:r.length}var a=/--!?>/g;a.lastIndex=n;var u,s=a.exec(e);return s?s.index+s[0].length:r.length};function nm(e,t){for(var n,r,o,i,a=/<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g,u=e.schema,s=(n=e.getTempAttrs(),r=t,o=new RegExp(["\\s?("+n.join("|")+')="[^"]+"'].join("|"),"gi"),r.replace(o,"")),c=u.getShortEndedElements();i=a.exec(s);){var l=a.lastIndex,f=i[0].length,d=c[i[1]]?l:Qd.findEndTag(u,s,l),s=s.substring(0,l-f)+s.substring(d);a.lastIndex=l-f}return Eo(s)}function rm(o){return{compare:function(e,t){return e.nodeName===t.nodeName&&!(!r(n(e),n(t))||!r(o.parseStyle(o.getAttrib(e,"style")),o.parseStyle(o.getAttrib(t,"style")))||Jc(e)||Jc(t));function n(n){var r={};return um(o.getAttribs(n),function(e){var t=e.nodeName.toLowerCase();0!==t.indexOf("_")&&"style"!==t&&0!==t.indexOf("data-")&&(r[t]=o.getAttrib(n,t))}),r}function r(e,t){var n,r;for(r in e)if(ke(e,r)){if(void 0===(n=t[r]))return;if(e[r]!==n)return;delete t[r]}for(r in t)if(ke(t,r))return;return 1}}}}function om(e){var u=[],s=(e=e||{}).indent,c=sm(e.indent_before||""),l=sm(e.indent_after||""),f=Qo.getEncodeFunc(e.entity_encoding||"raw",e.entities),d="html"===e.element_format;return{start:function(e,t,n){var r,o,i,a;if(s&&c[e]&&0<u.length&&0<(a=u[u.length-1]).length&&"\n"!==a&&u.push("\n"),u.push("<",e),t)for(r=0,o=t.length;r<o;r++)i=t[r],u.push(" ",i.name,'="',f(i.value,!0),'"');u[u.length]=!n||d?">":" />",n&&s&&l[e]&&0<u.length&&0<(a=u[u.length-1]).length&&"\n"!==a&&u.push("\n")},end:function(e){var t;u.push("</",e,">"),s&&l[e]&&0<u.length&&0<(t=u[u.length-1]).length&&"\n"!==t&&u.push("\n")},text:function(e,t){0<e.length&&(u[u.length]=t?e:f(e))},cdata:function(e){u.push("<![CDATA[",e,"]]>")},comment:function(e){u.push("\x3c!--",e,"--\x3e")},pi:function(e,t){t?u.push("<?",e," ",f(t),"?>"):u.push("<?",e,"?>"),s&&u.push("\n")},doctype:function(e){u.push("<!DOCTYPE",e,">",s?"\n":"")},reset:function(){u.length=0},getContent:function(){return u.join("").replace(/\n$/,"")}}}function im(t,g){void 0===g&&(g=ro());var p=om(t);return(t=t||{}).validate=!("validate"in t)||t.validate,{serialize:function(e){var f=t.validate,d={3:function(e){p.text(e.value,e.raw)},8:function(e){p.comment(e.value)},7:function(e){p.pi(e.name,e.value)},10:function(e){p.doctype(e.value)},4:function(e){p.cdata(e.value)},11:function(e){if(e=e.firstChild)for(;m(e),e=e.next;);}};p.reset();var m=function(e){var t=d[e.type];if(t)t(e);else{var n=e.name,r=e.shortEnded,o=e.attributes;if(f&&o&&1<o.length){var i=[];i.map={};var a=g.getElementRule(e.name);if(a){for(var u=0,s=a.attributesOrder.length;u<s;u++)(c=a.attributesOrder[u])in o.map&&(l=o.map[c],i.map[c]=l,i.push({name:c,value:l}));for(var c,l,u=0,s=o.length;u<s;u++)(c=o[u].name)in i.map||(l=o.map[c],i.map[c]=l,i.push({name:c,value:l}));o=i}}if(p.start(e.name,o,r),!r){if(e=e.firstChild)for(;m(e),e=e.next;);p.end(n)}}};return 1!==e.type||t.inner?d[11](e):m(e),p.getContent()}}}Qd.findEndTag=Jd;var am=nm,um=Et.each,sm=Et.makeMap,cm=new Set;function lm(e,t){return we(e.parseStyle(e.getAttrib(t,"style")))}function fm(n,r,o){return ve.from(o.container()).filter(jn).exists(function(e){var t=n?0:-1;return r(e.data.charAt(o.offset()+t))})}function dm(e){var t=e.container();return jn(t)&&(0===t.data.length||So(t.data)&&zl.isBookmarkNode(t.parentNode))}function mm(t,n){return function(e){return ve.from(Qs(t?0:-1,e)).filter(n).isSome()}}function gm(e){return Kn(e)&&"block"===xn(kt.fromDom(e),"display")}function pm(e){return Yn(e)&&!(zn(t=e)&&"all"===t.getAttribute("data-mce-bogus"));var t}function hm(e){Xt(e),Pn(e,kt.fromHtml('<br data-mce-bogus="1">'))}function vm(n){Ut(n).each(function(t){Bt(t).each(function(e){mo(n)&&Br(t)&&mo(e)&&Ln(t)})})}function bm(e,t){return o=D,Ve(r=t,n=e)?function(e,t){for(var n=y(t)?t:D,r=e.dom,o=[];null!==r.parentNode&&void 0!==r.parentNode;){var i=r.parentNode,a=kt.fromDom(i);if(o.push(a),!0===n(a))break;r=i}return o}(n,function(e){return o(e)||je(e,r)}).slice(0,-1):[];var n,r,o}function ym(e,t){return[e].concat(bm(e,t))}function Cm(e,t,n){return Zl(e,t,n,dm)}function xm(e,t){return M(ym(kt.fromDom(t.container()),e),mo)}function wm(e,n,r){return Cm(e,n.dom,r).forall(function(t){return xm(n,r).fold(function(){return!1===Js(t,r,n.dom)},function(e){return!1===Js(t,r,n.dom)&&Ve(e,kt.fromDom(t.container()))})})}function Sm(t,n,r){return xm(n,r).fold(function(){return Cm(t,n.dom,r).forall(function(e){return!1===Js(e,r,n.dom)})},function(e){return Cm(t,e.dom,r).isNone()})}function Em(e){return oc(e).exists(Br)}function km(e,t,n){var r=Q(U(ym(kt.fromDom(n.container()),t),mo)).getOr(t);return Ql(e,r.dom,n).filter(Em)}function Nm(e,t){return oc(t).exists(Br)||km(!0,e,t).isSome()}function _m(e,t){return ve.from(t.getNode(!0)).map(kt.fromDom).exists(Br)||km(!1,e,t).isSome()}function Am(e){return ss.isTextPosition(e)&&!e.isAtStart()&&!e.isAtEnd()}function Rm(e,t){return Q(U(ym(kt.fromDom(t.container()),e),mo)).getOr(e)}function Dm(e,t){return Am(t)?Gg(t):Gg(t)||tf(Rm(e,t).dom,t).exists(Gg)}function Tm(e,t){return Am(t)?Yg(t):Yg(t)||ef(Rm(e,t).dom,t).exists(Yg)}function Om(e){return oc(e).bind(function(e){return pr(e,Nn)}).exists(function(e){return T(["pre","pre-wrap"],xn(e,"white-space"))})}function Bm(e,t){return!Om(t)&&(ip(e,t)||up(e,t)||_m(e,t)||Dm(e,t))}function Pm(e,t){return!Om(t)&&(ap(e,t)||sp(e,t)||Nm(e,t)||Tm(e,t))}function Lm(e,t){return Bm(e,t)||Pm(e,(r=(n=t).container(),o=n.offset(),jn(r)&&o<r.data.length?ss(r,o+1):n));var n,r,o}function Im(e,t){return uf(e.charAt(t))}function Mm(e){var t=e.container();return jn(t)&&Te(t.data,xo)}function Fm(g,e){return ve.some(e).filter(Mm).bind(function(e){var t,n,r,o,i,a,u,s,c,l=e.container(),f=g,d=(i=l).data,m=ss(i,0);return(!Im(d,0)||Lm(f,m)?(s=(a=l).data,(c=A(u=s.split(""),function(e,t){return uf(e)&&0<t&&t<u.length-1&&Zc(u[t-1])&&Zc(u[t+1])?" ":e}).join(""))!==s&&(a.data=c,1)):(i.data=" "+d.slice(1),1))||(t=g,r=(n=l).data,o=ss(n,r.length-1),Im(r,r.length-1)&&!Lm(t,o)&&(n.data=r.slice(0,-1)+" ",1))?ve.some(e):ve.none()})}function Um(t){var e=kt.fromDom(t.getBody());t.selection.isCollapsed()&&Fm(e,ss.fromRangeStart(t.selection.getRng())).each(function(e){t.selection.setRng(e.toRange())})}function zm(e,t,n){var r,o,i,a,u,s,c,l;0!==n&&(o=gr(r=kt.fromDom(e),mo).getOr(r),i=e.data.slice(t,t+n),a=t+n>=e.data.length&&Pm(o,ss(e,e.data.length)),u=0===t&&Bm(o,ss(e,0)),e.replaceData(t,n,(c=u,l=a,L(s=i,function(e,t){return Qc(t)||uf(t)?e.previousCharIsSpace||""===e.str&&c||e.str.length===s.length-1&&l?{previousCharIsSpace:!1,str:e.str+xo}:{previousCharIsSpace:!0,str:e.str+" "}:{previousCharIsSpace:!1,str:e.str+t}},{previousCharIsSpace:!1,str:""}).str)))}function Hm(e,t){var n=e.data.slice(t);zm(e,t,n.length-Qe(n).length)}function jm(e,t){var n=e.data.slice(0,t),r=n.length-Ze(n).length;zm(e,t-r,r)}function Vm(e,t,n,r){void 0===r&&(r=!0);var o=Ze(e.data).length,i=r?e:t,a=r?t:e;return r?i.appendData(a.data):i.insertData(0,a.data),Ln(kt.fromDom(a)),n&&Hm(i,o),i}function qm(e,t){return r=e,o=(n=t).container(),i=n.offset(),!1===ss.isTextPosition(n)&&o===r.parentNode&&i>ss.before(r).offset()?ss(t.container(),t.offset()-1):t;var n,r,o,i}function $m(e){return jr(e.previousSibling)?ve.some((t=e.previousSibling,jn(t)?ss(t,t.data.length):ss.after(t))):e.previousSibling?rf(e.previousSibling):ve.none();var t}function Wm(e){return jr(e.nextSibling)?ve.some((t=e.nextSibling,jn(t)?ss(t,0):ss.before(t))):e.nextSibling?nf(e.nextSibling):ve.none();var t}function Km(r,o){return $m(o).orThunk(function(){return Wm(o)}).orThunk(function(){return e=r,n=ss.before((t=o).previousSibling||t.parentNode),tf(e,n).fold(function(){return ef(e,ss.after(t))},ve.some);var e,t,n})}function Xm(n,r){return Wm(r).orThunk(function(){return $m(r)}).orThunk(function(){return ef(e=n,ss.after(t=r)).fold(function(){return tf(e,ss.before(t))},ve.some);var e,t})}function Ym(t,n,e){e.fold(function(){t.focus()},function(e){t.selection.setRng(e.toRange(),n)})}function Gm(e,t){return t&&ke(e.schema.getBlockElements(),Nt(t))}function Jm(e){if(Wr(e)){var t=kt.fromHtml('<br data-mce-bogus="1">');return Xt(e),Pn(e,t),ve.some(ss.before(t.dom))}return ve.none()}function Qm(t,n,e,r){void 0===r&&(r=!0);var o,i,a,u,s,c,l,f,d,m,g,p,h,v,b=(p=n,h=t.getBody(),v=e.dom,(p?Xm:Km)(h,v).map(R(qm,v))),y=gr(e,R(Gm,t),(o=t.getBody(),function(e){return e.dom===o})),C=(u=b,i=a=e,s=ke(t.schema.getTextInlineElements(),Nt(i)),m=Bt(a).filter(_n),g=Pt(a).filter(_n),Ln(a),l=g,f=u,d=function(e,t,n){var r=e.dom,o=t.dom,i=r.data.length;return Vm(r,o,s),n.container()===o?ss(r,i):n},((c=m).isSome()&&l.isSome()&&f.isSome()?ve.some(d(c.getOrDie(),l.getOrDie(),f.getOrDie())):ve.none()).orThunk(function(){return s&&(m.each(function(e){return jm(e.dom,e.dom.length)}),g.each(function(e){return Hm(e.dom,0)})),u}));t.dom.isEmpty(t.getBody())?(t.setContent(""),t.selection.setCursorLocation()):y.bind(Jm).fold(function(){r&&Ym(t,n,C)},function(e){r&&Ym(t,n,ve.some(e))})}function Zm(e){return bu(e,"td,th")}function eg(e,t){return{start:e,end:t}}function tg(e,t){return br(kt.fromDom(e),"td,th",t)}function ng(e){return!je(e.start,e.end)}function rg(e,n){return Dl(e.start,n).bind(function(t){return Dl(e.end,n).bind(function(e){return je(t,e)?ve.some(t):ve.none()})})}function og(e){return function(t){return rg(t,e).map(function(e){return{rng:t,table:e,cells:Zm(e)}})}}function ig(e,t,n,r){if(n.collapsed||!e.forall(ng))return ve.none();if(t.isSameTable){var o=e.bind(og(r));return ve.some({start:o,end:o})}var i,a,u=tg(n.startContainer,r),s=tg(n.endContainer,r),c=u.bind((a=r,function(t){return Dl(t,a).bind(function(e){return Z(Zm(e)).map(function(e){return eg(t,e)})})})).bind(og(r)),l=s.bind((i=r,function(t){return Dl(t,i).bind(function(e){return Q(Zm(e)).map(function(e){return eg(e,t)})})})).bind(og(r));return ve.some({start:c,end:l})}function ag(e,t){return z(e,function(e){return je(e,t)})}function ug(n){return dn(ag(n.cells,n.rng.start),ag(n.cells,n.rng.end),function(e,t){return n.cells.slice(e,t+1)})}function sg(e,t){var n=t.startTable,r=t.endTable,o=e.cloneRange();return n.each(function(e){return o.setStartAfter(e.dom)}),r.each(function(e){return o.setEndBefore(e.dom)}),o}function cg(e,t){var n,r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,b=(n=e,function(e){return je(n,e)}),y=dn(tg((r=t).startContainer,o=b),tg(r.endContainer,o),eg),C=(l=b,f=x((c=t).startContainer),d=x(c.endContainer),m=f.isSome(),g=d.isSome(),p=dn(f,d,je).getOr(!1),{startTable:f,endTable:d,isStartInTable:m,isEndInTable:g,isSameTable:p,isMultiTable:!p&&m&&g});function x(e){return Dl(kt.fromDom(e),l)}return h=t,v=b,y.exists(function(e){return!ng(t=e)&&rg(t,v).exists(function(e){var t=e.dom.rows;return 1===t.length&&1===t[0].cells.length})&&Tl(e.start,h);var t})?y.map(function(e){return fp.singleCellTable(t,e.start)}):C.isMultiTable?ig(y,u=C,s=t,b).bind(function(e){var t=e.start,n=e.end,r=t.bind(ug).getOr([]),o=n.bind(ug).getOr([]);if(0<r.length&&0<o.length){var i=sg(s,u);return ve.some(fp.multiTable(r,o,i))}return ve.none()}):ig(y,i=C,a=t,b).bind(function(e){var t=e.start,n=e.end;return t.or(n)}).bind(function(e){var t=i.isSameTable,n=ug(e).getOr([]);if(t&&e.cells.length===n.length)return ve.some(fp.fullTable(e.table));if(0<n.length){if(t)return ve.some(fp.partialTable(n,ve.none()));var r=sg(a,i);return ve.some(fp.partialTable(n,ve.some(_e(_e({},i),{rng:r}))))}return ve.none()})}function lg(e){return Y(e,function(e){yn(e,"contenteditable"),hm(e)}),0}function fg(e,t,n,r){var o=n.cloneRange();r?(o.setStart(n.startContainer,n.startOffset),o.setEndAfter(t.dom.lastChild)):(o.setStartBefore(t.dom.firstChild),o.setEnd(n.endContainer,n.endOffset)),mp(e,o,t,!1)}function dg(e){var t=Rl(e),n=kt.fromDom(e.selection.getNode());Gn(n.dom)&&Wr(n)?e.selection.setCursorLocation(n.dom,0):e.selection.collapse(!0),1<t.length&&F(t,function(e){return je(e,n)})&&pn(n,"data-mce-selected","1")}function mg(s,c,e){var l=s.selection.getRng();return lg(e.bind(function(e){var t,n,r,o=e.rng,i=e.isStartInTable,a=(t=i?o.endContainer:o.startContainer,ve.from(s.dom.getParent(t,s.dom.isBlock)).map(kt.fromDom));o.deleteContents(),n=s,r=i,a.filter(Wr).each(function(e){r?Ln(e):(hm(e),n.selection.setCursorLocation(e.dom,0))});var u=i?c[0]:c[c.length-1];return fg(s,u,l,i),Wr(u)?ve.none():ve.some(i?c.slice(1):c.slice(0,-1))}).getOr(c)),dg(s),!0}function gg(e,t,n,r){var o=e.selection.getRng(),i=t[0],a=n[n.length-1];fg(e,i,o,!0),fg(e,a,o,!1);var u=Wr(i)?t:t.slice(1),s=Wr(a)?n:n.slice(0,-1);return lg(u.concat(s)),r.deleteContents(),dg(e),!0}function pg(e,t){return Qm(e,!1,t),!0}function hg(e,t){return M(ym(t,e),bo)}function vg(e,t){return(e?tp:np)(t)}function bg(f,d,s){var m=kt.fromDom(f.getBody());return gp(m,s).fold(function(){return o=f,i=d,a=m,e=s,u=ss.fromRangeStart(o.selection.getRng()),hg(a,e).bind(function(e){return Wr(e)?pp(o,e):(t=a,n=e,r=u,zc(i,o.getBody(),r).bind(function(e){return hg(t,kt.fromDom(e.getNode())).map(function(e){return!1===je(e,n)})}));var t,n,r}).getOr(!1)||(n=d,r=ss.fromRangeStart((t=f).selection.getRng()),vg(n,r)||Ql(n,t.getBody(),r).exists(function(e){return vg(n,e)}));var o,i,a,e,u,t,n,r},function(e){return n=d,r=m,o=e,i=ss.fromRangeStart((t=f).selection.getRng()),(Wr(o)?pp(t,o):(u=r,c=o,l=i,zc(s=n,(a=t).getBody(),l).bind(function(e){return r=s,o=l,i=e,nf((n=c).dom).bind(function(t){return rf(n.dom).map(function(e){return r?o.isEqual(t)&&i.isEqual(e):o.isEqual(e)&&i.isEqual(t)})}).getOr(!0)?pp(a,c):(t=c,gp(u,kt.fromDom(e.getNode())).map(function(e){return!1===je(e,t)}));var t,n,r,o,i}).or(ve.some(!0)))).getOr(!1);var a,u,s,c,l,t,n,r,o,i})}function yg(e,t){var n,r,o,i,a,u,s,c,l=kt.fromDom(e.selection.getStart(!0)),f=Rl(e);return e.selection.isCollapsed()&&0===f.length?bg(e,t,l):(r=l,o=f,i=kt.fromDom((n=e).getBody()),a=n.selection.getRng(),0!==o.length?mg(n,o,ve.none()):(u=n,c=a,gp(s=i,r).fold(function(){return t=u,cg(s,c).map(function(e){return e.fold(R(mp,t),R(pg,t),R(mg,t),R(gg,t))});var t},function(e){return pp(u,e)}).getOr(!1)))}function Cg(e){return e.collapsed?e:(a=e,u=ss.fromRangeStart(a),s=ss.fromRangeEnd(a),c=a.commonAncestorContainer,Ql(!1,c,s).map(function(e){return!Js(u,s,c)&&Js(u,e,c)?(t=u.container(),n=u.offset(),r=e.container(),o=e.offset(),(i=document.createRange()).setStart(t,n),i.setEnd(r,o),i):a;var t,n,r,o,i}).getOr(a));var a,u,s,c}function xg(e,t){var n,r,o,i,a,u=t.firstChild,s=t.lastChild;return u&&"meta"===u.name&&(u=u.next),r=s=s&&"mce_marker"===s.attr("id")?s.prev:s,o=(n=e).getNonEmptyElements(),r&&(r.isEmpty(o)||(i=r,n.getBlockElements()[i.name]&&i.firstChild&&i.firstChild===i.lastChild&&("br"===(a=i.firstChild).name||a.value===xo)))&&(s=s.prev),u&&u===s&&("ul"===u.name||"ol"===u.name)}function wg(e){return 0<e.length&&(!(r=e[e.length-1]).firstChild||(t=r)&&t.firstChild&&t.firstChild===t.lastChild&&((n=t.firstChild).data===xo||Wn(n)))?e.slice(0,-1):e;var t,n,r}function Sg(e,t){var n=e.getParent(t,e.isBlock);return n&&"LI"===n.nodeName?n:null}function Eg(e,t){var n=ss.after(e),r=Ic(t).prev(n);return r?r.toRange():null}function kg(e,o,i,t){function n(e){var t=ss.fromRangeStart(i),n=Ic(o.getRoot()),r=1===e?n.prev(t):n.next(t);return!r||Sg(o,r.getNode())!==R}var r,a,u,s,c,l,f,d,m,g,p,h,v,b,y,C,x,w,S,E,k,N,_,A=(r=o,c=e.serialize(t),u=(a=r.createFragment(c)).firstChild,s=a.lastChild,u&&"META"===u.nodeName&&u.parentNode.removeChild(u),s&&"mce_marker"===s.id&&s.parentNode.removeChild(s),a),R=Sg(o,i.startContainer),D=wg(U(A.firstChild.childNodes,function(e){return"LI"===e.nodeName})),T=o.getRoot();return n(1)?(S=T,_=(w=R).parentNode,Et.each(D,function(e){_.insertBefore(e,w)}),E=S,k=ss.before(w),(N=Ic(E).next(k))?N.toRange():null):n(2)?(l=R,d=T,o.insertAfter((f=D).reverse(),l),Eg(f[0],d)):(g=D,p=T,h=m=R,b=(v=i).cloneRange(),y=v.cloneRange(),b.setStartBefore(h),y.setEndAfter(h),C=[b.cloneContents(),y.cloneContents()],(x=m.parentNode).insertBefore(C[0],m),Et.each(g,function(e){x.insertBefore(e,m)}),x.insertBefore(C[1],m),x.removeChild(m),Eg(g[g.length-1],p))}function Ng(e,t,n){var r,o,i,a,u=e.selection,s=e.dom;/^ | $/.test(t)&&(r=s,o=u.getRng(),i=t,i=Bm(a=kt.fromDom(r.getRoot()),ss.fromRangeStart(o))?i.replace(/^ /," "):i.replace(/^ /," "),t=i=Pm(a,ss.fromRangeEnd(o))?i.replace(/( | )(<br( \/)>)?$/," "):i.replace(/ (<br( \/)?>)?$/," "));var c=e.parser,l=n.merge,f=im({validate:e.getParam("validate")},e.schema),d='<span id="mce_marker" data-mce-type="bookmark"></span>',m=e.fire("BeforeSetContent",{content:t,format:"html",selection:!0,paste:n.paste});if(m.isDefaultPrevented())e.fire("SetContent",{content:m.content,format:"html",selection:!0,paste:n.paste});else{-1===(t=m.content).indexOf("{$caret}")&&(t+="{$caret}"),t=t.replace(/\{\$caret\}/,d);var g,p,h=(g=u.getRng()).startContainer||(g.parentElement?g.parentElement():null),v=e.getBody();h===v&&u.isCollapsed()&&s.isBlock(v.firstChild)&&((p=v.firstChild)&&!e.schema.getShortEndedElements()[p.nodeName])&&s.isEmpty(v.firstChild)&&((g=s.createRng()).setStart(v.firstChild,0),g.setEnd(v.firstChild,0),u.setRng(g)),u.isCollapsed()||function(e){var t=e.dom,n=Cg(e.selection.getRng());e.selection.setRng(n);var r,o=t.getParent(n.startContainer,hp),i=n;null!==(r=o)&&r===t.getParent(i.endContainer,hp)&&Tl(kt.fromDom(r),i)?mp(e,n,kt.fromDom(o)):e.getDoc().execCommand("Delete",!1,null)}(e);var b,y,C,x,w,S,E,k,N,_,A,R,D,T,O={context:(I=u.getNode()).nodeName.toLowerCase(),data:n.data,insert:!0},B=c.parse(t,O);if(!0===n.paste&&xg(e.schema,B)&&Sg(s,I))return g=kg(f,s,u.getRng(),B),u.setRng(g),void e.fire("SetContent",m);if(function(){for(var e=B;e=e.walk();)1===e.type&&e.attr("data-mce-fragment","1")}(),"mce_marker"===(L=B.lastChild).attr("id"))for(var P=L,L=L.prev;L;L=L.walk(!0))if(3===L.type||!s.isBlock(L.name)){e.schema.isValidChild(L.parent.name,"span")&&L.parent.insert(P,L,"br"===L.name);break}if(e._selectionOverrides.showBlockCaretContainer(I),O.invalid){e.selection.setContent(d);var I=u.getNode(),M=e.getBody();for(9===I.nodeType?I=L=M:L=I;L!==M;)L=(I=L).parentNode;t=I===M?M.innerHTML:s.getOuterHTML(I),t=f.serialize(c.parse(t.replace(/<span (id="mce_marker"|id=mce_marker).+?<\/span>/i,function(){return f.serialize(B)}))),I===M?s.setHTML(M,t):s.setOuterHTML(I,t)}else b=e,y=t=f.serialize(B),"all"===(C=I).getAttribute("data-mce-bogus")?C.parentNode.insertBefore(b.dom.createFragment(y),C):(x=C.firstChild,w=C.lastChild,!x||x===w&&"BR"===x.nodeName?b.dom.setHTML(C,y):b.selection.setContent(y));E=l,_=(S=e).schema.getTextInlineElements(),A=S.dom,E&&(k=S.getBody(),N=rm(A),Et.each(A.select("*[data-mce-fragment]"),function(e){if(V(_[e.nodeName.toLowerCase()])&&j(lm(A,e),function(e){return!cm.has(e)}))for(var t=e.parentNode;V(t)&&t!==k&&!function(r,o,i){function a(e){var t=r.getStyle(o,e),n=r.getStyle(i,e);return Be(t)&&Be(n)&&t!==n}var e=lm(r,o),u=lm(r,i);return F(e,function(t){function e(e){return F(e,function(e){return e===t})}if(e(u)||!e(Xg))return a(t);var n=U(u,function(t){return F(Xg,function(e){return Ge(t,e)})});return F(n,a)})}(A,e,t);t=t.parentNode)if(N.compare(t,e)){A.remove(e,!0);break}})),function(n,e){var t,r=n.dom,o=n.selection;if(e){o.scrollIntoView(e);var i=vf(n.getBody(),e);if("false"===r.getContentEditable(i))return r.remove(e),o.select(i);var a,u=r.createRng(),s=e.previousSibling;jn(s)?(u.setStart(s,s.nodeValue.length),xt.ie||(a=e.nextSibling,jn(a)&&(s.appendData(a.data),a.parentNode.removeChild(a)))):(u.setStartBefore(e),u.setEndBefore(e));var c=r.getParent(e,r.isBlock);r.remove(e),c&&r.isEmpty(c)&&(n.$(c).empty(),u.setStart(c,0),u.setEnd(c,0),hp(c)||c.getAttribute("data-mce-fragment")||!(t=function(e){var t=ss.fromRangeStart(e);if(t=Ic(n.getBody()).next(t))return t.toRange()}(u))?r.add(c,r.create("br",{"data-mce-bogus":"1"})):(u=t,r.remove(c))),o.setRng(u)}}(e,s.get("mce_marker")),R=e.getBody(),Et.each(R.getElementsByTagName("*"),function(e){e.removeAttribute("data-mce-fragment")}),D=s,T=u.getStart(),ve.from(D.getParent(T,"td,th")).map(kt.fromDom).each(vm),e.fire("SetContent",m),e.addVisual()}}function _g(e){return e instanceof Hd}function Ag(e,t,n){var r;e.dom.setHTML(e.getBody(),t),!0!==n&&yd(r=e)&&nf(r.getBody()).each(function(e){var t=e.getNode(),n=cn(t)?nf(t).getOr(e):e;r.selection.setRng(n.toRange())})}function Rg(u,s,e){var t,n=(t=s,_e(_e({format:"html"},e),{set:!0,content:_g(t)?"":t})),c=e.no_events?n:u.fire("BeforeSetContent",n);return _g(s)||(s=c.content),ve.from(u.getBody()).fold(J(s),function(e){return _g(s)?function(e,t,n,r){var o,i,u,a;o=e.parser.getNodeFilters(),i=e.parser.getAttributeFilters(),u=n,a=function(e,n){var t,r,o={},i={},a=[];for(t in u.firstChild&&vp(u.firstChild,function(t){Y(e,function(e){e.name===t.name&&(o[e.name]?o[e.name].nodes.push(t):o[e.name]={filter:e,nodes:[t]})}),Y(n,function(e){"string"==typeof t.attr(e.name)&&(i[e.name]?i[e.name].nodes.push(t):i[e.name]={filter:e,nodes:[t]})})}),o)ke(o,t)&&a.push(o[t]);for(r in i)ke(i,r)&&a.push(i[r]);return a}(o,i),Y(a,function(t){Y(t.filter.callbacks,function(e){e(t.nodes,t.filter.name,{})})});var s=im({validate:e.validate},e.schema).serialize(n);return r.content=yo(kt.fromDom(t))?s:Et.trim(s),Ag(e,r.content,r.no_selection),r.no_events||e.fire("SetContent",r),n}(u,e,s,c):(t=u,n=e,o=c,0===(r=s).length||/^\s+$/.test(r)?(i='<br data-mce-bogus="1">',"TABLE"===n.nodeName?r="<tr><td>"+i+"</td></tr>":/^(UL|OL)$/.test(n.nodeName)&&(r="<li>"+i+"</li>"),r=(a=ks(t))&&t.schema.isValidChild(n.nodeName.toLowerCase(),a.toLowerCase())?(r=i,t.dom.createHTML(a,Ns(t),r)):r||'<br data-mce-bogus="1">',Ag(t,r,o.no_selection),t.fire("SetContent",o)):("raw"!==o.format&&(r=im({validate:t.validate},t.schema).serialize(t.parser.parse(r,{isRootContent:!0,insert:!0}))),o.content=yo(kt.fromDom(n))?r:Et.trim(r),Ag(t,o.content,o.no_selection),o.no_events||t.fire("SetContent",o)),o.content);var t,n,r,o,i,a})}function Dg(e){return y(e)?e:D}function Tg(i,e,t){var n=e(i),a=Dg(t);return n.orThunk(function(){return a(i)?ve.none():function(e){for(var t=i.dom,n=Dg(a);t.parentNode;){var t=t.parentNode,r=kt.fromDom(t),o=e(r);if(o.isSome())return o;if(n(r))break}return ve.none()}(e)})}function Og(e,t,n){var r=e.formatter.get(n);if(r)for(var o=0;o<r.length;o++){var i=r[o];if(ml(i)&&!1===i.inherit&&e.dom.is(t,i.selector))return 1}}function Bg(t,e,n,r,o){var i=t.dom.getRoot();return e!==i&&(e=t.dom.getParent(e,function(e){return!!Og(t,e,n)||e.parentNode===i||!!yp(t,e,n,r,!0)}),!!yp(t,e,n,r,o))}function Pg(e,t,n){return!!bp(t,n.inline)||!!bp(t,n.block)||(n.selector?1===t.nodeType&&e.is(t,n.selector):void 0)}function Lg(e,t,n,r,o,i){var a=n[r];if(y(n.onmatch))return n.onmatch(t,n,r);if(a)if(b(a.length)){for(var u in a)if(ke(a,u)){var s="attributes"===r?e.getAttrib(t,u):sl(e,t,u),c=il(a[u],i),l=K(s)||Pe(s);if(!l||!K(c)){if(o&&l&&!n.exact)return;if((!o||n.exact)&&!bp(s,ul(e,c,u)))return}}}else for(var f=0;f<a.length;f++)if("attributes"===r?e.getAttrib(t,a[f]):sl(e,t,a[f]))return 1;return 1}function Ig(e,t,n,r,o){if(r)return Bg(e,r,t,n,o);if(r=e.selection.getNode(),Bg(e,r,t,n,o))return!0;var i=e.selection.getStart();return!(i===r||!Bg(e,i,t,n,o))}function Mg(e){return 0<function(e){for(var t=[];e;){if(3===e.nodeType&&e.nodeValue!==Cp||1<e.childNodes.length)return[];1===e.nodeType&&t.push(e),e=e.firstChild}return t}(e).length}function Fg(e){if(e){var t=new Rr(e,e);for(e=t.current();e;e=t.next())if(jn(e))return e}return null}function Ug(e){var t=kt.fromTag("span");return hn(t,{id:xp,"data-mce-bogus":"1","data-mce-type":"format-caret"}),e&&Pn(t,kt.fromText(Cp)),t}function zg(e,t,n){void 0===n&&(n=!0);var r,o,i,a,u,s,c,l,f=e.dom,d=e.selection;Mg(t)?Qm(e,!1,kt.fromDom(t),n):(r=d.getRng(),o=f.getParent(t,f.isBlock),i=r.startContainer,a=r.startOffset,u=r.endContainer,s=r.endOffset,(l=Fg(t))&&l.nodeValue.charAt(0)===Cp&&l.deleteData(0,1),c=l,f.remove(t,!0),i===c&&0<a&&r.setStart(c,a-1),u===c&&0<s&&r.setEnd(c,s-1),o&&f.isEmpty(o)&&hm(kt.fromDom(o)),d.setRng(r))}function Hg(e,t,n){void 0===n&&(n=!0);var r=e.dom,o=e.selection;if(t)zg(e,t,n);else if(!(t=Vc(e.getBody(),o.getStart())))for(;t=r.get(xp);)zg(e,t,!1)}function jg(e,t){return e.appendChild(t),t}function Vg(e,t){var n=P(e,function(e,t){return jg(e,t.cloneNode(!1))},t);return jg(n,n.ownerDocument.createTextNode(Cp))}function qg(o,e,t,i,n,r){var a,u,s=o.formatter,c=o.dom,l=U(we(s.get()),function(e){return e!==i&&!Te(e,"removeformat")});if(0<U((a=o,u=t,L(l,function(e,t){var n=fl(a,t);return a.formatter.matchNode(u,t,{},n)?e.concat([t]):e},[])),function(e){return n=i,r=["inline","block","selector","attributes","styles","classes"],!F((t=o).formatter.get(e),function(e){var i=a(e);return F(t.formatter.get(n),function(e){var t,n=a(e),r=i,o=n;return d(t=void 0===t?p:t).eq(r,o)})});function a(e){return ae(e,function(e,t){return F(r,function(e){return e===t})})}var t,n,r}).length){var f=t.cloneNode(!1);return c.add(e,f),s.remove(i,n,f,r),c.remove(f),ve.some(f)}return ve.none()}function $g(e,t,n,r){var o,i,a,u,s,c,l,f,d,m,g,p,h,v,b,y=e.dom,C=e.selection,x=[],w=C.getRng(),S=w.startContainer,E=w.startOffset,k=S;for(3===S.nodeType&&(E!==S.nodeValue.length&&(o=!0),k=k.parentNode);k;){if(yp(e,k,t,n,r)){i=k;break}k.nextSibling&&(o=!0),x.push(k),k=k.parentNode}i&&(o?(a=C.getBookmark(),w.collapse(!0),u=Bf(kl(e,w,e.formatter.get(t),!0)),e.formatter.remove(t,n,u,r),C.moveToBookmark(a)):(s=Vc(e.getBody(),i),d=c=Ug(!1).dom,(p=(g=e.dom).getParent(m=null!==s?s:i,R(rl,e)))&&g.isEmpty(p)?m.parentNode.replaceChild(d,m):(h=kt.fromDom(m),v=bu(h,"br"),b=U(function(){for(var e=[],t=h.dom;t;)e.push(kt.fromDom(t)),t=t.lastChild;return e}().slice(-1),Br),v.length===b.length&&Y(b,Ln),g.isEmpty(m)?m.parentNode.replaceChild(d,m):g.insertAfter(d,m)),l=qg(e,c,i,t,n,r),f=Vg(x.concat(l.toArray()),c),zg(e,s,!1),C.setCursorLocation(f,1),y.isEmpty(i)&&y.remove(i)))}function Wg(e,t){var n=e.schema.getTextInlineElements();return ke(n,Nt(t))&&!jc(t.dom)&&!sn(t.dom)}Y(["margin","margin-left","margin-right","margin-top","margin-bottom","padding","padding-left","padding-right","padding-top","padding-bottom","border","border-width","border-style","border-color","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","float","position","left","right","top","bottom","z-index","display","transform","width","max-width","min-width","height","max-height","min-height","overflow","overflow-x","overflow-y","text-overflow","vertical-align","transition","transition-delay","transition-duration","transition-property","transition-timing-function"],function(e){cm.add(e)});var Kg,Xg=["font","text-decoration","text-emphasis"],Yg=R(fm,!0,Qc),Gg=R(fm,!1,Qc),Jg=mm(!0,gm),Qg=mm(!1,gm),Zg=mm(!0,Jn),ep=mm(!1,Jn),tp=mm(!0,cn),np=mm(!1,cn),rp=mm(!0,pm),op=mm(!1,pm),ip=R(Sm,!1),ap=R(Sm,!0),up=R(wm,!1),sp=R(wm,!0),cp=R(km,!1),lp=R(km,!0),fp=or([{singleCellTable:["rng","cell"]},{fullTable:["table"]},{partialTable:["cells","outsideDetails"]},{multiTable:["startTableCells","endTableCells","betweenRng"]}]),dp=function(e){var t;return(8===_t(t=e)||"#comment"===Nt(t)?Bt:Ut)(e).bind(dp).orThunk(function(){return ve.some(e)})},mp=function(e,t,n,r){void 0===r&&(r=!0),t.deleteContents();var o,i=dp(n).getOr(n),a=kt.fromDom(e.dom.getParent(i.dom,e.dom.isBlock));return Wr(a)&&(hm(a),r&&e.selection.setCursorLocation(a.dom,0)),je(n,a)||Y((fn(Ot(a),n)?[]:Ot(o=a).map(Dn).map(function(e){return U(e,function(e){return!je(o,e)})}).getOr([])).concat(Dn(n)),function(e){je(e,a)||Ve(e,a)||!Wr(e)||Ln(e)}),!0},gp=function(e,t){return M(ym(t,e),function(e){return Nn(e)&&"caption"===Nt(e)})},pp=function(e,t){return hm(t),e.selection.setCursorLocation(t.dom,0),ve.some(!0)},hp=Gn,vp=function(e,t){t(e),e.firstChild&&vp(e.firstChild,t),e.next&&vp(e.next,t)},bp=al,yp=function(e,t,n,r,o){var i=e.formatter.get(n),a=e.dom;if(i&&t)for(var u=0;u<i.length;u++){var s=i[u];if(Pg(e.dom,t,s)&&Lg(a,t,s,"attributes",o,r)&&Lg(a,t,s,"styles",o,r)){var c=s.classes;if(c)for(var l=0;l<c.length;l++)if(!e.dom.hasClass(t,il(c[l],r)))return;return s}}},Cp=wo,xp="_mce_caret",wp={},Sp=fe,Ep=ce;function kp(e){return zn(e)&&!Jc(e)&&!jc(e)&&!sn(e)}function Np(e,t){for(var n=e;n;n=n[t]){if(jn(n)&&Be(n.data))return e;if(zn(n)&&!Jc(n))return n}return e}function _p(e,t,n){var r=rm(e);if(t&&n&&(t=Np(t,"previousSibling"),n=Np(n,"nextSibling"),r.compare(t,n))){for(var o=t.nextSibling;o&&o!==n;){var i=o,o=o.nextSibling;t.appendChild(i)}return e.remove(n),Et.each(Et.grep(n.childNodes),function(e){t.appendChild(e)}),t}return n}function Ap(e,t,n,r){var o;r&&!1!==t.merge_siblings&&(o=_p(e,nl(r),r),_p(e,o,nl(o,!0)))}function Rp(t,n){return function(e){return!(!e||!sl(t,e,n))}}function Dp(r,o,i){return function(e){var t,n;r.setStyle(e,o,i),""===e.getAttribute("style")&&e.removeAttribute("style"),t=r,"SPAN"===(n=e).nodeName&&0===t.getAttribs(n).length&&t.remove(n,!0)}}function Tp(e,t,n){return e.isChildOf(t,n)&&t!==n&&!e.isBlock(n)}function Op(e,t,n){var r,o=t[n?"startContainer":"endContainer"],i=t[n?"startOffset":"endOffset"];return zn(o)&&(r=o.childNodes.length-1,!n&&i&&i--,o=o.childNodes[r<i?r:i]),jn(o)&&n&&i>=o.nodeValue.length&&(o=new Rr(o,e.getBody()).next()||o),jn(o)&&!n&&0===i&&new Rr(o,e.getBody()).prev()||o}function Bp(e,t){var n=t?"firstChild":"lastChild";if(/^(TR|TH|TD)$/.test(e.nodeName)&&e[n]){var r=e[n];return"TR"===e.nodeName&&r[n]||r}return e}function Pp(e,t,n,r){var o=e.create(n,r);return t.parentNode.insertBefore(o,t),o.appendChild(t),o}function Lp(e,t,n,r,o){var i=kt.fromDom(t),a=kt.fromDom(e.create(r,o));return Kt(a,(n?It:Lt)(i)),n?(qt(i,a),Wt(a,i)):($t(i,a),Pn(a,i)),a.dom}function Ip(e,t,n,r){var o=nl(t,n,r);return K(o)||"BR"===o.nodeName||e.isBlock(o)}function Mp(e,r,o,t,i){var n,a,u=e.dom,s=u,c=t;if(!(gl(a=r)&&Rh(c,a.inline)||dl(a)&&Rh(c,a.block)||ml(a)&&(zn(c)&&s.is(c,a.selector))||r.links&&"A"===t.nodeName))return Nh.keep();var l,f,d,m,g,p,h,v,b=t;if(gl(r)&&"all"===r.remove&&S(r.preserve_attributes)){var y=U(u.getAttribs(b),function(e){return T(r.preserve_attributes,e.name.toLowerCase())});if(u.removeAllAttribs(b),Y(y,function(e){return u.setAttrib(b,e.name,e.value)}),0<y.length)return Nh.rename("span")}if("all"!==r.remove){Ah(r.styles,function(e,t){e=ul(u,il(e,o),t+""),E(t)&&(t=e,i=null),!r.remove_similar&&i&&!Rh(sl(u,i,t),e)||u.setStyle(b,t,""),n=!0}),n&&""===u.getAttrib(b,"style")&&(b.removeAttribute("style"),b.removeAttribute("data-mce-style")),Ah(r.attributes,function(e,t){var n;if(e=il(e,o),E(t)&&(t=e,i=null),r.remove_similar||!i||Rh(u.getAttrib(i,t),e))if("class"===t&&(e=u.getAttrib(b,t))&&(n="",Y(e.split(/\s+/),function(e){/mce\-\w+/.test(e)&&(n+=(n?" ":"")+e)}),n))u.setAttrib(b,t,n);else{if(_h.test(t)&&b.removeAttribute("data-mce-"+t),"style"===t&&on(["li"])(b)&&"none"===u.getStyle(b,"list-style-type"))return b.removeAttribute(t),void u.setStyle(b,"list-style-type","none");"class"===t&&b.removeAttribute("className"),b.removeAttribute(t)}}),Ah(r.classes,function(e){e=il(e,o),i&&!u.hasClass(i,e)||u.removeClass(b,e)});for(var C=u.getAttribs(b),x=0;x<C.length;x++){var w=C[x].nodeName;if(0!==w.indexOf("_")&&0!==w.indexOf("data-"))return Nh.keep()}}return"none"!==r.remove?(l=e,d=r,p=(f=b).parentNode,h=l.dom,v=ks(l),dl(d)&&(v?p===h.getRoot()&&(d.list_block&&Rh(f,d.list_block)||Y(xe(f.childNodes),function(e){ol(l,v,e.nodeName.toLowerCase())?m?m.appendChild(e):(m=Pp(h,e,v),h.setAttribs(m,l.settings.forced_root_block_attrs)):m=null})):h.isBlock(f)&&!h.isBlock(p)&&(Ip(h,f,!1)||Ip(h,f.firstChild,!0,!0)||f.insertBefore(h.create("br"),f.firstChild),Ip(h,f,!0)||Ip(h,f.lastChild,!1,!0)||f.appendChild(h.create("br")))),ml(g=d)&&gl(g)&&fn(ue(g,"mixed"),!0)&&!Rh(d.inline,f)||h.remove(f,!0),Nh.removed()):Nh.keep()}function Fp(t,e,n,r,o){return Mp(t,e,n,r,o).fold(D,function(e){return t.dom.rename(r,e),!0},w)}function Up(u,s,c,e,l){function a(e){var n,r,o,i,a,t=(r=s,o=c,i=l,Y(ll((n=u).dom,e.parentNode).reverse(),function(e){var t;a||"_start"===e.id||"_end"===e.id||(t=yp(n,e,r,o,i))&&!1!==t.split&&(a=e)}),a);return function(e,t,n,r,o,i,a,u){var s,c,l=e.dom;if(n){for(var f=n.parentNode,d=r.parentNode;d&&d!==f;d=d.parentNode){for(var m=l.clone(d,!1),g=0;g<t.length&&null!==(m=function(t,e,n){return Mp(t,e,u,n,n).fold(J(n),function(e){return t.dom.createFragment().appendChild(n),t.dom.rename(n,e)},J(null))}(e,t[g],m));g++);m&&(s&&m.appendChild(s),c=c||m,s=m)}!i||a.mixed&&l.isBlock(n)||(r=l.split(n,r)),s&&(o.parentNode.insertBefore(s,o),c.appendChild(o),gl(a)&&Ap(l,a,0,s))}return r}(u,m,t,e,e,!0,g,c)}function f(t){return F(m,function(e){return Fp(u,e,c,t,t)})}function d(e){var t,n=h.get(e?"_start":"_end"),r=n[e?"firstChild":"lastChild"];return Jc(t=r)&&zn(t)&&("_start"===t.id||"_end"===t.id)&&(r=r[e?"firstChild":"lastChild"]),jn(r)&&0===r.data.length&&(r=e?n.previousSibling||n.nextSibling:n.nextSibling||n.previousSibling),h.remove(n,!0),r}function t(e){var t=kl(u,e,m,e.collapsed);if(g.split){if(t=Bf(t),(r=Op(u,t,!0))!==(o=Op(u,t))){if(r=Bp(r,!0),o=Bp(o,!1),Tp(h,r,o)){var n=ve.from(r.firstChild).getOr(r);return a(Lp(h,n,!0,"span",{id:"_start","data-mce-type":"bookmark"})),void d(!0)}if(Tp(h,o,r))return n=ve.from(o.lastChild).getOr(o),a(Lp(h,n,!1,"span",{id:"_end","data-mce-type":"bookmark"})),void d(!1);var r=Pp(h,r,"span",{id:"_start","data-mce-type":"bookmark"}),o=Pp(h,o,"span",{id:"_end","data-mce-type":"bookmark"}),i=h.createRng();i.setStartAfter(r),i.setEndBefore(o),Nl(h,i,function(e){Y(e,function(e){Jc(e)||Jc(e.parentNode)||a(e)})}),a(r),a(o),r=d(!0),o=d()}else r=o=a(r);t.startContainer=r.parentNode||r,t.startOffset=h.nodeIndex(r),t.endContainer=o.parentNode||o,t.endOffset=h.nodeIndex(o)+1}Nl(h,t,function(e){Y(e,v)})}var n,m=u.formatter.get(s),g=m[0],p=!0,h=u.dom,r=u.selection,v=function(t){var e=!0,n=!1;zn(t)&&h.getContentEditable(t)&&(e=p,p="true"===h.getContentEditable(t),n=!0);var r,o,i=xe(t.childNodes);if(p&&!n&&(r=f(t)||F(m,function(e){return Pg(h,t,e)}),o=t.parentNode,!r&&V(o)&&pl(g)&&f(o)),g.deep&&i.length){for(var a=0;a<i.length;a++)v(i[a]);n&&(p=e)}Y(["underline","line-through","overline"],function(e){zn(t)&&u.dom.getStyle(t,"text-decoration")===e&&t.parentNode&&cl(h,t.parentNode)===e&&Fp(u,{deep:!1,exact:!0,inline:"span",styles:{textDecoration:e}},null,t)})};if(e)return el(e)?((n=h.createRng()).setStartBefore(e),n.setEndAfter(e),t(n)):t(e),void xf(u,s,e,c);if("false"!==h.getContentEditable(r.getNode()))r.isCollapsed()&&gl(g)&&!Rl(u).length?$g(u,s,c,l):(Ll(r,!0,function(){Pl(u,t)}),gl(g)&&Ig(u,s,c,r.getStart())&&tl(h,r,r.getRng()),u.nodeChanged()),xf(u,s,e,c);else{e=r.getNode();for(var o=0;o<m.length&&(!m[o].ceFalseOverride||!Fp(u,m[o],c,e,e));o++);xf(u,s,e,c)}}function zp(e){return zn(e)&&!Jc(e)&&!jc(e)&&!sn(e)}function Hp(e){return ke(e,"vars")}function jp(n,e,r,o,i){return I(e,function(e){var t=n.formatter.matchNode(e,r,null!=i?i:{},o);return!b(t)},function(e){return Og(n,e,r)||!o&&V(n.formatter.matchNode(e,r,i,!0))})}function Vp(e,t){var n=null!=t?t:Bh(e);return U(ll(e.dom,n),function(e){return zn(e)&&!sn(e)})}function qp(e,o,i,a,t,n){var r,u,s,c,l,f,d,m,g;return null===o.get()&&(u=e,(r=o).set({}),u.on("NodeChange",function(e){Ph(u,e.element,r.get())}),u.on("FormatApply FormatRemove",function(e){var t=ve.from(e.node).map(function(e){return el(e)?e:e.startContainer}).bind(function(e){return zn(e)?ve.some(e):ve.from(e.parentElement)}).getOrThunk(function(){return Bh(u)});Ph(u,t,r.get())})),s=e,l=i,f=a,d=t,m=n,g=(c=o).get(),Y(l.split(","),function(t){function e(){var e=Vp(s);return jp(s,e,t,d,m).isSome()}var n,r=ue(g,t).getOrThunk(function(){var e={withSimilar:{state:iu(!1),similar:!0,callbacks:[]},withoutSimilar:{state:iu(!1),similar:!1,callbacks:[]},withVars:[]};return g[t]=e});b(m)?((n=d?r.withSimilar:r.withoutSimilar).callbacks.push(f),1===n.callbacks.length&&n.state.set(e())):r.withVars.push({state:iu(e()),similar:d,vars:m,callback:f})}),c.set(g),{unbind:function(){var e,t=i,n=a,r=(e=o).get();Y(t.split(","),function(t){return ue(r,t).each(function(e){r[t]={withSimilar:_e(_e({},e.withSimilar),{callbacks:U(e.withSimilar.callbacks,function(e){return e!==n})}),withoutSimilar:_e(_e({},e.withoutSimilar),{callbacks:U(e.withoutSimilar.callbacks,function(e){return e!==n})}),withVars:U(e.withVars,function(e){return e.callback!==n})}})}),e.set(r)}}}function $p(e,t){var n=(t||document).createDocumentFragment();return Y(e,function(e){n.appendChild(e.dom)}),kt.fromDom(n)}function Wp(e,t,n){return{element:e,width:t,rows:n}}function Kp(e,t){return{element:e,cells:t}}function Xp(e,t){var n=parseInt(vn(e,t),10);return isNaN(n)?1:n}function Yp(e){return L(e,function(e,t){return t.cells.length>e?t.cells.length:e},0)}function Gp(e,t){for(var n=e.rows,r=0;r<n.length;r++)for(var o=n[r].cells,i=0;i<o.length;i++)if(je(o[i],t))return ve.some({x:i,y:r});return ve.none()}function Jp(e,t,n,r,o){for(var i=[],a=e.rows,u=n;u<=o;u++){var s=a[u].cells,c=t<r?s.slice(t,r+1):s.slice(r,t+1);i.push(Kp(a[u].element,c))}return i}function Qp(e){var o=Wp(Eu(e),0,[]);return Y(bu(e,"tr"),function(n,r){Y(bu(n,"td,th"),function(e,t){!function(e,t,n,r,o){for(var i=Xp(o,"rowspan"),a=Xp(o,"colspan"),u=e.rows,s=n;s<n+i;s++){u[s]||(u[s]=Kp(ku(r),[]));for(var c=t;c<t+a;c++)u[s].cells[c]=s===n&&c===t?o:Eu(o)}}(o,function(e,t,n){for(;r=t,((o=e.rows)[n]?o[n].cells:[])[r];)t++;var r,o;return t}(o,t,r),r,n,e)})}),Wp(o.element,Yp(o.rows),o.rows)}function Zp(e,t){var n,r,o,i=kt.fromDom(t.commonAncestorContainer),a=ym(i,e),u=U(a,function(e){return Or(e)||fo(e)}),s=(o=t,M(r=a,function(e){return"li"===Nt(e)&&Tl(e,o)}).fold(J([]),function(e){return M(r,function(e){return"ul"===Nt(e)||"ol"===Nt(e)}).map(function(e){var t=kt.fromTag(Nt(e));return Cn(t,ae(Sn(e),function(e,t){return Ge(t,"list-style")})),[kt.fromTag("li"),t]}).getOr([])}));return A(u.concat(s.length?s:ho(n=i)?Ot(n).filter(po).fold(J([]),function(e){return[n,e]}):po(n)?[n]:[]),Eu)}function eh(){return $p([])}function th(e,i){return hr(i[0],"table",R(je,e)).bind(function(e){var s,t,n=i[0],r=i[i.length-1],o=Qp(e);return t=r,Gp(s=o,n).bind(function(u){return Gp(s,t).map(function(e){return t=s,n=u.x,r=u.y,o=e.x,a=r<(i=e.y)?Jp(t,n,r,o,i):Jp(t,n,i,o,r),Wp(t.element,Yp(a),a);var t,n,r,o,i,a})}).map(function(e){return $p([(n=A((t=e).rows,function(e){var t=A(e.cells,function(e){var t=ku(e);return yn(t,"colspan"),yn(t,"rowspan"),t}),n=Eu(e.element);return Kt(n,t),n}),r=Eu(t.element),Kt(o=kt.fromTag("tbody"),n),Pn(r,o),r)]);var t,n,r,o})}).getOrThunk(eh)}function nh(e,t){var n,r,o,i,a,u,s,c=Al(t,e);return 0<c.length?th(e,c):(n=e,0<(r=t).length&&r[0].collapsed?eh():(o=n,i=r[0],a=kt.fromDom(i.cloneContents()),s=L(u=Zp(o,i),function(e,t){return Pn(t,e),t},a),0<u.length?$p([s]):s))}function rh(e,t){return 0<=t&&t<e.length&&Qc(e.charAt(t))}function oh(e,t){var n=Eo(e.innerText);return t?n.replace(/^[ \f\n\r\t\v]+/,""):n}function ih(e){return zn(e)?e.outerHTML:jn(e)?Qo.encodeRaw(e.data,!1):Vn(e)?"\x3c!--"+e.data+"--\x3e":""}function ah(e,c){var l=0;Y(e,function(e){var t,n,r,o,i,a,u,s;0===e[0]?l++:1===e[0]?(o=c,i=e[1],a=l,s=function(e){var t,n=document.createElement("div"),r=document.createDocumentFragment();for(e&&(n.innerHTML=e);t=n.firstChild;)r.appendChild(t);return r}(i),o.hasChildNodes()&&a<o.childNodes.length?(u=o.childNodes[a]).parentNode.insertBefore(s,u):o.appendChild(s),l++):2===e[0]&&(n=l,(t=c).hasChildNodes()&&n<t.childNodes.length&&(r=t.childNodes[n]).parentNode.removeChild(r))})}function uh(n){var e,t=H((e=n.getBody(),U(A(xe(e.childNodes),ih),function(e){return 0<e.length})),function(e){var t=nm(n.serializer,e);return 0<t.length?[t]:[]}),r=t.join("");return-1!==r.indexOf("</iframe>")?{type:"fragmented",fragments:t,content:"",bookmark:null,beforeBookmark:null}:{type:"complete",fragments:null,content:r,bookmark:null,beforeBookmark:null}}function sh(e,t,n){var r,o,i,g,p,a,h,v,c,l,u,s=n?t.beforeBookmark:t.bookmark;function b(e,t,n,r){for(var o=e;o-t<r&&o<n&&g[o]===p[o-t];)++o;return{start:e,end:o,diag:t}}"fragmented"===t.type?(r=t.fragments,o=e.getBody(),i=A(xe(o.childNodes),ih),ah((p=r,a=(g=i).length+p.length+2,h=new Array(a),v=new Array(a),c=function(e,t,n,r,o){var i=l(e,t,n,r);if(null===i||i.start===t&&i.diag===t-r||i.end===e&&i.diag===e-n)for(var a=e,u=n;a<t||u<r;)a<t&&u<r&&g[a]===p[u]?(o.push([0,g[a]]),++a,++u):r-n<t-e?(o.push([2,g[a]]),++a):(o.push([1,p[u]]),++u);else{c(e,i.start,n,i.start-i.diag,o);for(var s=i.start;s<i.end;++s)o.push([0,g[s]]);c(i.end,t,i.end-i.diag,r,o)}},l=function(e,t,n,r){var o=t-e,i=r-n;if(0==o||0==i)return null;var a,u,s,c,l,f=o-i,d=i+o,m=(d%2==0?d:1+d)/2;for(h[1+m]=e,v[1+m]=t+1,a=0;a<=m;++a){for(u=-a;u<=a;u+=2){for(s=u+m,u===-a||u!==a&&h[s-1]<h[s+1]?h[s]=h[s+1]:h[s]=h[s-1]+1,l=(c=h[s])-e+n-u;c<t&&l<r&&g[c]===p[l];)h[s]=++c,++l;if(f%2!=0&&f-a<=u&&u<=f+a&&v[s-f]<=h[s])return b(v[s-f],u+e-n,t,r)}for(u=f-a;u<=f+a;u+=2){for(s=u+m-f,u===f-a||u!==f+a&&v[s+1]<=v[s-1]?v[s]=v[s+1]-1:v[s]=v[s-1],l=(c=v[s]-1)-e+n-u;e<=c&&n<=l&&g[c]===p[l];)v[s]=c--,l--;if(f%2==0&&-a<=u&&u<=a&&v[s]<=h[s+f])return b(v[s],u+e-n,t,r)}}},u=[],c(0,g.length,0,p.length,u),u),o)):e.setContent(t.content,{format:"raw",no_selection:!V(s)||!qc(s)||!s.isFakeCaret}),e.selection.moveToBookmark(s)}function ch(e){return"fragmented"===e.type?e.fragments.join(""):e.content}function lh(e){var t=kt.fromTag("body",Lh());return wu(t,ch(e)),Y(bu(t,"*[data-mce-bogus]"),Yt),t.dom.innerHTML}function fh(e,t){return!(!e||!t)&&(r=t,ch(e)===ch(r)||(n=t,lh(e)===lh(n)));var n,r}function dh(e){return 0===e.get()}function mh(e,t,n){dh(n)&&(e.typing=t)}function gh(e,t){e.typing&&(mh(e,!1,t),e.add())}function ph(c){return{undoManager:{beforeChange:function(e,t){var n=c,r=t;dh(e)&&r.set(pc(n.selection))},add:function(e,t,n,r,o,i){return function(e,t,n,r,o,i,a){var u=uh(e);if(i=Et.extend(i=i||{},u),!1===dh(r)||e.removed)return null;var s=t.data[n.get()];if(e.fire("BeforeAddUndo",{level:i,lastLevel:s,originalEvent:a}).isDefaultPrevented())return null;if(s&&fh(s,i))return null;t.data[n.get()]&&o.get().each(function(e){t.data[n.get()].beforeBookmark=e});var c=e.getParam("custom_undo_redo_levels",0,"number");if(c&&t.data.length>c){for(var l=0;l<t.data.length-1;l++)t.data[l]=t.data[l+1];t.data.length--,n.set(t.data.length)}i.bookmark=pc(e.selection),n.get()<t.data.length-1&&(t.data.length=n.get()+1),t.data.push(i),n.set(t.data.length-1);var f={level:i,lastLevel:s,originalEvent:a};return 0<n.get()?(e.setDirty(!0),e.fire("AddUndo",f),e.fire("change",f)):e.fire("AddUndo",f),i}(c,e,t,n,r,o,i)},undo:function(e,t,n){return r=c,i=t,a=n,(o=e).typing&&(o.add(),o.typing=!1,mh(o,!1,i)),0<a.get()&&(a.set(a.get()-1),sh(r,u=o.data[a.get()],!0),r.setDirty(!0),r.fire("Undo",{level:u})),u;var r,o,i,a,u},redo:function(e,t){return n=c,o=t,(r=e).get()<o.length-1&&(r.set(r.get()+1),sh(n,i=o[r.get()],!1),n.setDirty(!0),n.fire("Redo",{level:i})),i;var n,r,o,i},clear:function(e,t){var n,r=c,o=t;(n=e).data=[],o.set(0),n.typing=!1,r.fire("ClearUndos")},reset:function(e){var t;(t=e).clear(),t.add()},hasUndo:function(e,t){return n=c,r=e,0<t.get()||r.typing&&r.data[0]&&!fh(uh(n),r.data[0]);var n,r},hasRedo:function(e,t){return n=e,t.get()<n.data.length-1&&!n.typing;var n},transact:function(e,t,n){return o=n,gh(r=e,t),r.beforeChange(),r.ignore(o),r.add();var r,o},ignore:function(e,t){try{e.set(e.get()+1),t()}finally{e.set(e.get()-1)}},extra:function(e,t,n,r){var o,i,a=c,u=t,s=r;(o=e).transact(n)&&(i=o.data[u.get()].bookmark,sh(a,o.data[u.get()-1],!0),o.transact(s)&&(o.data[u.get()-1].beforeBookmark=i))}},formatter:{match:function(e,t,n,r){return Ig(c,e,t,n,r)},matchAll:function(e,t){return o=e,i=t,a=[],u={},n=(r=c).selection.getStart(),r.dom.getParent(n,function(e){for(var t=0;t<o.length;t++){var n=o[t];!u[n]&&yp(r,e,n,i)&&(u[n]=!0,a.push(n))}},r.dom.getRoot()),a;var r,o,i,a,u,n},matchNode:function(e,t,n,r){return yp(c,e,t,n,r)},canApply:function(u){return function(e){var t=e.formatter.get(u),n=e.dom;if(t)for(var r=ll(n,e.selection.getStart()),o=t.length-1;0<=o;o--){var i=t[o];if(!ml(i)||V(i.defaultBlock))return!0;for(var a=r.length-1;0<=a;a--)if(n.is(r[a],i.selector))return!0}return!1}(c)},closest:function(e){return r=c,o=e,ve.from(r.selection.getStart(!0)).bind(function(e){return Tg(kt.fromDom(e),function(n){return ee(o,function(e){return yp(r,n.dom,t=e)?ve.some(t):ve.none();var t})},t)}).getOrNull();function t(e){return je(e,kt.fromDom(r.getBody()))}var r,o},apply:function(e,t,n){return Oh(c,e,t,n)},remove:function(e,t,n,r){return Up(c,e,t,n,r)},toggle:function(e,t,n){var r,o=e,i=t,a=n,u=(r=c).formatter.get(o);(!Ig(r,o,i,a)||"toggle"in u[0]&&!u[0].toggle?Oh:Up)(r,o,i,a)},formatChanged:function(e,t,n,r,o){return qp(c,e,t,n,r,o)}},editor:{getContent:function(e,t){return d=c,m=e,g=t,ve.from(d.getBody()).fold(J("tree"===m.format?new Hd("body",11):""),function(e){return t=d,r=e,o=g,c=_e(_e({},n=m),{format:o,get:!0,getInner:!0}),l=n.no_events?c:t.fire("BeforeGetContent",c),f="raw"===l.format?Et.trim(am(t.serializer,r.innerHTML)):"text"===l.format?t.dom.isEmpty(r)?"":Eo(r.innerText||r.textContent):"tree"===l.format?t.serializer.serialize(r,l):(a=(i=t).serializer.serialize(r,l),u=ks(i),s=new RegExp("^(<"+u+"[^>]*>( | |\\s|\xa0|<br \\/>|)<\\/"+u+">[\r\n]*|<br \\/>[\r\n]*)$"),a.replace(s,"")),T(["text","tree"],l.format)||yo(kt.fromDom(r))?l.content=f:l.content=Et.trim(f),(l.no_events?l:t.fire("GetContent",l)).content;var t,n,r,o,i,a,u,s,c,l,f});var d,m,g},setContent:function(e,t){return Rg(c,e,t)},insertContent:function(e,t){return Ng(c,e,t)},addVisual:function(e){var i,t=e,a=(i=c).dom,n=V(t)?t:i.getBody();b(i.hasVisual)&&(i.hasVisual=i.getParam("visual",!0,"boolean")),Y(a.select("table,a",n),function(e){switch(e.nodeName){case"TABLE":var t=i.getParam("visual_table_class","mce-item-table","string"),n=a.getAttrib(e,"border");n&&"0"!==n||!i.hasVisual?a.removeClass(e,t):a.addClass(e,t);break;case"A":var r,o;a.getAttrib(e,"href")||(r=a.getAttrib(e,"name")||e.id,o=i.getParam("visual_anchor_class","mce-item-anchor","string"),r&&i.hasVisual?a.addClass(e,o):a.removeClass(e,o))}}),i.fire("VisualAid",{element:t,hasVisual:i.hasVisual})}},selection:{getContent:function(e,t){return function(e,t,n){var r,o=(r=t,_e(_e({},n=void 0===n?{}:n),{format:r,get:!0,selection:!0})),i=e.fire("BeforeGetContent",o);if(i.isDefaultPrevented())return e.fire("GetContent",i),i.content;if("text"===i.format)return m=e,ve.from(m.selection.getRng()).map(function(e){var t=ve.from(m.dom.getParent(e.commonAncestorContainer,m.dom.isBlock)),n=m.getBody(),r=t.map(function(e){return e.nodeName}).getOr("div").toLowerCase(),o=xt.browser.isIE()&&"pre"!==r,i=m.dom.add(n,r,{"data-mce-bogus":"all",style:"overflow: hidden; opacity: 0;"},e.cloneContents()),a=oh(i,o),u=Eo(i.textContent);if(m.dom.remove(i),rh(u,0)||rh(u,u.length-1)){var s=oh(t.getOr(n),o),c=s.indexOf(a);return-1===c?a:(rh(s,c-1)?" ":"")+a+(rh(s,c+a.length)?" ":"")}return a}).getOr("");i.getInner=!0;var a,u,s,c,l,f,d,m,g=(u=i,s=(a=e).selection.getRng(),c=a.dom.create("body"),l=a.selection.getSel(),f=Ed(a,_l(l)),(d=u.contextual?nh(kt.fromDom(a.getBody()),f).dom:s.cloneContents())&&c.appendChild(d),a.selection.serializer.serialize(c,u));return"tree"===i.format?g:(i.content=e.selection.isCollapsed()?"":g,e.fire("GetContent",i),i.content)}(c,e,t)}},raw:{getModel:function(){return ve.none()}}}}function hh(e){return ke(e.plugins,"rtc")}function vh(e){var u=e;return ue(e.plugins,"rtc").bind(function(e){return ve.from(e.setup)}).fold(function(){return u.rtcInstance=ph(e),ve.none()},function(e){var t,n;return u.rtcInstance=(t=J(null),n=J(""),{undoManager:{beforeChange:te,add:t,undo:t,redo:t,clear:te,reset:te,hasUndo:D,hasRedo:D,transact:t,ignore:te,extra:te},formatter:{match:D,matchAll:J([]),matchNode:J(void 0),canApply:D,closest:n,apply:te,remove:te,toggle:te,formatChanged:J({unbind:te})},editor:{getContent:n,setContent:n,insertContent:te,addVisual:te},selection:{getContent:n},raw:{getModel:J(ve.none())}}),ve.some(function(){return e().then(function(e){return u.rtcInstance=(i=e.undoManager,a=e.formatter,n=e.editor,r=e.selection,t=e.raw,{undoManager:{beforeChange:i.beforeChange,add:i.add,undo:i.undo,redo:i.redo,clear:i.clear,reset:i.reset,hasUndo:i.hasUndo,hasRedo:i.hasRedo,transact:function(e,t,n){return i.transact(n)},ignore:function(e,t){return i.ignore(t)},extra:function(e,t,n,r){return i.extra(n,r)}},formatter:{match:function(e,t,n,r){return a.match(e,o(t),r)},matchAll:a.matchAll,matchNode:a.matchNode,canApply:function(e){return a.canApply(e)},closest:function(e){return a.closest(e)},apply:function(e,t,n){return a.apply(e,o(t))},remove:function(e,t,n,r){return a.remove(e,o(t))},toggle:function(e,t,n){return a.toggle(e,o(t))},formatChanged:function(e,t,n,r,o){return a.formatChanged(t,n,r,o)}},editor:{getContent:function(e,t){return n.getContent(e)},setContent:function(e,t){return n.setContent(e,t)},insertContent:function(e,t){return n.insertContent(e)},addVisual:n.addVisual},selection:{getContent:function(e,t){return r.getContent(t)}},raw:{getModel:function(){return ve.some(t.getRawModel())}}}),e.rtc.isRemote;function o(e){return h(e)?e:{}}var i,a,n,r,t})})})}function bh(e){return e.rtcInstance||ph(e)}function yh(e){var t=e.rtcInstance;if(t)return t;throw new Error("Failed to get RTC instance not yet initialized.")}function Ch(e){return 0===e.dom.length?(Ln(e),ve.none()):ve.some(e)}function xh(e,t,u,s){e.bind(function(a){return(s?jm:Hm)(a.dom,s?a.dom.length:0),t.filter(_n).map(function(e){var t=u,n=s,r=a.dom,o=e.dom,i=(n?r:o).length;n?(Vm(r,o,!1,!n),t.setStart(o,i)):(Vm(o,r,!1,!n),t.setEnd(o,i))})}).orThunk(function(){var e=s;return t.filter(function(e){return zl.isBookmarkNode(e.dom)}).bind(e?Pt:Bt).or(t).filter(_n).map(function(e){var n,r=s;Ot(n=e).each(function(e){var t=n.dom;r&&Bm(e,ss(t,0))?Hm(t,0):!r&&Pm(e,ss(t,t.length))&&jm(t,t.length)})})})}function wh(e,t,n){var r,o=(r=t,_e(_e({format:"html"},n=void 0===n?{}:n),{set:!0,selection:!0,content:r})),i=o;if(!o.no_events){var a=e.fire("BeforeSetContent",o);if(a.isDefaultPrevented())return void e.fire("SetContent",a);i=a}i.content=function(e,t){if("raw"===t.format)return t.content;var n=e.selection.getRng(),r=e.dom.getParent(n.commonAncestorContainer,e.dom.isBlock),o=r?{context:r.nodeName.toLowerCase()}:{},i=e.parser.parse(t.content,_e(_e({isRootContent:!0,forced_root_block:!1},o),t));return im({validate:e.validate},e.schema).serialize(i)}(e,i);var u=e.selection.getRng();!function(e,t){var n=ve.from(t.firstChild).map(kt.fromDom),r=ve.from(t.lastChild).map(kt.fromDom);e.deleteContents(),e.insertNode(t);var o=n.bind(Bt).filter(_n).bind(Ch),i=r.bind(Pt).filter(_n).bind(Ch);xh(o,n,e,!0),xh(i,r,e,!1),e.collapse(!1)}(u,u.createContextualFragment(i.content)),e.selection.setRng(u),td(e,u),i.no_events||e.fire("SetContent",i)}function Sh(e,t,n){var r;e&&ke(e,t)&&(0===(r=U(e[t],function(e){return e!==n})).length?delete e[t]:e[t]=r)}Kg=function(e){var t,n=e.selection.getRng(),r=on(["pre"]);n.collapsed||(t=e.selection.getSelectedBlocks(),Ep(Sp(Sp(t,r),function(e){return r(e.previousSibling)&&-1!==de(t,e.previousSibling)}),function(e){var t,n=e.previousSibling;Xa(t=e).remove(),Xa(n).append("<br><br>").append(t.childNodes)}))},wp["pre"]||(wp.pre=[]),wp.pre.push(Kg);var Eh=Et.each,kh=function(e,t,n){Eh(e.childNodes,function(e){kp(e)&&(t(e)&&n(e),e.hasChildNodes()&&kh(e,t,n))})},Nh=or([{keep:[]},{rename:["name"]},{removed:[]}]),_h=/^(src|href|style)$/,Ah=Et.each,Rh=al,Dh=Et.each,Th=Et.each,Oh=function(S,E,k,r){function N(n,e){var t;y((e=void 0===e?A:e).onformat)&&e.onformat(n,e,k,r),Th(e.styles,function(e,t){u.setStyle(n,t,il(e,k))}),!e.styles||(t=u.getAttrib(n,"style"))&&u.setAttrib(n,"data-mce-style",t),Th(e.attributes,function(e,t){u.setAttrib(n,t,il(e,k))}),Th(e.classes,function(e){e=il(e,k),u.hasClass(n,e)||u.addClass(n,e)})}function g(e,t){var n=!1;return Th(e,function(e){return!!ml(e)&&(V(e.collapsed)&&e.collapsed!==a||!u.is(t,e.selector)||jc(t)?void 0:(N(t,e),!(n=!0)))}),n}function o(x,e,l){var w=[],f=!0,d=A.inline||A.block,m=function(e){if(X(e)){var t=u.create(e);return N(t),t}return null}(d);Nl(x,e,function(e){var s,c=function(e){var t=!1,n=f,r=e.nodeName.toLowerCase(),o=e.parentNode,i=o.nodeName.toLowerCase();if(zn(e)&&x.getContentEditable(e)&&(n=f,f="true"===x.getContentEditable(e),t=!0),Wn(e)&&!function(e,t,n,r){if(e.getParam("format_empty_lines",!1,"boolean")&&gl(t)){var o=to(e.schema),i=(a=kt.fromDom(n),s=function(e){return jc(e.dom)},((c=(u=a).dom).parentNode?kr(kt.fromDom(c.parentNode),function(e){return!je(u,e)&&s(e)}):ve.none()).isSome());return se(o,r)&&Wr(kt.fromDom(n.parentNode),!1)&&!i}var a,u,s,c}(S,A,e,i))return s=null,void(dl(A)&&x.remove(e));if(dl(A)&&A.wrapper&&yp(S,e,E,k))s=null;else{if(f&&!t&&dl(A)&&!A.wrapper&&rl(S,r)&&ol(S,i,d)){var a=x.rename(e,d);return N(a),w.push(a),void(s=null)}if(ml(A)){var u=g(_,e);if(!u&&V(o)&&pl(A)&&(u=g(_,o)),!gl(A)||u)return void(s=null)}!f||t||!ol(S,d,r)||!ol(S,i,d)||!l&&jn(e)&&So(e.data)||jc(e)||gl(A)&&x.isBlock(e)?(s=null,Y(xe(e.childNodes),c),t&&(f=n),s=null):(s||(s=x.clone(m,!1),e.parentNode.insertBefore(s,e),w.push(s)),s.appendChild(e))}};Y(e,c)}),!0===A.links&&Y(w,function(e){var t=function(e){"A"===e.nodeName&&N(e,A),Y(xe(e.childNodes),t)};t(e)}),Y(w,function(e){var n,t,r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,b,y=(n=0,Y(e.childNodes,function(e){var t;V(t=e)&&jn(t)&&0===t.length||Jc(e)||n++}),n);function C(e){var t;1===e.nodeType&&e.parentNode&&1===e.parentNode.nodeType&&(t=cl(m,e.parentNode),m.getStyle(e,"color")&&t?m.setStyle(e,"text-decoration",t):m.getStyle(e,"text-decoration")===t&&m.setStyle(e,"text-decoration",null))}!(1<w.length)&&x.isBlock(e)||0!==y?(gl(A)||dl(A)&&A.wrapper)&&(A.exact||1!==y||(e=M((d=e).childNodes,zp).filter(function(e){return Pg(x,e,A)}).map(function(e){var t=x.clone(e,!1);return N(t),x.replace(t,d,!0),x.remove(e,!0),t}).getOr(d)),h=S,v=k,b=e,Dh(_,function(t){var r,e,n;gl(t)&&Dh(h.dom.select(t.inline,b),function(e){kp(e)&&Fp(h,t,v,e,t.exact?e:null)}),r=h.dom,(e=t).clear_child_styles&&(n=e.links?"*:not(a)":"*",Eh(r.select(n,b),function(n){kp(n)&&Eh(e.styles,function(e,t){r.setStyle(n,t,"")})}))}),s=A,yp(u=S,(f=e).parentNode,c=E,l=k)&&Fp(u,s,l,f)||s.merge_with_parents&&u.dom.getParent(f.parentNode,function(e){if(yp(u,e,c,l))return Fp(u,s,l,f),!0}),a=e,(i=A).styles&&i.styles.backgroundColor&&kh(a,Rp(x,"fontSize"),Dp(x,"backgroundColor",il(i.styles.backgroundColor,k))),m=x,p=e,(g=A).styles&&(g.styles.color||g.styles.textDecoration)&&(Et.walk(p,C,"childNodes"),C(p)),t=x,o=e,!gl(r=A)||"sub"!==r.inline&&"sup"!==r.inline||(kh(o,Rp(t,"fontSize"),Dp(t,"fontSize","")),t.remove(t.select("sup"===r.inline?"sub":"sup",o),!0)),Ap(x,A,0,e)):x.remove(e,!0)})}var e,t,n,i,_=S.formatter.get(E),A=_[0],a=!r&&S.selection.isCollapsed(),u=S.dom,s=S.selection;if("false"!==u.getContentEditable(s.getNode()))A&&(r?el(r)?g(_,r)||((e=u.createRng()).setStartBefore(r),e.setEndAfter(r),o(u,kl(S,e,_),!0)):o(u,r,!0):a&&gl(A)&&!Rl(S).length?function(e,t,n){var r,o=e.selection,i=o.getRng(),a=i.startOffset,u=i.startContainer.nodeValue,s=Vc(e.getBody(),o.getStart());s&&(r=Fg(s));var c,l,f,d,m=/[^\s\u00a0\u00ad\u200b\ufeff]/;u&&0<a&&a<u.length&&m.test(u.charAt(a))&&m.test(u.charAt(a-1))?(c=o.getBookmark(),i.collapse(!0),l=Bf(kl(e,i,e.formatter.get(t))),e.formatter.apply(t,n,l),o.moveToBookmark(c)):(s&&r.nodeValue===Cp||(f=e.getDoc(),d=Ug(!0).dom,r=(s=f.importNode(d,!0)).firstChild,i.insertNode(s),a=1),e.formatter.apply(t,n,s),o.setCursorLocation(r,a))}(S,E,k):(t=s.getNode(),n=_[0],S.settings.forced_root_block||!n.defaultBlock||u.getParent(t,u.isBlock)||Oh(S,n.defaultBlock),s.setRng(Cg(s.getRng())),Ll(s,!0,function(){Pl(S,function(e,t){var n=t?e:kl(S,e,_);o(u,n,!1)})}),tl(u,s,s.getRng()),S.nodeChanged()),i=S,Ep(wp[E],function(e){e(i)})),Cf(S,E,r,k);else{r=s.getNode();for(var c=0,l=_.length;c<l;c++){var f=_[c];if(f.ceFalseOverride&&ml(f)&&u.is(r,f.selector)){N(r,f);break}}Cf(S,E,r,k)}},Bh=function(e){return e.selection.getStart()},Ph=function(i,a,e){var u=Vp(i,a);ne(e,function(e,o){function t(e){var t,n=jp(i,u,o,e.similar,Hp(e)?e.vars:void 0),r=n.isSome();e.state.get()!==r&&(e.state.set(r),t=n.getOr(a),Hp(e)?e.callback(r,{node:t,format:o,parents:u}):Y(e.callbacks,function(e){return e(r,{node:t,format:o,parents:u})}))}Y([e.withSimilar,e.withoutSimilar],t),Y(e.withVars,t)})},Lh=Re(function(){return document.implementation.createHTMLDocument("undo")});function Ih(e){return e.select}function Mh(e){return e&&e.ownerDocument&&Ve(kt.fromDom(e.ownerDocument),kt.fromDom(e))}function Fh(a,u,e,s){function t(e,t){return wh(s,e,t)}function n(){var e=c(),t=null==e?void 0:e.anchorNode,n=null==e?void 0:e.focusNode;if(!e||!t||!n||rn(t)||rn(n))return!0;var r=a.createRng();r.setStart(t,e.anchorOffset),r.collapse(!0);var o=a.createRng();return o.setStart(n,e.focusOffset),o.collapse(!0),r.compareBoundaryPoints(r.START_TO_START,o)<=0}function r(e){var t=p();t.collapse(!!e),h(t)}function c(){return u.getSelection?u.getSelection():u.document.selection}var l,f,o,i,d,m,g=function(e,t){return d||(d={},m={},i.on("NodeChange",function(e){var n=e.element,r=x(n),o={};Et.each(d,function(e,n){C(n,r).each(function(t){m[n]||(Y(e,function(e){e(!0,{node:t,selector:n,parents:r})}),m[n]=e),o[n]=e})}),Et.each(m,function(e,t){o[t]||(delete m[t],Et.each(e,function(e){e(!1,{node:n,selector:t,parents:r})}))})})),d[e]||(d[e]=[]),d[e].push(t),C(e,x(i.selection.getStart())).each(function(){m[e]=d[e]}),{unbind:function(){Sh(d,e,t),Sh(m,e,t)}}},p=function(){function e(e,t,n){try{return t.compareBoundaryPoints(e,n)}catch(e){return-1}}var t,n,r,o=u.document;if(void 0!==s.bookmark&&!1===yd(s)){var i=dd(s);if(i.isSome())return i.map(function(e){return Ed(s,[e])[0]}).getOr(o.createRange())}try{(t=c())&&!rn(t.anchorNode)&&(n=0<t.rangeCount?t.getRangeAt(0):(t.createRange?t:o).createRange(),n=Ed(s,[n])[0])}catch(e){}return(n=n||(o.createRange?o.createRange():o.body.createTextRange())).setStart&&9===n.startContainer.nodeType&&n.collapsed&&(r=a.getRoot(),n.setStart(r,0),n.setEnd(r,0)),l&&f&&(0===e(n.START_TO_START,n,l)&&0===e(n.END_TO_END,n,l)?n=f:f=l=null),n},h=function(e,t){var n;if((r=e)&&(Ih(r)||Mh(r.startContainer)&&Mh(r.endContainer))){var r,o=Ih(e)?e:null;if(o){f=null;try{o.select()}catch(e){}}else{var i=c();if(e=s.fire("SetSelectionRange",{range:e,forward:t}).range,i){f=e;try{i.removeAllRanges(),i.addRange(e)}catch(e){}!1===t&&i.extend&&(i.collapse(e.endContainer,e.endOffset),i.extend(e.startContainer,e.startOffset)),l=0<i.rangeCount?i.getRangeAt(0):null}e.collapsed||e.startContainer!==e.endContainer||!i.setBaseAndExtent||xt.ie||e.endOffset-e.startOffset<2&&e.startContainer.hasChildNodes()&&(n=e.startContainer.childNodes[e.startOffset])&&"IMG"===n.tagName&&(i.setBaseAndExtent(e.startContainer,e.startOffset,e.endContainer,e.endOffset),i.anchorNode===e.startContainer&&i.focusNode===e.endContainer||i.setBaseAndExtent(n,0,n,1)),s.fire("AfterSetSelectionRange",{range:e,forward:t})}}},v={bookmarkManager:null,controlSelection:null,dom:o=a,win:u,serializer:e,editor:i=s,collapse:r,setCursorLocation:function(e,t){var n=a.createRng();V(e)&&V(t)?(n.setStart(e,t),n.setEnd(e,t),h(n),r(!1)):(Ol(a,n,s.getBody(),!0),h(n))},getContent:function(e){return n=(t=void 0===(t=e)?{}:t).format||"html",r=t,yh(s).selection.getContent(n,r);var t,n,r},setContent:t,getBookmark:function(e,t){return b.getBookmark(e,t)},moveToBookmark:function(e){return b.moveToBookmark(e)},select:function(e,t){var r=a,o=t;return ve.from(e).map(function(e){var t=r.nodeIndex(e),n=r.createRng();return n.setStart(e.parentNode,t),n.setEnd(e.parentNode,t+1),o&&(Ol(r,n,e,!0),Ol(r,n,e,!1)),n}).each(h),e},isCollapsed:function(){var e=p(),t=c();return!(!e||e.item)&&(e.compareEndPoints?0===e.compareEndPoints("StartToEnd",e):!t||e.collapsed)},isForward:n,setNode:function(e){return t(a.getOuterHTML(e)),e},getNode:function(){return function(e,t){if(!t)return e;var n=t.startContainer,r=t.endContainer,o=t.startOffset,i=t.endOffset,a=t.commonAncestorContainer;return!t.collapsed&&(n===r&&i-o<2&&n.hasChildNodes()&&(a=n.childNodes[o]),3===n.nodeType&&3===r.nodeType&&(n=n.length===o?Sd(n.nextSibling,!0):n.parentNode,r=0===i?Sd(r.previousSibling,!1):r.parentNode,n&&n===r))?n:a&&3===a.nodeType?a.parentNode:a}(s.getBody(),p())},getSel:c,setRng:h,getRng:p,getStart:function(e){return xd(s.getBody(),p(),e)},getEnd:function(e){return wd(s.getBody(),p(),e)},getSelectedBlocks:function(e,t){return function(e,t,n,r){var o=[],i=e.getRoot();if(n=e.getParent(n||xd(i,t,t.collapsed),e.isBlock),r=e.getParent(r||wd(i,t,t.collapsed),e.isBlock),n&&n!==i&&o.push(n),n&&r&&n!==r)for(var a,u=new Rr(n,i);(a=u.next())&&a!==r;)e.isBlock(a)&&o.push(a);return r&&n!==r&&r!==i&&o.push(r),o}(a,p(),e,t)},normalize:function(){var e=p();if(1<_l(c()).length||!Bl(s))return e;var t=Tf(a,e);return t.each(function(e){h(e,n())}),t.getOr(e)},selectorChanged:function(e,t){return g(e,t),v},selectorChangedWithUnbind:g,getScrollContainer:function(){for(var e,t=a.getRoot();t&&"BODY"!==t.nodeName;){if(t.scrollHeight>t.clientHeight){e=t;break}t=t.parentNode}return e},scrollIntoView:function(e,t){V(e)?(s.inline?Qf:ed)(s,e,t):td(s,p(),t)},placeCaretAt:function(e,t){return h(Ef(e,t,s.getDoc()))},getBoundingClientRect:function(){var e=p();return e.collapsed?ss.fromRangeStart(e).getClientRects()[0]:e.getBoundingClientRect()},destroy:function(){u=l=f=null,y.destroy()}},b=zl(v),y=wf(v,s);function C(t,e){return M(e,function(e){return o.is(e,t)})}function x(e){return o.getParents(e,null,o.getRoot())}return v.bookmarkManager=b,v.controlSelection=y,v}function Uh(e,t){var n,r,a,u,o=io();t.convert_fonts_to_spans&&(r=e,a=o,u=Et.explode(t.font_size_legacy_values),r.addNodeFilter("font",function(e){Y(e,function(e){var t,n=a.parse(e.attr("style")),r=e.attr("color"),o=e.attr("face"),i=e.attr("size");r&&(n.color=r),o&&(n["font-family"]=o),i&&(n["font-size"]=u[parseInt(e.attr("size"),10)-1]),e.name="span",e.attr("style",a.serialize(n)),t=e,Y(["color","face","size"],function(e){t.attr(e,null)})})})),n=o,e.addNodeFilter("strike",function(e){Y(e,function(e){var t=n.parse(e.attr("style"));t["text-decoration"]="line-through",e.name="span",e.attr("style",n.serialize(t))})})}function zh(e){var t,n=decodeURIComponent(e).split(","),r=/data:([^;]+)/.exec(n[0]);return{type:t=r?r[1]:t,data:n[1]}}function Hh(e,t){var n;try{n=atob(t)}catch(e){return ve.none()}for(var r=new Uint8Array(n.length),o=0;o<r.length;o++)r[o]=n.charCodeAt(o);return ve.some(new Blob([r],{type:e}))}function jh(e){return 0===e.indexOf("blob:")?(o=e,new Nr(function(e,t){function n(){t("Cannot convert "+o+" to Blob. Resource might not exist or is inaccessible.")}try{var r=new XMLHttpRequest;r.open("GET",o,!0),r.responseType="blob",r.onload=function(){200===r.status?e(r.response):n()},r.onerror=n,r.send()}catch(e){n()}})):0===e.indexOf("data:")?(n=e,new Nr(function(e){var t=zh(n);Hh(t.type,t.data).fold(function(){return e(new Blob([]))},e)})):null;var o,n}function Vh(e){return(e||"blobid")+mv++}function qh(r,d){var o={};return{findAll:function(e,n){n=n||w;var t=A(U(e?xe(e.getElementsByTagName("img")):[],function(e){var t=e.src;return xt.fileApi&&!e.hasAttribute("data-mce-bogus")&&!e.hasAttribute("data-mce-placeholder")&&t&&t!==xt.transparentSrc&&(0===t.indexOf("blob:")?!r.isUploaded(t)&&n(e):0===t.indexOf("data:")&&n(e))}),function(f){if(void 0!==o[f.src])return new Nr(function(t){o[f.src].then(function(e){return"string"==typeof e?e:void t({image:f,blobInfo:e.blobInfo})})});var e=new Nr(function(e,t){var r,o,i,n,a,u,s,c,l;r=d,i=e,n=t,0!==(o=f).src.indexOf("blob:")?(u=(a=zh(o.src)).data,s=a.type,c=u,(l=r.getByData(c,s))?i({image:o,blobInfo:l}):jh(o.src).then(function(e){l=r.create(Vh(),e,c),r.add(l),i({image:o,blobInfo:l})},function(e){n(e)})):(l=r.getByUri(o.src))?i({image:o,blobInfo:l}):jh(o.src).then(function(t){var n=t;new Nr(function(e){var t=new FileReader;t.onloadend=function(){e(t.result)},t.readAsDataURL(n)}).then(function(e){c=zh(e).data,l=r.create(Vh(),t,c),r.add(l),i({image:o,blobInfo:l})})},function(e){n(e)})}).then(function(e){return delete o[e.image.src],e}).catch(function(e){return delete o[f.src],e});return o[f.src]=e});return Nr.all(t)}}}function $h(e,t,n,r){(e.padd_empty_with_br||t.insert)&&n[r.name]?r.empty().append(new Hd("br",1)).shortEnded=!0:r.empty().append(new Hd("#text",3)).value=xo}function Wh(n,e,t,r){return r.isEmpty(e,t,function(e){return(t=n.getElementRule(e.name))&&t.paddEmpty;var t})}function Kh(e,p){var t,o,i,h=e.schema;function n(t){var e,n,r=t.attr("src");(e=t).attr("src")===xt.transparentSrc||V(e.attr("data-mce-placeholder"))||V(t.attr("data-mce-bogus"))||((n=/data:([^;]+);base64,([a-z0-9\+\/=\s]+)/i.exec(r))?ve.some({type:n[1],data:decodeURIComponent(n[2])}):ve.none()).filter(function(){return function(e,t){if(t.images_dataimg_filter){var n=new Image;return n.src=e.attr("src"),ne(e.attributes.map,function(e,t){n.setAttribute(t,e)}),t.images_dataimg_filter(n)}return!0}(t,o)}).bind(function(e){var t=e.type,n=e.data;return ve.from(i.getByData(n,t)).orThunk(function(){return Hh(t,n).map(function(e){var t=i.create(Vh(),e,n);return i.add(t),t})})}).each(function(e){t.attr("src",e.blobUri())})}p.remove_trailing_brs&&e.addNodeFilter("br",function(e,t,n){var r,o,i,a,u,s,c,l,f=e.length,d=Et.extend({},h.getBlockElements()),m=h.getNonEmptyElements(),g=h.getWhiteSpaceElements();for(d.body=1,r=0;r<f;r++)if(i=(o=e[r]).parent,d[o.parent.name]&&o===i.lastChild){for(u=o.prev;u;){if("span"!==(s=u.name)||"bookmark"!==u.attr("data-mce-type")){"br"===s&&(o=null);break}u=u.prev}o&&(o.remove(),Wh(h,m,g,i)&&(c=h.getElementRule(i.name))&&(c.removeEmpty?i.remove():c.paddEmpty&&$h(p,n,d,i)))}else{for(a=o;i&&i.firstChild===a&&i.lastChild===a&&!d[(a=i).name];)i=i.parent;a===i&&!0!==p.padd_empty_with_br&&((l=new Hd("#text",3)).value=xo,o.replace(l))}}),e.addAttributeFilter("href",function(e){var t,n,r=e.length;if(!p.allow_unsafe_link_target)for(;r--;){var o=e[r];"a"===o.name&&"_blank"===o.attr("target")&&o.attr("rel",(n=void 0,n=(t=o.attr("rel"))?Et.trim(t):"",/\b(noopener)\b/g.test(n)?n:n.split(" ").filter(function(e){return 0<e.length}).concat(["noopener"]).sort().join(" ")))}}),p.allow_html_in_named_anchor||e.addAttributeFilter("id,name",function(e){for(var t,n,r,o,i=e.length;i--;)if("a"===(o=e[i]).name&&o.firstChild&&!o.attr("href"))for(r=o.parent,t=o.lastChild;n=t.prev,r.insert(t,o),t=n;);}),p.fix_list_elements&&e.addNodeFilter("ul,ol",function(e){for(var t,n,r,o=e.length;o--;)"ul"!==(r=(n=e[o]).parent).name&&"ol"!==r.name||(n.prev&&"li"===n.prev.name?n.prev.append(n):((t=new Hd("li",1)).attr("style","list-style-type: none"),n.wrap(t)))}),p.validate&&h.getValidClasses()&&e.addAttributeFilter("class",function(e){for(var t=h.getValidClasses(),n=e.length;n--;){for(var r=e[n],o=r.attr("class").split(" "),i="",a=0;a<o.length;a++){var u=o[a],s=!1,c=t["*"];c&&c[u]&&(s=!0),c=t[r.name],(s=!(s||!c||!c[u])||s)&&(i&&(i+=" "),i+=u)}i.length||(i=null),r.attr("class",i)}}),t=e,(i=(o=p).blob_cache)&&t.addAttributeFilter("src",function(e){return Y(e,n)})}function Xh(A,R){void 0===R&&(R=ro());var D={},T=[],O={},B={};(A=A||{}).validate=!("validate"in A)||A.validate,A.root_name=A.root_name||"body";function P(e){var t=e.name;t in D&&((r=O[t])?r.push(e):O[t]=[e]);for(var n=T.length;n--;){var r,o=T[n].name;o in e.attributes.map&&((r=B[o])?r.push(e):B[o]=[e])}return e}var e={schema:R,addAttributeFilter:function(e,n){hv(vv(e),function(e){for(var t=0;t<T.length;t++)if(T[t].name===e)return void T[t].callbacks.push(n);T.push({name:e,callbacks:[n]})})},getAttributeFilters:function(){return[].concat(T)},addNodeFilter:function(e,n){hv(vv(e),function(e){var t=D[e];t||(D[e]=t=[]),t.push(n)})},getNodeFilters:function(){var e,t=[];for(e in D)ke(D,e)&&t.push({name:e,callbacks:D[e]});return t},filterNode:P,parse:function(e,s){var t,n,r,o,i,c,a,l,f=[];function d(e){for(var t=R.getBlockElements(),n=e.prev;n&&3===n.type;){var r=n.value.replace(w,"");if(0<r.length)return n.value=r,0;var o=n.next;if(o){if(3===o.type&&o.value.length){n=n.prev;continue}if(!t[o.name]&&"script"!==o.name&&"style"!==o.name){n=n.prev;continue}}var i=n.prev;n.remove(),n=i}}s=s||{},O={},B={};function m(e,t){var n,r=new Hd(e,t);return e in D&&((n=O[e])?n.push(r):O[e]=[r]),r}var g=bv(pv("script,style,head,html,body,title,meta,param"),R.getBlockElements()),p=to(R),h=R.getNonEmptyElements(),v=R.children,b=A.validate,u=("forced_root_block"in s?s:A).forced_root_block,y=!1===u?"":!0===u?"p":u,C=R.getWhiteSpaceElements(),x=/^[ \t\r\n]+/,w=/[ \t\r\n]+$/,S=/[ \t\r\n]+/g,E=/^[ \t\r\n]+$/,k=ke(C,s.context)||ke(C,A.root_name),N=Qd({validate:b,document:A.document,allow_html_data_urls:A.allow_html_data_urls,allow_svg_data_urls:A.allow_svg_data_urls,allow_script_urls:A.allow_script_urls,allow_conditional_comments:A.allow_conditional_comments,preserve_cdata:A.preserve_cdata,self_closing_elements:function(e){var t,n={};for(t in e)"li"!==t&&"p"!==t&&(n[t]=e[t]);return n}(R.getSelfClosingElements()),cdata:function(e){l.append(m("#cdata",4)).value=e},text:function(e,t){var n,r;k||(e=e.replace(S," "),(r=l.lastChild)&&(ke(g,r.name)||"br"===r.name)&&(e=e.replace(x,""))),0!==e.length&&((n=m("#text",3)).raw=!!t,l.append(n).value=e)},comment:function(e){l.append(m("#comment",8)).value=e},pi:function(e,t){l.append(m(e,7)).value=t,d(l)},doctype:function(e){l.append(m("#doctype",10)).value=e,d(l)},start:function(e,t,n){var r=b?R.getElementRule(e):{};if(r){var o=m(r.outputName||e,1);o.attributes=t,o.shortEnded=n,l.append(o);var i=v[l.name];i&&v[o.name]&&!i[o.name]&&f.push(o);for(var a=T.length;a--;){var u=T[a].name;u in t.map&&((c=B[u])?c.push(o):B[u]=[o])}g[e]&&d(o),n||(l=o),!k&&C[e]&&(k=!0)}},end:function(e){var t,n,r,o,i=b?R.getElementRule(e):{};if(i){if(g[e]&&!k){if((t=l.firstChild)&&3===t.type)if(0<(n=t.value.replace(x,"")).length)t.value=n,t=t.next;else for(r=t.next,t.remove(),t=r;t&&3===t.type;)n=t.value,r=t.next,0!==n.length&&!E.test(n)||(t.remove(),t=r),t=r;if((t=l.lastChild)&&3===t.type)if(0<(n=t.value.replace(w,"")).length)t.value=n,t=t.prev;else for(r=t.prev,t.remove(),t=r;t&&3===t.type;)n=t.value,r=t.prev,0!==n.length&&!E.test(n)||(t.remove(),t=r),t=r}k&&C[e]&&(k=!1);var a=Wh(R,h,C,l),u=l.parent;i.paddInEmptyBlock&&a&&function(){for(var e=l;V(e);){if(e.name in p)return Wh(R,h,C,e);e=e.parent}}()?$h(A,s,g,l):i.removeEmpty&&a?g[l.name]?l.empty().remove():l.unwrap():i.paddEmpty&&(gv(o=l,"#text")&&o.firstChild.value===xo||a)&&$h(A,s,g,l),l=u}}},R),_=l=new Hd(s.context||A.root_name,11);if(N.parse(e,s.format),b&&f.length&&(s.context?s.invalid=!0:function(e){for(var t=pv("tr,td,th,tbody,thead,tfoot,table"),n=R.getNonEmptyElements(),r=R.getWhiteSpaceElements(),o=R.getTextBlockElements(),i=R.getSpecialElements(),a=function(e,t){if(void 0===t&&(t=e.parent),i[e.name])e.empty().remove();else{for(var n=0,r=e.children();n<r.length;n++){var o=r[n];R.isValidChild(t.name,o.name)||a(o,t)}e.unwrap()}},u=0;u<e.length;u++){var s,c=e[u],l=void 0,f=void 0;if(c.parent&&!c.fixed)if(o[c.name]&&"li"===c.parent.name){for(var d=c.next;d&&o[d.name];)d.name="li",d.fixed=!0,c.parent.insert(d,c.parent),d=d.next;c.unwrap()}else{for(var m=[c],l=c.parent;l&&!R.isValidChild(l.name,c.name)&&!t[l.name];l=l.parent)m.push(l);if(l&&1<m.length)if(R.isValidChild(l.name,c.name)){m.reverse();for(var g=s=P(m[0].clone()),p=0;p<m.length-1;p++){R.isValidChild(g.name,m[p].name)?(f=P(m[p].clone()),g.append(f)):f=g;for(var h=m[p].firstChild;h&&h!==m[p+1];){var v=h.next;f.append(h),h=v}g=f}Wh(R,n,r,s)?l.insert(c,m[0],!0):(l.insert(s,m[0],!0),l.insert(c,s)),l=m[0],(Wh(R,n,r,l)||gv(l,"br"))&&l.empty().remove()}else a(c);else c.parent&&("li"!==c.name?R.isValidChild(c.parent.name,"div")&&R.isValidChild("div",c.name)?c.wrap(P(new Hd("div",1))):a(c):!(d=c.prev)||"ul"!==d.name&&"ol"!==d.name?!(d=c.next)||"ul"!==d.name&&"ol"!==d.name?c.wrap(P(new Hd("ul",1))):d.insert(c,d.firstChild,!0):d.append(c))}}}(f)),y&&("body"===_.name||s.isRootContent)&&function(){function e(e){e&&((t=e.firstChild)&&3===t.type&&(t.value=t.value.replace(x,"")),(t=e.lastChild)&&3===t.type&&(t.value=t.value.replace(w,"")))}var t=_.firstChild,n=null;if(R.isValidChild(_.name,y.toLowerCase())){for(;t;){var r=t.next;3===t.type||1===t.type&&"p"!==t.name&&!g[t.name]&&!t.attr("data-mce-type")?(n||((n=m(y,1)).attr(A.forced_root_block_attrs),_.insert(n,t)),n.append(t)):(e(n),n=null),t=r}e(n)}}(),!s.invalid){for(a in O)if(ke(O,a)){for(c=D[a],o=(t=O[a]).length;o--;)t[o].parent||t.splice(o,1);for(n=0,r=c.length;n<r;n++)c[n](t,a,s)}for(n=0,r=T.length;n<r;n++)if((c=T[n]).name in B){for(o=(t=B[c.name]).length;o--;)t[o].parent||t.splice(o,1);for(o=0,i=c.callbacks.length;o<i;o++)c.callbacks[o](t,c.name,s)}}return _}};return Kh(e,A),A.inline_styles&&Uh(e,A),e}function Yh(e,t,n){-1===Et.inArray(t,n)&&(e.addAttributeFilter(n,function(e,t){for(var n=e.length;n--;)e[n].attr(t,null)}),t.push(n))}function Gh(L,I){var e=["data-mce-selected"],M=I&&I.dom?I.dom:Za.DOM,F=I&&I.schema?I.schema:ro(L);L.entity_encoding=L.entity_encoding||"named",L.remove_trailing_brs=!("remove_trailing_brs"in L)||L.remove_trailing_brs;var t,U=Xh(L,F),s=L,c=M;return(t=U).addAttributeFilter("data-mce-tabindex",function(e,t){for(var n=e.length;n--;){var r=e[n];r.attr("tabindex",r.attr("data-mce-tabindex")),r.attr(t,null)}}),t.addAttributeFilter("src,href,style",function(e,t){for(var n="data-mce-"+t,r=s.url_converter,o=s.url_converter_scope,i=e.length;i--;){var a=e[i],u=a.attr(n);void 0!==u?(a.attr(t,0<u.length?u:null),a.attr(n,null)):(u=a.attr(t),"style"===t?u=c.serializeStyle(c.parseStyle(u),a.name):r&&(u=r.call(o,u,t,a.name)),a.attr(t,0<u.length?u:null))}}),t.addAttributeFilter("class",function(e){for(var t=e.length;t--;){var n,r=e[t];r.attr("class")&&(n=r.attr("class").replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),r.attr("class",0<n.length?n:null))}}),t.addAttributeFilter("data-mce-type",function(e,t,n){for(var r=e.length;r--;){var o=e[r];"bookmark"!==o.attr("data-mce-type")||n.cleanup||(ve.from(o.firstChild).exists(function(e){return!So(e.value)})?o.unwrap():o.remove())}}),t.addNodeFilter("noscript",function(e){for(var t=e.length;t--;){var n=e[t].firstChild;n&&(n.value=Qo.decode(n.value))}}),t.addNodeFilter("script,style",function(e,t){for(var n=function(e){return e.replace(/(<!--\[CDATA\[|\]\]-->)/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi,"").replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")},r=e.length;r--;){var o,i=e[r],a=i.firstChild?i.firstChild.value:"";"script"===t?((o=i.attr("type"))&&i.attr("type","mce-no/type"===o?null:o.replace(/^mce\-/,"")),"xhtml"===s.element_format&&0<a.length&&(i.firstChild.value="// <![CDATA[\n"+n(a)+"\n// ]]>")):"xhtml"===s.element_format&&0<a.length&&(i.firstChild.value="\x3c!--\n"+n(a)+"\n--\x3e")}}),t.addNodeFilter("#comment",function(e){for(var t=e.length;t--;){var n=e[t];s.preserve_cdata&&0===n.value.indexOf("[CDATA[")?(n.name="#cdata",n.type=4,n.value=c.decode(n.value.replace(/^\[CDATA\[|\]\]$/g,""))):0===n.value.indexOf("mce:protected ")&&(n.name="#text",n.type=3,n.raw=!0,n.value=unescape(n.value).substr(14))}}),t.addNodeFilter("xml:namespace,input",function(e,t){for(var n=e.length;n--;){var r=e[n];7===r.type?r.remove():1===r.type&&("input"!==t||r.attr("type")||r.attr("type","text"))}}),t.addAttributeFilter("data-mce-type",function(e){Y(e,function(e){"format-caret"===e.attr("data-mce-type")&&(e.isEmpty(t.schema.getNonEmptyElements())?e.remove():e.unwrap())})}),t.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-type,data-mce-resize,data-mce-placeholder",function(e,t){for(var n=e.length;n--;)e[n].attr(t,null)}),{schema:F,addNodeFilter:U.addNodeFilter,addAttributeFilter:U.addAttributeFilter,serialize:function(e,t){var n,r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,b,y,C,x,w,S,E,k,N,_,A,R,D,T=_e({format:"html"},t=void 0===t?{}:t),O=(n=(m=e,E=g=T,(d=I)&&d.hasEventListeners("PreProcess")&&!E.no_events?(h=g,x=(p=d).dom,w=m.cloneNode(!0),(S=document.implementation).createHTMLDocument&&(b=S.createHTMLDocument(""),Et.each("BODY"===w.nodeName?w.childNodes:[w],function(e){b.body.appendChild(b.importNode(e,!0))}),w="BODY"!==w.nodeName?b.body.firstChild:b.body,v=x.doc,x.doc=b),y=p,C=_e(_e({},h),{node:w}),y.fire("PreProcess",C),v&&(x.doc=v),w):m),o=Eo((r=T).getInner?n.innerHTML:M.getOuterHTML(n)),r.selection||yo(kt.fromDom(n))?o:Et.trim(o)),B=(i=U,a=O,s=(u=T).selection?_e({forced_root_block:!1},u):u,c=i.parse(a,s),!P(f=c.lastChild)||P(l=f.prev)&&(f.remove(),l.remove()),c);function P(e){return e&&"br"===e.name}return"tree"===T.format?B:(k=I,N=T,_=B,D=im(L,F).serialize(_),N.no_events||!k?D:(A=k,R=_e(_e({},N),{content:D}),A.fire("PostProcess",R).content))},addRules:F.addValidElements,setRules:F.setValidElements,addTempAttr:R(Yh,U,e),getTempAttrs:J(e),getNodeFilters:U.getNodeFilters,getAttributeFilters:U.getAttributeFilters}}function Jh(e,t){var n=Gh(e,t);return{schema:n.schema,addNodeFilter:n.addNodeFilter,addAttributeFilter:n.addAttributeFilter,serialize:n.serialize,addRules:n.addRules,setRules:n.setRules,addTempAttr:n.addTempAttr,getTempAttrs:n.getTempAttrs,getNodeFilters:n.getNodeFilters,getAttributeFilters:n.getAttributeFilters}}function Qh(e,t,n){return r=n=void 0===n?{}:n,bh(e).editor.setContent(t,r);var r}function Zh(e){return ve.from(e).each(function(e){return e.destroy()})}function ev(e,t){var n,r,o,i,a,u,s,c=(n=e,r=U(xv,function(e){return ke(n,e)}),!1!==(o=n.forced_root_block)&&""!==o||r.push("forced_root_block (false only)"),W(r)),l=(s=Et.makeMap(t.plugins," "),W(Ae(Ae([],U(wv,g),!0),H(Sv,function(e){return g(e)?[e+" (moving to premium)"]:[]}),!0))),f=0<l.length,d=0<c.length,m="mobile"===t.theme;function g(e){return ke(s,e)}(f||d||m)&&(i=m?"\n\nThemes:\n- mobile":"",a=f?"\n\nPlugins:\n- "+l.join("\n- "):"",u=d?"\n\nSettings:\n- "+c.join("\n- "):"",console.warn("The following deprecated features are currently enabled, these will be removed in TinyMCE 6.0. See https://www.tiny.cloud/docs/release-notes/6.0-upcoming-changes/ for more information."+i+a+u))}function tv(e){var t=S(e)?e.join(" "):e;return U(A(X(t)?t.split(" "):[],Je),function(e){return 0<e.length})}function nv(e,t){return ke(e.sections(),t)}function rv(e,t){return ue(e,"toolbar_mode").orThunk(function(){return ue(e,"toolbar_drawer").map(function(e){return!1===e?"wrap":e})}).getOr(t)}function ov(e,t,n,r){var o,i,a,u,s,c,l,f,d=tv(n.forced_plugins),m=tv(r.plugins),g=nv(o=t,"mobile")?o.sections().mobile:{},p=g.plugins?tv(g.plugins):m,h=(i=(u=t,s=m,c=p,(a=e)&&(0,f=(l=u).sections(),nv(l,"mobile")&&"mobile"===f.mobile.theme)?U(c,R(T,Av)):a&&nv(u,"mobile")?c:s),[].concat(tv(d)).concat(tv(i)));if(xt.browser.isIE()&&T(h,"rtc"))throw new Error("RTC plugin is not supported on IE 11.");return Et.extend(r,{plugins:h.join(" ")})}function iv(e,t,n,r,o){var i,a,u,s,c,l,f,d,m=e?{mobile:(i=t,a={resize:!1,toolbar_mode:rv(o.mobile||{},"scrolling"),toolbar_sticky:!1},_e(_e(_e({},Rv),a),i?{menubar:!1}:{}))}:{},g=(c=["mobile"],ie(Cv(m,o),function(e,t){return T(c,t)},oe(l={}),oe(f={})),{sections:J((d={t:l,f:f}).t),settings:J(d.f)}),p=Et.extend(n,r,g.settings(),e&&nv(g,"mobile")?function(e){void 0===e&&(e={});var t=ue(g.sections(),"mobile").getOr({});return Et.extend({},e,t)}():{},{validate:!0,external_plugins:(u=r,s=g.settings().external_plugins||{},u&&u.external_plugins?Et.extend({},u.external_plugins,s):s)});return ov(e,g,r,p)}function av(e,t,n){return ve.from(t.settings[n]).filter(e)}function uv(e,t){return t.dom[e]}function sv(e,t){return parseInt(xn(t,e),10)}function cv(e,t,n){var r,o,i,a,u,s,c=kt.fromDom(e.getBody()),l=e.inline?c:kt.fromDom(Dt(c).dom.documentElement),f=(r=e.inline,i=t,a=n,u=(o=l).dom.getBoundingClientRect(),{x:i-(r?u.left+o.dom.clientLeft+Pv(o):0),y:a-(r?u.top+o.dom.clientTop+Bv(o):0)}),d=f.x,m=f.y,g=Tv(s=l),p=Ov(s);return 0<=d&&0<=m&&d<=g&&m<=p}function lv(o){function i(){var e=o.theme;return e&&e.getNotificationManagerImpl?e.getNotificationManagerImpl():{open:t,close:t,reposition:t,getArgs:t};function t(){throw new Error("Theme did not provide a NotificationManager implementation.")}}function a(){return ve.from(c[0])}function u(){0<c.length&&i().reposition(c)}function s(t){z(c,function(e){return e===t}).each(function(e){c.splice(e,1)})}function t(n,e){if(void 0===e&&(e=!0),!o.removed&&(r=(t=o).inline?t.getBody():t.getContentAreaContainer(),ve.from(r).map(kt.fromDom).map(In).getOr(!1)))return e&&o.fire("BeforeOpenNotification",{notification:n}),M(c,function(e){return!((t=i().getArgs(e)).type!==n.type||t.text!==n.text||t.progressBar||t.timeout||n.progressBar||n.timeout);var t}).getOrThunk(function(){o.editorManager.setActive(o);var e=i().open(n,function(){s(e),u(),a().fold(function(){return o.focus()},function(e){return kt.fromDom(e.getEl()).dom.focus()})});return c.push(e),u(),o.fire("OpenNotification",{notification:_e({},e)}),e});var t,r}var n,c=[],e=J(c);return(n=o).on("SkinLoaded",function(){var e=n.getParam("service_message");e&&t({text:e,type:"warning",timeout:0},!1),u()}),n.on("show ResizeEditor ResizeWindow NodeChange",function(){_r.requestAnimationFrame(u)}),n.on("remove",function(){Y(c.slice(),function(e){i().close(e)})}),{open:t,close:function(){a().each(function(e){i().close(e),s(e),u()})},getNotifications:e}}var fv,dv,mv=0,gv=function(e,t){return e&&e.firstChild&&e.firstChild===e.lastChild&&e.firstChild.name===t},pv=Et.makeMap,hv=Et.each,vv=Et.explode,bv=Et.extend,yv=Za.DOM,Cv=(fv=function(e,t){return h(e)&&h(t)?Cv(e,t):t},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<e.length;r++){var o,i=e[r];for(o in i)ke(i,o)&&(n[o]=fv(n[o],i[o]))}return n}),xv="autoresize_on_init,content_editable_state,convert_fonts_to_spans,inline_styles,padd_empty_with_br,block_elements,boolean_attributes,editor_deselector,editor_selector,elements,file_browser_callback_types,filepicker_validator_handler,force_hex_style_colors,force_p_newlines,gecko_spellcheck,images_dataimg_filter,media_scripts,mode,move_caret_before_on_enter_elements,non_empty_elements,self_closing_elements,short_ended_elements,special,spellchecker_select_languages,spellchecker_whitelist,tab_focus,table_responsive_width,text_block_elements,text_inline_elements,toolbar_drawer,types,validate,whitespace_elements,paste_word_valid_elements,paste_retain_style_properties,paste_convert_word_fake_lists".split(","),wv="bbcode,colorpicker,contextmenu,fullpage,legacyoutput,spellchecker,textcolor".split(","),Sv="imagetools,toc".split(","),Ev=dt().deviceType,kv=Ev.isTouch(),Nv=Ev.isPhone(),_v=Ev.isTablet(),Av=["lists","autolink","autosave"],Rv={table_grid:!1,object_resizing:!1,resize:!1},Dv=(dv={},{add:function(e,t){dv[e]=t},get:function(e){return dv[e]||{icons:{}}},has:function(e){return ke(dv,e)}}),Tv=R(uv,"clientWidth"),Ov=R(uv,"clientHeight"),Bv=R(sv,"margin-top"),Pv=R(sv,"margin-left"),Lv=lu.PluginManager,Iv=lu.ThemeManager;function Mv(r){function o(){var e=r.theme;return e&&e.getWindowManagerImpl?e.getWindowManagerImpl():{open:t,openUrl:t,alert:t,confirm:t,close:t,getParams:t,setParams:t};function t(){throw new Error("Theme did not provide a WindowManager implementation.")}}function i(n,r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r?r.apply(n,e):void 0}}function n(t){r.fire("CloseWindow",{dialog:t}),0===(u=U(u,function(e){return e!==t})).length&&r.focus()}function a(e){r.editorManager.setActive(r),fd(r);var t,n=e();return t=n,u.push(t),r.fire("OpenWindow",{dialog:t}),n}var u=[];return r.on("remove",function(){Y(u,function(e){o().close(e)})}),{open:function(e,t){return a(function(){return o().open(e,t,n)})},openUrl:function(e){return a(function(){return o().openUrl(e,n)})},alert:function(e,t,n){var r=o();r.alert(e,i(n||r,t))},confirm:function(e,t,n){var r=o();r.confirm(e,i(n||r,t))},close:function(){ve.from(u[u.length-1]).each(function(e){o().close(e),n(e)})}}}function Fv(e,t){e.notificationManager.open({type:"error",text:t})}function Uv(e,t){e._skinLoaded?Fv(e,t):e.on("SkinLoaded",function(){Fv(e,t)})}function zv(e,t,n){yf(e,t,{message:n}),console.error(n)}function Hv(e,t,n){return n?"Failed to load "+e+": "+n+" from url "+t:"Failed to load "+e+" url: "+t}function jv(e,t,n){zv(e,"PluginLoadError",Hv("plugin",t,n))}function Vv(e){var t,n;e.contentCSS=e.contentCSS.concat(dy(e,(n=(t=e).getParam("content_css"),X(n)?A(n.split(","),Je):S(n)?n:!1===n||t.inline?[]:["default"])),dy(e,Os(e)))}function qv(){function n(e,t){return{status:e,resultUri:t}}function t(e){return e in r}var r={};return{hasBlobUri:t,getResultUri:function(e){var t=r[e];return t?t.resultUri:null},isPending:function(e){return!!t(e)&&1===r[e].status},isUploaded:function(e){return!!t(e)&&2===r[e].status},markPending:function(e){r[e]=n(1,null)},markUploaded:function(e,t){r[e]=n(2,t)},removeFailed:function(e){delete r[e]},destroy:function(){r={}}}}function $v(e){return e+my+++("s"+(new Date).getTime().toString(36)+t()+t()+t());function t(){return Math.round(4294967295*Math.random()).toString(36)}}function Wv(){function e(e){return M(n,e).getOrUndefined()}function i(e){if(!e.blob||!e.base64)throw new Error("blob and base64 representations of the image are required for BlobInfo to be created");var t=e.id||$v("blobid"),n=e.name||t,r=e.blob;return{id:J(t),name:J(n),filename:J(e.filename||n+"."+({"image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/png":"png","image/apng":"apng","image/avif":"avif","image/svg+xml":"svg","image/webp":"webp","image/bmp":"bmp","image/tiff":"tiff"}[r.type.toLowerCase()]||"dat")),blob:J(r),base64:J(e.base64),blobUri:J(e.blobUri||URL.createObjectURL(r)),uri:J(e.uri)}}function t(t){return e(function(e){return e.id()===t})}var n=[];return{create:function(e,t,n,r,o){if(X(e))return i({id:e,name:r,filename:o,blob:t,base64:n});if(h(e))return i(e);throw new Error("Unknown input type")},add:function(e){t(e.id())||n.push(e)},get:t,getByUri:function(t){return e(function(e){return e.blobUri()===t})},getByData:function(t,n){return e(function(e){return e.base64()===t&&e.blob().type===n})},findFirst:e,removeByUri:function(t){n=U(n,function(e){return e.blobUri()!==t||void URL.revokeObjectURL(e.blobUri())})},destroy:function(){Y(n,function(e){URL.revokeObjectURL(e.blobUri())}),n=[]}}}function Kv(u,s){function o(e,r,o,t){var i=new XMLHttpRequest;i.open("POST",s.url),i.withCredentials=s.credentials,i.upload.onprogress=function(e){t(e.loaded/e.total*100)},i.onerror=function(){o("Image upload failed due to a XHR Transport error. Code: "+i.status)},i.onload=function(){var e,t,n;i.status<200||300<=i.status?o("HTTP Error: "+i.status):(e=JSON.parse(i.responseText))&&"string"==typeof e.location?r((t=s.basePath,n=e.location,t?t.replace(/\/$/,"")+"/"+n.replace(/^\//,""):n)):o("Invalid JSON: "+i.responseText)};var n=new FormData;n.append("file",e.blob(),e.filename()),i.send(n)}function c(e,t){return{url:t,blobInfo:e,status:!0}}function l(e,t,n){return{url:"",blobInfo:e,status:!1,error:{message:t,options:n}}}function f(e,t){Et.each(d[e],function(e){e(t)}),delete d[e]}var d={};return!1===y(s.handler)&&(s.handler=o),{upload:function(e,t){return s.url||s.handler!==o?(n=e,r=t,n=Et.grep(e,function(e){return!u.isUploaded(e.blobUri())}),Nr.all(Et.map(n,function(e){return u.isPending(e.blobUri())?(n=e.blobUri(),new Nr(function(e){d[n]=d[n]||[],d[n].push(e)})):(i=e,t=s.handler,a=r,u.markPending(i.blobUri()),new Nr(function(r){var n;try{var o=function(){n&&n.close()};t(i,function(e){o(),u.markUploaded(i.blobUri(),e),f(i.blobUri(),c(i,e)),r(c(i,e))},function(e,t){var n=t||{};o(),u.removeFailed(i.blobUri()),f(i.blobUri(),l(i,e,n)),r(l(i,e,n))},function(t){t<0||100<t||ve.from(n).orThunk(function(){return ve.from(a).map(C)}).each(function(e){(n=e).progressBar.value(t)})})}catch(e){r(l(i,e.message,{}))}}));var i,t,a,n}))):new Nr(function(e){e([])});var n,r}}}function Xv(e){return function(){return e.notificationManager.open({text:e.translate("Image uploading..."),type:"info",timeout:-1,progressBar:!0})}}function Yv(e,t){return Kv(t,{url:e.getParam("images_upload_url","","string"),basePath:e.getParam("images_upload_base_path","","string"),credentials:e.getParam("images_upload_credentials",!1,"boolean"),handler:e.getParam("images_upload_handler",null,"function")})}function Gv(l){function t(t){return function(e){return l.selection?t(e):[]}}function r(e,t,n){for(var r=0;-1!==(r=e.indexOf(t,r))&&(e=e.substring(0,r)+n+e.substr(r+t.length),r+=n.length-t.length+1),-1!==r;);return e}function o(e,t,n){return e=r(e,'src="'+t+'"','src="'+n+'"'+(n===xt.transparentSrc?' data-mce-placeholder="1"':"")),r(e,'data-mce-src="'+t+'"','data-mce-src="'+n+'"')}function f(t,n){Y(l.undoManager.data,function(e){"fragmented"===e.type?e.fragments=A(e.fragments,function(e){return o(e,t,n)}):e.content=o(e.content,t,n)})}function n(n){return u=u||Yv(l,g),v().then(t(function(c){var e=A(c,function(e){return e.blobInfo});return u.upload(e,Xv(l)).then(t(function(e){var s=[],t=A(e,function(e,t){var n,r,o,i,a=c[t].blobInfo,u=c[t].image;return e.status&&l.getParam("images_replace_blob_uris",!0,"boolean")?(m.removeByUri(u.src),hh(l)||(r=u,o=e.url,i=l.convertURL(o,"src"),f(r.src,o),l.$(r).attr({src:l.getParam("images_reuse_filename",!1,"boolean")?o+(-1===o.indexOf("?")?"?":"&")+(new Date).getTime():o,"data-mce-src":i}))):e.error&&(e.error.options.remove&&(f(u.getAttribute("src"),xt.transparentSrc),s.push(u)),n=e.error.message,Uv(l,cu.translate(["Failed to upload image: {0}",n]))),{element:u,status:e.status,uploadUri:e.url,blobInfo:a}});return 0<t.length&&h.fireIfChanged(),0<s.length&&(hh(l)?console.error("Removing images on failed uploads is currently unsupported for RTC"):l.undoManager.transact(function(){Y(s,function(e){l.dom.remove(e),m.removeByUri(e.src)})})),n&&n(t),t}))}))}function e(e){if(_s(l))return n(e)}function i(t){return!1!==j(p,function(e){return e(t)})&&(0!==t.getAttribute("src").indexOf("data:")||l.getParam("images_dataimg_filter",w,"function")(t))}function a(e){return e.replace(/src="(blob:[^"]+)"/g,function(e,n){var t=g.getResultUri(n);if(t)return'src="'+t+'"';var r=(r=m.getByUri(n))||L(l.editorManager.get(),function(e,t){return e||t.editorUpload&&t.editorUpload.blobCache.getByUri(n)},null);return r?'src="data:'+r.blob().type+";base64,"+r.base64()+'"':e})}var u,s,c,d,m=Wv(),g=qv(),p=[],h=(d=iu(null),(c=l).on("change AddUndo",function(e){d.set(_e({},e.level))}),{fireIfChanged:function(){var t=c.undoManager.data;Z(t).filter(function(e){return!fh(d.get(),e)}).each(function(e){c.setDirty(!0),c.fire("change",{level:e,lastLevel:G(t,t.length-2).getOrNull()})})}}),v=function(){return(s=s||qh(g,m)).findAll(l.getBody(),i).then(t(function(e){return e=U(e,function(e){return"string"!=typeof e||void Uv(l,e)}),hh(l)||Y(e,function(e){f(e.image.src,e.blobInfo.blobUri()),e.image.src=e.blobInfo.blobUri(),e.image.removeAttribute("data-mce-src")}),e}))};return l.on("SetContent",function(){(_s(l)?e:v)()}),l.on("RawSaveContent",function(e){e.content=a(e.content)}),l.on("GetContent",function(e){e.source_view||"raw"===e.format||"tree"===e.format||(e.content=a(e.content))}),l.on("PostRender",function(){l.parser.addNodeFilter("img",function(e){Y(e,function(e){var t,n=e.attr("src");m.getByUri(n)||(t=g.getResultUri(n))&&e.attr("src",t)})})}),{blobCache:m,addFilter:function(e){p.push(e)},uploadImages:n,uploadImagesAuto:e,scanForImages:v,destroy:function(){m.destroy(),g.destroy(),s=u=null}}}function Jv(e,t){function m(e){o="string"==typeof e?{name:e,classes:[],attrs:{}}:e;var t,n=py.create(o.name),r=n;return(t=o).classes.length&&py.addClass(r,t.classes.join(" ")),py.setAttribs(r,t.attrs),n}var n,o,r,g=t&&t.schema||ro({}),p=function(n,e,t){var r,o,i,a,u,s,c,l=0<e.length&&e[0],f=l&&l.name,d=(a=f,u="string"!=typeof(i=n)?i.nodeName.toLowerCase():i,!(!(c=(s=g.getElementRule(u))&&s.parentsRequired)||!c.length)&&(a&&-1!==Et.inArray(c,a)?a:c[0]));if(d)f===d?(o=e[0],e=e.slice(1)):o=d;else if(l)o=e[0],e=e.slice(1);else if(!t)return n;return o&&(r=m(o)).appendChild(n),t&&(r||(r=py.create("div")).appendChild(n),Et.each(t,function(e){var t=m(e);r.insertBefore(t,n)})),p(r,e,o&&o.siblings)};return e&&e.length?(n=m(o=e[0]),(r=py.create("div")).appendChild(p(n,e.slice(1),o.siblings)),r):""}function Qv(e){var t,a={classes:[],attrs:{}};return"*"!==(e=a.selector=Et.trim(e))&&(t=e.replace(/(?:([#\.]|::?)([\w\-]+)|(\[)([^\]]+)\]?)/g,function(e,t,n,r,o){switch(t){case"#":a.attrs.id=n;break;case".":a.classes.push(n);break;case":":-1!==Et.inArray("checked disabled enabled read-only required".split(" "),n)&&(a.attrs[n]=n)}var i;return"["!==r||(i=o.match(/([\w\-]+)(?:\=\"([^\"]+))?/))&&(a.attrs[i[1]]=i[2]),""})),a.name=t||"div",a}function Zv(n,e){var r,t,o="",i=(t=n.getParam("preview_styles","font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow"),X(t)?t:"");if(""===i)return"";function a(e){return e.replace(/%(\w+)/g,"")}if("string"==typeof e){if(!(e=n.formatter.get(e)))return;e=e[0]}if("preview"in e){var u=ue(e,"preview");if(fn(u,!1))return"";i=u.getOr(i)}var s,c=e.block||e.inline||"span",l=(s=e.selector)&&"string"==typeof s?(s=(s=s.split(/\s*,\s*/)[0]).replace(/\s*(~\+|~|\+|>)\s*/g,"$1"),Et.map(s.split(/(?:>|\s+(?![^\[\]]+\]))/),function(e){var t=Et.map(e.split(/(?:~\+|~|\+)/),Qv),n=t.pop();return t.length&&(n.siblings=t),n}).reverse()):[],f=l.length?(l[0].name||(l[0].name=c),c=e.selector,Jv(l,n)):Jv([c],n),d=py.select(c,f)[0]||f.firstChild;return gy(e.styles,function(e,t){var n=a(e);n&&py.setStyle(d,t,n)}),gy(e.attributes,function(e,t){var n=a(e);n&&py.setAttrib(d,t,n)}),gy(e.classes,function(e){var t=a(e);py.hasClass(d,t)||py.addClass(d,t)}),n.fire("PreviewFormats"),py.setStyles(f,{position:"absolute",left:-65535}),n.getBody().appendChild(f),r=py.getStyle(n.getBody(),"fontSize",!0),r=/px$/.test(r)?parseInt(r,10):0,gy(i.split(" "),function(e){var t=py.getStyle(d,e,!0);if(!("background-color"===e&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(t)&&(t=py.getStyle(n.getBody(),e,!0),"#ffffff"===py.toHex(t).toLowerCase())||"color"===e&&"#000000"===py.toHex(t).toLowerCase())){if("font-size"===e&&/em|%$/.test(t)){if(0===r)return;t=parseFloat(t)/(/%$/.test(t)?100:1)*r+"px"}"border"===e&&t&&(o+="padding:0 2px;"),o+=e+":"+t+";"}}),n.fire("AfterPreviewFormats"),py.remove(f),o}function eb(c){var e,r,t,n,o,i,a=(n={},(o=function(e,t){e&&(X(e)?(Y(t=!S(t)?[t]:t,function(e){b(e.deep)&&(e.deep=!ml(e)),b(e.split)&&(e.split=!ml(e)||gl(e)),b(e.remove)&&ml(e)&&!gl(e)&&(e.remove="none"),ml(e)&&gl(e)&&(e.mixed=!0,e.block_expand=!0),X(e.classes)&&(e.classes=e.classes.split(/\s+/))}),n[e]=t):ne(e,function(e,t){o(t,e)}))})((r=(e=c).dom,t={valigntop:[{selector:"td,th",styles:{verticalAlign:"top"}}],valignmiddle:[{selector:"td,th",styles:{verticalAlign:"middle"}}],valignbottom:[{selector:"td,th",styles:{verticalAlign:"bottom"}}],alignleft:[{selector:"figure.image",collapsed:!1,classes:"align-left",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"left"},inherit:!1,preview:!1,defaultBlock:"div"},{selector:"img,table,audio,video",collapsed:!1,styles:{float:"left"},preview:"font-family font-size"}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"center"},inherit:!1,preview:"font-family font-size",defaultBlock:"div"},{selector:"figure.image",collapsed:!1,classes:"align-center",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"img,audio,video",collapsed:!1,styles:{display:"block",marginLeft:"auto",marginRight:"auto"},preview:!1},{selector:"table",collapsed:!1,styles:{marginLeft:"auto",marginRight:"auto"},preview:"font-family font-size"}],alignright:[{selector:"figure.image",collapsed:!1,classes:"align-right",ceFalseOverride:!0,preview:"font-family font-size"},{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"right"},inherit:!1,preview:"font-family font-size",defaultBlock:"div"},{selector:"img,table,audio,video",collapsed:!1,styles:{float:"right"},preview:"font-family font-size"}],alignjustify:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,tr,div,ul,ol,li",styles:{textAlign:"justify"},inherit:!1,defaultBlock:"div",preview:"font-family font-size"}],bold:[{inline:"strong",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b",remove:"all",preserve_attributes:["class","style"]}],italic:[{inline:"em",remove:"all",preserve_attributes:["class","style"]},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i",remove:"all",preserve_attributes:["class","style"]}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:!0},{inline:"u",remove:"all",preserve_attributes:["class","style"]}],strikethrough:[{inline:"span",styles:{textDecoration:"line-through"},exact:!0},{inline:"strike",remove:"all",preserve_attributes:["class","style"]},{inline:"s",remove:"all",preserve_attributes:["class","style"]}],forecolor:{inline:"span",styles:{color:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},links:!0,remove_similar:!0,clear_child_styles:!0},fontname:{inline:"span",toggle:!1,styles:{fontFamily:"%value"},clear_child_styles:!0},fontsize:{inline:"span",toggle:!1,styles:{fontSize:"%value"},clear_child_styles:!0},lineheight:{selector:"h1,h2,h3,h4,h5,h6,p,li,td,th,div",defaultBlock:"p",styles:{lineHeight:"%value"}},fontsize_class:{inline:"span",attributes:{class:"%value"}},blockquote:{block:"blockquote",wrapper:!0,remove:"all"},subscript:{inline:"sub"},superscript:{inline:"sup"},code:{inline:"code"},link:{inline:"a",selector:"a",remove:"all",split:!0,deep:!0,onmatch:function(e,t,n){return zn(e)&&e.hasAttribute("href")},onformat:function(n,e,t){Et.each(t,function(e,t){r.setAttrib(n,t,e)})}},lang:{inline:"span",clear_child_styles:!0,remove_similar:!0,attributes:{lang:"%value","data-mce-lang":function(e){var t;return null!==(t=null==e?void 0:e.customValue)&&void 0!==t?t:null}}},removeformat:[{selector:"b,strong,em,i,font,u,strike,s,sub,sup,dfn,code,samp,kbd,var,cite,mark,q,del,ins,small",remove:"all",split:!0,expand:!1,block_expand:!0,deep:!0},{selector:"span",attributes:["style","class"],remove:"empty",split:!0,expand:!1,deep:!0},{selector:"*",attributes:["style","class"],split:!1,expand:!1,deep:!0}]},Et.each("p h1 h2 h3 h4 h5 h6 div address pre dt dd samp".split(/\s/),function(e){t[e]={block:e,remove:"all"}}),t)),o(e.getParam("formats")),{get:function(e){return V(e)?n[e]:n},has:function(e){return ke(n,e)},register:o,unregister:function(e){return e&&n[e]&&delete n[e],n}}),l=iu(null);return function(e){e.addShortcut("meta+b","","Bold"),e.addShortcut("meta+i","","Italic"),e.addShortcut("meta+u","","Underline");for(var t=1;t<=6;t++)e.addShortcut("access+"+t,"",["FormatBlock",!1,"h"+t]);e.addShortcut("access+7","",["FormatBlock",!1,"p"]),e.addShortcut("access+8","",["FormatBlock",!1,"div"]),e.addShortcut("access+9","",["FormatBlock",!1,"address"])}(c),(i=c).on("mouseup keydown",function(e){var t=i,n=e.keyCode,r=t.selection,o=t.getBody();Hg(t,null,!1),8!==n&&46!==n||!r.isCollapsed()||r.getStart().innerHTML!==Cp||Hg(t,Vc(o,r.getStart())),37!==n&&39!==n||Hg(t,Vc(o,r.getStart()))}),{get:a.get,has:a.has,register:a.register,unregister:a.unregister,apply:function(e,t,n){var r=e,o=t,i=n;yh(c).formatter.apply(r,o,i)},remove:function(e,t,n,r){var o=e,i=t,a=n,u=r;yh(c).formatter.remove(o,i,a,u)},toggle:function(e,t,n){var r=e,o=t,i=n;yh(c).formatter.toggle(r,o,i)},match:function(e,t,n,r){return o=e,i=t,a=n,u=r,yh(c).formatter.match(o,i,a,u);var o,i,a,u},closest:function(e){return t=e,yh(c).formatter.closest(t);var t},matchAll:function(e,t){return n=e,r=t,yh(c).formatter.matchAll(n,r);var n,r},matchNode:function(e,t,n,r){return o=e,i=t,a=n,u=r,yh(c).formatter.matchNode(o,i,a,u);var o,i,a,u},canApply:function(e){return t=e,yh(c).formatter.canApply(t);var t},formatChanged:function(e,t,n,r){return o=l,i=e,a=t,u=n,s=r,yh(c).formatter.formatChanged(o,i,a,u,s);var o,i,a,u,s},getCssText:R(Zv,c)}}function tb(e){switch(e.toLowerCase()){case"undo":case"redo":case"mcerepaint":case"mcefocus":return 1;default:return}}function nb(s){var e,n,r,o,i,c=fu(),l=iu(0),f=iu(0),d={data:[],typing:!1,beforeChange:function(){var e=l,t=c;yh(s).undoManager.beforeChange(e,t)},add:function(e,t){return n=d,r=f,o=l,i=c,a=e,u=t,yh(s).undoManager.add(n,r,o,i,a,u);var n,r,o,i,a,u},undo:function(){return e=d,t=l,n=f,yh(s).undoManager.undo(e,t,n);var e,t,n},redo:function(){return e=f,t=d.data,yh(s).undoManager.redo(e,t);var e,t},clear:function(){var e=d,t=f;yh(s).undoManager.clear(e,t)},reset:function(){var e=d;yh(s).undoManager.reset(e)},hasUndo:function(){return e=d,t=f,yh(s).undoManager.hasUndo(e,t);var e,t},hasRedo:function(){return e=d,t=f,yh(s).undoManager.hasRedo(e,t);var e,t},transact:function(e){return t=d,n=l,r=e,yh(s).undoManager.transact(t,n,r);var t,n,r},ignore:function(e){var t=l,n=e;yh(s).undoManager.ignore(t,n)},extra:function(e,t){var n=d,r=f,o=e,i=t;yh(s).undoManager.extra(n,r,o,i)}};return hh(s)||(r=d,o=l,i=iu(!1),(n=s).on("init",function(){r.add()}),n.on("BeforeExecCommand",function(e){tb(e.command)||(gh(r,o),r.beforeChange())}),n.on("ExecCommand",function(e){tb(e.command)||a(e)}),n.on("ObjectResizeStart cut",function(){r.beforeChange()}),n.on("SaveContent ObjectResized blur",a),n.on("dragend",a),n.on("keyup",function(e){var t=e.keyCode;e.isDefaultPrevented()||((33<=t&&t<=36||37<=t&&t<=40||45===t||e.ctrlKey)&&(a(),n.nodeChanged()),46!==t&&8!==t||n.nodeChanged(),i.get()&&r.typing&&!1===fh(uh(n),r.data[0])&&(!1===n.isDirty()&&(n.setDirty(!0),n.fire("change",{level:r.data[0],lastLevel:null})),n.fire("TypingUndo"),i.set(!1),n.nodeChanged()))}),n.on("keydown",function(e){var t,n=e.keyCode;e.isDefaultPrevented()||(33<=n&&n<=36||37<=n&&n<=40||45===n?r.typing&&a(e):(t=e.ctrlKey&&!e.altKey||e.metaKey,!(n<16||20<n)||224===n||91===n||r.typing||t||(r.beforeChange(),mh(r,!0,o),r.add({},e),i.set(!0))))}),n.on("mousedown",function(e){r.typing&&a(e)}),n.on("input",function(e){e.inputType&&("insertReplacementText"===e.inputType||"insertText"===e.inputType&&null===e.data||"insertFromPaste"===e.inputType||"insertFromDrop"===e.inputType)&&a(e)}),n.on("AddUndo Undo Redo ClearUndos",function(e){e.isDefaultPrevented()||n.nodeChanged()})),(e=s).addShortcut("meta+z","","Undo"),e.addShortcut("meta+y,meta+shift+z","","Redo"),d;function a(e){mh(r,!1,o),r.add({},e)}}function rb(e){return"keydown"===e.type||"keyup"===e.type}function ob(e){var t=e.keyCode;return t===Lf.BACKSPACE||t===Lf.DELETE}function ib(e,t){return ze(kt.fromDom(t),e.getParam("inline_boundaries_selector","a[href],code,.mce-annotation","string"))}function ab(e,t,n){var r,o,i=(r=e,o=t,U(Za.DOM.getParents(n.container(),"*",o),r));return ve.from(i[i.length-1])}function ub(e,t){if(!t)return t;var n=t.container(),r=t.offset();return e?Lr(n)?jn(n.nextSibling)?ss(n.nextSibling,0):ss.after(n):Fr(t)?ss(n,r+1):t:Lr(n)?jn(n.previousSibling)?ss(n.previousSibling,n.previousSibling.data.length):ss.before(n):Ur(t)?ss(n,r-1):t}function sb(e){return go(e)||ho(e)}function cb(e,t){return Ve(e,t)?pr(t,sb,(n=e,function(e){return je(n,kt.fromDom(e.dom.parentNode))})):ve.none();var n}function lb(e){var t,n,r;e.dom.isEmpty(e.getBody())&&(e.setContent(""),r=(n=(t=e).getBody()).firstChild&&t.dom.isBlock(n.firstChild)?n.firstChild:n,t.selection.setCursorLocation(r,0))}function fb(e,t){return{from:e,to:t}}function db(e,t){return cb(kt.fromDom(e),kt.fromDom(t.container())).map(function(e){return{block:e,position:t}})}function mb(e){var t,n=z(t=Dn(e),mo).fold(J(t),function(e){return t.slice(0,e)});return Y(n,Ln),n}function gb(e,t){return M(ym(t,e).reverse(),function(e){return Wr(e)}).each(Ln)}function pb(e,t,n,r){if(Wr(n))return hm(n),nf(n.dom);0===U(Lt(r),function(e){return!Wr(e)}).length&&Wr(t)&&qt(r,kt.fromTag("br"));var o=tf(n.dom,ss.before(r.dom));return Y(mb(t),function(e){qt(r,e)}),gb(e,t),o}function hb(e,t,n){if(Wr(n))return Ln(n),Wr(t)&&hm(t),nf(t.dom);var r=rf(n.dom);return Y(mb(t),function(e){Pn(n,e)}),gb(e,t),r}function vb(e,t){Hc(e,t.dom).map(function(e){return e.getNode()}).map(kt.fromDom).filter(Br).each(Ln)}function bb(e,t,n){return vb(!0,t),vb(!1,n),(Ve(o=n,r=t)?(i=ym(r,o),ve.from(i[i.length-1])):ve.none()).fold(R(hb,e,t,n),R(pb,e,t,n));var r,o,i}function yb(e,t,n,r){return t?bb(e,r,n):bb(e,n,r)}function Cb(t,n){var e,r,o,i,a,u,s,c=kt.fromDom(t.getBody()),l=(e=c.dom,r=n,((o=t.selection.getRng()).collapsed?(a=r,u=db(i=e,ss.fromRangeStart(o)),s=u.bind(function(e){return Ql(a,i,e.position).bind(function(e){return db(i,e).map(function(e){return t=i,n=a,Wn((r=e).position.getNode())&&!1===Wr(r.block)?Hc(!1,r.block.dom).bind(function(e){return e.isEqual(r.position)?Ql(n,t,e).bind(function(e){return db(t,e)}):ve.some(r)}).getOr(r):r;var t,n,r})})}),dn(u,s,fb).filter(function(e){return!1===je(e.from.block,e.to.block)&&Ot((n=e).from.block).bind(function(t){return Ot(n.to.block).filter(function(e){return je(t,e)})}).isSome()&&!1===Yn((t=e).from.block.dom)&&!1===Yn(t.to.block.dom);var t,n})):ve.none()).bind(function(e){return yb(c,n,e.from.block,e.to.block)}));return l.each(function(e){t.selection.setRng(e.toRange())}),l.isSome()}function xb(e,t){var n=kt.fromDom(t),r=R(je,e);return gr(n,bo,r).isSome()}function wb(e){var n,r,o,t,i,a,u,s,c,l,f=kt.fromDom(e.getBody()),d=e.selection.getRng();return a=d,c=tf((i=f).dom,ss.fromRangeStart(a)).isNone(),l=ef(i.dom,ss.fromRangeEnd(a)).isNone(),!xb(u=i,(s=a).startContainer)&&!xb(u,s.endContainer)&&c&&l?((t=e).setContent(""),t.selection.setCursorLocation(),!0):(n=f,r=e.selection,o=r.getRng(),dn(cb(n,kt.fromDom(o.startContainer)),cb(n,kt.fromDom(o.endContainer)),function(e,t){return!1===je(e,t)&&(o.deleteContents(),yb(n,!0,e,t).each(function(e){r.setRng(e.toRange())}),!0)}).getOr(!1))}function Sb(e,t){return!e.selection.isCollapsed()&&wb(e)}function Eb(e,t,n,r,o){return ve.from(t._selectionOverrides.showCaret(e,n,r,o))}function kb(e,t){var n,r;return e.fire("BeforeObjectSelected",{target:t}).isDefaultPrevented()?ve.none():ve.some(((r=(n=t).ownerDocument.createRange()).selectNode(n),r))}function Nb(e,t,n){var r=tc(1,e.getBody(),t),o=ss.fromRangeStart(r),i=o.getNode();if(Ec(i))return Eb(1,e,i,!o.isAtEnd(),!1);var a=o.getNode(!0);if(Ec(a))return Eb(1,e,a,!1,!1);var u=e.dom.getParent(o.getNode(),function(e){return wy(e)||xy(e)});return Ec(u)?Eb(1,e,u,!1,n):ve.none()}function _b(e,t,n){return t.collapsed?Nb(e,t,n).getOr(t):t}function Ab(e){return rp(e)||Zg(e)}function Rb(e){return op(e)||ep(e)}function Db(n,r,e,t,o,i){var a,u;return Eb(t,n,i.getNode(!o),o,!0).each(function(e){var t;r.collapsed?(t=r.cloneRange(),o?t.setEnd(e.startContainer,e.startOffset):t.setStart(e.endContainer,e.endOffset),t.deleteContents()):r.deleteContents(),n.selection.setRng(e)}),a=n.dom,jn(u=e)&&0===u.data.length&&a.remove(u),!0}function Tb(e,t){var n=e.selection.getRng();if(!jn(n.commonAncestorContainer))return!1;var r=t?uc.Forwards:uc.Backwards,o=Ic(e.getBody()),i=R(ic,t?o.next:o.prev),a=t?Ab:Rb,u=rc(r,e.getBody(),n),s=ub(t,i(u));if(!s||!ac(u,s))return!1;if(a(s))return Db(e,n,u.getNode(),r,t,s);var c=i(s);return!!(c&&a(c)&&ac(s,c))&&Db(e,n,u.getNode(),r,t,c)}function Ob(l,f,d){return Ql(f,l,d).bind(function(e){return s=e.getNode(),bo(kt.fromDom(s))||ho(kt.fromDom(s))||(o=l,u=e,nc(!(i=f),a=d).fold(function(){return nc(i,u).fold(D,c)},c))?ve.none():f&&Yn(e.getNode())||!1===f&&Yn(e.getNode(!0))?(t=l,n=d,r=e.getNode(!1===f),cb(kt.fromDom(t),kt.fromDom(n.getNode())).map(function(e){return Wr(e)?Sy.remove(e.dom):Sy.moveToElement(r)}).orThunk(function(){return ve.some(Sy.moveToElement(r))})):f&&op(d)||!1===f&&rp(d)?ve.some(Sy.moveToPosition(e)):ve.none();var t,n,r,o,i,a,u,s;function c(e){return Or(kt.fromDom(e))&&!Js(a,u,o)}})}function Bb(e,t){return ve.from(vf(e.getBody(),t))}function Pb(m,g){var e=m.selection.getNode();return Bb(m,e).filter(Yn).fold(function(){return s=m.getBody(),l=tc((c=g)?1:-1,s,m.selection.getRng()),f=ss.fromRangeStart(l),d=kt.fromDom(s),(!1===c&&op(f)?ve.some(Sy.remove(f.getNode(!0))):c&&rp(f)?ve.some(Sy.remove(f.getNode())):!1===c&&rp(f)&&_m(d,f)?cp(d,f).map(function(e){return Sy.remove(e.getNode())}):c&&op(f)&&Nm(d,f)?lp(d,f).map(function(e){return Sy.remove(e.getNode())}):(r=s,e=c,a=(o=f).getNode(!1===(i=e)),u=i?"after":"before",zn(a)&&a.getAttribute("data-mce-caret")===u?(n=o.getNode(!1===(t=e)),(t&&Yn(n.nextSibling)?ve.some(Sy.moveToElement(n.nextSibling)):!1===t&&Yn(n.previousSibling)?ve.some(Sy.moveToElement(n.previousSibling)):ve.none()).fold(function(){return Ob(r,e,o)},ve.some)):Ob(r,e,o).bind(function(e){return t=r,n=o,e.fold(function(e){return ve.some(Sy.remove(e))},function(e){return ve.some(Sy.moveToElement(e))},function(e){return Js(n,e,t)?ve.none():ve.some(Sy.moveToPosition(e))});var t,n}))).exists(function(e){return e.fold(function(e){return o._selectionOverrides.hideFakeCaret(),Qm(o,i,kt.fromDom(e)),!0},(r=i=g,function(e){var t=r?ss.before(e):ss.after(e);return n.selection.setRng(t.toRange()),!0}),(t=n=o=m,function(e){return t.selection.setRng(e.toRange()),!0}));var t,n,r,o,i});var r,e,o,t,n,i,a,u,s,c,l,f,d},w)}function Lb(e,t){var n=e.selection.getNode();return!(!Yn(n)||Gn(n))&&Bb(e,n.parentNode).filter(Yn).fold(function(){return Y(bu(kt.fromDom(e.getBody()),".mce-offscreen-selection"),Ln),Qm(e,t,kt.fromDom(e.selection.getNode())),lb(e),!0},w)}function Ib(e){var t,n=e.dom,r=e.selection,o=vf(e.getBody(),r.getNode());return Xn(o)&&n.isBlock(o)&&n.isEmpty(o)&&(t=n.create("br",{"data-mce-bogus":"1"}),n.setHTML(o,""),o.appendChild(t),r.setRng(ss.before(t).toRange())),!0}function Mb(e,t){return(e.selection.isCollapsed()?Pb:Lb)(e,t)}function Fb(e,t){return!!e.selection.isCollapsed()&&(n=e,r=t,o=ss.fromRangeStart(n.selection.getRng()),Ql(r,n.getBody(),o).filter(function(e){return(r?Jg:Qg)(e)}).bind(function(e){return ve.from(Qs(r?0:-1,e))}).exists(function(e){return n.selection.select(e),!0}));var n,r,o}function Ub(e){return Ey(e)&&e.data[0]===wo}function zb(e){return Ey(e)&&e.data[e.data.length-1]===wo}function Hb(e){return e.ownerDocument.createTextNode(wo)}function jb(e,t){return(e?function(e){if(Ey(e.previousSibling))return zb(e.previousSibling)||e.previousSibling.appendData(wo),e.previousSibling;if(Ey(e))return Ub(e)||e.insertData(0,wo),e;var t=Hb(e);return e.parentNode.insertBefore(t,e),t}:function(e){if(Ey(e.nextSibling))return Ub(e.nextSibling)||e.nextSibling.insertData(0,wo),e.nextSibling;if(Ey(e))return zb(e)||e.appendData(wo),e;var t=Hb(e);return e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t),t})(t)}function Vb(e,t){return jn(e.container())?jb(t,e.container()):jb(t,e.getNode())}function qb(e,t){var n=t.get();return n&&e.container()===n&&Lr(n)}function $b(n,e){return e.fold(function(e){yc(n.get());var t=ky(e);return n.set(t),ve.some(ss(t,t.length-1))},function(e){return nf(e).map(function(e){if(qb(e,n))return ss(n.get(),1);yc(n.get());var t=Vb(e,!0);return n.set(t),ss(t,1)})},function(e){return rf(e).map(function(e){if(qb(e,n))return ss(n.get(),n.get().length-1);yc(n.get());var t=Vb(e,!1);return n.set(t),ss(t,t.length-1)})},function(e){yc(n.get());var t=Ny(e);return n.set(t),ve.some(ss(t,1))})}function Wb(e,t){for(var n=0;n<e.length;n++){var r=e[n].apply(null,t);if(r.isSome())return r}return ve.none()}function Kb(e,t){return Gs(t,e)||e}function Xb(e,t,n){var r=yy(n),o=Kb(t,r.container());return ab(e,o,r).fold(function(){return ef(o,r).bind(R(ab,e,o)).map(function(e){return _y.before(e)})},ve.none)}function Yb(e,t){return null===Vc(e,t)}function Gb(e,t,n){return ab(e,t,n).filter(R(Yb,t))}function Jb(e,t,n){var r=Cy(n);return Gb(e,t,r).bind(function(e){return tf(e,r).isNone()?ve.some(_y.start(e)):ve.none()})}function Qb(e,t,n){var r=yy(n);return Gb(e,t,r).bind(function(e){return ef(e,r).isNone()?ve.some(_y.end(e)):ve.none()})}function Zb(e,t,n){var r=Cy(n),o=Kb(t,r.container());return ab(e,o,r).fold(function(){return tf(o,r).bind(R(ab,e,o)).map(function(e){return _y.after(e)})},ve.none)}function ey(e){return!1===(t=Ay(e),"rtl"===Za.DOM.getStyle(t,"direction",!0)||(n=t.textContent,by.test(n)));var t,n}function ty(e,t,n){return Wb([Xb,Jb,Qb,Zb],[e,t,n]).filter(ey)}function ny(e){return e.fold(J("before"),J("start"),J("end"),J("after"))}function ry(e){return e.fold(_y.before,_y.before,_y.after,_y.after)}function oy(e){return e.fold(_y.start,_y.start,_y.end,_y.end)}function iy(a,e,u,t,n,s){return dn(ab(e,u,t),ab(e,u,n),function(e,t){return e!==t&&(r=t,o=Gs(e,n=u),i=Gs(r,n),o&&o===i)?_y.after(a?e:t):s;var n,r,o,i}).getOr(s)}function ay(e,r){return e.fold(w,function(e){return n=r,!(ny(t=e)===ny(n)&&Ay(t)===Ay(n));var t,n})}function uy(e,t){return e?t.fold(i(ve.some,_y.start),ve.none,i(ve.some,_y.after),ve.none):t.fold(ve.none,i(ve.some,_y.before),ve.none,i(ve.some,_y.end))}function sy(e,a,u,s){var t=ub(e,s),c=ty(a,u,t);return ty(a,u,t).bind(R(uy,e)).orThunk(function(){return n=a,r=u,o=c,i=ub(t=e,s),Ql(t,r,i).map(R(ub,t)).fold(function(){return o.map(ry)},function(e){return ty(n,r,e).map(R(iy,t,n,r,i,e)).filter(R(ay,o))}).filter(ey);var t,n,r,o,i})}function cy(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r=window.console;r&&(r.error||r.log).apply(r,Ae([e],t,!1))}var ly,fy,dy=function(t,e){var n=t.editorManager.baseURL+"/skins/content",r="content"+t.editorManager.suffix+".css",o=!0===t.inline;return A(e,function(e){return/^[a-z0-9\-]+$/i.test(e)&&!o?n+"/"+e+"/"+r:t.documentBaseURI.toAbsolute(e)})},my=0,gy=Et.each,py=Za.DOM,hy=[9,27,Lf.HOME,Lf.END,19,20,44,144,145,33,34,45,16,17,18,91,92,93,Lf.DOWN,Lf.UP,Lf.LEFT,Lf.RIGHT].concat(xt.browser.isFirefox()?[224]:[]),vy="data-mce-placeholder",by=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,yy=R(ub,!0),Cy=R(ub,!1),xy=Xn,wy=Yn,Sy=or([{remove:["element"]},{moveToElement:["element"]},{moveToPosition:["position"]}]),Ey=jn,ky=R(jb,!0),Ny=R(jb,!1),_y=or([{before:["element"]},{start:["element"]},{end:["element"]},{after:["element"]}]),Ay=function(e){return e.fold(u,u,u,u)};function Ry(e,t,n){var r=e?1:-1;return t.setRng(ss(n.container(),n.offset()+r).toRange()),t.getSel().modify("move",e?"forward":"backward","word"),!0}function Dy(e,t){return e===uc.Backwards?q(t):t}function Ty(e,t,n,r){for(var o,i,a,u,s=Ic(n),c=r,l=[];c;){var f=(a=s,u=c,t===uc.Forwards?a.next(u):a.prev(u));if(!f)break;if(Wn(f.getNode(!1)))return t===uc.Forwards?{positions:Dy(t,l).concat([f]),breakType:ly.Br,breakAt:ve.some(f)}:{positions:Dy(t,l),breakType:ly.Br,breakAt:ve.some(f)};if(f.isVisible()){if(e(c,f)){var d=(o=c,Wn((i=f).getNode(t===uc.Forwards))?ly.Br:!1===Js(o,i)?ly.Block:ly.Wrap);return{positions:Dy(t,l),breakType:d,breakAt:ve.some(f)}}l.push(f),c=f}else c=f}return{positions:Dy(t,l),breakType:ly.Eol,breakAt:ve.none()}}function Oy(n,r,o,e){return r(o,e).breakAt.map(function(e){var t=r(o,e).positions;return n===uc.Backwards?t.concat(e):[e].concat(t)}).getOr([])}function By(e,i){return L(e,function(e,o){return e.fold(function(){return ve.some(o)},function(r){return dn(Q(r.getClientRects()),Q(o.getClientRects()),function(e,t){var n=Math.abs(i-e.left);return Math.abs(i-t.left)<=n?o:r}).or(e)})},ve.none())}function Py(t,e){return Q(e.getClientRects()).bind(function(e){return By(t,e.left)})}function Ly(n){function e(e){return A(e,function(e){var t=Au(e);return t.node=n,t})}if(zn(n))return e(n.getClientRects());if(jn(n)){var t=n.ownerDocument.createRange();return t.setStart(n,0),t.setEnd(n,n.data.length),e(t.getClientRects())}}function Iy(e){return H(e,Ly)}R(sy,!1),R(sy,!0),(fy=ly={})[fy.Br=0]="Br",fy[fy.Block=1]="Block",fy[fy.Wrap=2]="Wrap",fy[fy.Eol=3]="Eol";var My,Fy,Uy=R(Ty,ss.isAbove,-1),zy=R(Ty,ss.isBelow,1),Hy=R(Oy,-1,Uy),jy=R(Oy,1,zy);function Vy(o,i,a,e,u,t){function n(e){var t=Iy([e]);-1===o&&(t=t.reverse());for(var n=0;n<t.length;n++){var r=t[n];if(!a(r,l)){if(0<c.length&&i(r,pe(c))&&s++,r.line=s,u(r))return!0;c.push(r)}}}var s=0,c=[],l=pe(t.getClientRects());if(!l)return c;var r=t.getNode();return n(r),function(e,t,n,r){for(;r=Ys(r,e,Vr,t);)if(n(r))return}(o,e,n,r),c}function qy(t){return function(e){return e.line>t}}function $y(t){return function(e){return e.line===t}}function Wy(e,t){return Math.abs(e.left-t)}function Ky(e,t){return Math.abs(e.right-t)}function Xy(e,t){return e>=t.left&&e<=t.right}function Yy(e,t){return e>=t.top&&e<=t.bottom}function Gy(e,o,i){return void 0===i&&(i=w),me(e,function(e,t){if(Xy(o,t))return i(t)?t:e;if(Xy(o,e))return i(e)?e:t;var n=Math.min(Wy(e,o),Ky(e,o)),r=Math.min(Wy(t,o),Ky(t,o));return r===n&&se(t,"node")&&zC(t.node)||r<n?t:e})}function Jy(e,t,n,r,o){var i=HC(r,e,Vr,t,!o);do{if(!i||n(i))return}while(i=HC(i,e,Vr,t))}function Qy(e,t,n){function r(e){return!cn(e.node)&&!Jn(e.node)}var o,i,a,u=Iy(U(xe(e.getElementsByTagName("*")),Ks)),s=U(u,R(Yy,n));if((a=Gy(s,t,r))&&((a=Gy(function(e,r,t){function n(t,e){var n=U(Iy([e]),function(e){return!t(e,r)});return o=o.concat(n),0===n.length}void 0===t&&(t=!0);var o=[];return o.push(r),Jy(My.Up,e,R(n,Tu),r.node,t),Jy(My.Down,e,R(n,Ou),r.node,t),o}(e,a,r(a)),t,r))&&Ks(a.node)))return{node:(o=a).node,before:Wy(o,i=t)<Ky(o,i)};return null}function Zy(e,t){e.selection.setRng(t),td(e,e.selection.getRng())}function e0(e,t,n){return ve.some(_b(e,t,n))}function t0(e,t,n,r,o,i){var a=t===uc.Forwards,u=Ic(e.getBody()),s=R(ic,a?u.next:u.prev),c=a?r:o;if(!n.collapsed){var l=Pu(n);if(i(l))return Eb(t,e,l,t===uc.Backwards,!1)}var f=rc(t,e.getBody(),n);if(c(f))return kb(e,f.getNode(!a));var d=ub(a,s(f)),m=Hr(n);if(!d)return m?ve.some(n):ve.none();if(c(d))return Eb(t,e,d.getNode(!a),a,!1);var g=s(d);return g&&c(g)&&ac(d,g)?Eb(t,e,g.getNode(!a),a,!1):m?e0(e,d.toRange(),!1):ve.none()}function n0(t,e,n,r,o,i){var a=rc(e,t.getBody(),n),u=pe(a.getClientRects()),s=e===My.Down;if(!u)return ve.none();var c,l=U((s?UC:FC)(t.getBody(),qy(1),a),$y(1)),f=u.left,d=Gy(l,f);if(d&&i(d.node)){var m=Math.abs(f-d.left),g=Math.abs(f-d.right);return Eb(e,t,d.node,m<g,!1)}if(c=r(a)?a.getNode():o(a)?a.getNode(!0):Pu(n)){var p=function(e,t,n,r){function o(e){return pe(e.getClientRects())}var i,a,u,s=Ic(t),c=[],l=0,f=1===e?(i=s.next,a=Ou,u=Tu,ss.after(r)):(i=s.prev,a=Tu,u=Ou,ss.before(r)),d=o(f);do{if(f.isVisible()){var m=o(f);if(!u(m,d)){0<c.length&&a(m,pe(c))&&l++;var g=Au(m);if(g.position=f,g.line=l,n(g))return c;c.push(g)}}}while(f=i(f));return c}(e,t.getBody(),qy(1),c),h=Gy(U(p,$y(1)),f);if(h)return e0(t,h.position.toRange(),!1);if(h=pe(U(p,$y(0))))return e0(t,h.position.toRange(),!1)}return 0===l.length?jC(t,s).filter(s?o:r).map(function(e){return _b(t,e.toRange(),!1)}):ve.none()}function r0(t,e,n){return jC(t,e).filter(n).exists(function(e){return t.selection.setRng(e.toRange()),!0})}function o0(e,t){var n=e.dom.createRng();n.setStart(t.container(),t.offset()),n.setEnd(t.container(),t.offset()),e.selection.setRng(n)}function i0(e,t){e?t.setAttribute("data-mce-selected","inline-boundary"):t.removeAttribute("data-mce-selected")}function a0(t,e,n){return $b(e,n).map(function(e){return o0(t,e),n})}function u0(e,t,n){return!!Is(e)&&(o=t,i=n,a=(r=e).getBody(),u=ss.fromRangeStart(r.selection.getRng()),sy(i,R(ib,r),a,u).bind(function(e){return a0(r,o,e)}).isSome());var r,o,i,a,u}function s0(e,t,n){return!!Is(t)&&(r=e,i=(o=t).selection.getRng(),a=r?ss.fromRangeEnd(i):ss.fromRangeStart(i),!!y(o.selection.getSel().modify)&&(r&&Fr(a)?Ry(!0,o.selection,a):!(r||!Ur(a))&&Ry(!1,o.selection,a)));var r,o,i,a}function c0(g){var p=iu(null),h=R(ib,g);return g.on("NodeChange",function(e){var n,r,o,t,i,a,u,s,c,l,f,d,m;!Is(g)||xt.browser.isIE()&&e.initial||(i=h,a=g.dom,u=e.parents,Y($(s=U(A(bu(kt.fromDom(a.getRoot()),'*[data-mce-selected="inline-boundary"]'),function(e){return e.dom}),i),c=U(u,i)),R(i0,!1)),Y($(c,s),R(i0,!0)),f=p,(l=g).selection.isCollapsed()&&!0!==l.composing&&f.get()&&(d=ss.fromRangeStart(l.selection.getRng()),ss.isTextPosition(d)&&!1===(Fr(m=d)||Ur(m))&&(o0(l,Vs(f.get(),d)),f.set(null))),n=h,r=g,o=p,t=e.parents,r.selection.isCollapsed()&&Y(U(t,n),function(e){var t=ss.fromRangeStart(r.selection.getRng());ty(n,r.getBody(),t).bind(function(e){return a0(r,o,e)})}))}),p}function l0(n,t,r){if(Is(n)){var e=jC(n,t).getOrThunk(function(){var e=n.selection.getRng();return t?ss.fromRangeEnd(e):ss.fromRangeStart(e)});return ty(R(ib,n),n.getBody(),e).exists(function(e){var t=ry(e);return $b(r,t).exists(function(e){return o0(n,e),!0})})}return!1}function f0(t,n){return function(e){return $b(n,e).exists(function(e){return o0(t,e),!0})}}function d0(r,o,i,a){var u=r.getBody(),s=R(ib,r);r.undoManager.ignore(function(){var e,t,n;r.selection.setRng((e=i,t=a,(n=document.createRange()).setStart(e.container(),e.offset()),n.setEnd(t.container(),t.offset()),n)),r.execCommand("Delete"),ty(s,u,ss.fromRangeStart(r.selection.getRng())).map(oy).map(f0(r,o))}),r.nodeChanged()}function m0(e,t,n){if(e.selection.isCollapsed()&&Is(e)){var r=ss.fromRangeStart(e.selection.getRng());return o=t,a=n,u=r,s=(i=e).getBody(),c=Gs(u.container(),s)||s,l=R(ib,i),(f=ty(l,c,u)).bind(function(e){return a?e.fold(J(ve.some(oy(e))),ve.none,J(ve.some(ry(e))),ve.none):e.fold(ve.none,J(ve.some(ry(e))),ve.none,J(ve.some(oy(e))))}).map(f0(i,o)).getOrThunk(function(){var t=zc(a,c,u),e=t.bind(function(e){return ty(l,c,e)});return dn(f,e,function(){return ab(l,c,u).exists(function(e){return!!dn(nf(o=e),rf(o),function(e,t){var n=ub(!0,e),r=ub(!1,t);return ef(o,n).forall(function(e){return e.isEqual(r)})}).getOr(!0)&&(Qm(i,a,kt.fromDom(e)),!0);var o})}).orThunk(function(){return e.bind(function(e){return t.map(function(e){return a?d0(i,o,u,e):d0(i,o,e,u),!0})})}).getOr(!1)})}var i,o,a,u,s,c,l,f;return!1}function g0(e){return 1===zt(e)}function p0(g,p){var t,e=kt.fromDom(g.getBody()),n=kt.fromDom(g.selection.getStart()),h=U(z(t=ym(n,e),mo).fold(J(t),function(e){return t.slice(0,e)}),g0);return Z(h).exists(function(e){var t,n,r,o,i,a,u,s,c,l=ss.fromRangeStart(g.selection.getRng()),f=p,d=l,m=e.dom;return!(!dn(nf(m),rf(m),function(e,t){var n=ub(!0,e),r=ub(!1,t),o=ub(!1,d);return f?ef(m,o).exists(function(e){return e.isEqual(r)&&d.isEqual(n)}):tf(m,o).exists(function(e){return e.isEqual(n)&&d.isEqual(r)})}).getOr(!0)||jc((t=e).dom)&&Mg(t.dom)||(n=p,o=e,0===(c=A(U(h,R(Wg,r=g)),function(e){return e.dom})).length?Qm(r,n,o):(a=o.dom,s=Vg(c,(u=Ug(!1)).dom),qt(kt.fromDom(a),u),Ln(kt.fromDom(a)),i=ss(s,0),r.selection.setRng(i.toRange())),0))})}function h0(e,t){return!!e.selection.isCollapsed()&&p0(e,t)}function v0(e,t,n){return e._selectionOverrides.hideFakeCaret(),Qm(e,t,kt.fromDom(n)),!0}function b0(e,t){return e.selection.isCollapsed()?(i=e,u=(a=t)?Zg:ep,s=a?uc.Forwards:uc.Backwards,c=rc(s,i.getBody(),i.selection.getRng()),u(c)?v0(i,a,c.getNode(!a)):ve.from(ub(a,c)).filter(function(e){return u(e)&&ac(c,e)}).exists(function(e){return v0(i,a,e.getNode(!a))})):(r=t,o=(n=e).selection.getNode(),!!Jn(o)&&v0(n,r,o));var n,r,o,i,a,u,s,c}function y0(e){var t=parseInt(e,10);return isNaN(t)?0:t}function C0(e,t){return(e||"table"===Nt(t)?"margin":"padding")+("rtl"===xn(t,"direction")?"-right":"-left")}function x0(e){var n,t=$C(e);return!e.mode.isReadOnly()&&(1<t.length||(n=e,j(t,function(e){var t=wn(e,C0(Ts(n),e)).map(y0).getOr(0);return"false"!==n.dom.getContentEditable(e.dom)&&0<t})))}function w0(e){return po(e)||ho(e)}function S0(e,s){var c=e.dom,t=e.selection,n=e.formatter,r=e.getParam("indentation","40px","string"),l=/[a-z%]+$/i.exec(r)[0],f=parseInt(r,10),d=Ts(e),o=ks(e);e.queryCommandState("InsertUnorderedList")||e.queryCommandState("InsertOrderedList")||""!==o||c.getParent(t.getNode(),c.isBlock)||n.apply("div"),Y($C(e),function(e){var t,n=c,r=s,o=f,i=l,a=e.dom,u=C0(d,kt.fromDom(a));"outdent"===r?(t=Math.max(0,y0(a.style[u])-o),n.setStyle(a,u,t?t+i:"")):(t=y0(a.style[u])+o+i,n.setStyle(a,u,t))})}function E0(e,t){if(e.selection.isCollapsed()&&x0(e)){var n=e.dom,r=e.selection.getRng(),o=ss.fromRangeStart(r),i=n.getParent(r.startContainer,n.isBlock);if(null!==i&&ip(kt.fromDom(i),o))return S0(e,"outdent"),!0}return!1}function k0(e,t){e.getDoc().execCommand(t,!1,null)}function N0(e){return void 0===e.touches||1!==e.touches.length?ve.none():ve.some(e.touches[0])}function _0(e,t){return ke(e,t.nodeName)}function A0(e){var t,n,r,o=e.dom,i=e.selection,a=e.schema,u=a.getBlockElements(),s=i.getStart(),c=e.getBody(),l=ks(e);if(s&&zn(s)&&l){var f=c.nodeName.toLowerCase();if(a.isValidChild(f,l.toLowerCase())&&(d=u,m=c,g=s,!F(bm(kt.fromDom(g),kt.fromDom(m)),function(e){return _0(d,e.dom)}))){for(var d,m,g,p,h,v=i.getRng(),b=v.startContainer,y=v.startOffset,C=v.endContainer,x=v.endOffset,w=yd(e),s=c.firstChild;s;)p=u,jn(h=s)||zn(h)&&!_0(p,h)&&!Jc(h)?function(e,t){if(jn(t)){if(0===t.nodeValue.length)return 1;if(/^\s+$/.test(t.nodeValue)&&(!t.nextSibling||_0(e,t.nextSibling)))return 1}}(u,s)?(s=(n=s).nextSibling,o.remove(n)):(t||(t=o.create(l,Ns(e)),s.parentNode.insertBefore(t,s),r=!0),s=(n=s).nextSibling,t.appendChild(n)):(t=null,s=s.nextSibling);r&&w&&(v.setStart(b,y),v.setEnd(C,x),i.setRng(v),e.nodeChanged())}}}function R0(e,t){t.hasAttribute("data-mce-caret")&&(zr(t),e.selection.setRng(e.selection.getRng()),e.selection.scrollIntoView(t))}function D0(e,t){var n=vr(kt.fromDom(e.getBody()),"*[data-mce-caret]").map(function(e){return e.dom}).getOrNull();if(n)return"compositionstart"===t.type?(t.preventDefault(),t.stopPropagation(),void R0(e,n)):void(Mr(n)&&(R0(e,n),e.undoManager.add()))}function T0(e,t,n){var r,o,i,a=Ic(e.getBody()),u=R(ic,1===t?a.next:a.prev);!n.collapsed||""===ks(e)||(r=e.dom.getParent(n.startContainer,"PRE"))&&(u(ss.fromRangeStart(n))||(i=e.dom.create(ks(e)),(!xt.ie||11<=xt.ie)&&(i.innerHTML='<br data-mce-bogus="1">'),o=i,1===t?e.$(r).after(o):e.$(r).before(o),e.selection.select(o,!0),e.selection.collapse()))}function O0(t,e){return n=t,r=e?uc.Forwards:uc.Backwards,o=n.selection.getRng(),t0(n,r,o,rp,op,WC).orThunk(function(){return T0(n,r,o),ve.none()}).exists(function(e){return Zy(t,e),!0});var n,r,o}function B0(t,e){return r=e?1:-1,o=(n=t).selection.getRng(),n0(n,r,o,function(e){return rp(e)||tp(e)},function(e){return op(e)||np(e)},WC).orThunk(function(){return T0(n,r,o),ve.none()}).exists(function(e){return Zy(t,e),!0});var n,r,o}function P0(e,t){return r0(e,t,t?op:rp)}function L0(e){return T(["figcaption"],Nt(e))}function I0(e){var t=document.createRange();return t.setStartBefore(e.dom),t.setEndBefore(e.dom),t}function M0(e,t,n){(n?Pn:Wt)(e,t)}function F0(h,v){var b=kt.fromDom(h.getBody()),y=ss.fromRangeStart(h.selection.getRng()),C=ks(h),x=Ns(h),e=y,t=R(je,b);return pr(kt.fromDom(e.container()),mo,t).filter(L0).exists(function(){if(d=b,m=y,v?(p=d.dom,zy(p,m).breakAt.isNone()):(g=d.dom,Uy(g,m).breakAt.isNone())){var e=(t=b,r=x,o=v,""===(n=C)?(l=o,M0(t,f=kt.fromTag("br"),l),I0(f)):(i=t,a=o,u=r,s=kt.fromTag(n),c=kt.fromTag("br"),hn(s,u),Pn(s,c),M0(i,s,a),I0(c)));return h.selection.setRng(e),!0}var t,n,r,o,i,a,u,s,c,l,f,d,m,g,p;return!1})}function U0(e,t){return!!e.selection.isCollapsed()&&F0(e,t)}function z0(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return function(){return e.apply(null,t)}}function H0(e,t){return M((n=t,H(A(e,function(e){return _e({shiftKey:!1,altKey:!1,ctrlKey:!1,metaKey:!1,keyCode:0,action:te},e)}),function(e){return n.keyCode===e.keyCode&&n.shiftKey===e.shiftKey&&n.altKey===e.altKey&&n.ctrlKey===e.ctrlKey&&n.metaKey===e.metaKey?[e]:[]})),function(e){return e.action()});var n}function j0(t,e){var n=e?uc.Forwards:uc.Backwards,r=t.selection.getRng();return t0(t,n,r,Zg,ep,Jn).exists(function(e){return Zy(t,e),!0})}function V0(t,e){var n=e?1:-1,r=t.selection.getRng();return n0(t,n,r,Zg,ep,Jn).exists(function(e){return Zy(t,e),!0})}function q0(e,t){return r0(e,t,t?ep:Zg)}function $0(e,t,n,r,o){var i,a=bu(kt.fromDom(n),"td,th,caption").map(function(e){return e.dom}),u=U((i=e,H(a,function(e){var t,n={left:(t=Au(e.getBoundingClientRect())).left- -1,top:t.top- -1,right:t.right+-2,bottom:t.bottom+-2,width:t.width+-1,height:t.height+-1};return[{x:n.left,y:i(n),cell:e},{x:n.right,y:i(n),cell:e}]})),function(e){return t(e,o)}),s=r,c=o;return L(u,function(e,r){return e.fold(function(){return ve.some(r)},function(e){var t=Math.sqrt(Math.abs(e.x-s)+Math.abs(e.y-c)),n=Math.sqrt(Math.abs(r.x-s)+Math.abs(r.y-c));return ve.some(n<t?r:e)})},ve.none()).map(function(e){return e.cell})}function W0(e,t,n){var r,o,i=e(t,n);return i.breakType===ly.Wrap&&0===i.positions.length||!Wn(n.getNode())&&i.breakType===ly.Br&&1===i.positions.length?(r=e,o=t,!i.breakAt.exists(function(e){return r(o,e).breakAt.isSome()})):i.breakAt.isNone()}function K0(t,e,n,r){var o,i,a,u=t.selection.getRng(),s=e?1:-1;return!(!Ws()||(o=e,i=n,a=ss.fromRangeStart(u),!Hc(!o,i).exists(function(e){return e.isEqual(a)}))||(Eb(s,t,n,!e,!1).each(function(e){Zy(t,e)}),0))}function X0(u,s,c){var e,t,n=(e=!!s,t=c.getNode(e),zn(t)&&"TABLE"===t.nodeName?ve.some(t):ve.none()),r=!1===s;n.fold(function(){return Zy(u,c.toRange())},function(a){return Hc(r,u.getBody()).filter(function(e){return e.isEqual(c)}).fold(function(){return Zy(u,c.toRange())},function(e){var n,r,o=s,i=a,t=c;(r=ks(n=u))?n.undoManager.transact(function(){var e=kt.fromTag(r);hn(e,Ns(n)),Pn(e,kt.fromTag("br")),(o?$t:qt)(kt.fromDom(i),e);var t=n.dom.createRng();t.setStart(e.dom,0),t.setEnd(e.dom,0),Zy(n,t)}):Zy(n,t.toRange())})})}function Y0(e,t,n,r){var o,i,a,u,s,c,l,f,d,m,g=e.selection.getRng(),p=ss.fromRangeStart(g),h=e.getBody();if(t||!YC(r,p))return!(!t||!GC(r,p))&&(o=h,d=i=n,X0(e,t,v=Z((m=a=p).getClientRects()).bind(function(e){return XC(d,e.left,e.top)}).bind(function(e){return Py(nf(t=e).map(function(e){return[e].concat(zy(t,e).positions)}).getOr([]),m);var t}).orThunk(function(){return Q(a.getClientRects()).bind(function(e){return By(jy(o,ss.after(i)),e.left)})}).getOr(ss.after(i))),!0);var v=(u=h,l=s=n,Q((f=c=p).getClientRects()).bind(function(e){return KC(l,e.left,e.top)}).bind(function(e){return Py(rf(t=e).map(function(e){return Uy(t,e).positions.concat(e)}).getOr([]),f);var t}).orThunk(function(){return Q(c.getClientRects()).bind(function(e){return By(Hy(u,ss.before(s)),e.left)})}).getOr(ss.before(s)));return X0(e,t,v),!0}function G0(n,r,o){return ve.from(n.dom.getParent(n.selection.getNode(),"td,th")).bind(function(t){return ve.from(n.dom.getParent(t,"table")).map(function(e){return o(n,r,e,t)})}).getOr(!1)}function J0(e,t){return G0(e,t,K0)}function Q0(e,t){return G0(e,t,Y0)}function Z0(e,t){var n,r,o=t,i=e.dom,a=e.schema.getMoveCaretBeforeOnEnterElements();if(t){!/^(LI|DT|DD)$/.test(t.nodeName)||(r=function(e){for(;e;){if(1===e.nodeType||3===e.nodeType&&e.data&&/[\r\n\s]/.test(e.data))return e;e=e.nextSibling}}(t.firstChild))&&/^(UL|OL|DL)$/.test(r.nodeName)&&t.insertBefore(i.doc.createTextNode(xo),t.firstChild);var u=i.createRng();if(t.normalize(),t.hasChildNodes()){for(var s=new Rr(t,t);n=s.current();){if(jn(n)){u.setStart(n,0),u.setEnd(n,0);break}if(a[n.nodeName.toLowerCase()]){u.setStartBefore(n),u.setEndBefore(n);break}o=n,n=s.next()}n||(u.setStart(o,0),u.setEnd(o,0))}else Wn(t)?t.nextSibling&&i.isBlock(t.nextSibling)?(u.setStartBefore(t),u.setEndBefore(t)):(u.setStartAfter(t),u.setEndAfter(t)):(u.setStart(t,0),u.setEnd(t,0));e.selection.setRng(u),td(e,u)}}function eC(e){return ve.from(e.dom.getParent(e.selection.getStart(!0),e.dom.isBlock))}function tC(e,t){return e&&e.parentNode&&e.parentNode.nodeName===t}function nC(e){return e&&/^(OL|UL|LI)$/.test(e.nodeName)}function rC(e){var t=e.parentNode;return/^(LI|DT|DD)$/.test(t.nodeName)?t:e}function oC(e,t,n){for(var r=e[n?"firstChild":"lastChild"];r&&!zn(r);)r=r[n?"nextSibling":"previousSibling"];return r===t}function iC(e){e.innerHTML='<br data-mce-bogus="1">'}function aC(e,t){return e.nodeName===t||e.previousSibling&&e.previousSibling.nodeName===t}function uC(e,t){return t&&e.isBlock(t)&&!/^(TD|TH|CAPTION|FORM)$/.test(t.nodeName)&&!/^(fixed|absolute)/i.test(t.style.position)&&"true"!==e.getContentEditable(t)}function sC(e,t,n){return!1===jn(t)?n:e?1===n&&t.data.charAt(n-1)===wo?0:n:n===t.data.length-1&&t.data.charAt(n)===wo?t.data.length:n}function cC(e,t){for(var n,r=e.getRoot(),o=t;o!==r&&"false"!==e.getContentEditable(o);)"true"===e.getContentEditable(o)&&(n=o),o=o.parentNode;return o!==r?n:r}function lC(e,t){var n=ks(e);n&&n.toLowerCase()===t.tagName.toLowerCase()&&function(e,o,t){var i=e.dom;ve.from(t.style).map(i.parseStyle).each(function(e){var t=Sn(kt.fromDom(o)),n=_e(_e({},t),e);i.setStyles(o,n)}),dn(ve.from(t.class).map(function(e){return e.split(/\s+/)}),ve.from(o.className).map(function(e){return U(e.split(/\s+/),function(e){return""!==e})}),function(t,e){var n=U(e,function(e){return!T(t,e)}),r=Ae(Ae([],t,!0),n,!0);i.setAttrib(o,"class",r.join(" "))});var n=["style","class"],r=ae(t,function(e,t){return!T(n,t)});i.setAttribs(o,r)}(e,t,Ns(e))}function fC(a,e){function t(e){var t,n=m,r=l.getTextInlineElements(),o=e||"TABLE"===C||"HR"===C?c.create(e||p):b.cloneNode(!1),i=o;if(!1===a.getParam("keep_styles",!0))c.setAttrib(o,"style",null),c.setAttrib(o,"class",null);else for(;r[n.nodeName]&&(jc(n)||Jc(n)||(t=n.cloneNode(!1),c.setAttrib(t,"id",""),o.hasChildNodes()?t.appendChild(o.firstChild):i=t,o.appendChild(t))),(n=n.parentNode)&&n!==F;);return lC(a,o),iC(i),o}function n(e){var t,n,r=sC(e,m,g);if(!jn(m)||!(e?0<r:r<m.nodeValue.length)){if(m.parentNode===b&&s&&!e)return 1;if(e&&zn(m)&&m===b.firstChild)return 1;if(aC(m,"TABLE")||aC(m,"HR"))return s&&!e||!s&&e;var o=new Rr(m,b);for(jn(m)&&(e&&0===r?o.prev():e||r!==m.nodeValue.length||o.next());t=o.current();){if(zn(t)){if(!t.getAttribute("data-mce-bogus")&&(n=t.nodeName.toLowerCase(),f[n]&&"br"!==n))return}else if(jn(t)&&!qr(t.nodeValue))return;e?o.prev():o.next()}return 1}}function r(){u=/^(H[1-6]|PRE|FIGURE)$/.test(C)&&"HGROUP"!==x?t(p):t(),a.getParam("end_container_on_empty_block",!1)&&uC(c,y)&&c.isEmpty(b)?u=c.split(y,b):c.insertAfter(u,b),Z0(a,u)}var o,u,i,s,c=a.dom,l=a.schema,f=l.getNonEmptyElements(),d=a.selection.getRng();Tf(c,d).each(function(e){d.setStart(e.startContainer,e.startOffset),d.setEnd(e.endContainer,e.endOffset)});var m=d.startContainer,g=d.startOffset,p=ks(a),h=!(!e||!e.shiftKey),v=!(!e||!e.ctrlKey);zn(m)&&m.hasChildNodes()&&(s=g>m.childNodes.length-1,m=m.childNodes[Math.min(g,m.childNodes.length-1)]||m,g=s&&jn(m)?m.nodeValue.length:0);var b,y,C,x,w,S,p,E,k,N,_,A,R,D,T,O,B,P,L,I,M,F=cC(c,m);F&&((p&&!h||!p&&h)&&(m=function(e,t,n,r){var o,i,a,u,s,c,l=p||"P",f=e.dom,d=cC(f,n),m=f.getParent(n,f.isBlock);if(!m||!uC(f,m)){if(s=((m=m||d)===e.getBody()||(c=m)&&/^(TD|TH|CAPTION)$/.test(c.nodeName)?m:m.parentNode).nodeName.toLowerCase(),!m.hasChildNodes())return lC(e,o=f.create(l)),m.appendChild(o),t.setStart(o,0),t.setEnd(o,0),o;for(a=n;a.parentNode!==m;)a=a.parentNode;for(;a&&!f.isBlock(a);)a=(i=a).previousSibling;if(i&&e.schema.isValidChild(s,l.toLowerCase())){for(lC(e,o=f.create(l)),i.parentNode.insertBefore(o,i),a=i;a&&!f.isBlock(a);)u=a.nextSibling,o.appendChild(a),a=u;t.setStart(n,r),t.setEnd(n,r)}}return n}(a,d,m,g)),y=(b=c.getParent(m,c.isBlock))?c.getParent(b.parentNode,c.isBlock):null,C=b?b.nodeName.toUpperCase():"","LI"!==(x=y?y.nodeName.toUpperCase():"")||v||(y=(b=y).parentNode,C=x),/^(LI|DT|DD)$/.test(C)&&c.isEmpty(b)?(k=t,N=y,_=b,A=p,I=(E=a).dom,M=E.selection.getRng(),N!==E.getBody()&&(D=(A=nC(R=N)&&nC(R.parentNode)?"LI":A)?k(A):I.create("BR"),oC(N,_,!0)&&oC(N,_,!1)?tC(N,"LI")?(T=rC(N),I.insertAfter(D,T),(null===(L=(P=N).parentNode)||void 0===L?void 0:L.firstChild)===P?I.remove(T):I.remove(N)):I.replace(D,N):(oC(N,_,!0)?tC(N,"LI")?(I.insertAfter(D,rC(N)),D.appendChild(I.doc.createTextNode(" ")),D.appendChild(N)):N.parentNode.insertBefore(D,N):oC(N,_,!1)?I.insertAfter(D,rC(N)):(N=rC(N),(O=M.cloneRange()).setStartAfter(_),O.setEndAfter(N),B=O.extractContents(),"LI"===A&&(B.firstChild&&"LI"===B.firstChild.nodeName)?(D=B.firstChild,I.insertAfter(B,N)):(I.insertAfter(B,N),I.insertAfter(D,N))),I.remove(_)),Z0(E,D))):p&&b===a.getBody()||(p=p||"P",Pr(b)?(u=zr(b),c.isEmpty(b)&&iC(b),lC(a,u),Z0(a,u)):n()?r():n(!0)?(u=b.parentNode.insertBefore(t(),b),Z0(a,aC(b,"HR")?u:b)):((S=(w=d).cloneRange()).setStart(w.startContainer,sC(!0,w.startContainer,w.startOffset)),S.setEnd(w.endContainer,sC(!1,w.endContainer,w.endOffset)),(o=S.cloneRange()).setEndAfter(b),i=o.extractContents(),Y(Vu(kt.fromDom(i),_n),function(e){var t=e.dom;t.nodeValue=Eo(t.nodeValue)}),function(e){for(;jn(e)&&(e.nodeValue=e.nodeValue.replace(/^[\r\n]+/,"")),e=e.firstChild;);}(i),u=i.firstChild,c.insertAfter(i,b),function(e,t){var n,r,o=u,i=[];if(o){for(;o=o.firstChild;){if(e.isBlock(o))return;zn(o)&&!t[o.nodeName.toLowerCase()]&&i.push(o)}for(n=i.length;n--;)!(o=i[n]).hasChildNodes()||o.firstChild===o.lastChild&&""===o.firstChild.nodeValue?e.remove(o):(r=o)&&"A"===r.nodeName&&e.isEmpty(r)&&e.remove(o)}}(c,f),function(e,t){t.normalize();var n=t.lastChild;n&&!/^(left|right)$/gi.test(e.getStyle(n,"float",!0))||e.add(t,"br")}(c,b),c.isEmpty(b)&&iC(b),u.normalize(),c.isEmpty(u)?(c.remove(u),r()):(lC(a,u),Z0(a,u))),c.setAttrib(u,"id",""),a.fire("NewBlock",{newBlock:u})))}function dC(e,t,n){var r=e.dom.createRng();n?(r.setStartBefore(t),r.setEndBefore(t)):(r.setStartAfter(t),r.setEndAfter(t)),e.selection.setRng(r),td(e,r)}function mC(e,t){var n=kt.fromTag("br");qt(kt.fromDom(t),n),e.undoManager.add()}function gC(e,t){JC(e.getBody(),t)||$t(kt.fromDom(t),kt.fromTag("br"));var n=kt.fromTag("br");$t(kt.fromDom(t),n),dC(e,n.dom,!1),e.undoManager.add()}function pC(e){return e&&"A"===e.nodeName&&"href"in e}function hC(e){return e.fold(D,pC,pC,D)}function vC(e,t){t.fold(te,R(mC,e),R(gC,e),te)}function bC(e,t){var n,r,o,i=(r=R(ib,n=e),o=ss.fromRangeStart(n.selection.getRng()),ty(r,n.getBody(),o).filter(hC));i.isSome()?i.each(R(vC,e)):function(e,t){var n,r,o=e.selection,i=e.dom,a=o.getRng();Tf(i,a).each(function(e){a.setStart(e.startContainer,e.startOffset),a.setEnd(e.endContainer,e.endOffset)});var u,s=a.startOffset,c=a.startContainer;1===c.nodeType&&c.hasChildNodes()&&(u=s>c.childNodes.length-1,c=c.childNodes[Math.min(s,c.childNodes.length-1)]||c,s=u&&3===c.nodeType?c.nodeValue.length:0);var l=i.getParent(c,i.isBlock),f=l?i.getParent(l.parentNode,i.isBlock):null,d=f?f.nodeName.toUpperCase():"",m=!(!t||!t.ctrlKey);"LI"!==d||m||(l=f),c&&3===c.nodeType&&s>=c.nodeValue.length&&!function(e){for(var t,n=new Rr(c,l),r=e.getNonEmptyElements();t=n.next();)if(r[t.nodeName.toLowerCase()]||0<t.length)return 1}(e.schema)&&(n=i.create("br"),a.insertNode(n),a.setStartAfter(n),a.setEndAfter(n),r=!0),n=i.create("br"),ls(i,a,n),dC(e,n,r),e.undoManager.add()}(e,t)}function yC(e,t){return eC(e).filter(function(e){return 0<t.length&&ze(kt.fromDom(e),t)}).isSome()}function CC(e,t){return yC(e,e.getParam("no_newline_selector",""))}function xC(n){return function(e,t){return""===ks(e)===n}}function wC(n){return function(e,t){return eC(e).filter(function(e){return ho(kt.fromDom(e))}).isSome()===n}}function SC(n,r){return function(e,t){return eC(e).fold(J(""),function(e){return e.nodeName.toUpperCase()})===n.toUpperCase()===r}}function EC(e){return SC("pre",e)}function kC(n){return function(e,t){return e.getParam("br_in_pre",!0)===n}}function NC(e,t){return yC(e,e.getParam("br_newline_selector",".mce-toc h2,figcaption,caption"))}function _C(e,t){return t}function AC(e){var t=ks(e),n=function(e,t){for(var n,r=e.getRoot(),o=t;o!==r&&"false"!==e.getContentEditable(o);)"true"===e.getContentEditable(o)&&(n=o),o=o.parentNode;return o!==r?n:r}(e.dom,e.selection.getStart());return n&&e.schema.isValidChild(n.nodeName,t||"P")}function RC(e,t){return function(n,r){return L(e,function(e,t){return e&&t(n,r)},!0)?ve.some(t):ve.none()}}function DC(e,t){var n,r;n=e,r=t,Wb([RC([CC],QC.none()),RC([SC("summary",!0)],QC.br()),RC([EC(!0),kC(!1),_C],QC.br()),RC([EC(!0),kC(!1)],QC.block()),RC([EC(!0),kC(!0),_C],QC.block()),RC([EC(!0),kC(!0)],QC.br()),RC([wC(!0),_C],QC.br()),RC([wC(!0)],QC.block()),RC([xC(!0),_C,AC],QC.block()),RC([xC(!0)],QC.br()),RC([NC],QC.br()),RC([xC(!1),_C],QC.br()),RC([AC],QC.block())],[n,!(!r||!r.shiftKey)]).getOr(QC.none()).fold(function(){bC(e,t)},function(){fC(e,t)},te)}function TC(e){return e.stopImmediatePropagation()}function OC(e){return e.keyCode===Lf.PAGE_UP||e.keyCode===Lf.PAGE_DOWN}function BC(e,t,n){n&&!e.get()?t.on("NodeChange",TC,!0):!n&&e.get()&&t.off("NodeChange",TC),e.set(n)}function PC(n,r){var e=r.container(),t=r.offset();return jn(e)?(e.insertData(t,n),ve.some(ss(e,t+n.length))):oc(r).map(function(e){var t=kt.fromText(n);return(r.isAtEnd()?$t:qt)(e,t),ss(t.dom,n.length)})}function LC(i,a){return function(e){return r=i,(!Om(o=e)&&(n=o,tf((t=r).dom,n).isNone()||ef(t.dom,n).isNone()||ip(t,n)||ap(t,n)||_m(t,n)||Nm(t,n)||Dm(r,o)||Tm(r,o))?t1:n1)(a);var t,n,r,o}}function IC(e){var t,n,r=ss.fromRangeStart(e.selection.getRng()),o=kt.fromDom(e.getBody());if(e.selection.isCollapsed()){var i=R(ib,e),a=ss.fromRangeStart(e.selection.getRng());return ty(i,e.getBody(),a).bind((n=o,function(e){return e.fold(function(e){return tf(n.dom,ss.before(e))},function(e){return nf(e)},function(e){return rf(e)},function(e){return ef(n.dom,ss.after(e))})})).bind(LC(o,r)).exists((t=e,function(e){return t.selection.setRng(e.toRange()),t.nodeChanged(),!0}))}return!1}function MC(e){var o,i,a,u,s,t,n,r,c,l,f,d,m,g,p=c0(e);return e.on("keyup compositionstart",R(D0,e)),g=p,(m=e).on("keydown",function(e){var t,n,r,o;!1===e.isDefaultPrevented()&&(t=m,n=g,r=e,o=dt().os,H0([{keyCode:Lf.RIGHT,action:z0(O0,t,!0)},{keyCode:Lf.LEFT,action:z0(O0,t,!1)},{keyCode:Lf.UP,action:z0(B0,t,!1)},{keyCode:Lf.DOWN,action:z0(B0,t,!0)},{keyCode:Lf.RIGHT,action:z0(J0,t,!0)},{keyCode:Lf.LEFT,action:z0(J0,t,!1)},{keyCode:Lf.UP,action:z0(Q0,t,!1)},{keyCode:Lf.DOWN,action:z0(Q0,t,!0)},{keyCode:Lf.RIGHT,action:z0(j0,t,!0)},{keyCode:Lf.LEFT,action:z0(j0,t,!1)},{keyCode:Lf.UP,action:z0(V0,t,!1)},{keyCode:Lf.DOWN,action:z0(V0,t,!0)},{keyCode:Lf.RIGHT,action:z0(u0,t,n,!0)},{keyCode:Lf.LEFT,action:z0(u0,t,n,!1)},{keyCode:Lf.RIGHT,ctrlKey:!o.isOSX(),altKey:o.isOSX(),action:z0(VC,t,n)},{keyCode:Lf.LEFT,ctrlKey:!o.isOSX(),altKey:o.isOSX(),action:z0(qC,t,n)},{keyCode:Lf.UP,action:z0(U0,t,!1)},{keyCode:Lf.DOWN,action:z0(U0,t,!0)}],r).each(function(e){r.preventDefault()}))}),d=p,(f=e).on("keydown",function(e){var t,n,r;!1===e.isDefaultPrevented()&&(n=d,r=e,H0([{keyCode:Lf.BACKSPACE,action:z0(E0,t=f,!1)},{keyCode:Lf.BACKSPACE,action:z0(Mb,t,!1)},{keyCode:Lf.DELETE,action:z0(Mb,t,!0)},{keyCode:Lf.BACKSPACE,action:z0(Tb,t,!1)},{keyCode:Lf.DELETE,action:z0(Tb,t,!0)},{keyCode:Lf.BACKSPACE,action:z0(m0,t,n,!1)},{keyCode:Lf.DELETE,action:z0(m0,t,n,!0)},{keyCode:Lf.BACKSPACE,action:z0(yg,t,!1)},{keyCode:Lf.DELETE,action:z0(yg,t,!0)},{keyCode:Lf.BACKSPACE,action:z0(Fb,t,!1)},{keyCode:Lf.DELETE,action:z0(Fb,t,!0)},{keyCode:Lf.BACKSPACE,action:z0(b0,t,!1)},{keyCode:Lf.DELETE,action:z0(b0,t,!0)},{keyCode:Lf.BACKSPACE,action:z0(Sb,t,!1)},{keyCode:Lf.DELETE,action:z0(Sb,t,!0)},{keyCode:Lf.BACKSPACE,action:z0(Cb,t,!1)},{keyCode:Lf.DELETE,action:z0(Cb,t,!0)},{keyCode:Lf.BACKSPACE,action:z0(h0,t,!1)},{keyCode:Lf.DELETE,action:z0(h0,t,!0)}],r).each(function(e){r.preventDefault()}))}),f.on("keyup",function(e){var t,n;!1===e.isDefaultPrevented()&&(n=e,H0([{keyCode:Lf.BACKSPACE,action:z0(Ib,t=f)},{keyCode:Lf.DELETE,action:z0(Ib,t)}],n))}),(l=e).on("keydown",function(e){var t,n,r;e.keyCode===Lf.ENTER&&(t=l,(n=e).isDefaultPrevented()||(n.preventDefault(),(r=t.undoManager).typing&&(r.typing=!1,r.add()),t.undoManager.transact(function(){!1===t.selection.isCollapsed()&&t.execCommand("Delete"),DC(t,n)})))}),(c=e).on("keydown",function(e){var t;!1===e.isDefaultPrevented()&&(t=e,H0([{keyCode:Lf.SPACEBAR,action:z0(IC,c)}],t).each(function(e){t.preventDefault()}))}),n=t=e,r=du(function(){n.composing||Um(n)},0),ZC.isIE()&&(n.on("keypress",function(e){r.throttle()}),n.on("remove",function(e){r.cancel()})),t.on("input",function(e){!1===e.isComposing&&Um(t)}),s=p,(u=e).on("keydown",function(e){var t,n,r;!1===e.isDefaultPrevented()&&(n=s,r=e,H0([{keyCode:Lf.END,action:z0(P0,t=u,!0)},{keyCode:Lf.HOME,action:z0(P0,t,!1)},{keyCode:Lf.END,action:z0(q0,t,!0)},{keyCode:Lf.HOME,action:z0(q0,t,!1)},{keyCode:Lf.END,action:z0(l0,t,!0,n)},{keyCode:Lf.HOME,action:z0(l0,t,!1,n)}],r).each(function(e){r.preventDefault()}))}),o=e,i=p,e1.os.isOSX()||(a=iu(!1),o.on("keydown",function(e){OC(e)&&BC(a,o,!0)}),o.on("keyup",function(e){var t,n,r;!1===e.isDefaultPrevented()&&(r=e,H0([{keyCode:Lf.PAGE_UP,action:z0(l0,t=o,!1,n=i)},{keyCode:Lf.PAGE_DOWN,action:z0(l0,t,!0,n)}],r)),OC(e)&&a.get()&&(BC(a,o,!1),o.nodeChanged())})),p}(Fy=My=My||{})[Fy.Up=-1]="Up",Fy[Fy.Down=1]="Down";var FC=R(Vy,My.Up,Tu,Ou),UC=R(Vy,My.Down,Ou,Tu),zC=Yn,HC=Ys,jC=function(e,t){var n=e.selection.getRng(),r=e.getBody();if(t){var o=ss.fromRangeEnd(n),i=zy(r,o);return Z(i.positions)}return o=ss.fromRangeStart(n),Q((i=Uy(r,o)).positions)},VC=R(s0,!0),qC=R(s0,!1),$C=function(e){return U(A(e.selection.getSelectedBlocks(),kt.fromDom),function(e){return!w0(e)&&!Ot(e).exists(w0)&&pr(e,function(e){return Xn(e.dom)||Yn(e.dom)}).exists(function(e){return Xn(e.dom)})})},WC=Yn,KC=R($0,function(e){return e.bottom},function(e,t){return e.y<t}),XC=R($0,function(e){return e.top},function(e,t){return e.y>t}),YC=R(W0,Uy),GC=R(W0,zy),JC=function(e,t){return n=ss.after(t),!!Wn(n.getNode())||ef(e,ss.after(t)).map(function(e){return Wn(e.getNode())}).getOr(!1);var n},QC=or([{br:[]},{block:[]},{none:[]}]),ZC=dt().browser,e1=dt(),t1=R(PC,xo),n1=R(PC," "),r1=(o1.prototype.nodeChanged=function(e){var t,n,r,o=this.editor.selection;this.editor.initialized&&o&&!this.editor.getParam("disable_nodechange")&&!this.editor.mode.isReadOnly()&&(r=this.editor.getBody(),(t=o.getStart(!0)||r).ownerDocument===this.editor.getDoc()&&this.editor.dom.isChildOf(t,r)||(t=r),n=[],this.editor.dom.getParent(t,function(e){return e===r||void n.push(e)}),(e=e||{}).element=t,e.parents=n,this.editor.fire("NodeChange",e))},o1.prototype.isSameElementPath=function(e){var t,n=this.editor.$(e).parentsUntil(this.editor.getBody()).add(e);if(n.length===this.lastPath.length){for(t=n.length;0<=t&&n[t]===this.lastPath[t];t--);if(-1===t)return this.lastPath=n,!0}return this.lastPath=n,!1},o1);function o1(r){var o;this.lastPath=[],this.editor=r;var t=this;"onselectionchange"in r.getDoc()||r.on("NodeChange click mouseup keyup focus",function(e){var t=r.selection.getRng(),n={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset};"nodechange"!==e.type&&kf(n,o)||r.fire("SelectionChange"),o=n}),r.on("contextmenu",function(){r.fire("SelectionChange")}),r.on("SelectionChange",function(){var e=r.selection.getStart(!0);!e||!xt.range&&r.selection.isCollapsed()||Bl(r)&&!t.isSameElementPath(e)&&r.dom.isChildOf(e,r.getBody())&&r.nodeChanged({selectionChange:!0})}),r.on("mouseup",function(e){!e.isDefaultPrevented()&&Bl(r)&&("IMG"===r.selection.getNode().nodeName?_r.setEditorTimeout(r,function(){r.nodeChanged()}):r.nodeChanged())})}function i1(e){return zn(e)&&go(kt.fromDom(e))}function a1(e){var t=e.getBoundingClientRect(),n=e.ownerDocument,r=n.documentElement,o=n.defaultView;return{top:t.top+o.pageYOffset-r.clientTop,left:t.left+o.pageXOffset-r.clientLeft}}function u1(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function s1(e,S){var E=_r.throttle(function(e,t){S._selectionOverrides.hideFakeCaret(),S.selection.placeCaretAt(e,t)},0);return S.on("remove",E.stop),function(w){return e.on(function(e){var t,n,r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,b,y,C,x=Math.max(Math.abs(w.screenX-e.screenX),Math.abs(w.screenY-e.screenY));if(!e.dragging&&10<x){if(S.fire("dragstart",{target:e.element}).isDefaultPrevented())return;e.dragging=!0,S.focus()}e.dragging&&(d=e,t={pageX:(p=w,h=(g=S).inline?a1(g.getBody()):{left:0,top:0},C=(y=g).getBody(),v=y.inline?{left:C.scrollLeft,top:C.scrollTop}:{left:0,top:0},(m={pageX:(b=function(e,t){if(t.target.ownerDocument===e.getDoc())return{left:t.pageX,top:t.pageY};var n,r,o,i,a,u=a1(e.getContentAreaContainer()),s=(r=(n=e).getBody(),o=n.getDoc().documentElement,i={left:r.scrollLeft,top:r.scrollTop},a={left:r.scrollLeft||o.scrollLeft,top:r.scrollTop||o.scrollTop},n.inline?i:a);return{left:t.pageX-u.left+s.left,top:t.pageY-u.top+s.top}}(g,p)).left-h.left+v.left,pageY:b.top-h.top+v.top}).pageX-d.relX),pageY:m.pageY+5},l=e.ghost,f=S.getBody(),l.parentNode!==f&&f.appendChild(l),n=e.ghost,o=e.width,i=e.height,a=e.maxX,u=e.maxY,c=s=0,n.style.left=(r=t).pageX+"px",n.style.top=r.pageY+"px",u<r.pageY+i&&(c=r.pageY+i-u),n.style.width=o-(s=a<r.pageX+o?r.pageX+o-a:s)+"px",n.style.height=i-c+"px",E(w.clientX,w.clientY))})}}function c1(e){function t(e){var t,n,r,o,i,a;0===e.button&&(t=M(c.dom.getParents(e.target),function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return function(e){for(var t=0;t<n.length;t++)if(n[t](e))return!0;return!1}}(P1,L1)).getOr(null),i=c.getBody(),P1(a=t)&&a!==i&&(n=c.dom.getPos(t),r=c.getBody(),o=c.getDoc().documentElement,u.set({element:t,dragging:!1,screenX:e.screenX,screenY:e.screenY,maxX:(c.inline?r.scrollWidth:o.offsetWidth)-2,maxY:(c.inline?r.scrollHeight:o.offsetHeight)-2,relX:e.pageX-n.x,relY:e.pageY-n.y,width:t.offsetWidth,height:t.offsetHeight,ghost:function(e,t,n){var r=c.dom,o=e.cloneNode(!0);r.setStyles(o,{width:t,height:n}),r.setAttrib(o,"data-mce-selected",null);var i=r.create("div",{class:"mce-drag-container","data-mce-bogus":"all",unselectable:"on",contenteditable:"false"});return r.setStyles(i,{position:"absolute",opacity:.5,overflow:"hidden",border:0,padding:0,margin:0,width:t,height:n}),r.setStyles(o,{margin:0,boxSizing:"border-box"}),i.appendChild(o),i}(t,t.offsetWidth,t.offsetHeight)})))}function n(u){i.on(function(e){var t,n,r,o,i,a;e.dragging&&((o=3===(a=(r=s).selection.getSel().getRangeAt(0).startContainer).nodeType?a.parentNode:a)===(i=e.element)||r.dom.isChildOf(o,i)||P1(o)||((n=e.element.cloneNode(!0)).removeAttribute("data-mce-selected"),t=n,s.fire("drop",{clientX:u.clientX,clientY:u.clientY}).isDefaultPrevented()||s.undoManager.transact(function(){u1(e.element),s.insertContent(s.dom.getOuterHTML(t)),s._selectionOverrides.hideFakeCaret()})),s.fire("dragend"))}),I1(i)}var r,o,i,s,u,c,a=fu(),l=Za.DOM,f=document,d=s1(u=a,c=e),m=(r=i=a,function(){r.on(function(e){e.dragging&&o.fire("dragend")}),I1(r)});(o=s=e).on("mousedown",t),e.on("mousemove",d),e.on("mouseup",n),l.bind(f,"mousemove",d),l.bind(f,"mouseup",m),e.on("remove",function(){l.unbind(f,"mousemove",d),l.unbind(f,"mouseup",m)}),e.on("keydown",function(e){e.keyCode===Lf.ESC&&m()})}function l1(e){var n,i;function a(e){var t;e.isDefaultPrevented()||(t=e.dataTransfer)&&(T(t.types,"Files")||0<t.files.length)&&(e.preventDefault(),"drop"===e.type&&Uv(i,"Dropped file type is not supported"))}function u(e){gd(i,e.target)&&a(e)}function t(){var t=Za.DOM,n=i.dom,r=document,o=i.inline?i.getBody():i.getDoc(),e=["drop","dragover"];Y(e,function(e){t.bind(r,e,u),n.bind(o,e,a)}),i.on("remove",function(){Y(e,function(e){t.unbind(r,e,u),n.unbind(o,e,a)})})}c1(e),(n=e).on("drop",function(e){var t=void 0!==e.clientX?n.getDoc().elementFromPoint(e.clientX,e.clientY):null;!P1(t)&&"false"!==n.dom.getContentEditableParent(t)||e.preventDefault()}),e.getParam("block_unsupported_drop",!0,"boolean")&&(i=e).on("init",function(){_r.setEditorTimeout(i,t,0)})}function f1(e,t){return vf(e.getBody(),t)}function d1(l){function f(e){return e!==x&&(F1(e)||Jn(e))&&y.isChildOf(e,x)}function c(e){return rp(e)||op(e)||Zg(e)||ep(e)}function d(e){e&&b.setRng(e)}function m(e,t,n,r){return void 0===r&&(r=!0),l.fire("ShowCaret",{target:t,direction:e,before:n}).isDefaultPrevented()?null:(r&&b.scrollIntoView(t,-1===e),i.show(n,t))}function t(e){return Ir(e)||_o(e)||Ao(e)}function g(e){return t(e.startContainer)||t(e.endContainer)}function p(e,t){if(!e)return null;if(e.collapsed){if(!g(e)){var n=t?1:-1,r=rc(n,x,e),o=r.getNode(!t);if(Ks(o))return m(n,o,!!t&&!r.isAtEnd(),!1);var i=r.getNode(t);if(Ks(i))return m(n,i,!t&&!r.isAtEnd(),!1)}return null}var a=e.startContainer,u=e.startOffset,s=e.endOffset;if(3===a.nodeType&&0===u&&F1(a.parentNode)&&(a=a.parentNode,u=y.nodeIndex(a),a=a.parentNode),1!==a.nodeType)return null;if(s===u+1&&a===e.endContainer){var c=a.childNodes[u];if(f(c))return function(e){var t=e.cloneNode(!0),n=l.fire("ObjectSelected",{target:e,targetClone:t});if(n.isDefaultPrevented())return null;var r=function(e,t,n){var r=l.$,o=vr(kt.fromDom(l.getBody()),"#"+w).fold(function(){return r([])},function(e){return r([e.dom])});0===o.length&&(o=r('<div data-mce-bogus="all" class="mce-offscreen-selection"></div>').attr("id",w)).appendTo(l.getBody());var i=y.createRng();t===n&&xt.ie?(o.empty().append('<p style="font-size: 0" data-mce-bogus="all">\xa0</p>').append(t),i.setStartAfter(o[0].firstChild.firstChild),i.setEndAfter(t)):(o.empty().append(xo).append(t).append(xo),i.setStart(o[0].firstChild,1),i.setEnd(o[0].lastChild,0)),o.css({top:y.getPos(e,l.getBody()).y}),o[0].focus();var a=b.getSel();return a.removeAllRanges(),a.addRange(i),i}(e,n.targetClone,t),o=kt.fromDom(e);return Y(bu(kt.fromDom(l.getBody()),"*[data-mce-selected]"),function(e){je(o,e)||yn(e,S)}),y.getAttrib(e,S)||e.setAttribute(S,"1"),v=e,E(),r}(c)}return null}function h(){v&&v.removeAttribute(S),vr(kt.fromDom(l.getBody()),"#"+w).each(Ln),v=null}var v,n,e,o,b=l.selection,y=l.dom,C=y.isBlock,x=l.getBody(),i=$s(l,x,C,function(){return yd(l)}),w="sel-"+y.uniqueId(),S="data-mce-selected",r=b.getRng,E=function(){i.hide()};return xt.ceFalse&&!hh(l)&&(l.on("mouseup",function(e){var t=r();t.collapsed&&cv(l,e.clientX,e.clientY)&&Nb(l,t,!1).each(d)}),l.on("click",function(e){var t=f1(l,e.target);t&&(F1(t)&&(e.preventDefault(),l.focus()),M1(t)&&y.isChildOf(t,b.getNode())&&h())}),l.on("blur NewBlock",h),l.on("ResizeWindow FullscreenStateChanged",i.reposition),l.on("tap",function(e){var t=e.target,n=f1(l,t);F1(n)?(e.preventDefault(),kb(l,n).each(p)):f(t)&&kb(l,t).each(p)},!0),l.on("mousedown",function(e){var t,n,r,o,i,a,u,s=e.target;s!==x&&"HTML"!==s.nodeName&&!y.isChildOf(s,x)||!1===cv(l,e.clientX,e.clientY)||((t=f1(l,s))?F1(t)?(e.preventDefault(),kb(l,t).each(p)):(h(),M1(t)&&e.shiftKey||bf(e.clientX,e.clientY,b.getRng())||(E(),b.placeCaretAt(e.clientX,e.clientY))):f(s)?kb(l,s).each(p):!1===Ks(s)&&(h(),E(),(n=Qy(x,e.clientX,e.clientY))&&(r=s,o=n.node,a=y.getParent(r,C),u=y.getParent(o,C),!K(a)&&(r!==u&&y.isChildOf(a,u)&&!1===F1(f1(l,a))||!y.isChildOf(u,a)&&(i=u,y.getParent(a,C)!==y.getParent(i,C))&&function(e){var t=e.firstChild;if(!K(t)){var n=ss.before(t);if(Wn(n.getNode())&&1===e.childNodes.length)return!c(n);var r=Ic(e).next(n);return r&&!c(r)}}(a))||(e.preventDefault(),d(m(1,n.node,n.before,!1)),l.getBody().focus()))))}),l.on("keypress",function(e){Lf.modifierPressed(e)||F1(b.getNode())&&e.preventDefault()}),l.on("GetSelectionRange",function(e){var t=e.range;v&&(v.parentNode?((t=t.cloneRange()).selectNode(v),e.range=t):v=null)}),l.on("SetSelectionRange",function(e){var t,n,r,o,i,a,u;e.range=(t=e.range,n=l.schema.getShortEndedElements(),r=y.createRng(),o=t.startContainer,i=t.startOffset,a=t.endContainer,u=t.endOffset,ke(n,o.nodeName.toLowerCase())?0===i?r.setStartBefore(o):r.setStartAfter(o):r.setStart(o,i),ke(n,a.nodeName.toLowerCase())?0===u?r.setEndBefore(a):r.setEndAfter(a):r.setEnd(a,u),r);var s=p(e.range,e.forward);s&&(e.range=s)}),l.on("AfterSetSelectionRange",function(e){var t=e.range,n=t.startContainer.parentNode;g(t)||"mcepastebin"===n.id||E(),y.hasClass(n,"mce-offscreen-selection")||h()}),l.on("copy",function(e){var t,n,r=e.clipboardData;e.isDefaultPrevented()||!e.clipboardData||xt.ie||(t=(n=y.get(w))&&n.getElementsByTagName("*")[0])&&(e.preventDefault(),r.clearData(),r.setData("text/html",t.outerHTML),r.setData("text/plain",t.outerText||t.innerText))}),l1(l),e=du(function(){var e,t;n.removed||!n.getBody().contains(document.activeElement)||(e=n.selection.getRng()).collapsed&&(t=_b(n,e,!1),n.selection.setRng(t))},0),(n=l).on("focus",function(){e.throttle()}),n.on("blur",function(){e.cancel()}),(o=l).on("init",function(){o.on("focusin",function(e){var t,n,r=e.target;Jn(r)&&(t=vf(o.getBody(),r),n=Yn(t)?t:r,o.selection.getNode()!==n&&kb(o,n).each(function(e){return o.selection.setRng(e)}))})})),{showCaret:m,showBlockCaretContainer:function(e){e.hasAttribute("data-mce-caret")&&(zr(e),d(r()),b.scrollIntoView(e))},hideFakeCaret:E,destroy:function(){i.destroy(),v=null}}}function m1(a){function e(e,t){try{a.getDoc().execCommand(e,!1,t)}catch(e){}}function u(e){return e.isDefaultPrevented()}function t(){a.shortcuts.add("meta+a",null,"SelectAll")}function n(){a.inline||b.bind(a.getDoc(),"mousedown mouseup",function(e){var t;e.target===a.getDoc().documentElement&&(t=y.getRng(),a.getBody().focus(),"mousedown"===e.type?Ir(t.startContainer)||y.placeCaretAt(e.clientX,e.clientY):y.setRng(t))})}function r(){Range.prototype.getClientRects||a.on("mousedown",function(e){var t;u(e)||"HTML"!==e.target.nodeName||((t=a.getBody()).blur(),_r.setEditorTimeout(a,function(){t.focus()}))})}function o(){a.on("click",function(e){var t=e.target;/^(IMG|HR)$/.test(t.nodeName)&&"false"!==b.getContentEditableParent(t)&&(e.preventDefault(),a.selection.select(t),a.nodeChanged()),"A"===t.nodeName&&b.hasClass(t,"mce-item-anchor")&&(e.preventDefault(),y.select(t))})}function i(){a.on("keydown",function(e){if(!u(e)&&e.keyCode===h&&y.isCollapsed()&&0===y.getRng().startOffset){var t=y.getNode().previousSibling;if(t&&t.nodeName&&"table"===t.nodeName.toLowerCase())return e.preventDefault(),!1}})}function s(){a.getParam("readonly")||a.on("BeforeExecCommand mousedown",function(){e("StyleWithCSS",!1),e("enableInlineTableEditing",!1),Bs(a)||e("enableObjectResizing",!1)})}function c(){a.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function l(){a.inline||a.on("keydown",function(){document.activeElement===document.body&&a.getWin().focus()})}function f(){a.inline||(a.contentStyles.push("body {min-height: 150px}"),a.on("click",function(e){var t;"HTML"===e.target.nodeName&&(11<xt.ie?a.getBody().focus():(t=a.selection.getRng(),a.getBody().focus(),a.selection.setRng(t),a.selection.normalize(),a.nodeChanged()))}))}function d(){xt.mac&&a.on("keydown",function(e){!Lf.metaKeyPressed(e)||e.shiftKey||37!==e.keyCode&&39!==e.keyCode||(e.preventDefault(),a.selection.getSel().modify("move",37===e.keyCode?"backward":"forward","lineboundary"))})}function m(){a.on("click",function(e){var t=e.target;do{if("A"===t.tagName)return void e.preventDefault()}while(t=t.parentNode)}),a.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function g(){a.on("init",function(){a.dom.bind(a.getBody(),"submit",function(e){e.preventDefault()})})}var p=Et.each,h=Lf.BACKSPACE,v=Lf.DELETE,b=a.dom,y=a.selection,C=a.parser,x=xt.gecko,w=xt.ie,S=xt.webkit,E="data:text/mce-internal,",k=w?"Text":"URL",N=te;return hh(a)?(S&&(n(),o(),g(),t(),xt.iOS&&(l(),f(),m())),x&&(r(),s(),c(),d())):(a.on("keydown",function(e){if(!u(e)&&e.keyCode===Lf.BACKSPACE){var t,n=(t=y.getRng()).startContainer,r=t.startOffset,o=b.getRoot(),i=n;if(t.collapsed&&0===r){for(;i&&i.parentNode&&i.parentNode.firstChild===i&&i.parentNode!==o;)i=i.parentNode;"BLOCKQUOTE"===i.tagName&&(a.formatter.toggle("blockquote",null,i),(t=b.createRng()).setStart(n,0),t.setEnd(n,0),y.setRng(t))}}}),a.on("keydown",function(e){var t,n,r,o,i=e.keyCode;u(e)||i!==v&&i!==h||(t=a.selection.isCollapsed(),n=a.getBody(),t&&!b.isEmpty(n)||!t&&(r=R(a.selection.getRng()),(o=b.createRng()).selectNode(a.getBody()),r!==R(o))||(e.preventDefault(),a.setContent(""),n.firstChild&&b.isBlock(n.firstChild)?a.selection.setCursorLocation(n.firstChild,0):a.selection.setCursorLocation(n,0),a.nodeChanged()))}),xt.windowsPhone||a.on("keyup focusin mouseup",function(e){Lf.modifierPressed(e)||y.normalize()},!0),S&&(n(),o(),ks(a)&&a.on("init",function(){e("DefaultParagraphSeparator",ks(a))}),g(),i(),C.addNodeFilter("br",function(e){for(var t=e.length;t--;)"Apple-interchange-newline"===e[t].attr("class")&&e[t].remove()}),xt.iOS?(l(),f(),m()):t()),11<=xt.ie&&(f(),i()),xt.ie&&(t(),e("AutoUrlDetect",!1),a.on("dragstart",function(e){var t,n,r;(t=e).dataTransfer&&(a.selection.isCollapsed()&&"IMG"===t.target.tagName&&y.select(t.target),0<(n=a.selection.getContent()).length&&(r=E+escape(a.id)+","+escape(n),t.dataTransfer.setData(k,r)))}),a.on("drop",function(e){var t,n,r,o;u(e)||(t=e.dataTransfer&&(o=e.dataTransfer.getData(k))&&0<=o.indexOf(E)?(o=o.substr(E.length).split(","),{id:unescape(o[0]),html:unescape(o[1])}):null)&&t.id!==a.id&&(e.preventDefault(),n=Ef(e.x,e.y,a.getDoc()),y.setRng(n),r=t.html,a.queryCommandSupported("mceInsertClipboardContent")?a.execCommand("mceInsertClipboardContent",!1,{content:r,internal:!0}):a.execCommand("mceInsertContent",!1,r))})),x&&(a.on("keydown",function(e){if(!u(e)&&e.keyCode===h&&a.getBody().getElementsByTagName("hr").length&&y.isCollapsed()&&0===y.getRng().startOffset){var t=y.getNode(),n=t.previousSibling;if("HR"===t.nodeName)return b.remove(t),void e.preventDefault();n&&n.nodeName&&"hr"===n.nodeName.toLowerCase()&&(b.remove(n),e.preventDefault())}}),r(),a.on("keypress",function(e){var t;if(!u(e)&&(8===e.keyCode||46===e.keyCode)&&A())return t=_(),a.getDoc().execCommand("delete",!1,null),t(),e.preventDefault(),!1}),b.bind(a.getDoc(),"cut",function(e){var t;!u(e)&&A()&&(t=_(),_r.setEditorTimeout(a,function(){t()}))}),s(),a.on("SetContent ExecCommand",function(e){"setcontent"!==e.type&&"mceInsertLink"!==e.command||p(b.select("a"),function(e){var t=e.parentNode,n=b.getRoot();if(t.lastChild===e){for(;t&&!b.isBlock(t);){if(t.parentNode.lastChild!==t||t===n)return;t=t.parentNode}b.add(t,"br",{"data-mce-bogus":1})}})}),c(),d(),i())),{refreshContentEditable:N,isHidden:function(){if(!x||a.removed)return!1;var e=a.selection.getSel();return!e||!e.rangeCount||0===e.rangeCount}};function _(){var e=b.getAttribs(y.getStart().cloneNode(!1));return function(){var t=y.getStart();t!==a.getBody()&&(b.setAttrib(t,"style",null),p(e,function(e){t.setAttributeNode(e.cloneNode(!0))}))}}function A(){return!y.isCollapsed()&&b.getParent(y.getStart(),b.isBlock)!==b.getParent(y.getEnd(),b.isBlock)}function R(e){var t=b.create("body"),n=e.cloneContents();return t.appendChild(n),y.serializer.serialize(t,{format:"html"})}}function g1(e){return ae(e,function(e){return!1===b(e)})}function p1(e){var t=e.settings;return g1({block_elements:t.block_elements,boolean_attributes:t.boolean_attributes,custom_elements:t.custom_elements,extended_valid_elements:t.extended_valid_elements,invalid_elements:t.invalid_elements,invalid_styles:t.invalid_styles,move_caret_before_on_enter_elements:t.move_caret_before_on_enter_elements,non_empty_elements:t.non_empty_elements,schema:t.schema,self_closing_elements:t.self_closing_elements,short_ended_elements:t.short_ended_elements,special:t.special,text_block_elements:t.text_block_elements,text_inline_elements:t.text_inline_elements,valid_children:t.valid_children,valid_classes:t.valid_classes,valid_elements:t.valid_elements,valid_styles:t.valid_styles,verify_html:t.verify_html,whitespace_elements:t.whitespace_elements,padd_empty_block_inline_children:t.format_empty_lines})}function h1(e){var t=e.settings,n=e.editorUpload.blobCache;return g1({allow_conditional_comments:t.allow_conditional_comments,allow_html_data_urls:t.allow_html_data_urls,allow_svg_data_urls:t.allow_svg_data_urls,allow_html_in_named_anchor:t.allow_html_in_named_anchor,allow_script_urls:t.allow_script_urls,allow_unsafe_link_target:t.allow_unsafe_link_target,convert_fonts_to_spans:t.convert_fonts_to_spans,fix_list_elements:t.fix_list_elements,font_size_legacy_values:t.font_size_legacy_values,forced_root_block:t.forced_root_block,forced_root_block_attrs:t.forced_root_block_attrs,padd_empty_with_br:t.padd_empty_with_br,preserve_cdata:t.preserve_cdata,remove_trailing_brs:t.remove_trailing_brs,inline_styles:t.inline_styles,root_name:e.inline?e.getElement().nodeName.toLowerCase():void 0,validate:!0,blob_cache:n,document:e.getDoc(),images_dataimg_filter:t.images_dataimg_filter})}function v1(e){var t,u,n;e.bindPendingEventDelegates(),e.initialized=!0,e.fire("Init"),e.focus(!0),n=(u=e).dom.getRoot(),u.inline||Bl(u)&&u.selection.getStart(!0)!==n||nf(n).each(function(e){var t,n,r,o,i=e.getNode(),a=cn(i)?nf(i).getOr(e):e;xt.browser.isIE()?(t=u,n=a.toRange(),r=kt.fromDom(t.getBody()),o=(sd(t)?ve.from(n):ve.none()).map(cd).filter(ud(r)),t.bookmark=o.isSome()?o:t.bookmark):u.selection.setRng(a.toRange())}),e.nodeChanged({initial:!0}),e.execCallback("init_instance_callback",e),(t=e).settings.auto_focus&&_r.setEditorTimeout(t,function(){var e=!0===t.settings.auto_focus?t:t.editorManager.get(t.settings.auto_focus);e.destroyed||e.focus()},100)}function b1(e){return(e.inline?e.ui:e.dom).styleSheetLoader}function y1(e){function t(){o.unloadAll(a),e.inline||e.ui.styleSheetLoader.unloadAll(i)}function n(){e.removed?t():e.on("remove",t)}var r,o=b1(e),i=Os(e),a=e.contentCSS;0<e.contentStyles.length&&(r="",Et.each(e.contentStyles,function(e){r+=e+"\r\n"}),e.dom.addStyle(r));var u,s,c,l,f,d,m,g,p,h=Nr.all((u=e,s=a,c=i,l=[new Nr(function(e,t){return b1(u).loadAll(s,e,t)})],u.inline?l:l.concat([new Nr(function(e,t){return u.ui.styleSheetLoader.loadAll(c,e,t)})]))).then(n).catch(n);return e.settings.content_style&&(d=(f=e).settings.content_style,m=kt.fromDom(f.getBody()),g=jt(Bn(m)),pn(p=kt.fromTag("style"),"type","text/css"),Pn(p,kt.fromText(d)),Pn(g,p),f.on("remove",function(){Ln(p)})),h}function C1(e){var t;!0!==e.removed&&(hh(t=e)||t.load({initial:!0,format:"html"}),t.startContent=t.getContent({format:"raw"}),v1(e))}function x1(t,e){var n=t.settings,r=t.getElement(),o=t.getDoc();n.inline||(t.getElement().style.visibility=t.orgVisibility),e||t.inline||(o.open(),o.write(t.iframeHTML),o.close()),t.inline&&(U1.addClass(r,"mce-content-body"),t.contentDocument=o=document,t.contentWindow=window,t.bodyElement=r,t.contentAreaContainer=r);var u,i,a,s,c,l,f,d,m,g,p,h,v=t.getBody();v.disabled=!0,t.readonly=!!n.readonly,t.readonly||(t.inline&&"static"===U1.getStyle(v,"position",!0)&&(v.style.position="relative"),v.contentEditable=t.getParam("content_editable_state",!0)),v.disabled=!1,t.editorUpload=Gv(t),t.schema=ro(p1(t)),t.dom=Za(o,{keep_values:!0,url_converter:t.convertURL,url_converter_scope:t,hex_colors:n.force_hex_style_colors,update_styles:!0,root_element:t.inline?t.getBody():null,collect:function(){return t.inline},schema:t.schema,contentCssCors:t.getParam("content_css_cors",!1,"boolean"),referrerPolicy:Rs(t),onSetAttrib:function(e){t.fire("SetAttrib",e)}}),t.parser=((i=Xh(h1(u=t),u.schema)).addAttributeFilter("src,href,style,tabindex",function(e,t){for(var n,r,o=e.length,i=u.dom,a="data-mce-"+t;o--;)(r=(n=e[o]).attr(t))&&!n.attr(a)&&0!==r.indexOf("data:")&&0!==r.indexOf("blob:")&&("style"===t?((r=i.serializeStyle(i.parseStyle(r),n.name)).length||(r=null),n.attr(a,r),n.attr(t,r)):"tabindex"===t?(n.attr(a,r),n.attr(t,null)):n.attr(a,u.convertURL(r,t,n.name)))}),i.addNodeFilter("script",function(e){for(var t=e.length;t--;){var n=e[t],r=n.attr("type")||"no/type";0!==r.indexOf("mce-")&&n.attr("type","mce-"+r)}}),u.settings.preserve_cdata&&i.addNodeFilter("#cdata",function(e){for(var t=e.length;t--;){var n=e[t];n.type=8,n.name="#comment",n.value="[CDATA["+u.dom.encode(n.value)+"]]"}}),i.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(e){for(var t=e.length,n=u.schema.getNonEmptyElements();t--;){var r=e[t];r.isEmpty(n)&&0===r.getAll("br").length&&(r.append(new Hd("br",1)).shortEnded=!0)}}),i),t.serializer=Jh((s=(a=t).settings,_e(_e(_e({},h1(a)),p1(a)),g1({url_converter:s.url_converter,url_converter_scope:s.url_converter_scope,element_format:s.element_format,entities:s.entities,entity_encoding:s.entity_encoding,indent:s.indent,indent_after:s.indent_after,indent_before:s.indent_before}))),t),t.selection=Fh(t.dom,t.getWin(),t.serializer,t),t.annotator=Ul(t),t.formatter=eb(t),t.undoManager=nb(t),t._nodeChangeDispatcher=new r1(t),t._selectionOverrides=d1(t),m=t,g=fu(),p=iu(!1),h=mu(function(e){m.fire("longpress",_e(_e({},e),{type:"longpress"})),p.set(!0)},400),m.on("touchstart",function(n){N0(n).each(function(e){h.cancel();var t={x:e.clientX,y:e.clientY,target:n.target};h.throttle(n),p.set(!1),g.set(t)})},!0),m.on("touchmove",function(e){h.cancel(),N0(e).each(function(i){g.on(function(e){var t=i,n=e,r=Math.abs(t.clientX-n.x),o=Math.abs(t.clientY-n.y);(5<r||5<o)&&(g.clear(),p.set(!1),m.fire("longpresscancel"))})})},!0),m.on("touchend touchcancel",function(t){h.cancel(),"touchcancel"!==t.type&&g.get().filter(function(e){return e.target.isEqualNode(t.target)}).each(function(){p.get()?t.preventDefault():m.fire("tap",_e(_e({},t),{type:"tap"}))})},!0),(f=l=t).on("click",function(e){f.dom.getParent(e.target,"details")&&e.preventDefault()}),(d=l).parser.addNodeFilter("details",function(e){Y(e,function(e){e.attr("data-mce-open",e.attr("open")),e.attr("open","open")})}),d.serializer.addNodeFilter("details",function(e){Y(e,function(e){var t=e.attr("data-mce-open");e.attr("open",X(t)?t:null),e.attr("data-mce-open",null)})}),hh(t)||(c=t).on("click",function(e){var t,n,r,o,i;3<=e.detail&&(r=(t=c).selection.getRng(),o=ss.fromRangeStart(r),i=ss.fromRangeEnd(r),!ss.isElementPosition(o)||i1(n=o.container())&&nf(n).each(function(e){return r.setStart(e.container(),e.offset())}),!ss.isElementPosition(i)||i1(n=o.container())&&rf(n).each(function(e){return r.setEnd(e.container(),e.offset())}),t.selection.setRng(Cg(r)))});var b,y,C,x,w,S,E,k,N,_=hh(b=t)?iu(null):MC(b);N=_,(k=t).addCommand("delete",function(){var e,t=N;E0(e=k)||Mb(e,!1)||Tb(e,!1)||m0(e,t,!1)||Cb(e,!1)||yg(e)||Fb(e,!1)||b0(e,!1)||Sb(e)||h0(e,!1)||(k0(e,"Delete"),lb(e))}),k.addCommand("forwardDelete",function(){var e,t=N;Mb(e=k,!0)||Tb(e,!0)||m0(e,t,!0)||Cb(e,!0)||yg(e)||Fb(e,!0)||b0(e,!0)||Sb(e)||h0(e,!0)||k0(e,"ForwardDelete")}),ks(y=t)&&y.on("NodeChange",R(A0,y)),x=(C=t).dom,w=ks(C),S=C.getParam("placeholder",hc.getAttrib(C.getElement(),"placeholder"),"string"),E=function(e,t){var n,r,o;!function(e){if(rb(e)){var t=e.keyCode;return!ob(e)&&(Lf.metaKeyPressed(e)||e.altKey||112<=t&&t<=123||T(hy,t))}}(e)&&(n=C.getBody(),r=!(rb(o=e)&&!(ob(o)||"keyup"===o.type&&229===o.keyCode))&&function(e,t,n){if(Wr(kt.fromDom(t),!1)){var r=""===n,o=t.firstElementChild;return!o||!e.getStyle(t.firstElementChild,"padding-left")&&!e.getStyle(t.firstElementChild,"padding-right")&&(r?!e.isBlock(o):n===o.nodeName.toLowerCase())}return!1}(x,n,w),""!==x.getAttrib(n,vy)===r&&!t||(x.setAttrib(n,vy,r?S:null),x.setAttrib(n,"aria-placeholder",r?S:null),C.fire("PlaceholderToggle",{state:r}),C.on(r?"keydown":"keyup",E),C.off(r?"keyup":"keydown",E)))},S&&C.on("init",function(e){E(e,!0),C.on("change SetContent ExecCommand",E),C.on("paste",function(e){return _r.setEditorTimeout(C,function(){return E(e)})})});var A=vh(t);(function(t){var e=t.settings,n=t.getDoc(),r=t.getBody();t.fire("PreInit"),e.browser_spellcheck||e.gecko_spellcheck||(n.body.spellcheck=!1,U1.setAttrib(r,"spellcheck","false")),t.quirks=m1(t),t.fire("PostRender");var o=t.getParam("directionality",cu.isRtl()?"rtl":void 0);void 0!==o&&(r.dir=o),e.protect&&t.on("BeforeSetContent",function(t){Et.each(e.protect,function(e){t.content=t.content.replace(e,function(e){return"\x3c!--mce:protected "+escape(e)+"--\x3e"})})}),t.on("SetContent",function(){t.addVisual(t.getBody())}),t.on("compositionstart compositionend",function(e){t.composing="compositionstart"===e.type})})(t),A.fold(function(){y1(t).then(function(){return C1(t)})},function(e){t.setProgressState(!0),y1(t).then(function(){e().then(function(e){t.setProgressState(!1),C1(t)},function(e){t.notificationManager.open({type:"error",text:String(e)}),C1(t)})})})}function w1(e,t){var n,r,o,i,a=e.translate("Rich Text Area"),u=(n=e.id,r=a,t.height,o=e.getParam("iframe_attrs",{}),hn(i=kt.fromTag("iframe"),o),hn(i,{id:n+"_ifr",frameBorder:"0",allowTransparency:"true",title:r}),hu(i,"tox-edit-area__iframe"),i.dom);u.onload=function(){u.onload=null,e.fire("load")};var s=function(e,t){if(document.domain!==window.location.hostname&&xt.browser.isIE()){var n=$v("mce");e[n]=function(){x1(e)};var r='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinymce.get("'+e.id+'");document.write(ed.iframeHTML);document.close();ed.'+n+"(true);})()";return z1.setAttrib(t,"src",r),!0}return!1}(e,u);return e.contentAreaContainer=t.iframeContainer,e.iframeElement=u,e.iframeHTML=function(e){var t=e.getParam("doctype","<!DOCTYPE html>")+"<html><head>";e.getParam("document_base_url","")!==e.documentBaseUrl&&(t+='<base href="'+e.documentBaseURI.getURI()+'" />'),t+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';var n=Ss(e,"body_id","tinymce"),r=Ss(e,"body_class",""),o=e.translate(e.getParam("iframe_aria_text","Rich Text Area. Press ALT-0 for help.","string"));return Es(e)&&(t+='<meta http-equiv="Content-Security-Policy" content="'+Es(e)+'" />'),t+('</head><body id="'+n+'" class="mce-content-body '+r+'" data-id="'+e.id)+'" aria-label="'+o+'"><br></body></html>'}(e),z1.add(t.iframeContainer,u),s}function S1(e){return e.replace(/^\-/,"")}function E1(e){return{editorContainer:e,iframeContainer:e,api:{}}}function k1(e){var t,n,r,o,i,a,u,s=e.getElement();return e.orgDisplay=s.style.display,X(Ls(e))?e.theme.renderUI():y(Ls(e))?(n=(t=e).getElement(),(r=Ls(t)(t,n)).editorContainer.nodeType&&(r.editorContainer.id=r.editorContainer.id||t.id+"_parent"),r.iframeContainer&&r.iframeContainer.nodeType&&(r.iframeContainer.id=r.iframeContainer.id||t.id+"_iframecontainer"),r.height=r.iframeHeight||n.offsetHeight,r):(u=(o=e).getElement(),o.inline?E1(null):(i=u,a=H1.create("div"),H1.insertAfter(a,i),E1(a)))}function N1(e){var n,t,r,o,i,a,u,s;e.fire("ScriptsLoaded"),n=e,t=Et.trim(As(n)),r=n.ui.registry.getAll().icons,ne(_e(_e({},Dv.get("default").icons),Dv.get(t).icons),function(e,t){ke(r,t)||n.ui.registry.addIcon(t,e)}),a=Ls(o=e),X(a)?(o.settings.theme=S1(a),i=Iv.get(a),o.theme=new i(o,Iv.urls[a]),o.theme.init&&o.theme.init(o,Iv.urls[a]||o.documentBaseUrl.replace(/\/$/,""),o.$)):o.theme={},s=[],Et.each(Ms(u=e).split(/[ ,]/),function(e){j1(u,s,S1(e))});var c=k1(e),l=e,f=ve.from(c.api).getOr({}),d={show:ve.from(f.show).getOr(te),hide:ve.from(f.hide).getOr(te),disable:ve.from(f.disable).getOr(te),isDisabled:ve.from(f.isDisabled).getOr(D),enable:function(){l.mode.isReadOnly()||ve.from(f.enable).map(x)}};l.ui=_e(_e({},l.ui),d);var m,g,p,h={editorContainer:c.editorContainer,iframeContainer:c.iframeContainer};return e.editorContainer=h.editorContainer||null,Vv(e),e.inline?x1(e):(p=w1(m=e,g=h),g.editorContainer&&(z1.get(g.editorContainer).style.display=m.orgDisplay,m.hidden=z1.isHidden(g.editorContainer)),m.getElement().style.display="none",z1.setAttrib(m.id,"aria-hidden","true"),void(p||x1(m)))}function _1(e){return"-"===e.charAt(0)}function A1(t,e,n){return ve.from(e).filter(function(e){return 0<e.length&&!Dv.has(e)}).map(function(e){return{url:t.editorManager.baseURL+"/icons/"+e+"/icons"+n+".js",name:ve.some(e)}})}function R1(c,l){var e,t,f=ru.ScriptLoader,n=f,r=l,o=function(){var r,o,t,n,e,i,a,u,s;e=f,u=Ds(i=c),s=i.getParam("language_url","","string"),!1===cu.hasCode(u)&&"en"!==u&&(a=""!==s?s:i.editorManager.baseURL+"/langs/"+u+".js",e.add(a,te,void 0,function(){zv(i,"LanguageLoadError",Hv("language",a,u))})),t=f,Y(function(e){for(var t=[],n=function(e){t.push(e)},r=0;r<e.length;r++)e[r].each(n);return t}([A1(n=c,"default",l),ve.from(n.getParam("icons_url","","string")).filter(function(e){return 0<e.length}).map(function(e){return{url:e,name:ve.none()}}).orThunk(function(){return A1(n,As(n),"")})]),function(e){t.add(e.url,te,void 0,function(){zv(n,"IconsLoadError",Hv("icons",e.url,e.name.getOrUndefined()))})}),r=c,o=l,Et.each(r.getParam("external_plugins"),function(e,t){Lv.load(t,e,te,void 0,function(){jv(r,e,t)}),r.settings.plugins+=" "+t}),Et.each(Ms(r).split(/[ ,]/),function(e){var t,n;(e=Et.trim(e))&&!Lv.urls[e]&&(_1(e)?(e=e.substr(1,e.length),t=Lv.dependencies(e),Et.each(t,function(e){var t=Lv.createUrl({prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"},e);Lv.load(t.resource,t,te,void 0,function(){jv(r,t.prefix+t.resource+t.suffix,t.resource)})})):(n={prefix:"plugins/",resource:e,suffix:"/plugin"+o+".js"},Lv.load(e,n,te,void 0,function(){jv(r,n.prefix+n.resource+n.suffix,e)})))}),f.loadQueue(function(){c.removed||N1(c)},c,function(){c.removed||N1(c)})},i=Ls(e=c);X(i)?(_1(i)||ke(Iv.urls,i)||((t=e.getParam("theme_url"))?Iv.load(i,e.documentBaseURI.toAbsolute(t)):Iv.load(i,"themes/"+i+"/theme"+r+".js")),n.loadQueue(function(){Iv.waitFor(i,o)})):o()}function D1(a){return function(i,e){return ve.from(e).map(kt.fromDom).filter(Nn).bind(function(e){return n=a,t=i,r=e.dom,Tg(kt.fromDom(r),function(e){return wn(t=e,n).orThunk(function(){return"font"===Nt(t)?ue(q1,n).bind(function(e){return bn(t,e)}):ve.none()});var t},function(e){return je(kt.fromDom(t),e)}).or((o=e.dom,ve.from(Za.DOM.getStyle(o,a,!0))));var n,t,r,o}).getOr("")}}function T1(e){return nf(e.getBody()).map(function(e){var t=e.container();return jn(t)?t.parentNode:t})}function O1(e,t){return n=e,r=a(ve.some,t),o=n,ve.from(o.selection.getRng()).bind(function(e){var t=o.getBody();return e.startContainer===t&&0===e.startOffset?ve.none():ve.from(o.selection.getStart(!0))}).orThunk(R(T1,n)).map(kt.fromDom).filter(Nn).bind(r);var n,r,o}function B1(e,t){if(/^[0-9.]+$/.test(t)){var n=parseInt(t,10);if(1<=n&&n<=7){var r=Et.explode(e.getParam("font_size_style_values","xx-small,x-small,small,medium,large,x-large,xx-large")),o=Et.explode(e.getParam("font_size_classes",""));return o?o[n-1]||t:r[n-1]||t}return t}return t}var P1=Yn,L1=Xn,I1=function(e){e.on(function(e){u1(e.ghost)}),e.clear()},M1=Xn,F1=Yn,U1=Za.DOM,z1=Za.DOM,H1=Za.DOM,j1=function(t,n,r){var o,i,a,u,e=Lv.get(r),s=Lv.urls[r]||t.documentBaseUrl.replace(/\/$/,"");if(r=Et.trim(r),e&&-1===Et.inArray(n,r)&&(Et.each(Lv.dependencies(r),function(e){j1(t,n,e)}),!t.plugins[r]))try{var c=new e(t,s,t.$);(t.plugins[r]=c).init&&(c.init(t,s),n.push(r))}catch(e){i=r,a=e,yf(o=t,"PluginLoadError",{message:u=cu.translate(["Failed to initialize plugin: {0}",i])}),cy(u,a),Uv(o,u)}},V1=Za.DOM,q1={"font-size":"size","font-family":"face"},$1=D1("font-size"),W1=i(function(e){return e.replace(/[\'\"\\]/g,"").replace(/,\s+/g,",")},D1("font-family")),K1=Et.each,X1=Et.map,Y1=Et.inArray,G1=(J1.prototype.execCommand=function(t,n,r,e){var o,i,a=!1,u=this;if(!u.editor.removed){if("mcefocus"!==t.toLowerCase()&&(/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(t)||e&&e.skip_focus?dd(i=u.editor).each(function(e){return i.selection.setRng(e)}):u.editor.focus()),(e=u.editor.fire("BeforeExecCommand",{command:t,ui:n,value:r})).isDefaultPrevented())return!1;var s=t.toLowerCase();if(o=u.commands.exec[s])return o(s,n,r),u.editor.fire("ExecCommand",{command:t,ui:n,value:r}),!0;if(K1(this.editor.plugins,function(e){if(e.execCommand&&e.execCommand(t,n,r))return u.editor.fire("ExecCommand",{command:t,ui:n,value:r}),!(a=!0)}),a)return a;if(u.editor.theme&&u.editor.theme.execCommand&&u.editor.theme.execCommand(t,n,r))return u.editor.fire("ExecCommand",{command:t,ui:n,value:r}),!0;try{a=u.editor.getDoc().execCommand(t,n,r)}catch(e){}return!!a&&(u.editor.fire("ExecCommand",{command:t,ui:n,value:r}),!0)}},J1.prototype.queryCommandState=function(e){var t;if(!this.editor.quirks.isHidden()&&!this.editor.removed){if(e=e.toLowerCase(),t=this.commands.state[e])return t(e);try{return this.editor.getDoc().queryCommandState(e)}catch(e){}return!1}},J1.prototype.queryCommandValue=function(e){var t;if(!this.editor.quirks.isHidden()&&!this.editor.removed){if(e=e.toLowerCase(),t=this.commands.value[e])return t(e);try{return this.editor.getDoc().queryCommandValue(e)}catch(e){}}},J1.prototype.addCommands=function(e,n){void 0===n&&(n="exec");var r=this;K1(e,function(t,e){K1(e.toLowerCase().split(","),function(e){r.commands[n][e]=t})})},J1.prototype.addCommand=function(e,o,i){var a=this;e=e.toLowerCase(),this.commands.exec[e]=function(e,t,n,r){return o.call(i||a.editor,t,n,r)}},J1.prototype.queryCommandSupported=function(e){if(e=e.toLowerCase(),this.commands.exec[e])return!0;try{return this.editor.getDoc().queryCommandSupported(e)}catch(e){}return!1},J1.prototype.addQueryStateHandler=function(e,t,n){var r=this;e=e.toLowerCase(),this.commands.state[e]=function(){return t.call(n||r.editor)}},J1.prototype.addQueryValueHandler=function(e,t,n){var r=this;e=e.toLowerCase(),this.commands.value[e]=function(){return t.call(n||r.editor)}},J1.prototype.hasCustomCommand=function(e){return e=e.toLowerCase(),!!this.commands.exec[e]},J1.prototype.execNativeCommand=function(e,t,n){return void 0===t&&(t=!1),void 0===n&&(n=null),this.editor.getDoc().execCommand(e,t,n)},J1.prototype.isFormatMatch=function(e){return this.editor.formatter.match(e)},J1.prototype.toggleFormat=function(e,t){this.editor.formatter.toggle(e,t),this.editor.nodeChanged()},J1.prototype.storeSelection=function(e){this.selectionBookmark=this.editor.selection.getBookmark(e)},J1.prototype.restoreSelection=function(){this.editor.selection.moveToBookmark(this.selectionBookmark)},J1.prototype.setupCommands=function(u){var o=this;function e(r){return function(){var e=u.selection,t=e.isCollapsed()?[u.dom.getParent(e.getNode(),u.dom.isBlock)]:e.getSelectedBlocks(),n=X1(t,function(e){return!!u.formatter.matchNode(e,r)});return-1!==Y1(n,!0)}}this.addCommands({"mceResetDesignMode,mceBeginUndoLevel":te,"mceEndUndoLevel,mceAddUndoLevel":function(){u.undoManager.add()},mceFocus:function(e,t,n){var r,o;o=n,(r=u).removed||(o?Ud:function(t){var e=t.selection,n=t.getBody(),r=e.getRng();t.quirks.refreshContentEditable(),void 0!==t.bookmark&&!1===yd(t)&&dd(t).each(function(e){t.selection.setRng(e),r=e});var o,i,a=(o=t,i=e.getNode(),o.dom.getParent(i,function(e){return"true"===o.dom.getContentEditable(e)}));if(t.$.contains(n,a))return bd(a),vd(t,r),Ud(t);t.inline||(xt.opera||bd(n),t.getWin().focus()),(xt.gecko||t.inline)&&(bd(n),vd(t,r)),Ud(t)})(r)},"Cut,Copy,Paste":function(e){var t,n,r=u.getDoc();try{o.execNativeCommand(e)}catch(e){t=!0}!(t="paste"===e&&!r.queryCommandEnabled(e)||t)&&r.queryCommandSupported(e)||(n=u.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead."),xt.mac&&(n=n.replace(/Ctrl\+/g,"\u2318+")),u.notificationManager.open({text:n,type:"error"}))},unlink:function(){var e;u.selection.isCollapsed()?(e=u.dom.getParent(u.selection.getStart(),"a"))&&u.dom.remove(e,!0):u.formatter.remove("link")},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull,JustifyNone":function(e){var t=e.substring(7);"full"===t&&(t="justify"),K1("left,center,right,justify".split(","),function(e){t!==e&&u.formatter.remove("align"+e)}),"none"!==t&&o.toggleFormat("align"+t)},"InsertUnorderedList,InsertOrderedList":function(e){var t;o.execNativeCommand(e);var n=u.dom.getParent(u.selection.getNode(),"ol,ul");n&&(t=n.parentNode,/^(H[1-6]|P|ADDRESS|PRE)$/.test(t.nodeName)&&(o.storeSelection(),u.dom.split(t,n),o.restoreSelection()))},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(e){o.toggleFormat(e)},"ForeColor,HiliteColor":function(e,t,n){o.toggleFormat(e,{value:n})},FontName:function(e,t,n){var r,o;o=B1(r=u,n),r.formatter.toggle("fontname",{value:A(o.split(/\s*,\s*/),function(e){return-1===e.indexOf(" ")||Ge(e,'"')||Ge(e,"'")?e:"'"+e+"'"}).join(",")}),r.nodeChanged()},FontSize:function(e,t,n){var r;(r=u).formatter.toggle("fontsize",{value:B1(r,n)}),r.nodeChanged()},LineHeight:function(e,t,n){var r;(r=u).formatter.toggle("lineheight",{value:String(n)}),r.nodeChanged()},Lang:function(e,t,n){o.toggleFormat(e,{value:n.code,customValue:n.customCode})},RemoveFormat:function(e){u.formatter.remove(e)},mceBlockQuote:function(){o.toggleFormat("blockquote")},FormatBlock:function(e,t,n){return o.toggleFormat(n||"p")},mceCleanup:function(){var e=u.selection.getBookmark();u.setContent(u.getContent()),u.selection.moveToBookmark(e)},mceRemoveNode:function(e,t,n){var r=n||u.selection.getNode();r!==u.getBody()&&(o.storeSelection(),u.dom.remove(r,!0),o.restoreSelection())},mceSelectNodeDepth:function(e,t,n){var r=0;u.dom.getParent(u.selection.getNode(),function(e){if(1===e.nodeType&&r++===n)return u.selection.select(e),!1},u.getBody())},mceSelectNode:function(e,t,n){u.selection.select(n)},mceInsertContent:function(e,t,n){var r,o,i,a;r=u,o=function(e){if("string"==typeof e)return{content:e,details:{}};var t=Et.extend({paste:e.paste,data:{paste:e.paste}},e);return{content:e.content,details:t}}(n),i=o.content,a=o.details,bh(r).editor.insertContent(i,a)},mceInsertRawHTML:function(e,t,n){u.selection.setContent("tiny_mce_marker");var r=u.getContent();u.setContent(r.replace(/tiny_mce_marker/g,function(){return n}))},mceInsertNewLine:function(e,t,n){DC(u,n)},mceToggleFormat:function(e,t,n){o.toggleFormat(n)},mceSetContent:function(e,t,n){u.setContent(n)},"Indent,Outdent":function(e){S0(u,e)},mceRepaint:te,InsertHorizontalRule:function(){u.execCommand("mceInsertContent",!1,"<hr />")},mceToggleVisualAid:function(){u.hasVisual=!u.hasVisual,u.addVisual()},mceReplaceContent:function(e,t,n){u.execCommand("mceInsertContent",!1,n.replace(/\{\$selection\}/g,u.selection.getContent({format:"text"})))},mceInsertLink:function(e,t,n){"string"==typeof n&&(n={href:n});var r=u.dom.getParent(u.selection.getNode(),"a");n.href=n.href.replace(/ /g,"%20"),r&&n.href||u.formatter.remove("link"),n.href&&u.formatter.apply("link",n,r)},selectAll:function(){var e,t=u.dom.getParent(u.selection.getStart(),Xn);t&&((e=u.dom.createRng()).selectNodeContents(t),u.selection.setRng(e))},mceNewDocument:function(){u.setContent("")},InsertLineBreak:function(e,t,n){return bC(u,n),!0}}),o.addCommands({JustifyLeft:e("alignleft"),JustifyCenter:e("aligncenter"),JustifyRight:e("alignright"),JustifyFull:e("alignjustify"),"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(e){return o.isFormatMatch(e)},mceBlockQuote:function(){return o.isFormatMatch("blockquote")},Outdent:function(){return x0(u)},"InsertUnorderedList,InsertOrderedList":function(e){var t=u.dom.getParent(u.selection.getNode(),"ul,ol");return t&&("insertunorderedlist"===e&&"UL"===t.tagName||"insertorderedlist"===e&&"OL"===t.tagName)}},"state"),o.addCommands({Undo:function(){u.undoManager.undo()},Redo:function(){u.undoManager.redo()}}),o.addQueryValueHandler("FontName",function(){return O1(t=u,function(e){return W1(t.getBody(),e.dom)}).getOr("");var t},this),o.addQueryValueHandler("FontSize",function(){return O1(t=u,function(e){return $1(t.getBody(),e.dom)}).getOr("");var t},this),o.addQueryValueHandler("LineHeight",function(){return O1(t=u,function(n){var e=kt.fromDom(t.getBody());return Tg(n,function(e){return wn(e,"line-height")},R(je,e)).getOrThunk(function(){var e=parseFloat(xn(n,"line-height")),t=parseFloat(xn(n,"font-size"));return String(e/t)})}).getOr("");var t},this)},J1);function J1(e){this.commands={state:{},exec:{},value:{}},this.editor=e,this.setupCommands(e)}function Q1(e,t,n){var r,o,i,a,u,s;vu(e,t)&&!1===n?(o=t,pu(r=e)?r.dom.classList.remove(o):(u=o,0<(s=U(gu(a=r,"class"),function(e){return e!==u})).length?pn(a,"class",s.join(" ")):yn(a,"class")),0===(pu(i=r)?i.dom.classList:gu(i,"class")).length&&yn(i,"class")):n&&hu(e,t)}function Z1(e,t,n){try{e.getDoc().execCommand(t,!1,String(n))}catch(e){}}function ex(e,t){e.dom.contentEditable=t?"true":"false"}function tx(e,t){var n,r,o=kt.fromDom(e.getBody());Q1(o,"mce-content-readonly",t),t?(e.selection.controlSelection.hideResizeRect(),e._selectionOverrides.hideFakeCaret(),ve.from(e.selection.getNode()).each(function(e){e.removeAttribute("data-mce-selected")}),ex(o,!(e.readonly=!0)),Y(bu(o,'*[contenteditable="true"]'),function(e){pn(e,ox,"true"),ex(e,!1)})):(ex(o,!(e.readonly=!1)),Y(bu(o,"*["+ox+'="true"]'),function(e){yn(e,ox),ex(e,!0)}),Z1(e,"StyleWithCSS",!1),Z1(e,"enableInlineTableEditing",!1),Z1(e,"enableObjectResizing",!1),(yd(n=e)||(r=n,rd(Bn(kt.fromDom(r.getElement()))).filter(function(e){return!(void 0!==(t=e.dom.classList)&&(t.contains("tox-edit-area")||t.contains("tox-edit-area__iframe")||t.contains("mce-content-body")))&&gd(r,e.dom);var t}).isSome()))&&e.focus(),e.selection.setRng(e.selection.getRng()),e.nodeChanged())}function nx(e){return e.readonly}function rx(t){t.parser.addAttributeFilter("contenteditable",function(e){nx(t)&&Y(e,function(e){e.attr(ox,e.attr("contenteditable")),e.attr("contenteditable","false")})}),t.serializer.addAttributeFilter(ox,function(e){nx(t)&&Y(e,function(e){e.attr("contenteditable",e.attr(ox))})}),t.serializer.addTempAttr(ox)}var ox="data-mce-contenteditable",ix=Et.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input beforeinput contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchmove touchend touchcancel"," "),ax=(ux.isNative=function(e){return!!ix[e.toLowerCase()]},ux.prototype.fire=function(e,t){var n=e.toLowerCase(),r=uo(n,t||{},this.scope);this.settings.beforeFire&&this.settings.beforeFire(r);var o=this.bindings[n];if(o)for(var i=0,a=o.length;i<a;i++){var u=o[i];if(!u.removed){if(u.once&&this.off(n,u.func),r.isImmediatePropagationStopped())return r;if(!1===u.func.call(this.scope,r))return r.preventDefault(),r}}return r},ux.prototype.on=function(e,t,n,r){if(t=!1===t?D:t){var o={func:t,removed:!1};r&&Et.extend(o,r);for(var i=e.toLowerCase().split(" "),a=i.length;a--;){var u=i[a],s=this.bindings[u];s||(s=[],this.toggleEvent(u,!0)),s=n?Ae([o],s,!0):Ae(Ae([],s,!0),[o],!1),this.bindings[u]=s}}return this},ux.prototype.off=function(e,t){var n=this;if(e)for(var r=e.toLowerCase().split(" "),o=r.length;o--;){var i,a=r[o],u=this.bindings[a];if(!a)return ne(this.bindings,function(e,t){n.toggleEvent(t,!1),delete n.bindings[t]}),this;u&&(t?(u=(i=B(u,function(e){return e.func===t})).fail,this.bindings[a]=u,Y(i.pass,function(e){e.removed=!0})):u.length=0,u.length||(this.toggleEvent(e,!1),delete this.bindings[a]))}else ne(this.bindings,function(e,t){n.toggleEvent(t,!1)}),this.bindings={};return this},ux.prototype.once=function(e,t,n){return this.on(e,t,n,{once:!0})},ux.prototype.has=function(e){return e=e.toLowerCase(),!(!this.bindings[e]||0===this.bindings[e].length)},ux);function ux(e){this.bindings={},this.settings=e||{},this.scope=this.settings.scope||this,this.toggleEvent=this.settings.toggleEvent||D}function sx(n){return n._eventDispatcher||(n._eventDispatcher=new ax({scope:n,toggleEvent:function(e,t){ax.isNative(e)&&n.toggleNativeEvent&&n.toggleNativeEvent(e,t)}})),n._eventDispatcher}function cx(e,t){if("selectionchange"===t)return e.getDoc();if(!e.inline&&/^mouse|touch|click|contextmenu|drop|dragover|dragend/.test(t))return e.getDoc().documentElement;var n=Ps(e);return n?(e.eventRoot||(e.eventRoot=hx.select(n)[0]),e.eventRoot):e.getBody()}function lx(e,t,n){var r,o,i,a;e.hidden||nx(e)?nx(e)&&(r=e,"click"!==(o=n).type||Lf.metaKeyPressed(o)||(i=kt.fromDom(o.target),a=r,br(i,"a",function(e){return je(e,kt.fromDom(a.getBody()))}).bind(function(e){return bn(e,"href")}).each(function(e){var t,n;o.preventDefault(),/^#/.test(e)?(t=r.dom.select(e+',[name="'+(Ge(n=e,"#")?n.substring("#".length):n)+'"]')).length&&r.selection.scrollIntoView(t[0],!0):window.open(e,"_blank","rel=noopener noreferrer,menubar=yes,toolbar=yes,location=yes,status=yes,resizable=yes,scrollbars=yes")}))):e.fire(t,n)}function fx(i,a){var e,t;i.delegates||(i.delegates={}),i.delegates[a]||i.removed||(t=cx(i,a),Ps(i)?(gx||(gx={},i.editorManager.on("removeEditor",function(){i.editorManager.activeEditor||gx&&(ne(gx,function(e,t){i.dom.unbind(cx(i,t))}),gx=null)})),gx[a]||(gx[a]=e=function(e){for(var t=e.target,n=i.editorManager.get(),r=n.length;r--;){var o=n[r].getBody();o!==t&&!hx.isChildOf(t,o)||lx(n[r],a,e)}},hx.bind(t,a,e))):(hx.bind(t,a,e=function(e){lx(i,a,e)}),i.delegates[a]=e))}function dx(e,t,n,r){var o=n[t.get()],i=n[r];try{i.activate()}catch(e){return void console.error("problem while activating editor mode "+r+":",e)}o.deactivate(),o.editorReadOnly!==i.editorReadOnly&&tx(e,i.editorReadOnly),t.set(r),e.fire("SwitchMode",{mode:r})}function mx(e){var t,n={};yx(Cx(e.toLowerCase(),"+"),function(e){e in wx?n[e]=!0:/^[0-9]{2,}$/.test(e)?n.keyCode=parseInt(e,10):(n.charCode=e.charCodeAt(0),n.keyCode=xx[e]||e.toUpperCase().charCodeAt(0))});var r=[n.keyCode];for(t in wx)n[t]?r.push(t):n[t]=!1;return n.id=r.join(","),n.access&&(n.alt=!0,xt.mac?n.ctrl=!0:n.shift=!0),n.meta&&(xt.mac?n.meta=!0:(n.ctrl=!0,n.meta=!1)),n}var gx,px={fire:function(e,t,n){if(this.removed&&"remove"!==e&&"detach"!==e)return t;var r=sx(this).fire(e,t);if(!1!==n&&this.parent)for(var o=this.parent();o&&!r.isPropagationStopped();)o.fire(e,r,!1),o=o.parent();return r},on:function(e,t,n){return sx(this).on(e,t,n)},off:function(e,t){return sx(this).off(e,t)},once:function(e,t){return sx(this).once(e,t)},hasEventListeners:function(e){return sx(this).has(e)}},hx=Za.DOM,vx=_e(_e({},px),{bindPendingEventDelegates:function(){var t=this;Et.each(t._pendingNativeEvents,function(e){fx(t,e)})},toggleNativeEvent:function(e,t){var n=this;"focus"!==e&&"blur"!==e&&(n.removed||(t?n.initialized?fx(n,e):n._pendingNativeEvents?n._pendingNativeEvents.push(e):n._pendingNativeEvents=[e]:n.initialized&&(n.dom.unbind(cx(n,e),e,n.delegates[e]),delete n.delegates[e])))},unbindAllNativeEvents:function(){var n=this,e=n.getBody(),t=n.dom;n.delegates&&(ne(n.delegates,function(e,t){n.dom.unbind(cx(n,t),t,e)}),delete n.delegates),!n.inline&&e&&t&&(e.onload=null,t.unbind(n.getWin()),t.unbind(n.getDoc())),t&&(t.unbind(e),t.unbind(n.getContainer()))}}),bx=["design","readonly"],yx=Et.each,Cx=Et.explode,xx={f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},wx=Et.makeMap("alt,ctrl,shift,meta,access"),Sx=(Ex.prototype.add=function(e,n,t,r){var o=this,i=o.normalizeCommandFunc(t);return yx(Cx(Et.trim(e)),function(e){var t=o.createShortcut(e,n,i,r);o.shortcuts[t.id]=t}),!0},Ex.prototype.remove=function(e){var t=this.createShortcut(e);return!!this.shortcuts[t.id]&&(delete this.shortcuts[t.id],!0)},Ex.prototype.normalizeCommandFunc=function(e){var t=this,n=e;return"string"==typeof n?function(){t.editor.execCommand(n,!1,null)}:Et.isArray(n)?function(){t.editor.execCommand(n[0],n[1],n[2])}:n},Ex.prototype.createShortcut=function(e,t,n,r){var o=Et.map(Cx(e,">"),mx);return o[o.length-1]=Et.extend(o[o.length-1],{func:n,scope:r||this.editor}),Et.extend(o[0],{desc:this.editor.translate(t),subpatterns:o.slice(1)})},Ex.prototype.hasModifier=function(e){return e.altKey||e.ctrlKey||e.metaKey},Ex.prototype.isFunctionKey=function(e){return"keydown"===e.type&&112<=e.keyCode&&e.keyCode<=123},Ex.prototype.matchShortcut=function(e,t){return!!t&&t.ctrl===e.ctrlKey&&t.meta===e.metaKey&&t.alt===e.altKey&&t.shift===e.shiftKey&&!!(e.keyCode===t.keyCode||e.charCode&&e.charCode===t.charCode)&&(e.preventDefault(),!0)},Ex.prototype.executeShortcutAction=function(e){return e.func?e.func.call(e.scope):null},Ex);function Ex(e){this.shortcuts={},this.pendingPatterns=[],this.editor=e;var n=this;e.on("keyup keypress keydown",function(t){!n.hasModifier(t)&&!n.isFunctionKey(t)||t.isDefaultPrevented()||(yx(n.shortcuts,function(e){if(n.matchShortcut(t,e))return n.pendingPatterns=e.subpatterns.slice(0),"keydown"===t.type&&n.executeShortcutAction(e),!0}),n.matchShortcut(t,n.pendingPatterns[0])&&(1===n.pendingPatterns.length&&"keydown"===t.type&&n.executeShortcutAction(n.pendingPatterns[0]),n.pendingPatterns.shift()))})}var kx=Za.DOM,Nx=Et.extend,_x=Et.each,Ax=Et.resolve,Rx=xt.ie,Dx=(Tx.prototype.render=function(){!function(t){var e=t.id;cu.setCode(Ds(t));var n,r,o,i,a=function(){V1.unbind(window,"ready",a),t.render()};si.Event.domLoaded?t.getElement()&&xt.contentEditable&&(n=kt.fromDom(t.getElement()),r=L(n.dom.attributes,function(e,t){return e[t.name]=t.value,e},{}),t.on("remove",function(){O(n.dom.attributes,function(e){return yn(n,e.name),0}),hn(n,r)}),t.ui.styleSheetLoader=Ar.forElement(n,{contentCssCors:(o=t).getParam("content_css_cors"),referrerPolicy:Rs(o)}),t.getParam("inline")?t.inline=!0:(t.orgVisibility=t.getElement().style.visibility,t.getElement().style.visibility="hidden"),(i=t.getElement().form||V1.getParent(e,"form"))&&(t.formElement=i,t.getParam("hidden_input")&&!Hn(t.getElement())&&(V1.insertAfter(V1.create("input",{type:"hidden",name:e}),e),t.hasHiddenInput=!0),t.formEventDelegate=function(e){t.fire(e.type,e)},V1.bind(i,"submit reset",t.formEventDelegate),t.on("reset",function(){t.resetContent()}),!t.getParam("submit_patch")||i.submit.nodeType||i.submit.length||i._mceOldSubmit||(i._mceOldSubmit=i.submit,i.submit=function(){return t.editorManager.triggerSave(),t.setDirty(!1),i._mceOldSubmit(i)})),t.windowManager=Mv(t),t.notificationManager=lv(t),"xml"===t.getParam("encoding")&&t.on("GetContent",function(e){e.save&&(e.content=V1.encode(e.content))}),t.getParam("add_form_submit_trigger")&&t.on("submit",function(){t.initialized&&t.save()}),t.getParam("add_unload_trigger")&&(t._beforeUnload=function(){!t.initialized||t.destroyed||t.isHidden()||t.save({format:"raw",no_events:!0,set_dirty:!1})},t.editorManager.on("BeforeUnload",t._beforeUnload)),t.editorManager.add(t),R1(t,t.suffix)):V1.bind(window,"ready",a)}(this)},Tx.prototype.focus=function(e){this.execCommand("mceFocus",!1,e)},Tx.prototype.hasFocus=function(){return yd(this)},Tx.prototype.execCallback=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var r,o=this.settings[e];if(o)return this.callbackLookup&&(r=this.callbackLookup[e])&&(o=r.func,r=r.scope),"string"==typeof o&&(r=(r=o.replace(/\.\w+$/,""))?Ax(r):0,o=Ax(o),this.callbackLookup=this.callbackLookup||{},this.callbackLookup[e]={func:o,scope:r}),o.apply(r||this,t)},Tx.prototype.translate=function(e){return cu.translate(e)},Tx.prototype.getParam=function(e,t,n){return i=t,a=n,l=(o=e)in(r=this).settings?r.settings[o]:i,"hash"===a?(c={},"string"==typeof(s=l)?Y(0<s.indexOf("=")?s.split(/[;,](?![^=;,]*(?:[;,]|$))/):s.split(","),function(e){var t=e.split("=");1<t.length?c[Et.trim(t[0])]=Et.trim(t[1]):c[Et.trim(t[0])]=Et.trim(t[0])}):c=s,c):"string"===a?av(X,r,o).getOr(i):"number"===a?av(E,r,o).getOr(i):"boolean"===a?av(v,r,o).getOr(i):"object"===a?av(h,r,o).getOr(i):"array"===a?av(S,r,o).getOr(i):"string[]"===a?av((u=X,function(e){return S(e)&&j(e,u)}),r,o).getOr(i):"function"===a?av(y,r,o).getOr(i):l;var r,o,i,a,u,s,c,l},Tx.prototype.hasPlugin=function(e,t){return!(!T(Ms(this).split(/[ ,]/),e)||t&&void 0===Lv.get(e))},Tx.prototype.nodeChanged=function(e){this._nodeChangeDispatcher.nodeChanged(e)},Tx.prototype.addCommand=function(e,t,n){this.editorCommands.addCommand(e,t,n)},Tx.prototype.addQueryStateHandler=function(e,t,n){this.editorCommands.addQueryStateHandler(e,t,n)},Tx.prototype.addQueryValueHandler=function(e,t,n){this.editorCommands.addQueryValueHandler(e,t,n)},Tx.prototype.addShortcut=function(e,t,n,r){this.shortcuts.add(e,t,n,r)},Tx.prototype.execCommand=function(e,t,n,r){return this.editorCommands.execCommand(e,t,n,r)},Tx.prototype.queryCommandState=function(e){return this.editorCommands.queryCommandState(e)},Tx.prototype.queryCommandValue=function(e){return this.editorCommands.queryCommandValue(e)},Tx.prototype.queryCommandSupported=function(e){return this.editorCommands.queryCommandSupported(e)},Tx.prototype.show=function(){this.hidden&&(this.hidden=!1,this.inline?this.getBody().contentEditable="true":(kx.show(this.getContainer()),kx.hide(this.id)),this.load(),this.fire("show"))},Tx.prototype.hide=function(){var e=this,t=e.getDoc();e.hidden||(Rx&&t&&!e.inline&&t.execCommand("SelectAll"),e.save(),e.inline?(e.getBody().contentEditable="false",e===e.editorManager.focusedEditor&&(e.editorManager.focusedEditor=null)):(kx.hide(e.getContainer()),kx.setStyle(e.id,"display",e.orgDisplay)),e.hidden=!0,e.fire("hide"))},Tx.prototype.isHidden=function(){return!!this.hidden},Tx.prototype.setProgressState=function(e,t){this.fire("ProgressState",{state:e,time:t})},Tx.prototype.load=function(e){var t=this.getElement();if(this.removed)return"";if(t){(e=e||{}).load=!0;var n=Hn(t)?t.value:t.innerHTML,r=this.setContent(n,e);return e.element=t,e.no_events||this.fire("LoadContent",e),e.element=t=null,r}},Tx.prototype.save=function(e){var t,n,r=this,o=r.getElement();if(o&&r.initialized&&!r.removed)return(e=e||{}).save=!0,e.element=o,e.content=r.getContent(e),e.no_events||r.fire("SaveContent",e),"raw"===e.format&&r.fire("RawSaveContent",e),t=e.content,Hn(o)?o.value=t:(!e.is_removing&&r.inline||(o.innerHTML=t),(n=kx.getParent(r.id,"form"))&&_x(n.elements,function(e){if(e.name===r.id)return e.value=t,!1})),e.element=o=null,!1!==e.set_dirty&&r.setDirty(!1),t},Tx.prototype.setContent=function(e,t){return Qh(this,e,t)},Tx.prototype.getContent=function(e){return t=this,r=(n=void 0===(n=e)?{}:n).format||"html",o=n,bh(t).editor.getContent(o,r);var t,n,r,o},Tx.prototype.insertContent=function(e,t){t&&(e=Nx({content:e},t)),this.execCommand("mceInsertContent",!1,e)},Tx.prototype.resetContent=function(e){void 0===e?Qh(this,this.startContent,{format:"raw"}):Qh(this,e),this.undoManager.reset(),this.setDirty(!1),this.nodeChanged()},Tx.prototype.isDirty=function(){return!this.isNotDirty},Tx.prototype.setDirty=function(e){var t=!this.isNotDirty;this.isNotDirty=!e,e&&e!==t&&this.fire("dirty")},Tx.prototype.getContainer=function(){return this.container||(this.container=kx.get(this.editorContainer||this.id+"_parent")),this.container},Tx.prototype.getContentAreaContainer=function(){return this.contentAreaContainer},Tx.prototype.getElement=function(){return this.targetElm||(this.targetElm=kx.get(this.id)),this.targetElm},Tx.prototype.getWin=function(){var e;return this.contentWindow||(e=this.iframeElement)&&(this.contentWindow=e.contentWindow),this.contentWindow},Tx.prototype.getDoc=function(){var e;return this.contentDocument||(e=this.getWin())&&(this.contentDocument=e.document),this.contentDocument},Tx.prototype.getBody=function(){var e=this.getDoc();return this.bodyElement||(e?e.body:null)},Tx.prototype.convertURL=function(e,t,n){var r=this.settings;return r.urlconverter_callback?this.execCallback("urlconverter_callback",e,n,!0,t):!r.convert_urls||n&&"LINK"===n.nodeName||0===e.indexOf("file:")||0===e.length?e:r.relative_urls?this.documentBaseURI.toRelative(e):this.documentBaseURI.toAbsolute(e,r.remove_script_host)},Tx.prototype.addVisual=function(e){var t;t=e,yh(this).editor.addVisual(t)},Tx.prototype.remove=function(){var e,t,n,r,o;(e=this).removed||(t=e._selectionOverrides,n=e.editorUpload,r=e.getBody(),o=e.getElement(),r&&e.save({is_removing:!0}),e.removed=!0,e.unbindAllNativeEvents(),e.hasHiddenInput&&o&&yv.remove(o.nextSibling),e.fire("remove"),e.editorManager.remove(e),!e.inline&&r&&yv.setStyle(e.id,"display",e.orgDisplay),e.fire("detach"),yv.remove(e.getContainer()),Zh(t),Zh(n),e.destroy())},Tx.prototype.destroy=function(e){var t,n,r,o,i,a,u;n=e,a=(t=this).selection,u=t.dom,t.destroyed||(n||t.removed?(n||(t.editorManager.off("beforeunload",t._beforeUnload),t.theme&&t.theme.destroy&&t.theme.destroy(),Zh(a),Zh(u)),(o=(r=t).formElement)&&(o._mceOldSubmit&&(o.submit=o._mceOldSubmit,o._mceOldSubmit=null),yv.unbind(o,"submit reset",r.formEventDelegate)),(i=t).contentAreaContainer=i.formElement=i.container=i.editorContainer=null,i.bodyElement=i.contentDocument=i.contentWindow=null,i.iframeElement=i.targetElm=null,i.selection&&(i.selection=i.selection.win=i.selection.dom=i.selection.dom.doc=null),t.destroyed=!0):t.remove())},Tx.prototype.uploadImages=function(e){return this.editorUpload.uploadImages(e)},Tx.prototype._scanForImages=function(){return this.editorUpload.scanForImages()},Tx.prototype.addButton=function(){throw new Error("editor.addButton has been removed in tinymce 5x, use editor.ui.registry.addButton or editor.ui.registry.addToggleButton or editor.ui.registry.addSplitButton instead")},Tx.prototype.addSidebar=function(){throw new Error("editor.addSidebar has been removed in tinymce 5x, use editor.ui.registry.addSidebar instead")},Tx.prototype.addMenuItem=function(){throw new Error("editor.addMenuItem has been removed in tinymce 5x, use editor.ui.registry.addMenuItem instead")},Tx.prototype.addContextToolbar=function(){throw new Error("editor.addContextToolbar has been removed in tinymce 5x, use editor.ui.registry.addContextToolbar instead")},Tx);function Tx(e,t,n){var r,o,i,a,u,s,c,l,f,d,m,g,p,h,v,b,y,C,x=this;function w(n,r){return function(e,t){return n[e.toLowerCase()]=_e(_e({},t),{type:r})}}this.plugins={},this.contentCSS=[],this.contentStyles=[],this.loadedCSS={},this.isNotDirty=!1,this.editorManager=n,this.documentBaseUrl=n.documentBaseURL,Nx(this,vx),this.settings=(d=(f=this).documentBaseUrl,m=n.defaultSettings,p=d,h=kv,v=f,b={id:e,theme:"silver",toolbar_mode:rv(g=t,"floating"),plugins:"",document_base_url:p,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"<!DOCTYPE html>",visual:!0,font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,inline_styles:!0,convert_fonts_to_spans:!0,indent:!0,indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,summary,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",entity_encoding:"named",url_converter:v.convertURL,url_converter_scope:v},y=_e(_e({},b),h?Rv:{}),!1!==(C=iv(Nv||_v,Nv,y,m,g)).deprecation_warnings&&ev(g,C),C),this.settings.suffix&&(n.suffix=this.settings.suffix),this.suffix=n.suffix,this.settings.base_url&&n._setBaseUrl(this.settings.base_url),this.baseUri=n.baseURI,this.settings.referrer_policy&&(ru.ScriptLoader._setReferrerPolicy(this.settings.referrer_policy),Za.DOM.styleSheetLoader._setReferrerPolicy(this.settings.referrer_policy)),lu.languageLoad=this.settings.language_load,lu.baseURL=n.baseURL,this.id=e,this.setDirty(!1),this.documentBaseURI=new Yd(this.settings.document_base_url,{base_uri:this.baseUri}),this.baseURI=this.baseUri,this.inline=!!this.settings.inline,this.shortcuts=new Sx(this),this.editorCommands=new G1(this),this.settings.cache_suffix&&(xt.cacheSuffix=this.settings.cache_suffix.replace(/^[\?\&]+/,"")),this.ui={registry:{addAutocompleter:(u={},(r={addButton:w(o={},"button"),addGroupToolbarButton:w(o,"grouptoolbarbutton"),addToggleButton:w(o,"togglebutton"),addMenuButton:w(o,"menubutton"),addSplitButton:w(o,"splitbutton"),addMenuItem:w(i={},"menuitem"),addNestedMenuItem:w(i,"nestedmenuitem"),addToggleMenuItem:w(i,"togglemenuitem"),addAutocompleter:w(a={},"autocompleter"),addContextMenu:w(s={},"contextmenu"),addContextToolbar:w(c={},"contexttoolbar"),addContextForm:w(c,"contextform"),addSidebar:w(l={},"sidebar"),addIcon:function(e,t){return u[e.toLowerCase()]=t},getAll:function(){return{buttons:o,menuItems:i,icons:u,popups:a,contextMenus:s,contextToolbars:c,sidebars:l}}}).addAutocompleter),addButton:r.addButton,addContextForm:r.addContextForm,addContextMenu:r.addContextMenu,addContextToolbar:r.addContextToolbar,addIcon:r.addIcon,addMenuButton:r.addMenuButton,addMenuItem:r.addMenuItem,addNestedMenuItem:r.addNestedMenuItem,addSidebar:r.addSidebar,addSplitButton:r.addSplitButton,addToggleButton:r.addToggleButton,addGroupToolbarButton:r.addGroupToolbarButton,addToggleMenuItem:r.addToggleMenuItem,getAll:r.getAll},styleSheetLoader:void 0,show:te,hide:te,enable:te,disable:te,isDisabled:D};var S,E,k,N,_,A=(N=iu("design"),_=iu({design:{activate:te,deactivate:te,editorReadOnly:!1},readonly:{activate:te,deactivate:te,editorReadOnly:!0}}),(E=S=this).serializer?rx(E):E.on("PreInit",function(){rx(E)}),(k=S).on("ShowCaret",function(e){nx(k)&&e.preventDefault()}),k.on("ObjectSelected",function(e){nx(k)&&e.preventDefault()}),{isReadOnly:function(){return nx(S)},set:function(e){return function(e,t,n,r){if(r!==n.get()){if(!ke(t,r))throw new Error("Editor mode '"+r+"' is invalid");e.initialized?dx(e,n,t,r):e.on("init",function(){return dx(e,n,t,r)})}}(S,_.get(),N,e)},get:function(){return N.get()},register:function(e,t){_.set(function(e,t,n){var r;if(T(bx,t))throw new Error("Cannot override default mode "+t);return _e(_e({},e),((r={})[t]=_e(_e({},n),{deactivate:function(){try{n.deactivate()}catch(e){console.error("problem while deactivating editor mode "+t+":",e)}}}),r))}(_.get(),e,t))}});this.mode=A,this.setMode=A.set,n.fire("SetupEditor",{editor:this}),this.execCallback("setup",this),this.$=Xa.overrideDefaults(function(){return{context:x.inline?x.getBody():x.getDoc(),element:x.getBody()}})}function Ox(t){var n=t.type;Fx($x.get(),function(e){switch(n){case"scroll":e.fire("ScrollWindow",t);break;case"resize":e.fire("ResizeWindow",t)}})}function Bx(e){e!==Hx&&(e?Xa(window).on("resize scroll",Ox):Xa(window).off("resize scroll",Ox),Hx=e)}function Px(t){var e=Vx;delete jx[t.id];for(var n=0;n<jx.length;n++)if(jx[n]===t){jx.splice(n,1);break}return Vx=U(Vx,function(e){return t!==e}),$x.activeEditor===t&&($x.activeEditor=0<Vx.length?Vx[0]:null),$x.focusedEditor===t&&($x.focusedEditor=null),e.length!==Vx.length}var Lx,Ix=Za.DOM,Mx=Et.explode,Fx=Et.each,Ux=Et.extend,zx=0,Hx=!1,jx=[],Vx=[],qx="CSS1Compat"!==document.compatMode,$x=_e(_e({},px),{baseURI:null,baseURL:null,defaultSettings:{},documentBaseURL:null,suffix:null,$:Xa,majorVersion:"5",minorVersion:"10.6",releaseDate:"2022-10-19",editors:jx,i18n:cu,activeEditor:null,focusedEditor:null,settings:{},setup:function(){var e,t="",n=Yd.getDocumentBaseUrl(document.location);/^[^:]+:\/\/\/?[^\/]+\//.test(n)&&(n=n.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(n)||(n+="/"));var r=window.tinymce||window.tinyMCEPreInit;if(r)e=r.base||r.baseURL,t=r.suffix;else{for(var o,i=document.getElementsByTagName("script"),a=0;a<i.length;a++)if(""!==(o=i[a].src||"")){var u=o.substring(o.lastIndexOf("/"));if(/tinymce(\.full|\.jquery|)(\.min|\.dev|)\.js/.test(o)){-1!==u.indexOf(".min")&&(t=".min"),e=o.substring(0,o.lastIndexOf("/"));break}}!e&&document.currentScript&&(-1!==(o=document.currentScript.src).indexOf(".min")&&(t=".min"),e=o.substring(0,o.lastIndexOf("/")))}this.baseURL=new Yd(n).toAbsolute(e),this.documentBaseURL=n,this.baseURI=new Yd(this.baseURL),this.suffix=t,this.on("AddEditor",R(pd,this)),this.on("RemoveEditor",R(hd,this))},overrideDefaults:function(e){var t=e.base_url;t&&this._setBaseUrl(t);var n=e.suffix;e.suffix&&(this.suffix=n);var r=(this.defaultSettings=e).plugin_base_urls;void 0!==r&&ne(r,function(e,t){lu.PluginManager.urls[t]=e})},init:function(r){function u(e){var t=e.id;return t||(t=ue(e,"name").filter(function(e){return!Ix.get(e)}).getOrThunk(Ix.uniqueId),e.setAttribute("id",t)),t}function s(e,t){return t.constructor===RegExp?t.test(e.className):Ix.hasClass(e,t)}var n,c=this,l=Et.makeMap("area base basefont br col frame hr img input isindex link meta param embed source wbr track colgroup option table tbody tfoot thead tr th td script noscript style textarea video audio iframe object menu"," "),f=function(e){n=e},t=function(){function n(e,t,n){var r=new Dx(e,t,c);a.push(r),r.on("init",function(){++i===o.length&&f(a)}),r.targetElm=r.targetElm||n,r.render()}var o,e,i=0,a=[];Ix.unbind(window,"ready",t),(e=r.onpageload)&&e.apply(c,[]),o=Xa.unique(function(t){var n=[];if(xt.browser.isIE()&&xt.browser.version.major<11)return cy("TinyMCE does not support the browser you are using. For a list of supported browsers please see: https://www.tinymce.com/docs/get-started/system-requirements/"),[];if(qx)return cy("Failed to initialize the editor as the document is not in standards mode. TinyMCE requires standards mode."),[];if(t.types)return Fx(t.types,function(e){n=n.concat(Ix.select(e.selector))}),n;if(t.selector)return Ix.select(t.selector);if(t.target)return[t.target];switch(t.mode){case"exact":var e=t.elements||"";0<e.length&&Fx(Mx(e),function(t){var e=Ix.get(t);e?n.push(e):Fx(document.forms,function(e){Fx(e.elements,function(e){e.name===t&&(t="mce_editor_"+zx++,Ix.setAttrib(e,"id",t),n.push(e))})})});break;case"textareas":case"specific_textareas":Fx(Ix.select("textarea"),function(e){t.editor_deselector&&s(e,t.editor_deselector)||t.editor_selector&&!s(e,t.editor_selector)||n.push(e)})}return n}(r)),r.types?Fx(r.types,function(t){Et.each(o,function(e){return!Ix.is(e,t.selector)||(n(u(e),Ux({},r,t),e),!1)})}):(Et.each(o,function(e){var t;(t=c.get(e.id))&&t.initialized&&!(t.getContainer()||t.getBody()).parentNode&&(Px(t),t.unbindAllNativeEvents(),t.destroy(!0),t.removed=!0)}),0===(o=Et.grep(o,function(e){return!c.get(e.id)})).length?f([]):Fx(o,function(e){var t=e;r.inline&&t.tagName.toLowerCase()in l?cy("Could not initialize inline editor on invalid inline target element",e):n(u(e),r,e)}))};return c.settings=r,Ix.bind(window,"ready",t),new Nr(function(t){n?t(n):f=function(e){t(e)}})},get:function(t){return 0===arguments.length?Vx.slice(0):X(t)?M(Vx,function(e){return e.id===t}).getOr(null):E(t)&&Vx[t]||null},add:function(e){var n=this;return jx[e.id]===e||(null===n.get(e.id)&&("length"!==e.id&&(jx[e.id]=e),jx.push(e),Vx.push(e)),Bx(!0),n.activeEditor=e,n.fire("AddEditor",{editor:e}),Lx||(Lx=function(e){var t=n.fire("BeforeUnload");if(t.returnValue)return e.preventDefault(),e.returnValue=t.returnValue,t.returnValue},window.addEventListener("beforeunload",Lx))),e},createEditor:function(e,t){return this.add(new Dx(e,t,this))},remove:function(e){var t,n,r=this;if(e){if(!X(e))return n=e,l(r.get(n.id))?null:(Px(n)&&r.fire("RemoveEditor",{editor:n}),0===Vx.length&&window.removeEventListener("beforeunload",Lx),n.remove(),Bx(0<Vx.length),n);Fx(Ix.select(e),function(e){(n=r.get(e.id))&&r.remove(n)})}else for(t=Vx.length-1;0<=t;t--)r.remove(Vx[t])},execCommand:function(e,t,n){var r=this.get(n);switch(e){case"mceAddEditor":return this.get(n)||new Dx(n,this.settings,this).render(),!0;case"mceRemoveEditor":return r&&r.remove(),!0;case"mceToggleEditor":return r?r.isHidden()?r.show():r.hide():this.execCommand("mceAddEditor",!1,n),!0}return!!this.activeEditor&&this.activeEditor.execCommand(e,t,n)},triggerSave:function(){Fx(Vx,function(e){e.save()})},addI18n:function(e,t){cu.add(e,t)},translate:function(e){return cu.translate(e)},setActive:function(e){var t=this.activeEditor;this.activeEditor!==e&&(t&&t.fire("deactivate",{relatedTarget:e}),e.fire("activate",{relatedTarget:t})),this.activeEditor=e},_setBaseUrl:function(e){this.baseURL=new Yd(this.documentBaseURL).toAbsolute(e.replace(/\/+$/,"")),this.baseURI=new Yd(this.baseURL)}});function Wx(e,t,n){var r=t.x,o=t.y,i=e.w,a=e.h,u=t.w,s=t.h,c=(n||"").split("");return"b"===c[0]&&(o+=s),"r"===c[1]&&(r+=u),"c"===c[0]&&(o+=tw(s/2)),"c"===c[1]&&(r+=tw(u/2)),"b"===c[3]&&(o-=a),"r"===c[4]&&(r-=i),"c"===c[3]&&(o-=tw(a/2)),"c"===c[4]&&(r-=tw(i/2)),Xx(r,o,i,a)}function Kx(){}$x.setup();function Xx(e,t,n,r){return{x:e,y:t,w:n,h:r}}var Yx,Gx,Jx,Qx,Zx=Math.min,ew=Math.max,tw=Math.round,nw={inflate:function(e,t,n){return Xx(e.x-t,e.y-n,e.w+2*t,e.h+2*n)},relativePosition:Wx,findBestRelativePosition:function(e,t,n,r){for(var o,i=0;i<r.length;i++)if((o=Wx(e,t,r[i])).x>=n.x&&o.x+o.w<=n.w+n.x&&o.y>=n.y&&o.y+o.h<=n.h+n.y)return r[i];return null},intersect:function(e,t){var n=ew(e.x,t.x),r=ew(e.y,t.y),o=Zx(e.x+e.w,t.x+t.w),i=Zx(e.y+e.h,t.y+t.h);return o-n<0||i-r<0?null:Xx(n,r,o-n,i-r)},clamp:function(e,t,n){var r=e.x,o=e.y,i=e.x+e.w,a=e.y+e.h,u=t.x+t.w,s=t.y+t.h,c=ew(0,t.x-r),l=ew(0,t.y-o),f=ew(0,i-u),d=ew(0,a-s);return r+=c,o+=l,n&&(i+=c,a+=l,r-=f,o-=d),Xx(r,o,(i-=f)-r,(a-=d)-o)},create:Xx,fromClientRect:function(e){return Xx(e.left,e.top,e.width,e.height)}},rw=(Yx={},Gx={},{load:function(r,o){var i='Script at URL "'+o+'" failed to load',a='Script at URL "'+o+"\" did not call `tinymce.Resource.add('"+r+"', data)` within 1 second";if(void 0!==Yx[r])return Yx[r];var e=new Nr(function(e,t){var n=function(e,t,n){function r(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o||(o=!0,null!==i&&(clearTimeout(i),i=null),n.apply(null,e))}}void 0===n&&(n=1e3);var o=!1,i=null,a=r(e),u=r(t);return{start:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o||null!==i||(i=setTimeout(function(){return u.apply(null,e)},n))},resolve:a,reject:u}}(e,t);Gx[r]=n.resolve,ru.ScriptLoader.loadScript(o,function(){return n.start(a)},function(){return n.reject(i)})});return Yx[r]=e},add:function(e,t){void 0!==Gx[e]&&(Gx[e](t),delete Gx[e]),Yx[e]=Nr.resolve(t)}}),ow=Et.each,iw=Et.extend;Kx.extend=Jx=function(n){function r(){var e,t,n;if(!Qx&&(this.init&&this.init.apply(this,arguments),t=this.Mixins))for(e=t.length;e--;)(n=t[e]).init&&n.init.apply(this,arguments)}function t(){return this}var o=this.prototype;Qx=!0;var i=new this;return Qx=!1,n.Mixins&&(ow(n.Mixins,function(e){for(var t in e)"init"!==t&&(n[t]=e[t])}),o.Mixins&&(n.Mixins=o.Mixins.concat(n.Mixins))),n.Methods&&ow(n.Methods.split(","),function(e){n[e]=t}),n.Properties&&ow(n.Properties.split(","),function(e){var t="_"+e;n[e]=function(e){return void 0!==e?(this[t]=e,this):this[t]}}),n.Statics&&ow(n.Statics,function(e,t){r[t]=e}),n.Defaults&&o.Defaults&&(n.Defaults=iw({},o.Defaults,n.Defaults)),ne(n,function(e,t){var n,r;"function"==typeof e&&o[t]?i[t]=(n=t,r=e,function(){var e=this._super;this._super=o[n];var t=r.apply(this,arguments);return this._super=e,t}):i[t]=e}),r.prototype=i,(r.constructor=r).extend=Jx,r};var aw,uw,sw,cw=Math.min,lw=Math.max,fw=Math.round,dw={serialize:function(e){var t=JSON.stringify(e);return X(t)?t.replace(/[\u0080-\uFFFF]/g,function(e){var t=e.charCodeAt(0).toString(16);return"\\u"+"0000".substring(t.length)+t}):t},parse:function(e){try{return JSON.parse(e)}catch(e){}}},mw={callbacks:{},count:0,send:function(t){var n=this,r=Za.DOM,o=(void 0!==t.count?t:n).count,i="tinymce_jsonp_"+o;n.callbacks[o]=function(e){r.remove(i),delete n.callbacks[o],t.callback(e)},r.add(r.doc.body,"script",{id:i,src:t.url,type:"text/javascript"}),n.count++}},gw=_e(_e({},px),{send:function(e){var t,n=0,r=function(){!e.async||4===t.readyState||1e4<n++?(e.success&&n<1e4&&200===t.status?e.success.call(e.success_scope,""+t.responseText,t,e):e.error&&e.error.call(e.error_scope,1e4<n?"TIMED_OUT":"GENERAL",t,e),t=null):_r.setTimeout(r,10)};if(e.scope=e.scope||this,e.success_scope=e.success_scope||e.scope,e.error_scope=e.error_scope||e.scope,e.async=!1!==e.async,e.data=e.data||"",gw.fire("beforeInitialize",{settings:e}),(t=new XMLHttpRequest).overrideMimeType&&t.overrideMimeType(e.content_type),t.open(e.type||(e.data?"POST":"GET"),e.url,e.async),e.crossDomain&&(t.withCredentials=!0),e.content_type&&t.setRequestHeader("Content-Type",e.content_type),e.requestheaders&&Et.each(e.requestheaders,function(e){t.setRequestHeader(e.key,e.value)}),t.setRequestHeader("X-Requested-With","XMLHttpRequest"),(t=gw.fire("beforeSend",{xhr:t,settings:e}).xhr).send(e.data),!e.async)return r();_r.setTimeout(r,10)}}),pw=Et.extend,hw=(vw.sendRPC=function(e){return(new vw).send(e)},vw.prototype.send=function(e){var n=e.error,r=e.success,o=pw(this.settings,e);o.success=function(e,t){(e=void 0===(e=dw.parse(e))?{error:"JSON Parse error."}:e).error?n.call(o.error_scope||o.scope,e.error,t):r.call(o.success_scope||o.scope,e.result)},o.error=function(e,t){n&&n.call(o.error_scope||o.scope,e,t)},o.data=dw.serialize({id:e.id||"c"+this.count++,method:e.method,params:e.params}),o.content_type="application/json",gw.send(o)},vw);function vw(e){this.settings=pw({},e),this.count=0}try{var bw,yw="__storage_test__";(bw=window.localStorage).setItem(yw,yw),bw.removeItem(yw)}catch(e){aw={},uw=[],sw={getItem:function(e){return aw[e]||null},setItem:function(e,t){uw.push(e),aw[e]=String(t)},key:function(e){return uw[e]},removeItem:function(t){uw=uw.filter(function(e){return e===t}),delete aw[t]},clear:function(){uw=[],aw={}},length:0},Object.defineProperty(sw,"length",{get:function(){return uw.length},configurable:!1,enumerable:!1}),bw=sw}var Cw={geom:{Rect:nw},util:{Promise:Nr,Delay:_r,Tools:Et,VK:Lf,URI:Yd,Class:Kx,EventDispatcher:ax,Observable:px,I18n:cu,XHR:gw,JSON:dw,JSONRequest:hw,JSONP:mw,LocalStorage:bw,Color:function(e){function t(e){var t;return"object"==typeof e?"r"in e?(u=e.r,s=e.g,c=e.b):"v"in e&&function(e,t,n){if(e=(parseInt(e,10)||0)%360,t=parseInt(t,10)/100,n=parseInt(n,10)/100,t=lw(0,cw(t,1)),n=lw(0,cw(n,1)),0!==t){var r=e/60,o=n*t,i=o*(1-Math.abs(r%2-1)),a=n-o;switch(Math.floor(r)){case 0:u=o,s=i,c=0;break;case 1:u=i,s=o,c=0;break;case 2:u=0,s=o,c=i;break;case 3:u=0,s=i,c=o;break;case 4:u=i,s=0,c=o;break;case 5:u=o,s=0,c=i;break;default:u=s=c=0}u=fw(255*(u+a)),s=fw(255*(s+a)),c=fw(255*(c+a))}else u=s=c=fw(255*n)}(e.h,e.s,e.v):(t=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)[^\)]*\)/gi.exec(e))?(u=parseInt(t[1],10),s=parseInt(t[2],10),c=parseInt(t[3],10)):(t=/#([0-F]{2})([0-F]{2})([0-F]{2})/gi.exec(e))?(u=parseInt(t[1],16),s=parseInt(t[2],16),c=parseInt(t[3],16)):(t=/#([0-F])([0-F])([0-F])/gi.exec(e))&&(u=parseInt(t[1]+t[1],16),s=parseInt(t[2]+t[2],16),c=parseInt(t[3]+t[3],16)),u=u<0?0:255<u?255:u,s=s<0?0:255<s?255:s,c=c<0?0:255<c?255:c,n}var n={},u=0,s=0,c=0;return e&&t(e),n.toRgb=function(){return{r:u,g:s,b:c}},n.toHsv=function(){return e=u,t=s,n=c,o=0,(i=cw(e/=255,cw(t/=255,n/=255)))===(a=lw(e,lw(t,n)))?{h:0,s:0,v:100*(o=i)}:(r=(a-i)/a,{h:fw(60*((e===i?3:n===i?1:5)-(e===i?t-n:n===i?e-t:n-e)/((o=a)-i))),s:fw(100*r),v:fw(100*o)});var e,t,n,r,o,i,a},n.toHex=function(){function e(e){return 1<(e=parseInt(e,10).toString(16)).length?e:"0"+e}return"#"+e(u)+e(s)+e(c)},n.parse=t,n},ImageUploader:function(n){var e=qv(),r=Yv(n,e);return{upload:function(e,t){return r.upload(e,(t=void 0===t||t)?Xv(n):void 0)}}}},dom:{EventUtils:si,Sizzle:sa,DomQuery:Xa,TreeWalker:Rr,TextSeeker:_u,DOMUtils:Za,ScriptLoader:ru,RangeUtils:Pf,Serializer:Jh,StyleSheetLoader:wr,ControlSelection:wf,BookmarkManager:zl,Selection:Fh,Event:si.Event},html:{Styles:io,Entities:Qo,Node:Hd,Schema:ro,SaxParser:Qd,DomParser:Xh,Writer:om,Serializer:im},Env:xt,AddOnManager:lu,Annotator:Ul,Formatter:eb,UndoManager:nb,EditorCommands:G1,WindowManager:Mv,NotificationManager:lv,EditorObservable:vx,Shortcuts:Sx,Editor:Dx,FocusManager:Md,EditorManager:$x,DOM:Za.DOM,ScriptLoader:ru.ScriptLoader,PluginManager:Lv,ThemeManager:Iv,IconManager:Dv,Resource:rw,trim:Et.trim,isArray:Et.isArray,is:Et.is,toArray:Et.toArray,makeMap:Et.makeMap,each:Et.each,map:Et.map,grep:Et.grep,inArray:Et.inArray,extend:Et.extend,create:Et.create,walk:Et.walk,createNS:Et.createNS,resolve:Et.resolve,explode:Et.explode,_addCacheSuffix:Et._addCacheSuffix,isOpera:xt.opera,isWebKit:xt.webkit,isIE:xt.ie,isGecko:xt.gecko,isMac:xt.mac},xw=Et.extend($x,Cw),ww=xw;window.tinymce=ww,window.tinyMCE=ww,function(e){if("object"==typeof module)try{module.exports=e}catch(e){}}(xw)}();
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var eq$1 = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isObject = isType$1('object');
|
|
var isArray = isType$1('array');
|
|
var isNull = eq$1(null);
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isUndefined = eq$1(undefined);
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
var isNumber = isSimpleType('number');
|
|
var isArrayOf = function (value, pred) {
|
|
if (isArray(value)) {
|
|
for (var i = 0, len = value.length; i < len; ++i) {
|
|
if (!pred(value[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
var noop = function () {
|
|
};
|
|
var noarg = function (f) {
|
|
return function () {
|
|
return f();
|
|
};
|
|
};
|
|
var compose = function (fa, fb) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return fa(fb.apply(null, args));
|
|
};
|
|
};
|
|
var compose1 = function (fbc, fab) {
|
|
return function (a) {
|
|
return fbc(fab(a));
|
|
};
|
|
};
|
|
var constant$1 = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity$1 = function (x) {
|
|
return x;
|
|
};
|
|
var tripleEquals = function (a, b) {
|
|
return a === b;
|
|
};
|
|
function curry(fn) {
|
|
var initialArgs = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
initialArgs[_i - 1] = arguments[_i];
|
|
}
|
|
return function () {
|
|
var restArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
restArgs[_i] = arguments[_i];
|
|
}
|
|
var all = initialArgs.concat(restArgs);
|
|
return fn.apply(null, all);
|
|
};
|
|
}
|
|
var not = function (f) {
|
|
return function (t) {
|
|
return !f(t);
|
|
};
|
|
};
|
|
var die = function (msg) {
|
|
return function () {
|
|
throw new Error(msg);
|
|
};
|
|
};
|
|
var never = constant$1(false);
|
|
var always = constant$1(true);
|
|
|
|
var global$g = tinymce.util.Tools.resolve('tinymce.ThemeManager');
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
function __rest(s, e) {
|
|
var t = {};
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
t[p] = s[p];
|
|
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
|
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
t[p[i]] = s[p[i]];
|
|
}
|
|
return t;
|
|
}
|
|
function __spreadArray(to, from, pack) {
|
|
if (pack || arguments.length === 2)
|
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
if (ar || !(i in from)) {
|
|
if (!ar)
|
|
ar = Array.prototype.slice.call(from, 0, i);
|
|
ar[i] = from[i];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
}
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity$1;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant$1(null),
|
|
getOrUndefined: constant$1(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant$1('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant$1(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from$1 = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from$1
|
|
};
|
|
|
|
var nativeSlice = Array.prototype.slice;
|
|
var nativeIndexOf = Array.prototype.indexOf;
|
|
var nativePush = Array.prototype.push;
|
|
var rawIndexOf = function (ts, t) {
|
|
return nativeIndexOf.call(ts, t);
|
|
};
|
|
var indexOf = function (xs, x) {
|
|
var r = rawIndexOf(xs, x);
|
|
return r === -1 ? Optional.none() : Optional.some(r);
|
|
};
|
|
var contains$2 = function (xs, x) {
|
|
return rawIndexOf(xs, x) > -1;
|
|
};
|
|
var exists = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var range$2 = function (num, f) {
|
|
var r = [];
|
|
for (var i = 0; i < num; i++) {
|
|
r.push(f(i));
|
|
}
|
|
return r;
|
|
};
|
|
var chunk$1 = function (array, size) {
|
|
var r = [];
|
|
for (var i = 0; i < array.length; i += size) {
|
|
var s = nativeSlice.call(array, i, i + size);
|
|
r.push(s);
|
|
}
|
|
return r;
|
|
};
|
|
var map$2 = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var eachr = function (xs, f) {
|
|
for (var i = xs.length - 1; i >= 0; i--) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var partition$3 = function (xs, pred) {
|
|
var pass = [];
|
|
var fail = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
var arr = pred(x, i) ? pass : fail;
|
|
arr.push(x);
|
|
}
|
|
return {
|
|
pass: pass,
|
|
fail: fail
|
|
};
|
|
};
|
|
var filter$2 = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var foldr = function (xs, f, acc) {
|
|
eachr(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each$1(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find$5 = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var findIndex$1 = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(i);
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind$3 = function (xs, f) {
|
|
return flatten(map$2(xs, f));
|
|
};
|
|
var forall = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
var x = xs[i];
|
|
if (pred(x, i) !== true) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
var reverse = function (xs) {
|
|
var r = nativeSlice.call(xs, 0);
|
|
r.reverse();
|
|
return r;
|
|
};
|
|
var difference = function (a1, a2) {
|
|
return filter$2(a1, function (x) {
|
|
return !contains$2(a2, x);
|
|
});
|
|
};
|
|
var mapToObject = function (xs, f) {
|
|
var r = {};
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
r[String(x)] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var pure$2 = function (x) {
|
|
return [x];
|
|
};
|
|
var sort = function (xs, comparator) {
|
|
var copy = nativeSlice.call(xs, 0);
|
|
copy.sort(comparator);
|
|
return copy;
|
|
};
|
|
var get$f = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get$f(xs, 0);
|
|
};
|
|
var last$2 = function (xs) {
|
|
return get$f(xs, xs.length - 1);
|
|
};
|
|
var from = isFunction(Array.from) ? Array.from : function (x) {
|
|
return nativeSlice.call(x);
|
|
};
|
|
var findMap = function (arr, f) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var r = f(arr[i], i);
|
|
if (r.isSome()) {
|
|
return r;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var map$1 = function (obj, f) {
|
|
return tupleMap(obj, function (x, i) {
|
|
return {
|
|
k: i,
|
|
v: f(x, i)
|
|
};
|
|
});
|
|
};
|
|
var tupleMap = function (obj, f) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
var tuple = f(x, i);
|
|
r[tuple.k] = tuple.v;
|
|
});
|
|
return r;
|
|
};
|
|
var objAcc = function (r) {
|
|
return function (x, i) {
|
|
r[i] = x;
|
|
};
|
|
};
|
|
var internalFilter = function (obj, pred, onTrue, onFalse) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
});
|
|
return r;
|
|
};
|
|
var filter$1 = function (obj, pred) {
|
|
var t = {};
|
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
return t;
|
|
};
|
|
var mapToArray = function (obj, f) {
|
|
var r = [];
|
|
each(obj, function (value, name) {
|
|
r.push(f(value, name));
|
|
});
|
|
return r;
|
|
};
|
|
var find$4 = function (obj, pred) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
if (pred(x, i, obj)) {
|
|
return Optional.some(x);
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var values = function (obj) {
|
|
return mapToArray(obj, identity$1);
|
|
};
|
|
var get$e = function (obj, key) {
|
|
return has$2(obj, key) ? Optional.from(obj[key]) : Optional.none();
|
|
};
|
|
var has$2 = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
var hasNonNullableKey = function (obj, key) {
|
|
return has$2(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
};
|
|
|
|
var is$1 = function (lhs, rhs, comparator) {
|
|
if (comparator === void 0) {
|
|
comparator = tripleEquals;
|
|
}
|
|
return lhs.exists(function (left) {
|
|
return comparator(left, rhs);
|
|
});
|
|
};
|
|
var equals = function (lhs, rhs, comparator) {
|
|
if (comparator === void 0) {
|
|
comparator = tripleEquals;
|
|
}
|
|
return lift2(lhs, rhs, comparator).getOr(lhs.isNone() && rhs.isNone());
|
|
};
|
|
var cat = function (arr) {
|
|
var r = [];
|
|
var push = function (x) {
|
|
r.push(x);
|
|
};
|
|
for (var i = 0; i < arr.length; i++) {
|
|
arr[i].each(push);
|
|
}
|
|
return r;
|
|
};
|
|
var sequence = function (arr) {
|
|
var r = [];
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var x = arr[i];
|
|
if (x.isSome()) {
|
|
r.push(x.getOrDie());
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
return Optional.some(r);
|
|
};
|
|
var lift2 = function (oa, ob, f) {
|
|
return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
|
|
};
|
|
var lift3 = function (oa, ob, oc, f) {
|
|
return oa.isSome() && ob.isSome() && oc.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie(), oc.getOrDie())) : Optional.none();
|
|
};
|
|
var mapFrom = function (a, f) {
|
|
return a !== undefined && a !== null ? Optional.some(f(a)) : Optional.none();
|
|
};
|
|
var someIf = function (b, a) {
|
|
return b ? Optional.some(a) : Optional.none();
|
|
};
|
|
|
|
var addToEnd = function (str, suffix) {
|
|
return str + suffix;
|
|
};
|
|
var removeFromStart = function (str, numChars) {
|
|
return str.substring(numChars);
|
|
};
|
|
|
|
var checkRange = function (str, substr, start) {
|
|
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
};
|
|
var removeLeading = function (str, prefix) {
|
|
return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
|
|
};
|
|
var ensureTrailing = function (str, suffix) {
|
|
return endsWith(str, suffix) ? str : addToEnd(str, suffix);
|
|
};
|
|
var contains$1 = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
var startsWith = function (str, prefix) {
|
|
return checkRange(str, prefix, 0);
|
|
};
|
|
var endsWith = function (str, suffix) {
|
|
return checkRange(str, suffix, str.length - suffix.length);
|
|
};
|
|
var blank = function (r) {
|
|
return function (s) {
|
|
return s.replace(r, '');
|
|
};
|
|
};
|
|
var trim$1 = blank(/^\s+|\s+$/g);
|
|
var isNotEmpty = function (s) {
|
|
return s.length > 0;
|
|
};
|
|
var isEmpty = function (s) {
|
|
return !isNotEmpty(s);
|
|
};
|
|
|
|
var isSupported$1 = function (dom) {
|
|
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
};
|
|
|
|
var fromHtml$2 = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml$2,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var DOCUMENT = 9;
|
|
var DOCUMENT_FRAGMENT = 11;
|
|
var ELEMENT = 1;
|
|
var TEXT = 3;
|
|
|
|
var name$2 = function (element) {
|
|
var r = element.dom.nodeName;
|
|
return r.toLowerCase();
|
|
};
|
|
var type = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type(element) === t;
|
|
};
|
|
};
|
|
var isElement$2 = isType(ELEMENT);
|
|
var isText$1 = isType(TEXT);
|
|
var isDocument = isType(DOCUMENT);
|
|
var isDocumentFragment = isType(DOCUMENT_FRAGMENT);
|
|
|
|
var cached = function (f) {
|
|
var called = false;
|
|
var r;
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (!called) {
|
|
called = true;
|
|
r = f.apply(null, args);
|
|
}
|
|
return r;
|
|
};
|
|
};
|
|
|
|
var DeviceType = function (os, browser, userAgent, mediaMatch) {
|
|
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
|
|
var isiPhone = os.isiOS() && !isiPad;
|
|
var isMobile = os.isiOS() || os.isAndroid();
|
|
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
|
|
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
|
|
var isPhone = isiPhone || isMobile && !isTablet;
|
|
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
|
|
var isDesktop = !isPhone && !isTablet && !iOSwebview;
|
|
return {
|
|
isiPad: constant$1(isiPad),
|
|
isiPhone: constant$1(isiPhone),
|
|
isTablet: constant$1(isTablet),
|
|
isPhone: constant$1(isPhone),
|
|
isTouch: constant$1(isTouch),
|
|
isAndroid: os.isAndroid,
|
|
isiOS: os.isiOS,
|
|
isWebView: constant$1(iOSwebview),
|
|
isDesktop: constant$1(isDesktop)
|
|
};
|
|
};
|
|
|
|
var firstMatch = function (regexes, s) {
|
|
for (var i = 0; i < regexes.length; i++) {
|
|
var x = regexes[i];
|
|
if (x.test(s)) {
|
|
return x;
|
|
}
|
|
}
|
|
return undefined;
|
|
};
|
|
var find$3 = function (regexes, agent) {
|
|
var r = firstMatch(regexes, agent);
|
|
if (!r) {
|
|
return {
|
|
major: 0,
|
|
minor: 0
|
|
};
|
|
}
|
|
var group = function (i) {
|
|
return Number(agent.replace(r, '$' + i));
|
|
};
|
|
return nu$d(group(1), group(2));
|
|
};
|
|
var detect$4 = function (versionRegexes, agent) {
|
|
var cleanedAgent = String(agent).toLowerCase();
|
|
if (versionRegexes.length === 0) {
|
|
return unknown$3();
|
|
}
|
|
return find$3(versionRegexes, cleanedAgent);
|
|
};
|
|
var unknown$3 = function () {
|
|
return nu$d(0, 0);
|
|
};
|
|
var nu$d = function (major, minor) {
|
|
return {
|
|
major: major,
|
|
minor: minor
|
|
};
|
|
};
|
|
var Version = {
|
|
nu: nu$d,
|
|
detect: detect$4,
|
|
unknown: unknown$3
|
|
};
|
|
|
|
var detectBrowser$1 = function (browsers, userAgentData) {
|
|
return findMap(userAgentData.brands, function (uaBrand) {
|
|
var lcBrand = uaBrand.brand.toLowerCase();
|
|
return find$5(browsers, function (browser) {
|
|
var _a;
|
|
return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
}).map(function (info) {
|
|
return {
|
|
current: info.name,
|
|
version: Version.nu(parseInt(uaBrand.version, 10), 0)
|
|
};
|
|
});
|
|
});
|
|
};
|
|
|
|
var detect$3 = function (candidates, userAgent) {
|
|
var agent = String(userAgent).toLowerCase();
|
|
return find$5(candidates, function (candidate) {
|
|
return candidate.search(agent);
|
|
});
|
|
};
|
|
var detectBrowser = function (browsers, userAgent) {
|
|
return detect$3(browsers, userAgent).map(function (browser) {
|
|
var version = Version.detect(browser.versionRegexes, userAgent);
|
|
return {
|
|
current: browser.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
var detectOs = function (oses, userAgent) {
|
|
return detect$3(oses, userAgent).map(function (os) {
|
|
var version = Version.detect(os.versionRegexes, userAgent);
|
|
return {
|
|
current: os.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
|
|
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
|
|
var checkContains = function (target) {
|
|
return function (uastring) {
|
|
return contains$1(uastring, target);
|
|
};
|
|
};
|
|
var browsers = [
|
|
{
|
|
name: 'Edge',
|
|
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
|
|
}
|
|
},
|
|
{
|
|
name: 'Chrome',
|
|
brand: 'Chromium',
|
|
versionRegexes: [
|
|
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
|
|
normalVersionRegex
|
|
],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');
|
|
}
|
|
},
|
|
{
|
|
name: 'IE',
|
|
versionRegexes: [
|
|
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*?rv:([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'msie') || contains$1(uastring, 'trident');
|
|
}
|
|
},
|
|
{
|
|
name: 'Opera',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?opera\/([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: checkContains('opera')
|
|
},
|
|
{
|
|
name: 'Firefox',
|
|
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
|
|
search: checkContains('firefox')
|
|
},
|
|
{
|
|
name: 'Safari',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?cpu os ([0-9]+)_([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');
|
|
}
|
|
}
|
|
];
|
|
var oses = [
|
|
{
|
|
name: 'Windows',
|
|
search: checkContains('win'),
|
|
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'iOS',
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad');
|
|
},
|
|
versionRegexes: [
|
|
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*cpu os ([0-9]+)_([0-9]+).*/,
|
|
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
|
|
]
|
|
},
|
|
{
|
|
name: 'Android',
|
|
search: checkContains('android'),
|
|
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'OSX',
|
|
search: checkContains('mac os x'),
|
|
versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'Linux',
|
|
search: checkContains('linux'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'Solaris',
|
|
search: checkContains('sunos'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'FreeBSD',
|
|
search: checkContains('freebsd'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'ChromeOS',
|
|
search: checkContains('cros'),
|
|
versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
|
|
}
|
|
];
|
|
var PlatformInfo = {
|
|
browsers: constant$1(browsers),
|
|
oses: constant$1(oses)
|
|
};
|
|
|
|
var edge = 'Edge';
|
|
var chrome = 'Chrome';
|
|
var ie = 'IE';
|
|
var opera = 'Opera';
|
|
var firefox = 'Firefox';
|
|
var safari = 'Safari';
|
|
var unknown$2 = function () {
|
|
return nu$c({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu$c = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isBrowser = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isEdge: isBrowser(edge),
|
|
isChrome: isBrowser(chrome),
|
|
isIE: isBrowser(ie),
|
|
isOpera: isBrowser(opera),
|
|
isFirefox: isBrowser(firefox),
|
|
isSafari: isBrowser(safari)
|
|
};
|
|
};
|
|
var Browser = {
|
|
unknown: unknown$2,
|
|
nu: nu$c,
|
|
edge: constant$1(edge),
|
|
chrome: constant$1(chrome),
|
|
ie: constant$1(ie),
|
|
opera: constant$1(opera),
|
|
firefox: constant$1(firefox),
|
|
safari: constant$1(safari)
|
|
};
|
|
|
|
var windows = 'Windows';
|
|
var ios = 'iOS';
|
|
var android = 'Android';
|
|
var linux = 'Linux';
|
|
var osx = 'OSX';
|
|
var solaris = 'Solaris';
|
|
var freebsd = 'FreeBSD';
|
|
var chromeos = 'ChromeOS';
|
|
var unknown$1 = function () {
|
|
return nu$b({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu$b = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isOS = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isWindows: isOS(windows),
|
|
isiOS: isOS(ios),
|
|
isAndroid: isOS(android),
|
|
isOSX: isOS(osx),
|
|
isLinux: isOS(linux),
|
|
isSolaris: isOS(solaris),
|
|
isFreeBSD: isOS(freebsd),
|
|
isChromeOS: isOS(chromeos)
|
|
};
|
|
};
|
|
var OperatingSystem = {
|
|
unknown: unknown$1,
|
|
nu: nu$b,
|
|
windows: constant$1(windows),
|
|
ios: constant$1(ios),
|
|
android: constant$1(android),
|
|
linux: constant$1(linux),
|
|
osx: constant$1(osx),
|
|
solaris: constant$1(solaris),
|
|
freebsd: constant$1(freebsd),
|
|
chromeos: constant$1(chromeos)
|
|
};
|
|
|
|
var detect$2 = function (userAgent, userAgentDataOpt, mediaMatch) {
|
|
var browsers = PlatformInfo.browsers();
|
|
var oses = PlatformInfo.oses();
|
|
var browser = userAgentDataOpt.bind(function (userAgentData) {
|
|
return detectBrowser$1(browsers, userAgentData);
|
|
}).orThunk(function () {
|
|
return detectBrowser(browsers, userAgent);
|
|
}).fold(Browser.unknown, Browser.nu);
|
|
var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
|
|
var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
|
|
return {
|
|
browser: browser,
|
|
os: os,
|
|
deviceType: deviceType
|
|
};
|
|
};
|
|
var PlatformDetection = { detect: detect$2 };
|
|
|
|
var mediaMatch = function (query) {
|
|
return window.matchMedia(query).matches;
|
|
};
|
|
var platform = cached(function () {
|
|
return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
|
|
});
|
|
var detect$1 = function () {
|
|
return platform();
|
|
};
|
|
|
|
var compareDocumentPosition = function (a, b, match) {
|
|
return (a.compareDocumentPosition(b) & match) !== 0;
|
|
};
|
|
var documentPositionContainedBy = function (a, b) {
|
|
return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY);
|
|
};
|
|
|
|
var is = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
var bypassSelector = function (dom) {
|
|
return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
|
|
};
|
|
var all$3 = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? [] : map$2(base.querySelectorAll(selector), SugarElement.fromDom);
|
|
};
|
|
var one = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
|
|
};
|
|
|
|
var eq = function (e1, e2) {
|
|
return e1.dom === e2.dom;
|
|
};
|
|
var regularContains = function (e1, e2) {
|
|
var d1 = e1.dom;
|
|
var d2 = e2.dom;
|
|
return d1 === d2 ? false : d1.contains(d2);
|
|
};
|
|
var ieContains = function (e1, e2) {
|
|
return documentPositionContainedBy(e1.dom, e2.dom);
|
|
};
|
|
var contains = function (e1, e2) {
|
|
return detect$1().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);
|
|
};
|
|
|
|
var owner$4 = function (element) {
|
|
return SugarElement.fromDom(element.dom.ownerDocument);
|
|
};
|
|
var documentOrOwner = function (dos) {
|
|
return isDocument(dos) ? dos : owner$4(dos);
|
|
};
|
|
var documentElement = function (element) {
|
|
return SugarElement.fromDom(documentOrOwner(element).dom.documentElement);
|
|
};
|
|
var defaultView = function (element) {
|
|
return SugarElement.fromDom(documentOrOwner(element).dom.defaultView);
|
|
};
|
|
var parent = function (element) {
|
|
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
};
|
|
var parentNode = function (element) {
|
|
return parent(element);
|
|
};
|
|
var offsetParent = function (element) {
|
|
return Optional.from(element.dom.offsetParent).map(SugarElement.fromDom);
|
|
};
|
|
var nextSibling = function (element) {
|
|
return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
|
|
};
|
|
var children = function (element) {
|
|
return map$2(element.dom.childNodes, SugarElement.fromDom);
|
|
};
|
|
var child$2 = function (element, index) {
|
|
var cs = element.dom.childNodes;
|
|
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
|
};
|
|
var firstChild = function (element) {
|
|
return child$2(element, 0);
|
|
};
|
|
var spot = function (element, offset) {
|
|
return {
|
|
element: element,
|
|
offset: offset
|
|
};
|
|
};
|
|
var leaf = function (element, offset) {
|
|
var cs = children(element);
|
|
return cs.length > 0 && offset < cs.length ? spot(cs[offset], 0) : spot(element, offset);
|
|
};
|
|
|
|
var isShadowRoot = function (dos) {
|
|
return isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
};
|
|
var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
|
|
var isSupported = constant$1(supported);
|
|
var getRootNode = supported ? function (e) {
|
|
return SugarElement.fromDom(e.dom.getRootNode());
|
|
} : documentOrOwner;
|
|
var getContentContainer = function (dos) {
|
|
return isShadowRoot(dos) ? dos : SugarElement.fromDom(documentOrOwner(dos).dom.body);
|
|
};
|
|
var isInShadowRoot = function (e) {
|
|
return getShadowRoot(e).isSome();
|
|
};
|
|
var getShadowRoot = function (e) {
|
|
var r = getRootNode(e);
|
|
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
};
|
|
var getShadowHost = function (e) {
|
|
return SugarElement.fromDom(e.dom.host);
|
|
};
|
|
var getOriginalEventTarget = function (event) {
|
|
if (isSupported() && isNonNullable(event.target)) {
|
|
var el = SugarElement.fromDom(event.target);
|
|
if (isElement$2(el) && isOpenShadowHost(el)) {
|
|
if (event.composed && event.composedPath) {
|
|
var composedPath = event.composedPath();
|
|
if (composedPath) {
|
|
return head(composedPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Optional.from(event.target);
|
|
};
|
|
var isOpenShadowHost = function (element) {
|
|
return isNonNullable(element.dom.shadowRoot);
|
|
};
|
|
|
|
var inBody = function (element) {
|
|
var dom = isText$1(element) ? element.dom.parentNode : element.dom;
|
|
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
return false;
|
|
}
|
|
var doc = dom.ownerDocument;
|
|
return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {
|
|
return doc.body.contains(dom);
|
|
}, compose1(inBody, getShadowHost));
|
|
};
|
|
var body = function () {
|
|
return getBody(SugarElement.fromDom(document));
|
|
};
|
|
var getBody = function (doc) {
|
|
var b = doc.dom.body;
|
|
if (b === null || b === undefined) {
|
|
throw new Error('Body is not available yet');
|
|
}
|
|
return SugarElement.fromDom(b);
|
|
};
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set$8 = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
var setAll$1 = function (element, attrs) {
|
|
var dom = element.dom;
|
|
each(attrs, function (v, k) {
|
|
rawSet(dom, k, v);
|
|
});
|
|
};
|
|
var get$d = function (element, key) {
|
|
var v = element.dom.getAttribute(key);
|
|
return v === null ? undefined : v;
|
|
};
|
|
var getOpt = function (element, key) {
|
|
return Optional.from(get$d(element, key));
|
|
};
|
|
var has$1 = function (element, key) {
|
|
var dom = element.dom;
|
|
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
|
|
};
|
|
var remove$7 = function (element, key) {
|
|
element.dom.removeAttribute(key);
|
|
};
|
|
|
|
var internalSet = function (dom, property, value) {
|
|
if (!isString(value)) {
|
|
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('CSS value must be a string: ' + value);
|
|
}
|
|
if (isSupported$1(dom)) {
|
|
dom.style.setProperty(property, value);
|
|
}
|
|
};
|
|
var internalRemove = function (dom, property) {
|
|
if (isSupported$1(dom)) {
|
|
dom.style.removeProperty(property);
|
|
}
|
|
};
|
|
var set$7 = function (element, property, value) {
|
|
var dom = element.dom;
|
|
internalSet(dom, property, value);
|
|
};
|
|
var setAll = function (element, css) {
|
|
var dom = element.dom;
|
|
each(css, function (v, k) {
|
|
internalSet(dom, k, v);
|
|
});
|
|
};
|
|
var setOptions = function (element, css) {
|
|
var dom = element.dom;
|
|
each(css, function (v, k) {
|
|
v.fold(function () {
|
|
internalRemove(dom, k);
|
|
}, function (value) {
|
|
internalSet(dom, k, value);
|
|
});
|
|
});
|
|
};
|
|
var get$c = function (element, property) {
|
|
var dom = element.dom;
|
|
var styles = window.getComputedStyle(dom);
|
|
var r = styles.getPropertyValue(property);
|
|
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
|
|
};
|
|
var getUnsafeProperty = function (dom, property) {
|
|
return isSupported$1(dom) ? dom.style.getPropertyValue(property) : '';
|
|
};
|
|
var getRaw = function (element, property) {
|
|
var dom = element.dom;
|
|
var raw = getUnsafeProperty(dom, property);
|
|
return Optional.from(raw).filter(function (r) {
|
|
return r.length > 0;
|
|
});
|
|
};
|
|
var getAllRaw = function (element) {
|
|
var css = {};
|
|
var dom = element.dom;
|
|
if (isSupported$1(dom)) {
|
|
for (var i = 0; i < dom.style.length; i++) {
|
|
var ruleName = dom.style.item(i);
|
|
css[ruleName] = dom.style[ruleName];
|
|
}
|
|
}
|
|
return css;
|
|
};
|
|
var isValidValue = function (tag, property, value) {
|
|
var element = SugarElement.fromTag(tag);
|
|
set$7(element, property, value);
|
|
var style = getRaw(element, property);
|
|
return style.isSome();
|
|
};
|
|
var remove$6 = function (element, property) {
|
|
var dom = element.dom;
|
|
internalRemove(dom, property);
|
|
if (is$1(getOpt(element, 'style').map(trim$1), '')) {
|
|
remove$7(element, 'style');
|
|
}
|
|
};
|
|
var reflow = function (e) {
|
|
return e.dom.offsetWidth;
|
|
};
|
|
|
|
var Dimension = function (name, getOffset) {
|
|
var set = function (element, h) {
|
|
if (!isNumber(h) && !h.match(/^[0-9]+$/)) {
|
|
throw new Error(name + '.set accepts only positive integer values. Value was ' + h);
|
|
}
|
|
var dom = element.dom;
|
|
if (isSupported$1(dom)) {
|
|
dom.style[name] = h + 'px';
|
|
}
|
|
};
|
|
var get = function (element) {
|
|
var r = getOffset(element);
|
|
if (r <= 0 || r === null) {
|
|
var css = get$c(element, name);
|
|
return parseFloat(css) || 0;
|
|
}
|
|
return r;
|
|
};
|
|
var getOuter = get;
|
|
var aggregate = function (element, properties) {
|
|
return foldl(properties, function (acc, property) {
|
|
var val = get$c(element, property);
|
|
var value = val === undefined ? 0 : parseInt(val, 10);
|
|
return isNaN(value) ? acc : acc + value;
|
|
}, 0);
|
|
};
|
|
var max = function (element, value, properties) {
|
|
var cumulativeInclusions = aggregate(element, properties);
|
|
var absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;
|
|
return absoluteMax;
|
|
};
|
|
return {
|
|
set: set,
|
|
get: get,
|
|
getOuter: getOuter,
|
|
aggregate: aggregate,
|
|
max: max
|
|
};
|
|
};
|
|
|
|
var api$3 = Dimension('height', function (element) {
|
|
var dom = element.dom;
|
|
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
|
|
});
|
|
var get$b = function (element) {
|
|
return api$3.get(element);
|
|
};
|
|
var getOuter$2 = function (element) {
|
|
return api$3.getOuter(element);
|
|
};
|
|
var setMax$1 = function (element, value) {
|
|
var inclusions = [
|
|
'margin-top',
|
|
'border-top-width',
|
|
'padding-top',
|
|
'padding-bottom',
|
|
'border-bottom-width',
|
|
'margin-bottom'
|
|
];
|
|
var absMax = api$3.max(element, value, inclusions);
|
|
set$7(element, 'max-height', absMax + 'px');
|
|
};
|
|
|
|
var r$1 = function (left, top) {
|
|
var translate = function (x, y) {
|
|
return r$1(left + x, top + y);
|
|
};
|
|
return {
|
|
left: left,
|
|
top: top,
|
|
translate: translate
|
|
};
|
|
};
|
|
var SugarPosition = r$1;
|
|
|
|
var boxPosition = function (dom) {
|
|
var box = dom.getBoundingClientRect();
|
|
return SugarPosition(box.left, box.top);
|
|
};
|
|
var firstDefinedOrZero = function (a, b) {
|
|
if (a !== undefined) {
|
|
return a;
|
|
} else {
|
|
return b !== undefined ? b : 0;
|
|
}
|
|
};
|
|
var absolute$3 = function (element) {
|
|
var doc = element.dom.ownerDocument;
|
|
var body = doc.body;
|
|
var win = doc.defaultView;
|
|
var html = doc.documentElement;
|
|
if (body === element.dom) {
|
|
return SugarPosition(body.offsetLeft, body.offsetTop);
|
|
}
|
|
var scrollTop = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageYOffset, html.scrollTop);
|
|
var scrollLeft = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageXOffset, html.scrollLeft);
|
|
var clientTop = firstDefinedOrZero(html.clientTop, body.clientTop);
|
|
var clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft);
|
|
return viewport$1(element).translate(scrollLeft - clientLeft, scrollTop - clientTop);
|
|
};
|
|
var viewport$1 = function (element) {
|
|
var dom = element.dom;
|
|
var doc = dom.ownerDocument;
|
|
var body = doc.body;
|
|
if (body === dom) {
|
|
return SugarPosition(body.offsetLeft, body.offsetTop);
|
|
}
|
|
if (!inBody(element)) {
|
|
return SugarPosition(0, 0);
|
|
}
|
|
return boxPosition(dom);
|
|
};
|
|
|
|
var api$2 = Dimension('width', function (element) {
|
|
return element.dom.offsetWidth;
|
|
});
|
|
var set$6 = function (element, h) {
|
|
return api$2.set(element, h);
|
|
};
|
|
var get$a = function (element) {
|
|
return api$2.get(element);
|
|
};
|
|
var getOuter$1 = function (element) {
|
|
return api$2.getOuter(element);
|
|
};
|
|
var setMax = function (element, value) {
|
|
var inclusions = [
|
|
'margin-left',
|
|
'border-left-width',
|
|
'padding-left',
|
|
'padding-right',
|
|
'border-right-width',
|
|
'margin-right'
|
|
];
|
|
var absMax = api$2.max(element, value, inclusions);
|
|
set$7(element, 'max-width', absMax + 'px');
|
|
};
|
|
|
|
var mkEvent = function (target, x, y, stop, prevent, kill, raw) {
|
|
return {
|
|
target: target,
|
|
x: x,
|
|
y: y,
|
|
stop: stop,
|
|
prevent: prevent,
|
|
kill: kill,
|
|
raw: raw
|
|
};
|
|
};
|
|
var fromRawEvent$1 = function (rawEvent) {
|
|
var target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target));
|
|
var stop = function () {
|
|
return rawEvent.stopPropagation();
|
|
};
|
|
var prevent = function () {
|
|
return rawEvent.preventDefault();
|
|
};
|
|
var kill = compose(prevent, stop);
|
|
return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent);
|
|
};
|
|
var handle = function (filter, handler) {
|
|
return function (rawEvent) {
|
|
if (filter(rawEvent)) {
|
|
handler(fromRawEvent$1(rawEvent));
|
|
}
|
|
};
|
|
};
|
|
var binder = function (element, event, filter, handler, useCapture) {
|
|
var wrapped = handle(filter, handler);
|
|
element.dom.addEventListener(event, wrapped, useCapture);
|
|
return { unbind: curry(unbind, element, event, wrapped, useCapture) };
|
|
};
|
|
var bind$2 = function (element, event, filter, handler) {
|
|
return binder(element, event, filter, handler, false);
|
|
};
|
|
var capture$1 = function (element, event, filter, handler) {
|
|
return binder(element, event, filter, handler, true);
|
|
};
|
|
var unbind = function (element, event, handler, useCapture) {
|
|
element.dom.removeEventListener(event, handler, useCapture);
|
|
};
|
|
|
|
var before$2 = function (marker, element) {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
v.dom.insertBefore(element.dom, marker.dom);
|
|
});
|
|
};
|
|
var after$2 = function (marker, element) {
|
|
var sibling = nextSibling(marker);
|
|
sibling.fold(function () {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
append$2(v, element);
|
|
});
|
|
}, function (v) {
|
|
before$2(v, element);
|
|
});
|
|
};
|
|
var prepend$1 = function (parent, element) {
|
|
var firstChild$1 = firstChild(parent);
|
|
firstChild$1.fold(function () {
|
|
append$2(parent, element);
|
|
}, function (v) {
|
|
parent.dom.insertBefore(element.dom, v.dom);
|
|
});
|
|
};
|
|
var append$2 = function (parent, element) {
|
|
parent.dom.appendChild(element.dom);
|
|
};
|
|
var appendAt = function (parent, element, index) {
|
|
child$2(parent, index).fold(function () {
|
|
append$2(parent, element);
|
|
}, function (v) {
|
|
before$2(v, element);
|
|
});
|
|
};
|
|
|
|
var before$1 = function (marker, elements) {
|
|
each$1(elements, function (x) {
|
|
before$2(marker, x);
|
|
});
|
|
};
|
|
var append$1 = function (parent, elements) {
|
|
each$1(elements, function (x) {
|
|
append$2(parent, x);
|
|
});
|
|
};
|
|
|
|
var empty = function (element) {
|
|
element.dom.textContent = '';
|
|
each$1(children(element), function (rogue) {
|
|
remove$5(rogue);
|
|
});
|
|
};
|
|
var remove$5 = function (element) {
|
|
var dom = element.dom;
|
|
if (dom.parentNode !== null) {
|
|
dom.parentNode.removeChild(dom);
|
|
}
|
|
};
|
|
var unwrap = function (wrapper) {
|
|
var children$1 = children(wrapper);
|
|
if (children$1.length > 0) {
|
|
before$1(wrapper, children$1);
|
|
}
|
|
remove$5(wrapper);
|
|
};
|
|
|
|
var get$9 = function (_DOC) {
|
|
var doc = _DOC !== undefined ? _DOC.dom : document;
|
|
var x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
|
|
var y = doc.body.scrollTop || doc.documentElement.scrollTop;
|
|
return SugarPosition(x, y);
|
|
};
|
|
var to = function (x, y, _DOC) {
|
|
var doc = _DOC !== undefined ? _DOC.dom : document;
|
|
var win = doc.defaultView;
|
|
if (win) {
|
|
win.scrollTo(x, y);
|
|
}
|
|
};
|
|
|
|
var get$8 = function (_win) {
|
|
var win = _win === undefined ? window : _win;
|
|
if (detect$1().browser.isFirefox()) {
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.from(win['visualViewport']);
|
|
}
|
|
};
|
|
var bounds$1 = function (x, y, width, height) {
|
|
return {
|
|
x: x,
|
|
y: y,
|
|
width: width,
|
|
height: height,
|
|
right: x + width,
|
|
bottom: y + height
|
|
};
|
|
};
|
|
var getBounds$3 = function (_win) {
|
|
var win = _win === undefined ? window : _win;
|
|
var doc = win.document;
|
|
var scroll = get$9(SugarElement.fromDom(doc));
|
|
return get$8(win).fold(function () {
|
|
var html = win.document.documentElement;
|
|
var width = html.clientWidth;
|
|
var height = html.clientHeight;
|
|
return bounds$1(scroll.left, scroll.top, width, height);
|
|
}, function (visualViewport) {
|
|
return bounds$1(Math.max(visualViewport.pageLeft, scroll.left), Math.max(visualViewport.pageTop, scroll.top), visualViewport.width, visualViewport.height);
|
|
});
|
|
};
|
|
|
|
var walkUp = function (navigation, doc) {
|
|
var frame = navigation.view(doc);
|
|
return frame.fold(constant$1([]), function (f) {
|
|
var parent = navigation.owner(f);
|
|
var rest = walkUp(navigation, parent);
|
|
return [f].concat(rest);
|
|
});
|
|
};
|
|
var pathTo = function (element, navigation) {
|
|
var d = navigation.owner(element);
|
|
var paths = walkUp(navigation, d);
|
|
return Optional.some(paths);
|
|
};
|
|
|
|
var view = function (doc) {
|
|
var _a;
|
|
var element = doc.dom === document ? Optional.none() : Optional.from((_a = doc.dom.defaultView) === null || _a === void 0 ? void 0 : _a.frameElement);
|
|
return element.map(SugarElement.fromDom);
|
|
};
|
|
var owner$3 = function (element) {
|
|
return owner$4(element);
|
|
};
|
|
|
|
var Navigation = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
view: view,
|
|
owner: owner$3
|
|
});
|
|
|
|
var find$2 = function (element) {
|
|
var doc = SugarElement.fromDom(document);
|
|
var scroll = get$9(doc);
|
|
var path = pathTo(element, Navigation);
|
|
return path.fold(curry(absolute$3, element), function (frames) {
|
|
var offset = viewport$1(element);
|
|
var r = foldr(frames, function (b, a) {
|
|
var loc = viewport$1(a);
|
|
return {
|
|
left: b.left + loc.left,
|
|
top: b.top + loc.top
|
|
};
|
|
}, {
|
|
left: 0,
|
|
top: 0
|
|
});
|
|
return SugarPosition(r.left + offset.left + scroll.left, r.top + offset.top + scroll.top);
|
|
});
|
|
};
|
|
|
|
var pointed = function (point, width, height) {
|
|
return {
|
|
point: point,
|
|
width: width,
|
|
height: height
|
|
};
|
|
};
|
|
var rect = function (x, y, width, height) {
|
|
return {
|
|
x: x,
|
|
y: y,
|
|
width: width,
|
|
height: height
|
|
};
|
|
};
|
|
var bounds = function (x, y, width, height) {
|
|
return {
|
|
x: x,
|
|
y: y,
|
|
width: width,
|
|
height: height,
|
|
right: x + width,
|
|
bottom: y + height
|
|
};
|
|
};
|
|
var box$1 = function (element) {
|
|
var xy = absolute$3(element);
|
|
var w = getOuter$1(element);
|
|
var h = getOuter$2(element);
|
|
return bounds(xy.left, xy.top, w, h);
|
|
};
|
|
var absolute$2 = function (element) {
|
|
var position = find$2(element);
|
|
var width = getOuter$1(element);
|
|
var height = getOuter$2(element);
|
|
return bounds(position.left, position.top, width, height);
|
|
};
|
|
var win = function () {
|
|
return getBounds$3(window);
|
|
};
|
|
|
|
var value$3 = function (o) {
|
|
var or = function (_opt) {
|
|
return value$3(o);
|
|
};
|
|
var orThunk = function (_f) {
|
|
return value$3(o);
|
|
};
|
|
var map = function (f) {
|
|
return value$3(f(o));
|
|
};
|
|
var mapError = function (_f) {
|
|
return value$3(o);
|
|
};
|
|
var each = function (f) {
|
|
f(o);
|
|
};
|
|
var bind = function (f) {
|
|
return f(o);
|
|
};
|
|
var fold = function (_, onValue) {
|
|
return onValue(o);
|
|
};
|
|
var exists = function (f) {
|
|
return f(o);
|
|
};
|
|
var forall = function (f) {
|
|
return f(o);
|
|
};
|
|
var toOptional = function () {
|
|
return Optional.some(o);
|
|
};
|
|
return {
|
|
isValue: always,
|
|
isError: never,
|
|
getOr: constant$1(o),
|
|
getOrThunk: constant$1(o),
|
|
getOrDie: constant$1(o),
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: each,
|
|
bind: bind,
|
|
exists: exists,
|
|
forall: forall,
|
|
toOptional: toOptional
|
|
};
|
|
};
|
|
var error$1 = function (message) {
|
|
var getOrThunk = function (f) {
|
|
return f();
|
|
};
|
|
var getOrDie = function () {
|
|
return die(String(message))();
|
|
};
|
|
var or = identity$1;
|
|
var orThunk = function (f) {
|
|
return f();
|
|
};
|
|
var map = function (_f) {
|
|
return error$1(message);
|
|
};
|
|
var mapError = function (f) {
|
|
return error$1(f(message));
|
|
};
|
|
var bind = function (_f) {
|
|
return error$1(message);
|
|
};
|
|
var fold = function (onError, _) {
|
|
return onError(message);
|
|
};
|
|
return {
|
|
isValue: never,
|
|
isError: always,
|
|
getOr: identity$1,
|
|
getOrThunk: getOrThunk,
|
|
getOrDie: getOrDie,
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: noop,
|
|
bind: bind,
|
|
exists: never,
|
|
forall: always,
|
|
toOptional: Optional.none
|
|
};
|
|
};
|
|
var fromOption = function (opt, err) {
|
|
return opt.fold(function () {
|
|
return error$1(err);
|
|
}, value$3);
|
|
};
|
|
var Result = {
|
|
value: value$3,
|
|
error: error$1,
|
|
fromOption: fromOption
|
|
};
|
|
|
|
var SimpleResultType;
|
|
(function (SimpleResultType) {
|
|
SimpleResultType[SimpleResultType['Error'] = 0] = 'Error';
|
|
SimpleResultType[SimpleResultType['Value'] = 1] = 'Value';
|
|
}(SimpleResultType || (SimpleResultType = {})));
|
|
var fold$1 = function (res, onError, onValue) {
|
|
return res.stype === SimpleResultType.Error ? onError(res.serror) : onValue(res.svalue);
|
|
};
|
|
var partition$2 = function (results) {
|
|
var values = [];
|
|
var errors = [];
|
|
each$1(results, function (obj) {
|
|
fold$1(obj, function (err) {
|
|
return errors.push(err);
|
|
}, function (val) {
|
|
return values.push(val);
|
|
});
|
|
});
|
|
return {
|
|
values: values,
|
|
errors: errors
|
|
};
|
|
};
|
|
var mapError = function (res, f) {
|
|
if (res.stype === SimpleResultType.Error) {
|
|
return {
|
|
stype: SimpleResultType.Error,
|
|
serror: f(res.serror)
|
|
};
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var map = function (res, f) {
|
|
if (res.stype === SimpleResultType.Value) {
|
|
return {
|
|
stype: SimpleResultType.Value,
|
|
svalue: f(res.svalue)
|
|
};
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var bind$1 = function (res, f) {
|
|
if (res.stype === SimpleResultType.Value) {
|
|
return f(res.svalue);
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var bindError = function (res, f) {
|
|
if (res.stype === SimpleResultType.Error) {
|
|
return f(res.serror);
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var svalue = function (v) {
|
|
return {
|
|
stype: SimpleResultType.Value,
|
|
svalue: v
|
|
};
|
|
};
|
|
var serror = function (e) {
|
|
return {
|
|
stype: SimpleResultType.Error,
|
|
serror: e
|
|
};
|
|
};
|
|
var toResult$1 = function (res) {
|
|
return fold$1(res, Result.error, Result.value);
|
|
};
|
|
var fromResult$1 = function (res) {
|
|
return res.fold(serror, svalue);
|
|
};
|
|
var SimpleResult = {
|
|
fromResult: fromResult$1,
|
|
toResult: toResult$1,
|
|
svalue: svalue,
|
|
partition: partition$2,
|
|
serror: serror,
|
|
bind: bind$1,
|
|
bindError: bindError,
|
|
map: map,
|
|
mapError: mapError,
|
|
fold: fold$1
|
|
};
|
|
|
|
var field$2 = function (key, newKey, presence, prop) {
|
|
return {
|
|
tag: 'field',
|
|
key: key,
|
|
newKey: newKey,
|
|
presence: presence,
|
|
prop: prop
|
|
};
|
|
};
|
|
var customField$1 = function (newKey, instantiator) {
|
|
return {
|
|
tag: 'custom',
|
|
newKey: newKey,
|
|
instantiator: instantiator
|
|
};
|
|
};
|
|
var fold = function (value, ifField, ifCustom) {
|
|
switch (value.tag) {
|
|
case 'field':
|
|
return ifField(value.key, value.newKey, value.presence, value.prop);
|
|
case 'custom':
|
|
return ifCustom(value.newKey, value.instantiator);
|
|
}
|
|
};
|
|
|
|
var shallow$1 = function (old, nu) {
|
|
return nu;
|
|
};
|
|
var deep = function (old, nu) {
|
|
var bothObjects = isObject(old) && isObject(nu);
|
|
return bothObjects ? deepMerge(old, nu) : nu;
|
|
};
|
|
var baseMerge = function (merger) {
|
|
return function () {
|
|
var objects = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
objects[_i] = arguments[_i];
|
|
}
|
|
if (objects.length === 0) {
|
|
throw new Error('Can\'t merge zero objects');
|
|
}
|
|
var ret = {};
|
|
for (var j = 0; j < objects.length; j++) {
|
|
var curObject = objects[j];
|
|
for (var key in curObject) {
|
|
if (has$2(curObject, key)) {
|
|
ret[key] = merger(ret[key], curObject[key]);
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
};
|
|
var deepMerge = baseMerge(deep);
|
|
var merge$1 = baseMerge(shallow$1);
|
|
|
|
var required$2 = function () {
|
|
return {
|
|
tag: 'required',
|
|
process: {}
|
|
};
|
|
};
|
|
var defaultedThunk = function (fallbackThunk) {
|
|
return {
|
|
tag: 'defaultedThunk',
|
|
process: fallbackThunk
|
|
};
|
|
};
|
|
var defaulted$1 = function (fallback) {
|
|
return defaultedThunk(constant$1(fallback));
|
|
};
|
|
var asOption = function () {
|
|
return {
|
|
tag: 'option',
|
|
process: {}
|
|
};
|
|
};
|
|
var mergeWithThunk = function (baseThunk) {
|
|
return {
|
|
tag: 'mergeWithThunk',
|
|
process: baseThunk
|
|
};
|
|
};
|
|
var mergeWith = function (base) {
|
|
return mergeWithThunk(constant$1(base));
|
|
};
|
|
|
|
var mergeValues$1 = function (values, base) {
|
|
return values.length > 0 ? SimpleResult.svalue(deepMerge(base, merge$1.apply(undefined, values))) : SimpleResult.svalue(base);
|
|
};
|
|
var mergeErrors$1 = function (errors) {
|
|
return compose(SimpleResult.serror, flatten)(errors);
|
|
};
|
|
var consolidateObj = function (objects, base) {
|
|
var partition = SimpleResult.partition(objects);
|
|
return partition.errors.length > 0 ? mergeErrors$1(partition.errors) : mergeValues$1(partition.values, base);
|
|
};
|
|
var consolidateArr = function (objects) {
|
|
var partitions = SimpleResult.partition(objects);
|
|
return partitions.errors.length > 0 ? mergeErrors$1(partitions.errors) : SimpleResult.svalue(partitions.values);
|
|
};
|
|
var ResultCombine = {
|
|
consolidateObj: consolidateObj,
|
|
consolidateArr: consolidateArr
|
|
};
|
|
|
|
var formatObj = function (input) {
|
|
return isObject(input) && keys(input).length > 100 ? ' removed due to size' : JSON.stringify(input, null, 2);
|
|
};
|
|
var formatErrors = function (errors) {
|
|
var es = errors.length > 10 ? errors.slice(0, 10).concat([{
|
|
path: [],
|
|
getErrorInfo: constant$1('... (only showing first ten failures)')
|
|
}]) : errors;
|
|
return map$2(es, function (e) {
|
|
return 'Failed path: (' + e.path.join(' > ') + ')\n' + e.getErrorInfo();
|
|
});
|
|
};
|
|
|
|
var nu$a = function (path, getErrorInfo) {
|
|
return SimpleResult.serror([{
|
|
path: path,
|
|
getErrorInfo: getErrorInfo
|
|
}]);
|
|
};
|
|
var missingRequired = function (path, key, obj) {
|
|
return nu$a(path, function () {
|
|
return 'Could not find valid *required* value for "' + key + '" in ' + formatObj(obj);
|
|
});
|
|
};
|
|
var missingKey = function (path, key) {
|
|
return nu$a(path, function () {
|
|
return 'Choice schema did not contain choice key: "' + key + '"';
|
|
});
|
|
};
|
|
var missingBranch = function (path, branches, branch) {
|
|
return nu$a(path, function () {
|
|
return 'The chosen schema: "' + branch + '" did not exist in branches: ' + formatObj(branches);
|
|
});
|
|
};
|
|
var unsupportedFields = function (path, unsupported) {
|
|
return nu$a(path, function () {
|
|
return 'There are unsupported fields: [' + unsupported.join(', ') + '] specified';
|
|
});
|
|
};
|
|
var custom = function (path, err) {
|
|
return nu$a(path, constant$1(err));
|
|
};
|
|
|
|
var value$2 = function (validator) {
|
|
var extract = function (path, val) {
|
|
return SimpleResult.bindError(validator(val), function (err) {
|
|
return custom(path, err);
|
|
});
|
|
};
|
|
var toString = constant$1('val');
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var anyValue$1 = value$2(SimpleResult.svalue);
|
|
|
|
var requiredAccess = function (path, obj, key, bundle) {
|
|
return get$e(obj, key).fold(function () {
|
|
return missingRequired(path, key, obj);
|
|
}, bundle);
|
|
};
|
|
var fallbackAccess = function (obj, key, fallback, bundle) {
|
|
var v = get$e(obj, key).getOrThunk(function () {
|
|
return fallback(obj);
|
|
});
|
|
return bundle(v);
|
|
};
|
|
var optionAccess = function (obj, key, bundle) {
|
|
return bundle(get$e(obj, key));
|
|
};
|
|
var optionDefaultedAccess = function (obj, key, fallback, bundle) {
|
|
var opt = get$e(obj, key).map(function (val) {
|
|
return val === true ? fallback(obj) : val;
|
|
});
|
|
return bundle(opt);
|
|
};
|
|
var extractField = function (field, path, obj, key, prop) {
|
|
var bundle = function (av) {
|
|
return prop.extract(path.concat([key]), av);
|
|
};
|
|
var bundleAsOption = function (optValue) {
|
|
return optValue.fold(function () {
|
|
return SimpleResult.svalue(Optional.none());
|
|
}, function (ov) {
|
|
var result = prop.extract(path.concat([key]), ov);
|
|
return SimpleResult.map(result, Optional.some);
|
|
});
|
|
};
|
|
switch (field.tag) {
|
|
case 'required':
|
|
return requiredAccess(path, obj, key, bundle);
|
|
case 'defaultedThunk':
|
|
return fallbackAccess(obj, key, field.process, bundle);
|
|
case 'option':
|
|
return optionAccess(obj, key, bundleAsOption);
|
|
case 'defaultedOptionThunk':
|
|
return optionDefaultedAccess(obj, key, field.process, bundleAsOption);
|
|
case 'mergeWithThunk': {
|
|
return fallbackAccess(obj, key, constant$1({}), function (v) {
|
|
var result = deepMerge(field.process(obj), v);
|
|
return bundle(result);
|
|
});
|
|
}
|
|
}
|
|
};
|
|
var extractFields = function (path, obj, fields) {
|
|
var success = {};
|
|
var errors = [];
|
|
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
var field = fields_1[_i];
|
|
fold(field, function (key, newKey, presence, prop) {
|
|
var result = extractField(presence, path, obj, key, prop);
|
|
SimpleResult.fold(result, function (err) {
|
|
errors.push.apply(errors, err);
|
|
}, function (res) {
|
|
success[newKey] = res;
|
|
});
|
|
}, function (newKey, instantiator) {
|
|
success[newKey] = instantiator(obj);
|
|
});
|
|
}
|
|
return errors.length > 0 ? SimpleResult.serror(errors) : SimpleResult.svalue(success);
|
|
};
|
|
var valueThunk = function (getDelegate) {
|
|
var extract = function (path, val) {
|
|
return getDelegate().extract(path, val);
|
|
};
|
|
var toString = function () {
|
|
return getDelegate().toString();
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var getSetKeys = function (obj) {
|
|
return keys(filter$1(obj, isNonNullable));
|
|
};
|
|
var objOfOnly = function (fields) {
|
|
var delegate = objOf(fields);
|
|
var fieldNames = foldr(fields, function (acc, value) {
|
|
return fold(value, function (key) {
|
|
var _a;
|
|
return deepMerge(acc, (_a = {}, _a[key] = true, _a));
|
|
}, constant$1(acc));
|
|
}, {});
|
|
var extract = function (path, o) {
|
|
var keys = isBoolean(o) ? [] : getSetKeys(o);
|
|
var extra = filter$2(keys, function (k) {
|
|
return !hasNonNullableKey(fieldNames, k);
|
|
});
|
|
return extra.length === 0 ? delegate.extract(path, o) : unsupportedFields(path, extra);
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: delegate.toString
|
|
};
|
|
};
|
|
var objOf = function (values) {
|
|
var extract = function (path, o) {
|
|
return extractFields(path, o, values);
|
|
};
|
|
var toString = function () {
|
|
var fieldStrings = map$2(values, function (value) {
|
|
return fold(value, function (key, _okey, _presence, prop) {
|
|
return key + ' -> ' + prop.toString();
|
|
}, function (newKey, _instantiator) {
|
|
return 'state(' + newKey + ')';
|
|
});
|
|
});
|
|
return 'obj{\n' + fieldStrings.join('\n') + '}';
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var arrOf = function (prop) {
|
|
var extract = function (path, array) {
|
|
var results = map$2(array, function (a, i) {
|
|
return prop.extract(path.concat(['[' + i + ']']), a);
|
|
});
|
|
return ResultCombine.consolidateArr(results);
|
|
};
|
|
var toString = function () {
|
|
return 'array(' + prop.toString() + ')';
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var oneOf = function (props) {
|
|
var extract = function (path, val) {
|
|
var errors = [];
|
|
for (var _i = 0, props_1 = props; _i < props_1.length; _i++) {
|
|
var prop = props_1[_i];
|
|
var res = prop.extract(path, val);
|
|
if (res.stype === SimpleResultType.Value) {
|
|
return res;
|
|
}
|
|
errors.push(res);
|
|
}
|
|
return ResultCombine.consolidateArr(errors);
|
|
};
|
|
var toString = function () {
|
|
return 'oneOf(' + map$2(props, function (prop) {
|
|
return prop.toString();
|
|
}).join(', ') + ')';
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var setOf$1 = function (validator, prop) {
|
|
var validateKeys = function (path, keys) {
|
|
return arrOf(value$2(validator)).extract(path, keys);
|
|
};
|
|
var extract = function (path, o) {
|
|
var keys$1 = keys(o);
|
|
var validatedKeys = validateKeys(path, keys$1);
|
|
return SimpleResult.bind(validatedKeys, function (validKeys) {
|
|
var schema = map$2(validKeys, function (vk) {
|
|
return field$2(vk, vk, required$2(), prop);
|
|
});
|
|
return objOf(schema).extract(path, o);
|
|
});
|
|
};
|
|
var toString = function () {
|
|
return 'setOf(' + prop.toString() + ')';
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var thunk = function (_desc, processor) {
|
|
var getP = cached(processor);
|
|
var extract = function (path, val) {
|
|
return getP().extract(path, val);
|
|
};
|
|
var toString = function () {
|
|
return getP().toString();
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var arrOfObj = compose(arrOf, objOf);
|
|
|
|
var anyValue = constant$1(anyValue$1);
|
|
var typedValue = function (validator, expectedType) {
|
|
return value$2(function (a) {
|
|
var actualType = typeof a;
|
|
return validator(a) ? SimpleResult.svalue(a) : SimpleResult.serror('Expected type: ' + expectedType + ' but got: ' + actualType);
|
|
});
|
|
};
|
|
var number = typedValue(isNumber, 'number');
|
|
var string = typedValue(isString, 'string');
|
|
var boolean = typedValue(isBoolean, 'boolean');
|
|
var functionProcessor = typedValue(isFunction, 'function');
|
|
var isPostMessageable = function (val) {
|
|
if (Object(val) !== val) {
|
|
return true;
|
|
}
|
|
switch ({}.toString.call(val).slice(8, -1)) {
|
|
case 'Boolean':
|
|
case 'Number':
|
|
case 'String':
|
|
case 'Date':
|
|
case 'RegExp':
|
|
case 'Blob':
|
|
case 'FileList':
|
|
case 'ImageData':
|
|
case 'ImageBitmap':
|
|
case 'ArrayBuffer':
|
|
return true;
|
|
case 'Array':
|
|
case 'Object':
|
|
return Object.keys(val).every(function (prop) {
|
|
return isPostMessageable(val[prop]);
|
|
});
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
var postMessageable = value$2(function (a) {
|
|
if (isPostMessageable(a)) {
|
|
return SimpleResult.svalue(a);
|
|
} else {
|
|
return SimpleResult.serror('Expected value to be acceptable for sending via postMessage');
|
|
}
|
|
});
|
|
|
|
var chooseFrom = function (path, input, branches, ch) {
|
|
var fields = get$e(branches, ch);
|
|
return fields.fold(function () {
|
|
return missingBranch(path, branches, ch);
|
|
}, function (vp) {
|
|
return vp.extract(path.concat(['branch: ' + ch]), input);
|
|
});
|
|
};
|
|
var choose$2 = function (key, branches) {
|
|
var extract = function (path, input) {
|
|
var choice = get$e(input, key);
|
|
return choice.fold(function () {
|
|
return missingKey(path, key);
|
|
}, function (chosen) {
|
|
return chooseFrom(path, input, branches, chosen);
|
|
});
|
|
};
|
|
var toString = function () {
|
|
return 'chooseOn(' + key + '). Possible values: ' + keys(branches);
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
|
|
var arrOfVal = function () {
|
|
return arrOf(anyValue$1);
|
|
};
|
|
var valueOf = function (validator) {
|
|
return value$2(function (v) {
|
|
return validator(v).fold(SimpleResult.serror, SimpleResult.svalue);
|
|
});
|
|
};
|
|
var setOf = function (validator, prop) {
|
|
return setOf$1(function (v) {
|
|
return SimpleResult.fromResult(validator(v));
|
|
}, prop);
|
|
};
|
|
var extractValue = function (label, prop, obj) {
|
|
var res = prop.extract([label], obj);
|
|
return SimpleResult.mapError(res, function (errs) {
|
|
return {
|
|
input: obj,
|
|
errors: errs
|
|
};
|
|
});
|
|
};
|
|
var asRaw = function (label, prop, obj) {
|
|
return SimpleResult.toResult(extractValue(label, prop, obj));
|
|
};
|
|
var getOrDie = function (extraction) {
|
|
return extraction.fold(function (errInfo) {
|
|
throw new Error(formatError(errInfo));
|
|
}, identity$1);
|
|
};
|
|
var asRawOrDie$1 = function (label, prop, obj) {
|
|
return getOrDie(asRaw(label, prop, obj));
|
|
};
|
|
var formatError = function (errInfo) {
|
|
return 'Errors: \n' + formatErrors(errInfo.errors).join('\n') + '\n\nInput object: ' + formatObj(errInfo.input);
|
|
};
|
|
var choose$1 = function (key, branches) {
|
|
return choose$2(key, map$1(branches, objOf));
|
|
};
|
|
var thunkOf = function (desc, schema) {
|
|
return thunk(desc, schema);
|
|
};
|
|
|
|
var field$1 = field$2;
|
|
var customField = customField$1;
|
|
var validateEnum = function (values) {
|
|
return valueOf(function (value) {
|
|
return contains$2(values, value) ? Result.value(value) : Result.error('Unsupported value: "' + value + '", choose one of "' + values.join(', ') + '".');
|
|
});
|
|
};
|
|
var required$1 = function (key) {
|
|
return field$1(key, key, required$2(), anyValue());
|
|
};
|
|
var requiredOf = function (key, schema) {
|
|
return field$1(key, key, required$2(), schema);
|
|
};
|
|
var requiredNumber = function (key) {
|
|
return requiredOf(key, number);
|
|
};
|
|
var requiredString = function (key) {
|
|
return requiredOf(key, string);
|
|
};
|
|
var requiredStringEnum = function (key, values) {
|
|
return field$1(key, key, required$2(), validateEnum(values));
|
|
};
|
|
var requiredBoolean = function (key) {
|
|
return requiredOf(key, boolean);
|
|
};
|
|
var requiredFunction = function (key) {
|
|
return requiredOf(key, functionProcessor);
|
|
};
|
|
var forbid = function (key, message) {
|
|
return field$1(key, key, asOption(), value$2(function (_v) {
|
|
return SimpleResult.serror('The field: ' + key + ' is forbidden. ' + message);
|
|
}));
|
|
};
|
|
var requiredObjOf = function (key, objSchema) {
|
|
return field$1(key, key, required$2(), objOf(objSchema));
|
|
};
|
|
var requiredArrayOfObj = function (key, objFields) {
|
|
return field$1(key, key, required$2(), arrOfObj(objFields));
|
|
};
|
|
var requiredArrayOf = function (key, schema) {
|
|
return field$1(key, key, required$2(), arrOf(schema));
|
|
};
|
|
var option = function (key) {
|
|
return field$1(key, key, asOption(), anyValue());
|
|
};
|
|
var optionOf = function (key, schema) {
|
|
return field$1(key, key, asOption(), schema);
|
|
};
|
|
var optionNumber = function (key) {
|
|
return optionOf(key, number);
|
|
};
|
|
var optionString = function (key) {
|
|
return optionOf(key, string);
|
|
};
|
|
var optionFunction = function (key) {
|
|
return optionOf(key, functionProcessor);
|
|
};
|
|
var optionArrayOf = function (key, schema) {
|
|
return optionOf(key, arrOf(schema));
|
|
};
|
|
var optionObjOf = function (key, objSchema) {
|
|
return optionOf(key, objOf(objSchema));
|
|
};
|
|
var optionObjOfOnly = function (key, objSchema) {
|
|
return optionOf(key, objOfOnly(objSchema));
|
|
};
|
|
var defaulted = function (key, fallback) {
|
|
return field$1(key, key, defaulted$1(fallback), anyValue());
|
|
};
|
|
var defaultedOf = function (key, fallback, schema) {
|
|
return field$1(key, key, defaulted$1(fallback), schema);
|
|
};
|
|
var defaultedNumber = function (key, fallback) {
|
|
return defaultedOf(key, fallback, number);
|
|
};
|
|
var defaultedString = function (key, fallback) {
|
|
return defaultedOf(key, fallback, string);
|
|
};
|
|
var defaultedStringEnum = function (key, fallback, values) {
|
|
return defaultedOf(key, fallback, validateEnum(values));
|
|
};
|
|
var defaultedBoolean = function (key, fallback) {
|
|
return defaultedOf(key, fallback, boolean);
|
|
};
|
|
var defaultedFunction = function (key, fallback) {
|
|
return defaultedOf(key, fallback, functionProcessor);
|
|
};
|
|
var defaultedPostMsg = function (key, fallback) {
|
|
return defaultedOf(key, fallback, postMessageable);
|
|
};
|
|
var defaultedArrayOf = function (key, fallback, schema) {
|
|
return defaultedOf(key, fallback, arrOf(schema));
|
|
};
|
|
var defaultedObjOf = function (key, fallback, objSchema) {
|
|
return defaultedOf(key, fallback, objOf(objSchema));
|
|
};
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var generate$7 = function (cases) {
|
|
if (!isArray(cases)) {
|
|
throw new Error('cases must be an array');
|
|
}
|
|
if (cases.length === 0) {
|
|
throw new Error('there must be at least one case');
|
|
}
|
|
var constructors = [];
|
|
var adt = {};
|
|
each$1(cases, function (acase, count) {
|
|
var keys$1 = keys(acase);
|
|
if (keys$1.length !== 1) {
|
|
throw new Error('one and only one name per case');
|
|
}
|
|
var key = keys$1[0];
|
|
var value = acase[key];
|
|
if (adt[key] !== undefined) {
|
|
throw new Error('duplicate key detected:' + key);
|
|
} else if (key === 'cata') {
|
|
throw new Error('cannot have a case named cata (sorry)');
|
|
} else if (!isArray(value)) {
|
|
throw new Error('case arguments must be an array');
|
|
}
|
|
constructors.push(key);
|
|
adt[key] = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var argLength = args.length;
|
|
if (argLength !== value.length) {
|
|
throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
|
|
}
|
|
var match = function (branches) {
|
|
var branchKeys = keys(branches);
|
|
if (constructors.length !== branchKeys.length) {
|
|
throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
|
|
}
|
|
var allReqd = forall(constructors, function (reqKey) {
|
|
return contains$2(branchKeys, reqKey);
|
|
});
|
|
if (!allReqd) {
|
|
throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
|
|
}
|
|
return branches[key].apply(null, args);
|
|
};
|
|
return {
|
|
fold: function () {
|
|
var foldArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
foldArgs[_i] = arguments[_i];
|
|
}
|
|
if (foldArgs.length !== cases.length) {
|
|
throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
|
|
}
|
|
var target = foldArgs[count];
|
|
return target.apply(null, args);
|
|
},
|
|
match: match,
|
|
log: function (label) {
|
|
console.log(label, {
|
|
constructors: constructors,
|
|
constructor: key,
|
|
params: args
|
|
});
|
|
}
|
|
};
|
|
};
|
|
});
|
|
return adt;
|
|
};
|
|
var Adt = { generate: generate$7 };
|
|
|
|
Adt.generate([
|
|
{
|
|
bothErrors: [
|
|
'error1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
firstError: [
|
|
'error1',
|
|
'value2'
|
|
]
|
|
},
|
|
{
|
|
secondError: [
|
|
'value1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
bothValues: [
|
|
'value1',
|
|
'value2'
|
|
]
|
|
}
|
|
]);
|
|
var partition$1 = function (results) {
|
|
var errors = [];
|
|
var values = [];
|
|
each$1(results, function (result) {
|
|
result.fold(function (err) {
|
|
errors.push(err);
|
|
}, function (value) {
|
|
values.push(value);
|
|
});
|
|
});
|
|
return {
|
|
errors: errors,
|
|
values: values
|
|
};
|
|
};
|
|
|
|
var exclude$1 = function (obj, fields) {
|
|
var r = {};
|
|
each(obj, function (v, k) {
|
|
if (!contains$2(fields, k)) {
|
|
r[k] = v;
|
|
}
|
|
});
|
|
return r;
|
|
};
|
|
|
|
var wrap$2 = function (key, value) {
|
|
var _a;
|
|
return _a = {}, _a[key] = value, _a;
|
|
};
|
|
var wrapAll$1 = function (keyvalues) {
|
|
var r = {};
|
|
each$1(keyvalues, function (kv) {
|
|
r[kv.key] = kv.value;
|
|
});
|
|
return r;
|
|
};
|
|
|
|
var exclude = function (obj, fields) {
|
|
return exclude$1(obj, fields);
|
|
};
|
|
var wrap$1 = function (key, value) {
|
|
return wrap$2(key, value);
|
|
};
|
|
var wrapAll = function (keyvalues) {
|
|
return wrapAll$1(keyvalues);
|
|
};
|
|
var mergeValues = function (values, base) {
|
|
return values.length === 0 ? Result.value(base) : Result.value(deepMerge(base, merge$1.apply(undefined, values)));
|
|
};
|
|
var mergeErrors = function (errors) {
|
|
return Result.error(flatten(errors));
|
|
};
|
|
var consolidate = function (objs, base) {
|
|
var partitions = partition$1(objs);
|
|
return partitions.errors.length > 0 ? mergeErrors(partitions.errors) : mergeValues(partitions.values, base);
|
|
};
|
|
|
|
var ensureIsRoot = function (isRoot) {
|
|
return isFunction(isRoot) ? isRoot : never;
|
|
};
|
|
var ancestor$2 = function (scope, transform, isRoot) {
|
|
var element = scope.dom;
|
|
var stop = ensureIsRoot(isRoot);
|
|
while (element.parentNode) {
|
|
element = element.parentNode;
|
|
var el = SugarElement.fromDom(element);
|
|
var transformed = transform(el);
|
|
if (transformed.isSome()) {
|
|
return transformed;
|
|
} else if (stop(el)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var closest$4 = function (scope, transform, isRoot) {
|
|
var current = transform(scope);
|
|
var stop = ensureIsRoot(isRoot);
|
|
return current.orThunk(function () {
|
|
return stop(scope) ? Optional.none() : ancestor$2(scope, transform, stop);
|
|
});
|
|
};
|
|
|
|
var isSource = function (component, simulatedEvent) {
|
|
return eq(component.element, simulatedEvent.event.target);
|
|
};
|
|
|
|
var defaultEventHandler = {
|
|
can: always,
|
|
abort: never,
|
|
run: noop
|
|
};
|
|
var nu$9 = function (parts) {
|
|
if (!hasNonNullableKey(parts, 'can') && !hasNonNullableKey(parts, 'abort') && !hasNonNullableKey(parts, 'run')) {
|
|
throw new Error('EventHandler defined by: ' + JSON.stringify(parts, null, 2) + ' does not have can, abort, or run!');
|
|
}
|
|
return __assign(__assign({}, defaultEventHandler), parts);
|
|
};
|
|
var all$2 = function (handlers, f) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return foldl(handlers, function (acc, handler) {
|
|
return acc && f(handler).apply(undefined, args);
|
|
}, true);
|
|
};
|
|
};
|
|
var any = function (handlers, f) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return foldl(handlers, function (acc, handler) {
|
|
return acc || f(handler).apply(undefined, args);
|
|
}, false);
|
|
};
|
|
};
|
|
var read$2 = function (handler) {
|
|
return isFunction(handler) ? {
|
|
can: always,
|
|
abort: never,
|
|
run: handler
|
|
} : handler;
|
|
};
|
|
var fuse$1 = function (handlers) {
|
|
var can = all$2(handlers, function (handler) {
|
|
return handler.can;
|
|
});
|
|
var abort = any(handlers, function (handler) {
|
|
return handler.abort;
|
|
});
|
|
var run = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
each$1(handlers, function (handler) {
|
|
handler.run.apply(undefined, args);
|
|
});
|
|
};
|
|
return {
|
|
can: can,
|
|
abort: abort,
|
|
run: run
|
|
};
|
|
};
|
|
|
|
var constant = constant$1;
|
|
var touchstart = constant('touchstart');
|
|
var touchmove = constant('touchmove');
|
|
var touchend = constant('touchend');
|
|
var touchcancel = constant('touchcancel');
|
|
var mousedown = constant('mousedown');
|
|
var mousemove = constant('mousemove');
|
|
var mouseout = constant('mouseout');
|
|
var mouseup = constant('mouseup');
|
|
var mouseover = constant('mouseover');
|
|
var focusin = constant('focusin');
|
|
var focusout = constant('focusout');
|
|
var keydown = constant('keydown');
|
|
var keyup = constant('keyup');
|
|
var input = constant('input');
|
|
var change = constant('change');
|
|
var click = constant('click');
|
|
var transitioncancel = constant('transitioncancel');
|
|
var transitionend = constant('transitionend');
|
|
var transitionstart = constant('transitionstart');
|
|
var selectstart = constant('selectstart');
|
|
|
|
var prefixName = function (name) {
|
|
return constant$1('alloy.' + name);
|
|
};
|
|
var alloy = { tap: prefixName('tap') };
|
|
var focus$4 = prefixName('focus');
|
|
var postBlur = prefixName('blur.post');
|
|
var postPaste = prefixName('paste.post');
|
|
var receive = prefixName('receive');
|
|
var execute$5 = prefixName('execute');
|
|
var focusItem = prefixName('focus.item');
|
|
var tap = alloy.tap;
|
|
var longpress = prefixName('longpress');
|
|
var sandboxClose = prefixName('sandbox.close');
|
|
var typeaheadCancel = prefixName('typeahead.cancel');
|
|
var systemInit = prefixName('system.init');
|
|
var documentTouchmove = prefixName('system.touchmove');
|
|
var documentTouchend = prefixName('system.touchend');
|
|
var windowScroll = prefixName('system.scroll');
|
|
var windowResize = prefixName('system.resize');
|
|
var attachedToDom = prefixName('system.attached');
|
|
var detachedFromDom = prefixName('system.detached');
|
|
var dismissRequested = prefixName('system.dismissRequested');
|
|
var repositionRequested = prefixName('system.repositionRequested');
|
|
var focusShifted = prefixName('focusmanager.shifted');
|
|
var slotVisibility = prefixName('slotcontainer.visibility');
|
|
var changeTab = prefixName('change.tab');
|
|
var dismissTab = prefixName('dismiss.tab');
|
|
var highlight$1 = prefixName('highlight');
|
|
var dehighlight$1 = prefixName('dehighlight');
|
|
|
|
var emit = function (component, event) {
|
|
dispatchWith(component, component.element, event, {});
|
|
};
|
|
var emitWith = function (component, event, properties) {
|
|
dispatchWith(component, component.element, event, properties);
|
|
};
|
|
var emitExecute = function (component) {
|
|
emit(component, execute$5());
|
|
};
|
|
var dispatch = function (component, target, event) {
|
|
dispatchWith(component, target, event, {});
|
|
};
|
|
var dispatchWith = function (component, target, event, properties) {
|
|
var data = __assign({ target: target }, properties);
|
|
component.getSystem().triggerEvent(event, target, data);
|
|
};
|
|
var dispatchEvent = function (component, target, event, simulatedEvent) {
|
|
component.getSystem().triggerEvent(event, target, simulatedEvent.event);
|
|
};
|
|
|
|
var derive$2 = function (configs) {
|
|
return wrapAll(configs);
|
|
};
|
|
var abort = function (name, predicate) {
|
|
return {
|
|
key: name,
|
|
value: nu$9({ abort: predicate })
|
|
};
|
|
};
|
|
var can = function (name, predicate) {
|
|
return {
|
|
key: name,
|
|
value: nu$9({ can: predicate })
|
|
};
|
|
};
|
|
var preventDefault = function (name) {
|
|
return {
|
|
key: name,
|
|
value: nu$9({
|
|
run: function (component, simulatedEvent) {
|
|
simulatedEvent.event.prevent();
|
|
}
|
|
})
|
|
};
|
|
};
|
|
var run$1 = function (name, handler) {
|
|
return {
|
|
key: name,
|
|
value: nu$9({ run: handler })
|
|
};
|
|
};
|
|
var runActionExtra = function (name, action, extra) {
|
|
return {
|
|
key: name,
|
|
value: nu$9({
|
|
run: function (component, simulatedEvent) {
|
|
action.apply(undefined, [
|
|
component,
|
|
simulatedEvent
|
|
].concat(extra));
|
|
}
|
|
})
|
|
};
|
|
};
|
|
var runOnName = function (name) {
|
|
return function (handler) {
|
|
return run$1(name, handler);
|
|
};
|
|
};
|
|
var runOnSourceName = function (name) {
|
|
return function (handler) {
|
|
return {
|
|
key: name,
|
|
value: nu$9({
|
|
run: function (component, simulatedEvent) {
|
|
if (isSource(component, simulatedEvent)) {
|
|
handler(component, simulatedEvent);
|
|
}
|
|
}
|
|
})
|
|
};
|
|
};
|
|
};
|
|
var redirectToUid = function (name, uid) {
|
|
return run$1(name, function (component, simulatedEvent) {
|
|
component.getSystem().getByUid(uid).each(function (redirectee) {
|
|
dispatchEvent(redirectee, redirectee.element, name, simulatedEvent);
|
|
});
|
|
});
|
|
};
|
|
var redirectToPart = function (name, detail, partName) {
|
|
var uid = detail.partUids[partName];
|
|
return redirectToUid(name, uid);
|
|
};
|
|
var runWithTarget = function (name, f) {
|
|
return run$1(name, function (component, simulatedEvent) {
|
|
var ev = simulatedEvent.event;
|
|
var target = component.getSystem().getByDom(ev.target).getOrThunk(function () {
|
|
var closest = closest$4(ev.target, function (el) {
|
|
return component.getSystem().getByDom(el).toOptional();
|
|
}, never);
|
|
return closest.getOr(component);
|
|
});
|
|
f(component, target, simulatedEvent);
|
|
});
|
|
};
|
|
var cutter = function (name) {
|
|
return run$1(name, function (component, simulatedEvent) {
|
|
simulatedEvent.cut();
|
|
});
|
|
};
|
|
var stopper = function (name) {
|
|
return run$1(name, function (component, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
});
|
|
};
|
|
var runOnSource = function (name, f) {
|
|
return runOnSourceName(name)(f);
|
|
};
|
|
var runOnAttached = runOnSourceName(attachedToDom());
|
|
var runOnDetached = runOnSourceName(detachedFromDom());
|
|
var runOnInit = runOnSourceName(systemInit());
|
|
var runOnExecute$1 = runOnName(execute$5());
|
|
|
|
var fromHtml$1 = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
return children(SugarElement.fromDom(div));
|
|
};
|
|
|
|
var get$7 = function (element) {
|
|
return element.dom.innerHTML;
|
|
};
|
|
var set$5 = function (element, content) {
|
|
var owner = owner$4(element);
|
|
var docDom = owner.dom;
|
|
var fragment = SugarElement.fromDom(docDom.createDocumentFragment());
|
|
var contentElements = fromHtml$1(content, docDom);
|
|
append$1(fragment, contentElements);
|
|
empty(element);
|
|
append$2(element, fragment);
|
|
};
|
|
var getOuter = function (element) {
|
|
var container = SugarElement.fromTag('div');
|
|
var clone = SugarElement.fromDom(element.dom.cloneNode(true));
|
|
append$2(container, clone);
|
|
return get$7(container);
|
|
};
|
|
|
|
var clone$1 = function (original, isDeep) {
|
|
return SugarElement.fromDom(original.dom.cloneNode(isDeep));
|
|
};
|
|
var shallow = function (original) {
|
|
return clone$1(original, false);
|
|
};
|
|
|
|
var getHtml = function (element) {
|
|
if (isShadowRoot(element)) {
|
|
return '#shadow-root';
|
|
} else {
|
|
var clone = shallow(element);
|
|
return getOuter(clone);
|
|
}
|
|
};
|
|
|
|
var element = function (elem) {
|
|
return getHtml(elem);
|
|
};
|
|
|
|
var isRecursive = function (component, originator, target) {
|
|
return eq(originator, component.element) && !eq(originator, target);
|
|
};
|
|
var events$i = derive$2([can(focus$4(), function (component, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
var originator = event.originator;
|
|
var target = event.target;
|
|
if (isRecursive(component, originator, target)) {
|
|
console.warn(focus$4() + ' did not get interpreted by the desired target. ' + '\nOriginator: ' + element(originator) + '\nTarget: ' + element(target) + '\nCheck the ' + focus$4() + ' event handlers');
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
})]);
|
|
|
|
var DefaultEvents = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$i
|
|
});
|
|
|
|
var unique = 0;
|
|
var generate$6 = function (prefix) {
|
|
var date = new Date();
|
|
var time = date.getTime();
|
|
var random = Math.floor(Math.random() * 1000000000);
|
|
unique++;
|
|
return prefix + '_' + random + unique + String(time);
|
|
};
|
|
|
|
var prefix$1 = constant$1('alloy-id-');
|
|
var idAttr$1 = constant$1('data-alloy-id');
|
|
|
|
var prefix = prefix$1();
|
|
var idAttr = idAttr$1();
|
|
var write = function (label, elem) {
|
|
var id = generate$6(prefix + label);
|
|
writeOnly(elem, id);
|
|
return id;
|
|
};
|
|
var writeOnly = function (elem, uid) {
|
|
Object.defineProperty(elem.dom, idAttr, {
|
|
value: uid,
|
|
writable: true
|
|
});
|
|
};
|
|
var read$1 = function (elem) {
|
|
var id = isElement$2(elem) ? elem.dom[idAttr] : null;
|
|
return Optional.from(id);
|
|
};
|
|
var generate$5 = function (prefix) {
|
|
return generate$6(prefix);
|
|
};
|
|
|
|
var make$8 = identity$1;
|
|
|
|
var NoContextApi = function (getComp) {
|
|
var getMessage = function (event) {
|
|
return 'The component must be in a context to execute: ' + event + (getComp ? '\n' + element(getComp().element) + ' is not in context.' : '');
|
|
};
|
|
var fail = function (event) {
|
|
return function () {
|
|
throw new Error(getMessage(event));
|
|
};
|
|
};
|
|
var warn = function (event) {
|
|
return function () {
|
|
console.warn(getMessage(event));
|
|
};
|
|
};
|
|
return {
|
|
debugInfo: constant$1('fake'),
|
|
triggerEvent: warn('triggerEvent'),
|
|
triggerFocus: warn('triggerFocus'),
|
|
triggerEscape: warn('triggerEscape'),
|
|
broadcast: warn('broadcast'),
|
|
broadcastOn: warn('broadcastOn'),
|
|
broadcastEvent: warn('broadcastEvent'),
|
|
build: fail('build'),
|
|
addToWorld: fail('addToWorld'),
|
|
removeFromWorld: fail('removeFromWorld'),
|
|
addToGui: fail('addToGui'),
|
|
removeFromGui: fail('removeFromGui'),
|
|
getByUid: fail('getByUid'),
|
|
getByDom: fail('getByDom'),
|
|
isConnected: never
|
|
};
|
|
};
|
|
var singleton$1 = NoContextApi();
|
|
|
|
var markAsBehaviourApi = function (f, apiName, apiFunction) {
|
|
var delegate = apiFunction.toString();
|
|
var endIndex = delegate.indexOf(')') + 1;
|
|
var openBracketIndex = delegate.indexOf('(');
|
|
var parameters = delegate.substring(openBracketIndex + 1, endIndex - 1).split(/,\s*/);
|
|
f.toFunctionAnnotation = function () {
|
|
return {
|
|
name: apiName,
|
|
parameters: cleanParameters(parameters.slice(0, 1).concat(parameters.slice(3)))
|
|
};
|
|
};
|
|
return f;
|
|
};
|
|
var cleanParameters = function (parameters) {
|
|
return map$2(parameters, function (p) {
|
|
return endsWith(p, '/*') ? p.substring(0, p.length - '/*'.length) : p;
|
|
});
|
|
};
|
|
var markAsExtraApi = function (f, extraName) {
|
|
var delegate = f.toString();
|
|
var endIndex = delegate.indexOf(')') + 1;
|
|
var openBracketIndex = delegate.indexOf('(');
|
|
var parameters = delegate.substring(openBracketIndex + 1, endIndex - 1).split(/,\s*/);
|
|
f.toFunctionAnnotation = function () {
|
|
return {
|
|
name: extraName,
|
|
parameters: cleanParameters(parameters)
|
|
};
|
|
};
|
|
return f;
|
|
};
|
|
var markAsSketchApi = function (f, apiFunction) {
|
|
var delegate = apiFunction.toString();
|
|
var endIndex = delegate.indexOf(')') + 1;
|
|
var openBracketIndex = delegate.indexOf('(');
|
|
var parameters = delegate.substring(openBracketIndex + 1, endIndex - 1).split(/,\s*/);
|
|
f.toFunctionAnnotation = function () {
|
|
return {
|
|
name: 'OVERRIDE',
|
|
parameters: cleanParameters(parameters.slice(1))
|
|
};
|
|
};
|
|
return f;
|
|
};
|
|
|
|
var premadeTag = generate$6('alloy-premade');
|
|
var premade$1 = function (comp) {
|
|
return wrap$1(premadeTag, comp);
|
|
};
|
|
var getPremade = function (spec) {
|
|
return get$e(spec, premadeTag);
|
|
};
|
|
var makeApi = function (f) {
|
|
return markAsSketchApi(function (component) {
|
|
var rest = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
rest[_i - 1] = arguments[_i];
|
|
}
|
|
return f.apply(void 0, __spreadArray([
|
|
component.getApis(),
|
|
component
|
|
], rest, false));
|
|
}, f);
|
|
};
|
|
|
|
var NoState = {
|
|
init: function () {
|
|
return nu$8({ readState: constant$1('No State required') });
|
|
}
|
|
};
|
|
var nu$8 = function (spec) {
|
|
return spec;
|
|
};
|
|
|
|
var generateFrom$1 = function (spec, all) {
|
|
var schema = map$2(all, function (a) {
|
|
return optionObjOf(a.name(), [
|
|
required$1('config'),
|
|
defaulted('state', NoState)
|
|
]);
|
|
});
|
|
var validated = asRaw('component.behaviours', objOf(schema), spec.behaviours).fold(function (errInfo) {
|
|
throw new Error(formatError(errInfo) + '\nComplete spec:\n' + JSON.stringify(spec, null, 2));
|
|
}, identity$1);
|
|
return {
|
|
list: all,
|
|
data: map$1(validated, function (optBlobThunk) {
|
|
var output = optBlobThunk.map(function (blob) {
|
|
return {
|
|
config: blob.config,
|
|
state: blob.state.init(blob.config)
|
|
};
|
|
});
|
|
return constant$1(output);
|
|
})
|
|
};
|
|
};
|
|
var getBehaviours$3 = function (bData) {
|
|
return bData.list;
|
|
};
|
|
var getData$2 = function (bData) {
|
|
return bData.data;
|
|
};
|
|
|
|
var byInnerKey = function (data, tuple) {
|
|
var r = {};
|
|
each(data, function (detail, key) {
|
|
each(detail, function (value, indexKey) {
|
|
var chain = get$e(r, indexKey).getOr([]);
|
|
r[indexKey] = chain.concat([tuple(key, value)]);
|
|
});
|
|
});
|
|
return r;
|
|
};
|
|
|
|
var nu$7 = function (s) {
|
|
return {
|
|
classes: isUndefined(s.classes) ? [] : s.classes,
|
|
attributes: isUndefined(s.attributes) ? {} : s.attributes,
|
|
styles: isUndefined(s.styles) ? {} : s.styles
|
|
};
|
|
};
|
|
var merge = function (defnA, mod) {
|
|
return __assign(__assign({}, defnA), {
|
|
attributes: __assign(__assign({}, defnA.attributes), mod.attributes),
|
|
styles: __assign(__assign({}, defnA.styles), mod.styles),
|
|
classes: defnA.classes.concat(mod.classes)
|
|
});
|
|
};
|
|
|
|
var combine$2 = function (info, baseMod, behaviours, base) {
|
|
var modsByBehaviour = __assign({}, baseMod);
|
|
each$1(behaviours, function (behaviour) {
|
|
modsByBehaviour[behaviour.name()] = behaviour.exhibit(info, base);
|
|
});
|
|
var byAspect = byInnerKey(modsByBehaviour, function (name, modification) {
|
|
return {
|
|
name: name,
|
|
modification: modification
|
|
};
|
|
});
|
|
var combineObjects = function (objects) {
|
|
return foldr(objects, function (b, a) {
|
|
return __assign(__assign({}, a.modification), b);
|
|
}, {});
|
|
};
|
|
var combinedClasses = foldr(byAspect.classes, function (b, a) {
|
|
return a.modification.concat(b);
|
|
}, []);
|
|
var combinedAttributes = combineObjects(byAspect.attributes);
|
|
var combinedStyles = combineObjects(byAspect.styles);
|
|
return nu$7({
|
|
classes: combinedClasses,
|
|
attributes: combinedAttributes,
|
|
styles: combinedStyles
|
|
});
|
|
};
|
|
|
|
var sortKeys = function (label, keyName, array, order) {
|
|
try {
|
|
var sorted = sort(array, function (a, b) {
|
|
var aKey = a[keyName];
|
|
var bKey = b[keyName];
|
|
var aIndex = order.indexOf(aKey);
|
|
var bIndex = order.indexOf(bKey);
|
|
if (aIndex === -1) {
|
|
throw new Error('The ordering for ' + label + ' does not have an entry for ' + aKey + '.\nOrder specified: ' + JSON.stringify(order, null, 2));
|
|
}
|
|
if (bIndex === -1) {
|
|
throw new Error('The ordering for ' + label + ' does not have an entry for ' + bKey + '.\nOrder specified: ' + JSON.stringify(order, null, 2));
|
|
}
|
|
if (aIndex < bIndex) {
|
|
return -1;
|
|
} else if (bIndex < aIndex) {
|
|
return 1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
});
|
|
return Result.value(sorted);
|
|
} catch (err) {
|
|
return Result.error([err]);
|
|
}
|
|
};
|
|
|
|
var uncurried = function (handler, purpose) {
|
|
return {
|
|
handler: handler,
|
|
purpose: purpose
|
|
};
|
|
};
|
|
var curried = function (handler, purpose) {
|
|
return {
|
|
cHandler: handler,
|
|
purpose: purpose
|
|
};
|
|
};
|
|
var curryArgs = function (descHandler, extraArgs) {
|
|
return curried(curry.apply(undefined, [descHandler.handler].concat(extraArgs)), descHandler.purpose);
|
|
};
|
|
var getCurried = function (descHandler) {
|
|
return descHandler.cHandler;
|
|
};
|
|
|
|
var behaviourTuple = function (name, handler) {
|
|
return {
|
|
name: name,
|
|
handler: handler
|
|
};
|
|
};
|
|
var nameToHandlers = function (behaviours, info) {
|
|
var r = {};
|
|
each$1(behaviours, function (behaviour) {
|
|
r[behaviour.name()] = behaviour.handlers(info);
|
|
});
|
|
return r;
|
|
};
|
|
var groupByEvents = function (info, behaviours, base) {
|
|
var behaviourEvents = __assign(__assign({}, base), nameToHandlers(behaviours, info));
|
|
return byInnerKey(behaviourEvents, behaviourTuple);
|
|
};
|
|
var combine$1 = function (info, eventOrder, behaviours, base) {
|
|
var byEventName = groupByEvents(info, behaviours, base);
|
|
return combineGroups(byEventName, eventOrder);
|
|
};
|
|
var assemble = function (rawHandler) {
|
|
var handler = read$2(rawHandler);
|
|
return function (component, simulatedEvent) {
|
|
var rest = [];
|
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
rest[_i - 2] = arguments[_i];
|
|
}
|
|
var args = [
|
|
component,
|
|
simulatedEvent
|
|
].concat(rest);
|
|
if (handler.abort.apply(undefined, args)) {
|
|
simulatedEvent.stop();
|
|
} else if (handler.can.apply(undefined, args)) {
|
|
handler.run.apply(undefined, args);
|
|
}
|
|
};
|
|
};
|
|
var missingOrderError = function (eventName, tuples) {
|
|
return Result.error(['The event (' + eventName + ') has more than one behaviour that listens to it.\nWhen this occurs, you must ' + 'specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that ' + 'can trigger it are: ' + JSON.stringify(map$2(tuples, function (c) {
|
|
return c.name;
|
|
}), null, 2)]);
|
|
};
|
|
var fuse = function (tuples, eventOrder, eventName) {
|
|
var order = eventOrder[eventName];
|
|
if (!order) {
|
|
return missingOrderError(eventName, tuples);
|
|
} else {
|
|
return sortKeys('Event: ' + eventName, 'name', tuples, order).map(function (sortedTuples) {
|
|
var handlers = map$2(sortedTuples, function (tuple) {
|
|
return tuple.handler;
|
|
});
|
|
return fuse$1(handlers);
|
|
});
|
|
}
|
|
};
|
|
var combineGroups = function (byEventName, eventOrder) {
|
|
var r = mapToArray(byEventName, function (tuples, eventName) {
|
|
var combined = tuples.length === 1 ? Result.value(tuples[0].handler) : fuse(tuples, eventOrder, eventName);
|
|
return combined.map(function (handler) {
|
|
var assembled = assemble(handler);
|
|
var purpose = tuples.length > 1 ? filter$2(eventOrder[eventName], function (o) {
|
|
return exists(tuples, function (t) {
|
|
return t.name === o;
|
|
});
|
|
}).join(' > ') : tuples[0].name;
|
|
return wrap$1(eventName, uncurried(assembled, purpose));
|
|
});
|
|
});
|
|
return consolidate(r, {});
|
|
};
|
|
|
|
var _a$2;
|
|
var baseBehaviour = 'alloy.base.behaviour';
|
|
var schema$z = objOf([
|
|
field$1('dom', 'dom', required$2(), objOf([
|
|
required$1('tag'),
|
|
defaulted('styles', {}),
|
|
defaulted('classes', []),
|
|
defaulted('attributes', {}),
|
|
option('value'),
|
|
option('innerHtml')
|
|
])),
|
|
required$1('components'),
|
|
required$1('uid'),
|
|
defaulted('events', {}),
|
|
defaulted('apis', {}),
|
|
field$1('eventOrder', 'eventOrder', mergeWith((_a$2 = {}, _a$2[execute$5()] = [
|
|
'disabling',
|
|
baseBehaviour,
|
|
'toggling',
|
|
'typeaheadevents'
|
|
], _a$2[focus$4()] = [
|
|
baseBehaviour,
|
|
'focusing',
|
|
'keying'
|
|
], _a$2[systemInit()] = [
|
|
baseBehaviour,
|
|
'disabling',
|
|
'toggling',
|
|
'representing'
|
|
], _a$2[input()] = [
|
|
baseBehaviour,
|
|
'representing',
|
|
'streaming',
|
|
'invalidating'
|
|
], _a$2[detachedFromDom()] = [
|
|
baseBehaviour,
|
|
'representing',
|
|
'item-events',
|
|
'tooltipping'
|
|
], _a$2[mousedown()] = [
|
|
'focusing',
|
|
baseBehaviour,
|
|
'item-type-events'
|
|
], _a$2[touchstart()] = [
|
|
'focusing',
|
|
baseBehaviour,
|
|
'item-type-events'
|
|
], _a$2[mouseover()] = [
|
|
'item-type-events',
|
|
'tooltipping'
|
|
], _a$2[receive()] = [
|
|
'receiving',
|
|
'reflecting',
|
|
'tooltipping'
|
|
], _a$2)), anyValue()),
|
|
option('domModification')
|
|
]);
|
|
var toInfo = function (spec) {
|
|
return asRaw('custom.definition', schema$z, spec);
|
|
};
|
|
var toDefinition = function (detail) {
|
|
return __assign(__assign({}, detail.dom), {
|
|
uid: detail.uid,
|
|
domChildren: map$2(detail.components, function (comp) {
|
|
return comp.element;
|
|
})
|
|
});
|
|
};
|
|
var toModification = function (detail) {
|
|
return detail.domModification.fold(function () {
|
|
return nu$7({});
|
|
}, nu$7);
|
|
};
|
|
var toEvents = function (info) {
|
|
return info.events;
|
|
};
|
|
|
|
var read = function (element, attr) {
|
|
var value = get$d(element, attr);
|
|
return value === undefined || value === '' ? [] : value.split(' ');
|
|
};
|
|
var add$4 = function (element, attr, id) {
|
|
var old = read(element, attr);
|
|
var nu = old.concat([id]);
|
|
set$8(element, attr, nu.join(' '));
|
|
return true;
|
|
};
|
|
var remove$4 = function (element, attr, id) {
|
|
var nu = filter$2(read(element, attr), function (v) {
|
|
return v !== id;
|
|
});
|
|
if (nu.length > 0) {
|
|
set$8(element, attr, nu.join(' '));
|
|
} else {
|
|
remove$7(element, attr);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
var supports = function (element) {
|
|
return element.dom.classList !== undefined;
|
|
};
|
|
var get$6 = function (element) {
|
|
return read(element, 'class');
|
|
};
|
|
var add$3 = function (element, clazz) {
|
|
return add$4(element, 'class', clazz);
|
|
};
|
|
var remove$3 = function (element, clazz) {
|
|
return remove$4(element, 'class', clazz);
|
|
};
|
|
|
|
var add$2 = function (element, clazz) {
|
|
if (supports(element)) {
|
|
element.dom.classList.add(clazz);
|
|
} else {
|
|
add$3(element, clazz);
|
|
}
|
|
};
|
|
var cleanClass = function (element) {
|
|
var classList = supports(element) ? element.dom.classList : get$6(element);
|
|
if (classList.length === 0) {
|
|
remove$7(element, 'class');
|
|
}
|
|
};
|
|
var remove$2 = function (element, clazz) {
|
|
if (supports(element)) {
|
|
var classList = element.dom.classList;
|
|
classList.remove(clazz);
|
|
} else {
|
|
remove$3(element, clazz);
|
|
}
|
|
cleanClass(element);
|
|
};
|
|
var has = function (element, clazz) {
|
|
return supports(element) && element.dom.classList.contains(clazz);
|
|
};
|
|
|
|
var add$1 = function (element, classes) {
|
|
each$1(classes, function (x) {
|
|
add$2(element, x);
|
|
});
|
|
};
|
|
var remove$1 = function (element, classes) {
|
|
each$1(classes, function (x) {
|
|
remove$2(element, x);
|
|
});
|
|
};
|
|
var hasAll = function (element, classes) {
|
|
return forall(classes, function (clazz) {
|
|
return has(element, clazz);
|
|
});
|
|
};
|
|
|
|
var get$5 = function (element) {
|
|
return element.dom.value;
|
|
};
|
|
var set$4 = function (element, value) {
|
|
if (value === undefined) {
|
|
throw new Error('Value.set was undefined');
|
|
}
|
|
element.dom.value = value;
|
|
};
|
|
|
|
var renderToDom = function (definition) {
|
|
var subject = SugarElement.fromTag(definition.tag);
|
|
setAll$1(subject, definition.attributes);
|
|
add$1(subject, definition.classes);
|
|
setAll(subject, definition.styles);
|
|
definition.innerHtml.each(function (html) {
|
|
return set$5(subject, html);
|
|
});
|
|
var children = definition.domChildren;
|
|
append$1(subject, children);
|
|
definition.value.each(function (value) {
|
|
set$4(subject, value);
|
|
});
|
|
if (!definition.uid) {
|
|
debugger;
|
|
}
|
|
writeOnly(subject, definition.uid);
|
|
return subject;
|
|
};
|
|
|
|
var getBehaviours$2 = function (spec) {
|
|
var behaviours = get$e(spec, 'behaviours').getOr({});
|
|
return bind$3(keys(behaviours), function (name) {
|
|
var behaviour = behaviours[name];
|
|
return isNonNullable(behaviour) ? [behaviour.me] : [];
|
|
});
|
|
};
|
|
var generateFrom = function (spec, all) {
|
|
return generateFrom$1(spec, all);
|
|
};
|
|
var generate$4 = function (spec) {
|
|
var all = getBehaviours$2(spec);
|
|
return generateFrom(spec, all);
|
|
};
|
|
|
|
var getDomDefinition = function (info, bList, bData) {
|
|
var definition = toDefinition(info);
|
|
var infoModification = toModification(info);
|
|
var baseModification = { 'alloy.base.modification': infoModification };
|
|
var modification = bList.length > 0 ? combine$2(bData, baseModification, bList, definition) : infoModification;
|
|
return merge(definition, modification);
|
|
};
|
|
var getEvents = function (info, bList, bData) {
|
|
var baseEvents = { 'alloy.base.behaviour': toEvents(info) };
|
|
return combine$1(bData, info.eventOrder, bList, baseEvents).getOrDie();
|
|
};
|
|
var build$2 = function (spec) {
|
|
var getMe = function () {
|
|
return me;
|
|
};
|
|
var systemApi = Cell(singleton$1);
|
|
var info = getOrDie(toInfo(spec));
|
|
var bBlob = generate$4(spec);
|
|
var bList = getBehaviours$3(bBlob);
|
|
var bData = getData$2(bBlob);
|
|
var modDefinition = getDomDefinition(info, bList, bData);
|
|
var item = renderToDom(modDefinition);
|
|
var events = getEvents(info, bList, bData);
|
|
var subcomponents = Cell(info.components);
|
|
var connect = function (newApi) {
|
|
systemApi.set(newApi);
|
|
};
|
|
var disconnect = function () {
|
|
systemApi.set(NoContextApi(getMe));
|
|
};
|
|
var syncComponents = function () {
|
|
var children$1 = children(item);
|
|
var subs = bind$3(children$1, function (child) {
|
|
return systemApi.get().getByDom(child).fold(function () {
|
|
return [];
|
|
}, pure$2);
|
|
});
|
|
subcomponents.set(subs);
|
|
};
|
|
var config = function (behaviour) {
|
|
var b = bData;
|
|
var f = isFunction(b[behaviour.name()]) ? b[behaviour.name()] : function () {
|
|
throw new Error('Could not find ' + behaviour.name() + ' in ' + JSON.stringify(spec, null, 2));
|
|
};
|
|
return f();
|
|
};
|
|
var hasConfigured = function (behaviour) {
|
|
return isFunction(bData[behaviour.name()]);
|
|
};
|
|
var getApis = function () {
|
|
return info.apis;
|
|
};
|
|
var readState = function (behaviourName) {
|
|
return bData[behaviourName]().map(function (b) {
|
|
return b.state.readState();
|
|
}).getOr('not enabled');
|
|
};
|
|
var me = {
|
|
uid: spec.uid,
|
|
getSystem: systemApi.get,
|
|
config: config,
|
|
hasConfigured: hasConfigured,
|
|
spec: spec,
|
|
readState: readState,
|
|
getApis: getApis,
|
|
connect: connect,
|
|
disconnect: disconnect,
|
|
element: item,
|
|
syncComponents: syncComponents,
|
|
components: subcomponents.get,
|
|
events: events
|
|
};
|
|
return me;
|
|
};
|
|
|
|
var buildSubcomponents = function (spec) {
|
|
var components = get$e(spec, 'components').getOr([]);
|
|
return map$2(components, build$1);
|
|
};
|
|
var buildFromSpec = function (userSpec) {
|
|
var _a = make$8(userSpec), specEvents = _a.events, spec = __rest(_a, ['events']);
|
|
var components = buildSubcomponents(spec);
|
|
var completeSpec = __assign(__assign({}, spec), {
|
|
events: __assign(__assign({}, DefaultEvents), specEvents),
|
|
components: components
|
|
});
|
|
return Result.value(build$2(completeSpec));
|
|
};
|
|
var text = function (textContent) {
|
|
var element = SugarElement.fromText(textContent);
|
|
return external$2({ element: element });
|
|
};
|
|
var external$2 = function (spec) {
|
|
var extSpec = asRawOrDie$1('external.component', objOfOnly([
|
|
required$1('element'),
|
|
option('uid')
|
|
]), spec);
|
|
var systemApi = Cell(NoContextApi());
|
|
var connect = function (newApi) {
|
|
systemApi.set(newApi);
|
|
};
|
|
var disconnect = function () {
|
|
systemApi.set(NoContextApi(function () {
|
|
return me;
|
|
}));
|
|
};
|
|
var uid = extSpec.uid.getOrThunk(function () {
|
|
return generate$5('external');
|
|
});
|
|
writeOnly(extSpec.element, uid);
|
|
var me = {
|
|
uid: uid,
|
|
getSystem: systemApi.get,
|
|
config: Optional.none,
|
|
hasConfigured: never,
|
|
connect: connect,
|
|
disconnect: disconnect,
|
|
getApis: function () {
|
|
return {};
|
|
},
|
|
element: extSpec.element,
|
|
spec: spec,
|
|
readState: constant$1('No state'),
|
|
syncComponents: noop,
|
|
components: constant$1([]),
|
|
events: {}
|
|
};
|
|
return premade$1(me);
|
|
};
|
|
var uids = generate$5;
|
|
var isSketchSpec$1 = function (spec) {
|
|
return has$2(spec, 'uid');
|
|
};
|
|
var build$1 = function (spec) {
|
|
return getPremade(spec).getOrThunk(function () {
|
|
var userSpecWithUid = isSketchSpec$1(spec) ? spec : __assign({ uid: uids('') }, spec);
|
|
return buildFromSpec(userSpecWithUid).getOrDie();
|
|
});
|
|
};
|
|
var premade = premade$1;
|
|
|
|
function ClosestOrAncestor (is, ancestor, scope, a, isRoot) {
|
|
if (is(scope, a)) {
|
|
return Optional.some(scope);
|
|
} else if (isFunction(isRoot) && isRoot(scope)) {
|
|
return Optional.none();
|
|
} else {
|
|
return ancestor(scope, a, isRoot);
|
|
}
|
|
}
|
|
|
|
var ancestor$1 = function (scope, predicate, isRoot) {
|
|
var element = scope.dom;
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
while (element.parentNode) {
|
|
element = element.parentNode;
|
|
var el = SugarElement.fromDom(element);
|
|
if (predicate(el)) {
|
|
return Optional.some(el);
|
|
} else if (stop(el)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var closest$3 = function (scope, predicate, isRoot) {
|
|
var is = function (s, test) {
|
|
return test(s);
|
|
};
|
|
return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
|
|
};
|
|
var child$1 = function (scope, predicate) {
|
|
var pred = function (node) {
|
|
return predicate(SugarElement.fromDom(node));
|
|
};
|
|
var result = find$5(scope.dom.childNodes, pred);
|
|
return result.map(SugarElement.fromDom);
|
|
};
|
|
var descendant$1 = function (scope, predicate) {
|
|
var descend = function (node) {
|
|
for (var i = 0; i < node.childNodes.length; i++) {
|
|
var child_1 = SugarElement.fromDom(node.childNodes[i]);
|
|
if (predicate(child_1)) {
|
|
return Optional.some(child_1);
|
|
}
|
|
var res = descend(node.childNodes[i]);
|
|
if (res.isSome()) {
|
|
return res;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
return descend(scope.dom);
|
|
};
|
|
|
|
var closest$2 = function (scope, predicate, isRoot) {
|
|
return closest$3(scope, predicate, isRoot).isSome();
|
|
};
|
|
|
|
var ancestor = function (scope, selector, isRoot) {
|
|
return ancestor$1(scope, function (e) {
|
|
return is(e, selector);
|
|
}, isRoot);
|
|
};
|
|
var child = function (scope, selector) {
|
|
return child$1(scope, function (e) {
|
|
return is(e, selector);
|
|
});
|
|
};
|
|
var descendant = function (scope, selector) {
|
|
return one(selector, scope);
|
|
};
|
|
var closest$1 = function (scope, selector, isRoot) {
|
|
var is$1 = function (element, selector) {
|
|
return is(element, selector);
|
|
};
|
|
return ClosestOrAncestor(is$1, ancestor, scope, selector, isRoot);
|
|
};
|
|
|
|
var find$1 = function (queryElem) {
|
|
var dependent = closest$3(queryElem, function (elem) {
|
|
if (!isElement$2(elem)) {
|
|
return false;
|
|
}
|
|
var id = get$d(elem, 'id');
|
|
return id !== undefined && id.indexOf('aria-owns') > -1;
|
|
});
|
|
return dependent.bind(function (dep) {
|
|
var id = get$d(dep, 'id');
|
|
var dos = getRootNode(dep);
|
|
return descendant(dos, '[aria-owns="' + id + '"]');
|
|
});
|
|
};
|
|
var manager = function () {
|
|
var ariaId = generate$6('aria-owns');
|
|
var link = function (elem) {
|
|
set$8(elem, 'aria-owns', ariaId);
|
|
};
|
|
var unlink = function (elem) {
|
|
remove$7(elem, 'aria-owns');
|
|
};
|
|
return {
|
|
id: ariaId,
|
|
link: link,
|
|
unlink: unlink
|
|
};
|
|
};
|
|
|
|
var isAriaPartOf = function (component, queryElem) {
|
|
return find$1(queryElem).exists(function (owner) {
|
|
return isPartOf$1(component, owner);
|
|
});
|
|
};
|
|
var isPartOf$1 = function (component, queryElem) {
|
|
return closest$2(queryElem, function (el) {
|
|
return eq(el, component.element);
|
|
}, never) || isAriaPartOf(component, queryElem);
|
|
};
|
|
|
|
var unknown = 'unknown';
|
|
var EventConfiguration;
|
|
(function (EventConfiguration) {
|
|
EventConfiguration[EventConfiguration['STOP'] = 0] = 'STOP';
|
|
EventConfiguration[EventConfiguration['NORMAL'] = 1] = 'NORMAL';
|
|
EventConfiguration[EventConfiguration['LOGGING'] = 2] = 'LOGGING';
|
|
}(EventConfiguration || (EventConfiguration = {})));
|
|
var eventConfig = Cell({});
|
|
var makeEventLogger = function (eventName, initialTarget) {
|
|
var sequence = [];
|
|
var startTime = new Date().getTime();
|
|
return {
|
|
logEventCut: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'cut',
|
|
target: target,
|
|
purpose: purpose
|
|
});
|
|
},
|
|
logEventStopped: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'stopped',
|
|
target: target,
|
|
purpose: purpose
|
|
});
|
|
},
|
|
logNoParent: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'no-parent',
|
|
target: target,
|
|
purpose: purpose
|
|
});
|
|
},
|
|
logEventNoHandlers: function (_name, target) {
|
|
sequence.push({
|
|
outcome: 'no-handlers-left',
|
|
target: target
|
|
});
|
|
},
|
|
logEventResponse: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'response',
|
|
purpose: purpose,
|
|
target: target
|
|
});
|
|
},
|
|
write: function () {
|
|
var finishTime = new Date().getTime();
|
|
if (contains$2([
|
|
'mousemove',
|
|
'mouseover',
|
|
'mouseout',
|
|
systemInit()
|
|
], eventName)) {
|
|
return;
|
|
}
|
|
console.log(eventName, {
|
|
event: eventName,
|
|
time: finishTime - startTime,
|
|
target: initialTarget.dom,
|
|
sequence: map$2(sequence, function (s) {
|
|
if (!contains$2([
|
|
'cut',
|
|
'stopped',
|
|
'response'
|
|
], s.outcome)) {
|
|
return s.outcome;
|
|
} else {
|
|
return '{' + s.purpose + '} ' + s.outcome + ' at (' + element(s.target) + ')';
|
|
}
|
|
})
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var processEvent = function (eventName, initialTarget, f) {
|
|
var status = get$e(eventConfig.get(), eventName).orThunk(function () {
|
|
var patterns = keys(eventConfig.get());
|
|
return findMap(patterns, function (p) {
|
|
return eventName.indexOf(p) > -1 ? Optional.some(eventConfig.get()[p]) : Optional.none();
|
|
});
|
|
}).getOr(EventConfiguration.NORMAL);
|
|
switch (status) {
|
|
case EventConfiguration.NORMAL:
|
|
return f(noLogger());
|
|
case EventConfiguration.LOGGING: {
|
|
var logger = makeEventLogger(eventName, initialTarget);
|
|
var output = f(logger);
|
|
logger.write();
|
|
return output;
|
|
}
|
|
case EventConfiguration.STOP:
|
|
return true;
|
|
}
|
|
};
|
|
var path = [
|
|
'alloy/data/Fields',
|
|
'alloy/debugging/Debugging'
|
|
];
|
|
var getTrace = function () {
|
|
var err = new Error();
|
|
if (err.stack !== undefined) {
|
|
var lines = err.stack.split('\n');
|
|
return find$5(lines, function (line) {
|
|
return line.indexOf('alloy') > 0 && !exists(path, function (p) {
|
|
return line.indexOf(p) > -1;
|
|
});
|
|
}).getOr(unknown);
|
|
} else {
|
|
return unknown;
|
|
}
|
|
};
|
|
var ignoreEvent = {
|
|
logEventCut: noop,
|
|
logEventStopped: noop,
|
|
logNoParent: noop,
|
|
logEventNoHandlers: noop,
|
|
logEventResponse: noop,
|
|
write: noop
|
|
};
|
|
var monitorEvent = function (eventName, initialTarget, f) {
|
|
return processEvent(eventName, initialTarget, f);
|
|
};
|
|
var noLogger = constant$1(ignoreEvent);
|
|
|
|
var menuFields = constant$1([
|
|
required$1('menu'),
|
|
required$1('selectedMenu')
|
|
]);
|
|
var itemFields = constant$1([
|
|
required$1('item'),
|
|
required$1('selectedItem')
|
|
]);
|
|
constant$1(objOf(itemFields().concat(menuFields())));
|
|
var itemSchema$3 = constant$1(objOf(itemFields()));
|
|
|
|
var _initSize = requiredObjOf('initSize', [
|
|
required$1('numColumns'),
|
|
required$1('numRows')
|
|
]);
|
|
var itemMarkers = function () {
|
|
return requiredOf('markers', itemSchema$3());
|
|
};
|
|
var tieredMenuMarkers = function () {
|
|
return requiredObjOf('markers', [required$1('backgroundMenu')].concat(menuFields()).concat(itemFields()));
|
|
};
|
|
var markers$1 = function (required) {
|
|
return requiredObjOf('markers', map$2(required, required$1));
|
|
};
|
|
var onPresenceHandler = function (label, fieldName, presence) {
|
|
getTrace();
|
|
return field$1(fieldName, fieldName, presence, valueOf(function (f) {
|
|
return Result.value(function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return f.apply(undefined, args);
|
|
});
|
|
}));
|
|
};
|
|
var onHandler = function (fieldName) {
|
|
return onPresenceHandler('onHandler', fieldName, defaulted$1(noop));
|
|
};
|
|
var onKeyboardHandler = function (fieldName) {
|
|
return onPresenceHandler('onKeyboardHandler', fieldName, defaulted$1(Optional.none));
|
|
};
|
|
var onStrictHandler = function (fieldName) {
|
|
return onPresenceHandler('onHandler', fieldName, required$2());
|
|
};
|
|
var onStrictKeyboardHandler = function (fieldName) {
|
|
return onPresenceHandler('onKeyboardHandler', fieldName, required$2());
|
|
};
|
|
var output$1 = function (name, value) {
|
|
return customField(name, constant$1(value));
|
|
};
|
|
var snapshot = function (name) {
|
|
return customField(name, identity$1);
|
|
};
|
|
var initSize = constant$1(_initSize);
|
|
|
|
var nu$6 = function (x, y, bubble, direction, placement, boundsRestriction, labelPrefix, alwaysFit) {
|
|
if (alwaysFit === void 0) {
|
|
alwaysFit = false;
|
|
}
|
|
return {
|
|
x: x,
|
|
y: y,
|
|
bubble: bubble,
|
|
direction: direction,
|
|
placement: placement,
|
|
restriction: boundsRestriction,
|
|
label: labelPrefix + '-' + placement,
|
|
alwaysFit: alwaysFit
|
|
};
|
|
};
|
|
|
|
var adt$a = Adt.generate([
|
|
{ southeast: [] },
|
|
{ southwest: [] },
|
|
{ northeast: [] },
|
|
{ northwest: [] },
|
|
{ south: [] },
|
|
{ north: [] },
|
|
{ east: [] },
|
|
{ west: [] }
|
|
]);
|
|
var cata$2 = function (subject, southeast, southwest, northeast, northwest, south, north, east, west) {
|
|
return subject.fold(southeast, southwest, northeast, northwest, south, north, east, west);
|
|
};
|
|
var cataVertical = function (subject, south, middle, north) {
|
|
return subject.fold(south, south, north, north, south, north, middle, middle);
|
|
};
|
|
var cataHorizontal = function (subject, east, middle, west) {
|
|
return subject.fold(east, west, east, west, middle, middle, east, west);
|
|
};
|
|
var southeast$3 = adt$a.southeast;
|
|
var southwest$3 = adt$a.southwest;
|
|
var northeast$3 = adt$a.northeast;
|
|
var northwest$3 = adt$a.northwest;
|
|
var south$3 = adt$a.south;
|
|
var north$3 = adt$a.north;
|
|
var east$3 = adt$a.east;
|
|
var west$3 = adt$a.west;
|
|
|
|
var cycleBy = function (value, delta, min, max) {
|
|
var r = value + delta;
|
|
if (r > max) {
|
|
return min;
|
|
} else if (r < min) {
|
|
return max;
|
|
} else {
|
|
return r;
|
|
}
|
|
};
|
|
var clamp$1 = function (value, min, max) {
|
|
return Math.min(Math.max(value, min), max);
|
|
};
|
|
|
|
var getRestriction = function (anchor, restriction) {
|
|
switch (restriction) {
|
|
case 1:
|
|
return anchor.x;
|
|
case 0:
|
|
return anchor.x + anchor.width;
|
|
case 2:
|
|
return anchor.y;
|
|
case 3:
|
|
return anchor.y + anchor.height;
|
|
}
|
|
};
|
|
var boundsRestriction = function (anchor, restrictions) {
|
|
return mapToObject([
|
|
'left',
|
|
'right',
|
|
'top',
|
|
'bottom'
|
|
], function (dir) {
|
|
return get$e(restrictions, dir).map(function (restriction) {
|
|
return getRestriction(anchor, restriction);
|
|
});
|
|
});
|
|
};
|
|
var adjustBounds = function (bounds$1, restriction, bubbleOffset) {
|
|
var applyRestriction = function (dir, current) {
|
|
return restriction[dir].map(function (pos) {
|
|
var isVerticalAxis = dir === 'top' || dir === 'bottom';
|
|
var offset = isVerticalAxis ? bubbleOffset.top : bubbleOffset.left;
|
|
var comparator = dir === 'left' || dir === 'top' ? Math.max : Math.min;
|
|
var newPos = comparator(pos, current) + offset;
|
|
return isVerticalAxis ? clamp$1(newPos, bounds$1.y, bounds$1.bottom) : clamp$1(newPos, bounds$1.x, bounds$1.right);
|
|
}).getOr(current);
|
|
};
|
|
var adjustedLeft = applyRestriction('left', bounds$1.x);
|
|
var adjustedTop = applyRestriction('top', bounds$1.y);
|
|
var adjustedRight = applyRestriction('right', bounds$1.right);
|
|
var adjustedBottom = applyRestriction('bottom', bounds$1.bottom);
|
|
return bounds(adjustedLeft, adjustedTop, adjustedRight - adjustedLeft, adjustedBottom - adjustedTop);
|
|
};
|
|
|
|
var labelPrefix$2 = 'layout';
|
|
var eastX$1 = function (anchor) {
|
|
return anchor.x;
|
|
};
|
|
var middleX$1 = function (anchor, element) {
|
|
return anchor.x + anchor.width / 2 - element.width / 2;
|
|
};
|
|
var westX$1 = function (anchor, element) {
|
|
return anchor.x + anchor.width - element.width;
|
|
};
|
|
var northY$2 = function (anchor, element) {
|
|
return anchor.y - element.height;
|
|
};
|
|
var southY$2 = function (anchor) {
|
|
return anchor.y + anchor.height;
|
|
};
|
|
var centreY$1 = function (anchor, element) {
|
|
return anchor.y + anchor.height / 2 - element.height / 2;
|
|
};
|
|
var eastEdgeX$1 = function (anchor) {
|
|
return anchor.x + anchor.width;
|
|
};
|
|
var westEdgeX$1 = function (anchor, element) {
|
|
return anchor.x - element.width;
|
|
};
|
|
var southeast$2 = function (anchor, element, bubbles) {
|
|
return nu$6(eastX$1(anchor), southY$2(anchor), bubbles.southeast(), southeast$3(), 'southeast', boundsRestriction(anchor, {
|
|
left: 1,
|
|
top: 3
|
|
}), labelPrefix$2);
|
|
};
|
|
var southwest$2 = function (anchor, element, bubbles) {
|
|
return nu$6(westX$1(anchor, element), southY$2(anchor), bubbles.southwest(), southwest$3(), 'southwest', boundsRestriction(anchor, {
|
|
right: 0,
|
|
top: 3
|
|
}), labelPrefix$2);
|
|
};
|
|
var northeast$2 = function (anchor, element, bubbles) {
|
|
return nu$6(eastX$1(anchor), northY$2(anchor, element), bubbles.northeast(), northeast$3(), 'northeast', boundsRestriction(anchor, {
|
|
left: 1,
|
|
bottom: 2
|
|
}), labelPrefix$2);
|
|
};
|
|
var northwest$2 = function (anchor, element, bubbles) {
|
|
return nu$6(westX$1(anchor, element), northY$2(anchor, element), bubbles.northwest(), northwest$3(), 'northwest', boundsRestriction(anchor, {
|
|
right: 0,
|
|
bottom: 2
|
|
}), labelPrefix$2);
|
|
};
|
|
var north$2 = function (anchor, element, bubbles) {
|
|
return nu$6(middleX$1(anchor, element), northY$2(anchor, element), bubbles.north(), north$3(), 'north', boundsRestriction(anchor, { bottom: 2 }), labelPrefix$2);
|
|
};
|
|
var south$2 = function (anchor, element, bubbles) {
|
|
return nu$6(middleX$1(anchor, element), southY$2(anchor), bubbles.south(), south$3(), 'south', boundsRestriction(anchor, { top: 3 }), labelPrefix$2);
|
|
};
|
|
var east$2 = function (anchor, element, bubbles) {
|
|
return nu$6(eastEdgeX$1(anchor), centreY$1(anchor, element), bubbles.east(), east$3(), 'east', boundsRestriction(anchor, { left: 0 }), labelPrefix$2);
|
|
};
|
|
var west$2 = function (anchor, element, bubbles) {
|
|
return nu$6(westEdgeX$1(anchor, element), centreY$1(anchor, element), bubbles.west(), west$3(), 'west', boundsRestriction(anchor, { right: 1 }), labelPrefix$2);
|
|
};
|
|
var all$1 = function () {
|
|
return [
|
|
southeast$2,
|
|
southwest$2,
|
|
northeast$2,
|
|
northwest$2,
|
|
south$2,
|
|
north$2,
|
|
east$2,
|
|
west$2
|
|
];
|
|
};
|
|
var allRtl$1 = function () {
|
|
return [
|
|
southwest$2,
|
|
southeast$2,
|
|
northwest$2,
|
|
northeast$2,
|
|
south$2,
|
|
north$2,
|
|
east$2,
|
|
west$2
|
|
];
|
|
};
|
|
var aboveOrBelow = function () {
|
|
return [
|
|
northeast$2,
|
|
northwest$2,
|
|
southeast$2,
|
|
southwest$2,
|
|
north$2,
|
|
south$2
|
|
];
|
|
};
|
|
var aboveOrBelowRtl = function () {
|
|
return [
|
|
northwest$2,
|
|
northeast$2,
|
|
southwest$2,
|
|
southeast$2,
|
|
north$2,
|
|
south$2
|
|
];
|
|
};
|
|
var belowOrAbove = function () {
|
|
return [
|
|
southeast$2,
|
|
southwest$2,
|
|
northeast$2,
|
|
northwest$2,
|
|
south$2,
|
|
north$2
|
|
];
|
|
};
|
|
var belowOrAboveRtl = function () {
|
|
return [
|
|
southwest$2,
|
|
southeast$2,
|
|
northwest$2,
|
|
northeast$2,
|
|
south$2,
|
|
north$2
|
|
];
|
|
};
|
|
|
|
var chooseChannels = function (channels, message) {
|
|
return message.universal ? channels : filter$2(channels, function (ch) {
|
|
return contains$2(message.channels, ch);
|
|
});
|
|
};
|
|
var events$h = function (receiveConfig) {
|
|
return derive$2([run$1(receive(), function (component, message) {
|
|
var channelMap = receiveConfig.channels;
|
|
var channels = keys(channelMap);
|
|
var receivingData = message;
|
|
var targetChannels = chooseChannels(channels, receivingData);
|
|
each$1(targetChannels, function (ch) {
|
|
var channelInfo = channelMap[ch];
|
|
var channelSchema = channelInfo.schema;
|
|
var data = asRawOrDie$1('channel[' + ch + '] data\nReceiver: ' + element(component.element), channelSchema, receivingData.data);
|
|
channelInfo.onReceive(component, data);
|
|
});
|
|
})]);
|
|
};
|
|
|
|
var ActiveReceiving = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$h
|
|
});
|
|
|
|
var ReceivingSchema = [requiredOf('channels', setOf(Result.value, objOfOnly([
|
|
onStrictHandler('onReceive'),
|
|
defaulted('schema', anyValue())
|
|
])))];
|
|
|
|
var executeEvent = function (bConfig, bState, executor) {
|
|
return runOnExecute$1(function (component) {
|
|
executor(component, bConfig, bState);
|
|
});
|
|
};
|
|
var loadEvent = function (bConfig, bState, f) {
|
|
return runOnInit(function (component, _simulatedEvent) {
|
|
f(component, bConfig, bState);
|
|
});
|
|
};
|
|
var create$8 = function (schema, name, active, apis, extra, state) {
|
|
var configSchema = objOfOnly(schema);
|
|
var schemaSchema = optionObjOf(name, [optionObjOfOnly('config', schema)]);
|
|
return doCreate(configSchema, schemaSchema, name, active, apis, extra, state);
|
|
};
|
|
var createModes$1 = function (modes, name, active, apis, extra, state) {
|
|
var configSchema = modes;
|
|
var schemaSchema = optionObjOf(name, [optionOf('config', modes)]);
|
|
return doCreate(configSchema, schemaSchema, name, active, apis, extra, state);
|
|
};
|
|
var wrapApi = function (bName, apiFunction, apiName) {
|
|
var f = function (component) {
|
|
var rest = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
rest[_i - 1] = arguments[_i];
|
|
}
|
|
var args = [component].concat(rest);
|
|
return component.config({ name: constant$1(bName) }).fold(function () {
|
|
throw new Error('We could not find any behaviour configuration for: ' + bName + '. Using API: ' + apiName);
|
|
}, function (info) {
|
|
var rest = Array.prototype.slice.call(args, 1);
|
|
return apiFunction.apply(undefined, [
|
|
component,
|
|
info.config,
|
|
info.state
|
|
].concat(rest));
|
|
});
|
|
};
|
|
return markAsBehaviourApi(f, apiName, apiFunction);
|
|
};
|
|
var revokeBehaviour = function (name) {
|
|
return {
|
|
key: name,
|
|
value: undefined
|
|
};
|
|
};
|
|
var doCreate = function (configSchema, schemaSchema, name, active, apis, extra, state) {
|
|
var getConfig = function (info) {
|
|
return hasNonNullableKey(info, name) ? info[name]() : Optional.none();
|
|
};
|
|
var wrappedApis = map$1(apis, function (apiF, apiName) {
|
|
return wrapApi(name, apiF, apiName);
|
|
});
|
|
var wrappedExtra = map$1(extra, function (extraF, extraName) {
|
|
return markAsExtraApi(extraF, extraName);
|
|
});
|
|
var me = __assign(__assign(__assign({}, wrappedExtra), wrappedApis), {
|
|
revoke: curry(revokeBehaviour, name),
|
|
config: function (spec) {
|
|
var prepared = asRawOrDie$1(name + '-config', configSchema, spec);
|
|
return {
|
|
key: name,
|
|
value: {
|
|
config: prepared,
|
|
me: me,
|
|
configAsRaw: cached(function () {
|
|
return asRawOrDie$1(name + '-config', configSchema, spec);
|
|
}),
|
|
initialConfig: spec,
|
|
state: state
|
|
}
|
|
};
|
|
},
|
|
schema: constant$1(schemaSchema),
|
|
exhibit: function (info, base) {
|
|
return lift2(getConfig(info), get$e(active, 'exhibit'), function (behaviourInfo, exhibitor) {
|
|
return exhibitor(base, behaviourInfo.config, behaviourInfo.state);
|
|
}).getOrThunk(function () {
|
|
return nu$7({});
|
|
});
|
|
},
|
|
name: constant$1(name),
|
|
handlers: function (info) {
|
|
return getConfig(info).map(function (behaviourInfo) {
|
|
var getEvents = get$e(active, 'events').getOr(function () {
|
|
return {};
|
|
});
|
|
return getEvents(behaviourInfo.config, behaviourInfo.state);
|
|
}).getOr({});
|
|
}
|
|
});
|
|
return me;
|
|
};
|
|
|
|
var derive$1 = function (capabilities) {
|
|
return wrapAll(capabilities);
|
|
};
|
|
var simpleSchema = objOfOnly([
|
|
required$1('fields'),
|
|
required$1('name'),
|
|
defaulted('active', {}),
|
|
defaulted('apis', {}),
|
|
defaulted('state', NoState),
|
|
defaulted('extra', {})
|
|
]);
|
|
var create$7 = function (data) {
|
|
var value = asRawOrDie$1('Creating behaviour: ' + data.name, simpleSchema, data);
|
|
return create$8(value.fields, value.name, value.active, value.apis, value.extra, value.state);
|
|
};
|
|
var modeSchema = objOfOnly([
|
|
required$1('branchKey'),
|
|
required$1('branches'),
|
|
required$1('name'),
|
|
defaulted('active', {}),
|
|
defaulted('apis', {}),
|
|
defaulted('state', NoState),
|
|
defaulted('extra', {})
|
|
]);
|
|
var createModes = function (data) {
|
|
var value = asRawOrDie$1('Creating behaviour: ' + data.name, modeSchema, data);
|
|
return createModes$1(choose$1(value.branchKey, value.branches), value.name, value.active, value.apis, value.extra, value.state);
|
|
};
|
|
var revoke = constant$1(undefined);
|
|
|
|
var Receiving = create$7({
|
|
fields: ReceivingSchema,
|
|
name: 'receiving',
|
|
active: ActiveReceiving
|
|
});
|
|
|
|
var exhibit$6 = function (base, posConfig) {
|
|
return nu$7({
|
|
classes: [],
|
|
styles: posConfig.useFixed() ? {} : { position: 'relative' }
|
|
});
|
|
};
|
|
|
|
var ActivePosition = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$6
|
|
});
|
|
|
|
var getDocument = function () {
|
|
return SugarElement.fromDom(document);
|
|
};
|
|
|
|
var focus$3 = function (element) {
|
|
return element.dom.focus();
|
|
};
|
|
var blur$1 = function (element) {
|
|
return element.dom.blur();
|
|
};
|
|
var hasFocus = function (element) {
|
|
var root = getRootNode(element).dom;
|
|
return element.dom === root.activeElement;
|
|
};
|
|
var active = function (root) {
|
|
if (root === void 0) {
|
|
root = getDocument();
|
|
}
|
|
return Optional.from(root.dom.activeElement).map(SugarElement.fromDom);
|
|
};
|
|
var search = function (element) {
|
|
return active(getRootNode(element)).filter(function (e) {
|
|
return element.dom.contains(e.dom);
|
|
});
|
|
};
|
|
|
|
var preserve$1 = function (f, container) {
|
|
var dos = getRootNode(container);
|
|
var refocus = active(dos).bind(function (focused) {
|
|
var hasFocus = function (elem) {
|
|
return eq(focused, elem);
|
|
};
|
|
return hasFocus(container) ? Optional.some(container) : descendant$1(container, hasFocus);
|
|
});
|
|
var result = f(container);
|
|
refocus.each(function (oldFocus) {
|
|
active(dos).filter(function (newFocus) {
|
|
return eq(newFocus, oldFocus);
|
|
}).fold(function () {
|
|
focus$3(oldFocus);
|
|
}, noop);
|
|
});
|
|
return result;
|
|
};
|
|
|
|
var NuPositionCss = function (position, left, top, right, bottom) {
|
|
var toPx = function (num) {
|
|
return num + 'px';
|
|
};
|
|
return {
|
|
position: position,
|
|
left: left.map(toPx),
|
|
top: top.map(toPx),
|
|
right: right.map(toPx),
|
|
bottom: bottom.map(toPx)
|
|
};
|
|
};
|
|
var toOptions = function (position) {
|
|
return __assign(__assign({}, position), { position: Optional.some(position.position) });
|
|
};
|
|
var applyPositionCss = function (element, position) {
|
|
setOptions(element, toOptions(position));
|
|
};
|
|
|
|
var adt$9 = Adt.generate([
|
|
{ none: [] },
|
|
{
|
|
relative: [
|
|
'x',
|
|
'y',
|
|
'width',
|
|
'height'
|
|
]
|
|
},
|
|
{
|
|
fixed: [
|
|
'x',
|
|
'y',
|
|
'width',
|
|
'height'
|
|
]
|
|
}
|
|
]);
|
|
var positionWithDirection = function (posName, decision, x, y, width, height) {
|
|
var decisionRect = decision.rect;
|
|
var decisionX = decisionRect.x - x;
|
|
var decisionY = decisionRect.y - y;
|
|
var decisionWidth = decisionRect.width;
|
|
var decisionHeight = decisionRect.height;
|
|
var decisionRight = width - (decisionX + decisionWidth);
|
|
var decisionBottom = height - (decisionY + decisionHeight);
|
|
var left = Optional.some(decisionX);
|
|
var top = Optional.some(decisionY);
|
|
var right = Optional.some(decisionRight);
|
|
var bottom = Optional.some(decisionBottom);
|
|
var none = Optional.none();
|
|
return cata$2(decision.direction, function () {
|
|
return NuPositionCss(posName, left, top, none, none);
|
|
}, function () {
|
|
return NuPositionCss(posName, none, top, right, none);
|
|
}, function () {
|
|
return NuPositionCss(posName, left, none, none, bottom);
|
|
}, function () {
|
|
return NuPositionCss(posName, none, none, right, bottom);
|
|
}, function () {
|
|
return NuPositionCss(posName, left, top, none, none);
|
|
}, function () {
|
|
return NuPositionCss(posName, left, none, none, bottom);
|
|
}, function () {
|
|
return NuPositionCss(posName, left, top, none, none);
|
|
}, function () {
|
|
return NuPositionCss(posName, none, top, right, none);
|
|
});
|
|
};
|
|
var reposition = function (origin, decision) {
|
|
return origin.fold(function () {
|
|
var decisionRect = decision.rect;
|
|
return NuPositionCss('absolute', Optional.some(decisionRect.x), Optional.some(decisionRect.y), Optional.none(), Optional.none());
|
|
}, function (x, y, width, height) {
|
|
return positionWithDirection('absolute', decision, x, y, width, height);
|
|
}, function (x, y, width, height) {
|
|
return positionWithDirection('fixed', decision, x, y, width, height);
|
|
});
|
|
};
|
|
var toBox = function (origin, element) {
|
|
var rel = curry(find$2, element);
|
|
var position = origin.fold(rel, rel, function () {
|
|
var scroll = get$9();
|
|
return find$2(element).translate(-scroll.left, -scroll.top);
|
|
});
|
|
var width = getOuter$1(element);
|
|
var height = getOuter$2(element);
|
|
return bounds(position.left, position.top, width, height);
|
|
};
|
|
var viewport = function (origin, getBounds) {
|
|
return getBounds.fold(function () {
|
|
return origin.fold(win, win, bounds);
|
|
}, function (b) {
|
|
return origin.fold(b, b, function () {
|
|
var bounds$1 = b();
|
|
var pos = translate$2(origin, bounds$1.x, bounds$1.y);
|
|
return bounds(pos.left, pos.top, bounds$1.width, bounds$1.height);
|
|
});
|
|
});
|
|
};
|
|
var translate$2 = function (origin, x, y) {
|
|
var pos = SugarPosition(x, y);
|
|
var removeScroll = function () {
|
|
var outerScroll = get$9();
|
|
return pos.translate(-outerScroll.left, -outerScroll.top);
|
|
};
|
|
return origin.fold(constant$1(pos), constant$1(pos), removeScroll);
|
|
};
|
|
var cata$1 = function (subject, onNone, onRelative, onFixed) {
|
|
return subject.fold(onNone, onRelative, onFixed);
|
|
};
|
|
adt$9.none;
|
|
var relative$1 = adt$9.relative;
|
|
var fixed$1 = adt$9.fixed;
|
|
|
|
var anchor = function (anchorBox, origin) {
|
|
return {
|
|
anchorBox: anchorBox,
|
|
origin: origin
|
|
};
|
|
};
|
|
var box = function (anchorBox, origin) {
|
|
return anchor(anchorBox, origin);
|
|
};
|
|
|
|
var placementAttribute = 'data-alloy-placement';
|
|
var setPlacement$1 = function (element, placement) {
|
|
set$8(element, placementAttribute, placement);
|
|
};
|
|
var getPlacement = function (element) {
|
|
return getOpt(element, placementAttribute);
|
|
};
|
|
var reset$2 = function (element) {
|
|
return remove$7(element, placementAttribute);
|
|
};
|
|
|
|
var adt$8 = Adt.generate([
|
|
{ fit: ['reposition'] },
|
|
{
|
|
nofit: [
|
|
'reposition',
|
|
'visibleW',
|
|
'visibleH',
|
|
'isVisible'
|
|
]
|
|
}
|
|
]);
|
|
var determinePosition = function (box, bounds) {
|
|
var boundsX = bounds.x, boundsY = bounds.y, boundsRight = bounds.right, boundsBottom = bounds.bottom;
|
|
var x = box.x, y = box.y, right = box.right, bottom = box.bottom, width = box.width, height = box.height;
|
|
var xInBounds = x >= boundsX && x <= boundsRight;
|
|
var yInBounds = y >= boundsY && y <= boundsBottom;
|
|
var originInBounds = xInBounds && yInBounds;
|
|
var rightInBounds = right <= boundsRight && right >= boundsX;
|
|
var bottomInBounds = bottom <= boundsBottom && bottom >= boundsY;
|
|
var sizeInBounds = rightInBounds && bottomInBounds;
|
|
var visibleW = Math.min(width, x >= boundsX ? boundsRight - x : right - boundsX);
|
|
var visibleH = Math.min(height, y >= boundsY ? boundsBottom - y : bottom - boundsY);
|
|
return {
|
|
originInBounds: originInBounds,
|
|
sizeInBounds: sizeInBounds,
|
|
visibleW: visibleW,
|
|
visibleH: visibleH
|
|
};
|
|
};
|
|
var calcReposition = function (box, bounds$1) {
|
|
var boundsX = bounds$1.x, boundsY = bounds$1.y, boundsRight = bounds$1.right, boundsBottom = bounds$1.bottom;
|
|
var x = box.x, y = box.y, width = box.width, height = box.height;
|
|
var maxX = Math.max(boundsX, boundsRight - width);
|
|
var maxY = Math.max(boundsY, boundsBottom - height);
|
|
var restrictedX = clamp$1(x, boundsX, maxX);
|
|
var restrictedY = clamp$1(y, boundsY, maxY);
|
|
var restrictedWidth = Math.min(restrictedX + width, boundsRight) - restrictedX;
|
|
var restrictedHeight = Math.min(restrictedY + height, boundsBottom) - restrictedY;
|
|
return bounds(restrictedX, restrictedY, restrictedWidth, restrictedHeight);
|
|
};
|
|
var calcMaxSizes = function (direction, box, bounds) {
|
|
var upAvailable = constant$1(box.bottom - bounds.y);
|
|
var downAvailable = constant$1(bounds.bottom - box.y);
|
|
var maxHeight = cataVertical(direction, downAvailable, downAvailable, upAvailable);
|
|
var westAvailable = constant$1(box.right - bounds.x);
|
|
var eastAvailable = constant$1(bounds.right - box.x);
|
|
var maxWidth = cataHorizontal(direction, eastAvailable, eastAvailable, westAvailable);
|
|
return {
|
|
maxWidth: maxWidth,
|
|
maxHeight: maxHeight
|
|
};
|
|
};
|
|
var attempt = function (candidate, width, height, bounds$1) {
|
|
var bubble = candidate.bubble;
|
|
var bubbleOffset = bubble.offset;
|
|
var adjustedBounds = adjustBounds(bounds$1, candidate.restriction, bubbleOffset);
|
|
var newX = candidate.x + bubbleOffset.left;
|
|
var newY = candidate.y + bubbleOffset.top;
|
|
var box = bounds(newX, newY, width, height);
|
|
var _a = determinePosition(box, adjustedBounds), originInBounds = _a.originInBounds, sizeInBounds = _a.sizeInBounds, visibleW = _a.visibleW, visibleH = _a.visibleH;
|
|
var fits = originInBounds && sizeInBounds;
|
|
var fittedBox = fits ? box : calcReposition(box, adjustedBounds);
|
|
var isPartlyVisible = fittedBox.width > 0 && fittedBox.height > 0;
|
|
var _b = calcMaxSizes(candidate.direction, fittedBox, bounds$1), maxWidth = _b.maxWidth, maxHeight = _b.maxHeight;
|
|
var reposition = {
|
|
rect: fittedBox,
|
|
maxHeight: maxHeight,
|
|
maxWidth: maxWidth,
|
|
direction: candidate.direction,
|
|
placement: candidate.placement,
|
|
classes: {
|
|
on: bubble.classesOn,
|
|
off: bubble.classesOff
|
|
},
|
|
layout: candidate.label,
|
|
testY: newY
|
|
};
|
|
return fits || candidate.alwaysFit ? adt$8.fit(reposition) : adt$8.nofit(reposition, visibleW, visibleH, isPartlyVisible);
|
|
};
|
|
var attempts = function (element, candidates, anchorBox, elementBox, bubbles, bounds) {
|
|
var panelWidth = elementBox.width;
|
|
var panelHeight = elementBox.height;
|
|
var attemptBestFit = function (layout, reposition, visibleW, visibleH, isVisible) {
|
|
var next = layout(anchorBox, elementBox, bubbles, element, bounds);
|
|
var attemptLayout = attempt(next, panelWidth, panelHeight, bounds);
|
|
return attemptLayout.fold(constant$1(attemptLayout), function (newReposition, newVisibleW, newVisibleH, newIsVisible) {
|
|
var improved = isVisible === newIsVisible ? newVisibleH > visibleH || newVisibleW > visibleW : !isVisible && newIsVisible;
|
|
return improved ? attemptLayout : adt$8.nofit(reposition, visibleW, visibleH, isVisible);
|
|
});
|
|
};
|
|
var abc = foldl(candidates, function (b, a) {
|
|
var bestNext = curry(attemptBestFit, a);
|
|
return b.fold(constant$1(b), bestNext);
|
|
}, adt$8.nofit({
|
|
rect: anchorBox,
|
|
maxHeight: elementBox.height,
|
|
maxWidth: elementBox.width,
|
|
direction: southeast$3(),
|
|
placement: 'southeast',
|
|
classes: {
|
|
on: [],
|
|
off: []
|
|
},
|
|
layout: 'none',
|
|
testY: anchorBox.y
|
|
}, -1, -1, false));
|
|
return abc.fold(identity$1, identity$1);
|
|
};
|
|
|
|
var singleton = function (doRevoke) {
|
|
var subject = Cell(Optional.none());
|
|
var revoke = function () {
|
|
return subject.get().each(doRevoke);
|
|
};
|
|
var clear = function () {
|
|
revoke();
|
|
subject.set(Optional.none());
|
|
};
|
|
var isSet = function () {
|
|
return subject.get().isSome();
|
|
};
|
|
var get = function () {
|
|
return subject.get();
|
|
};
|
|
var set = function (s) {
|
|
revoke();
|
|
subject.set(Optional.some(s));
|
|
};
|
|
return {
|
|
clear: clear,
|
|
isSet: isSet,
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var destroyable = function () {
|
|
return singleton(function (s) {
|
|
return s.destroy();
|
|
});
|
|
};
|
|
var unbindable = function () {
|
|
return singleton(function (s) {
|
|
return s.unbind();
|
|
});
|
|
};
|
|
var api$1 = function () {
|
|
var subject = destroyable();
|
|
var run = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { run: run });
|
|
};
|
|
var value$1 = function () {
|
|
var subject = singleton(noop);
|
|
var on = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { on: on });
|
|
};
|
|
|
|
var filter = always;
|
|
var bind = function (element, event, handler) {
|
|
return bind$2(element, event, filter, handler);
|
|
};
|
|
var capture = function (element, event, handler) {
|
|
return capture$1(element, event, filter, handler);
|
|
};
|
|
var fromRawEvent = fromRawEvent$1;
|
|
|
|
var properties = [
|
|
'top',
|
|
'bottom',
|
|
'right',
|
|
'left'
|
|
];
|
|
var timerAttr = 'data-alloy-transition-timer';
|
|
var isTransitioning$1 = function (element, transition) {
|
|
return hasAll(element, transition.classes);
|
|
};
|
|
var shouldApplyTransitionCss = function (transition, decision, lastPlacement) {
|
|
return lastPlacement.exists(function (placer) {
|
|
var mode = transition.mode;
|
|
return mode === 'all' ? true : placer[mode] !== decision[mode];
|
|
});
|
|
};
|
|
var hasChanges = function (position, intermediate) {
|
|
var round = function (value) {
|
|
return parseFloat(value).toFixed(3);
|
|
};
|
|
return find$4(intermediate, function (value, key) {
|
|
var newValue = position[key].map(round);
|
|
var val = value.map(round);
|
|
return !equals(newValue, val);
|
|
}).isSome();
|
|
};
|
|
var getTransitionDuration = function (element) {
|
|
var get = function (name) {
|
|
var style = get$c(element, name);
|
|
var times = isString(style) ? style.split(/\s*,\s*/) : [];
|
|
return filter$2(times, isNotEmpty);
|
|
};
|
|
var parse = function (value) {
|
|
if (isString(value) && /^[\d.]+/.test(value)) {
|
|
var num = parseFloat(value);
|
|
return endsWith(value, 'ms') ? num : num * 1000;
|
|
} else {
|
|
return 0;
|
|
}
|
|
};
|
|
var delay = get('transition-delay');
|
|
var duration = get('transition-duration');
|
|
return foldl(duration, function (acc, dur, i) {
|
|
var time = parse(delay[i]) + parse(dur);
|
|
return Math.max(acc, time);
|
|
}, 0);
|
|
};
|
|
var setupTransitionListeners = function (element, transition) {
|
|
var transitionEnd = unbindable();
|
|
var transitionCancel = unbindable();
|
|
var timer;
|
|
var isSourceTransition = function (e) {
|
|
var _a;
|
|
var pseudoElement = (_a = e.raw.pseudoElement) !== null && _a !== void 0 ? _a : '';
|
|
return eq(e.target, element) && isEmpty(pseudoElement) && contains$2(properties, e.raw.propertyName);
|
|
};
|
|
var transitionDone = function (e) {
|
|
if (isNullable(e) || isSourceTransition(e)) {
|
|
transitionEnd.clear();
|
|
transitionCancel.clear();
|
|
var type = e === null || e === void 0 ? void 0 : e.raw.type;
|
|
if (isNullable(type) || type === transitionend()) {
|
|
clearTimeout(timer);
|
|
remove$7(element, timerAttr);
|
|
remove$1(element, transition.classes);
|
|
}
|
|
}
|
|
};
|
|
var transitionStarted = function () {
|
|
transitionEnd.set(bind(element, transitionend(), transitionDone));
|
|
transitionCancel.set(bind(element, transitioncancel(), transitionDone));
|
|
};
|
|
if ('ontransitionstart' in element.dom) {
|
|
var transitionStart_1 = bind(element, transitionstart(), function (e) {
|
|
if (isSourceTransition(e)) {
|
|
transitionStart_1.unbind();
|
|
transitionStarted();
|
|
}
|
|
});
|
|
} else {
|
|
transitionStarted();
|
|
}
|
|
var duration = getTransitionDuration(element);
|
|
requestAnimationFrame(function () {
|
|
timer = setTimeout(transitionDone, duration + 17);
|
|
set$8(element, timerAttr, timer);
|
|
});
|
|
};
|
|
var startTransitioning = function (element, transition) {
|
|
add$1(element, transition.classes);
|
|
getOpt(element, timerAttr).each(function (timerId) {
|
|
clearTimeout(parseInt(timerId, 10));
|
|
remove$7(element, timerAttr);
|
|
});
|
|
setupTransitionListeners(element, transition);
|
|
};
|
|
var applyTransitionCss = function (element, origin, position, transition, decision, lastPlacement) {
|
|
var shouldTransition = shouldApplyTransitionCss(transition, decision, lastPlacement);
|
|
if (shouldTransition || isTransitioning$1(element, transition)) {
|
|
set$7(element, 'position', position.position);
|
|
var rect = toBox(origin, element);
|
|
var intermediatePosition_1 = reposition(origin, __assign(__assign({}, decision), { rect: rect }));
|
|
var intermediateCssOptions = mapToObject(properties, function (prop) {
|
|
return intermediatePosition_1[prop];
|
|
});
|
|
if (hasChanges(position, intermediateCssOptions)) {
|
|
setOptions(element, intermediateCssOptions);
|
|
if (shouldTransition) {
|
|
startTransitioning(element, transition);
|
|
}
|
|
reflow(element);
|
|
}
|
|
} else {
|
|
remove$1(element, transition.classes);
|
|
}
|
|
};
|
|
|
|
var elementSize = function (p) {
|
|
return {
|
|
width: getOuter$1(p),
|
|
height: getOuter$2(p)
|
|
};
|
|
};
|
|
var layout = function (anchorBox, element, bubbles, options) {
|
|
remove$6(element, 'max-height');
|
|
remove$6(element, 'max-width');
|
|
var elementBox = elementSize(element);
|
|
return attempts(element, options.preference, anchorBox, elementBox, bubbles, options.bounds);
|
|
};
|
|
var setClasses = function (element, decision) {
|
|
var classInfo = decision.classes;
|
|
remove$1(element, classInfo.off);
|
|
add$1(element, classInfo.on);
|
|
};
|
|
var setHeight = function (element, decision, options) {
|
|
var maxHeightFunction = options.maxHeightFunction;
|
|
maxHeightFunction(element, decision.maxHeight);
|
|
};
|
|
var setWidth = function (element, decision, options) {
|
|
var maxWidthFunction = options.maxWidthFunction;
|
|
maxWidthFunction(element, decision.maxWidth);
|
|
};
|
|
var position$2 = function (element, decision, options) {
|
|
var positionCss = reposition(options.origin, decision);
|
|
options.transition.each(function (transition) {
|
|
applyTransitionCss(element, options.origin, positionCss, transition, decision, options.lastPlacement);
|
|
});
|
|
applyPositionCss(element, positionCss);
|
|
};
|
|
var setPlacement = function (element, decision) {
|
|
setPlacement$1(element, decision.placement);
|
|
};
|
|
|
|
var setMaxHeight = function (element, maxHeight) {
|
|
setMax$1(element, Math.floor(maxHeight));
|
|
};
|
|
var anchored = constant$1(function (element, available) {
|
|
setMaxHeight(element, available);
|
|
setAll(element, {
|
|
'overflow-x': 'hidden',
|
|
'overflow-y': 'auto'
|
|
});
|
|
});
|
|
var expandable$1 = constant$1(function (element, available) {
|
|
setMaxHeight(element, available);
|
|
});
|
|
|
|
var defaultOr = function (options, key, dephault) {
|
|
return options[key] === undefined ? dephault : options[key];
|
|
};
|
|
var simple = function (anchor, element, bubble, layouts, lastPlacement, getBounds, overrideOptions, transition) {
|
|
var maxHeightFunction = defaultOr(overrideOptions, 'maxHeightFunction', anchored());
|
|
var maxWidthFunction = defaultOr(overrideOptions, 'maxWidthFunction', noop);
|
|
var anchorBox = anchor.anchorBox;
|
|
var origin = anchor.origin;
|
|
var options = {
|
|
bounds: viewport(origin, getBounds),
|
|
origin: origin,
|
|
preference: layouts,
|
|
maxHeightFunction: maxHeightFunction,
|
|
maxWidthFunction: maxWidthFunction,
|
|
lastPlacement: lastPlacement,
|
|
transition: transition
|
|
};
|
|
return go(anchorBox, element, bubble, options);
|
|
};
|
|
var go = function (anchorBox, element, bubble, options) {
|
|
var decision = layout(anchorBox, element, bubble, options);
|
|
position$2(element, decision, options);
|
|
setPlacement(element, decision);
|
|
setClasses(element, decision);
|
|
setHeight(element, decision, options);
|
|
setWidth(element, decision, options);
|
|
return {
|
|
layout: decision.layout,
|
|
placement: decision.placement
|
|
};
|
|
};
|
|
|
|
var allAlignments = [
|
|
'valignCentre',
|
|
'alignLeft',
|
|
'alignRight',
|
|
'alignCentre',
|
|
'top',
|
|
'bottom',
|
|
'left',
|
|
'right',
|
|
'inset'
|
|
];
|
|
var nu$5 = function (xOffset, yOffset, classes, insetModifier) {
|
|
if (insetModifier === void 0) {
|
|
insetModifier = 1;
|
|
}
|
|
var insetXOffset = xOffset * insetModifier;
|
|
var insetYOffset = yOffset * insetModifier;
|
|
var getClasses = function (prop) {
|
|
return get$e(classes, prop).getOr([]);
|
|
};
|
|
var make = function (xDelta, yDelta, alignmentsOn) {
|
|
var alignmentsOff = difference(allAlignments, alignmentsOn);
|
|
return {
|
|
offset: SugarPosition(xDelta, yDelta),
|
|
classesOn: bind$3(alignmentsOn, getClasses),
|
|
classesOff: bind$3(alignmentsOff, getClasses)
|
|
};
|
|
};
|
|
return {
|
|
southeast: function () {
|
|
return make(-xOffset, yOffset, [
|
|
'top',
|
|
'alignLeft'
|
|
]);
|
|
},
|
|
southwest: function () {
|
|
return make(xOffset, yOffset, [
|
|
'top',
|
|
'alignRight'
|
|
]);
|
|
},
|
|
south: function () {
|
|
return make(-xOffset / 2, yOffset, [
|
|
'top',
|
|
'alignCentre'
|
|
]);
|
|
},
|
|
northeast: function () {
|
|
return make(-xOffset, -yOffset, [
|
|
'bottom',
|
|
'alignLeft'
|
|
]);
|
|
},
|
|
northwest: function () {
|
|
return make(xOffset, -yOffset, [
|
|
'bottom',
|
|
'alignRight'
|
|
]);
|
|
},
|
|
north: function () {
|
|
return make(-xOffset / 2, -yOffset, [
|
|
'bottom',
|
|
'alignCentre'
|
|
]);
|
|
},
|
|
east: function () {
|
|
return make(xOffset, -yOffset / 2, [
|
|
'valignCentre',
|
|
'left'
|
|
]);
|
|
},
|
|
west: function () {
|
|
return make(-xOffset, -yOffset / 2, [
|
|
'valignCentre',
|
|
'right'
|
|
]);
|
|
},
|
|
insetNortheast: function () {
|
|
return make(insetXOffset, insetYOffset, [
|
|
'top',
|
|
'alignLeft',
|
|
'inset'
|
|
]);
|
|
},
|
|
insetNorthwest: function () {
|
|
return make(-insetXOffset, insetYOffset, [
|
|
'top',
|
|
'alignRight',
|
|
'inset'
|
|
]);
|
|
},
|
|
insetNorth: function () {
|
|
return make(-insetXOffset / 2, insetYOffset, [
|
|
'top',
|
|
'alignCentre',
|
|
'inset'
|
|
]);
|
|
},
|
|
insetSoutheast: function () {
|
|
return make(insetXOffset, -insetYOffset, [
|
|
'bottom',
|
|
'alignLeft',
|
|
'inset'
|
|
]);
|
|
},
|
|
insetSouthwest: function () {
|
|
return make(-insetXOffset, -insetYOffset, [
|
|
'bottom',
|
|
'alignRight',
|
|
'inset'
|
|
]);
|
|
},
|
|
insetSouth: function () {
|
|
return make(-insetXOffset / 2, -insetYOffset, [
|
|
'bottom',
|
|
'alignCentre',
|
|
'inset'
|
|
]);
|
|
},
|
|
insetEast: function () {
|
|
return make(-insetXOffset, -insetYOffset / 2, [
|
|
'valignCentre',
|
|
'right',
|
|
'inset'
|
|
]);
|
|
},
|
|
insetWest: function () {
|
|
return make(insetXOffset, -insetYOffset / 2, [
|
|
'valignCentre',
|
|
'left',
|
|
'inset'
|
|
]);
|
|
}
|
|
};
|
|
};
|
|
var fallback = function () {
|
|
return nu$5(0, 0, {});
|
|
};
|
|
|
|
var nu$4 = identity$1;
|
|
|
|
var onDirection = function (isLtr, isRtl) {
|
|
return function (element) {
|
|
return getDirection(element) === 'rtl' ? isRtl : isLtr;
|
|
};
|
|
};
|
|
var getDirection = function (element) {
|
|
return get$c(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
|
|
};
|
|
|
|
var AttributeValue;
|
|
(function (AttributeValue) {
|
|
AttributeValue['TopToBottom'] = 'toptobottom';
|
|
AttributeValue['BottomToTop'] = 'bottomtotop';
|
|
}(AttributeValue || (AttributeValue = {})));
|
|
var Attribute = 'data-alloy-vertical-dir';
|
|
var isBottomToTopDir = function (el) {
|
|
return closest$2(el, function (current) {
|
|
return isElement$2(current) && get$d(current, 'data-alloy-vertical-dir') === AttributeValue.BottomToTop;
|
|
});
|
|
};
|
|
|
|
var schema$y = function () {
|
|
return optionObjOf('layouts', [
|
|
required$1('onLtr'),
|
|
required$1('onRtl'),
|
|
option('onBottomLtr'),
|
|
option('onBottomRtl')
|
|
]);
|
|
};
|
|
var get$4 = function (elem, info, defaultLtr, defaultRtl, defaultBottomLtr, defaultBottomRtl, dirElement) {
|
|
var isBottomToTop = dirElement.map(isBottomToTopDir).getOr(false);
|
|
var customLtr = info.layouts.map(function (ls) {
|
|
return ls.onLtr(elem);
|
|
});
|
|
var customRtl = info.layouts.map(function (ls) {
|
|
return ls.onRtl(elem);
|
|
});
|
|
var ltr = isBottomToTop ? info.layouts.bind(function (ls) {
|
|
return ls.onBottomLtr.map(function (f) {
|
|
return f(elem);
|
|
});
|
|
}).or(customLtr).getOr(defaultBottomLtr) : customLtr.getOr(defaultLtr);
|
|
var rtl = isBottomToTop ? info.layouts.bind(function (ls) {
|
|
return ls.onBottomRtl.map(function (f) {
|
|
return f(elem);
|
|
});
|
|
}).or(customRtl).getOr(defaultBottomRtl) : customRtl.getOr(defaultRtl);
|
|
var f = onDirection(ltr, rtl);
|
|
return f(elem);
|
|
};
|
|
|
|
var placement$4 = function (component, anchorInfo, origin) {
|
|
var hotspot = anchorInfo.hotspot;
|
|
var anchorBox = toBox(origin, hotspot.element);
|
|
var layouts = get$4(component.element, anchorInfo, belowOrAbove(), belowOrAboveRtl(), aboveOrBelow(), aboveOrBelowRtl(), Optional.some(anchorInfo.hotspot.element));
|
|
return Optional.some(nu$4({
|
|
anchorBox: anchorBox,
|
|
bubble: anchorInfo.bubble.getOr(fallback()),
|
|
overrides: anchorInfo.overrides,
|
|
layouts: layouts,
|
|
placer: Optional.none()
|
|
}));
|
|
};
|
|
var HotspotAnchor = [
|
|
required$1('hotspot'),
|
|
option('bubble'),
|
|
defaulted('overrides', {}),
|
|
schema$y(),
|
|
output$1('placement', placement$4)
|
|
];
|
|
|
|
var placement$3 = function (component, anchorInfo, origin) {
|
|
var pos = translate$2(origin, anchorInfo.x, anchorInfo.y);
|
|
var anchorBox = bounds(pos.left, pos.top, anchorInfo.width, anchorInfo.height);
|
|
var layouts = get$4(component.element, anchorInfo, all$1(), allRtl$1(), all$1(), allRtl$1(), Optional.none());
|
|
return Optional.some(nu$4({
|
|
anchorBox: anchorBox,
|
|
bubble: anchorInfo.bubble,
|
|
overrides: anchorInfo.overrides,
|
|
layouts: layouts,
|
|
placer: Optional.none()
|
|
}));
|
|
};
|
|
var MakeshiftAnchor = [
|
|
required$1('x'),
|
|
required$1('y'),
|
|
defaulted('height', 0),
|
|
defaulted('width', 0),
|
|
defaulted('bubble', fallback()),
|
|
defaulted('overrides', {}),
|
|
schema$y(),
|
|
output$1('placement', placement$3)
|
|
];
|
|
|
|
var adt$7 = Adt.generate([
|
|
{ screen: ['point'] },
|
|
{
|
|
absolute: [
|
|
'point',
|
|
'scrollLeft',
|
|
'scrollTop'
|
|
]
|
|
}
|
|
]);
|
|
var toFixed = function (pos) {
|
|
return pos.fold(identity$1, function (point, scrollLeft, scrollTop) {
|
|
return point.translate(-scrollLeft, -scrollTop);
|
|
});
|
|
};
|
|
var toAbsolute = function (pos) {
|
|
return pos.fold(identity$1, identity$1);
|
|
};
|
|
var sum = function (points) {
|
|
return foldl(points, function (b, a) {
|
|
return b.translate(a.left, a.top);
|
|
}, SugarPosition(0, 0));
|
|
};
|
|
var sumAsFixed = function (positions) {
|
|
var points = map$2(positions, toFixed);
|
|
return sum(points);
|
|
};
|
|
var sumAsAbsolute = function (positions) {
|
|
var points = map$2(positions, toAbsolute);
|
|
return sum(points);
|
|
};
|
|
var screen = adt$7.screen;
|
|
var absolute$1 = adt$7.absolute;
|
|
|
|
var getOffset = function (component, origin, anchorInfo) {
|
|
var win = defaultView(anchorInfo.root).dom;
|
|
var hasSameOwner = function (frame) {
|
|
var frameOwner = owner$4(frame);
|
|
var compOwner = owner$4(component.element);
|
|
return eq(frameOwner, compOwner);
|
|
};
|
|
return Optional.from(win.frameElement).map(SugarElement.fromDom).filter(hasSameOwner).map(absolute$3);
|
|
};
|
|
var getRootPoint = function (component, origin, anchorInfo) {
|
|
var doc = owner$4(component.element);
|
|
var outerScroll = get$9(doc);
|
|
var offset = getOffset(component, origin, anchorInfo).getOr(outerScroll);
|
|
return absolute$1(offset, outerScroll.left, outerScroll.top);
|
|
};
|
|
|
|
var getBox = function (left, top, width, height) {
|
|
var point = screen(SugarPosition(left, top));
|
|
return Optional.some(pointed(point, width, height));
|
|
};
|
|
var calcNewAnchor = function (optBox, rootPoint, anchorInfo, origin, elem) {
|
|
return optBox.map(function (box) {
|
|
var points = [
|
|
rootPoint,
|
|
box.point
|
|
];
|
|
var topLeft = cata$1(origin, function () {
|
|
return sumAsAbsolute(points);
|
|
}, function () {
|
|
return sumAsAbsolute(points);
|
|
}, function () {
|
|
return sumAsFixed(points);
|
|
});
|
|
var anchorBox = rect(topLeft.left, topLeft.top, box.width, box.height);
|
|
var layoutsLtr = anchorInfo.showAbove ? aboveOrBelow() : belowOrAbove();
|
|
var layoutsRtl = anchorInfo.showAbove ? aboveOrBelowRtl() : belowOrAboveRtl();
|
|
var layouts = get$4(elem, anchorInfo, layoutsLtr, layoutsRtl, layoutsLtr, layoutsRtl, Optional.none());
|
|
return nu$4({
|
|
anchorBox: anchorBox,
|
|
bubble: anchorInfo.bubble.getOr(fallback()),
|
|
overrides: anchorInfo.overrides,
|
|
layouts: layouts,
|
|
placer: Optional.none()
|
|
});
|
|
});
|
|
};
|
|
|
|
var placement$2 = function (component, anchorInfo, origin) {
|
|
var rootPoint = getRootPoint(component, origin, anchorInfo);
|
|
return anchorInfo.node.filter(inBody).bind(function (target) {
|
|
var rect = target.dom.getBoundingClientRect();
|
|
var nodeBox = getBox(rect.left, rect.top, rect.width, rect.height);
|
|
var elem = anchorInfo.node.getOr(component.element);
|
|
return calcNewAnchor(nodeBox, rootPoint, anchorInfo, origin, elem);
|
|
});
|
|
};
|
|
var NodeAnchor = [
|
|
required$1('node'),
|
|
required$1('root'),
|
|
option('bubble'),
|
|
schema$y(),
|
|
defaulted('overrides', {}),
|
|
defaulted('showAbove', false),
|
|
output$1('placement', placement$2)
|
|
];
|
|
|
|
var zeroWidth = '\uFEFF';
|
|
var nbsp = '\xA0';
|
|
|
|
var create$6 = function (start, soffset, finish, foffset) {
|
|
return {
|
|
start: start,
|
|
soffset: soffset,
|
|
finish: finish,
|
|
foffset: foffset
|
|
};
|
|
};
|
|
var SimRange = { create: create$6 };
|
|
|
|
var adt$6 = Adt.generate([
|
|
{ before: ['element'] },
|
|
{
|
|
on: [
|
|
'element',
|
|
'offset'
|
|
]
|
|
},
|
|
{ after: ['element'] }
|
|
]);
|
|
var cata = function (subject, onBefore, onOn, onAfter) {
|
|
return subject.fold(onBefore, onOn, onAfter);
|
|
};
|
|
var getStart$1 = function (situ) {
|
|
return situ.fold(identity$1, identity$1, identity$1);
|
|
};
|
|
var before = adt$6.before;
|
|
var on$1 = adt$6.on;
|
|
var after$1 = adt$6.after;
|
|
var Situ = {
|
|
before: before,
|
|
on: on$1,
|
|
after: after$1,
|
|
cata: cata,
|
|
getStart: getStart$1
|
|
};
|
|
|
|
var adt$5 = Adt.generate([
|
|
{ domRange: ['rng'] },
|
|
{
|
|
relative: [
|
|
'startSitu',
|
|
'finishSitu'
|
|
]
|
|
},
|
|
{
|
|
exact: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
}
|
|
]);
|
|
var exactFromRange = function (simRange) {
|
|
return adt$5.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset);
|
|
};
|
|
var getStart = function (selection) {
|
|
return selection.match({
|
|
domRange: function (rng) {
|
|
return SugarElement.fromDom(rng.startContainer);
|
|
},
|
|
relative: function (startSitu, _finishSitu) {
|
|
return Situ.getStart(startSitu);
|
|
},
|
|
exact: function (start, _soffset, _finish, _foffset) {
|
|
return start;
|
|
}
|
|
});
|
|
};
|
|
var domRange = adt$5.domRange;
|
|
var relative = adt$5.relative;
|
|
var exact = adt$5.exact;
|
|
var getWin = function (selection) {
|
|
var start = getStart(selection);
|
|
return defaultView(start);
|
|
};
|
|
var range$1 = SimRange.create;
|
|
var SimSelection = {
|
|
domRange: domRange,
|
|
relative: relative,
|
|
exact: exact,
|
|
exactFromRange: exactFromRange,
|
|
getWin: getWin,
|
|
range: range$1
|
|
};
|
|
|
|
var setStart = function (rng, situ) {
|
|
situ.fold(function (e) {
|
|
rng.setStartBefore(e.dom);
|
|
}, function (e, o) {
|
|
rng.setStart(e.dom, o);
|
|
}, function (e) {
|
|
rng.setStartAfter(e.dom);
|
|
});
|
|
};
|
|
var setFinish = function (rng, situ) {
|
|
situ.fold(function (e) {
|
|
rng.setEndBefore(e.dom);
|
|
}, function (e, o) {
|
|
rng.setEnd(e.dom, o);
|
|
}, function (e) {
|
|
rng.setEndAfter(e.dom);
|
|
});
|
|
};
|
|
var relativeToNative = function (win, startSitu, finishSitu) {
|
|
var range = win.document.createRange();
|
|
setStart(range, startSitu);
|
|
setFinish(range, finishSitu);
|
|
return range;
|
|
};
|
|
var exactToNative = function (win, start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
};
|
|
var toRect = function (rect) {
|
|
return {
|
|
left: rect.left,
|
|
top: rect.top,
|
|
right: rect.right,
|
|
bottom: rect.bottom,
|
|
width: rect.width,
|
|
height: rect.height
|
|
};
|
|
};
|
|
var getFirstRect$1 = function (rng) {
|
|
var rects = rng.getClientRects();
|
|
var rect = rects.length > 0 ? rects[0] : rng.getBoundingClientRect();
|
|
return rect.width > 0 || rect.height > 0 ? Optional.some(rect).map(toRect) : Optional.none();
|
|
};
|
|
var getBounds$2 = function (rng) {
|
|
var rect = rng.getBoundingClientRect();
|
|
return rect.width > 0 || rect.height > 0 ? Optional.some(rect).map(toRect) : Optional.none();
|
|
};
|
|
|
|
var adt$4 = Adt.generate([
|
|
{
|
|
ltr: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
},
|
|
{
|
|
rtl: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
}
|
|
]);
|
|
var fromRange = function (win, type, range) {
|
|
return type(SugarElement.fromDom(range.startContainer), range.startOffset, SugarElement.fromDom(range.endContainer), range.endOffset);
|
|
};
|
|
var getRanges = function (win, selection) {
|
|
return selection.match({
|
|
domRange: function (rng) {
|
|
return {
|
|
ltr: constant$1(rng),
|
|
rtl: Optional.none
|
|
};
|
|
},
|
|
relative: function (startSitu, finishSitu) {
|
|
return {
|
|
ltr: cached(function () {
|
|
return relativeToNative(win, startSitu, finishSitu);
|
|
}),
|
|
rtl: cached(function () {
|
|
return Optional.some(relativeToNative(win, finishSitu, startSitu));
|
|
})
|
|
};
|
|
},
|
|
exact: function (start, soffset, finish, foffset) {
|
|
return {
|
|
ltr: cached(function () {
|
|
return exactToNative(win, start, soffset, finish, foffset);
|
|
}),
|
|
rtl: cached(function () {
|
|
return Optional.some(exactToNative(win, finish, foffset, start, soffset));
|
|
})
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var doDiagnose = function (win, ranges) {
|
|
var rng = ranges.ltr();
|
|
if (rng.collapsed) {
|
|
var reversed = ranges.rtl().filter(function (rev) {
|
|
return rev.collapsed === false;
|
|
});
|
|
return reversed.map(function (rev) {
|
|
return adt$4.rtl(SugarElement.fromDom(rev.endContainer), rev.endOffset, SugarElement.fromDom(rev.startContainer), rev.startOffset);
|
|
}).getOrThunk(function () {
|
|
return fromRange(win, adt$4.ltr, rng);
|
|
});
|
|
} else {
|
|
return fromRange(win, adt$4.ltr, rng);
|
|
}
|
|
};
|
|
var diagnose = function (win, selection) {
|
|
var ranges = getRanges(win, selection);
|
|
return doDiagnose(win, ranges);
|
|
};
|
|
var asLtrRange = function (win, selection) {
|
|
var diagnosis = diagnose(win, selection);
|
|
return diagnosis.match({
|
|
ltr: function (start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
},
|
|
rtl: function (start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(finish.dom, foffset);
|
|
rng.setEnd(start.dom, soffset);
|
|
return rng;
|
|
}
|
|
});
|
|
};
|
|
adt$4.ltr;
|
|
adt$4.rtl;
|
|
|
|
var NodeValue = function (is, name) {
|
|
var get = function (element) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
return getOption(element).getOr('');
|
|
};
|
|
var getOption = function (element) {
|
|
return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
|
|
};
|
|
var set = function (element, value) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
element.dom.nodeValue = value;
|
|
};
|
|
return {
|
|
get: get,
|
|
getOption: getOption,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var api = NodeValue(isText$1, 'text');
|
|
var get$3 = function (element) {
|
|
return api.get(element);
|
|
};
|
|
var getOption = function (element) {
|
|
return api.getOption(element);
|
|
};
|
|
|
|
var getEnd = function (element) {
|
|
return name$2(element) === 'img' ? 1 : getOption(element).fold(function () {
|
|
return children(element).length;
|
|
}, function (v) {
|
|
return v.length;
|
|
});
|
|
};
|
|
var isTextNodeWithCursorPosition = function (el) {
|
|
return getOption(el).filter(function (text) {
|
|
return text.trim().length !== 0 || text.indexOf(nbsp) > -1;
|
|
}).isSome();
|
|
};
|
|
var elementsWithCursorPosition = [
|
|
'img',
|
|
'br'
|
|
];
|
|
var isCursorPosition = function (elem) {
|
|
var hasCursorPosition = isTextNodeWithCursorPosition(elem);
|
|
return hasCursorPosition || contains$2(elementsWithCursorPosition, name$2(elem));
|
|
};
|
|
|
|
var last$1 = function (element) {
|
|
return descendantRtl(element, isCursorPosition);
|
|
};
|
|
var descendantRtl = function (scope, predicate) {
|
|
var descend = function (element) {
|
|
var children$1 = children(element);
|
|
for (var i = children$1.length - 1; i >= 0; i--) {
|
|
var child = children$1[i];
|
|
if (predicate(child)) {
|
|
return Optional.some(child);
|
|
}
|
|
var res = descend(child);
|
|
if (res.isSome()) {
|
|
return res;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
return descend(scope);
|
|
};
|
|
|
|
var descendants = function (scope, selector) {
|
|
return all$3(selector, scope);
|
|
};
|
|
|
|
var makeRange = function (start, soffset, finish, foffset) {
|
|
var doc = owner$4(start);
|
|
var rng = doc.dom.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
};
|
|
var after = function (start, soffset, finish, foffset) {
|
|
var r = makeRange(start, soffset, finish, foffset);
|
|
var same = eq(start, finish) && soffset === foffset;
|
|
return r.collapsed && !same;
|
|
};
|
|
|
|
var getNativeSelection = function (win) {
|
|
return Optional.from(win.getSelection());
|
|
};
|
|
var readRange = function (selection) {
|
|
if (selection.rangeCount > 0) {
|
|
var firstRng = selection.getRangeAt(0);
|
|
var lastRng = selection.getRangeAt(selection.rangeCount - 1);
|
|
return Optional.some(SimRange.create(SugarElement.fromDom(firstRng.startContainer), firstRng.startOffset, SugarElement.fromDom(lastRng.endContainer), lastRng.endOffset));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var doGetExact = function (selection) {
|
|
if (selection.anchorNode === null || selection.focusNode === null) {
|
|
return readRange(selection);
|
|
} else {
|
|
var anchor = SugarElement.fromDom(selection.anchorNode);
|
|
var focus_1 = SugarElement.fromDom(selection.focusNode);
|
|
return after(anchor, selection.anchorOffset, focus_1, selection.focusOffset) ? Optional.some(SimRange.create(anchor, selection.anchorOffset, focus_1, selection.focusOffset)) : readRange(selection);
|
|
}
|
|
};
|
|
var getExact = function (win) {
|
|
return getNativeSelection(win).filter(function (sel) {
|
|
return sel.rangeCount > 0;
|
|
}).bind(doGetExact);
|
|
};
|
|
var getFirstRect = function (win, selection) {
|
|
var rng = asLtrRange(win, selection);
|
|
return getFirstRect$1(rng);
|
|
};
|
|
var getBounds$1 = function (win, selection) {
|
|
var rng = asLtrRange(win, selection);
|
|
return getBounds$2(rng);
|
|
};
|
|
|
|
var point$1 = function (element, offset) {
|
|
return {
|
|
element: element,
|
|
offset: offset
|
|
};
|
|
};
|
|
var descendOnce$1 = function (element, offset) {
|
|
var children$1 = children(element);
|
|
if (children$1.length === 0) {
|
|
return point$1(element, offset);
|
|
} else if (offset < children$1.length) {
|
|
return point$1(children$1[offset], 0);
|
|
} else {
|
|
var last = children$1[children$1.length - 1];
|
|
var len = isText$1(last) ? get$3(last).length : children(last).length;
|
|
return point$1(last, len);
|
|
}
|
|
};
|
|
|
|
var descendOnce = function (element, offset) {
|
|
return isText$1(element) ? point$1(element, offset) : descendOnce$1(element, offset);
|
|
};
|
|
var getAnchorSelection = function (win, anchorInfo) {
|
|
var getSelection = anchorInfo.getSelection.getOrThunk(function () {
|
|
return function () {
|
|
return getExact(win);
|
|
};
|
|
});
|
|
return getSelection().map(function (sel) {
|
|
var modStart = descendOnce(sel.start, sel.soffset);
|
|
var modFinish = descendOnce(sel.finish, sel.foffset);
|
|
return SimSelection.range(modStart.element, modStart.offset, modFinish.element, modFinish.offset);
|
|
});
|
|
};
|
|
var placement$1 = function (component, anchorInfo, origin) {
|
|
var win = defaultView(anchorInfo.root).dom;
|
|
var rootPoint = getRootPoint(component, origin, anchorInfo);
|
|
var selectionBox = getAnchorSelection(win, anchorInfo).bind(function (sel) {
|
|
var optRect = getBounds$1(win, SimSelection.exactFromRange(sel)).orThunk(function () {
|
|
var x = SugarElement.fromText(zeroWidth);
|
|
before$2(sel.start, x);
|
|
var rect = getFirstRect(win, SimSelection.exact(x, 0, x, 1));
|
|
remove$5(x);
|
|
return rect;
|
|
});
|
|
return optRect.bind(function (rawRect) {
|
|
return getBox(rawRect.left, rawRect.top, rawRect.width, rawRect.height);
|
|
});
|
|
});
|
|
var targetElement = getAnchorSelection(win, anchorInfo).bind(function (sel) {
|
|
return isElement$2(sel.start) ? Optional.some(sel.start) : parentNode(sel.start);
|
|
});
|
|
var elem = targetElement.getOr(component.element);
|
|
return calcNewAnchor(selectionBox, rootPoint, anchorInfo, origin, elem);
|
|
};
|
|
var SelectionAnchor = [
|
|
option('getSelection'),
|
|
required$1('root'),
|
|
option('bubble'),
|
|
schema$y(),
|
|
defaulted('overrides', {}),
|
|
defaulted('showAbove', false),
|
|
output$1('placement', placement$1)
|
|
];
|
|
|
|
var labelPrefix$1 = 'link-layout';
|
|
var eastX = function (anchor) {
|
|
return anchor.x + anchor.width;
|
|
};
|
|
var westX = function (anchor, element) {
|
|
return anchor.x - element.width;
|
|
};
|
|
var northY$1 = function (anchor, element) {
|
|
return anchor.y - element.height + anchor.height;
|
|
};
|
|
var southY$1 = function (anchor) {
|
|
return anchor.y;
|
|
};
|
|
var southeast$1 = function (anchor, element, bubbles) {
|
|
return nu$6(eastX(anchor), southY$1(anchor), bubbles.southeast(), southeast$3(), 'southeast', boundsRestriction(anchor, {
|
|
left: 0,
|
|
top: 2
|
|
}), labelPrefix$1);
|
|
};
|
|
var southwest$1 = function (anchor, element, bubbles) {
|
|
return nu$6(westX(anchor, element), southY$1(anchor), bubbles.southwest(), southwest$3(), 'southwest', boundsRestriction(anchor, {
|
|
right: 1,
|
|
top: 2
|
|
}), labelPrefix$1);
|
|
};
|
|
var northeast$1 = function (anchor, element, bubbles) {
|
|
return nu$6(eastX(anchor), northY$1(anchor, element), bubbles.northeast(), northeast$3(), 'northeast', boundsRestriction(anchor, {
|
|
left: 0,
|
|
bottom: 3
|
|
}), labelPrefix$1);
|
|
};
|
|
var northwest$1 = function (anchor, element, bubbles) {
|
|
return nu$6(westX(anchor, element), northY$1(anchor, element), bubbles.northwest(), northwest$3(), 'northwest', boundsRestriction(anchor, {
|
|
right: 1,
|
|
bottom: 3
|
|
}), labelPrefix$1);
|
|
};
|
|
var all = function () {
|
|
return [
|
|
southeast$1,
|
|
southwest$1,
|
|
northeast$1,
|
|
northwest$1
|
|
];
|
|
};
|
|
var allRtl = function () {
|
|
return [
|
|
southwest$1,
|
|
southeast$1,
|
|
northwest$1,
|
|
northeast$1
|
|
];
|
|
};
|
|
|
|
var placement = function (component, submenuInfo, origin) {
|
|
var anchorBox = toBox(origin, submenuInfo.item.element);
|
|
var layouts = get$4(component.element, submenuInfo, all(), allRtl(), all(), allRtl(), Optional.none());
|
|
return Optional.some(nu$4({
|
|
anchorBox: anchorBox,
|
|
bubble: fallback(),
|
|
overrides: submenuInfo.overrides,
|
|
layouts: layouts,
|
|
placer: Optional.none()
|
|
}));
|
|
};
|
|
var SubmenuAnchor = [
|
|
required$1('item'),
|
|
schema$y(),
|
|
defaulted('overrides', {}),
|
|
output$1('placement', placement)
|
|
];
|
|
|
|
var AnchorSchema = choose$1('type', {
|
|
selection: SelectionAnchor,
|
|
node: NodeAnchor,
|
|
hotspot: HotspotAnchor,
|
|
submenu: SubmenuAnchor,
|
|
makeshift: MakeshiftAnchor
|
|
});
|
|
|
|
var TransitionSchema = [
|
|
requiredArrayOf('classes', string),
|
|
defaultedStringEnum('mode', 'all', [
|
|
'all',
|
|
'layout',
|
|
'placement'
|
|
])
|
|
];
|
|
var PositionSchema = [
|
|
defaulted('useFixed', never),
|
|
option('getBounds')
|
|
];
|
|
var PlacementSchema = [
|
|
requiredOf('anchor', AnchorSchema),
|
|
optionObjOf('transition', TransitionSchema)
|
|
];
|
|
|
|
var getFixedOrigin = function () {
|
|
var html = document.documentElement;
|
|
return fixed$1(0, 0, html.clientWidth, html.clientHeight);
|
|
};
|
|
var getRelativeOrigin = function (component) {
|
|
var position = absolute$3(component.element);
|
|
var bounds = component.element.dom.getBoundingClientRect();
|
|
return relative$1(position.left, position.top, bounds.width, bounds.height);
|
|
};
|
|
var place = function (component, origin, anchoring, getBounds, placee, lastPlace, transition) {
|
|
var anchor = box(anchoring.anchorBox, origin);
|
|
return simple(anchor, placee.element, anchoring.bubble, anchoring.layouts, lastPlace, getBounds, anchoring.overrides, transition);
|
|
};
|
|
var position$1 = function (component, posConfig, posState, placee, placementSpec) {
|
|
positionWithin(component, posConfig, posState, placee, placementSpec, Optional.none());
|
|
};
|
|
var positionWithin = function (component, posConfig, posState, placee, placementSpec, boxElement) {
|
|
var boundsBox = boxElement.map(box$1);
|
|
return positionWithinBounds(component, posConfig, posState, placee, placementSpec, boundsBox);
|
|
};
|
|
var positionWithinBounds = function (component, posConfig, posState, placee, placementSpec, bounds) {
|
|
var placeeDetail = asRawOrDie$1('placement.info', objOf(PlacementSchema), placementSpec);
|
|
var anchorage = placeeDetail.anchor;
|
|
var element = placee.element;
|
|
var placeeState = posState.get(placee.uid);
|
|
preserve$1(function () {
|
|
set$7(element, 'position', 'fixed');
|
|
var oldVisibility = getRaw(element, 'visibility');
|
|
set$7(element, 'visibility', 'hidden');
|
|
var origin = posConfig.useFixed() ? getFixedOrigin() : getRelativeOrigin(component);
|
|
var placer = anchorage.placement;
|
|
var getBounds = bounds.map(constant$1).or(posConfig.getBounds);
|
|
placer(component, anchorage, origin).each(function (anchoring) {
|
|
var doPlace = anchoring.placer.getOr(place);
|
|
var newState = doPlace(component, origin, anchoring, getBounds, placee, placeeState, placeeDetail.transition);
|
|
posState.set(placee.uid, newState);
|
|
});
|
|
oldVisibility.fold(function () {
|
|
remove$6(element, 'visibility');
|
|
}, function (vis) {
|
|
set$7(element, 'visibility', vis);
|
|
});
|
|
if (getRaw(element, 'left').isNone() && getRaw(element, 'top').isNone() && getRaw(element, 'right').isNone() && getRaw(element, 'bottom').isNone() && is$1(getRaw(element, 'position'), 'fixed')) {
|
|
remove$6(element, 'position');
|
|
}
|
|
}, element);
|
|
};
|
|
var getMode = function (component, pConfig, _pState) {
|
|
return pConfig.useFixed() ? 'fixed' : 'absolute';
|
|
};
|
|
var reset$1 = function (component, pConfig, posState, placee) {
|
|
var element = placee.element;
|
|
each$1([
|
|
'position',
|
|
'left',
|
|
'right',
|
|
'top',
|
|
'bottom'
|
|
], function (prop) {
|
|
return remove$6(element, prop);
|
|
});
|
|
reset$2(element);
|
|
posState.clear(placee.uid);
|
|
};
|
|
|
|
var PositionApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
position: position$1,
|
|
positionWithin: positionWithin,
|
|
positionWithinBounds: positionWithinBounds,
|
|
getMode: getMode,
|
|
reset: reset$1
|
|
});
|
|
|
|
var init$g = function () {
|
|
var state = {};
|
|
var set = function (id, data) {
|
|
state[id] = data;
|
|
};
|
|
var get = function (id) {
|
|
return get$e(state, id);
|
|
};
|
|
var clear = function (id) {
|
|
if (isNonNullable(id)) {
|
|
delete state[id];
|
|
} else {
|
|
state = {};
|
|
}
|
|
};
|
|
return nu$8({
|
|
readState: function () {
|
|
return state;
|
|
},
|
|
clear: clear,
|
|
set: set,
|
|
get: get
|
|
});
|
|
};
|
|
|
|
var PositioningState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$g
|
|
});
|
|
|
|
var Positioning = create$7({
|
|
fields: PositionSchema,
|
|
name: 'positioning',
|
|
active: ActivePosition,
|
|
apis: PositionApis,
|
|
state: PositioningState
|
|
});
|
|
|
|
var fireDetaching = function (component) {
|
|
emit(component, detachedFromDom());
|
|
var children = component.components();
|
|
each$1(children, fireDetaching);
|
|
};
|
|
var fireAttaching = function (component) {
|
|
var children = component.components();
|
|
each$1(children, fireAttaching);
|
|
emit(component, attachedToDom());
|
|
};
|
|
var attach$1 = function (parent, child) {
|
|
append$2(parent.element, child.element);
|
|
};
|
|
var detachChildren$1 = function (component) {
|
|
each$1(component.components(), function (childComp) {
|
|
return remove$5(childComp.element);
|
|
});
|
|
empty(component.element);
|
|
component.syncComponents();
|
|
};
|
|
var replaceChildren = function (component, newChildren) {
|
|
var subs = component.components();
|
|
detachChildren$1(component);
|
|
var deleted = difference(subs, newChildren);
|
|
each$1(deleted, function (comp) {
|
|
fireDetaching(comp);
|
|
component.getSystem().removeFromWorld(comp);
|
|
});
|
|
each$1(newChildren, function (childComp) {
|
|
if (!childComp.getSystem().isConnected()) {
|
|
component.getSystem().addToWorld(childComp);
|
|
attach$1(component, childComp);
|
|
if (inBody(component.element)) {
|
|
fireAttaching(childComp);
|
|
}
|
|
} else {
|
|
attach$1(component, childComp);
|
|
}
|
|
component.syncComponents();
|
|
});
|
|
};
|
|
|
|
var attach = function (parent, child) {
|
|
attachWith(parent, child, append$2);
|
|
};
|
|
var attachWith = function (parent, child, insertion) {
|
|
parent.getSystem().addToWorld(child);
|
|
insertion(parent.element, child.element);
|
|
if (inBody(parent.element)) {
|
|
fireAttaching(child);
|
|
}
|
|
parent.syncComponents();
|
|
};
|
|
var doDetach = function (component) {
|
|
fireDetaching(component);
|
|
remove$5(component.element);
|
|
component.getSystem().removeFromWorld(component);
|
|
};
|
|
var detach = function (component) {
|
|
var parent$1 = parent(component.element).bind(function (p) {
|
|
return component.getSystem().getByDom(p).toOptional();
|
|
});
|
|
doDetach(component);
|
|
parent$1.each(function (p) {
|
|
p.syncComponents();
|
|
});
|
|
};
|
|
var detachChildren = function (component) {
|
|
var subs = component.components();
|
|
each$1(subs, doDetach);
|
|
empty(component.element);
|
|
component.syncComponents();
|
|
};
|
|
var attachSystem = function (element, guiSystem) {
|
|
attachSystemWith(element, guiSystem, append$2);
|
|
};
|
|
var attachSystemAfter = function (element, guiSystem) {
|
|
attachSystemWith(element, guiSystem, after$2);
|
|
};
|
|
var attachSystemWith = function (element, guiSystem, inserter) {
|
|
inserter(element, guiSystem.element);
|
|
var children$1 = children(guiSystem.element);
|
|
each$1(children$1, function (child) {
|
|
guiSystem.getByDom(child).each(fireAttaching);
|
|
});
|
|
};
|
|
var detachSystem = function (guiSystem) {
|
|
var children$1 = children(guiSystem.element);
|
|
each$1(children$1, function (child) {
|
|
guiSystem.getByDom(child).each(fireDetaching);
|
|
});
|
|
remove$5(guiSystem.element);
|
|
};
|
|
|
|
var rebuild = function (sandbox, sConfig, sState, data) {
|
|
sState.get().each(function (_data) {
|
|
detachChildren(sandbox);
|
|
});
|
|
var point = sConfig.getAttachPoint(sandbox);
|
|
attach(point, sandbox);
|
|
var built = sandbox.getSystem().build(data);
|
|
attach(sandbox, built);
|
|
sState.set(built);
|
|
return built;
|
|
};
|
|
var open$1 = function (sandbox, sConfig, sState, data) {
|
|
var newState = rebuild(sandbox, sConfig, sState, data);
|
|
sConfig.onOpen(sandbox, newState);
|
|
return newState;
|
|
};
|
|
var setContent = function (sandbox, sConfig, sState, data) {
|
|
return sState.get().map(function () {
|
|
return rebuild(sandbox, sConfig, sState, data);
|
|
});
|
|
};
|
|
var openWhileCloaked = function (sandbox, sConfig, sState, data, transaction) {
|
|
cloak(sandbox, sConfig);
|
|
open$1(sandbox, sConfig, sState, data);
|
|
transaction();
|
|
decloak(sandbox, sConfig);
|
|
};
|
|
var close$1 = function (sandbox, sConfig, sState) {
|
|
sState.get().each(function (data) {
|
|
detachChildren(sandbox);
|
|
detach(sandbox);
|
|
sConfig.onClose(sandbox, data);
|
|
sState.clear();
|
|
});
|
|
};
|
|
var isOpen$1 = function (_sandbox, _sConfig, sState) {
|
|
return sState.isOpen();
|
|
};
|
|
var isPartOf = function (sandbox, sConfig, sState, queryElem) {
|
|
return isOpen$1(sandbox, sConfig, sState) && sState.get().exists(function (data) {
|
|
return sConfig.isPartOf(sandbox, data, queryElem);
|
|
});
|
|
};
|
|
var getState$2 = function (_sandbox, _sConfig, sState) {
|
|
return sState.get();
|
|
};
|
|
var store = function (sandbox, cssKey, attr, newValue) {
|
|
getRaw(sandbox.element, cssKey).fold(function () {
|
|
remove$7(sandbox.element, attr);
|
|
}, function (v) {
|
|
set$8(sandbox.element, attr, v);
|
|
});
|
|
set$7(sandbox.element, cssKey, newValue);
|
|
};
|
|
var restore = function (sandbox, cssKey, attr) {
|
|
getOpt(sandbox.element, attr).fold(function () {
|
|
return remove$6(sandbox.element, cssKey);
|
|
}, function (oldValue) {
|
|
return set$7(sandbox.element, cssKey, oldValue);
|
|
});
|
|
};
|
|
var cloak = function (sandbox, sConfig, _sState) {
|
|
var sink = sConfig.getAttachPoint(sandbox);
|
|
set$7(sandbox.element, 'position', Positioning.getMode(sink));
|
|
store(sandbox, 'visibility', sConfig.cloakVisibilityAttr, 'hidden');
|
|
};
|
|
var hasPosition = function (element) {
|
|
return exists([
|
|
'top',
|
|
'left',
|
|
'right',
|
|
'bottom'
|
|
], function (pos) {
|
|
return getRaw(element, pos).isSome();
|
|
});
|
|
};
|
|
var decloak = function (sandbox, sConfig, _sState) {
|
|
if (!hasPosition(sandbox.element)) {
|
|
remove$6(sandbox.element, 'position');
|
|
}
|
|
restore(sandbox, 'visibility', sConfig.cloakVisibilityAttr);
|
|
};
|
|
|
|
var SandboxApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
cloak: cloak,
|
|
decloak: decloak,
|
|
open: open$1,
|
|
openWhileCloaked: openWhileCloaked,
|
|
close: close$1,
|
|
isOpen: isOpen$1,
|
|
isPartOf: isPartOf,
|
|
getState: getState$2,
|
|
setContent: setContent
|
|
});
|
|
|
|
var events$g = function (sandboxConfig, sandboxState) {
|
|
return derive$2([run$1(sandboxClose(), function (sandbox, _simulatedEvent) {
|
|
close$1(sandbox, sandboxConfig, sandboxState);
|
|
})]);
|
|
};
|
|
|
|
var ActiveSandbox = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$g
|
|
});
|
|
|
|
var SandboxSchema = [
|
|
onHandler('onOpen'),
|
|
onHandler('onClose'),
|
|
required$1('isPartOf'),
|
|
required$1('getAttachPoint'),
|
|
defaulted('cloakVisibilityAttr', 'data-precloak-visibility')
|
|
];
|
|
|
|
var init$f = function () {
|
|
var contents = value$1();
|
|
var readState = constant$1('not-implemented');
|
|
return nu$8({
|
|
readState: readState,
|
|
isOpen: contents.isSet,
|
|
clear: contents.clear,
|
|
set: contents.set,
|
|
get: contents.get
|
|
});
|
|
};
|
|
|
|
var SandboxState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$f
|
|
});
|
|
|
|
var Sandboxing = create$7({
|
|
fields: SandboxSchema,
|
|
name: 'sandboxing',
|
|
active: ActiveSandbox,
|
|
apis: SandboxApis,
|
|
state: SandboxState
|
|
});
|
|
|
|
var dismissPopups = constant$1('dismiss.popups');
|
|
var repositionPopups = constant$1('reposition.popups');
|
|
var mouseReleased = constant$1('mouse.released');
|
|
|
|
var schema$x = objOfOnly([
|
|
defaulted('isExtraPart', never),
|
|
optionObjOf('fireEventInstead', [defaulted('event', dismissRequested())])
|
|
]);
|
|
var receivingChannel$1 = function (rawSpec) {
|
|
var _a;
|
|
var detail = asRawOrDie$1('Dismissal', schema$x, rawSpec);
|
|
return _a = {}, _a[dismissPopups()] = {
|
|
schema: objOfOnly([required$1('target')]),
|
|
onReceive: function (sandbox, data) {
|
|
if (Sandboxing.isOpen(sandbox)) {
|
|
var isPart = Sandboxing.isPartOf(sandbox, data.target) || detail.isExtraPart(sandbox, data.target);
|
|
if (!isPart) {
|
|
detail.fireEventInstead.fold(function () {
|
|
return Sandboxing.close(sandbox);
|
|
}, function (fe) {
|
|
return emit(sandbox, fe.event);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}, _a;
|
|
};
|
|
|
|
var schema$w = objOfOnly([
|
|
optionObjOf('fireEventInstead', [defaulted('event', repositionRequested())]),
|
|
requiredFunction('doReposition')
|
|
]);
|
|
var receivingChannel = function (rawSpec) {
|
|
var _a;
|
|
var detail = asRawOrDie$1('Reposition', schema$w, rawSpec);
|
|
return _a = {}, _a[repositionPopups()] = {
|
|
onReceive: function (sandbox) {
|
|
if (Sandboxing.isOpen(sandbox)) {
|
|
detail.fireEventInstead.fold(function () {
|
|
return detail.doReposition(sandbox);
|
|
}, function (fe) {
|
|
return emit(sandbox, fe.event);
|
|
});
|
|
}
|
|
}
|
|
}, _a;
|
|
};
|
|
|
|
var onLoad$5 = function (component, repConfig, repState) {
|
|
repConfig.store.manager.onLoad(component, repConfig, repState);
|
|
};
|
|
var onUnload$2 = function (component, repConfig, repState) {
|
|
repConfig.store.manager.onUnload(component, repConfig, repState);
|
|
};
|
|
var setValue$3 = function (component, repConfig, repState, data) {
|
|
repConfig.store.manager.setValue(component, repConfig, repState, data);
|
|
};
|
|
var getValue$3 = function (component, repConfig, repState) {
|
|
return repConfig.store.manager.getValue(component, repConfig, repState);
|
|
};
|
|
var getState$1 = function (component, repConfig, repState) {
|
|
return repState;
|
|
};
|
|
|
|
var RepresentApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
onLoad: onLoad$5,
|
|
onUnload: onUnload$2,
|
|
setValue: setValue$3,
|
|
getValue: getValue$3,
|
|
getState: getState$1
|
|
});
|
|
|
|
var events$f = function (repConfig, repState) {
|
|
var es = repConfig.resetOnDom ? [
|
|
runOnAttached(function (comp, _se) {
|
|
onLoad$5(comp, repConfig, repState);
|
|
}),
|
|
runOnDetached(function (comp, _se) {
|
|
onUnload$2(comp, repConfig, repState);
|
|
})
|
|
] : [loadEvent(repConfig, repState, onLoad$5)];
|
|
return derive$2(es);
|
|
};
|
|
|
|
var ActiveRepresenting = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$f
|
|
});
|
|
|
|
var memory$1 = function () {
|
|
var data = Cell(null);
|
|
var readState = function () {
|
|
return {
|
|
mode: 'memory',
|
|
value: data.get()
|
|
};
|
|
};
|
|
var isNotSet = function () {
|
|
return data.get() === null;
|
|
};
|
|
var clear = function () {
|
|
data.set(null);
|
|
};
|
|
return nu$8({
|
|
set: data.set,
|
|
get: data.get,
|
|
isNotSet: isNotSet,
|
|
clear: clear,
|
|
readState: readState
|
|
});
|
|
};
|
|
var manual = function () {
|
|
var readState = noop;
|
|
return nu$8({ readState: readState });
|
|
};
|
|
var dataset = function () {
|
|
var dataByValue = Cell({});
|
|
var dataByText = Cell({});
|
|
var readState = function () {
|
|
return {
|
|
mode: 'dataset',
|
|
dataByValue: dataByValue.get(),
|
|
dataByText: dataByText.get()
|
|
};
|
|
};
|
|
var clear = function () {
|
|
dataByValue.set({});
|
|
dataByText.set({});
|
|
};
|
|
var lookup = function (itemString) {
|
|
return get$e(dataByValue.get(), itemString).orThunk(function () {
|
|
return get$e(dataByText.get(), itemString);
|
|
});
|
|
};
|
|
var update = function (items) {
|
|
var currentDataByValue = dataByValue.get();
|
|
var currentDataByText = dataByText.get();
|
|
var newDataByValue = {};
|
|
var newDataByText = {};
|
|
each$1(items, function (item) {
|
|
newDataByValue[item.value] = item;
|
|
get$e(item, 'meta').each(function (meta) {
|
|
get$e(meta, 'text').each(function (text) {
|
|
newDataByText[text] = item;
|
|
});
|
|
});
|
|
});
|
|
dataByValue.set(__assign(__assign({}, currentDataByValue), newDataByValue));
|
|
dataByText.set(__assign(__assign({}, currentDataByText), newDataByText));
|
|
};
|
|
return nu$8({
|
|
readState: readState,
|
|
lookup: lookup,
|
|
update: update,
|
|
clear: clear
|
|
});
|
|
};
|
|
var init$e = function (spec) {
|
|
return spec.store.manager.state(spec);
|
|
};
|
|
|
|
var RepresentState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
memory: memory$1,
|
|
dataset: dataset,
|
|
manual: manual,
|
|
init: init$e
|
|
});
|
|
|
|
var setValue$2 = function (component, repConfig, repState, data) {
|
|
var store = repConfig.store;
|
|
repState.update([data]);
|
|
store.setValue(component, data);
|
|
repConfig.onSetValue(component, data);
|
|
};
|
|
var getValue$2 = function (component, repConfig, repState) {
|
|
var store = repConfig.store;
|
|
var key = store.getDataKey(component);
|
|
return repState.lookup(key).getOrThunk(function () {
|
|
return store.getFallbackEntry(key);
|
|
});
|
|
};
|
|
var onLoad$4 = function (component, repConfig, repState) {
|
|
var store = repConfig.store;
|
|
store.initialValue.each(function (data) {
|
|
setValue$2(component, repConfig, repState, data);
|
|
});
|
|
};
|
|
var onUnload$1 = function (component, repConfig, repState) {
|
|
repState.clear();
|
|
};
|
|
var DatasetStore = [
|
|
option('initialValue'),
|
|
required$1('getFallbackEntry'),
|
|
required$1('getDataKey'),
|
|
required$1('setValue'),
|
|
output$1('manager', {
|
|
setValue: setValue$2,
|
|
getValue: getValue$2,
|
|
onLoad: onLoad$4,
|
|
onUnload: onUnload$1,
|
|
state: dataset
|
|
})
|
|
];
|
|
|
|
var getValue$1 = function (component, repConfig, _repState) {
|
|
return repConfig.store.getValue(component);
|
|
};
|
|
var setValue$1 = function (component, repConfig, _repState, data) {
|
|
repConfig.store.setValue(component, data);
|
|
repConfig.onSetValue(component, data);
|
|
};
|
|
var onLoad$3 = function (component, repConfig, _repState) {
|
|
repConfig.store.initialValue.each(function (data) {
|
|
repConfig.store.setValue(component, data);
|
|
});
|
|
};
|
|
var ManualStore = [
|
|
required$1('getValue'),
|
|
defaulted('setValue', noop),
|
|
option('initialValue'),
|
|
output$1('manager', {
|
|
setValue: setValue$1,
|
|
getValue: getValue$1,
|
|
onLoad: onLoad$3,
|
|
onUnload: noop,
|
|
state: NoState.init
|
|
})
|
|
];
|
|
|
|
var setValue = function (component, repConfig, repState, data) {
|
|
repState.set(data);
|
|
repConfig.onSetValue(component, data);
|
|
};
|
|
var getValue = function (component, repConfig, repState) {
|
|
return repState.get();
|
|
};
|
|
var onLoad$2 = function (component, repConfig, repState) {
|
|
repConfig.store.initialValue.each(function (initVal) {
|
|
if (repState.isNotSet()) {
|
|
repState.set(initVal);
|
|
}
|
|
});
|
|
};
|
|
var onUnload = function (component, repConfig, repState) {
|
|
repState.clear();
|
|
};
|
|
var MemoryStore = [
|
|
option('initialValue'),
|
|
output$1('manager', {
|
|
setValue: setValue,
|
|
getValue: getValue,
|
|
onLoad: onLoad$2,
|
|
onUnload: onUnload,
|
|
state: memory$1
|
|
})
|
|
];
|
|
|
|
var RepresentSchema = [
|
|
defaultedOf('store', { mode: 'memory' }, choose$1('mode', {
|
|
memory: MemoryStore,
|
|
manual: ManualStore,
|
|
dataset: DatasetStore
|
|
})),
|
|
onHandler('onSetValue'),
|
|
defaulted('resetOnDom', false)
|
|
];
|
|
|
|
var Representing = create$7({
|
|
fields: RepresentSchema,
|
|
name: 'representing',
|
|
active: ActiveRepresenting,
|
|
apis: RepresentApis,
|
|
extra: {
|
|
setValueFrom: function (component, source) {
|
|
var value = Representing.getValue(source);
|
|
Representing.setValue(component, value);
|
|
}
|
|
},
|
|
state: RepresentState
|
|
});
|
|
|
|
var field = function (name, forbidden) {
|
|
return defaultedObjOf(name, {}, map$2(forbidden, function (f) {
|
|
return forbid(f.name(), 'Cannot configure ' + f.name() + ' for ' + name);
|
|
}).concat([customField('dump', identity$1)]));
|
|
};
|
|
var get$2 = function (data) {
|
|
return data.dump;
|
|
};
|
|
var augment = function (data, original) {
|
|
return __assign(__assign({}, derive$1(original)), data.dump);
|
|
};
|
|
var SketchBehaviours = {
|
|
field: field,
|
|
augment: augment,
|
|
get: get$2
|
|
};
|
|
|
|
var _placeholder = 'placeholder';
|
|
var adt$3 = Adt.generate([
|
|
{
|
|
single: [
|
|
'required',
|
|
'valueThunk'
|
|
]
|
|
},
|
|
{
|
|
multiple: [
|
|
'required',
|
|
'valueThunks'
|
|
]
|
|
}
|
|
]);
|
|
var isSubstituted = function (spec) {
|
|
return has$2(spec, 'uiType');
|
|
};
|
|
var subPlaceholder = function (owner, detail, compSpec, placeholders) {
|
|
if (owner.exists(function (o) {
|
|
return o !== compSpec.owner;
|
|
})) {
|
|
return adt$3.single(true, constant$1(compSpec));
|
|
}
|
|
return get$e(placeholders, compSpec.name).fold(function () {
|
|
throw new Error('Unknown placeholder component: ' + compSpec.name + '\nKnown: [' + keys(placeholders) + ']\nNamespace: ' + owner.getOr('none') + '\nSpec: ' + JSON.stringify(compSpec, null, 2));
|
|
}, function (newSpec) {
|
|
return newSpec.replace();
|
|
});
|
|
};
|
|
var scan = function (owner, detail, compSpec, placeholders) {
|
|
if (isSubstituted(compSpec) && compSpec.uiType === _placeholder) {
|
|
return subPlaceholder(owner, detail, compSpec, placeholders);
|
|
} else {
|
|
return adt$3.single(false, constant$1(compSpec));
|
|
}
|
|
};
|
|
var substitute = function (owner, detail, compSpec, placeholders) {
|
|
var base = scan(owner, detail, compSpec, placeholders);
|
|
return base.fold(function (req, valueThunk) {
|
|
var value = isSubstituted(compSpec) ? valueThunk(detail, compSpec.config, compSpec.validated) : valueThunk(detail);
|
|
var childSpecs = get$e(value, 'components').getOr([]);
|
|
var substituted = bind$3(childSpecs, function (c) {
|
|
return substitute(owner, detail, c, placeholders);
|
|
});
|
|
return [__assign(__assign({}, value), { components: substituted })];
|
|
}, function (req, valuesThunk) {
|
|
if (isSubstituted(compSpec)) {
|
|
var values = valuesThunk(detail, compSpec.config, compSpec.validated);
|
|
var preprocessor = compSpec.validated.preprocess.getOr(identity$1);
|
|
return preprocessor(values);
|
|
} else {
|
|
return valuesThunk(detail);
|
|
}
|
|
});
|
|
};
|
|
var substituteAll = function (owner, detail, components, placeholders) {
|
|
return bind$3(components, function (c) {
|
|
return substitute(owner, detail, c, placeholders);
|
|
});
|
|
};
|
|
var oneReplace = function (label, replacements) {
|
|
var called = false;
|
|
var used = function () {
|
|
return called;
|
|
};
|
|
var replace = function () {
|
|
if (called) {
|
|
throw new Error('Trying to use the same placeholder more than once: ' + label);
|
|
}
|
|
called = true;
|
|
return replacements;
|
|
};
|
|
var required = function () {
|
|
return replacements.fold(function (req, _) {
|
|
return req;
|
|
}, function (req, _) {
|
|
return req;
|
|
});
|
|
};
|
|
return {
|
|
name: constant$1(label),
|
|
required: required,
|
|
used: used,
|
|
replace: replace
|
|
};
|
|
};
|
|
var substitutePlaces = function (owner, detail, components, placeholders) {
|
|
var ps = map$1(placeholders, function (ph, name) {
|
|
return oneReplace(name, ph);
|
|
});
|
|
var outcome = substituteAll(owner, detail, components, ps);
|
|
each(ps, function (p) {
|
|
if (p.used() === false && p.required()) {
|
|
throw new Error('Placeholder: ' + p.name() + ' was not found in components list\nNamespace: ' + owner.getOr('none') + '\nComponents: ' + JSON.stringify(detail.components, null, 2));
|
|
}
|
|
});
|
|
return outcome;
|
|
};
|
|
var single$2 = adt$3.single;
|
|
var multiple = adt$3.multiple;
|
|
var placeholder = constant$1(_placeholder);
|
|
|
|
var adt$2 = Adt.generate([
|
|
{ required: ['data'] },
|
|
{ external: ['data'] },
|
|
{ optional: ['data'] },
|
|
{ group: ['data'] }
|
|
]);
|
|
var fFactory = defaulted('factory', { sketch: identity$1 });
|
|
var fSchema = defaulted('schema', []);
|
|
var fName = required$1('name');
|
|
var fPname = field$1('pname', 'pname', defaultedThunk(function (typeSpec) {
|
|
return '<alloy.' + generate$6(typeSpec.name) + '>';
|
|
}), anyValue());
|
|
var fGroupSchema = customField('schema', function () {
|
|
return [option('preprocess')];
|
|
});
|
|
var fDefaults = defaulted('defaults', constant$1({}));
|
|
var fOverrides = defaulted('overrides', constant$1({}));
|
|
var requiredSpec = objOf([
|
|
fFactory,
|
|
fSchema,
|
|
fName,
|
|
fPname,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var externalSpec = objOf([
|
|
fFactory,
|
|
fSchema,
|
|
fName,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var optionalSpec = objOf([
|
|
fFactory,
|
|
fSchema,
|
|
fName,
|
|
fPname,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var groupSpec = objOf([
|
|
fFactory,
|
|
fGroupSchema,
|
|
fName,
|
|
required$1('unit'),
|
|
fPname,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var asNamedPart = function (part) {
|
|
return part.fold(Optional.some, Optional.none, Optional.some, Optional.some);
|
|
};
|
|
var name$1 = function (part) {
|
|
var get = function (data) {
|
|
return data.name;
|
|
};
|
|
return part.fold(get, get, get, get);
|
|
};
|
|
var asCommon = function (part) {
|
|
return part.fold(identity$1, identity$1, identity$1, identity$1);
|
|
};
|
|
var convert = function (adtConstructor, partSchema) {
|
|
return function (spec) {
|
|
var data = asRawOrDie$1('Converting part type', partSchema, spec);
|
|
return adtConstructor(data);
|
|
};
|
|
};
|
|
var required = convert(adt$2.required, requiredSpec);
|
|
var external$1 = convert(adt$2.external, externalSpec);
|
|
var optional = convert(adt$2.optional, optionalSpec);
|
|
var group = convert(adt$2.group, groupSpec);
|
|
var original = constant$1('entirety');
|
|
|
|
var PartType = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
required: required,
|
|
external: external$1,
|
|
optional: optional,
|
|
group: group,
|
|
asNamedPart: asNamedPart,
|
|
name: name$1,
|
|
asCommon: asCommon,
|
|
original: original
|
|
});
|
|
|
|
var combine = function (detail, data, partSpec, partValidated) {
|
|
return deepMerge(data.defaults(detail, partSpec, partValidated), partSpec, { uid: detail.partUids[data.name] }, data.overrides(detail, partSpec, partValidated));
|
|
};
|
|
var subs = function (owner, detail, parts) {
|
|
var internals = {};
|
|
var externals = {};
|
|
each$1(parts, function (part) {
|
|
part.fold(function (data) {
|
|
internals[data.pname] = single$2(true, function (detail, partSpec, partValidated) {
|
|
return data.factory.sketch(combine(detail, data, partSpec, partValidated));
|
|
});
|
|
}, function (data) {
|
|
var partSpec = detail.parts[data.name];
|
|
externals[data.name] = constant$1(data.factory.sketch(combine(detail, data, partSpec[original()]), partSpec));
|
|
}, function (data) {
|
|
internals[data.pname] = single$2(false, function (detail, partSpec, partValidated) {
|
|
return data.factory.sketch(combine(detail, data, partSpec, partValidated));
|
|
});
|
|
}, function (data) {
|
|
internals[data.pname] = multiple(true, function (detail, _partSpec, _partValidated) {
|
|
var units = detail[data.name];
|
|
return map$2(units, function (u) {
|
|
return data.factory.sketch(deepMerge(data.defaults(detail, u, _partValidated), u, data.overrides(detail, u)));
|
|
});
|
|
});
|
|
});
|
|
});
|
|
return {
|
|
internals: constant$1(internals),
|
|
externals: constant$1(externals)
|
|
};
|
|
};
|
|
|
|
var generate$3 = function (owner, parts) {
|
|
var r = {};
|
|
each$1(parts, function (part) {
|
|
asNamedPart(part).each(function (np) {
|
|
var g = doGenerateOne(owner, np.pname);
|
|
r[np.name] = function (config) {
|
|
var validated = asRawOrDie$1('Part: ' + np.name + ' in ' + owner, objOf(np.schema), config);
|
|
return __assign(__assign({}, g), {
|
|
config: config,
|
|
validated: validated
|
|
});
|
|
};
|
|
});
|
|
});
|
|
return r;
|
|
};
|
|
var doGenerateOne = function (owner, pname) {
|
|
return {
|
|
uiType: placeholder(),
|
|
owner: owner,
|
|
name: pname
|
|
};
|
|
};
|
|
var generateOne$1 = function (owner, pname, config) {
|
|
return {
|
|
uiType: placeholder(),
|
|
owner: owner,
|
|
name: pname,
|
|
config: config,
|
|
validated: {}
|
|
};
|
|
};
|
|
var schemas = function (parts) {
|
|
return bind$3(parts, function (part) {
|
|
return part.fold(Optional.none, Optional.some, Optional.none, Optional.none).map(function (data) {
|
|
return requiredObjOf(data.name, data.schema.concat([snapshot(original())]));
|
|
}).toArray();
|
|
});
|
|
};
|
|
var names = function (parts) {
|
|
return map$2(parts, name$1);
|
|
};
|
|
var substitutes = function (owner, detail, parts) {
|
|
return subs(owner, detail, parts);
|
|
};
|
|
var components$1 = function (owner, detail, internals) {
|
|
return substitutePlaces(Optional.some(owner), detail, detail.components, internals);
|
|
};
|
|
var getPart = function (component, detail, partKey) {
|
|
var uid = detail.partUids[partKey];
|
|
return component.getSystem().getByUid(uid).toOptional();
|
|
};
|
|
var getPartOrDie = function (component, detail, partKey) {
|
|
return getPart(component, detail, partKey).getOrDie('Could not find part: ' + partKey);
|
|
};
|
|
var getParts = function (component, detail, partKeys) {
|
|
var r = {};
|
|
var uids = detail.partUids;
|
|
var system = component.getSystem();
|
|
each$1(partKeys, function (pk) {
|
|
r[pk] = constant$1(system.getByUid(uids[pk]));
|
|
});
|
|
return r;
|
|
};
|
|
var getAllParts = function (component, detail) {
|
|
var system = component.getSystem();
|
|
return map$1(detail.partUids, function (pUid, _k) {
|
|
return constant$1(system.getByUid(pUid));
|
|
});
|
|
};
|
|
var getAllPartNames = function (detail) {
|
|
return keys(detail.partUids);
|
|
};
|
|
var getPartsOrDie = function (component, detail, partKeys) {
|
|
var r = {};
|
|
var uids = detail.partUids;
|
|
var system = component.getSystem();
|
|
each$1(partKeys, function (pk) {
|
|
r[pk] = constant$1(system.getByUid(uids[pk]).getOrDie());
|
|
});
|
|
return r;
|
|
};
|
|
var defaultUids = function (baseUid, partTypes) {
|
|
var partNames = names(partTypes);
|
|
return wrapAll(map$2(partNames, function (pn) {
|
|
return {
|
|
key: pn,
|
|
value: baseUid + '-' + pn
|
|
};
|
|
}));
|
|
};
|
|
var defaultUidsSchema = function (partTypes) {
|
|
return field$1('partUids', 'partUids', mergeWithThunk(function (spec) {
|
|
return defaultUids(spec.uid, partTypes);
|
|
}), anyValue());
|
|
};
|
|
|
|
var AlloyParts = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
generate: generate$3,
|
|
generateOne: generateOne$1,
|
|
schemas: schemas,
|
|
names: names,
|
|
substitutes: substitutes,
|
|
components: components$1,
|
|
defaultUids: defaultUids,
|
|
defaultUidsSchema: defaultUidsSchema,
|
|
getAllParts: getAllParts,
|
|
getAllPartNames: getAllPartNames,
|
|
getPart: getPart,
|
|
getPartOrDie: getPartOrDie,
|
|
getParts: getParts,
|
|
getPartsOrDie: getPartsOrDie
|
|
});
|
|
|
|
var base = function (partSchemas, partUidsSchemas) {
|
|
var ps = partSchemas.length > 0 ? [requiredObjOf('parts', partSchemas)] : [];
|
|
return ps.concat([
|
|
required$1('uid'),
|
|
defaulted('dom', {}),
|
|
defaulted('components', []),
|
|
snapshot('originalSpec'),
|
|
defaulted('debug.sketcher', {})
|
|
]).concat(partUidsSchemas);
|
|
};
|
|
var asRawOrDie = function (label, schema, spec, partSchemas, partUidsSchemas) {
|
|
var baseS = base(partSchemas, partUidsSchemas);
|
|
return asRawOrDie$1(label + ' [SpecSchema]', objOfOnly(baseS.concat(schema)), spec);
|
|
};
|
|
|
|
var single$1 = function (owner, schema, factory, spec) {
|
|
var specWithUid = supplyUid(spec);
|
|
var detail = asRawOrDie(owner, schema, specWithUid, [], []);
|
|
return factory(detail, specWithUid);
|
|
};
|
|
var composite$1 = function (owner, schema, partTypes, factory, spec) {
|
|
var specWithUid = supplyUid(spec);
|
|
var partSchemas = schemas(partTypes);
|
|
var partUidsSchema = defaultUidsSchema(partTypes);
|
|
var detail = asRawOrDie(owner, schema, specWithUid, partSchemas, [partUidsSchema]);
|
|
var subs = substitutes(owner, detail, partTypes);
|
|
var components = components$1(owner, detail, subs.internals());
|
|
return factory(detail, components, specWithUid, subs.externals());
|
|
};
|
|
var hasUid = function (spec) {
|
|
return has$2(spec, 'uid');
|
|
};
|
|
var supplyUid = function (spec) {
|
|
return hasUid(spec) ? spec : __assign(__assign({}, spec), { uid: generate$5('uid') });
|
|
};
|
|
|
|
var isSketchSpec = function (spec) {
|
|
return spec.uid !== undefined;
|
|
};
|
|
var singleSchema = objOfOnly([
|
|
required$1('name'),
|
|
required$1('factory'),
|
|
required$1('configFields'),
|
|
defaulted('apis', {}),
|
|
defaulted('extraApis', {})
|
|
]);
|
|
var compositeSchema = objOfOnly([
|
|
required$1('name'),
|
|
required$1('factory'),
|
|
required$1('configFields'),
|
|
required$1('partFields'),
|
|
defaulted('apis', {}),
|
|
defaulted('extraApis', {})
|
|
]);
|
|
var single = function (rawConfig) {
|
|
var config = asRawOrDie$1('Sketcher for ' + rawConfig.name, singleSchema, rawConfig);
|
|
var sketch = function (spec) {
|
|
return single$1(config.name, config.configFields, config.factory, spec);
|
|
};
|
|
var apis = map$1(config.apis, makeApi);
|
|
var extraApis = map$1(config.extraApis, function (f, k) {
|
|
return markAsExtraApi(f, k);
|
|
});
|
|
return __assign(__assign({
|
|
name: config.name,
|
|
configFields: config.configFields,
|
|
sketch: sketch
|
|
}, apis), extraApis);
|
|
};
|
|
var composite = function (rawConfig) {
|
|
var config = asRawOrDie$1('Sketcher for ' + rawConfig.name, compositeSchema, rawConfig);
|
|
var sketch = function (spec) {
|
|
return composite$1(config.name, config.configFields, config.partFields, config.factory, spec);
|
|
};
|
|
var parts = generate$3(config.name, config.partFields);
|
|
var apis = map$1(config.apis, makeApi);
|
|
var extraApis = map$1(config.extraApis, function (f, k) {
|
|
return markAsExtraApi(f, k);
|
|
});
|
|
return __assign(__assign({
|
|
name: config.name,
|
|
partFields: config.partFields,
|
|
configFields: config.configFields,
|
|
sketch: sketch,
|
|
parts: parts
|
|
}, apis), extraApis);
|
|
};
|
|
|
|
var inside = function (target) {
|
|
return name$2(target) === 'input' && get$d(target, 'type') !== 'radio' || name$2(target) === 'textarea';
|
|
};
|
|
|
|
var getCurrent = function (component, composeConfig, _composeState) {
|
|
return composeConfig.find(component);
|
|
};
|
|
|
|
var ComposeApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
getCurrent: getCurrent
|
|
});
|
|
|
|
var ComposeSchema = [required$1('find')];
|
|
|
|
var Composing = create$7({
|
|
fields: ComposeSchema,
|
|
name: 'composing',
|
|
apis: ComposeApis
|
|
});
|
|
|
|
var nativeDisabled = [
|
|
'input',
|
|
'button',
|
|
'textarea',
|
|
'select'
|
|
];
|
|
var onLoad$1 = function (component, disableConfig, disableState) {
|
|
var f = disableConfig.disabled() ? disable$1 : enable$1;
|
|
f(component, disableConfig);
|
|
};
|
|
var hasNative = function (component, config) {
|
|
return config.useNative === true && contains$2(nativeDisabled, name$2(component.element));
|
|
};
|
|
var nativeIsDisabled = function (component) {
|
|
return has$1(component.element, 'disabled');
|
|
};
|
|
var nativeDisable = function (component) {
|
|
set$8(component.element, 'disabled', 'disabled');
|
|
};
|
|
var nativeEnable = function (component) {
|
|
remove$7(component.element, 'disabled');
|
|
};
|
|
var ariaIsDisabled = function (component) {
|
|
return get$d(component.element, 'aria-disabled') === 'true';
|
|
};
|
|
var ariaDisable = function (component) {
|
|
set$8(component.element, 'aria-disabled', 'true');
|
|
};
|
|
var ariaEnable = function (component) {
|
|
set$8(component.element, 'aria-disabled', 'false');
|
|
};
|
|
var disable$1 = function (component, disableConfig, _disableState) {
|
|
disableConfig.disableClass.each(function (disableClass) {
|
|
add$2(component.element, disableClass);
|
|
});
|
|
var f = hasNative(component, disableConfig) ? nativeDisable : ariaDisable;
|
|
f(component);
|
|
disableConfig.onDisabled(component);
|
|
};
|
|
var enable$1 = function (component, disableConfig, _disableState) {
|
|
disableConfig.disableClass.each(function (disableClass) {
|
|
remove$2(component.element, disableClass);
|
|
});
|
|
var f = hasNative(component, disableConfig) ? nativeEnable : ariaEnable;
|
|
f(component);
|
|
disableConfig.onEnabled(component);
|
|
};
|
|
var isDisabled = function (component, disableConfig) {
|
|
return hasNative(component, disableConfig) ? nativeIsDisabled(component) : ariaIsDisabled(component);
|
|
};
|
|
var set$3 = function (component, disableConfig, disableState, disabled) {
|
|
var f = disabled ? disable$1 : enable$1;
|
|
f(component, disableConfig);
|
|
};
|
|
|
|
var DisableApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
enable: enable$1,
|
|
disable: disable$1,
|
|
isDisabled: isDisabled,
|
|
onLoad: onLoad$1,
|
|
set: set$3
|
|
});
|
|
|
|
var exhibit$5 = function (base, disableConfig) {
|
|
return nu$7({ classes: disableConfig.disabled() ? disableConfig.disableClass.toArray() : [] });
|
|
};
|
|
var events$e = function (disableConfig, disableState) {
|
|
return derive$2([
|
|
abort(execute$5(), function (component, _simulatedEvent) {
|
|
return isDisabled(component, disableConfig);
|
|
}),
|
|
loadEvent(disableConfig, disableState, onLoad$1)
|
|
]);
|
|
};
|
|
|
|
var ActiveDisable = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$5,
|
|
events: events$e
|
|
});
|
|
|
|
var DisableSchema = [
|
|
defaultedFunction('disabled', never),
|
|
defaulted('useNative', true),
|
|
option('disableClass'),
|
|
onHandler('onDisabled'),
|
|
onHandler('onEnabled')
|
|
];
|
|
|
|
var Disabling = create$7({
|
|
fields: DisableSchema,
|
|
name: 'disabling',
|
|
active: ActiveDisable,
|
|
apis: DisableApis
|
|
});
|
|
|
|
var dehighlightAllExcept = function (component, hConfig, hState, skip) {
|
|
var highlighted = descendants(component.element, '.' + hConfig.highlightClass);
|
|
each$1(highlighted, function (h) {
|
|
if (!exists(skip, function (skipComp) {
|
|
return skipComp.element === h;
|
|
})) {
|
|
remove$2(h, hConfig.highlightClass);
|
|
component.getSystem().getByDom(h).each(function (target) {
|
|
hConfig.onDehighlight(component, target);
|
|
emit(target, dehighlight$1());
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var dehighlightAll = function (component, hConfig, hState) {
|
|
return dehighlightAllExcept(component, hConfig, hState, []);
|
|
};
|
|
var dehighlight = function (component, hConfig, hState, target) {
|
|
if (isHighlighted(component, hConfig, hState, target)) {
|
|
remove$2(target.element, hConfig.highlightClass);
|
|
hConfig.onDehighlight(component, target);
|
|
emit(target, dehighlight$1());
|
|
}
|
|
};
|
|
var highlight = function (component, hConfig, hState, target) {
|
|
dehighlightAllExcept(component, hConfig, hState, [target]);
|
|
if (!isHighlighted(component, hConfig, hState, target)) {
|
|
add$2(target.element, hConfig.highlightClass);
|
|
hConfig.onHighlight(component, target);
|
|
emit(target, highlight$1());
|
|
}
|
|
};
|
|
var highlightFirst = function (component, hConfig, hState) {
|
|
getFirst(component, hConfig).each(function (firstComp) {
|
|
highlight(component, hConfig, hState, firstComp);
|
|
});
|
|
};
|
|
var highlightLast = function (component, hConfig, hState) {
|
|
getLast(component, hConfig).each(function (lastComp) {
|
|
highlight(component, hConfig, hState, lastComp);
|
|
});
|
|
};
|
|
var highlightAt = function (component, hConfig, hState, index) {
|
|
getByIndex(component, hConfig, hState, index).fold(function (err) {
|
|
throw err;
|
|
}, function (firstComp) {
|
|
highlight(component, hConfig, hState, firstComp);
|
|
});
|
|
};
|
|
var highlightBy = function (component, hConfig, hState, predicate) {
|
|
var candidates = getCandidates(component, hConfig);
|
|
var targetComp = find$5(candidates, predicate);
|
|
targetComp.each(function (c) {
|
|
highlight(component, hConfig, hState, c);
|
|
});
|
|
};
|
|
var isHighlighted = function (component, hConfig, hState, queryTarget) {
|
|
return has(queryTarget.element, hConfig.highlightClass);
|
|
};
|
|
var getHighlighted = function (component, hConfig, _hState) {
|
|
return descendant(component.element, '.' + hConfig.highlightClass).bind(function (e) {
|
|
return component.getSystem().getByDom(e).toOptional();
|
|
});
|
|
};
|
|
var getByIndex = function (component, hConfig, hState, index) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
return Optional.from(items[index]).fold(function () {
|
|
return Result.error(new Error('No element found with index ' + index));
|
|
}, component.getSystem().getByDom);
|
|
};
|
|
var getFirst = function (component, hConfig, _hState) {
|
|
return descendant(component.element, '.' + hConfig.itemClass).bind(function (e) {
|
|
return component.getSystem().getByDom(e).toOptional();
|
|
});
|
|
};
|
|
var getLast = function (component, hConfig, _hState) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
var last = items.length > 0 ? Optional.some(items[items.length - 1]) : Optional.none();
|
|
return last.bind(function (c) {
|
|
return component.getSystem().getByDom(c).toOptional();
|
|
});
|
|
};
|
|
var getDelta$2 = function (component, hConfig, hState, delta) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
var current = findIndex$1(items, function (item) {
|
|
return has(item, hConfig.highlightClass);
|
|
});
|
|
return current.bind(function (selected) {
|
|
var dest = cycleBy(selected, delta, 0, items.length - 1);
|
|
return component.getSystem().getByDom(items[dest]).toOptional();
|
|
});
|
|
};
|
|
var getPrevious = function (component, hConfig, hState) {
|
|
return getDelta$2(component, hConfig, hState, -1);
|
|
};
|
|
var getNext = function (component, hConfig, hState) {
|
|
return getDelta$2(component, hConfig, hState, +1);
|
|
};
|
|
var getCandidates = function (component, hConfig, _hState) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
return cat(map$2(items, function (i) {
|
|
return component.getSystem().getByDom(i).toOptional();
|
|
}));
|
|
};
|
|
|
|
var HighlightApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
dehighlightAll: dehighlightAll,
|
|
dehighlight: dehighlight,
|
|
highlight: highlight,
|
|
highlightFirst: highlightFirst,
|
|
highlightLast: highlightLast,
|
|
highlightAt: highlightAt,
|
|
highlightBy: highlightBy,
|
|
isHighlighted: isHighlighted,
|
|
getHighlighted: getHighlighted,
|
|
getFirst: getFirst,
|
|
getLast: getLast,
|
|
getPrevious: getPrevious,
|
|
getNext: getNext,
|
|
getCandidates: getCandidates
|
|
});
|
|
|
|
var HighlightSchema = [
|
|
required$1('highlightClass'),
|
|
required$1('itemClass'),
|
|
onHandler('onHighlight'),
|
|
onHandler('onDehighlight')
|
|
];
|
|
|
|
var Highlighting = create$7({
|
|
fields: HighlightSchema,
|
|
name: 'highlighting',
|
|
apis: HighlightApis
|
|
});
|
|
|
|
var BACKSPACE = [8];
|
|
var TAB = [9];
|
|
var ENTER = [13];
|
|
var ESCAPE = [27];
|
|
var SPACE = [32];
|
|
var LEFT = [37];
|
|
var UP = [38];
|
|
var RIGHT = [39];
|
|
var DOWN = [40];
|
|
|
|
var cyclePrev = function (values, index, predicate) {
|
|
var before = reverse(values.slice(0, index));
|
|
var after = reverse(values.slice(index + 1));
|
|
return find$5(before.concat(after), predicate);
|
|
};
|
|
var tryPrev = function (values, index, predicate) {
|
|
var before = reverse(values.slice(0, index));
|
|
return find$5(before, predicate);
|
|
};
|
|
var cycleNext = function (values, index, predicate) {
|
|
var before = values.slice(0, index);
|
|
var after = values.slice(index + 1);
|
|
return find$5(after.concat(before), predicate);
|
|
};
|
|
var tryNext = function (values, index, predicate) {
|
|
var after = values.slice(index + 1);
|
|
return find$5(after, predicate);
|
|
};
|
|
|
|
var inSet = function (keys) {
|
|
return function (event) {
|
|
var raw = event.raw;
|
|
return contains$2(keys, raw.which);
|
|
};
|
|
};
|
|
var and = function (preds) {
|
|
return function (event) {
|
|
return forall(preds, function (pred) {
|
|
return pred(event);
|
|
});
|
|
};
|
|
};
|
|
var isShift = function (event) {
|
|
var raw = event.raw;
|
|
return raw.shiftKey === true;
|
|
};
|
|
var isControl = function (event) {
|
|
var raw = event.raw;
|
|
return raw.ctrlKey === true;
|
|
};
|
|
var isNotShift = not(isShift);
|
|
|
|
var rule = function (matches, action) {
|
|
return {
|
|
matches: matches,
|
|
classification: action
|
|
};
|
|
};
|
|
var choose = function (transitions, event) {
|
|
var transition = find$5(transitions, function (t) {
|
|
return t.matches(event);
|
|
});
|
|
return transition.map(function (t) {
|
|
return t.classification;
|
|
});
|
|
};
|
|
|
|
var reportFocusShifting = function (component, prevFocus, newFocus) {
|
|
var noChange = prevFocus.exists(function (p) {
|
|
return newFocus.exists(function (n) {
|
|
return eq(n, p);
|
|
});
|
|
});
|
|
if (!noChange) {
|
|
emitWith(component, focusShifted(), {
|
|
prevFocus: prevFocus,
|
|
newFocus: newFocus
|
|
});
|
|
}
|
|
};
|
|
var dom$2 = function () {
|
|
var get = function (component) {
|
|
return search(component.element);
|
|
};
|
|
var set = function (component, focusee) {
|
|
var prevFocus = get(component);
|
|
component.getSystem().triggerFocus(focusee, component.element);
|
|
var newFocus = get(component);
|
|
reportFocusShifting(component, prevFocus, newFocus);
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var highlights = function () {
|
|
var get = function (component) {
|
|
return Highlighting.getHighlighted(component).map(function (item) {
|
|
return item.element;
|
|
});
|
|
};
|
|
var set = function (component, element) {
|
|
var prevFocus = get(component);
|
|
component.getSystem().getByDom(element).fold(noop, function (item) {
|
|
Highlighting.highlight(component, item);
|
|
});
|
|
var newFocus = get(component);
|
|
reportFocusShifting(component, prevFocus, newFocus);
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var FocusInsideModes;
|
|
(function (FocusInsideModes) {
|
|
FocusInsideModes['OnFocusMode'] = 'onFocus';
|
|
FocusInsideModes['OnEnterOrSpaceMode'] = 'onEnterOrSpace';
|
|
FocusInsideModes['OnApiMode'] = 'onApi';
|
|
}(FocusInsideModes || (FocusInsideModes = {})));
|
|
|
|
var typical = function (infoSchema, stateInit, getKeydownRules, getKeyupRules, optFocusIn) {
|
|
var schema = function () {
|
|
return infoSchema.concat([
|
|
defaulted('focusManager', dom$2()),
|
|
defaultedOf('focusInside', 'onFocus', valueOf(function (val) {
|
|
return contains$2([
|
|
'onFocus',
|
|
'onEnterOrSpace',
|
|
'onApi'
|
|
], val) ? Result.value(val) : Result.error('Invalid value for focusInside');
|
|
})),
|
|
output$1('handler', me),
|
|
output$1('state', stateInit),
|
|
output$1('sendFocusIn', optFocusIn)
|
|
]);
|
|
};
|
|
var processKey = function (component, simulatedEvent, getRules, keyingConfig, keyingState) {
|
|
var rules = getRules(component, simulatedEvent, keyingConfig, keyingState);
|
|
return choose(rules, simulatedEvent.event).bind(function (rule) {
|
|
return rule(component, simulatedEvent, keyingConfig, keyingState);
|
|
});
|
|
};
|
|
var toEvents = function (keyingConfig, keyingState) {
|
|
var onFocusHandler = keyingConfig.focusInside !== FocusInsideModes.OnFocusMode ? Optional.none() : optFocusIn(keyingConfig).map(function (focusIn) {
|
|
return run$1(focus$4(), function (component, simulatedEvent) {
|
|
focusIn(component, keyingConfig, keyingState);
|
|
simulatedEvent.stop();
|
|
});
|
|
});
|
|
var tryGoInsideComponent = function (component, simulatedEvent) {
|
|
var isEnterOrSpace = inSet(SPACE.concat(ENTER))(simulatedEvent.event);
|
|
if (keyingConfig.focusInside === FocusInsideModes.OnEnterOrSpaceMode && isEnterOrSpace && isSource(component, simulatedEvent)) {
|
|
optFocusIn(keyingConfig).each(function (focusIn) {
|
|
focusIn(component, keyingConfig, keyingState);
|
|
simulatedEvent.stop();
|
|
});
|
|
}
|
|
};
|
|
var keyboardEvents = [
|
|
run$1(keydown(), function (component, simulatedEvent) {
|
|
processKey(component, simulatedEvent, getKeydownRules, keyingConfig, keyingState).fold(function () {
|
|
tryGoInsideComponent(component, simulatedEvent);
|
|
}, function (_) {
|
|
simulatedEvent.stop();
|
|
});
|
|
}),
|
|
run$1(keyup(), function (component, simulatedEvent) {
|
|
processKey(component, simulatedEvent, getKeyupRules, keyingConfig, keyingState).each(function (_) {
|
|
simulatedEvent.stop();
|
|
});
|
|
})
|
|
];
|
|
return derive$2(onFocusHandler.toArray().concat(keyboardEvents));
|
|
};
|
|
var me = {
|
|
schema: schema,
|
|
processKey: processKey,
|
|
toEvents: toEvents
|
|
};
|
|
return me;
|
|
};
|
|
|
|
var create$5 = function (cyclicField) {
|
|
var schema = [
|
|
option('onEscape'),
|
|
option('onEnter'),
|
|
defaulted('selector', '[data-alloy-tabstop="true"]:not(:disabled)'),
|
|
defaulted('firstTabstop', 0),
|
|
defaulted('useTabstopAt', always),
|
|
option('visibilitySelector')
|
|
].concat([cyclicField]);
|
|
var isVisible = function (tabbingConfig, element) {
|
|
var target = tabbingConfig.visibilitySelector.bind(function (sel) {
|
|
return closest$1(element, sel);
|
|
}).getOr(element);
|
|
return get$b(target) > 0;
|
|
};
|
|
var findInitial = function (component, tabbingConfig) {
|
|
var tabstops = descendants(component.element, tabbingConfig.selector);
|
|
var visibles = filter$2(tabstops, function (elem) {
|
|
return isVisible(tabbingConfig, elem);
|
|
});
|
|
return Optional.from(visibles[tabbingConfig.firstTabstop]);
|
|
};
|
|
var findCurrent = function (component, tabbingConfig) {
|
|
return tabbingConfig.focusManager.get(component).bind(function (elem) {
|
|
return closest$1(elem, tabbingConfig.selector);
|
|
});
|
|
};
|
|
var isTabstop = function (tabbingConfig, element) {
|
|
return isVisible(tabbingConfig, element) && tabbingConfig.useTabstopAt(element);
|
|
};
|
|
var focusIn = function (component, tabbingConfig, _tabbingState) {
|
|
findInitial(component, tabbingConfig).each(function (target) {
|
|
tabbingConfig.focusManager.set(component, target);
|
|
});
|
|
};
|
|
var goFromTabstop = function (component, tabstops, stopIndex, tabbingConfig, cycle) {
|
|
return cycle(tabstops, stopIndex, function (elem) {
|
|
return isTabstop(tabbingConfig, elem);
|
|
}).fold(function () {
|
|
return tabbingConfig.cyclic ? Optional.some(true) : Optional.none();
|
|
}, function (target) {
|
|
tabbingConfig.focusManager.set(component, target);
|
|
return Optional.some(true);
|
|
});
|
|
};
|
|
var go = function (component, _simulatedEvent, tabbingConfig, cycle) {
|
|
var tabstops = descendants(component.element, tabbingConfig.selector);
|
|
return findCurrent(component, tabbingConfig).bind(function (tabstop) {
|
|
var optStopIndex = findIndex$1(tabstops, curry(eq, tabstop));
|
|
return optStopIndex.bind(function (stopIndex) {
|
|
return goFromTabstop(component, tabstops, stopIndex, tabbingConfig, cycle);
|
|
});
|
|
});
|
|
};
|
|
var goBackwards = function (component, simulatedEvent, tabbingConfig) {
|
|
var navigate = tabbingConfig.cyclic ? cyclePrev : tryPrev;
|
|
return go(component, simulatedEvent, tabbingConfig, navigate);
|
|
};
|
|
var goForwards = function (component, simulatedEvent, tabbingConfig) {
|
|
var navigate = tabbingConfig.cyclic ? cycleNext : tryNext;
|
|
return go(component, simulatedEvent, tabbingConfig, navigate);
|
|
};
|
|
var execute = function (component, simulatedEvent, tabbingConfig) {
|
|
return tabbingConfig.onEnter.bind(function (f) {
|
|
return f(component, simulatedEvent);
|
|
});
|
|
};
|
|
var exit = function (component, simulatedEvent, tabbingConfig) {
|
|
return tabbingConfig.onEscape.bind(function (f) {
|
|
return f(component, simulatedEvent);
|
|
});
|
|
};
|
|
var getKeydownRules = constant$1([
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), goBackwards),
|
|
rule(inSet(TAB), goForwards),
|
|
rule(inSet(ESCAPE), exit),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(ENTER)
|
|
]), execute)
|
|
]);
|
|
var getKeyupRules = constant$1([]);
|
|
return typical(schema, NoState.init, getKeydownRules, getKeyupRules, function () {
|
|
return Optional.some(focusIn);
|
|
});
|
|
};
|
|
|
|
var AcyclicType = create$5(customField('cyclic', never));
|
|
|
|
var CyclicType = create$5(customField('cyclic', always));
|
|
|
|
var doDefaultExecute = function (component, _simulatedEvent, focused) {
|
|
dispatch(component, focused, execute$5());
|
|
return Optional.some(true);
|
|
};
|
|
var defaultExecute = function (component, simulatedEvent, focused) {
|
|
var isComplex = inside(focused) && inSet(SPACE)(simulatedEvent.event);
|
|
return isComplex ? Optional.none() : doDefaultExecute(component, simulatedEvent, focused);
|
|
};
|
|
var stopEventForFirefox = function (_component, _simulatedEvent) {
|
|
return Optional.some(true);
|
|
};
|
|
|
|
var schema$v = [
|
|
defaulted('execute', defaultExecute),
|
|
defaulted('useSpace', false),
|
|
defaulted('useEnter', true),
|
|
defaulted('useControlEnter', false),
|
|
defaulted('useDown', false)
|
|
];
|
|
var execute$4 = function (component, simulatedEvent, executeConfig) {
|
|
return executeConfig.execute(component, simulatedEvent, component.element);
|
|
};
|
|
var getKeydownRules$5 = function (component, _simulatedEvent, executeConfig, _executeState) {
|
|
var spaceExec = executeConfig.useSpace && !inside(component.element) ? SPACE : [];
|
|
var enterExec = executeConfig.useEnter ? ENTER : [];
|
|
var downExec = executeConfig.useDown ? DOWN : [];
|
|
var execKeys = spaceExec.concat(enterExec).concat(downExec);
|
|
return [rule(inSet(execKeys), execute$4)].concat(executeConfig.useControlEnter ? [rule(and([
|
|
isControl,
|
|
inSet(ENTER)
|
|
]), execute$4)] : []);
|
|
};
|
|
var getKeyupRules$5 = function (component, _simulatedEvent, executeConfig, _executeState) {
|
|
return executeConfig.useSpace && !inside(component.element) ? [rule(inSet(SPACE), stopEventForFirefox)] : [];
|
|
};
|
|
var ExecutionType = typical(schema$v, NoState.init, getKeydownRules$5, getKeyupRules$5, function () {
|
|
return Optional.none();
|
|
});
|
|
|
|
var flatgrid$1 = function () {
|
|
var dimensions = value$1();
|
|
var setGridSize = function (numRows, numColumns) {
|
|
dimensions.set({
|
|
numRows: numRows,
|
|
numColumns: numColumns
|
|
});
|
|
};
|
|
var getNumRows = function () {
|
|
return dimensions.get().map(function (d) {
|
|
return d.numRows;
|
|
});
|
|
};
|
|
var getNumColumns = function () {
|
|
return dimensions.get().map(function (d) {
|
|
return d.numColumns;
|
|
});
|
|
};
|
|
return nu$8({
|
|
readState: function () {
|
|
return dimensions.get().map(function (d) {
|
|
return {
|
|
numRows: String(d.numRows),
|
|
numColumns: String(d.numColumns)
|
|
};
|
|
}).getOr({
|
|
numRows: '?',
|
|
numColumns: '?'
|
|
});
|
|
},
|
|
setGridSize: setGridSize,
|
|
getNumRows: getNumRows,
|
|
getNumColumns: getNumColumns
|
|
});
|
|
};
|
|
var init$d = function (spec) {
|
|
return spec.state(spec);
|
|
};
|
|
|
|
var KeyingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
flatgrid: flatgrid$1,
|
|
init: init$d
|
|
});
|
|
|
|
var useH = function (movement) {
|
|
return function (component, simulatedEvent, config, state) {
|
|
var move = movement(component.element);
|
|
return use(move, component, simulatedEvent, config, state);
|
|
};
|
|
};
|
|
var west$1 = function (moveLeft, moveRight) {
|
|
var movement = onDirection(moveLeft, moveRight);
|
|
return useH(movement);
|
|
};
|
|
var east$1 = function (moveLeft, moveRight) {
|
|
var movement = onDirection(moveRight, moveLeft);
|
|
return useH(movement);
|
|
};
|
|
var useV = function (move) {
|
|
return function (component, simulatedEvent, config, state) {
|
|
return use(move, component, simulatedEvent, config, state);
|
|
};
|
|
};
|
|
var use = function (move, component, simulatedEvent, config, state) {
|
|
var outcome = config.focusManager.get(component).bind(function (focused) {
|
|
return move(component.element, focused, config, state);
|
|
});
|
|
return outcome.map(function (newFocus) {
|
|
config.focusManager.set(component, newFocus);
|
|
return true;
|
|
});
|
|
};
|
|
var north$1 = useV;
|
|
var south$1 = useV;
|
|
var move$1 = useV;
|
|
|
|
var isHidden$1 = function (dom) {
|
|
return dom.offsetWidth <= 0 && dom.offsetHeight <= 0;
|
|
};
|
|
var isVisible = function (element) {
|
|
return !isHidden$1(element.dom);
|
|
};
|
|
|
|
var locate = function (candidates, predicate) {
|
|
return findIndex$1(candidates, predicate).map(function (index) {
|
|
return {
|
|
index: index,
|
|
candidates: candidates
|
|
};
|
|
});
|
|
};
|
|
|
|
var locateVisible = function (container, current, selector) {
|
|
var predicate = function (x) {
|
|
return eq(x, current);
|
|
};
|
|
var candidates = descendants(container, selector);
|
|
var visible = filter$2(candidates, isVisible);
|
|
return locate(visible, predicate);
|
|
};
|
|
var findIndex = function (elements, target) {
|
|
return findIndex$1(elements, function (elem) {
|
|
return eq(target, elem);
|
|
});
|
|
};
|
|
|
|
var withGrid = function (values, index, numCols, f) {
|
|
var oldRow = Math.floor(index / numCols);
|
|
var oldColumn = index % numCols;
|
|
return f(oldRow, oldColumn).bind(function (address) {
|
|
var newIndex = address.row * numCols + address.column;
|
|
return newIndex >= 0 && newIndex < values.length ? Optional.some(values[newIndex]) : Optional.none();
|
|
});
|
|
};
|
|
var cycleHorizontal$1 = function (values, index, numRows, numCols, delta) {
|
|
return withGrid(values, index, numCols, function (oldRow, oldColumn) {
|
|
var onLastRow = oldRow === numRows - 1;
|
|
var colsInRow = onLastRow ? values.length - oldRow * numCols : numCols;
|
|
var newColumn = cycleBy(oldColumn, delta, 0, colsInRow - 1);
|
|
return Optional.some({
|
|
row: oldRow,
|
|
column: newColumn
|
|
});
|
|
});
|
|
};
|
|
var cycleVertical$1 = function (values, index, numRows, numCols, delta) {
|
|
return withGrid(values, index, numCols, function (oldRow, oldColumn) {
|
|
var newRow = cycleBy(oldRow, delta, 0, numRows - 1);
|
|
var onLastRow = newRow === numRows - 1;
|
|
var colsInRow = onLastRow ? values.length - newRow * numCols : numCols;
|
|
var newCol = clamp$1(oldColumn, 0, colsInRow - 1);
|
|
return Optional.some({
|
|
row: newRow,
|
|
column: newCol
|
|
});
|
|
});
|
|
};
|
|
var cycleRight$1 = function (values, index, numRows, numCols) {
|
|
return cycleHorizontal$1(values, index, numRows, numCols, +1);
|
|
};
|
|
var cycleLeft$1 = function (values, index, numRows, numCols) {
|
|
return cycleHorizontal$1(values, index, numRows, numCols, -1);
|
|
};
|
|
var cycleUp$1 = function (values, index, numRows, numCols) {
|
|
return cycleVertical$1(values, index, numRows, numCols, -1);
|
|
};
|
|
var cycleDown$1 = function (values, index, numRows, numCols) {
|
|
return cycleVertical$1(values, index, numRows, numCols, +1);
|
|
};
|
|
|
|
var schema$u = [
|
|
required$1('selector'),
|
|
defaulted('execute', defaultExecute),
|
|
onKeyboardHandler('onEscape'),
|
|
defaulted('captureTab', false),
|
|
initSize()
|
|
];
|
|
var focusIn$3 = function (component, gridConfig, _gridState) {
|
|
descendant(component.element, gridConfig.selector).each(function (first) {
|
|
gridConfig.focusManager.set(component, first);
|
|
});
|
|
};
|
|
var findCurrent$1 = function (component, gridConfig) {
|
|
return gridConfig.focusManager.get(component).bind(function (elem) {
|
|
return closest$1(elem, gridConfig.selector);
|
|
});
|
|
};
|
|
var execute$3 = function (component, simulatedEvent, gridConfig, _gridState) {
|
|
return findCurrent$1(component, gridConfig).bind(function (focused) {
|
|
return gridConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var doMove$2 = function (cycle) {
|
|
return function (element, focused, gridConfig, gridState) {
|
|
return locateVisible(element, focused, gridConfig.selector).bind(function (identified) {
|
|
return cycle(identified.candidates, identified.index, gridState.getNumRows().getOr(gridConfig.initSize.numRows), gridState.getNumColumns().getOr(gridConfig.initSize.numColumns));
|
|
});
|
|
};
|
|
};
|
|
var handleTab = function (_component, _simulatedEvent, gridConfig) {
|
|
return gridConfig.captureTab ? Optional.some(true) : Optional.none();
|
|
};
|
|
var doEscape$1 = function (component, simulatedEvent, gridConfig) {
|
|
return gridConfig.onEscape(component, simulatedEvent);
|
|
};
|
|
var moveLeft$3 = doMove$2(cycleLeft$1);
|
|
var moveRight$3 = doMove$2(cycleRight$1);
|
|
var moveNorth$1 = doMove$2(cycleUp$1);
|
|
var moveSouth$1 = doMove$2(cycleDown$1);
|
|
var getKeydownRules$4 = constant$1([
|
|
rule(inSet(LEFT), west$1(moveLeft$3, moveRight$3)),
|
|
rule(inSet(RIGHT), east$1(moveLeft$3, moveRight$3)),
|
|
rule(inSet(UP), north$1(moveNorth$1)),
|
|
rule(inSet(DOWN), south$1(moveSouth$1)),
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), handleTab),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(TAB)
|
|
]), handleTab),
|
|
rule(inSet(ESCAPE), doEscape$1),
|
|
rule(inSet(SPACE.concat(ENTER)), execute$3)
|
|
]);
|
|
var getKeyupRules$4 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var FlatgridType = typical(schema$u, flatgrid$1, getKeydownRules$4, getKeyupRules$4, function () {
|
|
return Optional.some(focusIn$3);
|
|
});
|
|
|
|
var horizontal = function (container, selector, current, delta) {
|
|
var isDisabledButton = function (candidate) {
|
|
return name$2(candidate) === 'button' && get$d(candidate, 'disabled') === 'disabled';
|
|
};
|
|
var tryCycle = function (initial, index, candidates) {
|
|
var newIndex = cycleBy(index, delta, 0, candidates.length - 1);
|
|
if (newIndex === initial) {
|
|
return Optional.none();
|
|
} else {
|
|
return isDisabledButton(candidates[newIndex]) ? tryCycle(initial, newIndex, candidates) : Optional.from(candidates[newIndex]);
|
|
}
|
|
};
|
|
return locateVisible(container, current, selector).bind(function (identified) {
|
|
var index = identified.index;
|
|
var candidates = identified.candidates;
|
|
return tryCycle(index, index, candidates);
|
|
});
|
|
};
|
|
|
|
var schema$t = [
|
|
required$1('selector'),
|
|
defaulted('getInitial', Optional.none),
|
|
defaulted('execute', defaultExecute),
|
|
onKeyboardHandler('onEscape'),
|
|
defaulted('executeOnMove', false),
|
|
defaulted('allowVertical', true)
|
|
];
|
|
var findCurrent = function (component, flowConfig) {
|
|
return flowConfig.focusManager.get(component).bind(function (elem) {
|
|
return closest$1(elem, flowConfig.selector);
|
|
});
|
|
};
|
|
var execute$2 = function (component, simulatedEvent, flowConfig) {
|
|
return findCurrent(component, flowConfig).bind(function (focused) {
|
|
return flowConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var focusIn$2 = function (component, flowConfig, _state) {
|
|
flowConfig.getInitial(component).orThunk(function () {
|
|
return descendant(component.element, flowConfig.selector);
|
|
}).each(function (first) {
|
|
flowConfig.focusManager.set(component, first);
|
|
});
|
|
};
|
|
var moveLeft$2 = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, -1);
|
|
};
|
|
var moveRight$2 = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, +1);
|
|
};
|
|
var doMove$1 = function (movement) {
|
|
return function (component, simulatedEvent, flowConfig, flowState) {
|
|
return movement(component, simulatedEvent, flowConfig, flowState).bind(function () {
|
|
return flowConfig.executeOnMove ? execute$2(component, simulatedEvent, flowConfig) : Optional.some(true);
|
|
});
|
|
};
|
|
};
|
|
var doEscape = function (component, simulatedEvent, flowConfig) {
|
|
return flowConfig.onEscape(component, simulatedEvent);
|
|
};
|
|
var getKeydownRules$3 = function (_component, _se, flowConfig, _flowState) {
|
|
var westMovers = LEFT.concat(flowConfig.allowVertical ? UP : []);
|
|
var eastMovers = RIGHT.concat(flowConfig.allowVertical ? DOWN : []);
|
|
return [
|
|
rule(inSet(westMovers), doMove$1(west$1(moveLeft$2, moveRight$2))),
|
|
rule(inSet(eastMovers), doMove$1(east$1(moveLeft$2, moveRight$2))),
|
|
rule(inSet(ENTER), execute$2),
|
|
rule(inSet(SPACE), execute$2),
|
|
rule(inSet(ESCAPE), doEscape)
|
|
];
|
|
};
|
|
var getKeyupRules$3 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var FlowType = typical(schema$t, NoState.init, getKeydownRules$3, getKeyupRules$3, function () {
|
|
return Optional.some(focusIn$2);
|
|
});
|
|
|
|
var toCell = function (matrix, rowIndex, columnIndex) {
|
|
return Optional.from(matrix[rowIndex]).bind(function (row) {
|
|
return Optional.from(row[columnIndex]).map(function (cell) {
|
|
return {
|
|
rowIndex: rowIndex,
|
|
columnIndex: columnIndex,
|
|
cell: cell
|
|
};
|
|
});
|
|
});
|
|
};
|
|
var cycleHorizontal = function (matrix, rowIndex, startCol, deltaCol) {
|
|
var row = matrix[rowIndex];
|
|
var colsInRow = row.length;
|
|
var newColIndex = cycleBy(startCol, deltaCol, 0, colsInRow - 1);
|
|
return toCell(matrix, rowIndex, newColIndex);
|
|
};
|
|
var cycleVertical = function (matrix, colIndex, startRow, deltaRow) {
|
|
var nextRowIndex = cycleBy(startRow, deltaRow, 0, matrix.length - 1);
|
|
var colsInNextRow = matrix[nextRowIndex].length;
|
|
var nextColIndex = clamp$1(colIndex, 0, colsInNextRow - 1);
|
|
return toCell(matrix, nextRowIndex, nextColIndex);
|
|
};
|
|
var moveHorizontal = function (matrix, rowIndex, startCol, deltaCol) {
|
|
var row = matrix[rowIndex];
|
|
var colsInRow = row.length;
|
|
var newColIndex = clamp$1(startCol + deltaCol, 0, colsInRow - 1);
|
|
return toCell(matrix, rowIndex, newColIndex);
|
|
};
|
|
var moveVertical = function (matrix, colIndex, startRow, deltaRow) {
|
|
var nextRowIndex = clamp$1(startRow + deltaRow, 0, matrix.length - 1);
|
|
var colsInNextRow = matrix[nextRowIndex].length;
|
|
var nextColIndex = clamp$1(colIndex, 0, colsInNextRow - 1);
|
|
return toCell(matrix, nextRowIndex, nextColIndex);
|
|
};
|
|
var cycleRight = function (matrix, startRow, startCol) {
|
|
return cycleHorizontal(matrix, startRow, startCol, +1);
|
|
};
|
|
var cycleLeft = function (matrix, startRow, startCol) {
|
|
return cycleHorizontal(matrix, startRow, startCol, -1);
|
|
};
|
|
var cycleUp = function (matrix, startRow, startCol) {
|
|
return cycleVertical(matrix, startCol, startRow, -1);
|
|
};
|
|
var cycleDown = function (matrix, startRow, startCol) {
|
|
return cycleVertical(matrix, startCol, startRow, +1);
|
|
};
|
|
var moveLeft$1 = function (matrix, startRow, startCol) {
|
|
return moveHorizontal(matrix, startRow, startCol, -1);
|
|
};
|
|
var moveRight$1 = function (matrix, startRow, startCol) {
|
|
return moveHorizontal(matrix, startRow, startCol, +1);
|
|
};
|
|
var moveUp$1 = function (matrix, startRow, startCol) {
|
|
return moveVertical(matrix, startCol, startRow, -1);
|
|
};
|
|
var moveDown$1 = function (matrix, startRow, startCol) {
|
|
return moveVertical(matrix, startCol, startRow, +1);
|
|
};
|
|
|
|
var schema$s = [
|
|
requiredObjOf('selectors', [
|
|
required$1('row'),
|
|
required$1('cell')
|
|
]),
|
|
defaulted('cycles', true),
|
|
defaulted('previousSelector', Optional.none),
|
|
defaulted('execute', defaultExecute)
|
|
];
|
|
var focusIn$1 = function (component, matrixConfig, _state) {
|
|
var focused = matrixConfig.previousSelector(component).orThunk(function () {
|
|
var selectors = matrixConfig.selectors;
|
|
return descendant(component.element, selectors.cell);
|
|
});
|
|
focused.each(function (cell) {
|
|
matrixConfig.focusManager.set(component, cell);
|
|
});
|
|
};
|
|
var execute$1 = function (component, simulatedEvent, matrixConfig) {
|
|
return search(component.element).bind(function (focused) {
|
|
return matrixConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var toMatrix = function (rows, matrixConfig) {
|
|
return map$2(rows, function (row) {
|
|
return descendants(row, matrixConfig.selectors.cell);
|
|
});
|
|
};
|
|
var doMove = function (ifCycle, ifMove) {
|
|
return function (element, focused, matrixConfig) {
|
|
var move = matrixConfig.cycles ? ifCycle : ifMove;
|
|
return closest$1(focused, matrixConfig.selectors.row).bind(function (inRow) {
|
|
var cellsInRow = descendants(inRow, matrixConfig.selectors.cell);
|
|
return findIndex(cellsInRow, focused).bind(function (colIndex) {
|
|
var allRows = descendants(element, matrixConfig.selectors.row);
|
|
return findIndex(allRows, inRow).bind(function (rowIndex) {
|
|
var matrix = toMatrix(allRows, matrixConfig);
|
|
return move(matrix, rowIndex, colIndex).map(function (next) {
|
|
return next.cell;
|
|
});
|
|
});
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var moveLeft = doMove(cycleLeft, moveLeft$1);
|
|
var moveRight = doMove(cycleRight, moveRight$1);
|
|
var moveNorth = doMove(cycleUp, moveUp$1);
|
|
var moveSouth = doMove(cycleDown, moveDown$1);
|
|
var getKeydownRules$2 = constant$1([
|
|
rule(inSet(LEFT), west$1(moveLeft, moveRight)),
|
|
rule(inSet(RIGHT), east$1(moveLeft, moveRight)),
|
|
rule(inSet(UP), north$1(moveNorth)),
|
|
rule(inSet(DOWN), south$1(moveSouth)),
|
|
rule(inSet(SPACE.concat(ENTER)), execute$1)
|
|
]);
|
|
var getKeyupRules$2 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var MatrixType = typical(schema$s, NoState.init, getKeydownRules$2, getKeyupRules$2, function () {
|
|
return Optional.some(focusIn$1);
|
|
});
|
|
|
|
var schema$r = [
|
|
required$1('selector'),
|
|
defaulted('execute', defaultExecute),
|
|
defaulted('moveOnTab', false)
|
|
];
|
|
var execute = function (component, simulatedEvent, menuConfig) {
|
|
return menuConfig.focusManager.get(component).bind(function (focused) {
|
|
return menuConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var focusIn = function (component, menuConfig, _state) {
|
|
descendant(component.element, menuConfig.selector).each(function (first) {
|
|
menuConfig.focusManager.set(component, first);
|
|
});
|
|
};
|
|
var moveUp = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, -1);
|
|
};
|
|
var moveDown = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, +1);
|
|
};
|
|
var fireShiftTab = function (component, simulatedEvent, menuConfig, menuState) {
|
|
return menuConfig.moveOnTab ? move$1(moveUp)(component, simulatedEvent, menuConfig, menuState) : Optional.none();
|
|
};
|
|
var fireTab = function (component, simulatedEvent, menuConfig, menuState) {
|
|
return menuConfig.moveOnTab ? move$1(moveDown)(component, simulatedEvent, menuConfig, menuState) : Optional.none();
|
|
};
|
|
var getKeydownRules$1 = constant$1([
|
|
rule(inSet(UP), move$1(moveUp)),
|
|
rule(inSet(DOWN), move$1(moveDown)),
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), fireShiftTab),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(TAB)
|
|
]), fireTab),
|
|
rule(inSet(ENTER), execute),
|
|
rule(inSet(SPACE), execute)
|
|
]);
|
|
var getKeyupRules$1 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var MenuType = typical(schema$r, NoState.init, getKeydownRules$1, getKeyupRules$1, function () {
|
|
return Optional.some(focusIn);
|
|
});
|
|
|
|
var schema$q = [
|
|
onKeyboardHandler('onSpace'),
|
|
onKeyboardHandler('onEnter'),
|
|
onKeyboardHandler('onShiftEnter'),
|
|
onKeyboardHandler('onLeft'),
|
|
onKeyboardHandler('onRight'),
|
|
onKeyboardHandler('onTab'),
|
|
onKeyboardHandler('onShiftTab'),
|
|
onKeyboardHandler('onUp'),
|
|
onKeyboardHandler('onDown'),
|
|
onKeyboardHandler('onEscape'),
|
|
defaulted('stopSpaceKeyup', false),
|
|
option('focusIn')
|
|
];
|
|
var getKeydownRules = function (component, simulatedEvent, specialInfo) {
|
|
return [
|
|
rule(inSet(SPACE), specialInfo.onSpace),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(ENTER)
|
|
]), specialInfo.onEnter),
|
|
rule(and([
|
|
isShift,
|
|
inSet(ENTER)
|
|
]), specialInfo.onShiftEnter),
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), specialInfo.onShiftTab),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(TAB)
|
|
]), specialInfo.onTab),
|
|
rule(inSet(UP), specialInfo.onUp),
|
|
rule(inSet(DOWN), specialInfo.onDown),
|
|
rule(inSet(LEFT), specialInfo.onLeft),
|
|
rule(inSet(RIGHT), specialInfo.onRight),
|
|
rule(inSet(SPACE), specialInfo.onSpace),
|
|
rule(inSet(ESCAPE), specialInfo.onEscape)
|
|
];
|
|
};
|
|
var getKeyupRules = function (component, simulatedEvent, specialInfo) {
|
|
return specialInfo.stopSpaceKeyup ? [rule(inSet(SPACE), stopEventForFirefox)] : [];
|
|
};
|
|
var SpecialType = typical(schema$q, NoState.init, getKeydownRules, getKeyupRules, function (specialInfo) {
|
|
return specialInfo.focusIn;
|
|
});
|
|
|
|
var acyclic = AcyclicType.schema();
|
|
var cyclic = CyclicType.schema();
|
|
var flow = FlowType.schema();
|
|
var flatgrid = FlatgridType.schema();
|
|
var matrix = MatrixType.schema();
|
|
var execution = ExecutionType.schema();
|
|
var menu = MenuType.schema();
|
|
var special = SpecialType.schema();
|
|
|
|
var KeyboardBranches = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
acyclic: acyclic,
|
|
cyclic: cyclic,
|
|
flow: flow,
|
|
flatgrid: flatgrid,
|
|
matrix: matrix,
|
|
execution: execution,
|
|
menu: menu,
|
|
special: special
|
|
});
|
|
|
|
var isFlatgridState = function (keyState) {
|
|
return hasNonNullableKey(keyState, 'setGridSize');
|
|
};
|
|
var Keying = createModes({
|
|
branchKey: 'mode',
|
|
branches: KeyboardBranches,
|
|
name: 'keying',
|
|
active: {
|
|
events: function (keyingConfig, keyingState) {
|
|
var handler = keyingConfig.handler;
|
|
return handler.toEvents(keyingConfig, keyingState);
|
|
}
|
|
},
|
|
apis: {
|
|
focusIn: function (component, keyConfig, keyState) {
|
|
keyConfig.sendFocusIn(keyConfig).fold(function () {
|
|
component.getSystem().triggerFocus(component.element, component.element);
|
|
}, function (sendFocusIn) {
|
|
sendFocusIn(component, keyConfig, keyState);
|
|
});
|
|
},
|
|
setGridSize: function (component, keyConfig, keyState, numRows, numColumns) {
|
|
if (!isFlatgridState(keyState)) {
|
|
console.error('Layout does not support setGridSize');
|
|
} else {
|
|
keyState.setGridSize(numRows, numColumns);
|
|
}
|
|
}
|
|
},
|
|
state: KeyingState
|
|
});
|
|
|
|
var set$2 = function (component, replaceConfig, replaceState, data) {
|
|
preserve$1(function () {
|
|
var newChildren = map$2(data, component.getSystem().build);
|
|
replaceChildren(component, newChildren);
|
|
}, component.element);
|
|
};
|
|
var insert = function (component, replaceConfig, insertion, childSpec) {
|
|
var child = component.getSystem().build(childSpec);
|
|
attachWith(component, child, insertion);
|
|
};
|
|
var append = function (component, replaceConfig, replaceState, appendee) {
|
|
insert(component, replaceConfig, append$2, appendee);
|
|
};
|
|
var prepend = function (component, replaceConfig, replaceState, prependee) {
|
|
insert(component, replaceConfig, prepend$1, prependee);
|
|
};
|
|
var remove = function (component, replaceConfig, replaceState, removee) {
|
|
var children = contents(component);
|
|
var foundChild = find$5(children, function (child) {
|
|
return eq(removee.element, child.element);
|
|
});
|
|
foundChild.each(detach);
|
|
};
|
|
var contents = function (component, _replaceConfig) {
|
|
return component.components();
|
|
};
|
|
var replaceAt = function (component, replaceConfig, replaceState, replaceeIndex, replacer) {
|
|
var children = contents(component);
|
|
return Optional.from(children[replaceeIndex]).map(function (replacee) {
|
|
remove(component, replaceConfig, replaceState, replacee);
|
|
replacer.each(function (r) {
|
|
insert(component, replaceConfig, function (p, c) {
|
|
appendAt(p, c, replaceeIndex);
|
|
}, r);
|
|
});
|
|
return replacee;
|
|
});
|
|
};
|
|
var replaceBy = function (component, replaceConfig, replaceState, replaceePred, replacer) {
|
|
var children = contents(component);
|
|
return findIndex$1(children, replaceePred).bind(function (replaceeIndex) {
|
|
return replaceAt(component, replaceConfig, replaceState, replaceeIndex, replacer);
|
|
});
|
|
};
|
|
|
|
var ReplaceApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
append: append,
|
|
prepend: prepend,
|
|
remove: remove,
|
|
replaceAt: replaceAt,
|
|
replaceBy: replaceBy,
|
|
set: set$2,
|
|
contents: contents
|
|
});
|
|
|
|
var Replacing = create$7({
|
|
fields: [],
|
|
name: 'replacing',
|
|
apis: ReplaceApis
|
|
});
|
|
|
|
var events$d = function (name, eventHandlers) {
|
|
var events = derive$2(eventHandlers);
|
|
return create$7({
|
|
fields: [required$1('enabled')],
|
|
name: name,
|
|
active: { events: constant$1(events) }
|
|
});
|
|
};
|
|
var config = function (name, eventHandlers) {
|
|
var me = events$d(name, eventHandlers);
|
|
return {
|
|
key: name,
|
|
value: {
|
|
config: {},
|
|
me: me,
|
|
configAsRaw: constant$1({}),
|
|
initialConfig: {},
|
|
state: NoState
|
|
}
|
|
};
|
|
};
|
|
|
|
var focus$2 = function (component, focusConfig) {
|
|
if (!focusConfig.ignore) {
|
|
focus$3(component.element);
|
|
focusConfig.onFocus(component);
|
|
}
|
|
};
|
|
var blur = function (component, focusConfig) {
|
|
if (!focusConfig.ignore) {
|
|
blur$1(component.element);
|
|
}
|
|
};
|
|
var isFocused = function (component) {
|
|
return hasFocus(component.element);
|
|
};
|
|
|
|
var FocusApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
focus: focus$2,
|
|
blur: blur,
|
|
isFocused: isFocused
|
|
});
|
|
|
|
var exhibit$4 = function (base, focusConfig) {
|
|
var mod = focusConfig.ignore ? {} : { attributes: { tabindex: '-1' } };
|
|
return nu$7(mod);
|
|
};
|
|
var events$c = function (focusConfig) {
|
|
return derive$2([run$1(focus$4(), function (component, simulatedEvent) {
|
|
focus$2(component, focusConfig);
|
|
simulatedEvent.stop();
|
|
})].concat(focusConfig.stopMousedown ? [run$1(mousedown(), function (_, simulatedEvent) {
|
|
simulatedEvent.event.prevent();
|
|
})] : []));
|
|
};
|
|
|
|
var ActiveFocus = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$4,
|
|
events: events$c
|
|
});
|
|
|
|
var FocusSchema = [
|
|
onHandler('onFocus'),
|
|
defaulted('stopMousedown', false),
|
|
defaulted('ignore', false)
|
|
];
|
|
|
|
var Focusing = create$7({
|
|
fields: FocusSchema,
|
|
name: 'focusing',
|
|
active: ActiveFocus,
|
|
apis: FocusApis
|
|
});
|
|
|
|
var SetupBehaviourCellState = function (initialState) {
|
|
var init = function () {
|
|
var cell = Cell(initialState);
|
|
var get = function () {
|
|
return cell.get();
|
|
};
|
|
var set = function (newState) {
|
|
return cell.set(newState);
|
|
};
|
|
var clear = function () {
|
|
return cell.set(initialState);
|
|
};
|
|
var readState = function () {
|
|
return cell.get();
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set,
|
|
clear: clear,
|
|
readState: readState
|
|
};
|
|
};
|
|
return { init: init };
|
|
};
|
|
|
|
var updateAriaState = function (component, toggleConfig, toggleState) {
|
|
var ariaInfo = toggleConfig.aria;
|
|
ariaInfo.update(component, ariaInfo, toggleState.get());
|
|
};
|
|
var updateClass = function (component, toggleConfig, toggleState) {
|
|
toggleConfig.toggleClass.each(function (toggleClass) {
|
|
if (toggleState.get()) {
|
|
add$2(component.element, toggleClass);
|
|
} else {
|
|
remove$2(component.element, toggleClass);
|
|
}
|
|
});
|
|
};
|
|
var toggle$2 = function (component, toggleConfig, toggleState) {
|
|
set$1(component, toggleConfig, toggleState, !toggleState.get());
|
|
};
|
|
var on = function (component, toggleConfig, toggleState) {
|
|
toggleState.set(true);
|
|
updateClass(component, toggleConfig, toggleState);
|
|
updateAriaState(component, toggleConfig, toggleState);
|
|
};
|
|
var off = function (component, toggleConfig, toggleState) {
|
|
toggleState.set(false);
|
|
updateClass(component, toggleConfig, toggleState);
|
|
updateAriaState(component, toggleConfig, toggleState);
|
|
};
|
|
var set$1 = function (component, toggleConfig, toggleState, state) {
|
|
var action = state ? on : off;
|
|
action(component, toggleConfig, toggleState);
|
|
};
|
|
var isOn = function (component, toggleConfig, toggleState) {
|
|
return toggleState.get();
|
|
};
|
|
var onLoad = function (component, toggleConfig, toggleState) {
|
|
set$1(component, toggleConfig, toggleState, toggleConfig.selected);
|
|
};
|
|
|
|
var ToggleApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
onLoad: onLoad,
|
|
toggle: toggle$2,
|
|
isOn: isOn,
|
|
on: on,
|
|
off: off,
|
|
set: set$1
|
|
});
|
|
|
|
var exhibit$3 = function () {
|
|
return nu$7({});
|
|
};
|
|
var events$b = function (toggleConfig, toggleState) {
|
|
var execute = executeEvent(toggleConfig, toggleState, toggle$2);
|
|
var load = loadEvent(toggleConfig, toggleState, onLoad);
|
|
return derive$2(flatten([
|
|
toggleConfig.toggleOnExecute ? [execute] : [],
|
|
[load]
|
|
]));
|
|
};
|
|
|
|
var ActiveToggle = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$3,
|
|
events: events$b
|
|
});
|
|
|
|
var updatePressed = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-pressed', status);
|
|
if (ariaInfo.syncWithExpanded) {
|
|
updateExpanded(component, ariaInfo, status);
|
|
}
|
|
};
|
|
var updateSelected = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-selected', status);
|
|
};
|
|
var updateChecked = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-checked', status);
|
|
};
|
|
var updateExpanded = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-expanded', status);
|
|
};
|
|
|
|
var ToggleSchema = [
|
|
defaulted('selected', false),
|
|
option('toggleClass'),
|
|
defaulted('toggleOnExecute', true),
|
|
defaultedOf('aria', { mode: 'none' }, choose$1('mode', {
|
|
pressed: [
|
|
defaulted('syncWithExpanded', false),
|
|
output$1('update', updatePressed)
|
|
],
|
|
checked: [output$1('update', updateChecked)],
|
|
expanded: [output$1('update', updateExpanded)],
|
|
selected: [output$1('update', updateSelected)],
|
|
none: [output$1('update', noop)]
|
|
}))
|
|
];
|
|
|
|
var Toggling = create$7({
|
|
fields: ToggleSchema,
|
|
name: 'toggling',
|
|
active: ActiveToggle,
|
|
apis: ToggleApis,
|
|
state: SetupBehaviourCellState(false)
|
|
});
|
|
|
|
var pointerEvents = function () {
|
|
var onClick = function (component, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
emitExecute(component);
|
|
};
|
|
return [
|
|
run$1(click(), onClick),
|
|
run$1(tap(), onClick),
|
|
cutter(touchstart()),
|
|
cutter(mousedown())
|
|
];
|
|
};
|
|
var events$a = function (optAction) {
|
|
var executeHandler = function (action) {
|
|
return runOnExecute$1(function (component, simulatedEvent) {
|
|
action(component);
|
|
simulatedEvent.stop();
|
|
});
|
|
};
|
|
return derive$2(flatten([
|
|
optAction.map(executeHandler).toArray(),
|
|
pointerEvents()
|
|
]));
|
|
};
|
|
|
|
var hoverEvent = 'alloy.item-hover';
|
|
var focusEvent = 'alloy.item-focus';
|
|
var onHover = function (item) {
|
|
if (search(item.element).isNone() || Focusing.isFocused(item)) {
|
|
if (!Focusing.isFocused(item)) {
|
|
Focusing.focus(item);
|
|
}
|
|
emitWith(item, hoverEvent, { item: item });
|
|
}
|
|
};
|
|
var onFocus$1 = function (item) {
|
|
emitWith(item, focusEvent, { item: item });
|
|
};
|
|
var hover = constant$1(hoverEvent);
|
|
var focus$1 = constant$1(focusEvent);
|
|
|
|
var builder$2 = function (detail) {
|
|
return {
|
|
dom: detail.dom,
|
|
domModification: __assign(__assign({}, detail.domModification), { attributes: __assign(__assign(__assign({ 'role': detail.toggling.isSome() ? 'menuitemcheckbox' : 'menuitem' }, detail.domModification.attributes), { 'aria-haspopup': detail.hasSubmenu }), detail.hasSubmenu ? { 'aria-expanded': false } : {}) }),
|
|
behaviours: SketchBehaviours.augment(detail.itemBehaviours, [
|
|
detail.toggling.fold(Toggling.revoke, function (tConfig) {
|
|
return Toggling.config(__assign({ aria: { mode: 'checked' } }, tConfig));
|
|
}),
|
|
Focusing.config({
|
|
ignore: detail.ignoreFocus,
|
|
stopMousedown: detail.ignoreFocus,
|
|
onFocus: function (component) {
|
|
onFocus$1(component);
|
|
}
|
|
}),
|
|
Keying.config({ mode: 'execution' }),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.data
|
|
}
|
|
}),
|
|
config('item-type-events', __spreadArray(__spreadArray([], pointerEvents(), true), [
|
|
run$1(mouseover(), onHover),
|
|
run$1(focusItem(), Focusing.focus)
|
|
], false))
|
|
]),
|
|
components: detail.components,
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var schema$p = [
|
|
required$1('data'),
|
|
required$1('components'),
|
|
required$1('dom'),
|
|
defaulted('hasSubmenu', false),
|
|
option('toggling'),
|
|
SketchBehaviours.field('itemBehaviours', [
|
|
Toggling,
|
|
Focusing,
|
|
Keying,
|
|
Representing
|
|
]),
|
|
defaulted('ignoreFocus', false),
|
|
defaulted('domModification', {}),
|
|
output$1('builder', builder$2),
|
|
defaulted('eventOrder', {})
|
|
];
|
|
|
|
var builder$1 = function (detail) {
|
|
return {
|
|
dom: detail.dom,
|
|
components: detail.components,
|
|
events: derive$2([stopper(focusItem())])
|
|
};
|
|
};
|
|
var schema$o = [
|
|
required$1('dom'),
|
|
required$1('components'),
|
|
output$1('builder', builder$1)
|
|
];
|
|
|
|
var owner$2 = constant$1('item-widget');
|
|
var parts$h = constant$1([required({
|
|
name: 'widget',
|
|
overrides: function (detail) {
|
|
return {
|
|
behaviours: derive$1([Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (_component) {
|
|
return detail.data;
|
|
},
|
|
setValue: noop
|
|
}
|
|
})])
|
|
};
|
|
}
|
|
})]);
|
|
|
|
var builder = function (detail) {
|
|
var subs = substitutes(owner$2(), detail, parts$h());
|
|
var components = components$1(owner$2(), detail, subs.internals());
|
|
var focusWidget = function (component) {
|
|
return getPart(component, detail, 'widget').map(function (widget) {
|
|
Keying.focusIn(widget);
|
|
return widget;
|
|
});
|
|
};
|
|
var onHorizontalArrow = function (component, simulatedEvent) {
|
|
return inside(simulatedEvent.event.target) ? Optional.none() : function () {
|
|
if (detail.autofocus) {
|
|
simulatedEvent.setSource(component.element);
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}();
|
|
};
|
|
return {
|
|
dom: detail.dom,
|
|
components: components,
|
|
domModification: detail.domModification,
|
|
events: derive$2([
|
|
runOnExecute$1(function (component, simulatedEvent) {
|
|
focusWidget(component).each(function (_widget) {
|
|
simulatedEvent.stop();
|
|
});
|
|
}),
|
|
run$1(mouseover(), onHover),
|
|
run$1(focusItem(), function (component, _simulatedEvent) {
|
|
if (detail.autofocus) {
|
|
focusWidget(component);
|
|
} else {
|
|
Focusing.focus(component);
|
|
}
|
|
})
|
|
]),
|
|
behaviours: SketchBehaviours.augment(detail.widgetBehaviours, [
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.data
|
|
}
|
|
}),
|
|
Focusing.config({
|
|
ignore: detail.ignoreFocus,
|
|
onFocus: function (component) {
|
|
onFocus$1(component);
|
|
}
|
|
}),
|
|
Keying.config({
|
|
mode: 'special',
|
|
focusIn: detail.autofocus ? function (component) {
|
|
focusWidget(component);
|
|
} : revoke(),
|
|
onLeft: onHorizontalArrow,
|
|
onRight: onHorizontalArrow,
|
|
onEscape: function (component, simulatedEvent) {
|
|
if (!Focusing.isFocused(component) && !detail.autofocus) {
|
|
Focusing.focus(component);
|
|
return Optional.some(true);
|
|
} else if (detail.autofocus) {
|
|
simulatedEvent.setSource(component.element);
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
})
|
|
])
|
|
};
|
|
};
|
|
var schema$n = [
|
|
required$1('uid'),
|
|
required$1('data'),
|
|
required$1('components'),
|
|
required$1('dom'),
|
|
defaulted('autofocus', false),
|
|
defaulted('ignoreFocus', false),
|
|
SketchBehaviours.field('widgetBehaviours', [
|
|
Representing,
|
|
Focusing,
|
|
Keying
|
|
]),
|
|
defaulted('domModification', {}),
|
|
defaultUidsSchema(parts$h()),
|
|
output$1('builder', builder)
|
|
];
|
|
|
|
var itemSchema$2 = choose$1('type', {
|
|
widget: schema$n,
|
|
item: schema$p,
|
|
separator: schema$o
|
|
});
|
|
var configureGrid = function (detail, movementInfo) {
|
|
return {
|
|
mode: 'flatgrid',
|
|
selector: '.' + detail.markers.item,
|
|
initSize: {
|
|
numColumns: movementInfo.initSize.numColumns,
|
|
numRows: movementInfo.initSize.numRows
|
|
},
|
|
focusManager: detail.focusManager
|
|
};
|
|
};
|
|
var configureMatrix = function (detail, movementInfo) {
|
|
return {
|
|
mode: 'matrix',
|
|
selectors: {
|
|
row: movementInfo.rowSelector,
|
|
cell: '.' + detail.markers.item
|
|
},
|
|
focusManager: detail.focusManager
|
|
};
|
|
};
|
|
var configureMenu = function (detail, movementInfo) {
|
|
return {
|
|
mode: 'menu',
|
|
selector: '.' + detail.markers.item,
|
|
moveOnTab: movementInfo.moveOnTab,
|
|
focusManager: detail.focusManager
|
|
};
|
|
};
|
|
var parts$g = constant$1([group({
|
|
factory: {
|
|
sketch: function (spec) {
|
|
var itemInfo = asRawOrDie$1('menu.spec item', itemSchema$2, spec);
|
|
return itemInfo.builder(itemInfo);
|
|
}
|
|
},
|
|
name: 'items',
|
|
unit: 'item',
|
|
defaults: function (detail, u) {
|
|
return has$2(u, 'uid') ? u : __assign(__assign({}, u), { uid: generate$5('item') });
|
|
},
|
|
overrides: function (detail, u) {
|
|
return {
|
|
type: u.type,
|
|
ignoreFocus: detail.fakeFocus,
|
|
domModification: { classes: [detail.markers.item] }
|
|
};
|
|
}
|
|
})]);
|
|
var schema$m = constant$1([
|
|
required$1('value'),
|
|
required$1('items'),
|
|
required$1('dom'),
|
|
required$1('components'),
|
|
defaulted('eventOrder', {}),
|
|
field('menuBehaviours', [
|
|
Highlighting,
|
|
Representing,
|
|
Composing,
|
|
Keying
|
|
]),
|
|
defaultedOf('movement', {
|
|
mode: 'menu',
|
|
moveOnTab: true
|
|
}, choose$1('mode', {
|
|
grid: [
|
|
initSize(),
|
|
output$1('config', configureGrid)
|
|
],
|
|
matrix: [
|
|
output$1('config', configureMatrix),
|
|
required$1('rowSelector')
|
|
],
|
|
menu: [
|
|
defaulted('moveOnTab', true),
|
|
output$1('config', configureMenu)
|
|
]
|
|
})),
|
|
itemMarkers(),
|
|
defaulted('fakeFocus', false),
|
|
defaulted('focusManager', dom$2()),
|
|
onHandler('onHighlight')
|
|
]);
|
|
|
|
var focus = constant$1('alloy.menu-focus');
|
|
|
|
var make$7 = function (detail, components, _spec, _externals) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
markers: detail.markers,
|
|
behaviours: augment(detail.menuBehaviours, [
|
|
Highlighting.config({
|
|
highlightClass: detail.markers.selectedItem,
|
|
itemClass: detail.markers.item,
|
|
onHighlight: detail.onHighlight
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.value
|
|
}
|
|
}),
|
|
Composing.config({ find: Optional.some }),
|
|
Keying.config(detail.movement.config(detail, detail.movement))
|
|
]),
|
|
events: derive$2([
|
|
run$1(focus$1(), function (menu, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
menu.getSystem().getByDom(event.target).each(function (item) {
|
|
Highlighting.highlight(menu, item);
|
|
simulatedEvent.stop();
|
|
emitWith(menu, focus(), {
|
|
menu: menu,
|
|
item: item
|
|
});
|
|
});
|
|
}),
|
|
run$1(hover(), function (menu, simulatedEvent) {
|
|
var item = simulatedEvent.event.item;
|
|
Highlighting.highlight(menu, item);
|
|
})
|
|
]),
|
|
components: components,
|
|
eventOrder: detail.eventOrder,
|
|
domModification: { attributes: { role: 'menu' } }
|
|
};
|
|
};
|
|
|
|
var Menu = composite({
|
|
name: 'Menu',
|
|
configFields: schema$m(),
|
|
partFields: parts$g(),
|
|
factory: make$7
|
|
});
|
|
|
|
var transpose$1 = function (obj) {
|
|
return tupleMap(obj, function (v, k) {
|
|
return {
|
|
k: v,
|
|
v: k
|
|
};
|
|
});
|
|
};
|
|
var trace = function (items, byItem, byMenu, finish) {
|
|
return get$e(byMenu, finish).bind(function (triggerItem) {
|
|
return get$e(items, triggerItem).bind(function (triggerMenu) {
|
|
var rest = trace(items, byItem, byMenu, triggerMenu);
|
|
return Optional.some([triggerMenu].concat(rest));
|
|
});
|
|
}).getOr([]);
|
|
};
|
|
var generate$2 = function (menus, expansions) {
|
|
var items = {};
|
|
each(menus, function (menuItems, menu) {
|
|
each$1(menuItems, function (item) {
|
|
items[item] = menu;
|
|
});
|
|
});
|
|
var byItem = expansions;
|
|
var byMenu = transpose$1(expansions);
|
|
var menuPaths = map$1(byMenu, function (_triggerItem, submenu) {
|
|
return [submenu].concat(trace(items, byItem, byMenu, submenu));
|
|
});
|
|
return map$1(items, function (menu) {
|
|
return get$e(menuPaths, menu).getOr([menu]);
|
|
});
|
|
};
|
|
|
|
var init$c = function () {
|
|
var expansions = Cell({});
|
|
var menus = Cell({});
|
|
var paths = Cell({});
|
|
var primary = value$1();
|
|
var directory = Cell({});
|
|
var clear = function () {
|
|
expansions.set({});
|
|
menus.set({});
|
|
paths.set({});
|
|
primary.clear();
|
|
};
|
|
var isClear = function () {
|
|
return primary.get().isNone();
|
|
};
|
|
var setMenuBuilt = function (menuName, built) {
|
|
var _a;
|
|
menus.set(__assign(__assign({}, menus.get()), (_a = {}, _a[menuName] = {
|
|
type: 'prepared',
|
|
menu: built
|
|
}, _a)));
|
|
};
|
|
var setContents = function (sPrimary, sMenus, sExpansions, dir) {
|
|
primary.set(sPrimary);
|
|
expansions.set(sExpansions);
|
|
menus.set(sMenus);
|
|
directory.set(dir);
|
|
var sPaths = generate$2(dir, sExpansions);
|
|
paths.set(sPaths);
|
|
};
|
|
var getTriggeringItem = function (menuValue) {
|
|
return find$4(expansions.get(), function (v, _k) {
|
|
return v === menuValue;
|
|
});
|
|
};
|
|
var getTriggerData = function (menuValue, getItemByValue, path) {
|
|
return getPreparedMenu(menuValue).bind(function (menu) {
|
|
return getTriggeringItem(menuValue).bind(function (triggeringItemValue) {
|
|
return getItemByValue(triggeringItemValue).map(function (triggeredItem) {
|
|
return {
|
|
triggeredMenu: menu,
|
|
triggeringItem: triggeredItem,
|
|
triggeringPath: path
|
|
};
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var getTriggeringPath = function (itemValue, getItemByValue) {
|
|
var extraPath = filter$2(lookupItem(itemValue).toArray(), function (menuValue) {
|
|
return getPreparedMenu(menuValue).isSome();
|
|
});
|
|
return get$e(paths.get(), itemValue).bind(function (path) {
|
|
var revPath = reverse(extraPath.concat(path));
|
|
var triggers = bind$3(revPath, function (menuValue, menuIndex) {
|
|
return getTriggerData(menuValue, getItemByValue, revPath.slice(0, menuIndex + 1)).fold(function () {
|
|
return is$1(primary.get(), menuValue) ? [] : [Optional.none()];
|
|
}, function (data) {
|
|
return [Optional.some(data)];
|
|
});
|
|
});
|
|
return sequence(triggers);
|
|
});
|
|
};
|
|
var expand = function (itemValue) {
|
|
return get$e(expansions.get(), itemValue).map(function (menu) {
|
|
var current = get$e(paths.get(), itemValue).getOr([]);
|
|
return [menu].concat(current);
|
|
});
|
|
};
|
|
var collapse = function (itemValue) {
|
|
return get$e(paths.get(), itemValue).bind(function (path) {
|
|
return path.length > 1 ? Optional.some(path.slice(1)) : Optional.none();
|
|
});
|
|
};
|
|
var refresh = function (itemValue) {
|
|
return get$e(paths.get(), itemValue);
|
|
};
|
|
var getPreparedMenu = function (menuValue) {
|
|
return lookupMenu(menuValue).bind(extractPreparedMenu);
|
|
};
|
|
var lookupMenu = function (menuValue) {
|
|
return get$e(menus.get(), menuValue);
|
|
};
|
|
var lookupItem = function (itemValue) {
|
|
return get$e(expansions.get(), itemValue);
|
|
};
|
|
var otherMenus = function (path) {
|
|
var menuValues = directory.get();
|
|
return difference(keys(menuValues), path);
|
|
};
|
|
var getPrimary = function () {
|
|
return primary.get().bind(getPreparedMenu);
|
|
};
|
|
var getMenus = function () {
|
|
return menus.get();
|
|
};
|
|
return {
|
|
setMenuBuilt: setMenuBuilt,
|
|
setContents: setContents,
|
|
expand: expand,
|
|
refresh: refresh,
|
|
collapse: collapse,
|
|
lookupMenu: lookupMenu,
|
|
lookupItem: lookupItem,
|
|
otherMenus: otherMenus,
|
|
getPrimary: getPrimary,
|
|
getMenus: getMenus,
|
|
clear: clear,
|
|
isClear: isClear,
|
|
getTriggeringPath: getTriggeringPath
|
|
};
|
|
};
|
|
var extractPreparedMenu = function (prep) {
|
|
return prep.type === 'prepared' ? Optional.some(prep.menu) : Optional.none();
|
|
};
|
|
var LayeredState = {
|
|
init: init$c,
|
|
extractPreparedMenu: extractPreparedMenu
|
|
};
|
|
|
|
var make$6 = function (detail, _rawUiSpec) {
|
|
var submenuParentItems = value$1();
|
|
var buildMenus = function (container, primaryName, menus) {
|
|
return map$1(menus, function (spec, name) {
|
|
var makeSketch = function () {
|
|
return Menu.sketch(__assign(__assign({}, spec), {
|
|
value: name,
|
|
markers: detail.markers,
|
|
fakeFocus: detail.fakeFocus,
|
|
onHighlight: detail.onHighlight,
|
|
focusManager: detail.fakeFocus ? highlights() : dom$2()
|
|
}));
|
|
};
|
|
return name === primaryName ? {
|
|
type: 'prepared',
|
|
menu: container.getSystem().build(makeSketch())
|
|
} : {
|
|
type: 'notbuilt',
|
|
nbMenu: makeSketch
|
|
};
|
|
});
|
|
};
|
|
var layeredState = LayeredState.init();
|
|
var setup = function (container) {
|
|
var componentMap = buildMenus(container, detail.data.primary, detail.data.menus);
|
|
var directory = toDirectory();
|
|
layeredState.setContents(detail.data.primary, componentMap, detail.data.expansions, directory);
|
|
return layeredState.getPrimary();
|
|
};
|
|
var getItemValue = function (item) {
|
|
return Representing.getValue(item).value;
|
|
};
|
|
var getItemByValue = function (_container, menus, itemValue) {
|
|
return findMap(menus, function (menu) {
|
|
if (!menu.getSystem().isConnected()) {
|
|
return Optional.none();
|
|
}
|
|
var candidates = Highlighting.getCandidates(menu);
|
|
return find$5(candidates, function (c) {
|
|
return getItemValue(c) === itemValue;
|
|
});
|
|
});
|
|
};
|
|
var toDirectory = function (_container) {
|
|
return map$1(detail.data.menus, function (data, _menuName) {
|
|
return bind$3(data.items, function (item) {
|
|
return item.type === 'separator' ? [] : [item.data.value];
|
|
});
|
|
});
|
|
};
|
|
var setActiveMenu = function (container, menu) {
|
|
Highlighting.highlight(container, menu);
|
|
Highlighting.getHighlighted(menu).orThunk(function () {
|
|
return Highlighting.getFirst(menu);
|
|
}).each(function (item) {
|
|
dispatch(container, item.element, focusItem());
|
|
});
|
|
};
|
|
var getMenus = function (state, menuValues) {
|
|
return cat(map$2(menuValues, function (mv) {
|
|
return state.lookupMenu(mv).bind(function (prep) {
|
|
return prep.type === 'prepared' ? Optional.some(prep.menu) : Optional.none();
|
|
});
|
|
}));
|
|
};
|
|
var closeOthers = function (container, state, path) {
|
|
var others = getMenus(state, state.otherMenus(path));
|
|
each$1(others, function (o) {
|
|
remove$1(o.element, [detail.markers.backgroundMenu]);
|
|
if (!detail.stayInDom) {
|
|
Replacing.remove(container, o);
|
|
}
|
|
});
|
|
};
|
|
var getSubmenuParents = function (container) {
|
|
return submenuParentItems.get().getOrThunk(function () {
|
|
var r = {};
|
|
var items = descendants(container.element, '.' + detail.markers.item);
|
|
var parentItems = filter$2(items, function (i) {
|
|
return get$d(i, 'aria-haspopup') === 'true';
|
|
});
|
|
each$1(parentItems, function (i) {
|
|
container.getSystem().getByDom(i).each(function (itemComp) {
|
|
var key = getItemValue(itemComp);
|
|
r[key] = itemComp;
|
|
});
|
|
});
|
|
submenuParentItems.set(r);
|
|
return r;
|
|
});
|
|
};
|
|
var updateAriaExpansions = function (container, path) {
|
|
var parentItems = getSubmenuParents(container);
|
|
each(parentItems, function (v, k) {
|
|
var expanded = contains$2(path, k);
|
|
set$8(v.element, 'aria-expanded', expanded);
|
|
});
|
|
};
|
|
var updateMenuPath = function (container, state, path) {
|
|
return Optional.from(path[0]).bind(function (latestMenuName) {
|
|
return state.lookupMenu(latestMenuName).bind(function (menuPrep) {
|
|
if (menuPrep.type === 'notbuilt') {
|
|
return Optional.none();
|
|
} else {
|
|
var activeMenu = menuPrep.menu;
|
|
var rest = getMenus(state, path.slice(1));
|
|
each$1(rest, function (r) {
|
|
add$2(r.element, detail.markers.backgroundMenu);
|
|
});
|
|
if (!inBody(activeMenu.element)) {
|
|
Replacing.append(container, premade(activeMenu));
|
|
}
|
|
remove$1(activeMenu.element, [detail.markers.backgroundMenu]);
|
|
setActiveMenu(container, activeMenu);
|
|
closeOthers(container, state, path);
|
|
return Optional.some(activeMenu);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var ExpandHighlightDecision;
|
|
(function (ExpandHighlightDecision) {
|
|
ExpandHighlightDecision[ExpandHighlightDecision['HighlightSubmenu'] = 0] = 'HighlightSubmenu';
|
|
ExpandHighlightDecision[ExpandHighlightDecision['HighlightParent'] = 1] = 'HighlightParent';
|
|
}(ExpandHighlightDecision || (ExpandHighlightDecision = {})));
|
|
var buildIfRequired = function (container, menuName, menuPrep) {
|
|
if (menuPrep.type === 'notbuilt') {
|
|
var menu = container.getSystem().build(menuPrep.nbMenu());
|
|
layeredState.setMenuBuilt(menuName, menu);
|
|
return menu;
|
|
} else {
|
|
return menuPrep.menu;
|
|
}
|
|
};
|
|
var expandRight = function (container, item, decision) {
|
|
if (decision === void 0) {
|
|
decision = ExpandHighlightDecision.HighlightSubmenu;
|
|
}
|
|
if (item.hasConfigured(Disabling) && Disabling.isDisabled(item)) {
|
|
return Optional.some(item);
|
|
} else {
|
|
var value = getItemValue(item);
|
|
return layeredState.expand(value).bind(function (path) {
|
|
updateAriaExpansions(container, path);
|
|
return Optional.from(path[0]).bind(function (menuName) {
|
|
return layeredState.lookupMenu(menuName).bind(function (activeMenuPrep) {
|
|
var activeMenu = buildIfRequired(container, menuName, activeMenuPrep);
|
|
if (!inBody(activeMenu.element)) {
|
|
Replacing.append(container, premade(activeMenu));
|
|
}
|
|
detail.onOpenSubmenu(container, item, activeMenu, reverse(path));
|
|
if (decision === ExpandHighlightDecision.HighlightSubmenu) {
|
|
Highlighting.highlightFirst(activeMenu);
|
|
return updateMenuPath(container, layeredState, path);
|
|
} else {
|
|
Highlighting.dehighlightAll(activeMenu);
|
|
return Optional.some(item);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var collapseLeft = function (container, item) {
|
|
var value = getItemValue(item);
|
|
return layeredState.collapse(value).bind(function (path) {
|
|
updateAriaExpansions(container, path);
|
|
return updateMenuPath(container, layeredState, path).map(function (activeMenu) {
|
|
detail.onCollapseMenu(container, item, activeMenu);
|
|
return activeMenu;
|
|
});
|
|
});
|
|
};
|
|
var updateView = function (container, item) {
|
|
var value = getItemValue(item);
|
|
return layeredState.refresh(value).bind(function (path) {
|
|
updateAriaExpansions(container, path);
|
|
return updateMenuPath(container, layeredState, path);
|
|
});
|
|
};
|
|
var onRight = function (container, item) {
|
|
return inside(item.element) ? Optional.none() : expandRight(container, item, ExpandHighlightDecision.HighlightSubmenu);
|
|
};
|
|
var onLeft = function (container, item) {
|
|
return inside(item.element) ? Optional.none() : collapseLeft(container, item);
|
|
};
|
|
var onEscape = function (container, item) {
|
|
return collapseLeft(container, item).orThunk(function () {
|
|
return detail.onEscape(container, item).map(function () {
|
|
return container;
|
|
});
|
|
});
|
|
};
|
|
var keyOnItem = function (f) {
|
|
return function (container, simulatedEvent) {
|
|
return closest$1(simulatedEvent.getSource(), '.' + detail.markers.item).bind(function (target) {
|
|
return container.getSystem().getByDom(target).toOptional().bind(function (item) {
|
|
return f(container, item).map(always);
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var events = derive$2([
|
|
run$1(focus(), function (sandbox, simulatedEvent) {
|
|
var item = simulatedEvent.event.item;
|
|
layeredState.lookupItem(getItemValue(item)).each(function () {
|
|
var menu = simulatedEvent.event.menu;
|
|
Highlighting.highlight(sandbox, menu);
|
|
var value = getItemValue(simulatedEvent.event.item);
|
|
layeredState.refresh(value).each(function (path) {
|
|
return closeOthers(sandbox, layeredState, path);
|
|
});
|
|
});
|
|
}),
|
|
runOnExecute$1(function (component, simulatedEvent) {
|
|
var target = simulatedEvent.event.target;
|
|
component.getSystem().getByDom(target).each(function (item) {
|
|
var itemValue = getItemValue(item);
|
|
if (itemValue.indexOf('collapse-item') === 0) {
|
|
collapseLeft(component, item);
|
|
}
|
|
expandRight(component, item, ExpandHighlightDecision.HighlightSubmenu).fold(function () {
|
|
detail.onExecute(component, item);
|
|
}, noop);
|
|
});
|
|
}),
|
|
runOnAttached(function (container, _simulatedEvent) {
|
|
setup(container).each(function (primary) {
|
|
Replacing.append(container, premade(primary));
|
|
detail.onOpenMenu(container, primary);
|
|
if (detail.highlightImmediately) {
|
|
setActiveMenu(container, primary);
|
|
}
|
|
});
|
|
})
|
|
].concat(detail.navigateOnHover ? [run$1(hover(), function (sandbox, simulatedEvent) {
|
|
var item = simulatedEvent.event.item;
|
|
updateView(sandbox, item);
|
|
expandRight(sandbox, item, ExpandHighlightDecision.HighlightParent);
|
|
detail.onHover(sandbox, item);
|
|
})] : []));
|
|
var getActiveItem = function (container) {
|
|
return Highlighting.getHighlighted(container).bind(Highlighting.getHighlighted);
|
|
};
|
|
var collapseMenuApi = function (container) {
|
|
getActiveItem(container).each(function (currentItem) {
|
|
collapseLeft(container, currentItem);
|
|
});
|
|
};
|
|
var highlightPrimary = function (container) {
|
|
layeredState.getPrimary().each(function (primary) {
|
|
setActiveMenu(container, primary);
|
|
});
|
|
};
|
|
var extractMenuFromContainer = function (container) {
|
|
return Optional.from(container.components()[0]).filter(function (comp) {
|
|
return get$d(comp.element, 'role') === 'menu';
|
|
});
|
|
};
|
|
var repositionMenus = function (container) {
|
|
var maybeActivePrimary = layeredState.getPrimary().bind(function (primary) {
|
|
return getActiveItem(container).bind(function (currentItem) {
|
|
var itemValue = getItemValue(currentItem);
|
|
var allMenus = values(layeredState.getMenus());
|
|
var preparedMenus = cat(map$2(allMenus, LayeredState.extractPreparedMenu));
|
|
return layeredState.getTriggeringPath(itemValue, function (v) {
|
|
return getItemByValue(container, preparedMenus, v);
|
|
});
|
|
}).map(function (triggeringPath) {
|
|
return {
|
|
primary: primary,
|
|
triggeringPath: triggeringPath
|
|
};
|
|
});
|
|
});
|
|
maybeActivePrimary.fold(function () {
|
|
extractMenuFromContainer(container).each(function (primaryMenu) {
|
|
detail.onRepositionMenu(container, primaryMenu, []);
|
|
});
|
|
}, function (_a) {
|
|
var primary = _a.primary, triggeringPath = _a.triggeringPath;
|
|
detail.onRepositionMenu(container, primary, triggeringPath);
|
|
});
|
|
};
|
|
var apis = {
|
|
collapseMenu: collapseMenuApi,
|
|
highlightPrimary: highlightPrimary,
|
|
repositionMenus: repositionMenus
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
markers: detail.markers,
|
|
behaviours: augment(detail.tmenuBehaviours, [
|
|
Keying.config({
|
|
mode: 'special',
|
|
onRight: keyOnItem(onRight),
|
|
onLeft: keyOnItem(onLeft),
|
|
onEscape: keyOnItem(onEscape),
|
|
focusIn: function (container, _keyInfo) {
|
|
layeredState.getPrimary().each(function (primary) {
|
|
dispatch(container, primary.element, focusItem());
|
|
});
|
|
}
|
|
}),
|
|
Highlighting.config({
|
|
highlightClass: detail.markers.selectedMenu,
|
|
itemClass: detail.markers.menu
|
|
}),
|
|
Composing.config({
|
|
find: function (container) {
|
|
return Highlighting.getHighlighted(container);
|
|
}
|
|
}),
|
|
Replacing.config({})
|
|
]),
|
|
eventOrder: detail.eventOrder,
|
|
apis: apis,
|
|
events: events
|
|
};
|
|
};
|
|
var collapseItem$1 = constant$1('collapse-item');
|
|
|
|
var tieredData = function (primary, menus, expansions) {
|
|
return {
|
|
primary: primary,
|
|
menus: menus,
|
|
expansions: expansions
|
|
};
|
|
};
|
|
var singleData = function (name, menu) {
|
|
return {
|
|
primary: name,
|
|
menus: wrap$1(name, menu),
|
|
expansions: {}
|
|
};
|
|
};
|
|
var collapseItem = function (text) {
|
|
return {
|
|
value: generate$6(collapseItem$1()),
|
|
meta: { text: text }
|
|
};
|
|
};
|
|
var tieredMenu = single({
|
|
name: 'TieredMenu',
|
|
configFields: [
|
|
onStrictKeyboardHandler('onExecute'),
|
|
onStrictKeyboardHandler('onEscape'),
|
|
onStrictHandler('onOpenMenu'),
|
|
onStrictHandler('onOpenSubmenu'),
|
|
onHandler('onRepositionMenu'),
|
|
onHandler('onCollapseMenu'),
|
|
defaulted('highlightImmediately', true),
|
|
requiredObjOf('data', [
|
|
required$1('primary'),
|
|
required$1('menus'),
|
|
required$1('expansions')
|
|
]),
|
|
defaulted('fakeFocus', false),
|
|
onHandler('onHighlight'),
|
|
onHandler('onHover'),
|
|
tieredMenuMarkers(),
|
|
required$1('dom'),
|
|
defaulted('navigateOnHover', true),
|
|
defaulted('stayInDom', false),
|
|
field('tmenuBehaviours', [
|
|
Keying,
|
|
Highlighting,
|
|
Composing,
|
|
Replacing
|
|
]),
|
|
defaulted('eventOrder', {})
|
|
],
|
|
apis: {
|
|
collapseMenu: function (apis, tmenu) {
|
|
apis.collapseMenu(tmenu);
|
|
},
|
|
highlightPrimary: function (apis, tmenu) {
|
|
apis.highlightPrimary(tmenu);
|
|
},
|
|
repositionMenus: function (apis, tmenu) {
|
|
apis.repositionMenus(tmenu);
|
|
}
|
|
},
|
|
factory: make$6,
|
|
extraApis: {
|
|
tieredData: tieredData,
|
|
singleData: singleData,
|
|
collapseItem: collapseItem
|
|
}
|
|
});
|
|
|
|
var makeMenu = function (detail, menuSandbox, placementSpec, menuSpec, getBounds) {
|
|
var lazySink = function () {
|
|
return detail.lazySink(menuSandbox);
|
|
};
|
|
var layouts = menuSpec.type === 'horizontal' ? {
|
|
layouts: {
|
|
onLtr: function () {
|
|
return belowOrAbove();
|
|
},
|
|
onRtl: function () {
|
|
return belowOrAboveRtl();
|
|
}
|
|
}
|
|
} : {};
|
|
var isFirstTierSubmenu = function (triggeringPaths) {
|
|
return triggeringPaths.length === 2;
|
|
};
|
|
var getSubmenuLayouts = function (triggeringPaths) {
|
|
return isFirstTierSubmenu(triggeringPaths) ? layouts : {};
|
|
};
|
|
return tieredMenu.sketch({
|
|
dom: { tag: 'div' },
|
|
data: menuSpec.data,
|
|
markers: menuSpec.menu.markers,
|
|
highlightImmediately: menuSpec.menu.highlightImmediately,
|
|
onEscape: function () {
|
|
Sandboxing.close(menuSandbox);
|
|
detail.onEscape.map(function (handler) {
|
|
return handler(menuSandbox);
|
|
});
|
|
return Optional.some(true);
|
|
},
|
|
onExecute: function () {
|
|
return Optional.some(true);
|
|
},
|
|
onOpenMenu: function (tmenu, menu) {
|
|
Positioning.positionWithinBounds(lazySink().getOrDie(), menu, placementSpec, getBounds());
|
|
},
|
|
onOpenSubmenu: function (tmenu, item, submenu, triggeringPaths) {
|
|
var sink = lazySink().getOrDie();
|
|
Positioning.position(sink, submenu, {
|
|
anchor: __assign({
|
|
type: 'submenu',
|
|
item: item
|
|
}, getSubmenuLayouts(triggeringPaths))
|
|
});
|
|
},
|
|
onRepositionMenu: function (tmenu, primaryMenu, submenuTriggers) {
|
|
var sink = lazySink().getOrDie();
|
|
Positioning.positionWithinBounds(sink, primaryMenu, placementSpec, getBounds());
|
|
each$1(submenuTriggers, function (st) {
|
|
var submenuLayouts = getSubmenuLayouts(st.triggeringPath);
|
|
Positioning.position(sink, st.triggeredMenu, {
|
|
anchor: __assign({
|
|
type: 'submenu',
|
|
item: st.triggeringItem
|
|
}, submenuLayouts)
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var factory$m = function (detail, spec) {
|
|
var isPartOfRelated = function (sandbox, queryElem) {
|
|
var related = detail.getRelated(sandbox);
|
|
return related.exists(function (rel) {
|
|
return isPartOf$1(rel, queryElem);
|
|
});
|
|
};
|
|
var setContent = function (sandbox, thing) {
|
|
Sandboxing.setContent(sandbox, thing);
|
|
};
|
|
var showAt = function (sandbox, thing, placementSpec) {
|
|
showWithin(sandbox, thing, placementSpec, Optional.none());
|
|
};
|
|
var showWithin = function (sandbox, thing, placementSpec, boxElement) {
|
|
showWithinBounds(sandbox, thing, placementSpec, function () {
|
|
return boxElement.map(function (elem) {
|
|
return box$1(elem);
|
|
});
|
|
});
|
|
};
|
|
var showWithinBounds = function (sandbox, thing, placementSpec, getBounds) {
|
|
var sink = detail.lazySink(sandbox).getOrDie();
|
|
Sandboxing.openWhileCloaked(sandbox, thing, function () {
|
|
return Positioning.positionWithinBounds(sink, sandbox, placementSpec, getBounds());
|
|
});
|
|
Representing.setValue(sandbox, Optional.some({
|
|
mode: 'position',
|
|
config: placementSpec,
|
|
getBounds: getBounds
|
|
}));
|
|
};
|
|
var showMenuAt = function (sandbox, placementSpec, menuSpec) {
|
|
showMenuWithinBounds(sandbox, placementSpec, menuSpec, Optional.none);
|
|
};
|
|
var showMenuWithinBounds = function (sandbox, placementSpec, menuSpec, getBounds) {
|
|
var menu = makeMenu(detail, sandbox, placementSpec, menuSpec, getBounds);
|
|
Sandboxing.open(sandbox, menu);
|
|
Representing.setValue(sandbox, Optional.some({
|
|
mode: 'menu',
|
|
menu: menu
|
|
}));
|
|
};
|
|
var hide = function (sandbox) {
|
|
if (Sandboxing.isOpen(sandbox)) {
|
|
Representing.setValue(sandbox, Optional.none());
|
|
Sandboxing.close(sandbox);
|
|
}
|
|
};
|
|
var getContent = function (sandbox) {
|
|
return Sandboxing.getState(sandbox);
|
|
};
|
|
var reposition = function (sandbox) {
|
|
if (Sandboxing.isOpen(sandbox)) {
|
|
Representing.getValue(sandbox).each(function (state) {
|
|
switch (state.mode) {
|
|
case 'menu':
|
|
Sandboxing.getState(sandbox).each(tieredMenu.repositionMenus);
|
|
break;
|
|
case 'position':
|
|
var sink = detail.lazySink(sandbox).getOrDie();
|
|
Positioning.positionWithinBounds(sink, sandbox, state.config, state.getBounds());
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
};
|
|
var apis = {
|
|
setContent: setContent,
|
|
showAt: showAt,
|
|
showWithin: showWithin,
|
|
showWithinBounds: showWithinBounds,
|
|
showMenuAt: showMenuAt,
|
|
showMenuWithinBounds: showMenuWithinBounds,
|
|
hide: hide,
|
|
getContent: getContent,
|
|
reposition: reposition,
|
|
isOpen: Sandboxing.isOpen
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
behaviours: augment(detail.inlineBehaviours, [
|
|
Sandboxing.config({
|
|
isPartOf: function (sandbox, data, queryElem) {
|
|
return isPartOf$1(data, queryElem) || isPartOfRelated(sandbox, queryElem);
|
|
},
|
|
getAttachPoint: function (sandbox) {
|
|
return detail.lazySink(sandbox).getOrDie();
|
|
},
|
|
onOpen: function (sandbox) {
|
|
detail.onShow(sandbox);
|
|
},
|
|
onClose: function (sandbox) {
|
|
detail.onHide(sandbox);
|
|
}
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: Optional.none()
|
|
}
|
|
}),
|
|
Receiving.config({
|
|
channels: __assign(__assign({}, receivingChannel$1(__assign({ isExtraPart: spec.isExtraPart }, detail.fireDismissalEventInstead.map(function (fe) {
|
|
return { fireEventInstead: { event: fe.event } };
|
|
}).getOr({})))), receivingChannel(__assign(__assign({}, detail.fireRepositionEventInstead.map(function (fe) {
|
|
return { fireEventInstead: { event: fe.event } };
|
|
}).getOr({})), { doReposition: reposition })))
|
|
})
|
|
]),
|
|
eventOrder: detail.eventOrder,
|
|
apis: apis
|
|
};
|
|
};
|
|
var InlineView = single({
|
|
name: 'InlineView',
|
|
configFields: [
|
|
required$1('lazySink'),
|
|
onHandler('onShow'),
|
|
onHandler('onHide'),
|
|
optionFunction('onEscape'),
|
|
field('inlineBehaviours', [
|
|
Sandboxing,
|
|
Representing,
|
|
Receiving
|
|
]),
|
|
optionObjOf('fireDismissalEventInstead', [defaulted('event', dismissRequested())]),
|
|
optionObjOf('fireRepositionEventInstead', [defaulted('event', repositionRequested())]),
|
|
defaulted('getRelated', Optional.none),
|
|
defaulted('isExtraPart', never),
|
|
defaulted('eventOrder', Optional.none)
|
|
],
|
|
factory: factory$m,
|
|
apis: {
|
|
showAt: function (apis, component, anchor, thing) {
|
|
apis.showAt(component, anchor, thing);
|
|
},
|
|
showWithin: function (apis, component, anchor, thing, boxElement) {
|
|
apis.showWithin(component, anchor, thing, boxElement);
|
|
},
|
|
showWithinBounds: function (apis, component, anchor, thing, bounds) {
|
|
apis.showWithinBounds(component, anchor, thing, bounds);
|
|
},
|
|
showMenuAt: function (apis, component, anchor, menuSpec) {
|
|
apis.showMenuAt(component, anchor, menuSpec);
|
|
},
|
|
showMenuWithinBounds: function (apis, component, anchor, menuSpec, bounds) {
|
|
apis.showMenuWithinBounds(component, anchor, menuSpec, bounds);
|
|
},
|
|
hide: function (apis, component) {
|
|
apis.hide(component);
|
|
},
|
|
isOpen: function (apis, component) {
|
|
return apis.isOpen(component);
|
|
},
|
|
getContent: function (apis, component) {
|
|
return apis.getContent(component);
|
|
},
|
|
setContent: function (apis, component, thing) {
|
|
apis.setContent(component, thing);
|
|
},
|
|
reposition: function (apis, component) {
|
|
apis.reposition(component);
|
|
}
|
|
}
|
|
});
|
|
|
|
var labelPrefix = 'layout-inset';
|
|
var westEdgeX = function (anchor) {
|
|
return anchor.x;
|
|
};
|
|
var middleX = function (anchor, element) {
|
|
return anchor.x + anchor.width / 2 - element.width / 2;
|
|
};
|
|
var eastEdgeX = function (anchor, element) {
|
|
return anchor.x + anchor.width - element.width;
|
|
};
|
|
var northY = function (anchor) {
|
|
return anchor.y;
|
|
};
|
|
var southY = function (anchor, element) {
|
|
return anchor.y + anchor.height - element.height;
|
|
};
|
|
var centreY = function (anchor, element) {
|
|
return anchor.y + anchor.height / 2 - element.height / 2;
|
|
};
|
|
var southwest = function (anchor, element, bubbles) {
|
|
return nu$6(eastEdgeX(anchor, element), southY(anchor, element), bubbles.insetSouthwest(), northwest$3(), 'southwest', boundsRestriction(anchor, {
|
|
right: 0,
|
|
bottom: 3
|
|
}), labelPrefix);
|
|
};
|
|
var southeast = function (anchor, element, bubbles) {
|
|
return nu$6(westEdgeX(anchor), southY(anchor, element), bubbles.insetSoutheast(), northeast$3(), 'southeast', boundsRestriction(anchor, {
|
|
left: 1,
|
|
bottom: 3
|
|
}), labelPrefix);
|
|
};
|
|
var northwest = function (anchor, element, bubbles) {
|
|
return nu$6(eastEdgeX(anchor, element), northY(anchor), bubbles.insetNorthwest(), southwest$3(), 'northwest', boundsRestriction(anchor, {
|
|
right: 0,
|
|
top: 2
|
|
}), labelPrefix);
|
|
};
|
|
var northeast = function (anchor, element, bubbles) {
|
|
return nu$6(westEdgeX(anchor), northY(anchor), bubbles.insetNortheast(), southeast$3(), 'northeast', boundsRestriction(anchor, {
|
|
left: 1,
|
|
top: 2
|
|
}), labelPrefix);
|
|
};
|
|
var north = function (anchor, element, bubbles) {
|
|
return nu$6(middleX(anchor, element), northY(anchor), bubbles.insetNorth(), south$3(), 'north', boundsRestriction(anchor, { top: 2 }), labelPrefix);
|
|
};
|
|
var south = function (anchor, element, bubbles) {
|
|
return nu$6(middleX(anchor, element), southY(anchor, element), bubbles.insetSouth(), north$3(), 'south', boundsRestriction(anchor, { bottom: 3 }), labelPrefix);
|
|
};
|
|
var east = function (anchor, element, bubbles) {
|
|
return nu$6(eastEdgeX(anchor, element), centreY(anchor, element), bubbles.insetEast(), west$3(), 'east', boundsRestriction(anchor, { right: 0 }), labelPrefix);
|
|
};
|
|
var west = function (anchor, element, bubbles) {
|
|
return nu$6(westEdgeX(anchor), centreY(anchor, element), bubbles.insetWest(), east$3(), 'west', boundsRestriction(anchor, { left: 1 }), labelPrefix);
|
|
};
|
|
var lookupPreserveLayout = function (lastPlacement) {
|
|
switch (lastPlacement) {
|
|
case 'north':
|
|
return north;
|
|
case 'northeast':
|
|
return northeast;
|
|
case 'northwest':
|
|
return northwest;
|
|
case 'south':
|
|
return south;
|
|
case 'southeast':
|
|
return southeast;
|
|
case 'southwest':
|
|
return southwest;
|
|
case 'east':
|
|
return east;
|
|
case 'west':
|
|
return west;
|
|
}
|
|
};
|
|
var preserve = function (anchor, element, bubbles, placee, bounds) {
|
|
var layout = getPlacement(placee).map(lookupPreserveLayout).getOr(north);
|
|
return layout(anchor, element, bubbles, placee, bounds);
|
|
};
|
|
var lookupFlippedLayout = function (lastPlacement) {
|
|
switch (lastPlacement) {
|
|
case 'north':
|
|
return south;
|
|
case 'northeast':
|
|
return southeast;
|
|
case 'northwest':
|
|
return southwest;
|
|
case 'south':
|
|
return north;
|
|
case 'southeast':
|
|
return northeast;
|
|
case 'southwest':
|
|
return northwest;
|
|
case 'east':
|
|
return west;
|
|
case 'west':
|
|
return east;
|
|
}
|
|
};
|
|
var flip$2 = function (anchor, element, bubbles, placee, bounds) {
|
|
var layout = getPlacement(placee).map(lookupFlippedLayout).getOr(north);
|
|
return layout(anchor, element, bubbles, placee, bounds);
|
|
};
|
|
|
|
var global$f = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var factory$l = function (detail) {
|
|
var events = events$a(detail.action);
|
|
var tag = detail.dom.tag;
|
|
var lookupAttr = function (attr) {
|
|
return get$e(detail.dom, 'attributes').bind(function (attrs) {
|
|
return get$e(attrs, attr);
|
|
});
|
|
};
|
|
var getModAttributes = function () {
|
|
if (tag === 'button') {
|
|
var type = lookupAttr('type').getOr('button');
|
|
var roleAttrs = lookupAttr('role').map(function (role) {
|
|
return { role: role };
|
|
}).getOr({});
|
|
return __assign({ type: type }, roleAttrs);
|
|
} else {
|
|
var role = lookupAttr('role').getOr('button');
|
|
return { role: role };
|
|
}
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: detail.components,
|
|
events: events,
|
|
behaviours: SketchBehaviours.augment(detail.buttonBehaviours, [
|
|
Focusing.config({}),
|
|
Keying.config({
|
|
mode: 'execution',
|
|
useSpace: true,
|
|
useEnter: true
|
|
})
|
|
]),
|
|
domModification: { attributes: getModAttributes() },
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var Button = single({
|
|
name: 'Button',
|
|
factory: factory$l,
|
|
configFields: [
|
|
defaulted('uid', undefined),
|
|
required$1('dom'),
|
|
defaulted('components', []),
|
|
SketchBehaviours.field('buttonBehaviours', [
|
|
Focusing,
|
|
Keying
|
|
]),
|
|
option('action'),
|
|
option('role'),
|
|
defaulted('eventOrder', {})
|
|
]
|
|
});
|
|
|
|
var record = function (spec) {
|
|
var uid = isSketchSpec(spec) && hasNonNullableKey(spec, 'uid') ? spec.uid : generate$5('memento');
|
|
var get = function (anyInSystem) {
|
|
return anyInSystem.getSystem().getByUid(uid).getOrDie();
|
|
};
|
|
var getOpt = function (anyInSystem) {
|
|
return anyInSystem.getSystem().getByUid(uid).toOptional();
|
|
};
|
|
var asSpec = function () {
|
|
return __assign(__assign({}, spec), { uid: uid });
|
|
};
|
|
return {
|
|
get: get,
|
|
getOpt: getOpt,
|
|
asSpec: asSpec
|
|
};
|
|
};
|
|
|
|
var global$e = tinymce.util.Tools.resolve('tinymce.util.I18n');
|
|
|
|
var rtlTransform = {
|
|
'indent': true,
|
|
'outdent': true,
|
|
'table-insert-column-after': true,
|
|
'table-insert-column-before': true,
|
|
'paste-column-after': true,
|
|
'paste-column-before': true,
|
|
'unordered-list': true,
|
|
'list-bull-circle': true,
|
|
'list-bull-default': true,
|
|
'list-bull-square': true
|
|
};
|
|
var defaultIconName = 'temporary-placeholder';
|
|
var defaultIcon = function (icons) {
|
|
return function () {
|
|
return get$e(icons, defaultIconName).getOr('!not found!');
|
|
};
|
|
};
|
|
var getIconName = function (name, icons) {
|
|
var lcName = name.toLowerCase();
|
|
if (global$e.isRtl()) {
|
|
var rtlName = ensureTrailing(lcName, '-rtl');
|
|
return has$2(icons, rtlName) ? rtlName : lcName;
|
|
} else {
|
|
return lcName;
|
|
}
|
|
};
|
|
var lookupIcon = function (name, icons) {
|
|
return get$e(icons, getIconName(name, icons));
|
|
};
|
|
var get$1 = function (name, iconProvider) {
|
|
var icons = iconProvider();
|
|
return lookupIcon(name, icons).getOrThunk(defaultIcon(icons));
|
|
};
|
|
var getOr = function (name, iconProvider, fallbackIcon) {
|
|
var icons = iconProvider();
|
|
return lookupIcon(name, icons).or(fallbackIcon).getOrThunk(defaultIcon(icons));
|
|
};
|
|
var needsRtlTransform = function (iconName) {
|
|
return global$e.isRtl() ? has$2(rtlTransform, iconName) : false;
|
|
};
|
|
var addFocusableBehaviour = function () {
|
|
return config('add-focusable', [runOnAttached(function (comp) {
|
|
child(comp.element, 'svg').each(function (svg) {
|
|
return set$8(svg, 'focusable', 'false');
|
|
});
|
|
})]);
|
|
};
|
|
var renderIcon$2 = function (spec, iconName, icons, fallbackIcon) {
|
|
var _a, _b;
|
|
var rtlIconClasses = needsRtlTransform(iconName) ? ['tox-icon--flip'] : [];
|
|
var iconHtml = get$e(icons, getIconName(iconName, icons)).or(fallbackIcon).getOrThunk(defaultIcon(icons));
|
|
return {
|
|
dom: {
|
|
tag: spec.tag,
|
|
attributes: (_a = spec.attributes) !== null && _a !== void 0 ? _a : {},
|
|
classes: spec.classes.concat(rtlIconClasses),
|
|
innerHtml: iconHtml
|
|
},
|
|
behaviours: derive$1(__spreadArray(__spreadArray([], (_b = spec.behaviours) !== null && _b !== void 0 ? _b : [], true), [addFocusableBehaviour()], false))
|
|
};
|
|
};
|
|
var render$3 = function (iconName, spec, iconProvider, fallbackIcon) {
|
|
if (fallbackIcon === void 0) {
|
|
fallbackIcon = Optional.none();
|
|
}
|
|
return renderIcon$2(spec, iconName, iconProvider(), fallbackIcon);
|
|
};
|
|
var renderFirst = function (iconNames, spec, iconProvider) {
|
|
var icons = iconProvider();
|
|
var iconName = find$5(iconNames, function (name) {
|
|
return has$2(icons, getIconName(name, icons));
|
|
});
|
|
return renderIcon$2(spec, iconName.getOr(defaultIconName), icons, Optional.none());
|
|
};
|
|
|
|
var notificationIconMap = {
|
|
success: 'checkmark',
|
|
error: 'warning',
|
|
err: 'error',
|
|
warning: 'warning',
|
|
warn: 'warning',
|
|
info: 'info'
|
|
};
|
|
var factory$k = function (detail) {
|
|
var memBannerText = record({
|
|
dom: {
|
|
tag: 'p',
|
|
innerHtml: detail.translationProvider(detail.text)
|
|
},
|
|
behaviours: derive$1([Replacing.config({})])
|
|
});
|
|
var renderPercentBar = function (percent) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-bar'],
|
|
attributes: { style: 'width: ' + percent + '%' }
|
|
}
|
|
};
|
|
};
|
|
var renderPercentText = function (percent) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-text'],
|
|
innerHtml: percent + '%'
|
|
}
|
|
};
|
|
};
|
|
var memBannerProgress = record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: detail.progress ? [
|
|
'tox-progress-bar',
|
|
'tox-progress-indicator'
|
|
] : ['tox-progress-bar']
|
|
},
|
|
components: [
|
|
{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-bar-container']
|
|
},
|
|
components: [renderPercentBar(0)]
|
|
},
|
|
renderPercentText(0)
|
|
],
|
|
behaviours: derive$1([Replacing.config({})])
|
|
});
|
|
var updateProgress = function (comp, percent) {
|
|
if (comp.getSystem().isConnected()) {
|
|
memBannerProgress.getOpt(comp).each(function (progress) {
|
|
Replacing.set(progress, [
|
|
{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-bar-container']
|
|
},
|
|
components: [renderPercentBar(percent)]
|
|
},
|
|
renderPercentText(percent)
|
|
]);
|
|
});
|
|
}
|
|
};
|
|
var updateText = function (comp, text$1) {
|
|
if (comp.getSystem().isConnected()) {
|
|
var banner = memBannerText.get(comp);
|
|
Replacing.set(banner, [text(text$1)]);
|
|
}
|
|
};
|
|
var apis = {
|
|
updateProgress: updateProgress,
|
|
updateText: updateText
|
|
};
|
|
var iconChoices = flatten([
|
|
detail.icon.toArray(),
|
|
detail.level.toArray(),
|
|
detail.level.bind(function (level) {
|
|
return Optional.from(notificationIconMap[level]);
|
|
}).toArray()
|
|
]);
|
|
var memButton = record(Button.sketch({
|
|
dom: {
|
|
tag: 'button',
|
|
classes: [
|
|
'tox-notification__dismiss',
|
|
'tox-button',
|
|
'tox-button--naked',
|
|
'tox-button--icon'
|
|
]
|
|
},
|
|
components: [render$3('close', {
|
|
tag: 'div',
|
|
classes: ['tox-icon'],
|
|
attributes: { 'aria-label': detail.translationProvider('Close') }
|
|
}, detail.iconProvider)],
|
|
action: function (comp) {
|
|
detail.onAction(comp);
|
|
}
|
|
}));
|
|
var notificationIconSpec = renderFirst(iconChoices, {
|
|
tag: 'div',
|
|
classes: ['tox-notification__icon']
|
|
}, detail.iconProvider);
|
|
var notificationBodySpec = {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-notification__body']
|
|
},
|
|
components: [memBannerText.asSpec()],
|
|
behaviours: derive$1([Replacing.config({})])
|
|
};
|
|
var components = [
|
|
notificationIconSpec,
|
|
notificationBodySpec
|
|
];
|
|
return {
|
|
uid: detail.uid,
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { role: 'alert' },
|
|
classes: detail.level.map(function (level) {
|
|
return [
|
|
'tox-notification',
|
|
'tox-notification--in',
|
|
'tox-notification--' + level
|
|
];
|
|
}).getOr([
|
|
'tox-notification',
|
|
'tox-notification--in'
|
|
])
|
|
},
|
|
behaviours: derive$1([
|
|
Focusing.config({}),
|
|
config('notification-events', [run$1(focusin(), function (comp) {
|
|
memButton.getOpt(comp).each(Focusing.focus);
|
|
})])
|
|
]),
|
|
components: components.concat(detail.progress ? [memBannerProgress.asSpec()] : []).concat(!detail.closeButton ? [] : [memButton.asSpec()]),
|
|
apis: apis
|
|
};
|
|
};
|
|
var Notification = single({
|
|
name: 'Notification',
|
|
factory: factory$k,
|
|
configFields: [
|
|
option('level'),
|
|
required$1('progress'),
|
|
required$1('icon'),
|
|
required$1('onAction'),
|
|
required$1('text'),
|
|
required$1('iconProvider'),
|
|
required$1('translationProvider'),
|
|
defaultedBoolean('closeButton', true)
|
|
],
|
|
apis: {
|
|
updateProgress: function (apis, comp, percent) {
|
|
apis.updateProgress(comp, percent);
|
|
},
|
|
updateText: function (apis, comp, text) {
|
|
apis.updateText(comp, text);
|
|
}
|
|
}
|
|
});
|
|
|
|
function NotificationManagerImpl (editor, extras, uiMothership) {
|
|
var sharedBackstage = extras.backstage.shared;
|
|
var getLayoutDirection = function (rel) {
|
|
switch (rel) {
|
|
case 'bc-bc':
|
|
return south;
|
|
case 'tc-tc':
|
|
return north;
|
|
case 'tc-bc':
|
|
return north$2;
|
|
case 'bc-tc':
|
|
default:
|
|
return south$2;
|
|
}
|
|
};
|
|
var reposition = function (notifications) {
|
|
if (notifications.length > 0) {
|
|
each$1(notifications, function (notification, index) {
|
|
if (index === 0) {
|
|
notification.moveRel(null, 'banner');
|
|
} else {
|
|
notification.moveRel(notifications[index - 1].getEl(), 'bc-tc');
|
|
}
|
|
});
|
|
}
|
|
};
|
|
var open = function (settings, closeCallback) {
|
|
var hideCloseButton = !settings.closeButton && settings.timeout && (settings.timeout > 0 || settings.timeout < 0);
|
|
var close = function () {
|
|
closeCallback();
|
|
InlineView.hide(notificationWrapper);
|
|
};
|
|
var notification = build$1(Notification.sketch({
|
|
text: settings.text,
|
|
level: contains$2([
|
|
'success',
|
|
'error',
|
|
'warning',
|
|
'warn',
|
|
'info'
|
|
], settings.type) ? settings.type : undefined,
|
|
progress: settings.progressBar === true,
|
|
icon: Optional.from(settings.icon),
|
|
closeButton: !hideCloseButton,
|
|
onAction: close,
|
|
iconProvider: sharedBackstage.providers.icons,
|
|
translationProvider: sharedBackstage.providers.translate
|
|
}));
|
|
var notificationWrapper = build$1(InlineView.sketch(__assign({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-notifications-container']
|
|
},
|
|
lazySink: sharedBackstage.getSink,
|
|
fireDismissalEventInstead: {}
|
|
}, sharedBackstage.header.isPositionedAtTop() ? {} : { fireRepositionEventInstead: {} })));
|
|
uiMothership.add(notificationWrapper);
|
|
if (settings.timeout > 0) {
|
|
global$f.setTimeout(function () {
|
|
close();
|
|
}, settings.timeout);
|
|
}
|
|
var getBounds = function () {
|
|
var contentArea = box$1(SugarElement.fromDom(editor.getContentAreaContainer()));
|
|
var win$1 = win();
|
|
var x = clamp$1(win$1.x, contentArea.x, contentArea.right);
|
|
var y = clamp$1(win$1.y, contentArea.y, contentArea.bottom);
|
|
var right = Math.max(contentArea.right, win$1.right);
|
|
var bottom = Math.max(contentArea.bottom, win$1.bottom);
|
|
return Optional.some(bounds(x, y, right - x, bottom - y));
|
|
};
|
|
return {
|
|
close: close,
|
|
moveTo: function (x, y) {
|
|
InlineView.showAt(notificationWrapper, premade(notification), {
|
|
anchor: {
|
|
type: 'makeshift',
|
|
x: x,
|
|
y: y
|
|
}
|
|
});
|
|
},
|
|
moveRel: function (element, rel) {
|
|
var notificationSpec = premade(notification);
|
|
var anchorOverrides = { maxHeightFunction: expandable$1() };
|
|
if (rel !== 'banner' && isNonNullable(element)) {
|
|
var layoutDirection_1 = getLayoutDirection(rel);
|
|
var nodeAnchor = {
|
|
type: 'node',
|
|
root: body(),
|
|
node: Optional.some(SugarElement.fromDom(element)),
|
|
overrides: anchorOverrides,
|
|
layouts: {
|
|
onRtl: function () {
|
|
return [layoutDirection_1];
|
|
},
|
|
onLtr: function () {
|
|
return [layoutDirection_1];
|
|
}
|
|
}
|
|
};
|
|
InlineView.showWithinBounds(notificationWrapper, notificationSpec, { anchor: nodeAnchor }, getBounds);
|
|
} else {
|
|
var anchor = __assign(__assign({}, sharedBackstage.anchors.banner()), { overrides: anchorOverrides });
|
|
InlineView.showWithinBounds(notificationWrapper, notificationSpec, { anchor: anchor }, getBounds);
|
|
}
|
|
},
|
|
text: function (nuText) {
|
|
Notification.updateText(notification, nuText);
|
|
},
|
|
settings: settings,
|
|
getEl: function () {
|
|
return notification.element.dom;
|
|
},
|
|
progressBar: {
|
|
value: function (percent) {
|
|
Notification.updateProgress(notification, percent);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var close = function (notification) {
|
|
notification.close();
|
|
};
|
|
var getArgs = function (notification) {
|
|
return notification.settings;
|
|
};
|
|
return {
|
|
open: open,
|
|
close: close,
|
|
reposition: reposition,
|
|
getArgs: getArgs
|
|
};
|
|
}
|
|
|
|
var first = function (fn, rate) {
|
|
var timer = null;
|
|
var cancel = function () {
|
|
if (!isNull(timer)) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
};
|
|
var throttle = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (isNull(timer)) {
|
|
timer = setTimeout(function () {
|
|
timer = null;
|
|
fn.apply(null, args);
|
|
}, rate);
|
|
}
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
throttle: throttle
|
|
};
|
|
};
|
|
var last = function (fn, rate) {
|
|
var timer = null;
|
|
var cancel = function () {
|
|
if (!isNull(timer)) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
};
|
|
var throttle = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
cancel();
|
|
timer = setTimeout(function () {
|
|
timer = null;
|
|
fn.apply(null, args);
|
|
}, rate);
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
throttle: throttle
|
|
};
|
|
};
|
|
|
|
var global$d = tinymce.util.Tools.resolve('tinymce.dom.TextSeeker');
|
|
|
|
var isBoundary = function (dom, node) {
|
|
return dom.isBlock(node) || contains$2([
|
|
'BR',
|
|
'IMG',
|
|
'HR',
|
|
'INPUT'
|
|
], node.nodeName) || dom.getContentEditable(node) === 'false';
|
|
};
|
|
var repeatLeft = function (dom, node, offset, process, rootNode) {
|
|
var search = global$d(dom, function (node) {
|
|
return isBoundary(dom, node);
|
|
});
|
|
return Optional.from(search.backwards(node, offset, process, rootNode));
|
|
};
|
|
|
|
var autocompleteSelector = '[data-mce-autocompleter]';
|
|
var create$4 = function (editor, range) {
|
|
return detect(SugarElement.fromDom(editor.selection.getNode())).getOrThunk(function () {
|
|
var wrapper = SugarElement.fromHtml('<span data-mce-autocompleter="1" data-mce-bogus="1"></span>', editor.getDoc());
|
|
append$2(wrapper, SugarElement.fromDom(range.extractContents()));
|
|
range.insertNode(wrapper.dom);
|
|
parent(wrapper).each(function (elm) {
|
|
return elm.dom.normalize();
|
|
});
|
|
last$1(wrapper).map(function (last) {
|
|
editor.selection.setCursorLocation(last.dom, getEnd(last));
|
|
});
|
|
return wrapper;
|
|
});
|
|
};
|
|
var detect = function (elm) {
|
|
return closest$1(elm, autocompleteSelector);
|
|
};
|
|
|
|
var isValidTextRange = function (rng) {
|
|
return rng.collapsed && rng.startContainer.nodeType === 3;
|
|
};
|
|
var getText = function (rng) {
|
|
return rng.toString().replace(/\u00A0/g, ' ').replace(/\uFEFF/g, '');
|
|
};
|
|
var isWhitespace = function (chr) {
|
|
return chr !== '' && ' \xA0\f\n\r\t\x0B'.indexOf(chr) !== -1;
|
|
};
|
|
|
|
var stripTriggerChar = function (text, triggerCh) {
|
|
return text.substring(triggerCh.length);
|
|
};
|
|
var findChar = function (text, index, ch) {
|
|
var i;
|
|
for (i = index - 1; i >= 0; i--) {
|
|
var char = text.charAt(i);
|
|
if (isWhitespace(char)) {
|
|
return Optional.none();
|
|
}
|
|
if (char === ch) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.some(i);
|
|
};
|
|
var findStart = function (dom, initRange, ch, minChars) {
|
|
if (minChars === void 0) {
|
|
minChars = 0;
|
|
}
|
|
if (!isValidTextRange(initRange)) {
|
|
return Optional.none();
|
|
}
|
|
var findTriggerChIndex = function (element, offset, text) {
|
|
return findChar(text, offset, ch).getOr(offset);
|
|
};
|
|
var root = dom.getParent(initRange.startContainer, dom.isBlock) || dom.getRoot();
|
|
return repeatLeft(dom, initRange.startContainer, initRange.startOffset, findTriggerChIndex, root).bind(function (spot) {
|
|
var range = initRange.cloneRange();
|
|
range.setStart(spot.container, spot.offset);
|
|
range.setEnd(initRange.endContainer, initRange.endOffset);
|
|
if (range.collapsed) {
|
|
return Optional.none();
|
|
}
|
|
var text = getText(range);
|
|
var triggerCharIndex = text.lastIndexOf(ch);
|
|
if (triggerCharIndex !== 0 || stripTriggerChar(text, ch).length < minChars) {
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.some({
|
|
text: stripTriggerChar(text, ch),
|
|
range: range,
|
|
triggerChar: ch
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var getContext = function (dom, initRange, ch, minChars) {
|
|
if (minChars === void 0) {
|
|
minChars = 0;
|
|
}
|
|
return detect(SugarElement.fromDom(initRange.startContainer)).fold(function () {
|
|
return findStart(dom, initRange, ch, minChars);
|
|
}, function (elm) {
|
|
var range = dom.createRng();
|
|
range.selectNode(elm.dom);
|
|
var text = getText(range);
|
|
return Optional.some({
|
|
range: range,
|
|
text: stripTriggerChar(text, ch),
|
|
triggerChar: ch
|
|
});
|
|
});
|
|
};
|
|
|
|
var setup$e = function (api, editor) {
|
|
editor.on('keypress compositionend', api.onKeypress.throttle);
|
|
editor.on('remove', api.onKeypress.cancel);
|
|
var redirectKeyToItem = function (item, e) {
|
|
emitWith(item, keydown(), { raw: e });
|
|
};
|
|
editor.on('keydown', function (e) {
|
|
var getItem = function () {
|
|
return api.getView().bind(Highlighting.getHighlighted);
|
|
};
|
|
if (e.which === 8) {
|
|
api.onKeypress.throttle(e);
|
|
}
|
|
if (api.isActive()) {
|
|
if (e.which === 27) {
|
|
api.cancelIfNecessary();
|
|
}
|
|
if (api.isMenuOpen()) {
|
|
if (e.which === 13) {
|
|
getItem().each(emitExecute);
|
|
e.preventDefault();
|
|
} else if (e.which === 40) {
|
|
getItem().fold(function () {
|
|
api.getView().each(Highlighting.highlightFirst);
|
|
}, function (item) {
|
|
redirectKeyToItem(item, e);
|
|
});
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
} else if (e.which === 37 || e.which === 38 || e.which === 39) {
|
|
getItem().each(function (item) {
|
|
redirectKeyToItem(item, e);
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
});
|
|
}
|
|
} else {
|
|
if (e.which === 13 || e.which === 38 || e.which === 40) {
|
|
api.cancelIfNecessary();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
editor.on('NodeChange', function (e) {
|
|
if (api.isActive() && !api.isProcessingAction() && detect(SugarElement.fromDom(e.element)).isNone()) {
|
|
api.cancelIfNecessary();
|
|
}
|
|
});
|
|
};
|
|
var AutocompleterEditorEvents = { setup: setup$e };
|
|
|
|
var global$c = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var point = function (container, offset) {
|
|
return {
|
|
container: container,
|
|
offset: offset
|
|
};
|
|
};
|
|
|
|
var isText = function (node) {
|
|
return node.nodeType === TEXT;
|
|
};
|
|
var isElement$1 = function (node) {
|
|
return node.nodeType === ELEMENT;
|
|
};
|
|
var toLast = function (node) {
|
|
if (isText(node)) {
|
|
return point(node, node.data.length);
|
|
} else {
|
|
var children = node.childNodes;
|
|
return children.length > 0 ? toLast(children[children.length - 1]) : point(node, children.length);
|
|
}
|
|
};
|
|
var toLeaf = function (node, offset) {
|
|
var children = node.childNodes;
|
|
if (children.length > 0 && offset < children.length) {
|
|
return toLeaf(children[offset], 0);
|
|
} else if (children.length > 0 && isElement$1(node) && children.length === offset) {
|
|
return toLast(children[children.length - 1]);
|
|
} else {
|
|
return point(node, offset);
|
|
}
|
|
};
|
|
|
|
var isPreviousCharContent = function (dom, leaf) {
|
|
return repeatLeft(dom, leaf.container, leaf.offset, function (element, offset) {
|
|
return offset === 0 ? -1 : offset;
|
|
}, dom.getRoot()).filter(function (spot) {
|
|
var char = spot.container.data.charAt(spot.offset - 1);
|
|
return !isWhitespace(char);
|
|
}).isSome();
|
|
};
|
|
var isStartOfWord = function (dom) {
|
|
return function (rng) {
|
|
var leaf = toLeaf(rng.startContainer, rng.startOffset);
|
|
return !isPreviousCharContent(dom, leaf);
|
|
};
|
|
};
|
|
var getTriggerContext = function (dom, initRange, database) {
|
|
return findMap(database.triggerChars, function (ch) {
|
|
return getContext(dom, initRange, ch);
|
|
});
|
|
};
|
|
var lookup$2 = function (editor, getDatabase) {
|
|
var database = getDatabase();
|
|
var rng = editor.selection.getRng();
|
|
return getTriggerContext(editor.dom, rng, database).bind(function (context) {
|
|
return lookupWithContext(editor, getDatabase, context);
|
|
});
|
|
};
|
|
var lookupWithContext = function (editor, getDatabase, context, fetchOptions) {
|
|
if (fetchOptions === void 0) {
|
|
fetchOptions = {};
|
|
}
|
|
var database = getDatabase();
|
|
var rng = editor.selection.getRng();
|
|
var startText = rng.startContainer.nodeValue;
|
|
var autocompleters = filter$2(database.lookupByChar(context.triggerChar), function (autocompleter) {
|
|
return context.text.length >= autocompleter.minChars && autocompleter.matches.getOrThunk(function () {
|
|
return isStartOfWord(editor.dom);
|
|
})(context.range, startText, context.text);
|
|
});
|
|
if (autocompleters.length === 0) {
|
|
return Optional.none();
|
|
}
|
|
var lookupData = global$c.all(map$2(autocompleters, function (ac) {
|
|
var fetchResult = ac.fetch(context.text, ac.maxResults, fetchOptions);
|
|
return fetchResult.then(function (results) {
|
|
return {
|
|
matchText: context.text,
|
|
items: results,
|
|
columns: ac.columns,
|
|
onAction: ac.onAction,
|
|
highlightOn: ac.highlightOn
|
|
};
|
|
});
|
|
}));
|
|
return Optional.some({
|
|
lookupData: lookupData,
|
|
context: context
|
|
});
|
|
};
|
|
|
|
var separatorMenuItemSchema = objOf([
|
|
requiredString('type'),
|
|
optionString('text')
|
|
]);
|
|
var createSeparatorMenuItem = function (spec) {
|
|
return asRaw('separatormenuitem', separatorMenuItemSchema, spec);
|
|
};
|
|
|
|
var autocompleterItemSchema = objOf([
|
|
defaulted('type', 'autocompleteitem'),
|
|
defaulted('active', false),
|
|
defaulted('disabled', false),
|
|
defaulted('meta', {}),
|
|
requiredString('value'),
|
|
optionString('text'),
|
|
optionString('icon')
|
|
]);
|
|
var autocompleterSchema = objOf([
|
|
requiredString('type'),
|
|
requiredString('ch'),
|
|
defaultedNumber('minChars', 1),
|
|
defaulted('columns', 1),
|
|
defaultedNumber('maxResults', 10),
|
|
optionFunction('matches'),
|
|
requiredFunction('fetch'),
|
|
requiredFunction('onAction'),
|
|
defaultedArrayOf('highlightOn', [], string)
|
|
]);
|
|
var createSeparatorItem = function (spec) {
|
|
return asRaw('Autocompleter.Separator', separatorMenuItemSchema, spec);
|
|
};
|
|
var createAutocompleterItem = function (spec) {
|
|
return asRaw('Autocompleter.Item', autocompleterItemSchema, spec);
|
|
};
|
|
var createAutocompleter = function (spec) {
|
|
return asRaw('Autocompleter', autocompleterSchema, spec);
|
|
};
|
|
|
|
var baseToolbarButtonFields = [
|
|
defaultedBoolean('disabled', false),
|
|
optionString('tooltip'),
|
|
optionString('icon'),
|
|
optionString('text'),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
})
|
|
];
|
|
var toolbarButtonSchema = objOf([
|
|
requiredString('type'),
|
|
requiredFunction('onAction')
|
|
].concat(baseToolbarButtonFields));
|
|
var createToolbarButton = function (spec) {
|
|
return asRaw('toolbarbutton', toolbarButtonSchema, spec);
|
|
};
|
|
|
|
var baseToolbarToggleButtonFields = [defaultedBoolean('active', false)].concat(baseToolbarButtonFields);
|
|
var toggleButtonSchema = objOf(baseToolbarToggleButtonFields.concat([
|
|
requiredString('type'),
|
|
requiredFunction('onAction')
|
|
]));
|
|
var createToggleButton = function (spec) {
|
|
return asRaw('ToggleButton', toggleButtonSchema, spec);
|
|
};
|
|
|
|
var contextBarFields = [
|
|
defaultedFunction('predicate', never),
|
|
defaultedStringEnum('scope', 'node', [
|
|
'node',
|
|
'editor'
|
|
]),
|
|
defaultedStringEnum('position', 'selection', [
|
|
'node',
|
|
'selection',
|
|
'line'
|
|
])
|
|
];
|
|
|
|
var contextButtonFields = baseToolbarButtonFields.concat([
|
|
defaulted('type', 'contextformbutton'),
|
|
defaulted('primary', false),
|
|
requiredFunction('onAction'),
|
|
customField('original', identity$1)
|
|
]);
|
|
var contextToggleButtonFields = baseToolbarToggleButtonFields.concat([
|
|
defaulted('type', 'contextformbutton'),
|
|
defaulted('primary', false),
|
|
requiredFunction('onAction'),
|
|
customField('original', identity$1)
|
|
]);
|
|
var launchButtonFields = baseToolbarButtonFields.concat([defaulted('type', 'contextformbutton')]);
|
|
var launchToggleButtonFields = baseToolbarToggleButtonFields.concat([defaulted('type', 'contextformtogglebutton')]);
|
|
var toggleOrNormal = choose$1('type', {
|
|
contextformbutton: contextButtonFields,
|
|
contextformtogglebutton: contextToggleButtonFields
|
|
});
|
|
var contextFormSchema = objOf([
|
|
defaulted('type', 'contextform'),
|
|
defaultedFunction('initValue', constant$1('')),
|
|
optionString('label'),
|
|
requiredArrayOf('commands', toggleOrNormal),
|
|
optionOf('launch', choose$1('type', {
|
|
contextformbutton: launchButtonFields,
|
|
contextformtogglebutton: launchToggleButtonFields
|
|
}))
|
|
].concat(contextBarFields));
|
|
var createContextForm = function (spec) {
|
|
return asRaw('ContextForm', contextFormSchema, spec);
|
|
};
|
|
|
|
var contextToolbarSchema = objOf([
|
|
defaulted('type', 'contexttoolbar'),
|
|
requiredString('items')
|
|
].concat(contextBarFields));
|
|
var createContextToolbar = function (spec) {
|
|
return asRaw('ContextToolbar', contextToolbarSchema, spec);
|
|
};
|
|
|
|
var stringArray = function (a) {
|
|
var all = {};
|
|
each$1(a, function (key) {
|
|
all[key] = {};
|
|
});
|
|
return keys(all);
|
|
};
|
|
|
|
var register$b = function (editor) {
|
|
var popups = editor.ui.registry.getAll().popups;
|
|
var dataset = map$1(popups, function (popup) {
|
|
return createAutocompleter(popup).fold(function (err) {
|
|
throw new Error(formatError(err));
|
|
}, identity$1);
|
|
});
|
|
var triggerChars = stringArray(mapToArray(dataset, function (v) {
|
|
return v.ch;
|
|
}));
|
|
var datasetValues = values(dataset);
|
|
var lookupByChar = function (ch) {
|
|
return filter$2(datasetValues, function (dv) {
|
|
return dv.ch === ch;
|
|
});
|
|
};
|
|
return {
|
|
dataset: dataset,
|
|
triggerChars: triggerChars,
|
|
lookupByChar: lookupByChar
|
|
};
|
|
};
|
|
|
|
var ItemResponse;
|
|
(function (ItemResponse) {
|
|
ItemResponse[ItemResponse['CLOSE_ON_EXECUTE'] = 0] = 'CLOSE_ON_EXECUTE';
|
|
ItemResponse[ItemResponse['BUBBLE_TO_SANDBOX'] = 1] = 'BUBBLE_TO_SANDBOX';
|
|
}(ItemResponse || (ItemResponse = {})));
|
|
var ItemResponse$1 = ItemResponse;
|
|
|
|
var navClass = 'tox-menu-nav__js';
|
|
var selectableClass = 'tox-collection__item';
|
|
var colorClass = 'tox-swatch';
|
|
var presetClasses = {
|
|
normal: navClass,
|
|
color: colorClass
|
|
};
|
|
var tickedClass = 'tox-collection__item--enabled';
|
|
var groupHeadingClass = 'tox-collection__group-heading';
|
|
var iconClass = 'tox-collection__item-icon';
|
|
var textClass = 'tox-collection__item-label';
|
|
var accessoryClass = 'tox-collection__item-accessory';
|
|
var caretClass = 'tox-collection__item-caret';
|
|
var checkmarkClass = 'tox-collection__item-checkmark';
|
|
var activeClass = 'tox-collection__item--active';
|
|
var containerClass = 'tox-collection__item-container';
|
|
var containerColumnClass = 'tox-collection__item-container--column';
|
|
var containerRowClass = 'tox-collection__item-container--row';
|
|
var containerAlignRightClass = 'tox-collection__item-container--align-right';
|
|
var containerAlignLeftClass = 'tox-collection__item-container--align-left';
|
|
var containerValignTopClass = 'tox-collection__item-container--valign-top';
|
|
var containerValignMiddleClass = 'tox-collection__item-container--valign-middle';
|
|
var containerValignBottomClass = 'tox-collection__item-container--valign-bottom';
|
|
var classForPreset = function (presets) {
|
|
return get$e(presetClasses, presets).getOr(navClass);
|
|
};
|
|
|
|
var forMenu = function (presets) {
|
|
if (presets === 'color') {
|
|
return 'tox-swatches';
|
|
} else {
|
|
return 'tox-menu';
|
|
}
|
|
};
|
|
var classes = function (presets) {
|
|
return {
|
|
backgroundMenu: 'tox-background-menu',
|
|
selectedMenu: 'tox-selected-menu',
|
|
selectedItem: 'tox-collection__item--active',
|
|
hasIcons: 'tox-menu--has-icons',
|
|
menu: forMenu(presets),
|
|
tieredMenu: 'tox-tiered-menu'
|
|
};
|
|
};
|
|
|
|
var markers = function (presets) {
|
|
var menuClasses = classes(presets);
|
|
return {
|
|
backgroundMenu: menuClasses.backgroundMenu,
|
|
selectedMenu: menuClasses.selectedMenu,
|
|
menu: menuClasses.menu,
|
|
selectedItem: menuClasses.selectedItem,
|
|
item: classForPreset(presets)
|
|
};
|
|
};
|
|
var dom$1 = function (hasIcons, columns, presets) {
|
|
var menuClasses = classes(presets);
|
|
return {
|
|
tag: 'div',
|
|
classes: flatten([
|
|
[
|
|
menuClasses.menu,
|
|
'tox-menu-' + columns + '-column'
|
|
],
|
|
hasIcons ? [menuClasses.hasIcons] : []
|
|
])
|
|
};
|
|
};
|
|
var components = [Menu.parts.items({})];
|
|
var part = function (hasIcons, columns, presets) {
|
|
var menuClasses = classes(presets);
|
|
var d = {
|
|
tag: 'div',
|
|
classes: flatten([[menuClasses.tieredMenu]])
|
|
};
|
|
return {
|
|
dom: d,
|
|
markers: markers(presets)
|
|
};
|
|
};
|
|
|
|
var chunk = function (rowDom, numColumns) {
|
|
return function (items) {
|
|
var chunks = chunk$1(items, numColumns);
|
|
return map$2(chunks, function (c) {
|
|
return {
|
|
dom: rowDom,
|
|
components: c
|
|
};
|
|
});
|
|
};
|
|
};
|
|
var forSwatch = function (columns) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-menu',
|
|
'tox-swatches-menu'
|
|
]
|
|
},
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-swatches']
|
|
},
|
|
components: [Menu.parts.items({
|
|
preprocess: columns !== 'auto' ? chunk({
|
|
tag: 'div',
|
|
classes: ['tox-swatches__row']
|
|
}, columns) : identity$1
|
|
})]
|
|
}]
|
|
};
|
|
};
|
|
var forToolbar = function (columns) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-menu',
|
|
'tox-collection',
|
|
'tox-collection--toolbar',
|
|
'tox-collection--toolbar-lg'
|
|
]
|
|
},
|
|
components: [Menu.parts.items({
|
|
preprocess: chunk({
|
|
tag: 'div',
|
|
classes: ['tox-collection__group']
|
|
}, columns)
|
|
})]
|
|
};
|
|
};
|
|
var preprocessCollection = function (items, isSeparator) {
|
|
var allSplits = [];
|
|
var currentSplit = [];
|
|
each$1(items, function (item, i) {
|
|
if (isSeparator(item, i)) {
|
|
if (currentSplit.length > 0) {
|
|
allSplits.push(currentSplit);
|
|
}
|
|
currentSplit = [];
|
|
if (has$2(item.dom, 'innerHtml')) {
|
|
currentSplit.push(item);
|
|
}
|
|
} else {
|
|
currentSplit.push(item);
|
|
}
|
|
});
|
|
if (currentSplit.length > 0) {
|
|
allSplits.push(currentSplit);
|
|
}
|
|
return map$2(allSplits, function (s) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-collection__group']
|
|
},
|
|
components: s
|
|
};
|
|
});
|
|
};
|
|
var forCollection = function (columns, initItems, _hasIcons) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-menu',
|
|
'tox-collection'
|
|
].concat(columns === 1 ? ['tox-collection--list'] : ['tox-collection--grid'])
|
|
},
|
|
components: [Menu.parts.items({
|
|
preprocess: function (items) {
|
|
if (columns !== 'auto' && columns > 1) {
|
|
return chunk({
|
|
tag: 'div',
|
|
classes: ['tox-collection__group']
|
|
}, columns)(items);
|
|
} else {
|
|
return preprocessCollection(items, function (_item, i) {
|
|
return initItems[i].type === 'separator';
|
|
});
|
|
}
|
|
}
|
|
})]
|
|
};
|
|
};
|
|
var forHorizontalCollection = function (initItems, _hasIcons) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-collection',
|
|
'tox-collection--horizontal'
|
|
]
|
|
},
|
|
components: [Menu.parts.items({
|
|
preprocess: function (items) {
|
|
return preprocessCollection(items, function (_item, i) {
|
|
return initItems[i].type === 'separator';
|
|
});
|
|
}
|
|
})]
|
|
};
|
|
};
|
|
|
|
var menuHasIcons = function (xs) {
|
|
return exists(xs, function (item) {
|
|
return 'icon' in item && item.icon !== undefined;
|
|
});
|
|
};
|
|
var handleError = function (error) {
|
|
console.error(formatError(error));
|
|
console.log(error);
|
|
return Optional.none();
|
|
};
|
|
var createHorizontalPartialMenuWithAlloyItems = function (value, _hasIcons, items, _columns, _presets) {
|
|
var structure = forHorizontalCollection(items);
|
|
return {
|
|
value: value,
|
|
dom: structure.dom,
|
|
components: structure.components,
|
|
items: items
|
|
};
|
|
};
|
|
var createPartialMenuWithAlloyItems = function (value, hasIcons, items, columns, presets) {
|
|
if (presets === 'color') {
|
|
var structure = forSwatch(columns);
|
|
return {
|
|
value: value,
|
|
dom: structure.dom,
|
|
components: structure.components,
|
|
items: items
|
|
};
|
|
}
|
|
if (presets === 'normal' && columns === 'auto') {
|
|
var structure = forCollection(columns, items);
|
|
return {
|
|
value: value,
|
|
dom: structure.dom,
|
|
components: structure.components,
|
|
items: items
|
|
};
|
|
}
|
|
if (presets === 'normal' && columns === 1) {
|
|
var structure = forCollection(1, items);
|
|
return {
|
|
value: value,
|
|
dom: structure.dom,
|
|
components: structure.components,
|
|
items: items
|
|
};
|
|
}
|
|
if (presets === 'normal') {
|
|
var structure = forCollection(columns, items);
|
|
return {
|
|
value: value,
|
|
dom: structure.dom,
|
|
components: structure.components,
|
|
items: items
|
|
};
|
|
}
|
|
if (presets === 'listpreview' && columns !== 'auto') {
|
|
var structure = forToolbar(columns);
|
|
return {
|
|
value: value,
|
|
dom: structure.dom,
|
|
components: structure.components,
|
|
items: items
|
|
};
|
|
}
|
|
return {
|
|
value: value,
|
|
dom: dom$1(hasIcons, columns, presets),
|
|
components: components,
|
|
items: items
|
|
};
|
|
};
|
|
|
|
var cardImageFields = [
|
|
requiredString('type'),
|
|
requiredString('src'),
|
|
optionString('alt'),
|
|
defaultedArrayOf('classes', [], string)
|
|
];
|
|
var cardImageSchema = objOf(cardImageFields);
|
|
|
|
var cardTextFields = [
|
|
requiredString('type'),
|
|
requiredString('text'),
|
|
optionString('name'),
|
|
defaultedArrayOf('classes', ['tox-collection__item-label'], string)
|
|
];
|
|
var cardTextSchema = objOf(cardTextFields);
|
|
|
|
var itemSchema$1 = valueThunk(function () {
|
|
return choose$2('type', {
|
|
cardimage: cardImageSchema,
|
|
cardtext: cardTextSchema,
|
|
cardcontainer: cardContainerSchema
|
|
});
|
|
});
|
|
var cardContainerSchema = objOf([
|
|
requiredString('type'),
|
|
defaultedString('direction', 'horizontal'),
|
|
defaultedString('align', 'left'),
|
|
defaultedString('valign', 'middle'),
|
|
requiredArrayOf('items', itemSchema$1)
|
|
]);
|
|
|
|
var commonMenuItemFields = [
|
|
defaultedBoolean('disabled', false),
|
|
optionString('text'),
|
|
optionString('shortcut'),
|
|
field$1('value', 'value', defaultedThunk(function () {
|
|
return generate$6('menuitem-value');
|
|
}), anyValue()),
|
|
defaulted('meta', {})
|
|
];
|
|
|
|
var cardMenuItemSchema = objOf([
|
|
requiredString('type'),
|
|
optionString('label'),
|
|
requiredArrayOf('items', itemSchema$1),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
}),
|
|
defaultedFunction('onAction', noop)
|
|
].concat(commonMenuItemFields));
|
|
var createCardMenuItem = function (spec) {
|
|
return asRaw('cardmenuitem', cardMenuItemSchema, spec);
|
|
};
|
|
|
|
var choiceMenuItemSchema = objOf([
|
|
requiredString('type'),
|
|
defaultedBoolean('active', false),
|
|
optionString('icon')
|
|
].concat(commonMenuItemFields));
|
|
var createChoiceMenuItem = function (spec) {
|
|
return asRaw('choicemenuitem', choiceMenuItemSchema, spec);
|
|
};
|
|
|
|
var baseFields = [
|
|
requiredString('type'),
|
|
requiredString('fancytype'),
|
|
defaultedFunction('onAction', noop)
|
|
];
|
|
var insertTableFields = [defaulted('initData', {})].concat(baseFields);
|
|
var colorSwatchFields = [defaultedObjOf('initData', {}, [
|
|
defaultedBoolean('allowCustomColors', true),
|
|
optionArrayOf('colors', anyValue())
|
|
])].concat(baseFields);
|
|
var fancyMenuItemSchema = choose$1('fancytype', {
|
|
inserttable: insertTableFields,
|
|
colorswatch: colorSwatchFields
|
|
});
|
|
var createFancyMenuItem = function (spec) {
|
|
return asRaw('fancymenuitem', fancyMenuItemSchema, spec);
|
|
};
|
|
|
|
var menuItemSchema = objOf([
|
|
requiredString('type'),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
}),
|
|
defaultedFunction('onAction', noop),
|
|
optionString('icon')
|
|
].concat(commonMenuItemFields));
|
|
var createMenuItem = function (spec) {
|
|
return asRaw('menuitem', menuItemSchema, spec);
|
|
};
|
|
|
|
var nestedMenuItemSchema = objOf([
|
|
requiredString('type'),
|
|
requiredFunction('getSubmenuItems'),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
}),
|
|
optionString('icon')
|
|
].concat(commonMenuItemFields));
|
|
var createNestedMenuItem = function (spec) {
|
|
return asRaw('nestedmenuitem', nestedMenuItemSchema, spec);
|
|
};
|
|
|
|
var toggleMenuItemSchema = objOf([
|
|
requiredString('type'),
|
|
optionString('icon'),
|
|
defaultedBoolean('active', false),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
}),
|
|
requiredFunction('onAction')
|
|
].concat(commonMenuItemFields));
|
|
var createToggleMenuItem = function (spec) {
|
|
return asRaw('togglemenuitem', toggleMenuItemSchema, spec);
|
|
};
|
|
|
|
var detectSize = function (comp, margin, selectorClass) {
|
|
var descendants$1 = descendants(comp.element, '.' + selectorClass);
|
|
if (descendants$1.length > 0) {
|
|
var columnLength = findIndex$1(descendants$1, function (c) {
|
|
var thisTop = c.dom.getBoundingClientRect().top;
|
|
var cTop = descendants$1[0].dom.getBoundingClientRect().top;
|
|
return Math.abs(thisTop - cTop) > margin;
|
|
}).getOr(descendants$1.length);
|
|
return Optional.some({
|
|
numColumns: columnLength,
|
|
numRows: Math.ceil(descendants$1.length / columnLength)
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
|
|
var namedEvents = function (name, handlers) {
|
|
return derive$1([config(name, handlers)]);
|
|
};
|
|
var unnamedEvents = function (handlers) {
|
|
return namedEvents(generate$6('unnamed-events'), handlers);
|
|
};
|
|
var SimpleBehaviours = {
|
|
namedEvents: namedEvents,
|
|
unnamedEvents: unnamedEvents
|
|
};
|
|
|
|
var ExclusivityChannel = generate$6('tooltip.exclusive');
|
|
var ShowTooltipEvent = generate$6('tooltip.show');
|
|
var HideTooltipEvent = generate$6('tooltip.hide');
|
|
|
|
var hideAllExclusive = function (component, _tConfig, _tState) {
|
|
component.getSystem().broadcastOn([ExclusivityChannel], {});
|
|
};
|
|
var setComponents = function (component, tConfig, tState, specs) {
|
|
tState.getTooltip().each(function (tooltip) {
|
|
if (tooltip.getSystem().isConnected()) {
|
|
Replacing.set(tooltip, specs);
|
|
}
|
|
});
|
|
};
|
|
|
|
var TooltippingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
hideAllExclusive: hideAllExclusive,
|
|
setComponents: setComponents
|
|
});
|
|
|
|
var events$9 = function (tooltipConfig, state) {
|
|
var hide = function (comp) {
|
|
state.getTooltip().each(function (p) {
|
|
detach(p);
|
|
tooltipConfig.onHide(comp, p);
|
|
state.clearTooltip();
|
|
});
|
|
state.clearTimer();
|
|
};
|
|
var show = function (comp) {
|
|
if (!state.isShowing()) {
|
|
hideAllExclusive(comp);
|
|
var sink = tooltipConfig.lazySink(comp).getOrDie();
|
|
var popup = comp.getSystem().build({
|
|
dom: tooltipConfig.tooltipDom,
|
|
components: tooltipConfig.tooltipComponents,
|
|
events: derive$2(tooltipConfig.mode === 'normal' ? [
|
|
run$1(mouseover(), function (_) {
|
|
emit(comp, ShowTooltipEvent);
|
|
}),
|
|
run$1(mouseout(), function (_) {
|
|
emit(comp, HideTooltipEvent);
|
|
})
|
|
] : []),
|
|
behaviours: derive$1([Replacing.config({})])
|
|
});
|
|
state.setTooltip(popup);
|
|
attach(sink, popup);
|
|
tooltipConfig.onShow(comp, popup);
|
|
Positioning.position(sink, popup, { anchor: tooltipConfig.anchor(comp) });
|
|
}
|
|
};
|
|
return derive$2(flatten([
|
|
[
|
|
run$1(ShowTooltipEvent, function (comp) {
|
|
state.resetTimer(function () {
|
|
show(comp);
|
|
}, tooltipConfig.delay);
|
|
}),
|
|
run$1(HideTooltipEvent, function (comp) {
|
|
state.resetTimer(function () {
|
|
hide(comp);
|
|
}, tooltipConfig.delay);
|
|
}),
|
|
run$1(receive(), function (comp, message) {
|
|
var receivingData = message;
|
|
if (!receivingData.universal) {
|
|
if (contains$2(receivingData.channels, ExclusivityChannel)) {
|
|
hide(comp);
|
|
}
|
|
}
|
|
}),
|
|
runOnDetached(function (comp) {
|
|
hide(comp);
|
|
})
|
|
],
|
|
tooltipConfig.mode === 'normal' ? [
|
|
run$1(focusin(), function (comp) {
|
|
emit(comp, ShowTooltipEvent);
|
|
}),
|
|
run$1(postBlur(), function (comp) {
|
|
emit(comp, HideTooltipEvent);
|
|
}),
|
|
run$1(mouseover(), function (comp) {
|
|
emit(comp, ShowTooltipEvent);
|
|
}),
|
|
run$1(mouseout(), function (comp) {
|
|
emit(comp, HideTooltipEvent);
|
|
})
|
|
] : [
|
|
run$1(highlight$1(), function (comp, _se) {
|
|
emit(comp, ShowTooltipEvent);
|
|
}),
|
|
run$1(dehighlight$1(), function (comp) {
|
|
emit(comp, HideTooltipEvent);
|
|
})
|
|
]
|
|
]));
|
|
};
|
|
|
|
var ActiveTooltipping = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$9
|
|
});
|
|
|
|
var TooltippingSchema = [
|
|
required$1('lazySink'),
|
|
required$1('tooltipDom'),
|
|
defaulted('exclusive', true),
|
|
defaulted('tooltipComponents', []),
|
|
defaulted('delay', 300),
|
|
defaultedStringEnum('mode', 'normal', [
|
|
'normal',
|
|
'follow-highlight'
|
|
]),
|
|
defaulted('anchor', function (comp) {
|
|
return {
|
|
type: 'hotspot',
|
|
hotspot: comp,
|
|
layouts: {
|
|
onLtr: constant$1([
|
|
south$2,
|
|
north$2,
|
|
southeast$2,
|
|
northeast$2,
|
|
southwest$2,
|
|
northwest$2
|
|
]),
|
|
onRtl: constant$1([
|
|
south$2,
|
|
north$2,
|
|
southeast$2,
|
|
northeast$2,
|
|
southwest$2,
|
|
northwest$2
|
|
])
|
|
}
|
|
};
|
|
}),
|
|
onHandler('onHide'),
|
|
onHandler('onShow')
|
|
];
|
|
|
|
var init$b = function () {
|
|
var timer = value$1();
|
|
var popup = value$1();
|
|
var clearTimer = function () {
|
|
timer.on(clearTimeout);
|
|
};
|
|
var resetTimer = function (f, delay) {
|
|
clearTimer();
|
|
timer.set(setTimeout(f, delay));
|
|
};
|
|
var readState = constant$1('not-implemented');
|
|
return nu$8({
|
|
getTooltip: popup.get,
|
|
isShowing: popup.isSet,
|
|
setTooltip: popup.set,
|
|
clearTooltip: popup.clear,
|
|
clearTimer: clearTimer,
|
|
resetTimer: resetTimer,
|
|
readState: readState
|
|
});
|
|
};
|
|
|
|
var TooltippingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$b
|
|
});
|
|
|
|
var Tooltipping = create$7({
|
|
fields: TooltippingSchema,
|
|
name: 'tooltipping',
|
|
active: ActiveTooltipping,
|
|
state: TooltippingState,
|
|
apis: TooltippingApis
|
|
});
|
|
|
|
var escape = function (text) {
|
|
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
};
|
|
|
|
var global$b = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$a = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
|
|
|
var getSkinUrl = function (editor) {
|
|
var skin = editor.getParam('skin');
|
|
var skinUrl = editor.getParam('skin_url');
|
|
if (skin !== false) {
|
|
var skinName = skin ? skin : 'oxide';
|
|
if (skinUrl) {
|
|
skinUrl = editor.documentBaseURI.toAbsolute(skinUrl);
|
|
} else {
|
|
skinUrl = global$a.baseURL + '/skins/ui/' + skinName;
|
|
}
|
|
}
|
|
return skinUrl;
|
|
};
|
|
var isReadOnly = function (editor) {
|
|
return editor.getParam('readonly', false, 'boolean');
|
|
};
|
|
var isSkinDisabled = function (editor) {
|
|
return editor.getParam('skin') === false;
|
|
};
|
|
var getHeightSetting = function (editor) {
|
|
return editor.getParam('height', Math.max(editor.getElement().offsetHeight, 200));
|
|
};
|
|
var getWidthSetting = function (editor) {
|
|
return editor.getParam('width', global$b.DOM.getStyle(editor.getElement(), 'width'));
|
|
};
|
|
var getMinWidthSetting = function (editor) {
|
|
return Optional.from(editor.getParam('min_width')).filter(isNumber);
|
|
};
|
|
var getMinHeightSetting = function (editor) {
|
|
return Optional.from(editor.getParam('min_height')).filter(isNumber);
|
|
};
|
|
var getMaxWidthSetting = function (editor) {
|
|
return Optional.from(editor.getParam('max_width')).filter(isNumber);
|
|
};
|
|
var getMaxHeightSetting = function (editor) {
|
|
return Optional.from(editor.getParam('max_height')).filter(isNumber);
|
|
};
|
|
var getUserStyleFormats = function (editor) {
|
|
return Optional.from(editor.getParam('style_formats')).filter(isArray);
|
|
};
|
|
var isMergeStyleFormats = function (editor) {
|
|
return editor.getParam('style_formats_merge', false, 'boolean');
|
|
};
|
|
var getLineHeightFormats = function (editor) {
|
|
return editor.getParam('lineheight_formats', '1 1.1 1.2 1.3 1.4 1.5 2', 'string').split(' ');
|
|
};
|
|
var getContentLanguages = function (editor) {
|
|
return editor.getParam('content_langs', undefined, 'array');
|
|
};
|
|
var getRemovedMenuItems = function (editor) {
|
|
return editor.getParam('removed_menuitems', '');
|
|
};
|
|
var isMenubarEnabled = function (editor) {
|
|
return editor.getParam('menubar', true, 'boolean') !== false;
|
|
};
|
|
var isToolbarEnabled = function (editor) {
|
|
var toolbar = editor.getParam('toolbar', true);
|
|
var isToolbarTrue = toolbar === true;
|
|
var isToolbarString = isString(toolbar);
|
|
var isToolbarObjectArray = isArray(toolbar) && toolbar.length > 0;
|
|
return !isMultipleToolbars(editor) && (isToolbarObjectArray || isToolbarString || isToolbarTrue);
|
|
};
|
|
var getMultipleToolbarsSetting = function (editor) {
|
|
var toolbars = range$2(9, function (num) {
|
|
return editor.getParam('toolbar' + (num + 1), false, 'string');
|
|
});
|
|
var toolbarArray = filter$2(toolbars, function (toolbar) {
|
|
return typeof toolbar === 'string';
|
|
});
|
|
return toolbarArray.length > 0 ? Optional.some(toolbarArray) : Optional.none();
|
|
};
|
|
var isMultipleToolbars = function (editor) {
|
|
return getMultipleToolbarsSetting(editor).fold(function () {
|
|
var toolbar = editor.getParam('toolbar', [], 'string[]');
|
|
return toolbar.length > 0;
|
|
}, always);
|
|
};
|
|
var ToolbarMode;
|
|
(function (ToolbarMode) {
|
|
ToolbarMode['default'] = 'wrap';
|
|
ToolbarMode['floating'] = 'floating';
|
|
ToolbarMode['sliding'] = 'sliding';
|
|
ToolbarMode['scrolling'] = 'scrolling';
|
|
}(ToolbarMode || (ToolbarMode = {})));
|
|
var getToolbarMode = function (editor) {
|
|
return editor.getParam('toolbar_mode', '', 'string');
|
|
};
|
|
var ToolbarLocation;
|
|
(function (ToolbarLocation) {
|
|
ToolbarLocation['auto'] = 'auto';
|
|
ToolbarLocation['top'] = 'top';
|
|
ToolbarLocation['bottom'] = 'bottom';
|
|
}(ToolbarLocation || (ToolbarLocation = {})));
|
|
var getToolbarGroups = function (editor) {
|
|
return editor.getParam('toolbar_groups', {}, 'object');
|
|
};
|
|
var getToolbarLocation = function (editor) {
|
|
return editor.getParam('toolbar_location', ToolbarLocation.auto, 'string');
|
|
};
|
|
var isToolbarLocationBottom = function (editor) {
|
|
return getToolbarLocation(editor) === ToolbarLocation.bottom;
|
|
};
|
|
var fixedContainerSelector = function (editor) {
|
|
return editor.getParam('fixed_toolbar_container', '', 'string');
|
|
};
|
|
var fixedToolbarContainerTarget = function (editor) {
|
|
return editor.getParam('fixed_toolbar_container_target');
|
|
};
|
|
var isToolbarPersist = function (editor) {
|
|
return editor.getParam('toolbar_persist', false, 'boolean');
|
|
};
|
|
var fixedContainerTarget = function (editor) {
|
|
if (!editor.inline) {
|
|
return Optional.none();
|
|
}
|
|
var selector = fixedContainerSelector(editor);
|
|
if (selector.length > 0) {
|
|
return descendant(body(), selector);
|
|
}
|
|
var element = fixedToolbarContainerTarget(editor);
|
|
if (isNonNullable(element)) {
|
|
return Optional.some(SugarElement.fromDom(element));
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var useFixedContainer = function (editor) {
|
|
return editor.inline && fixedContainerTarget(editor).isSome();
|
|
};
|
|
var getUiContainer = function (editor) {
|
|
var fixedContainer = fixedContainerTarget(editor);
|
|
return fixedContainer.getOrThunk(function () {
|
|
return getContentContainer(getRootNode(SugarElement.fromDom(editor.getElement())));
|
|
});
|
|
};
|
|
var isDistractionFree = function (editor) {
|
|
return editor.inline && !isMenubarEnabled(editor) && !isToolbarEnabled(editor) && !isMultipleToolbars(editor);
|
|
};
|
|
var isStickyToolbar = function (editor) {
|
|
var isStickyToolbar = editor.getParam('toolbar_sticky', false, 'boolean');
|
|
return (isStickyToolbar || editor.inline) && !useFixedContainer(editor) && !isDistractionFree(editor);
|
|
};
|
|
var getStickyToolbarOffset = function (editor) {
|
|
return editor.getParam('toolbar_sticky_offset', 0, 'number');
|
|
};
|
|
var isDraggableModal$1 = function (editor) {
|
|
return editor.getParam('draggable_modal', false, 'boolean');
|
|
};
|
|
var getMenus = function (editor) {
|
|
var menu = editor.getParam('menu');
|
|
if (menu) {
|
|
return map$1(menu, function (menu) {
|
|
return __assign(__assign({}, menu), { items: menu.items });
|
|
});
|
|
} else {
|
|
return {};
|
|
}
|
|
};
|
|
var getMenubar = function (editor) {
|
|
return editor.getParam('menubar');
|
|
};
|
|
var getToolbar = function (editor) {
|
|
return editor.getParam('toolbar', true);
|
|
};
|
|
var getFilePickerCallback = function (editor) {
|
|
return editor.getParam('file_picker_callback');
|
|
};
|
|
var getFilePickerTypes = function (editor) {
|
|
return editor.getParam('file_picker_types');
|
|
};
|
|
var getFileBrowserCallbackTypes = function (editor) {
|
|
return editor.getParam('file_browser_callback_types');
|
|
};
|
|
var noTypeaheadUrls = function (editor) {
|
|
return editor.getParam('typeahead_urls') === false;
|
|
};
|
|
var getAnchorTop = function (editor) {
|
|
return editor.getParam('anchor_top', '#top');
|
|
};
|
|
var getAnchorBottom = function (editor) {
|
|
return editor.getParam('anchor_bottom', '#bottom');
|
|
};
|
|
var getFilePickerValidatorHandler = function (editor) {
|
|
var handler = editor.getParam('file_picker_validator_handler', undefined, 'function');
|
|
if (handler === undefined) {
|
|
return editor.getParam('filepicker_validator_handler', undefined, 'function');
|
|
} else {
|
|
return handler;
|
|
}
|
|
};
|
|
|
|
var ReadOnlyChannel = 'silver.readonly';
|
|
var ReadOnlyDataSchema = objOf([requiredBoolean('readonly')]);
|
|
var broadcastReadonly = function (uiComponents, readonly) {
|
|
var outerContainer = uiComponents.outerContainer;
|
|
var target = outerContainer.element;
|
|
if (readonly) {
|
|
uiComponents.mothership.broadcastOn([dismissPopups()], { target: target });
|
|
uiComponents.uiMothership.broadcastOn([dismissPopups()], { target: target });
|
|
}
|
|
uiComponents.mothership.broadcastOn([ReadOnlyChannel], { readonly: readonly });
|
|
uiComponents.uiMothership.broadcastOn([ReadOnlyChannel], { readonly: readonly });
|
|
};
|
|
var setupReadonlyModeSwitch = function (editor, uiComponents) {
|
|
editor.on('init', function () {
|
|
if (editor.mode.isReadOnly()) {
|
|
broadcastReadonly(uiComponents, true);
|
|
}
|
|
});
|
|
editor.on('SwitchMode', function () {
|
|
return broadcastReadonly(uiComponents, editor.mode.isReadOnly());
|
|
});
|
|
if (isReadOnly(editor)) {
|
|
editor.setMode('readonly');
|
|
}
|
|
};
|
|
var receivingConfig = function () {
|
|
var _a;
|
|
return Receiving.config({
|
|
channels: (_a = {}, _a[ReadOnlyChannel] = {
|
|
schema: ReadOnlyDataSchema,
|
|
onReceive: function (comp, data) {
|
|
Disabling.set(comp, data.readonly);
|
|
}
|
|
}, _a)
|
|
});
|
|
};
|
|
|
|
var item = function (disabled) {
|
|
return Disabling.config({
|
|
disabled: disabled,
|
|
disableClass: 'tox-collection__item--state-disabled'
|
|
});
|
|
};
|
|
var button = function (disabled) {
|
|
return Disabling.config({ disabled: disabled });
|
|
};
|
|
var splitButton = function (disabled) {
|
|
return Disabling.config({
|
|
disabled: disabled,
|
|
disableClass: 'tox-tbtn--disabled'
|
|
});
|
|
};
|
|
var toolbarButton = function (disabled) {
|
|
return Disabling.config({
|
|
disabled: disabled,
|
|
disableClass: 'tox-tbtn--disabled',
|
|
useNative: false
|
|
});
|
|
};
|
|
var DisablingConfigs = {
|
|
item: item,
|
|
button: button,
|
|
splitButton: splitButton,
|
|
toolbarButton: toolbarButton
|
|
};
|
|
|
|
var runWithApi = function (info, comp) {
|
|
var api = info.getApi(comp);
|
|
return function (f) {
|
|
f(api);
|
|
};
|
|
};
|
|
var onControlAttached = function (info, editorOffCell) {
|
|
return runOnAttached(function (comp) {
|
|
var run = runWithApi(info, comp);
|
|
run(function (api) {
|
|
var onDestroy = info.onSetup(api);
|
|
if (isFunction(onDestroy)) {
|
|
editorOffCell.set(onDestroy);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var onControlDetached = function (getApi, editorOffCell) {
|
|
return runOnDetached(function (comp) {
|
|
return runWithApi(getApi, comp)(editorOffCell.get());
|
|
});
|
|
};
|
|
|
|
var _a$1;
|
|
var onMenuItemExecute = function (info, itemResponse) {
|
|
return runOnExecute$1(function (comp, simulatedEvent) {
|
|
runWithApi(info, comp)(info.onAction);
|
|
if (!info.triggersSubmenu && itemResponse === ItemResponse$1.CLOSE_ON_EXECUTE) {
|
|
emit(comp, sandboxClose());
|
|
simulatedEvent.stop();
|
|
}
|
|
});
|
|
};
|
|
var menuItemEventOrder = (_a$1 = {}, _a$1[execute$5()] = [
|
|
'disabling',
|
|
'alloy.base.behaviour',
|
|
'toggling',
|
|
'item-events'
|
|
], _a$1);
|
|
|
|
var componentRenderPipeline = cat;
|
|
var renderCommonItem = function (spec, structure, itemResponse, providersbackstage) {
|
|
var editorOffCell = Cell(noop);
|
|
return {
|
|
type: 'item',
|
|
dom: structure.dom,
|
|
components: componentRenderPipeline(structure.optComponents),
|
|
data: spec.data,
|
|
eventOrder: menuItemEventOrder,
|
|
hasSubmenu: spec.triggersSubmenu,
|
|
itemBehaviours: derive$1([
|
|
config('item-events', [
|
|
onMenuItemExecute(spec, itemResponse),
|
|
onControlAttached(spec, editorOffCell),
|
|
onControlDetached(spec, editorOffCell)
|
|
]),
|
|
DisablingConfigs.item(function () {
|
|
return spec.disabled || providersbackstage.isDisabled();
|
|
}),
|
|
receivingConfig(),
|
|
Replacing.config({})
|
|
].concat(spec.itemBehaviours))
|
|
};
|
|
};
|
|
var buildData = function (source) {
|
|
return {
|
|
value: source.value,
|
|
meta: __assign({ text: source.text.getOr('') }, source.meta)
|
|
};
|
|
};
|
|
|
|
var global$9 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var convertText = function (source) {
|
|
var mac = {
|
|
alt: '⌥',
|
|
ctrl: '⌃',
|
|
shift: '⇧',
|
|
meta: '⌘',
|
|
access: '⌃⌥'
|
|
};
|
|
var other = {
|
|
meta: 'Ctrl',
|
|
access: 'Shift+Alt'
|
|
};
|
|
var replace = global$9.mac ? mac : other;
|
|
var shortcut = source.split('+');
|
|
var updated = map$2(shortcut, function (segment) {
|
|
var search = segment.toLowerCase().trim();
|
|
return has$2(replace, search) ? replace[search] : segment;
|
|
});
|
|
return global$9.mac ? updated.join('') : updated.join('+');
|
|
};
|
|
|
|
var renderIcon$1 = function (name, icons, classes) {
|
|
if (classes === void 0) {
|
|
classes = [iconClass];
|
|
}
|
|
return render$3(name, {
|
|
tag: 'div',
|
|
classes: classes
|
|
}, icons);
|
|
};
|
|
var renderText = function (text$1) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [textClass]
|
|
},
|
|
components: [text(global$e.translate(text$1))]
|
|
};
|
|
};
|
|
var renderHtml = function (html, classes) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: classes,
|
|
innerHtml: html
|
|
}
|
|
};
|
|
};
|
|
var renderStyledText = function (style, text$1) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [textClass]
|
|
},
|
|
components: [{
|
|
dom: {
|
|
tag: style.tag,
|
|
styles: style.styles
|
|
},
|
|
components: [text(global$e.translate(text$1))]
|
|
}]
|
|
};
|
|
};
|
|
var renderShortcut = function (shortcut) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [accessoryClass],
|
|
innerHtml: convertText(shortcut)
|
|
}
|
|
};
|
|
};
|
|
var renderCheckmark = function (icons) {
|
|
return renderIcon$1('checkmark', icons, [checkmarkClass]);
|
|
};
|
|
var renderSubmenuCaret = function (icons) {
|
|
return renderIcon$1('chevron-right', icons, [caretClass]);
|
|
};
|
|
var renderDownwardsCaret = function (icons) {
|
|
return renderIcon$1('chevron-down', icons, [caretClass]);
|
|
};
|
|
var renderContainer = function (container, components) {
|
|
var directionClass = container.direction === 'vertical' ? containerColumnClass : containerRowClass;
|
|
var alignClass = container.align === 'left' ? containerAlignLeftClass : containerAlignRightClass;
|
|
var getValignClass = function () {
|
|
switch (container.valign) {
|
|
case 'top':
|
|
return containerValignTopClass;
|
|
case 'middle':
|
|
return containerValignMiddleClass;
|
|
case 'bottom':
|
|
return containerValignBottomClass;
|
|
}
|
|
};
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
containerClass,
|
|
directionClass,
|
|
alignClass,
|
|
getValignClass()
|
|
]
|
|
},
|
|
components: components
|
|
};
|
|
};
|
|
var renderImage = function (src, classes, alt) {
|
|
return {
|
|
dom: {
|
|
tag: 'img',
|
|
classes: classes,
|
|
attributes: {
|
|
src: src,
|
|
alt: alt.getOr('')
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
var renderColorStructure = function (item, providerBackstage, fallbackIcon) {
|
|
var colorPickerCommand = 'custom';
|
|
var removeColorCommand = 'remove';
|
|
var itemText = item.ariaLabel;
|
|
var itemValue = item.value;
|
|
var iconSvg = item.iconContent.map(function (name) {
|
|
return getOr(name, providerBackstage.icons, fallbackIcon);
|
|
});
|
|
var getDom = function () {
|
|
var common = colorClass;
|
|
var icon = iconSvg.getOr('');
|
|
var attributes = itemText.map(function (text) {
|
|
return { title: providerBackstage.translate(text) };
|
|
}).getOr({});
|
|
var baseDom = {
|
|
tag: 'div',
|
|
attributes: attributes,
|
|
classes: [common]
|
|
};
|
|
if (itemValue === colorPickerCommand) {
|
|
return __assign(__assign({}, baseDom), {
|
|
tag: 'button',
|
|
classes: __spreadArray(__spreadArray([], baseDom.classes, true), ['tox-swatches__picker-btn'], false),
|
|
innerHtml: icon
|
|
});
|
|
} else if (itemValue === removeColorCommand) {
|
|
return __assign(__assign({}, baseDom), {
|
|
classes: __spreadArray(__spreadArray([], baseDom.classes, true), ['tox-swatch--remove'], false),
|
|
innerHtml: icon
|
|
});
|
|
} else {
|
|
return __assign(__assign({}, baseDom), {
|
|
attributes: __assign(__assign({}, baseDom.attributes), { 'data-mce-color': itemValue }),
|
|
styles: { 'background-color': itemValue }
|
|
});
|
|
}
|
|
};
|
|
return {
|
|
dom: getDom(),
|
|
optComponents: []
|
|
};
|
|
};
|
|
var renderItemDomStructure = function (ariaLabel) {
|
|
var domTitle = ariaLabel.map(function (label) {
|
|
return { attributes: { title: global$e.translate(label) } };
|
|
}).getOr({});
|
|
return __assign({
|
|
tag: 'div',
|
|
classes: [
|
|
navClass,
|
|
selectableClass
|
|
]
|
|
}, domTitle);
|
|
};
|
|
var renderNormalItemStructure = function (info, providersBackstage, renderIcons, fallbackIcon) {
|
|
var iconSpec = {
|
|
tag: 'div',
|
|
classes: [iconClass]
|
|
};
|
|
var renderIcon = function (iconName) {
|
|
return render$3(iconName, iconSpec, providersBackstage.icons, fallbackIcon);
|
|
};
|
|
var renderEmptyIcon = function () {
|
|
return Optional.some({ dom: iconSpec });
|
|
};
|
|
var leftIcon = renderIcons ? info.iconContent.map(renderIcon).orThunk(renderEmptyIcon) : Optional.none();
|
|
var checkmark = info.checkMark;
|
|
var textRender = Optional.from(info.meta).fold(function () {
|
|
return renderText;
|
|
}, function (meta) {
|
|
return has$2(meta, 'style') ? curry(renderStyledText, meta.style) : renderText;
|
|
});
|
|
var content = info.htmlContent.fold(function () {
|
|
return info.textContent.map(textRender);
|
|
}, function (html) {
|
|
return Optional.some(renderHtml(html, [textClass]));
|
|
});
|
|
var menuItem = {
|
|
dom: renderItemDomStructure(info.ariaLabel),
|
|
optComponents: [
|
|
leftIcon,
|
|
content,
|
|
info.shortcutContent.map(renderShortcut),
|
|
checkmark,
|
|
info.caret
|
|
]
|
|
};
|
|
return menuItem;
|
|
};
|
|
var renderItemStructure = function (info, providersBackstage, renderIcons, fallbackIcon) {
|
|
if (fallbackIcon === void 0) {
|
|
fallbackIcon = Optional.none();
|
|
}
|
|
if (info.presets === 'color') {
|
|
return renderColorStructure(info, providersBackstage, fallbackIcon);
|
|
} else {
|
|
return renderNormalItemStructure(info, providersBackstage, renderIcons, fallbackIcon);
|
|
}
|
|
};
|
|
|
|
var tooltipBehaviour = function (meta, sharedBackstage) {
|
|
return get$e(meta, 'tooltipWorker').map(function (tooltipWorker) {
|
|
return [Tooltipping.config({
|
|
lazySink: sharedBackstage.getSink,
|
|
tooltipDom: {
|
|
tag: 'div',
|
|
classes: ['tox-tooltip-worker-container']
|
|
},
|
|
tooltipComponents: [],
|
|
anchor: function (comp) {
|
|
return {
|
|
type: 'submenu',
|
|
item: comp,
|
|
overrides: { maxHeightFunction: expandable$1 }
|
|
};
|
|
},
|
|
mode: 'follow-highlight',
|
|
onShow: function (component, _tooltip) {
|
|
tooltipWorker(function (elm) {
|
|
Tooltipping.setComponents(component, [external$2({ element: SugarElement.fromDom(elm) })]);
|
|
});
|
|
}
|
|
})];
|
|
}).getOr([]);
|
|
};
|
|
var encodeText = function (text) {
|
|
return global$b.DOM.encode(text);
|
|
};
|
|
var replaceText = function (text, matchText) {
|
|
var translated = global$e.translate(text);
|
|
var encoded = encodeText(translated);
|
|
if (matchText.length > 0) {
|
|
var escapedMatchRegex = new RegExp(escape(matchText), 'gi');
|
|
return encoded.replace(escapedMatchRegex, function (match) {
|
|
return '<span class="tox-autocompleter-highlight">' + match + '</span>';
|
|
});
|
|
} else {
|
|
return encoded;
|
|
}
|
|
};
|
|
var renderAutocompleteItem = function (spec, matchText, useText, presets, onItemValueHandler, itemResponse, sharedBackstage, renderIcons) {
|
|
if (renderIcons === void 0) {
|
|
renderIcons = true;
|
|
}
|
|
var structure = renderItemStructure({
|
|
presets: presets,
|
|
textContent: Optional.none(),
|
|
htmlContent: useText ? spec.text.map(function (text) {
|
|
return replaceText(text, matchText);
|
|
}) : Optional.none(),
|
|
ariaLabel: spec.text,
|
|
iconContent: spec.icon,
|
|
shortcutContent: Optional.none(),
|
|
checkMark: Optional.none(),
|
|
caret: Optional.none(),
|
|
value: spec.value
|
|
}, sharedBackstage.providers, renderIcons, spec.icon);
|
|
return renderCommonItem({
|
|
data: buildData(spec),
|
|
disabled: spec.disabled,
|
|
getApi: constant$1({}),
|
|
onAction: function (_api) {
|
|
return onItemValueHandler(spec.value, spec.meta);
|
|
},
|
|
onSetup: constant$1(noop),
|
|
triggersSubmenu: false,
|
|
itemBehaviours: tooltipBehaviour(spec.meta, sharedBackstage)
|
|
}, structure, itemResponse, sharedBackstage.providers);
|
|
};
|
|
|
|
var render$2 = function (items, extras) {
|
|
return map$2(items, function (item) {
|
|
switch (item.type) {
|
|
case 'cardcontainer':
|
|
return renderContainer(item, render$2(item.items, extras));
|
|
case 'cardimage':
|
|
return renderImage(item.src, item.classes, item.alt);
|
|
case 'cardtext':
|
|
var shouldHighlight = item.name.exists(function (name) {
|
|
return contains$2(extras.cardText.highlightOn, name);
|
|
});
|
|
var matchText = shouldHighlight ? Optional.from(extras.cardText.matchText).getOr('') : '';
|
|
return renderHtml(replaceText(item.text, matchText), item.classes);
|
|
}
|
|
});
|
|
};
|
|
var renderCardMenuItem = function (spec, itemResponse, sharedBackstage, extras) {
|
|
var getApi = function (component) {
|
|
return {
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
Disabling.set(component, state);
|
|
each$1(descendants(component.element, '*'), function (elm) {
|
|
component.getSystem().getByDom(elm).each(function (comp) {
|
|
if (comp.hasConfigured(Disabling)) {
|
|
Disabling.set(comp, state);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var structure = {
|
|
dom: renderItemDomStructure(spec.label),
|
|
optComponents: [Optional.some({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
containerClass,
|
|
containerRowClass
|
|
]
|
|
},
|
|
components: render$2(spec.items, extras)
|
|
})]
|
|
};
|
|
return renderCommonItem({
|
|
data: buildData(__assign({ text: Optional.none() }, spec)),
|
|
disabled: spec.disabled,
|
|
getApi: getApi,
|
|
onAction: spec.onAction,
|
|
onSetup: spec.onSetup,
|
|
triggersSubmenu: false,
|
|
itemBehaviours: Optional.from(extras.itemBehaviours).getOr([])
|
|
}, structure, itemResponse, sharedBackstage.providers);
|
|
};
|
|
|
|
var renderChoiceItem = function (spec, useText, presets, onItemValueHandler, isSelected, itemResponse, providersBackstage, renderIcons) {
|
|
if (renderIcons === void 0) {
|
|
renderIcons = true;
|
|
}
|
|
var getApi = function (component) {
|
|
return {
|
|
setActive: function (state) {
|
|
Toggling.set(component, state);
|
|
},
|
|
isActive: function () {
|
|
return Toggling.isOn(component);
|
|
},
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(component, state);
|
|
}
|
|
};
|
|
};
|
|
var structure = renderItemStructure({
|
|
presets: presets,
|
|
textContent: useText ? spec.text : Optional.none(),
|
|
htmlContent: Optional.none(),
|
|
ariaLabel: spec.text,
|
|
iconContent: spec.icon,
|
|
shortcutContent: useText ? spec.shortcut : Optional.none(),
|
|
checkMark: useText ? Optional.some(renderCheckmark(providersBackstage.icons)) : Optional.none(),
|
|
caret: Optional.none(),
|
|
value: spec.value
|
|
}, providersBackstage, renderIcons);
|
|
return deepMerge(renderCommonItem({
|
|
data: buildData(spec),
|
|
disabled: spec.disabled,
|
|
getApi: getApi,
|
|
onAction: function (_api) {
|
|
return onItemValueHandler(spec.value);
|
|
},
|
|
onSetup: function (api) {
|
|
api.setActive(isSelected);
|
|
return noop;
|
|
},
|
|
triggersSubmenu: false,
|
|
itemBehaviours: []
|
|
}, structure, itemResponse, providersBackstage), {
|
|
toggling: {
|
|
toggleClass: tickedClass,
|
|
toggleOnExecute: false,
|
|
selected: spec.active
|
|
}
|
|
});
|
|
};
|
|
|
|
var parts$f = generate$3(owner$2(), parts$h());
|
|
|
|
var hexColour = function (value) {
|
|
return { value: value };
|
|
};
|
|
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
var longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
|
var isHexString = function (hex) {
|
|
return shorthandRegex.test(hex) || longformRegex.test(hex);
|
|
};
|
|
var normalizeHex = function (hex) {
|
|
return removeLeading(hex, '#').toUpperCase();
|
|
};
|
|
var fromString$1 = function (hex) {
|
|
return isHexString(hex) ? Optional.some({ value: normalizeHex(hex) }) : Optional.none();
|
|
};
|
|
var getLongForm = function (hex) {
|
|
var hexString = hex.value.replace(shorthandRegex, function (m, r, g, b) {
|
|
return r + r + g + g + b + b;
|
|
});
|
|
return { value: hexString };
|
|
};
|
|
var extractValues = function (hex) {
|
|
var longForm = getLongForm(hex);
|
|
var splitForm = longformRegex.exec(longForm.value);
|
|
return splitForm === null ? [
|
|
'FFFFFF',
|
|
'FF',
|
|
'FF',
|
|
'FF'
|
|
] : splitForm;
|
|
};
|
|
var toHex = function (component) {
|
|
var hex = component.toString(16);
|
|
return (hex.length === 1 ? '0' + hex : hex).toUpperCase();
|
|
};
|
|
var fromRgba = function (rgbaColour) {
|
|
var value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
|
|
return hexColour(value);
|
|
};
|
|
|
|
var min = Math.min;
|
|
var max = Math.max;
|
|
var round$1 = Math.round;
|
|
var rgbRegex = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)/;
|
|
var rgbaRegex = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d?(?:\.\d+)?)\)/;
|
|
var rgbaColour = function (red, green, blue, alpha) {
|
|
return {
|
|
red: red,
|
|
green: green,
|
|
blue: blue,
|
|
alpha: alpha
|
|
};
|
|
};
|
|
var isRgbaComponent = function (value) {
|
|
var num = parseInt(value, 10);
|
|
return num.toString() === value && num >= 0 && num <= 255;
|
|
};
|
|
var fromHsv = function (hsv) {
|
|
var r;
|
|
var g;
|
|
var b;
|
|
var hue = (hsv.hue || 0) % 360;
|
|
var saturation = hsv.saturation / 100;
|
|
var brightness = hsv.value / 100;
|
|
saturation = max(0, min(saturation, 1));
|
|
brightness = max(0, min(brightness, 1));
|
|
if (saturation === 0) {
|
|
r = g = b = round$1(255 * brightness);
|
|
return rgbaColour(r, g, b, 1);
|
|
}
|
|
var side = hue / 60;
|
|
var chroma = brightness * saturation;
|
|
var x = chroma * (1 - Math.abs(side % 2 - 1));
|
|
var match = brightness - chroma;
|
|
switch (Math.floor(side)) {
|
|
case 0:
|
|
r = chroma;
|
|
g = x;
|
|
b = 0;
|
|
break;
|
|
case 1:
|
|
r = x;
|
|
g = chroma;
|
|
b = 0;
|
|
break;
|
|
case 2:
|
|
r = 0;
|
|
g = chroma;
|
|
b = x;
|
|
break;
|
|
case 3:
|
|
r = 0;
|
|
g = x;
|
|
b = chroma;
|
|
break;
|
|
case 4:
|
|
r = x;
|
|
g = 0;
|
|
b = chroma;
|
|
break;
|
|
case 5:
|
|
r = chroma;
|
|
g = 0;
|
|
b = x;
|
|
break;
|
|
default:
|
|
r = g = b = 0;
|
|
}
|
|
r = round$1(255 * (r + match));
|
|
g = round$1(255 * (g + match));
|
|
b = round$1(255 * (b + match));
|
|
return rgbaColour(r, g, b, 1);
|
|
};
|
|
var fromHex = function (hexColour) {
|
|
var result = extractValues(hexColour);
|
|
var red = parseInt(result[1], 16);
|
|
var green = parseInt(result[2], 16);
|
|
var blue = parseInt(result[3], 16);
|
|
return rgbaColour(red, green, blue, 1);
|
|
};
|
|
var fromStringValues = function (red, green, blue, alpha) {
|
|
var r = parseInt(red, 10);
|
|
var g = parseInt(green, 10);
|
|
var b = parseInt(blue, 10);
|
|
var a = parseFloat(alpha);
|
|
return rgbaColour(r, g, b, a);
|
|
};
|
|
var fromString = function (rgbaString) {
|
|
if (rgbaString === 'transparent') {
|
|
return Optional.some(rgbaColour(0, 0, 0, 0));
|
|
}
|
|
var rgbMatch = rgbRegex.exec(rgbaString);
|
|
if (rgbMatch !== null) {
|
|
return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
|
|
}
|
|
var rgbaMatch = rgbaRegex.exec(rgbaString);
|
|
if (rgbaMatch !== null) {
|
|
return Optional.some(fromStringValues(rgbaMatch[1], rgbaMatch[2], rgbaMatch[3], rgbaMatch[4]));
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var toString = function (rgba) {
|
|
return 'rgba(' + rgba.red + ',' + rgba.green + ',' + rgba.blue + ',' + rgba.alpha + ')';
|
|
};
|
|
var red = rgbaColour(255, 0, 0, 1);
|
|
|
|
var fireSkinLoaded$1 = function (editor) {
|
|
return editor.fire('SkinLoaded');
|
|
};
|
|
var fireSkinLoadError$1 = function (editor, error) {
|
|
return editor.fire('SkinLoadError', error);
|
|
};
|
|
var fireResizeEditor = function (editor) {
|
|
return editor.fire('ResizeEditor');
|
|
};
|
|
var fireResizeContent = function (editor, e) {
|
|
return editor.fire('ResizeContent', e);
|
|
};
|
|
var fireScrollContent = function (editor, e) {
|
|
return editor.fire('ScrollContent', e);
|
|
};
|
|
var fireTextColorChange = function (editor, data) {
|
|
return editor.fire('TextColorChange', data);
|
|
};
|
|
|
|
var hsvColour = function (hue, saturation, value) {
|
|
return {
|
|
hue: hue,
|
|
saturation: saturation,
|
|
value: value
|
|
};
|
|
};
|
|
var fromRgb = function (rgbaColour) {
|
|
var h = 0;
|
|
var s = 0;
|
|
var v = 0;
|
|
var r = rgbaColour.red / 255;
|
|
var g = rgbaColour.green / 255;
|
|
var b = rgbaColour.blue / 255;
|
|
var minRGB = Math.min(r, Math.min(g, b));
|
|
var maxRGB = Math.max(r, Math.max(g, b));
|
|
if (minRGB === maxRGB) {
|
|
v = minRGB;
|
|
return hsvColour(0, 0, v * 100);
|
|
}
|
|
var d = r === minRGB ? g - b : b === minRGB ? r - g : b - r;
|
|
h = r === minRGB ? 3 : b === minRGB ? 1 : 5;
|
|
h = 60 * (h - d / (maxRGB - minRGB));
|
|
s = (maxRGB - minRGB) / maxRGB;
|
|
v = maxRGB;
|
|
return hsvColour(Math.round(h), Math.round(s * 100), Math.round(v * 100));
|
|
};
|
|
|
|
var hexToHsv = function (hex) {
|
|
return fromRgb(fromHex(hex));
|
|
};
|
|
var hsvToHex = function (hsv) {
|
|
return fromRgba(fromHsv(hsv));
|
|
};
|
|
var anyToHex = function (color) {
|
|
return fromString$1(color).orThunk(function () {
|
|
return fromString(color).map(fromRgba);
|
|
}).getOrThunk(function () {
|
|
var canvas = document.createElement('canvas');
|
|
canvas.height = 1;
|
|
canvas.width = 1;
|
|
var canvasContext = canvas.getContext('2d');
|
|
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
|
|
canvasContext.fillStyle = '#FFFFFF';
|
|
canvasContext.fillStyle = color;
|
|
canvasContext.fillRect(0, 0, 1, 1);
|
|
var rgba = canvasContext.getImageData(0, 0, 1, 1).data;
|
|
var r = rgba[0];
|
|
var g = rgba[1];
|
|
var b = rgba[2];
|
|
var a = rgba[3];
|
|
return fromRgba(rgbaColour(r, g, b, a));
|
|
});
|
|
};
|
|
|
|
var global$8 = tinymce.util.Tools.resolve('tinymce.util.LocalStorage');
|
|
|
|
var storageName = 'tinymce-custom-colors';
|
|
function ColorCache (max) {
|
|
if (max === void 0) {
|
|
max = 10;
|
|
}
|
|
var storageString = global$8.getItem(storageName);
|
|
var localstorage = isString(storageString) ? JSON.parse(storageString) : [];
|
|
var prune = function (list) {
|
|
var diff = max - list.length;
|
|
return diff < 0 ? list.slice(0, max) : list;
|
|
};
|
|
var cache = prune(localstorage);
|
|
var add = function (key) {
|
|
indexOf(cache, key).each(remove);
|
|
cache.unshift(key);
|
|
if (cache.length > max) {
|
|
cache.pop();
|
|
}
|
|
global$8.setItem(storageName, JSON.stringify(cache));
|
|
};
|
|
var remove = function (idx) {
|
|
cache.splice(idx, 1);
|
|
};
|
|
var state = function () {
|
|
return cache.slice(0);
|
|
};
|
|
return {
|
|
add: add,
|
|
state: state
|
|
};
|
|
}
|
|
|
|
var choiceItem = 'choiceitem';
|
|
var defaultColors = [
|
|
{
|
|
type: choiceItem,
|
|
text: 'Light Green',
|
|
value: '#BFEDD2'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Light Yellow',
|
|
value: '#FBEEB8'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Light Red',
|
|
value: '#F8CAC6'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Light Purple',
|
|
value: '#ECCAFA'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Light Blue',
|
|
value: '#C2E0F4'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Green',
|
|
value: '#2DC26B'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Yellow',
|
|
value: '#F1C40F'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Red',
|
|
value: '#E03E2D'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Purple',
|
|
value: '#B96AD9'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Blue',
|
|
value: '#3598DB'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Dark Turquoise',
|
|
value: '#169179'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Orange',
|
|
value: '#E67E23'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Dark Red',
|
|
value: '#BA372A'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Dark Purple',
|
|
value: '#843FA1'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Dark Blue',
|
|
value: '#236FA1'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Light Gray',
|
|
value: '#ECF0F1'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Medium Gray',
|
|
value: '#CED4D9'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Gray',
|
|
value: '#95A5A6'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Dark Gray',
|
|
value: '#7E8C8D'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Navy Blue',
|
|
value: '#34495E'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'Black',
|
|
value: '#000000'
|
|
},
|
|
{
|
|
type: choiceItem,
|
|
text: 'White',
|
|
value: '#ffffff'
|
|
}
|
|
];
|
|
var colorCache = ColorCache(10);
|
|
var mapColors = function (colorMap) {
|
|
var colors = [];
|
|
for (var i = 0; i < colorMap.length; i += 2) {
|
|
colors.push({
|
|
text: colorMap[i + 1],
|
|
value: '#' + anyToHex(colorMap[i]).value,
|
|
type: 'choiceitem'
|
|
});
|
|
}
|
|
return colors;
|
|
};
|
|
var getColorCols$2 = function (editor, defaultCols) {
|
|
return editor.getParam('color_cols', defaultCols, 'number');
|
|
};
|
|
var hasCustomColors$1 = function (editor) {
|
|
return editor.getParam('custom_colors') !== false;
|
|
};
|
|
var getColorMap = function (editor) {
|
|
return editor.getParam('color_map');
|
|
};
|
|
var getColors$2 = function (editor) {
|
|
var unmapped = getColorMap(editor);
|
|
return unmapped !== undefined ? mapColors(unmapped) : defaultColors;
|
|
};
|
|
var getCurrentColors = function () {
|
|
return map$2(colorCache.state(), function (color) {
|
|
return {
|
|
type: choiceItem,
|
|
text: color,
|
|
value: color
|
|
};
|
|
});
|
|
};
|
|
var addColor = function (color) {
|
|
colorCache.add(color);
|
|
};
|
|
|
|
var fallbackColor = '#000000';
|
|
var getCurrentColor = function (editor, format) {
|
|
var color;
|
|
editor.dom.getParents(editor.selection.getStart(), function (elm) {
|
|
var value;
|
|
if (value = elm.style[format === 'forecolor' ? 'color' : 'background-color']) {
|
|
color = color ? color : value;
|
|
}
|
|
});
|
|
return Optional.from(color);
|
|
};
|
|
var applyFormat = function (editor, format, value) {
|
|
editor.undoManager.transact(function () {
|
|
editor.focus();
|
|
editor.formatter.apply(format, { value: value });
|
|
editor.nodeChanged();
|
|
});
|
|
};
|
|
var removeFormat = function (editor, format) {
|
|
editor.undoManager.transact(function () {
|
|
editor.focus();
|
|
editor.formatter.remove(format, { value: null }, null, true);
|
|
editor.nodeChanged();
|
|
});
|
|
};
|
|
var registerCommands = function (editor) {
|
|
editor.addCommand('mceApplyTextcolor', function (format, value) {
|
|
applyFormat(editor, format, value);
|
|
});
|
|
editor.addCommand('mceRemoveTextcolor', function (format) {
|
|
removeFormat(editor, format);
|
|
});
|
|
};
|
|
var calcCols = function (colors) {
|
|
return Math.max(5, Math.ceil(Math.sqrt(colors)));
|
|
};
|
|
var getColorCols$1 = function (editor) {
|
|
var colors = getColors$2(editor);
|
|
var defaultCols = calcCols(colors.length);
|
|
return getColorCols$2(editor, defaultCols);
|
|
};
|
|
var getAdditionalColors = function (hasCustom) {
|
|
var type = 'choiceitem';
|
|
var remove = {
|
|
type: type,
|
|
text: 'Remove color',
|
|
icon: 'color-swatch-remove-color',
|
|
value: 'remove'
|
|
};
|
|
var custom = {
|
|
type: type,
|
|
text: 'Custom color',
|
|
icon: 'color-picker',
|
|
value: 'custom'
|
|
};
|
|
return hasCustom ? [
|
|
remove,
|
|
custom
|
|
] : [remove];
|
|
};
|
|
var applyColor = function (editor, format, value, onChoice) {
|
|
if (value === 'custom') {
|
|
var dialog = colorPickerDialog(editor);
|
|
dialog(function (colorOpt) {
|
|
colorOpt.each(function (color) {
|
|
addColor(color);
|
|
editor.execCommand('mceApplyTextcolor', format, color);
|
|
onChoice(color);
|
|
});
|
|
}, fallbackColor);
|
|
} else if (value === 'remove') {
|
|
onChoice('');
|
|
editor.execCommand('mceRemoveTextcolor', format);
|
|
} else {
|
|
onChoice(value);
|
|
editor.execCommand('mceApplyTextcolor', format, value);
|
|
}
|
|
};
|
|
var getColors$1 = function (colors, hasCustom) {
|
|
return colors.concat(getCurrentColors().concat(getAdditionalColors(hasCustom)));
|
|
};
|
|
var getFetch$1 = function (colors, hasCustom) {
|
|
return function (callback) {
|
|
callback(getColors$1(colors, hasCustom));
|
|
};
|
|
};
|
|
var setIconColor = function (splitButtonApi, name, newColor) {
|
|
var id = name === 'forecolor' ? 'tox-icon-text-color__color' : 'tox-icon-highlight-bg-color__color';
|
|
splitButtonApi.setIconFill(id, newColor);
|
|
};
|
|
var registerTextColorButton = function (editor, name, format, tooltip, lastColor) {
|
|
editor.ui.registry.addSplitButton(name, {
|
|
tooltip: tooltip,
|
|
presets: 'color',
|
|
icon: name === 'forecolor' ? 'text-color' : 'highlight-bg-color',
|
|
select: function (value) {
|
|
var optCurrentRgb = getCurrentColor(editor, format);
|
|
return optCurrentRgb.bind(function (currentRgb) {
|
|
return fromString(currentRgb).map(function (rgba) {
|
|
var currentHex = fromRgba(rgba).value;
|
|
return contains$1(value.toLowerCase(), currentHex);
|
|
});
|
|
}).getOr(false);
|
|
},
|
|
columns: getColorCols$1(editor),
|
|
fetch: getFetch$1(getColors$2(editor), hasCustomColors$1(editor)),
|
|
onAction: function (_splitButtonApi) {
|
|
applyColor(editor, format, lastColor.get(), noop);
|
|
},
|
|
onItemAction: function (_splitButtonApi, value) {
|
|
applyColor(editor, format, value, function (newColor) {
|
|
lastColor.set(newColor);
|
|
fireTextColorChange(editor, {
|
|
name: name,
|
|
color: newColor
|
|
});
|
|
});
|
|
},
|
|
onSetup: function (splitButtonApi) {
|
|
setIconColor(splitButtonApi, name, lastColor.get());
|
|
var handler = function (e) {
|
|
if (e.name === name) {
|
|
setIconColor(splitButtonApi, e.name, e.color);
|
|
}
|
|
};
|
|
editor.on('TextColorChange', handler);
|
|
return function () {
|
|
editor.off('TextColorChange', handler);
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var registerTextColorMenuItem = function (editor, name, format, text) {
|
|
editor.ui.registry.addNestedMenuItem(name, {
|
|
text: text,
|
|
icon: name === 'forecolor' ? 'text-color' : 'highlight-bg-color',
|
|
getSubmenuItems: function () {
|
|
return [{
|
|
type: 'fancymenuitem',
|
|
fancytype: 'colorswatch',
|
|
onAction: function (data) {
|
|
applyColor(editor, format, data.value, noop);
|
|
}
|
|
}];
|
|
}
|
|
});
|
|
};
|
|
var colorPickerDialog = function (editor) {
|
|
return function (callback, value) {
|
|
var isValid = false;
|
|
var onSubmit = function (api) {
|
|
var data = api.getData();
|
|
var hex = data.colorpicker;
|
|
if (isValid) {
|
|
callback(Optional.from(hex));
|
|
api.close();
|
|
} else {
|
|
editor.windowManager.alert(editor.translate([
|
|
'Invalid hex color code: {0}',
|
|
hex
|
|
]));
|
|
}
|
|
};
|
|
var onAction = function (_api, details) {
|
|
if (details.name === 'hex-valid') {
|
|
isValid = details.value;
|
|
}
|
|
};
|
|
var initialData = { colorpicker: value };
|
|
editor.windowManager.open({
|
|
title: 'Color Picker',
|
|
size: 'normal',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'colorpicker',
|
|
name: 'colorpicker',
|
|
label: 'Color'
|
|
}]
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: initialData,
|
|
onAction: onAction,
|
|
onSubmit: onSubmit,
|
|
onClose: noop,
|
|
onCancel: function () {
|
|
callback(Optional.none());
|
|
}
|
|
});
|
|
};
|
|
};
|
|
var register$a = function (editor) {
|
|
registerCommands(editor);
|
|
var lastForeColor = Cell(fallbackColor);
|
|
var lastBackColor = Cell(fallbackColor);
|
|
registerTextColorButton(editor, 'forecolor', 'forecolor', 'Text color', lastForeColor);
|
|
registerTextColorButton(editor, 'backcolor', 'hilitecolor', 'Background color', lastBackColor);
|
|
registerTextColorMenuItem(editor, 'forecolor', 'forecolor', 'Text color');
|
|
registerTextColorMenuItem(editor, 'backcolor', 'hilitecolor', 'Background color');
|
|
};
|
|
|
|
var createPartialChoiceMenu = function (value, items, onItemValueHandler, columns, presets, itemResponse, select, providersBackstage) {
|
|
var hasIcons = menuHasIcons(items);
|
|
var presetItemTypes = presets !== 'color' ? 'normal' : 'color';
|
|
var alloyItems = createChoiceItems(items, onItemValueHandler, columns, presetItemTypes, itemResponse, select, providersBackstage);
|
|
return createPartialMenuWithAlloyItems(value, hasIcons, alloyItems, columns, presets);
|
|
};
|
|
var createChoiceItems = function (items, onItemValueHandler, columns, itemPresets, itemResponse, select, providersBackstage) {
|
|
return cat(map$2(items, function (item) {
|
|
if (item.type === 'choiceitem') {
|
|
return createChoiceMenuItem(item).fold(handleError, function (d) {
|
|
return Optional.some(renderChoiceItem(d, columns === 1, itemPresets, onItemValueHandler, select(item.value), itemResponse, providersBackstage, menuHasIcons(items)));
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}));
|
|
};
|
|
|
|
var deriveMenuMovement = function (columns, presets) {
|
|
var menuMarkers = markers(presets);
|
|
if (columns === 1) {
|
|
return {
|
|
mode: 'menu',
|
|
moveOnTab: true
|
|
};
|
|
} else if (columns === 'auto') {
|
|
return {
|
|
mode: 'grid',
|
|
selector: '.' + menuMarkers.item,
|
|
initSize: {
|
|
numColumns: 1,
|
|
numRows: 1
|
|
}
|
|
};
|
|
} else {
|
|
var rowClass = presets === 'color' ? 'tox-swatches__row' : 'tox-collection__group';
|
|
return {
|
|
mode: 'matrix',
|
|
rowSelector: '.' + rowClass
|
|
};
|
|
}
|
|
};
|
|
var deriveCollectionMovement = function (columns, presets) {
|
|
if (columns === 1) {
|
|
return {
|
|
mode: 'menu',
|
|
moveOnTab: false,
|
|
selector: '.tox-collection__item'
|
|
};
|
|
} else if (columns === 'auto') {
|
|
return {
|
|
mode: 'flatgrid',
|
|
selector: '.' + 'tox-collection__item',
|
|
initSize: {
|
|
numColumns: 1,
|
|
numRows: 1
|
|
}
|
|
};
|
|
} else {
|
|
return {
|
|
mode: 'matrix',
|
|
selectors: {
|
|
row: presets === 'color' ? '.tox-swatches__row' : '.tox-collection__group',
|
|
cell: presets === 'color' ? '.' + colorClass : '.' + selectableClass
|
|
}
|
|
};
|
|
}
|
|
};
|
|
|
|
var renderColorSwatchItem = function (spec, backstage) {
|
|
var items = getColorItems(spec, backstage);
|
|
var columns = backstage.colorinput.getColorCols();
|
|
var presets = 'color';
|
|
var menuSpec = createPartialChoiceMenu(generate$6('menu-value'), items, function (value) {
|
|
spec.onAction({ value: value });
|
|
}, columns, presets, ItemResponse$1.CLOSE_ON_EXECUTE, never, backstage.shared.providers);
|
|
var widgetSpec = __assign(__assign({}, menuSpec), {
|
|
markers: markers(presets),
|
|
movement: deriveMenuMovement(columns, presets)
|
|
});
|
|
return {
|
|
type: 'widget',
|
|
data: { value: generate$6('widget-id') },
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-fancymenuitem']
|
|
},
|
|
autofocus: true,
|
|
components: [parts$f.widget(Menu.sketch(widgetSpec))]
|
|
};
|
|
};
|
|
var getColorItems = function (spec, backstage) {
|
|
var useCustomColors = spec.initData.allowCustomColors && backstage.colorinput.hasCustomColors();
|
|
return spec.initData.colors.fold(function () {
|
|
return getColors$1(backstage.colorinput.getColors(), useCustomColors);
|
|
}, function (colors) {
|
|
return colors.concat(getAdditionalColors(useCustomColors));
|
|
});
|
|
};
|
|
|
|
var cellOverEvent = generate$6('cell-over');
|
|
var cellExecuteEvent = generate$6('cell-execute');
|
|
var makeCell = function (row, col, labelId) {
|
|
var _a;
|
|
var emitCellOver = function (c) {
|
|
return emitWith(c, cellOverEvent, {
|
|
row: row,
|
|
col: col
|
|
});
|
|
};
|
|
var emitExecute = function (c) {
|
|
return emitWith(c, cellExecuteEvent, {
|
|
row: row,
|
|
col: col
|
|
});
|
|
};
|
|
var onClick = function (c, se) {
|
|
se.stop();
|
|
emitExecute(c);
|
|
};
|
|
return build$1({
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: (_a = { role: 'button' }, _a['aria-labelledby'] = labelId, _a)
|
|
},
|
|
behaviours: derive$1([
|
|
config('insert-table-picker-cell', [
|
|
run$1(mouseover(), Focusing.focus),
|
|
run$1(execute$5(), emitExecute),
|
|
run$1(click(), onClick),
|
|
run$1(tap(), onClick)
|
|
]),
|
|
Toggling.config({
|
|
toggleClass: 'tox-insert-table-picker__selected',
|
|
toggleOnExecute: false
|
|
}),
|
|
Focusing.config({ onFocus: emitCellOver })
|
|
])
|
|
});
|
|
};
|
|
var makeCells = function (labelId, numRows, numCols) {
|
|
var cells = [];
|
|
for (var i = 0; i < numRows; i++) {
|
|
var row = [];
|
|
for (var j = 0; j < numCols; j++) {
|
|
row.push(makeCell(i, j, labelId));
|
|
}
|
|
cells.push(row);
|
|
}
|
|
return cells;
|
|
};
|
|
var selectCells = function (cells, selectedRow, selectedColumn, numRows, numColumns) {
|
|
for (var i = 0; i < numRows; i++) {
|
|
for (var j = 0; j < numColumns; j++) {
|
|
Toggling.set(cells[i][j], i <= selectedRow && j <= selectedColumn);
|
|
}
|
|
}
|
|
};
|
|
var makeComponents = function (cells) {
|
|
return bind$3(cells, function (cellRow) {
|
|
return map$2(cellRow, premade);
|
|
});
|
|
};
|
|
var makeLabelText = function (row, col) {
|
|
return text(col + 'x' + row);
|
|
};
|
|
var renderInsertTableMenuItem = function (spec) {
|
|
var numRows = 10;
|
|
var numColumns = 10;
|
|
var sizeLabelId = generate$6('size-label');
|
|
var cells = makeCells(sizeLabelId, numRows, numColumns);
|
|
var emptyLabelText = makeLabelText(0, 0);
|
|
var memLabel = record({
|
|
dom: {
|
|
tag: 'span',
|
|
classes: ['tox-insert-table-picker__label'],
|
|
attributes: { id: sizeLabelId }
|
|
},
|
|
components: [emptyLabelText],
|
|
behaviours: derive$1([Replacing.config({})])
|
|
});
|
|
return {
|
|
type: 'widget',
|
|
data: { value: generate$6('widget-id') },
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-fancymenuitem']
|
|
},
|
|
autofocus: true,
|
|
components: [parts$f.widget({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-insert-table-picker']
|
|
},
|
|
components: makeComponents(cells).concat(memLabel.asSpec()),
|
|
behaviours: derive$1([
|
|
config('insert-table-picker', [
|
|
runOnAttached(function (c) {
|
|
Replacing.set(memLabel.get(c), [emptyLabelText]);
|
|
}),
|
|
runWithTarget(cellOverEvent, function (c, t, e) {
|
|
var _a = e.event, row = _a.row, col = _a.col;
|
|
selectCells(cells, row, col, numRows, numColumns);
|
|
Replacing.set(memLabel.get(c), [makeLabelText(row + 1, col + 1)]);
|
|
}),
|
|
runWithTarget(cellExecuteEvent, function (c, _, e) {
|
|
var _a = e.event, row = _a.row, col = _a.col;
|
|
spec.onAction({
|
|
numRows: row + 1,
|
|
numColumns: col + 1
|
|
});
|
|
emit(c, sandboxClose());
|
|
})
|
|
]),
|
|
Keying.config({
|
|
initSize: {
|
|
numRows: numRows,
|
|
numColumns: numColumns
|
|
},
|
|
mode: 'flatgrid',
|
|
selector: '[role="button"]'
|
|
})
|
|
])
|
|
})]
|
|
};
|
|
};
|
|
|
|
var fancyMenuItems = {
|
|
inserttable: renderInsertTableMenuItem,
|
|
colorswatch: renderColorSwatchItem
|
|
};
|
|
var renderFancyMenuItem = function (spec, backstage) {
|
|
return get$e(fancyMenuItems, spec.fancytype).map(function (render) {
|
|
return render(spec, backstage);
|
|
});
|
|
};
|
|
|
|
var renderNestedItem = function (spec, itemResponse, providersBackstage, renderIcons, downwardsCaret) {
|
|
if (renderIcons === void 0) {
|
|
renderIcons = true;
|
|
}
|
|
if (downwardsCaret === void 0) {
|
|
downwardsCaret = false;
|
|
}
|
|
var caret = downwardsCaret ? renderDownwardsCaret(providersBackstage.icons) : renderSubmenuCaret(providersBackstage.icons);
|
|
var getApi = function (component) {
|
|
return {
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(component, state);
|
|
}
|
|
};
|
|
};
|
|
var structure = renderItemStructure({
|
|
presets: 'normal',
|
|
iconContent: spec.icon,
|
|
textContent: spec.text,
|
|
htmlContent: Optional.none(),
|
|
ariaLabel: spec.text,
|
|
caret: Optional.some(caret),
|
|
checkMark: Optional.none(),
|
|
shortcutContent: spec.shortcut
|
|
}, providersBackstage, renderIcons);
|
|
return renderCommonItem({
|
|
data: buildData(spec),
|
|
getApi: getApi,
|
|
disabled: spec.disabled,
|
|
onAction: noop,
|
|
onSetup: spec.onSetup,
|
|
triggersSubmenu: true,
|
|
itemBehaviours: []
|
|
}, structure, itemResponse, providersBackstage);
|
|
};
|
|
|
|
var renderNormalItem = function (spec, itemResponse, providersBackstage, renderIcons) {
|
|
if (renderIcons === void 0) {
|
|
renderIcons = true;
|
|
}
|
|
var getApi = function (component) {
|
|
return {
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(component, state);
|
|
}
|
|
};
|
|
};
|
|
var structure = renderItemStructure({
|
|
presets: 'normal',
|
|
iconContent: spec.icon,
|
|
textContent: spec.text,
|
|
htmlContent: Optional.none(),
|
|
ariaLabel: spec.text,
|
|
caret: Optional.none(),
|
|
checkMark: Optional.none(),
|
|
shortcutContent: spec.shortcut
|
|
}, providersBackstage, renderIcons);
|
|
return renderCommonItem({
|
|
data: buildData(spec),
|
|
getApi: getApi,
|
|
disabled: spec.disabled,
|
|
onAction: spec.onAction,
|
|
onSetup: spec.onSetup,
|
|
triggersSubmenu: false,
|
|
itemBehaviours: []
|
|
}, structure, itemResponse, providersBackstage);
|
|
};
|
|
|
|
var renderSeparatorItem = function (spec) {
|
|
var innerHtml = spec.text.fold(function () {
|
|
return {};
|
|
}, function (text) {
|
|
return { innerHtml: text };
|
|
});
|
|
return {
|
|
type: 'separator',
|
|
dom: __assign({
|
|
tag: 'div',
|
|
classes: [
|
|
selectableClass,
|
|
groupHeadingClass
|
|
]
|
|
}, innerHtml),
|
|
components: []
|
|
};
|
|
};
|
|
|
|
var renderToggleMenuItem = function (spec, itemResponse, providersBackstage, renderIcons) {
|
|
if (renderIcons === void 0) {
|
|
renderIcons = true;
|
|
}
|
|
var getApi = function (component) {
|
|
return {
|
|
setActive: function (state) {
|
|
Toggling.set(component, state);
|
|
},
|
|
isActive: function () {
|
|
return Toggling.isOn(component);
|
|
},
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(component, state);
|
|
}
|
|
};
|
|
};
|
|
var structure = renderItemStructure({
|
|
iconContent: spec.icon,
|
|
textContent: spec.text,
|
|
htmlContent: Optional.none(),
|
|
ariaLabel: spec.text,
|
|
checkMark: Optional.some(renderCheckmark(providersBackstage.icons)),
|
|
caret: Optional.none(),
|
|
shortcutContent: spec.shortcut,
|
|
presets: 'normal',
|
|
meta: spec.meta
|
|
}, providersBackstage, renderIcons);
|
|
return deepMerge(renderCommonItem({
|
|
data: buildData(spec),
|
|
disabled: spec.disabled,
|
|
getApi: getApi,
|
|
onAction: spec.onAction,
|
|
onSetup: spec.onSetup,
|
|
triggersSubmenu: false,
|
|
itemBehaviours: []
|
|
}, structure, itemResponse, providersBackstage), {
|
|
toggling: {
|
|
toggleClass: tickedClass,
|
|
toggleOnExecute: false,
|
|
selected: spec.active
|
|
}
|
|
});
|
|
};
|
|
|
|
var autocomplete = renderAutocompleteItem;
|
|
var separator$3 = renderSeparatorItem;
|
|
var normal = renderNormalItem;
|
|
var nested = renderNestedItem;
|
|
var toggle$1 = renderToggleMenuItem;
|
|
var fancy = renderFancyMenuItem;
|
|
var card = renderCardMenuItem;
|
|
|
|
var FocusMode;
|
|
(function (FocusMode) {
|
|
FocusMode[FocusMode['ContentFocus'] = 0] = 'ContentFocus';
|
|
FocusMode[FocusMode['UiFocus'] = 1] = 'UiFocus';
|
|
}(FocusMode || (FocusMode = {})));
|
|
var createMenuItemFromBridge = function (item, itemResponse, backstage, menuHasIcons, isHorizontalMenu) {
|
|
var providersBackstage = backstage.shared.providers;
|
|
var parseForHorizontalMenu = function (menuitem) {
|
|
return !isHorizontalMenu ? menuitem : __assign(__assign({}, menuitem), {
|
|
shortcut: Optional.none(),
|
|
icon: menuitem.text.isSome() ? Optional.none() : menuitem.icon
|
|
});
|
|
};
|
|
switch (item.type) {
|
|
case 'menuitem':
|
|
return createMenuItem(item).fold(handleError, function (d) {
|
|
return Optional.some(normal(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons));
|
|
});
|
|
case 'nestedmenuitem':
|
|
return createNestedMenuItem(item).fold(handleError, function (d) {
|
|
return Optional.some(nested(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons, isHorizontalMenu));
|
|
});
|
|
case 'togglemenuitem':
|
|
return createToggleMenuItem(item).fold(handleError, function (d) {
|
|
return Optional.some(toggle$1(parseForHorizontalMenu(d), itemResponse, providersBackstage, menuHasIcons));
|
|
});
|
|
case 'separator':
|
|
return createSeparatorMenuItem(item).fold(handleError, function (d) {
|
|
return Optional.some(separator$3(d));
|
|
});
|
|
case 'fancymenuitem':
|
|
return createFancyMenuItem(item).fold(handleError, function (d) {
|
|
return fancy(parseForHorizontalMenu(d), backstage);
|
|
});
|
|
default: {
|
|
console.error('Unknown item in general menu', item);
|
|
return Optional.none();
|
|
}
|
|
}
|
|
};
|
|
var createAutocompleteItems = function (items, matchText, onItemValueHandler, columns, itemResponse, sharedBackstage, highlightOn) {
|
|
var renderText = columns === 1;
|
|
var renderIcons = !renderText || menuHasIcons(items);
|
|
return cat(map$2(items, function (item) {
|
|
switch (item.type) {
|
|
case 'separator':
|
|
return createSeparatorItem(item).fold(handleError, function (d) {
|
|
return Optional.some(separator$3(d));
|
|
});
|
|
case 'cardmenuitem':
|
|
return createCardMenuItem(item).fold(handleError, function (d) {
|
|
return Optional.some(card(__assign(__assign({}, d), {
|
|
onAction: function (api) {
|
|
d.onAction(api);
|
|
onItemValueHandler(d.value, d.meta);
|
|
}
|
|
}), itemResponse, sharedBackstage, {
|
|
itemBehaviours: tooltipBehaviour(d.meta, sharedBackstage),
|
|
cardText: {
|
|
matchText: matchText,
|
|
highlightOn: highlightOn
|
|
}
|
|
}));
|
|
});
|
|
case 'autocompleteitem':
|
|
default:
|
|
return createAutocompleterItem(item).fold(handleError, function (d) {
|
|
return Optional.some(autocomplete(d, matchText, renderText, 'normal', onItemValueHandler, itemResponse, sharedBackstage, renderIcons));
|
|
});
|
|
}
|
|
}));
|
|
};
|
|
var createPartialMenu = function (value, items, itemResponse, backstage, isHorizontalMenu) {
|
|
var hasIcons = menuHasIcons(items);
|
|
var alloyItems = cat(map$2(items, function (item) {
|
|
var itemHasIcon = function (i) {
|
|
return isHorizontalMenu ? !has$2(i, 'text') : hasIcons;
|
|
};
|
|
var createItem = function (i) {
|
|
return createMenuItemFromBridge(i, itemResponse, backstage, itemHasIcon(i), isHorizontalMenu);
|
|
};
|
|
if (item.type === 'nestedmenuitem' && item.getSubmenuItems().length <= 0) {
|
|
return createItem(__assign(__assign({}, item), { disabled: true }));
|
|
} else {
|
|
return createItem(item);
|
|
}
|
|
}));
|
|
var createPartial = isHorizontalMenu ? createHorizontalPartialMenuWithAlloyItems : createPartialMenuWithAlloyItems;
|
|
return createPartial(value, hasIcons, alloyItems, 1, 'normal');
|
|
};
|
|
var createTieredDataFrom = function (partialMenu) {
|
|
return tieredMenu.singleData(partialMenu.value, partialMenu);
|
|
};
|
|
var createMenuFrom = function (partialMenu, columns, focusMode, presets) {
|
|
var focusManager = focusMode === FocusMode.ContentFocus ? highlights() : dom$2();
|
|
var movement = deriveMenuMovement(columns, presets);
|
|
var menuMarkers = markers(presets);
|
|
return {
|
|
dom: partialMenu.dom,
|
|
components: partialMenu.components,
|
|
items: partialMenu.items,
|
|
value: partialMenu.value,
|
|
markers: {
|
|
selectedItem: menuMarkers.selectedItem,
|
|
item: menuMarkers.item
|
|
},
|
|
movement: movement,
|
|
fakeFocus: focusMode === FocusMode.ContentFocus,
|
|
focusManager: focusManager,
|
|
menuBehaviours: SimpleBehaviours.unnamedEvents(columns !== 'auto' ? [] : [runOnAttached(function (comp, _se) {
|
|
detectSize(comp, 4, menuMarkers.item).each(function (_a) {
|
|
var numColumns = _a.numColumns, numRows = _a.numRows;
|
|
Keying.setGridSize(comp, numRows, numColumns);
|
|
});
|
|
})])
|
|
};
|
|
};
|
|
|
|
var register$9 = function (editor, sharedBackstage) {
|
|
var activeAutocompleter = value$1();
|
|
var processingAction = Cell(false);
|
|
var autocompleter = build$1(InlineView.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-autocompleter']
|
|
},
|
|
components: [],
|
|
fireDismissalEventInstead: {},
|
|
inlineBehaviours: derive$1([config('dismissAutocompleter', [run$1(dismissRequested(), function () {
|
|
return cancelIfNecessary();
|
|
})])]),
|
|
lazySink: sharedBackstage.getSink
|
|
}));
|
|
var isMenuOpen = function () {
|
|
return InlineView.isOpen(autocompleter);
|
|
};
|
|
var isActive = function () {
|
|
return activeAutocompleter.get().isSome();
|
|
};
|
|
var hideIfNecessary = function () {
|
|
if (isActive()) {
|
|
InlineView.hide(autocompleter);
|
|
}
|
|
};
|
|
var cancelIfNecessary = function () {
|
|
if (isActive()) {
|
|
var lastElement = activeAutocompleter.get().map(function (ac) {
|
|
return ac.element;
|
|
});
|
|
detect(lastElement.getOr(SugarElement.fromDom(editor.selection.getNode()))).each(unwrap);
|
|
hideIfNecessary();
|
|
activeAutocompleter.clear();
|
|
processingAction.set(false);
|
|
}
|
|
};
|
|
var getAutocompleters = cached(function () {
|
|
return register$b(editor);
|
|
});
|
|
var getCombinedItems = function (triggerChar, matches) {
|
|
var columns = findMap(matches, function (m) {
|
|
return Optional.from(m.columns);
|
|
}).getOr(1);
|
|
return bind$3(matches, function (match) {
|
|
var choices = match.items;
|
|
return createAutocompleteItems(choices, match.matchText, function (itemValue, itemMeta) {
|
|
var nr = editor.selection.getRng();
|
|
getContext(editor.dom, nr, triggerChar).fold(function () {
|
|
return console.error('Lost context. Cursor probably moved');
|
|
}, function (_a) {
|
|
var range = _a.range;
|
|
var autocompleterApi = {
|
|
hide: function () {
|
|
cancelIfNecessary();
|
|
},
|
|
reload: function (fetchOptions) {
|
|
hideIfNecessary();
|
|
load(fetchOptions);
|
|
}
|
|
};
|
|
processingAction.set(true);
|
|
match.onAction(autocompleterApi, range, itemValue, itemMeta);
|
|
processingAction.set(false);
|
|
});
|
|
}, columns, ItemResponse$1.BUBBLE_TO_SANDBOX, sharedBackstage, match.highlightOn);
|
|
});
|
|
};
|
|
var commenceIfNecessary = function (context) {
|
|
if (!isActive()) {
|
|
var wrapper = create$4(editor, context.range);
|
|
activeAutocompleter.set({
|
|
triggerChar: context.triggerChar,
|
|
element: wrapper,
|
|
matchLength: context.text.length
|
|
});
|
|
processingAction.set(false);
|
|
}
|
|
};
|
|
var display = function (ac, context, lookupData, items) {
|
|
ac.matchLength = context.text.length;
|
|
var columns = findMap(lookupData, function (ld) {
|
|
return Optional.from(ld.columns);
|
|
}).getOr(1);
|
|
InlineView.showAt(autocompleter, Menu.sketch(createMenuFrom(createPartialMenuWithAlloyItems('autocompleter-value', true, items, columns, 'normal'), columns, FocusMode.ContentFocus, 'normal')), {
|
|
anchor: {
|
|
type: 'node',
|
|
root: SugarElement.fromDom(editor.getBody()),
|
|
node: Optional.from(ac.element)
|
|
}
|
|
});
|
|
InlineView.getContent(autocompleter).each(Highlighting.highlightFirst);
|
|
};
|
|
var doLookup = function (fetchOptions) {
|
|
return activeAutocompleter.get().map(function (ac) {
|
|
return getContext(editor.dom, editor.selection.getRng(), ac.triggerChar).bind(function (newContext) {
|
|
return lookupWithContext(editor, getAutocompleters, newContext, fetchOptions);
|
|
});
|
|
}).getOrThunk(function () {
|
|
return lookup$2(editor, getAutocompleters);
|
|
});
|
|
};
|
|
var load = function (fetchOptions) {
|
|
doLookup(fetchOptions).fold(cancelIfNecessary, function (lookupInfo) {
|
|
commenceIfNecessary(lookupInfo.context);
|
|
lookupInfo.lookupData.then(function (lookupData) {
|
|
activeAutocompleter.get().map(function (ac) {
|
|
var context = lookupInfo.context;
|
|
if (ac.triggerChar === context.triggerChar) {
|
|
var combinedItems = getCombinedItems(context.triggerChar, lookupData);
|
|
if (combinedItems.length > 0) {
|
|
display(ac, context, lookupData, combinedItems);
|
|
} else if (context.text.length - ac.matchLength >= 10) {
|
|
cancelIfNecessary();
|
|
} else {
|
|
hideIfNecessary();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var onKeypress = last(function (e) {
|
|
if (e.which === 27) {
|
|
return;
|
|
}
|
|
load();
|
|
}, 50);
|
|
var autocompleterUiApi = {
|
|
onKeypress: onKeypress,
|
|
cancelIfNecessary: cancelIfNecessary,
|
|
isMenuOpen: isMenuOpen,
|
|
isActive: isActive,
|
|
isProcessingAction: processingAction.get,
|
|
getView: function () {
|
|
return InlineView.getContent(autocompleter);
|
|
}
|
|
};
|
|
if (editor.hasPlugin('rtc') === false) {
|
|
AutocompleterEditorEvents.setup(autocompleterUiApi, editor);
|
|
}
|
|
};
|
|
var Autocompleter = { register: register$9 };
|
|
|
|
var closest = function (scope, selector, isRoot) {
|
|
return closest$1(scope, selector, isRoot).isSome();
|
|
};
|
|
|
|
var DelayedFunction = function (fun, delay) {
|
|
var ref = null;
|
|
var schedule = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
ref = setTimeout(function () {
|
|
fun.apply(null, args);
|
|
ref = null;
|
|
}, delay);
|
|
};
|
|
var cancel = function () {
|
|
if (ref !== null) {
|
|
clearTimeout(ref);
|
|
ref = null;
|
|
}
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
schedule: schedule
|
|
};
|
|
};
|
|
|
|
var SIGNIFICANT_MOVE = 5;
|
|
var LONGPRESS_DELAY = 400;
|
|
var getTouch = function (event) {
|
|
var raw = event.raw;
|
|
if (raw.touches === undefined || raw.touches.length !== 1) {
|
|
return Optional.none();
|
|
}
|
|
return Optional.some(raw.touches[0]);
|
|
};
|
|
var isFarEnough = function (touch, data) {
|
|
var distX = Math.abs(touch.clientX - data.x);
|
|
var distY = Math.abs(touch.clientY - data.y);
|
|
return distX > SIGNIFICANT_MOVE || distY > SIGNIFICANT_MOVE;
|
|
};
|
|
var monitor = function (settings) {
|
|
var startData = value$1();
|
|
var longpressFired = Cell(false);
|
|
var longpress$1 = DelayedFunction(function (event) {
|
|
settings.triggerEvent(longpress(), event);
|
|
longpressFired.set(true);
|
|
}, LONGPRESS_DELAY);
|
|
var handleTouchstart = function (event) {
|
|
getTouch(event).each(function (touch) {
|
|
longpress$1.cancel();
|
|
var data = {
|
|
x: touch.clientX,
|
|
y: touch.clientY,
|
|
target: event.target
|
|
};
|
|
longpress$1.schedule(event);
|
|
longpressFired.set(false);
|
|
startData.set(data);
|
|
});
|
|
return Optional.none();
|
|
};
|
|
var handleTouchmove = function (event) {
|
|
longpress$1.cancel();
|
|
getTouch(event).each(function (touch) {
|
|
startData.on(function (data) {
|
|
if (isFarEnough(touch, data)) {
|
|
startData.clear();
|
|
}
|
|
});
|
|
});
|
|
return Optional.none();
|
|
};
|
|
var handleTouchend = function (event) {
|
|
longpress$1.cancel();
|
|
var isSame = function (data) {
|
|
return eq(data.target, event.target);
|
|
};
|
|
return startData.get().filter(isSame).map(function (_data) {
|
|
if (longpressFired.get()) {
|
|
event.prevent();
|
|
return false;
|
|
} else {
|
|
return settings.triggerEvent(tap(), event);
|
|
}
|
|
});
|
|
};
|
|
var handlers = wrapAll([
|
|
{
|
|
key: touchstart(),
|
|
value: handleTouchstart
|
|
},
|
|
{
|
|
key: touchmove(),
|
|
value: handleTouchmove
|
|
},
|
|
{
|
|
key: touchend(),
|
|
value: handleTouchend
|
|
}
|
|
]);
|
|
var fireIfReady = function (event, type) {
|
|
return get$e(handlers, type).bind(function (handler) {
|
|
return handler(event);
|
|
});
|
|
};
|
|
return { fireIfReady: fireIfReady };
|
|
};
|
|
|
|
var isDangerous = function (event) {
|
|
var keyEv = event.raw;
|
|
return keyEv.which === BACKSPACE[0] && !contains$2([
|
|
'input',
|
|
'textarea'
|
|
], name$2(event.target)) && !closest(event.target, '[contenteditable="true"]');
|
|
};
|
|
var isFirefox = function () {
|
|
return detect$1().browser.isFirefox();
|
|
};
|
|
var bindFocus = function (container, handler) {
|
|
if (isFirefox()) {
|
|
return capture(container, 'focus', handler);
|
|
} else {
|
|
return bind(container, 'focusin', handler);
|
|
}
|
|
};
|
|
var bindBlur = function (container, handler) {
|
|
if (isFirefox()) {
|
|
return capture(container, 'blur', handler);
|
|
} else {
|
|
return bind(container, 'focusout', handler);
|
|
}
|
|
};
|
|
var setup$d = function (container, rawSettings) {
|
|
var settings = __assign({ stopBackspace: true }, rawSettings);
|
|
var pointerEvents = [
|
|
'touchstart',
|
|
'touchmove',
|
|
'touchend',
|
|
'touchcancel',
|
|
'gesturestart',
|
|
'mousedown',
|
|
'mouseup',
|
|
'mouseover',
|
|
'mousemove',
|
|
'mouseout',
|
|
'click'
|
|
];
|
|
var tapEvent = monitor(settings);
|
|
var simpleEvents = map$2(pointerEvents.concat([
|
|
'selectstart',
|
|
'input',
|
|
'contextmenu',
|
|
'change',
|
|
'transitionend',
|
|
'transitioncancel',
|
|
'drag',
|
|
'dragstart',
|
|
'dragend',
|
|
'dragenter',
|
|
'dragleave',
|
|
'dragover',
|
|
'drop',
|
|
'keyup'
|
|
]), function (type) {
|
|
return bind(container, type, function (event) {
|
|
tapEvent.fireIfReady(event, type).each(function (tapStopped) {
|
|
if (tapStopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
var stopped = settings.triggerEvent(type, event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
});
|
|
var pasteTimeout = value$1();
|
|
var onPaste = bind(container, 'paste', function (event) {
|
|
tapEvent.fireIfReady(event, 'paste').each(function (tapStopped) {
|
|
if (tapStopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
var stopped = settings.triggerEvent('paste', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
pasteTimeout.set(setTimeout(function () {
|
|
settings.triggerEvent(postPaste(), event);
|
|
}, 0));
|
|
});
|
|
var onKeydown = bind(container, 'keydown', function (event) {
|
|
var stopped = settings.triggerEvent('keydown', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
} else if (settings.stopBackspace && isDangerous(event)) {
|
|
event.prevent();
|
|
}
|
|
});
|
|
var onFocusIn = bindFocus(container, function (event) {
|
|
var stopped = settings.triggerEvent('focusin', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
var focusoutTimeout = value$1();
|
|
var onFocusOut = bindBlur(container, function (event) {
|
|
var stopped = settings.triggerEvent('focusout', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
focusoutTimeout.set(setTimeout(function () {
|
|
settings.triggerEvent(postBlur(), event);
|
|
}, 0));
|
|
});
|
|
var unbind = function () {
|
|
each$1(simpleEvents, function (e) {
|
|
e.unbind();
|
|
});
|
|
onKeydown.unbind();
|
|
onFocusIn.unbind();
|
|
onFocusOut.unbind();
|
|
onPaste.unbind();
|
|
pasteTimeout.on(clearTimeout);
|
|
focusoutTimeout.on(clearTimeout);
|
|
};
|
|
return { unbind: unbind };
|
|
};
|
|
|
|
var derive = function (rawEvent, rawTarget) {
|
|
var source = get$e(rawEvent, 'target').getOr(rawTarget);
|
|
return Cell(source);
|
|
};
|
|
|
|
var fromSource = function (event, source) {
|
|
var stopper = Cell(false);
|
|
var cutter = Cell(false);
|
|
var stop = function () {
|
|
stopper.set(true);
|
|
};
|
|
var cut = function () {
|
|
cutter.set(true);
|
|
};
|
|
return {
|
|
stop: stop,
|
|
cut: cut,
|
|
isStopped: stopper.get,
|
|
isCut: cutter.get,
|
|
event: event,
|
|
setSource: source.set,
|
|
getSource: source.get
|
|
};
|
|
};
|
|
var fromExternal = function (event) {
|
|
var stopper = Cell(false);
|
|
var stop = function () {
|
|
stopper.set(true);
|
|
};
|
|
return {
|
|
stop: stop,
|
|
cut: noop,
|
|
isStopped: stopper.get,
|
|
isCut: never,
|
|
event: event,
|
|
setSource: die('Cannot set source of a broadcasted event'),
|
|
getSource: die('Cannot get source of a broadcasted event')
|
|
};
|
|
};
|
|
|
|
var adt$1 = Adt.generate([
|
|
{ stopped: [] },
|
|
{ resume: ['element'] },
|
|
{ complete: [] }
|
|
]);
|
|
var doTriggerHandler = function (lookup, eventType, rawEvent, target, source, logger) {
|
|
var handler = lookup(eventType, target);
|
|
var simulatedEvent = fromSource(rawEvent, source);
|
|
return handler.fold(function () {
|
|
logger.logEventNoHandlers(eventType, target);
|
|
return adt$1.complete();
|
|
}, function (handlerInfo) {
|
|
var descHandler = handlerInfo.descHandler;
|
|
var eventHandler = getCurried(descHandler);
|
|
eventHandler(simulatedEvent);
|
|
if (simulatedEvent.isStopped()) {
|
|
logger.logEventStopped(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt$1.stopped();
|
|
} else if (simulatedEvent.isCut()) {
|
|
logger.logEventCut(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt$1.complete();
|
|
} else {
|
|
return parent(handlerInfo.element).fold(function () {
|
|
logger.logNoParent(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt$1.complete();
|
|
}, function (parent) {
|
|
logger.logEventResponse(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt$1.resume(parent);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var doTriggerOnUntilStopped = function (lookup, eventType, rawEvent, rawTarget, source, logger) {
|
|
return doTriggerHandler(lookup, eventType, rawEvent, rawTarget, source, logger).fold(always, function (parent) {
|
|
return doTriggerOnUntilStopped(lookup, eventType, rawEvent, parent, source, logger);
|
|
}, never);
|
|
};
|
|
var triggerHandler = function (lookup, eventType, rawEvent, target, logger) {
|
|
var source = derive(rawEvent, target);
|
|
return doTriggerHandler(lookup, eventType, rawEvent, target, source, logger);
|
|
};
|
|
var broadcast = function (listeners, rawEvent, _logger) {
|
|
var simulatedEvent = fromExternal(rawEvent);
|
|
each$1(listeners, function (listener) {
|
|
var descHandler = listener.descHandler;
|
|
var handler = getCurried(descHandler);
|
|
handler(simulatedEvent);
|
|
});
|
|
return simulatedEvent.isStopped();
|
|
};
|
|
var triggerUntilStopped = function (lookup, eventType, rawEvent, logger) {
|
|
return triggerOnUntilStopped(lookup, eventType, rawEvent, rawEvent.target, logger);
|
|
};
|
|
var triggerOnUntilStopped = function (lookup, eventType, rawEvent, rawTarget, logger) {
|
|
var source = derive(rawEvent, rawTarget);
|
|
return doTriggerOnUntilStopped(lookup, eventType, rawEvent, rawTarget, source, logger);
|
|
};
|
|
|
|
var eventHandler = function (element, descHandler) {
|
|
return {
|
|
element: element,
|
|
descHandler: descHandler
|
|
};
|
|
};
|
|
var broadcastHandler = function (id, handler) {
|
|
return {
|
|
id: id,
|
|
descHandler: handler
|
|
};
|
|
};
|
|
var EventRegistry = function () {
|
|
var registry = {};
|
|
var registerId = function (extraArgs, id, events) {
|
|
each(events, function (v, k) {
|
|
var handlers = registry[k] !== undefined ? registry[k] : {};
|
|
handlers[id] = curryArgs(v, extraArgs);
|
|
registry[k] = handlers;
|
|
});
|
|
};
|
|
var findHandler = function (handlers, elem) {
|
|
return read$1(elem).bind(function (id) {
|
|
return get$e(handlers, id);
|
|
}).map(function (descHandler) {
|
|
return eventHandler(elem, descHandler);
|
|
});
|
|
};
|
|
var filterByType = function (type) {
|
|
return get$e(registry, type).map(function (handlers) {
|
|
return mapToArray(handlers, function (f, id) {
|
|
return broadcastHandler(id, f);
|
|
});
|
|
}).getOr([]);
|
|
};
|
|
var find = function (isAboveRoot, type, target) {
|
|
return get$e(registry, type).bind(function (handlers) {
|
|
return closest$4(target, function (elem) {
|
|
return findHandler(handlers, elem);
|
|
}, isAboveRoot);
|
|
});
|
|
};
|
|
var unregisterId = function (id) {
|
|
each(registry, function (handlersById, _eventName) {
|
|
if (has$2(handlersById, id)) {
|
|
delete handlersById[id];
|
|
}
|
|
});
|
|
};
|
|
return {
|
|
registerId: registerId,
|
|
unregisterId: unregisterId,
|
|
filterByType: filterByType,
|
|
find: find
|
|
};
|
|
};
|
|
|
|
var Registry = function () {
|
|
var events = EventRegistry();
|
|
var components = {};
|
|
var readOrTag = function (component) {
|
|
var elem = component.element;
|
|
return read$1(elem).getOrThunk(function () {
|
|
return write('uid-', component.element);
|
|
});
|
|
};
|
|
var failOnDuplicate = function (component, tagId) {
|
|
var conflict = components[tagId];
|
|
if (conflict === component) {
|
|
unregister(component);
|
|
} else {
|
|
throw new Error('The tagId "' + tagId + '" is already used by: ' + element(conflict.element) + '\nCannot use it for: ' + element(component.element) + '\n' + 'The conflicting element is' + (inBody(conflict.element) ? ' ' : ' not ') + 'already in the DOM');
|
|
}
|
|
};
|
|
var register = function (component) {
|
|
var tagId = readOrTag(component);
|
|
if (hasNonNullableKey(components, tagId)) {
|
|
failOnDuplicate(component, tagId);
|
|
}
|
|
var extraArgs = [component];
|
|
events.registerId(extraArgs, tagId, component.events);
|
|
components[tagId] = component;
|
|
};
|
|
var unregister = function (component) {
|
|
read$1(component.element).each(function (tagId) {
|
|
delete components[tagId];
|
|
events.unregisterId(tagId);
|
|
});
|
|
};
|
|
var filter = function (type) {
|
|
return events.filterByType(type);
|
|
};
|
|
var find = function (isAboveRoot, type, target) {
|
|
return events.find(isAboveRoot, type, target);
|
|
};
|
|
var getById = function (id) {
|
|
return get$e(components, id);
|
|
};
|
|
return {
|
|
find: find,
|
|
filter: filter,
|
|
register: register,
|
|
unregister: unregister,
|
|
getById: getById
|
|
};
|
|
};
|
|
|
|
var factory$j = function (detail) {
|
|
var _a = detail.dom, attributes = _a.attributes, domWithoutAttributes = __rest(_a, ['attributes']);
|
|
return {
|
|
uid: detail.uid,
|
|
dom: __assign({
|
|
tag: 'div',
|
|
attributes: __assign({ role: 'presentation' }, attributes)
|
|
}, domWithoutAttributes),
|
|
components: detail.components,
|
|
behaviours: get$2(detail.containerBehaviours),
|
|
events: detail.events,
|
|
domModification: detail.domModification,
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var Container = single({
|
|
name: 'Container',
|
|
factory: factory$j,
|
|
configFields: [
|
|
defaulted('components', []),
|
|
field('containerBehaviours', []),
|
|
defaulted('events', {}),
|
|
defaulted('domModification', {}),
|
|
defaulted('eventOrder', {})
|
|
]
|
|
});
|
|
|
|
var takeover = function (root) {
|
|
var isAboveRoot = function (el) {
|
|
return parent(root.element).fold(always, function (parent) {
|
|
return eq(el, parent);
|
|
});
|
|
};
|
|
var registry = Registry();
|
|
var lookup = function (eventName, target) {
|
|
return registry.find(isAboveRoot, eventName, target);
|
|
};
|
|
var domEvents = setup$d(root.element, {
|
|
triggerEvent: function (eventName, event) {
|
|
return monitorEvent(eventName, event.target, function (logger) {
|
|
return triggerUntilStopped(lookup, eventName, event, logger);
|
|
});
|
|
}
|
|
});
|
|
var systemApi = {
|
|
debugInfo: constant$1('real'),
|
|
triggerEvent: function (eventName, target, data) {
|
|
monitorEvent(eventName, target, function (logger) {
|
|
return triggerOnUntilStopped(lookup, eventName, data, target, logger);
|
|
});
|
|
},
|
|
triggerFocus: function (target, originator) {
|
|
read$1(target).fold(function () {
|
|
focus$3(target);
|
|
}, function (_alloyId) {
|
|
monitorEvent(focus$4(), target, function (logger) {
|
|
triggerHandler(lookup, focus$4(), {
|
|
originator: originator,
|
|
kill: noop,
|
|
prevent: noop,
|
|
target: target
|
|
}, target, logger);
|
|
return false;
|
|
});
|
|
});
|
|
},
|
|
triggerEscape: function (comp, simulatedEvent) {
|
|
systemApi.triggerEvent('keydown', comp.element, simulatedEvent.event);
|
|
},
|
|
getByUid: function (uid) {
|
|
return getByUid(uid);
|
|
},
|
|
getByDom: function (elem) {
|
|
return getByDom(elem);
|
|
},
|
|
build: build$1,
|
|
addToGui: function (c) {
|
|
add(c);
|
|
},
|
|
removeFromGui: function (c) {
|
|
remove(c);
|
|
},
|
|
addToWorld: function (c) {
|
|
addToWorld(c);
|
|
},
|
|
removeFromWorld: function (c) {
|
|
removeFromWorld(c);
|
|
},
|
|
broadcast: function (message) {
|
|
broadcast$1(message);
|
|
},
|
|
broadcastOn: function (channels, message) {
|
|
broadcastOn(channels, message);
|
|
},
|
|
broadcastEvent: function (eventName, event) {
|
|
broadcastEvent(eventName, event);
|
|
},
|
|
isConnected: always
|
|
};
|
|
var addToWorld = function (component) {
|
|
component.connect(systemApi);
|
|
if (!isText$1(component.element)) {
|
|
registry.register(component);
|
|
each$1(component.components(), addToWorld);
|
|
systemApi.triggerEvent(systemInit(), component.element, { target: component.element });
|
|
}
|
|
};
|
|
var removeFromWorld = function (component) {
|
|
if (!isText$1(component.element)) {
|
|
each$1(component.components(), removeFromWorld);
|
|
registry.unregister(component);
|
|
}
|
|
component.disconnect();
|
|
};
|
|
var add = function (component) {
|
|
attach(root, component);
|
|
};
|
|
var remove = function (component) {
|
|
detach(component);
|
|
};
|
|
var destroy = function () {
|
|
domEvents.unbind();
|
|
remove$5(root.element);
|
|
};
|
|
var broadcastData = function (data) {
|
|
var receivers = registry.filter(receive());
|
|
each$1(receivers, function (receiver) {
|
|
var descHandler = receiver.descHandler;
|
|
var handler = getCurried(descHandler);
|
|
handler(data);
|
|
});
|
|
};
|
|
var broadcast$1 = function (message) {
|
|
broadcastData({
|
|
universal: true,
|
|
data: message
|
|
});
|
|
};
|
|
var broadcastOn = function (channels, message) {
|
|
broadcastData({
|
|
universal: false,
|
|
channels: channels,
|
|
data: message
|
|
});
|
|
};
|
|
var broadcastEvent = function (eventName, event) {
|
|
var listeners = registry.filter(eventName);
|
|
return broadcast(listeners, event);
|
|
};
|
|
var getByUid = function (uid) {
|
|
return registry.getById(uid).fold(function () {
|
|
return Result.error(new Error('Could not find component with uid: "' + uid + '" in system.'));
|
|
}, Result.value);
|
|
};
|
|
var getByDom = function (elem) {
|
|
var uid = read$1(elem).getOr('not found');
|
|
return getByUid(uid);
|
|
};
|
|
addToWorld(root);
|
|
return {
|
|
root: root,
|
|
element: root.element,
|
|
destroy: destroy,
|
|
add: add,
|
|
remove: remove,
|
|
getByUid: getByUid,
|
|
getByDom: getByDom,
|
|
addToWorld: addToWorld,
|
|
removeFromWorld: removeFromWorld,
|
|
broadcast: broadcast$1,
|
|
broadcastOn: broadcastOn,
|
|
broadcastEvent: broadcastEvent
|
|
};
|
|
};
|
|
|
|
var renderBar = function (spec, backstage) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-bar',
|
|
'tox-form__controls-h-stack'
|
|
]
|
|
},
|
|
components: map$2(spec.items, backstage.interpreter)
|
|
};
|
|
};
|
|
|
|
var schema$l = constant$1([
|
|
defaulted('prefix', 'form-field'),
|
|
field('fieldBehaviours', [
|
|
Composing,
|
|
Representing
|
|
])
|
|
]);
|
|
var parts$e = constant$1([
|
|
optional({
|
|
schema: [required$1('dom')],
|
|
name: 'label'
|
|
}),
|
|
optional({
|
|
factory: {
|
|
sketch: function (spec) {
|
|
return {
|
|
uid: spec.uid,
|
|
dom: {
|
|
tag: 'span',
|
|
styles: { display: 'none' },
|
|
attributes: { 'aria-hidden': 'true' },
|
|
innerHtml: spec.text
|
|
}
|
|
};
|
|
}
|
|
},
|
|
schema: [required$1('text')],
|
|
name: 'aria-descriptor'
|
|
}),
|
|
required({
|
|
factory: {
|
|
sketch: function (spec) {
|
|
var excludeFactory = exclude(spec, ['factory']);
|
|
return spec.factory.sketch(excludeFactory);
|
|
}
|
|
},
|
|
schema: [required$1('factory')],
|
|
name: 'field'
|
|
})
|
|
]);
|
|
|
|
var factory$i = function (detail, components, _spec, _externals) {
|
|
var behaviours = augment(detail.fieldBehaviours, [
|
|
Composing.config({
|
|
find: function (container) {
|
|
return getPart(container, detail, 'field');
|
|
}
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (field) {
|
|
return Composing.getCurrent(field).bind(Representing.getValue);
|
|
},
|
|
setValue: function (field, value) {
|
|
Composing.getCurrent(field).each(function (current) {
|
|
Representing.setValue(current, value);
|
|
});
|
|
}
|
|
}
|
|
})
|
|
]);
|
|
var events = derive$2([runOnAttached(function (component, _simulatedEvent) {
|
|
var ps = getParts(component, detail, [
|
|
'label',
|
|
'field',
|
|
'aria-descriptor'
|
|
]);
|
|
ps.field().each(function (field) {
|
|
var id = generate$6(detail.prefix);
|
|
ps.label().each(function (label) {
|
|
set$8(label.element, 'for', id);
|
|
set$8(field.element, 'id', id);
|
|
});
|
|
ps['aria-descriptor']().each(function (descriptor) {
|
|
var descriptorId = generate$6(detail.prefix);
|
|
set$8(descriptor.element, 'id', descriptorId);
|
|
set$8(field.element, 'aria-describedby', descriptorId);
|
|
});
|
|
});
|
|
})]);
|
|
var apis = {
|
|
getField: function (container) {
|
|
return getPart(container, detail, 'field');
|
|
},
|
|
getLabel: function (container) {
|
|
return getPart(container, detail, 'label');
|
|
}
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: behaviours,
|
|
events: events,
|
|
apis: apis
|
|
};
|
|
};
|
|
var FormField = composite({
|
|
name: 'FormField',
|
|
configFields: schema$l(),
|
|
partFields: parts$e(),
|
|
factory: factory$i,
|
|
apis: {
|
|
getField: function (apis, comp) {
|
|
return apis.getField(comp);
|
|
},
|
|
getLabel: function (apis, comp) {
|
|
return apis.getLabel(comp);
|
|
}
|
|
}
|
|
});
|
|
|
|
var exhibit$2 = function (base, tabConfig) {
|
|
return nu$7({
|
|
attributes: wrapAll([{
|
|
key: tabConfig.tabAttr,
|
|
value: 'true'
|
|
}])
|
|
});
|
|
};
|
|
|
|
var ActiveTabstopping = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$2
|
|
});
|
|
|
|
var TabstopSchema = [defaulted('tabAttr', 'data-alloy-tabstop')];
|
|
|
|
var Tabstopping = create$7({
|
|
fields: TabstopSchema,
|
|
name: 'tabstopping',
|
|
active: ActiveTabstopping
|
|
});
|
|
|
|
var global$7 = tinymce.util.Tools.resolve('tinymce.html.Entities');
|
|
|
|
var renderFormFieldWith = function (pLabel, pField, extraClasses, extraBehaviours) {
|
|
var spec = renderFormFieldSpecWith(pLabel, pField, extraClasses, extraBehaviours);
|
|
return FormField.sketch(spec);
|
|
};
|
|
var renderFormField = function (pLabel, pField) {
|
|
return renderFormFieldWith(pLabel, pField, [], []);
|
|
};
|
|
var renderFormFieldSpecWith = function (pLabel, pField, extraClasses, extraBehaviours) {
|
|
return {
|
|
dom: renderFormFieldDomWith(extraClasses),
|
|
components: pLabel.toArray().concat([pField]),
|
|
fieldBehaviours: derive$1(extraBehaviours)
|
|
};
|
|
};
|
|
var renderFormFieldDom = function () {
|
|
return renderFormFieldDomWith([]);
|
|
};
|
|
var renderFormFieldDomWith = function (extraClasses) {
|
|
return {
|
|
tag: 'div',
|
|
classes: ['tox-form__group'].concat(extraClasses)
|
|
};
|
|
};
|
|
var renderLabel$2 = function (label, providersBackstage) {
|
|
return FormField.parts.label({
|
|
dom: {
|
|
tag: 'label',
|
|
classes: ['tox-label'],
|
|
innerHtml: providersBackstage.translate(label)
|
|
}
|
|
});
|
|
};
|
|
|
|
var formChangeEvent = generate$6('form-component-change');
|
|
var formCloseEvent = generate$6('form-close');
|
|
var formCancelEvent = generate$6('form-cancel');
|
|
var formActionEvent = generate$6('form-action');
|
|
var formSubmitEvent = generate$6('form-submit');
|
|
var formBlockEvent = generate$6('form-block');
|
|
var formUnblockEvent = generate$6('form-unblock');
|
|
var formTabChangeEvent = generate$6('form-tabchange');
|
|
var formResizeEvent = generate$6('form-resize');
|
|
|
|
var renderCollection = function (spec, providersBackstage) {
|
|
var _a;
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, providersBackstage);
|
|
});
|
|
var runOnItem = function (f) {
|
|
return function (comp, se) {
|
|
closest$1(se.event.target, '[data-collection-item-value]').each(function (target) {
|
|
f(comp, se, target, get$d(target, 'data-collection-item-value'));
|
|
});
|
|
};
|
|
};
|
|
var setContents = function (comp, items) {
|
|
var htmlLines = map$2(items, function (item) {
|
|
var itemText = global$e.translate(item.text);
|
|
var textContent = spec.columns === 1 ? '<div class="tox-collection__item-label">' + itemText + '</div>' : '';
|
|
var iconContent = '<div class="tox-collection__item-icon">' + item.icon + '</div>';
|
|
var mapItemName = {
|
|
'_': ' ',
|
|
' - ': ' ',
|
|
'-': ' '
|
|
};
|
|
var ariaLabel = itemText.replace(/\_| \- |\-/g, function (match) {
|
|
return mapItemName[match];
|
|
});
|
|
var disabledClass = providersBackstage.isDisabled() ? ' tox-collection__item--state-disabled' : '';
|
|
return '<div class="tox-collection__item' + disabledClass + '" tabindex="-1" data-collection-item-value="' + global$7.encodeAllRaw(item.value) + '" title="' + ariaLabel + '" aria-label="' + ariaLabel + '">' + iconContent + textContent + '</div>';
|
|
});
|
|
var chunks = spec.columns !== 'auto' && spec.columns > 1 ? chunk$1(htmlLines, spec.columns) : [htmlLines];
|
|
var html = map$2(chunks, function (ch) {
|
|
return '<div class="tox-collection__group">' + ch.join('') + '</div>';
|
|
});
|
|
set$5(comp.element, html.join(''));
|
|
};
|
|
var onClick = runOnItem(function (comp, se, tgt, itemValue) {
|
|
se.stop();
|
|
if (!providersBackstage.isDisabled()) {
|
|
emitWith(comp, formActionEvent, {
|
|
name: spec.name,
|
|
value: itemValue
|
|
});
|
|
}
|
|
});
|
|
var collectionEvents = [
|
|
run$1(mouseover(), runOnItem(function (comp, se, tgt) {
|
|
focus$3(tgt);
|
|
})),
|
|
run$1(click(), onClick),
|
|
run$1(tap(), onClick),
|
|
run$1(focusin(), runOnItem(function (comp, se, tgt) {
|
|
descendant(comp.element, '.' + activeClass).each(function (currentActive) {
|
|
remove$2(currentActive, activeClass);
|
|
});
|
|
add$2(tgt, activeClass);
|
|
})),
|
|
run$1(focusout(), runOnItem(function (comp) {
|
|
descendant(comp.element, '.' + activeClass).each(function (currentActive) {
|
|
remove$2(currentActive, activeClass);
|
|
});
|
|
})),
|
|
runOnExecute$1(runOnItem(function (comp, se, tgt, itemValue) {
|
|
emitWith(comp, formActionEvent, {
|
|
name: spec.name,
|
|
value: itemValue
|
|
});
|
|
}))
|
|
];
|
|
var iterCollectionItems = function (comp, applyAttributes) {
|
|
return map$2(descendants(comp.element, '.tox-collection__item'), applyAttributes);
|
|
};
|
|
var pField = FormField.parts.field({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-collection'].concat(spec.columns !== 1 ? ['tox-collection--grid'] : ['tox-collection--list'])
|
|
},
|
|
components: [],
|
|
factory: { sketch: identity$1 },
|
|
behaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: providersBackstage.isDisabled,
|
|
onDisabled: function (comp) {
|
|
iterCollectionItems(comp, function (childElm) {
|
|
add$2(childElm, 'tox-collection__item--state-disabled');
|
|
set$8(childElm, 'aria-disabled', true);
|
|
});
|
|
},
|
|
onEnabled: function (comp) {
|
|
iterCollectionItems(comp, function (childElm) {
|
|
remove$2(childElm, 'tox-collection__item--state-disabled');
|
|
remove$7(childElm, 'aria-disabled');
|
|
});
|
|
}
|
|
}),
|
|
receivingConfig(),
|
|
Replacing.config({}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: []
|
|
},
|
|
onSetValue: function (comp, items) {
|
|
setContents(comp, items);
|
|
if (spec.columns === 'auto') {
|
|
detectSize(comp, 5, 'tox-collection__item').each(function (_a) {
|
|
var numRows = _a.numRows, numColumns = _a.numColumns;
|
|
Keying.setGridSize(comp, numRows, numColumns);
|
|
});
|
|
}
|
|
emit(comp, formResizeEvent);
|
|
}
|
|
}),
|
|
Tabstopping.config({}),
|
|
Keying.config(deriveCollectionMovement(spec.columns, 'normal')),
|
|
config('collection-events', collectionEvents)
|
|
]),
|
|
eventOrder: (_a = {}, _a[execute$5()] = [
|
|
'disabling',
|
|
'alloy.base.behaviour',
|
|
'collection-events'
|
|
], _a)
|
|
});
|
|
var extraClasses = ['tox-form__group--collection'];
|
|
return renderFormFieldWith(pLabel, pField, extraClasses, []);
|
|
};
|
|
|
|
var schema$k = constant$1([
|
|
option('data'),
|
|
defaulted('inputAttributes', {}),
|
|
defaulted('inputStyles', {}),
|
|
defaulted('tag', 'input'),
|
|
defaulted('inputClasses', []),
|
|
onHandler('onSetValue'),
|
|
defaulted('styles', {}),
|
|
defaulted('eventOrder', {}),
|
|
field('inputBehaviours', [
|
|
Representing,
|
|
Focusing
|
|
]),
|
|
defaulted('selectOnFocus', true)
|
|
]);
|
|
var focusBehaviours = function (detail) {
|
|
return derive$1([Focusing.config({
|
|
onFocus: !detail.selectOnFocus ? noop : function (component) {
|
|
var input = component.element;
|
|
var value = get$5(input);
|
|
input.dom.setSelectionRange(0, value.length);
|
|
}
|
|
})]);
|
|
};
|
|
var behaviours = function (detail) {
|
|
return __assign(__assign({}, focusBehaviours(detail)), augment(detail.inputBehaviours, [Representing.config({
|
|
store: __assign(__assign({ mode: 'manual' }, detail.data.map(function (data) {
|
|
return { initialValue: data };
|
|
}).getOr({})), {
|
|
getValue: function (input) {
|
|
return get$5(input.element);
|
|
},
|
|
setValue: function (input, data) {
|
|
var current = get$5(input.element);
|
|
if (current !== data) {
|
|
set$4(input.element, data);
|
|
}
|
|
}
|
|
}),
|
|
onSetValue: detail.onSetValue
|
|
})]));
|
|
};
|
|
var dom = function (detail) {
|
|
return {
|
|
tag: detail.tag,
|
|
attributes: __assign({ type: 'text' }, detail.inputAttributes),
|
|
styles: detail.inputStyles,
|
|
classes: detail.inputClasses
|
|
};
|
|
};
|
|
|
|
var factory$h = function (detail, _spec) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: dom(detail),
|
|
components: [],
|
|
behaviours: behaviours(detail),
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var Input = single({
|
|
name: 'Input',
|
|
configFields: schema$k(),
|
|
factory: factory$h
|
|
});
|
|
|
|
var exports$1 = {}, module = { exports: exports$1 };
|
|
(function (define, exports, module, require) {
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EphoxContactWrapper = factory());
|
|
}(this, function () {
|
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
var promise = { exports: {} };
|
|
(function (module) {
|
|
(function (root) {
|
|
var setTimeoutFunc = setTimeout;
|
|
function noop() {
|
|
}
|
|
function bind(fn, thisArg) {
|
|
return function () {
|
|
fn.apply(thisArg, arguments);
|
|
};
|
|
}
|
|
function Promise(fn) {
|
|
if (typeof this !== 'object')
|
|
throw new TypeError('Promises must be constructed via new');
|
|
if (typeof fn !== 'function')
|
|
throw new TypeError('not a function');
|
|
this._state = 0;
|
|
this._handled = false;
|
|
this._value = undefined;
|
|
this._deferreds = [];
|
|
doResolve(fn, this);
|
|
}
|
|
function handle(self, deferred) {
|
|
while (self._state === 3) {
|
|
self = self._value;
|
|
}
|
|
if (self._state === 0) {
|
|
self._deferreds.push(deferred);
|
|
return;
|
|
}
|
|
self._handled = true;
|
|
Promise._immediateFn(function () {
|
|
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
|
|
if (cb === null) {
|
|
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
|
|
return;
|
|
}
|
|
var ret;
|
|
try {
|
|
ret = cb(self._value);
|
|
} catch (e) {
|
|
reject(deferred.promise, e);
|
|
return;
|
|
}
|
|
resolve(deferred.promise, ret);
|
|
});
|
|
}
|
|
function resolve(self, newValue) {
|
|
try {
|
|
if (newValue === self)
|
|
throw new TypeError('A promise cannot be resolved with itself.');
|
|
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
|
var then = newValue.then;
|
|
if (newValue instanceof Promise) {
|
|
self._state = 3;
|
|
self._value = newValue;
|
|
finale(self);
|
|
return;
|
|
} else if (typeof then === 'function') {
|
|
doResolve(bind(then, newValue), self);
|
|
return;
|
|
}
|
|
}
|
|
self._state = 1;
|
|
self._value = newValue;
|
|
finale(self);
|
|
} catch (e) {
|
|
reject(self, e);
|
|
}
|
|
}
|
|
function reject(self, newValue) {
|
|
self._state = 2;
|
|
self._value = newValue;
|
|
finale(self);
|
|
}
|
|
function finale(self) {
|
|
if (self._state === 2 && self._deferreds.length === 0) {
|
|
Promise._immediateFn(function () {
|
|
if (!self._handled) {
|
|
Promise._unhandledRejectionFn(self._value);
|
|
}
|
|
});
|
|
}
|
|
for (var i = 0, len = self._deferreds.length; i < len; i++) {
|
|
handle(self, self._deferreds[i]);
|
|
}
|
|
self._deferreds = null;
|
|
}
|
|
function Handler(onFulfilled, onRejected, promise) {
|
|
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
|
|
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
|
|
this.promise = promise;
|
|
}
|
|
function doResolve(fn, self) {
|
|
var done = false;
|
|
try {
|
|
fn(function (value) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
resolve(self, value);
|
|
}, function (reason) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
reject(self, reason);
|
|
});
|
|
} catch (ex) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
reject(self, ex);
|
|
}
|
|
}
|
|
Promise.prototype['catch'] = function (onRejected) {
|
|
return this.then(null, onRejected);
|
|
};
|
|
Promise.prototype.then = function (onFulfilled, onRejected) {
|
|
var prom = new this.constructor(noop);
|
|
handle(this, new Handler(onFulfilled, onRejected, prom));
|
|
return prom;
|
|
};
|
|
Promise.all = function (arr) {
|
|
var args = Array.prototype.slice.call(arr);
|
|
return new Promise(function (resolve, reject) {
|
|
if (args.length === 0)
|
|
return resolve([]);
|
|
var remaining = args.length;
|
|
function res(i, val) {
|
|
try {
|
|
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
var then = val.then;
|
|
if (typeof then === 'function') {
|
|
then.call(val, function (val) {
|
|
res(i, val);
|
|
}, reject);
|
|
return;
|
|
}
|
|
}
|
|
args[i] = val;
|
|
if (--remaining === 0) {
|
|
resolve(args);
|
|
}
|
|
} catch (ex) {
|
|
reject(ex);
|
|
}
|
|
}
|
|
for (var i = 0; i < args.length; i++) {
|
|
res(i, args[i]);
|
|
}
|
|
});
|
|
};
|
|
Promise.resolve = function (value) {
|
|
if (value && typeof value === 'object' && value.constructor === Promise) {
|
|
return value;
|
|
}
|
|
return new Promise(function (resolve) {
|
|
resolve(value);
|
|
});
|
|
};
|
|
Promise.reject = function (value) {
|
|
return new Promise(function (resolve, reject) {
|
|
reject(value);
|
|
});
|
|
};
|
|
Promise.race = function (values) {
|
|
return new Promise(function (resolve, reject) {
|
|
for (var i = 0, len = values.length; i < len; i++) {
|
|
values[i].then(resolve, reject);
|
|
}
|
|
});
|
|
};
|
|
Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {
|
|
setImmediate(fn);
|
|
} : function (fn) {
|
|
setTimeoutFunc(fn, 0);
|
|
};
|
|
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
|
|
if (typeof console !== 'undefined' && console) {
|
|
console.warn('Possible Unhandled Promise Rejection:', err);
|
|
}
|
|
};
|
|
Promise._setImmediateFn = function _setImmediateFn(fn) {
|
|
Promise._immediateFn = fn;
|
|
};
|
|
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
|
|
Promise._unhandledRejectionFn = fn;
|
|
};
|
|
if (module.exports) {
|
|
module.exports = Promise;
|
|
} else if (!root.Promise) {
|
|
root.Promise = Promise;
|
|
}
|
|
}(commonjsGlobal));
|
|
}(promise));
|
|
var promisePolyfill = promise.exports;
|
|
var Global = function () {
|
|
if (typeof window !== 'undefined') {
|
|
return window;
|
|
} else {
|
|
return Function('return this;')();
|
|
}
|
|
}();
|
|
var promisePolyfill_1 = { boltExport: Global.Promise || promisePolyfill };
|
|
return promisePolyfill_1;
|
|
}));
|
|
}(undefined, exports$1, module));
|
|
var Promise$1 = module.exports.boltExport;
|
|
|
|
var nu$3 = function (baseFn) {
|
|
var data = Optional.none();
|
|
var callbacks = [];
|
|
var map = function (f) {
|
|
return nu$3(function (nCallback) {
|
|
get(function (data) {
|
|
nCallback(f(data));
|
|
});
|
|
});
|
|
};
|
|
var get = function (nCallback) {
|
|
if (isReady()) {
|
|
call(nCallback);
|
|
} else {
|
|
callbacks.push(nCallback);
|
|
}
|
|
};
|
|
var set = function (x) {
|
|
if (!isReady()) {
|
|
data = Optional.some(x);
|
|
run(callbacks);
|
|
callbacks = [];
|
|
}
|
|
};
|
|
var isReady = function () {
|
|
return data.isSome();
|
|
};
|
|
var run = function (cbs) {
|
|
each$1(cbs, call);
|
|
};
|
|
var call = function (cb) {
|
|
data.each(function (x) {
|
|
setTimeout(function () {
|
|
cb(x);
|
|
}, 0);
|
|
});
|
|
};
|
|
baseFn(set);
|
|
return {
|
|
get: get,
|
|
map: map,
|
|
isReady: isReady
|
|
};
|
|
};
|
|
var pure$1 = function (a) {
|
|
return nu$3(function (callback) {
|
|
callback(a);
|
|
});
|
|
};
|
|
var LazyValue = {
|
|
nu: nu$3,
|
|
pure: pure$1
|
|
};
|
|
|
|
var errorReporter = function (err) {
|
|
setTimeout(function () {
|
|
throw err;
|
|
}, 0);
|
|
};
|
|
var make$5 = function (run) {
|
|
var get = function (callback) {
|
|
run().then(callback, errorReporter);
|
|
};
|
|
var map = function (fab) {
|
|
return make$5(function () {
|
|
return run().then(fab);
|
|
});
|
|
};
|
|
var bind = function (aFutureB) {
|
|
return make$5(function () {
|
|
return run().then(function (v) {
|
|
return aFutureB(v).toPromise();
|
|
});
|
|
});
|
|
};
|
|
var anonBind = function (futureB) {
|
|
return make$5(function () {
|
|
return run().then(function () {
|
|
return futureB.toPromise();
|
|
});
|
|
});
|
|
};
|
|
var toLazy = function () {
|
|
return LazyValue.nu(get);
|
|
};
|
|
var toCached = function () {
|
|
var cache = null;
|
|
return make$5(function () {
|
|
if (cache === null) {
|
|
cache = run();
|
|
}
|
|
return cache;
|
|
});
|
|
};
|
|
var toPromise = run;
|
|
return {
|
|
map: map,
|
|
bind: bind,
|
|
anonBind: anonBind,
|
|
toLazy: toLazy,
|
|
toCached: toCached,
|
|
toPromise: toPromise,
|
|
get: get
|
|
};
|
|
};
|
|
var nu$2 = function (baseFn) {
|
|
return make$5(function () {
|
|
return new Promise$1(baseFn);
|
|
});
|
|
};
|
|
var pure = function (a) {
|
|
return make$5(function () {
|
|
return Promise$1.resolve(a);
|
|
});
|
|
};
|
|
var Future = {
|
|
nu: nu$2,
|
|
pure: pure
|
|
};
|
|
|
|
var ariaElements = [
|
|
'input',
|
|
'textarea'
|
|
];
|
|
var isAriaElement = function (elem) {
|
|
var name = name$2(elem);
|
|
return contains$2(ariaElements, name);
|
|
};
|
|
var markValid = function (component, invalidConfig) {
|
|
var elem = invalidConfig.getRoot(component).getOr(component.element);
|
|
remove$2(elem, invalidConfig.invalidClass);
|
|
invalidConfig.notify.each(function (notifyInfo) {
|
|
if (isAriaElement(component.element)) {
|
|
set$8(component.element, 'aria-invalid', false);
|
|
}
|
|
notifyInfo.getContainer(component).each(function (container) {
|
|
set$5(container, notifyInfo.validHtml);
|
|
});
|
|
notifyInfo.onValid(component);
|
|
});
|
|
};
|
|
var markInvalid = function (component, invalidConfig, invalidState, text) {
|
|
var elem = invalidConfig.getRoot(component).getOr(component.element);
|
|
add$2(elem, invalidConfig.invalidClass);
|
|
invalidConfig.notify.each(function (notifyInfo) {
|
|
if (isAriaElement(component.element)) {
|
|
set$8(component.element, 'aria-invalid', true);
|
|
}
|
|
notifyInfo.getContainer(component).each(function (container) {
|
|
set$5(container, text);
|
|
});
|
|
notifyInfo.onInvalid(component, text);
|
|
});
|
|
};
|
|
var query = function (component, invalidConfig, _invalidState) {
|
|
return invalidConfig.validator.fold(function () {
|
|
return Future.pure(Result.value(true));
|
|
}, function (validatorInfo) {
|
|
return validatorInfo.validate(component);
|
|
});
|
|
};
|
|
var run = function (component, invalidConfig, invalidState) {
|
|
invalidConfig.notify.each(function (notifyInfo) {
|
|
notifyInfo.onValidate(component);
|
|
});
|
|
return query(component, invalidConfig).map(function (valid) {
|
|
if (component.getSystem().isConnected()) {
|
|
return valid.fold(function (err) {
|
|
markInvalid(component, invalidConfig, invalidState, err);
|
|
return Result.error(err);
|
|
}, function (v) {
|
|
markValid(component, invalidConfig);
|
|
return Result.value(v);
|
|
});
|
|
} else {
|
|
return Result.error('No longer in system');
|
|
}
|
|
});
|
|
};
|
|
var isInvalid = function (component, invalidConfig) {
|
|
var elem = invalidConfig.getRoot(component).getOr(component.element);
|
|
return has(elem, invalidConfig.invalidClass);
|
|
};
|
|
|
|
var InvalidateApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
markValid: markValid,
|
|
markInvalid: markInvalid,
|
|
query: query,
|
|
run: run,
|
|
isInvalid: isInvalid
|
|
});
|
|
|
|
var events$8 = function (invalidConfig, invalidState) {
|
|
return invalidConfig.validator.map(function (validatorInfo) {
|
|
return derive$2([run$1(validatorInfo.onEvent, function (component) {
|
|
run(component, invalidConfig, invalidState).get(identity$1);
|
|
})].concat(validatorInfo.validateOnLoad ? [runOnAttached(function (component) {
|
|
run(component, invalidConfig, invalidState).get(noop);
|
|
})] : []));
|
|
}).getOr({});
|
|
};
|
|
|
|
var ActiveInvalidate = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$8
|
|
});
|
|
|
|
var InvalidateSchema = [
|
|
required$1('invalidClass'),
|
|
defaulted('getRoot', Optional.none),
|
|
optionObjOf('notify', [
|
|
defaulted('aria', 'alert'),
|
|
defaulted('getContainer', Optional.none),
|
|
defaulted('validHtml', ''),
|
|
onHandler('onValid'),
|
|
onHandler('onInvalid'),
|
|
onHandler('onValidate')
|
|
]),
|
|
optionObjOf('validator', [
|
|
required$1('validate'),
|
|
defaulted('onEvent', 'input'),
|
|
defaulted('validateOnLoad', true)
|
|
])
|
|
];
|
|
|
|
var Invalidating = create$7({
|
|
fields: InvalidateSchema,
|
|
name: 'invalidating',
|
|
active: ActiveInvalidate,
|
|
apis: InvalidateApis,
|
|
extra: {
|
|
validation: function (validator) {
|
|
return function (component) {
|
|
var v = Representing.getValue(component);
|
|
return Future.pure(validator(v));
|
|
};
|
|
}
|
|
}
|
|
});
|
|
|
|
var getCoupled = function (component, coupleConfig, coupleState, name) {
|
|
return coupleState.getOrCreate(component, coupleConfig, name);
|
|
};
|
|
|
|
var CouplingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
getCoupled: getCoupled
|
|
});
|
|
|
|
var CouplingSchema = [requiredOf('others', setOf(Result.value, anyValue()))];
|
|
|
|
var init$a = function () {
|
|
var coupled = {};
|
|
var getOrCreate = function (component, coupleConfig, name) {
|
|
var available = keys(coupleConfig.others);
|
|
if (!available) {
|
|
throw new Error('Cannot find coupled component: ' + name + '. Known coupled components: ' + JSON.stringify(available, null, 2));
|
|
} else {
|
|
return get$e(coupled, name).getOrThunk(function () {
|
|
var builder = get$e(coupleConfig.others, name).getOrDie('No information found for coupled component: ' + name);
|
|
var spec = builder(component);
|
|
var built = component.getSystem().build(spec);
|
|
coupled[name] = built;
|
|
return built;
|
|
});
|
|
}
|
|
};
|
|
var readState = constant$1({});
|
|
return nu$8({
|
|
readState: readState,
|
|
getOrCreate: getOrCreate
|
|
});
|
|
};
|
|
|
|
var CouplingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$a
|
|
});
|
|
|
|
var Coupling = create$7({
|
|
fields: CouplingSchema,
|
|
name: 'coupling',
|
|
apis: CouplingApis,
|
|
state: CouplingState
|
|
});
|
|
|
|
var suffix = constant$1('sink');
|
|
var partType$1 = constant$1(optional({
|
|
name: suffix(),
|
|
overrides: constant$1({
|
|
dom: { tag: 'div' },
|
|
behaviours: derive$1([Positioning.config({ useFixed: always })]),
|
|
events: derive$2([
|
|
cutter(keydown()),
|
|
cutter(mousedown()),
|
|
cutter(click())
|
|
])
|
|
})
|
|
}));
|
|
|
|
var HighlightOnOpen;
|
|
(function (HighlightOnOpen) {
|
|
HighlightOnOpen[HighlightOnOpen['HighlightFirst'] = 0] = 'HighlightFirst';
|
|
HighlightOnOpen[HighlightOnOpen['HighlightNone'] = 1] = 'HighlightNone';
|
|
}(HighlightOnOpen || (HighlightOnOpen = {})));
|
|
var getAnchor = function (detail, component) {
|
|
var hotspot = detail.getHotspot(component).getOr(component);
|
|
var type = 'hotspot';
|
|
var overrides = detail.getAnchorOverrides();
|
|
return detail.layouts.fold(function () {
|
|
return {
|
|
type: type,
|
|
hotspot: hotspot,
|
|
overrides: overrides
|
|
};
|
|
}, function (layouts) {
|
|
return {
|
|
type: type,
|
|
hotspot: hotspot,
|
|
overrides: overrides,
|
|
layouts: layouts
|
|
};
|
|
});
|
|
};
|
|
var fetch = function (detail, mapFetch, component) {
|
|
var fetcher = detail.fetch;
|
|
return fetcher(component).map(mapFetch);
|
|
};
|
|
var openF = function (detail, mapFetch, anchor, component, sandbox, externals, highlightOnOpen) {
|
|
var futureData = fetch(detail, mapFetch, component);
|
|
var getLazySink = getSink(component, detail);
|
|
return futureData.map(function (tdata) {
|
|
return tdata.bind(function (data) {
|
|
return Optional.from(tieredMenu.sketch(__assign(__assign({}, externals.menu()), {
|
|
uid: generate$5(''),
|
|
data: data,
|
|
highlightImmediately: highlightOnOpen === HighlightOnOpen.HighlightFirst,
|
|
onOpenMenu: function (tmenu, menu) {
|
|
var sink = getLazySink().getOrDie();
|
|
Positioning.position(sink, menu, { anchor: anchor });
|
|
Sandboxing.decloak(sandbox);
|
|
},
|
|
onOpenSubmenu: function (tmenu, item, submenu) {
|
|
var sink = getLazySink().getOrDie();
|
|
Positioning.position(sink, submenu, {
|
|
anchor: {
|
|
type: 'submenu',
|
|
item: item
|
|
}
|
|
});
|
|
Sandboxing.decloak(sandbox);
|
|
},
|
|
onRepositionMenu: function (tmenu, primaryMenu, submenuTriggers) {
|
|
var sink = getLazySink().getOrDie();
|
|
Positioning.position(sink, primaryMenu, { anchor: anchor });
|
|
each$1(submenuTriggers, function (st) {
|
|
Positioning.position(sink, st.triggeredMenu, {
|
|
anchor: {
|
|
type: 'submenu',
|
|
item: st.triggeringItem
|
|
}
|
|
});
|
|
});
|
|
},
|
|
onEscape: function () {
|
|
Focusing.focus(component);
|
|
Sandboxing.close(sandbox);
|
|
return Optional.some(true);
|
|
}
|
|
})));
|
|
});
|
|
});
|
|
};
|
|
var open = function (detail, mapFetch, hotspot, sandbox, externals, onOpenSync, highlightOnOpen) {
|
|
var anchor = getAnchor(detail, hotspot);
|
|
var processed = openF(detail, mapFetch, anchor, hotspot, sandbox, externals, highlightOnOpen);
|
|
return processed.map(function (tdata) {
|
|
tdata.fold(function () {
|
|
if (Sandboxing.isOpen(sandbox)) {
|
|
Sandboxing.close(sandbox);
|
|
}
|
|
}, function (data) {
|
|
Sandboxing.cloak(sandbox);
|
|
Sandboxing.open(sandbox, data);
|
|
onOpenSync(sandbox);
|
|
});
|
|
return sandbox;
|
|
});
|
|
};
|
|
var close = function (detail, mapFetch, component, sandbox, _externals, _onOpenSync, _highlightOnOpen) {
|
|
Sandboxing.close(sandbox);
|
|
return Future.pure(sandbox);
|
|
};
|
|
var togglePopup = function (detail, mapFetch, hotspot, externals, onOpenSync, highlightOnOpen) {
|
|
var sandbox = Coupling.getCoupled(hotspot, 'sandbox');
|
|
var showing = Sandboxing.isOpen(sandbox);
|
|
var action = showing ? close : open;
|
|
return action(detail, mapFetch, hotspot, sandbox, externals, onOpenSync, highlightOnOpen);
|
|
};
|
|
var matchWidth = function (hotspot, container, useMinWidth) {
|
|
var menu = Composing.getCurrent(container).getOr(container);
|
|
var buttonWidth = get$a(hotspot.element);
|
|
if (useMinWidth) {
|
|
set$7(menu.element, 'min-width', buttonWidth + 'px');
|
|
} else {
|
|
set$6(menu.element, buttonWidth);
|
|
}
|
|
};
|
|
var getSink = function (anyInSystem, sinkDetail) {
|
|
return anyInSystem.getSystem().getByUid(sinkDetail.uid + '-' + suffix()).map(function (internalSink) {
|
|
return function () {
|
|
return Result.value(internalSink);
|
|
};
|
|
}).getOrThunk(function () {
|
|
return sinkDetail.lazySink.fold(function () {
|
|
return function () {
|
|
return Result.error(new Error('No internal sink is specified, nor could an external sink be found'));
|
|
};
|
|
}, function (lazySinkFn) {
|
|
return function () {
|
|
return lazySinkFn(anyInSystem);
|
|
};
|
|
});
|
|
});
|
|
};
|
|
var doRepositionMenus = function (sandbox) {
|
|
Sandboxing.getState(sandbox).each(function (tmenu) {
|
|
tieredMenu.repositionMenus(tmenu);
|
|
});
|
|
};
|
|
var makeSandbox$1 = function (detail, hotspot, extras) {
|
|
var ariaOwner = manager();
|
|
var onOpen = function (component, menu) {
|
|
var anchor = getAnchor(detail, hotspot);
|
|
ariaOwner.link(hotspot.element);
|
|
if (detail.matchWidth) {
|
|
matchWidth(anchor.hotspot, menu, detail.useMinWidth);
|
|
}
|
|
detail.onOpen(anchor, component, menu);
|
|
if (extras !== undefined && extras.onOpen !== undefined) {
|
|
extras.onOpen(component, menu);
|
|
}
|
|
};
|
|
var onClose = function (component, menu) {
|
|
ariaOwner.unlink(hotspot.element);
|
|
if (extras !== undefined && extras.onClose !== undefined) {
|
|
extras.onClose(component, menu);
|
|
}
|
|
};
|
|
var lazySink = getSink(hotspot, detail);
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: detail.sandboxClasses,
|
|
attributes: {
|
|
id: ariaOwner.id,
|
|
role: 'listbox'
|
|
}
|
|
},
|
|
behaviours: SketchBehaviours.augment(detail.sandboxBehaviours, [
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: hotspot
|
|
}
|
|
}),
|
|
Sandboxing.config({
|
|
onOpen: onOpen,
|
|
onClose: onClose,
|
|
isPartOf: function (container, data, queryElem) {
|
|
return isPartOf$1(data, queryElem) || isPartOf$1(hotspot, queryElem);
|
|
},
|
|
getAttachPoint: function () {
|
|
return lazySink().getOrDie();
|
|
}
|
|
}),
|
|
Composing.config({
|
|
find: function (sandbox) {
|
|
return Sandboxing.getState(sandbox).bind(function (menu) {
|
|
return Composing.getCurrent(menu);
|
|
});
|
|
}
|
|
}),
|
|
Receiving.config({ channels: __assign(__assign({}, receivingChannel$1({ isExtraPart: never })), receivingChannel({ doReposition: doRepositionMenus })) })
|
|
])
|
|
};
|
|
};
|
|
var repositionMenus = function (comp) {
|
|
var sandbox = Coupling.getCoupled(comp, 'sandbox');
|
|
doRepositionMenus(sandbox);
|
|
};
|
|
|
|
var sandboxFields = function () {
|
|
return [
|
|
defaulted('sandboxClasses', []),
|
|
SketchBehaviours.field('sandboxBehaviours', [
|
|
Composing,
|
|
Receiving,
|
|
Sandboxing,
|
|
Representing
|
|
])
|
|
];
|
|
};
|
|
|
|
var schema$j = constant$1([
|
|
required$1('dom'),
|
|
required$1('fetch'),
|
|
onHandler('onOpen'),
|
|
onKeyboardHandler('onExecute'),
|
|
defaulted('getHotspot', Optional.some),
|
|
defaulted('getAnchorOverrides', constant$1({})),
|
|
schema$y(),
|
|
field('dropdownBehaviours', [
|
|
Toggling,
|
|
Coupling,
|
|
Keying,
|
|
Focusing
|
|
]),
|
|
required$1('toggleClass'),
|
|
defaulted('eventOrder', {}),
|
|
option('lazySink'),
|
|
defaulted('matchWidth', false),
|
|
defaulted('useMinWidth', false),
|
|
option('role')
|
|
].concat(sandboxFields()));
|
|
var parts$d = constant$1([
|
|
external$1({
|
|
schema: [tieredMenuMarkers()],
|
|
name: 'menu',
|
|
defaults: function (detail) {
|
|
return { onExecute: detail.onExecute };
|
|
}
|
|
}),
|
|
partType$1()
|
|
]);
|
|
|
|
var factory$g = function (detail, components, _spec, externals) {
|
|
var _a;
|
|
var lookupAttr = function (attr) {
|
|
return get$e(detail.dom, 'attributes').bind(function (attrs) {
|
|
return get$e(attrs, attr);
|
|
});
|
|
};
|
|
var switchToMenu = function (sandbox) {
|
|
Sandboxing.getState(sandbox).each(function (tmenu) {
|
|
tieredMenu.highlightPrimary(tmenu);
|
|
});
|
|
};
|
|
var action = function (component) {
|
|
var onOpenSync = switchToMenu;
|
|
togglePopup(detail, identity$1, component, externals, onOpenSync, HighlightOnOpen.HighlightFirst).get(noop);
|
|
};
|
|
var apis = {
|
|
expand: function (comp) {
|
|
if (!Toggling.isOn(comp)) {
|
|
togglePopup(detail, identity$1, comp, externals, noop, HighlightOnOpen.HighlightNone).get(noop);
|
|
}
|
|
},
|
|
open: function (comp) {
|
|
if (!Toggling.isOn(comp)) {
|
|
togglePopup(detail, identity$1, comp, externals, noop, HighlightOnOpen.HighlightFirst).get(noop);
|
|
}
|
|
},
|
|
isOpen: Toggling.isOn,
|
|
close: function (comp) {
|
|
if (Toggling.isOn(comp)) {
|
|
togglePopup(detail, identity$1, comp, externals, noop, HighlightOnOpen.HighlightFirst).get(noop);
|
|
}
|
|
},
|
|
repositionMenus: function (comp) {
|
|
if (Toggling.isOn(comp)) {
|
|
repositionMenus(comp);
|
|
}
|
|
}
|
|
};
|
|
var triggerExecute = function (comp, _se) {
|
|
emitExecute(comp);
|
|
return Optional.some(true);
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.dropdownBehaviours, [
|
|
Toggling.config({
|
|
toggleClass: detail.toggleClass,
|
|
aria: { mode: 'expanded' }
|
|
}),
|
|
Coupling.config({
|
|
others: {
|
|
sandbox: function (hotspot) {
|
|
return makeSandbox$1(detail, hotspot, {
|
|
onOpen: function () {
|
|
return Toggling.on(hotspot);
|
|
},
|
|
onClose: function () {
|
|
return Toggling.off(hotspot);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}),
|
|
Keying.config({
|
|
mode: 'special',
|
|
onSpace: triggerExecute,
|
|
onEnter: triggerExecute,
|
|
onDown: function (comp, _se) {
|
|
if (Dropdown.isOpen(comp)) {
|
|
var sandbox = Coupling.getCoupled(comp, 'sandbox');
|
|
switchToMenu(sandbox);
|
|
} else {
|
|
Dropdown.open(comp);
|
|
}
|
|
return Optional.some(true);
|
|
},
|
|
onEscape: function (comp, _se) {
|
|
if (Dropdown.isOpen(comp)) {
|
|
Dropdown.close(comp);
|
|
return Optional.some(true);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
}),
|
|
Focusing.config({})
|
|
]),
|
|
events: events$a(Optional.some(action)),
|
|
eventOrder: __assign(__assign({}, detail.eventOrder), (_a = {}, _a[execute$5()] = [
|
|
'disabling',
|
|
'toggling',
|
|
'alloy.base.behaviour'
|
|
], _a)),
|
|
apis: apis,
|
|
domModification: {
|
|
attributes: __assign(__assign({ 'aria-haspopup': 'true' }, detail.role.fold(function () {
|
|
return {};
|
|
}, function (role) {
|
|
return { role: role };
|
|
})), detail.dom.tag === 'button' ? { type: lookupAttr('type').getOr('button') } : {})
|
|
}
|
|
};
|
|
};
|
|
var Dropdown = composite({
|
|
name: 'Dropdown',
|
|
configFields: schema$j(),
|
|
partFields: parts$d(),
|
|
factory: factory$g,
|
|
apis: {
|
|
open: function (apis, comp) {
|
|
return apis.open(comp);
|
|
},
|
|
expand: function (apis, comp) {
|
|
return apis.expand(comp);
|
|
},
|
|
close: function (apis, comp) {
|
|
return apis.close(comp);
|
|
},
|
|
isOpen: function (apis, comp) {
|
|
return apis.isOpen(comp);
|
|
},
|
|
repositionMenus: function (apis, comp) {
|
|
return apis.repositionMenus(comp);
|
|
}
|
|
}
|
|
});
|
|
|
|
var exhibit$1 = function () {
|
|
return nu$7({
|
|
styles: {
|
|
'-webkit-user-select': 'none',
|
|
'user-select': 'none',
|
|
'-ms-user-select': 'none',
|
|
'-moz-user-select': '-moz-none'
|
|
},
|
|
attributes: { unselectable: 'on' }
|
|
});
|
|
};
|
|
var events$7 = function () {
|
|
return derive$2([abort(selectstart(), always)]);
|
|
};
|
|
|
|
var ActiveUnselecting = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$7,
|
|
exhibit: exhibit$1
|
|
});
|
|
|
|
var Unselecting = create$7({
|
|
fields: [],
|
|
name: 'unselecting',
|
|
active: ActiveUnselecting
|
|
});
|
|
|
|
var renderPanelButton = function (spec, sharedBackstage) {
|
|
return Dropdown.sketch({
|
|
dom: spec.dom,
|
|
components: spec.components,
|
|
toggleClass: 'mce-active',
|
|
dropdownBehaviours: derive$1([
|
|
DisablingConfigs.button(sharedBackstage.providers.isDisabled),
|
|
receivingConfig(),
|
|
Unselecting.config({}),
|
|
Tabstopping.config({})
|
|
]),
|
|
layouts: spec.layouts,
|
|
sandboxClasses: ['tox-dialog__popups'],
|
|
lazySink: sharedBackstage.getSink,
|
|
fetch: function (comp) {
|
|
return Future.nu(function (callback) {
|
|
return spec.fetch(callback);
|
|
}).map(function (items) {
|
|
return Optional.from(createTieredDataFrom(deepMerge(createPartialChoiceMenu(generate$6('menu-value'), items, function (value) {
|
|
spec.onItemAction(comp, value);
|
|
}, spec.columns, spec.presets, ItemResponse$1.CLOSE_ON_EXECUTE, never, sharedBackstage.providers), { movement: deriveMenuMovement(spec.columns, spec.presets) })));
|
|
});
|
|
},
|
|
parts: { menu: part(false, 1, spec.presets) }
|
|
});
|
|
};
|
|
|
|
var colorInputChangeEvent = generate$6('color-input-change');
|
|
var colorSwatchChangeEvent = generate$6('color-swatch-change');
|
|
var colorPickerCancelEvent = generate$6('color-picker-cancel');
|
|
var renderColorInput = function (spec, sharedBackstage, colorInputBackstage) {
|
|
var pField = FormField.parts.field({
|
|
factory: Input,
|
|
inputClasses: ['tox-textfield'],
|
|
onSetValue: function (c) {
|
|
return Invalidating.run(c).get(noop);
|
|
},
|
|
inputBehaviours: derive$1([
|
|
Disabling.config({ disabled: sharedBackstage.providers.isDisabled }),
|
|
receivingConfig(),
|
|
Tabstopping.config({}),
|
|
Invalidating.config({
|
|
invalidClass: 'tox-textbox-field-invalid',
|
|
getRoot: function (comp) {
|
|
return parent(comp.element);
|
|
},
|
|
notify: {
|
|
onValid: function (comp) {
|
|
var val = Representing.getValue(comp);
|
|
emitWith(comp, colorInputChangeEvent, { color: val });
|
|
}
|
|
},
|
|
validator: {
|
|
validateOnLoad: false,
|
|
validate: function (input) {
|
|
var inputValue = Representing.getValue(input);
|
|
if (inputValue.length === 0) {
|
|
return Future.pure(Result.value(true));
|
|
} else {
|
|
var span = SugarElement.fromTag('span');
|
|
set$7(span, 'background-color', inputValue);
|
|
var res = getRaw(span, 'background-color').fold(function () {
|
|
return Result.error('blah');
|
|
}, function (_) {
|
|
return Result.value(inputValue);
|
|
});
|
|
return Future.pure(res);
|
|
}
|
|
}
|
|
}
|
|
})
|
|
]),
|
|
selectOnFocus: false
|
|
});
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, sharedBackstage.providers);
|
|
});
|
|
var emitSwatchChange = function (colorBit, value) {
|
|
emitWith(colorBit, colorSwatchChangeEvent, { value: value });
|
|
};
|
|
var onItemAction = function (comp, value) {
|
|
memColorButton.getOpt(comp).each(function (colorBit) {
|
|
if (value === 'custom') {
|
|
colorInputBackstage.colorPicker(function (valueOpt) {
|
|
valueOpt.fold(function () {
|
|
return emit(colorBit, colorPickerCancelEvent);
|
|
}, function (value) {
|
|
emitSwatchChange(colorBit, value);
|
|
addColor(value);
|
|
});
|
|
}, '#ffffff');
|
|
} else if (value === 'remove') {
|
|
emitSwatchChange(colorBit, '');
|
|
} else {
|
|
emitSwatchChange(colorBit, value);
|
|
}
|
|
});
|
|
};
|
|
var memColorButton = record(renderPanelButton({
|
|
dom: {
|
|
tag: 'span',
|
|
attributes: { 'aria-label': sharedBackstage.providers.translate('Color swatch') }
|
|
},
|
|
layouts: {
|
|
onRtl: function () {
|
|
return [
|
|
southwest$2,
|
|
southeast$2,
|
|
south$2
|
|
];
|
|
},
|
|
onLtr: function () {
|
|
return [
|
|
southeast$2,
|
|
southwest$2,
|
|
south$2
|
|
];
|
|
}
|
|
},
|
|
components: [],
|
|
fetch: getFetch$1(colorInputBackstage.getColors(), colorInputBackstage.hasCustomColors()),
|
|
columns: colorInputBackstage.getColorCols(),
|
|
presets: 'color',
|
|
onItemAction: onItemAction
|
|
}, sharedBackstage));
|
|
return FormField.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group']
|
|
},
|
|
components: pLabel.toArray().concat([{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-color-input']
|
|
},
|
|
components: [
|
|
pField,
|
|
memColorButton.asSpec()
|
|
]
|
|
}]),
|
|
fieldBehaviours: derive$1([config('form-field-events', [
|
|
run$1(colorInputChangeEvent, function (comp, se) {
|
|
memColorButton.getOpt(comp).each(function (colorButton) {
|
|
set$7(colorButton.element, 'background-color', se.event.color);
|
|
});
|
|
emitWith(comp, formChangeEvent, { name: spec.name });
|
|
}),
|
|
run$1(colorSwatchChangeEvent, function (comp, se) {
|
|
FormField.getField(comp).each(function (field) {
|
|
Representing.setValue(field, se.event.value);
|
|
Composing.getCurrent(comp).each(Focusing.focus);
|
|
});
|
|
}),
|
|
run$1(colorPickerCancelEvent, function (comp, _se) {
|
|
FormField.getField(comp).each(function (_field) {
|
|
Composing.getCurrent(comp).each(Focusing.focus);
|
|
});
|
|
})
|
|
])])
|
|
});
|
|
};
|
|
|
|
var labelPart = optional({
|
|
schema: [required$1('dom')],
|
|
name: 'label'
|
|
});
|
|
var edgePart = function (name) {
|
|
return optional({
|
|
name: '' + name + '-edge',
|
|
overrides: function (detail) {
|
|
var action = detail.model.manager.edgeActions[name];
|
|
return action.fold(function () {
|
|
return {};
|
|
}, function (a) {
|
|
return {
|
|
events: derive$2([
|
|
runActionExtra(touchstart(), function (comp, se, d) {
|
|
return a(comp, d);
|
|
}, [detail]),
|
|
runActionExtra(mousedown(), function (comp, se, d) {
|
|
return a(comp, d);
|
|
}, [detail]),
|
|
runActionExtra(mousemove(), function (comp, se, det) {
|
|
if (det.mouseIsDown.get()) {
|
|
a(comp, det);
|
|
}
|
|
}, [detail])
|
|
])
|
|
};
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var tlEdgePart = edgePart('top-left');
|
|
var tedgePart = edgePart('top');
|
|
var trEdgePart = edgePart('top-right');
|
|
var redgePart = edgePart('right');
|
|
var brEdgePart = edgePart('bottom-right');
|
|
var bedgePart = edgePart('bottom');
|
|
var blEdgePart = edgePart('bottom-left');
|
|
var ledgePart = edgePart('left');
|
|
var thumbPart = required({
|
|
name: 'thumb',
|
|
defaults: constant$1({ dom: { styles: { position: 'absolute' } } }),
|
|
overrides: function (detail) {
|
|
return {
|
|
events: derive$2([
|
|
redirectToPart(touchstart(), detail, 'spectrum'),
|
|
redirectToPart(touchmove(), detail, 'spectrum'),
|
|
redirectToPart(touchend(), detail, 'spectrum'),
|
|
redirectToPart(mousedown(), detail, 'spectrum'),
|
|
redirectToPart(mousemove(), detail, 'spectrum'),
|
|
redirectToPart(mouseup(), detail, 'spectrum')
|
|
])
|
|
};
|
|
}
|
|
});
|
|
var spectrumPart = required({
|
|
schema: [customField('mouseIsDown', function () {
|
|
return Cell(false);
|
|
})],
|
|
name: 'spectrum',
|
|
overrides: function (detail) {
|
|
var modelDetail = detail.model;
|
|
var model = modelDetail.manager;
|
|
var setValueFrom = function (component, simulatedEvent) {
|
|
return model.getValueFromEvent(simulatedEvent).map(function (value) {
|
|
return model.setValueFrom(component, detail, value);
|
|
});
|
|
};
|
|
return {
|
|
behaviours: derive$1([
|
|
Keying.config({
|
|
mode: 'special',
|
|
onLeft: function (spectrum) {
|
|
return model.onLeft(spectrum, detail);
|
|
},
|
|
onRight: function (spectrum) {
|
|
return model.onRight(spectrum, detail);
|
|
},
|
|
onUp: function (spectrum) {
|
|
return model.onUp(spectrum, detail);
|
|
},
|
|
onDown: function (spectrum) {
|
|
return model.onDown(spectrum, detail);
|
|
}
|
|
}),
|
|
Focusing.config({})
|
|
]),
|
|
events: derive$2([
|
|
run$1(touchstart(), setValueFrom),
|
|
run$1(touchmove(), setValueFrom),
|
|
run$1(mousedown(), setValueFrom),
|
|
run$1(mousemove(), function (spectrum, se) {
|
|
if (detail.mouseIsDown.get()) {
|
|
setValueFrom(spectrum, se);
|
|
}
|
|
})
|
|
])
|
|
};
|
|
}
|
|
});
|
|
var SliderParts = [
|
|
labelPart,
|
|
ledgePart,
|
|
redgePart,
|
|
tedgePart,
|
|
bedgePart,
|
|
tlEdgePart,
|
|
trEdgePart,
|
|
blEdgePart,
|
|
brEdgePart,
|
|
thumbPart,
|
|
spectrumPart
|
|
];
|
|
|
|
var _sliderChangeEvent = 'slider.change.value';
|
|
var sliderChangeEvent = constant$1(_sliderChangeEvent);
|
|
var isTouchEvent$2 = function (evt) {
|
|
return evt.type.indexOf('touch') !== -1;
|
|
};
|
|
var getEventSource = function (simulatedEvent) {
|
|
var evt = simulatedEvent.event.raw;
|
|
if (isTouchEvent$2(evt)) {
|
|
var touchEvent = evt;
|
|
return touchEvent.touches !== undefined && touchEvent.touches.length === 1 ? Optional.some(touchEvent.touches[0]).map(function (t) {
|
|
return SugarPosition(t.clientX, t.clientY);
|
|
}) : Optional.none();
|
|
} else {
|
|
var mouseEvent = evt;
|
|
return mouseEvent.clientX !== undefined ? Optional.some(mouseEvent).map(function (me) {
|
|
return SugarPosition(me.clientX, me.clientY);
|
|
}) : Optional.none();
|
|
}
|
|
};
|
|
|
|
var t = 'top', r = 'right', b = 'bottom', l = 'left';
|
|
var minX = function (detail) {
|
|
return detail.model.minX;
|
|
};
|
|
var minY = function (detail) {
|
|
return detail.model.minY;
|
|
};
|
|
var min1X = function (detail) {
|
|
return detail.model.minX - 1;
|
|
};
|
|
var min1Y = function (detail) {
|
|
return detail.model.minY - 1;
|
|
};
|
|
var maxX = function (detail) {
|
|
return detail.model.maxX;
|
|
};
|
|
var maxY = function (detail) {
|
|
return detail.model.maxY;
|
|
};
|
|
var max1X = function (detail) {
|
|
return detail.model.maxX + 1;
|
|
};
|
|
var max1Y = function (detail) {
|
|
return detail.model.maxY + 1;
|
|
};
|
|
var range = function (detail, max, min) {
|
|
return max(detail) - min(detail);
|
|
};
|
|
var xRange = function (detail) {
|
|
return range(detail, maxX, minX);
|
|
};
|
|
var yRange = function (detail) {
|
|
return range(detail, maxY, minY);
|
|
};
|
|
var halfX = function (detail) {
|
|
return xRange(detail) / 2;
|
|
};
|
|
var halfY = function (detail) {
|
|
return yRange(detail) / 2;
|
|
};
|
|
var step = function (detail) {
|
|
return detail.stepSize;
|
|
};
|
|
var snap = function (detail) {
|
|
return detail.snapToGrid;
|
|
};
|
|
var snapStart = function (detail) {
|
|
return detail.snapStart;
|
|
};
|
|
var rounded = function (detail) {
|
|
return detail.rounded;
|
|
};
|
|
var hasEdge = function (detail, edgeName) {
|
|
return detail[edgeName + '-edge'] !== undefined;
|
|
};
|
|
var hasLEdge = function (detail) {
|
|
return hasEdge(detail, l);
|
|
};
|
|
var hasREdge = function (detail) {
|
|
return hasEdge(detail, r);
|
|
};
|
|
var hasTEdge = function (detail) {
|
|
return hasEdge(detail, t);
|
|
};
|
|
var hasBEdge = function (detail) {
|
|
return hasEdge(detail, b);
|
|
};
|
|
var currentValue = function (detail) {
|
|
return detail.model.value.get();
|
|
};
|
|
|
|
var xValue = function (x) {
|
|
return { x: x };
|
|
};
|
|
var yValue = function (y) {
|
|
return { y: y };
|
|
};
|
|
var xyValue = function (x, y) {
|
|
return {
|
|
x: x,
|
|
y: y
|
|
};
|
|
};
|
|
var fireSliderChange$3 = function (component, value) {
|
|
emitWith(component, sliderChangeEvent(), { value: value });
|
|
};
|
|
var setToTLEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(min1X(detail), min1Y(detail)));
|
|
};
|
|
var setToTEdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, yValue(min1Y(detail)));
|
|
};
|
|
var setToTEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(halfX(detail), min1Y(detail)));
|
|
};
|
|
var setToTREdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(max1X(detail), min1Y(detail)));
|
|
};
|
|
var setToREdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, xValue(max1X(detail)));
|
|
};
|
|
var setToREdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(max1X(detail), halfY(detail)));
|
|
};
|
|
var setToBREdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(max1X(detail), max1Y(detail)));
|
|
};
|
|
var setToBEdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, yValue(max1Y(detail)));
|
|
};
|
|
var setToBEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(halfX(detail), max1Y(detail)));
|
|
};
|
|
var setToBLEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(min1X(detail), max1Y(detail)));
|
|
};
|
|
var setToLEdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, xValue(min1X(detail)));
|
|
};
|
|
var setToLEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(min1X(detail), halfY(detail)));
|
|
};
|
|
|
|
var reduceBy = function (value, min, max, step) {
|
|
if (value < min) {
|
|
return value;
|
|
} else if (value > max) {
|
|
return max;
|
|
} else if (value === min) {
|
|
return min - 1;
|
|
} else {
|
|
return Math.max(min, value - step);
|
|
}
|
|
};
|
|
var increaseBy = function (value, min, max, step) {
|
|
if (value > max) {
|
|
return value;
|
|
} else if (value < min) {
|
|
return min;
|
|
} else if (value === max) {
|
|
return max + 1;
|
|
} else {
|
|
return Math.min(max, value + step);
|
|
}
|
|
};
|
|
var capValue = function (value, min, max) {
|
|
return Math.max(min, Math.min(max, value));
|
|
};
|
|
var snapValueOf = function (value, min, max, step, snapStart) {
|
|
return snapStart.fold(function () {
|
|
var initValue = value - min;
|
|
var extraValue = Math.round(initValue / step) * step;
|
|
return capValue(min + extraValue, min - 1, max + 1);
|
|
}, function (start) {
|
|
var remainder = (value - start) % step;
|
|
var adjustment = Math.round(remainder / step);
|
|
var rawSteps = Math.floor((value - start) / step);
|
|
var maxSteps = Math.floor((max - start) / step);
|
|
var numSteps = Math.min(maxSteps, rawSteps + adjustment);
|
|
var r = start + numSteps * step;
|
|
return Math.max(start, r);
|
|
});
|
|
};
|
|
var findOffsetOf = function (value, min, max) {
|
|
return Math.min(max, Math.max(value, min)) - min;
|
|
};
|
|
var findValueOf = function (args) {
|
|
var min = args.min, max = args.max, range = args.range, value = args.value, step = args.step, snap = args.snap, snapStart = args.snapStart, rounded = args.rounded, hasMinEdge = args.hasMinEdge, hasMaxEdge = args.hasMaxEdge, minBound = args.minBound, maxBound = args.maxBound, screenRange = args.screenRange;
|
|
var capMin = hasMinEdge ? min - 1 : min;
|
|
var capMax = hasMaxEdge ? max + 1 : max;
|
|
if (value < minBound) {
|
|
return capMin;
|
|
} else if (value > maxBound) {
|
|
return capMax;
|
|
} else {
|
|
var offset = findOffsetOf(value, minBound, maxBound);
|
|
var newValue = capValue(offset / screenRange * range + min, capMin, capMax);
|
|
if (snap && newValue >= min && newValue <= max) {
|
|
return snapValueOf(newValue, min, max, step, snapStart);
|
|
} else if (rounded) {
|
|
return Math.round(newValue);
|
|
} else {
|
|
return newValue;
|
|
}
|
|
}
|
|
};
|
|
var findOffsetOfValue$2 = function (args) {
|
|
var min = args.min, max = args.max, range = args.range, value = args.value, hasMinEdge = args.hasMinEdge, hasMaxEdge = args.hasMaxEdge, maxBound = args.maxBound, maxOffset = args.maxOffset, centerMinEdge = args.centerMinEdge, centerMaxEdge = args.centerMaxEdge;
|
|
if (value < min) {
|
|
return hasMinEdge ? 0 : centerMinEdge;
|
|
} else if (value > max) {
|
|
return hasMaxEdge ? maxBound : centerMaxEdge;
|
|
} else {
|
|
return (value - min) / range * maxOffset;
|
|
}
|
|
};
|
|
|
|
var top = 'top', right = 'right', bottom = 'bottom', left = 'left', width = 'width', height = 'height';
|
|
var getBounds = function (component) {
|
|
return component.element.dom.getBoundingClientRect();
|
|
};
|
|
var getBoundsProperty = function (bounds, property) {
|
|
return bounds[property];
|
|
};
|
|
var getMinXBounds = function (component) {
|
|
var bounds = getBounds(component);
|
|
return getBoundsProperty(bounds, left);
|
|
};
|
|
var getMaxXBounds = function (component) {
|
|
var bounds = getBounds(component);
|
|
return getBoundsProperty(bounds, right);
|
|
};
|
|
var getMinYBounds = function (component) {
|
|
var bounds = getBounds(component);
|
|
return getBoundsProperty(bounds, top);
|
|
};
|
|
var getMaxYBounds = function (component) {
|
|
var bounds = getBounds(component);
|
|
return getBoundsProperty(bounds, bottom);
|
|
};
|
|
var getXScreenRange = function (component) {
|
|
var bounds = getBounds(component);
|
|
return getBoundsProperty(bounds, width);
|
|
};
|
|
var getYScreenRange = function (component) {
|
|
var bounds = getBounds(component);
|
|
return getBoundsProperty(bounds, height);
|
|
};
|
|
var getCenterOffsetOf = function (componentMinEdge, componentMaxEdge, spectrumMinEdge) {
|
|
return (componentMinEdge + componentMaxEdge) / 2 - spectrumMinEdge;
|
|
};
|
|
var getXCenterOffSetOf = function (component, spectrum) {
|
|
var componentBounds = getBounds(component);
|
|
var spectrumBounds = getBounds(spectrum);
|
|
var componentMinEdge = getBoundsProperty(componentBounds, left);
|
|
var componentMaxEdge = getBoundsProperty(componentBounds, right);
|
|
var spectrumMinEdge = getBoundsProperty(spectrumBounds, left);
|
|
return getCenterOffsetOf(componentMinEdge, componentMaxEdge, spectrumMinEdge);
|
|
};
|
|
var getYCenterOffSetOf = function (component, spectrum) {
|
|
var componentBounds = getBounds(component);
|
|
var spectrumBounds = getBounds(spectrum);
|
|
var componentMinEdge = getBoundsProperty(componentBounds, top);
|
|
var componentMaxEdge = getBoundsProperty(componentBounds, bottom);
|
|
var spectrumMinEdge = getBoundsProperty(spectrumBounds, top);
|
|
return getCenterOffsetOf(componentMinEdge, componentMaxEdge, spectrumMinEdge);
|
|
};
|
|
|
|
var fireSliderChange$2 = function (spectrum, value) {
|
|
emitWith(spectrum, sliderChangeEvent(), { value: value });
|
|
};
|
|
var sliderValue$2 = function (x) {
|
|
return { x: x };
|
|
};
|
|
var findValueOfOffset$1 = function (spectrum, detail, left) {
|
|
var args = {
|
|
min: minX(detail),
|
|
max: maxX(detail),
|
|
range: xRange(detail),
|
|
value: left,
|
|
step: step(detail),
|
|
snap: snap(detail),
|
|
snapStart: snapStart(detail),
|
|
rounded: rounded(detail),
|
|
hasMinEdge: hasLEdge(detail),
|
|
hasMaxEdge: hasREdge(detail),
|
|
minBound: getMinXBounds(spectrum),
|
|
maxBound: getMaxXBounds(spectrum),
|
|
screenRange: getXScreenRange(spectrum)
|
|
};
|
|
return findValueOf(args);
|
|
};
|
|
var setValueFrom$2 = function (spectrum, detail, value) {
|
|
var xValue = findValueOfOffset$1(spectrum, detail, value);
|
|
var sliderVal = sliderValue$2(xValue);
|
|
fireSliderChange$2(spectrum, sliderVal);
|
|
return xValue;
|
|
};
|
|
var setToMin$2 = function (spectrum, detail) {
|
|
var min = minX(detail);
|
|
fireSliderChange$2(spectrum, sliderValue$2(min));
|
|
};
|
|
var setToMax$2 = function (spectrum, detail) {
|
|
var max = maxX(detail);
|
|
fireSliderChange$2(spectrum, sliderValue$2(max));
|
|
};
|
|
var moveBy$2 = function (direction, spectrum, detail) {
|
|
var f = direction > 0 ? increaseBy : reduceBy;
|
|
var xValue = f(currentValue(detail).x, minX(detail), maxX(detail), step(detail));
|
|
fireSliderChange$2(spectrum, sliderValue$2(xValue));
|
|
return Optional.some(xValue);
|
|
};
|
|
var handleMovement$2 = function (direction) {
|
|
return function (spectrum, detail) {
|
|
return moveBy$2(direction, spectrum, detail).map(always);
|
|
};
|
|
};
|
|
var getValueFromEvent$2 = function (simulatedEvent) {
|
|
var pos = getEventSource(simulatedEvent);
|
|
return pos.map(function (p) {
|
|
return p.left;
|
|
});
|
|
};
|
|
var findOffsetOfValue$1 = function (spectrum, detail, value, minEdge, maxEdge) {
|
|
var minOffset = 0;
|
|
var maxOffset = getXScreenRange(spectrum);
|
|
var centerMinEdge = minEdge.bind(function (edge) {
|
|
return Optional.some(getXCenterOffSetOf(edge, spectrum));
|
|
}).getOr(minOffset);
|
|
var centerMaxEdge = maxEdge.bind(function (edge) {
|
|
return Optional.some(getXCenterOffSetOf(edge, spectrum));
|
|
}).getOr(maxOffset);
|
|
var args = {
|
|
min: minX(detail),
|
|
max: maxX(detail),
|
|
range: xRange(detail),
|
|
value: value,
|
|
hasMinEdge: hasLEdge(detail),
|
|
hasMaxEdge: hasREdge(detail),
|
|
minBound: getMinXBounds(spectrum),
|
|
minOffset: minOffset,
|
|
maxBound: getMaxXBounds(spectrum),
|
|
maxOffset: maxOffset,
|
|
centerMinEdge: centerMinEdge,
|
|
centerMaxEdge: centerMaxEdge
|
|
};
|
|
return findOffsetOfValue$2(args);
|
|
};
|
|
var findPositionOfValue$1 = function (slider, spectrum, value, minEdge, maxEdge, detail) {
|
|
var offset = findOffsetOfValue$1(spectrum, detail, value, minEdge, maxEdge);
|
|
return getMinXBounds(spectrum) - getMinXBounds(slider) + offset;
|
|
};
|
|
var setPositionFromValue$2 = function (slider, thumb, detail, edges) {
|
|
var value = currentValue(detail);
|
|
var pos = findPositionOfValue$1(slider, edges.getSpectrum(slider), value.x, edges.getLeftEdge(slider), edges.getRightEdge(slider), detail);
|
|
var thumbRadius = get$a(thumb.element) / 2;
|
|
set$7(thumb.element, 'left', pos - thumbRadius + 'px');
|
|
};
|
|
var onLeft$2 = handleMovement$2(-1);
|
|
var onRight$2 = handleMovement$2(1);
|
|
var onUp$2 = Optional.none;
|
|
var onDown$2 = Optional.none;
|
|
var edgeActions$2 = {
|
|
'top-left': Optional.none(),
|
|
'top': Optional.none(),
|
|
'top-right': Optional.none(),
|
|
'right': Optional.some(setToREdge),
|
|
'bottom-right': Optional.none(),
|
|
'bottom': Optional.none(),
|
|
'bottom-left': Optional.none(),
|
|
'left': Optional.some(setToLEdge)
|
|
};
|
|
|
|
var HorizontalModel = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setValueFrom: setValueFrom$2,
|
|
setToMin: setToMin$2,
|
|
setToMax: setToMax$2,
|
|
findValueOfOffset: findValueOfOffset$1,
|
|
getValueFromEvent: getValueFromEvent$2,
|
|
findPositionOfValue: findPositionOfValue$1,
|
|
setPositionFromValue: setPositionFromValue$2,
|
|
onLeft: onLeft$2,
|
|
onRight: onRight$2,
|
|
onUp: onUp$2,
|
|
onDown: onDown$2,
|
|
edgeActions: edgeActions$2
|
|
});
|
|
|
|
var fireSliderChange$1 = function (spectrum, value) {
|
|
emitWith(spectrum, sliderChangeEvent(), { value: value });
|
|
};
|
|
var sliderValue$1 = function (y) {
|
|
return { y: y };
|
|
};
|
|
var findValueOfOffset = function (spectrum, detail, top) {
|
|
var args = {
|
|
min: minY(detail),
|
|
max: maxY(detail),
|
|
range: yRange(detail),
|
|
value: top,
|
|
step: step(detail),
|
|
snap: snap(detail),
|
|
snapStart: snapStart(detail),
|
|
rounded: rounded(detail),
|
|
hasMinEdge: hasTEdge(detail),
|
|
hasMaxEdge: hasBEdge(detail),
|
|
minBound: getMinYBounds(spectrum),
|
|
maxBound: getMaxYBounds(spectrum),
|
|
screenRange: getYScreenRange(spectrum)
|
|
};
|
|
return findValueOf(args);
|
|
};
|
|
var setValueFrom$1 = function (spectrum, detail, value) {
|
|
var yValue = findValueOfOffset(spectrum, detail, value);
|
|
var sliderVal = sliderValue$1(yValue);
|
|
fireSliderChange$1(spectrum, sliderVal);
|
|
return yValue;
|
|
};
|
|
var setToMin$1 = function (spectrum, detail) {
|
|
var min = minY(detail);
|
|
fireSliderChange$1(spectrum, sliderValue$1(min));
|
|
};
|
|
var setToMax$1 = function (spectrum, detail) {
|
|
var max = maxY(detail);
|
|
fireSliderChange$1(spectrum, sliderValue$1(max));
|
|
};
|
|
var moveBy$1 = function (direction, spectrum, detail) {
|
|
var f = direction > 0 ? increaseBy : reduceBy;
|
|
var yValue = f(currentValue(detail).y, minY(detail), maxY(detail), step(detail));
|
|
fireSliderChange$1(spectrum, sliderValue$1(yValue));
|
|
return Optional.some(yValue);
|
|
};
|
|
var handleMovement$1 = function (direction) {
|
|
return function (spectrum, detail) {
|
|
return moveBy$1(direction, spectrum, detail).map(always);
|
|
};
|
|
};
|
|
var getValueFromEvent$1 = function (simulatedEvent) {
|
|
var pos = getEventSource(simulatedEvent);
|
|
return pos.map(function (p) {
|
|
return p.top;
|
|
});
|
|
};
|
|
var findOffsetOfValue = function (spectrum, detail, value, minEdge, maxEdge) {
|
|
var minOffset = 0;
|
|
var maxOffset = getYScreenRange(spectrum);
|
|
var centerMinEdge = minEdge.bind(function (edge) {
|
|
return Optional.some(getYCenterOffSetOf(edge, spectrum));
|
|
}).getOr(minOffset);
|
|
var centerMaxEdge = maxEdge.bind(function (edge) {
|
|
return Optional.some(getYCenterOffSetOf(edge, spectrum));
|
|
}).getOr(maxOffset);
|
|
var args = {
|
|
min: minY(detail),
|
|
max: maxY(detail),
|
|
range: yRange(detail),
|
|
value: value,
|
|
hasMinEdge: hasTEdge(detail),
|
|
hasMaxEdge: hasBEdge(detail),
|
|
minBound: getMinYBounds(spectrum),
|
|
minOffset: minOffset,
|
|
maxBound: getMaxYBounds(spectrum),
|
|
maxOffset: maxOffset,
|
|
centerMinEdge: centerMinEdge,
|
|
centerMaxEdge: centerMaxEdge
|
|
};
|
|
return findOffsetOfValue$2(args);
|
|
};
|
|
var findPositionOfValue = function (slider, spectrum, value, minEdge, maxEdge, detail) {
|
|
var offset = findOffsetOfValue(spectrum, detail, value, minEdge, maxEdge);
|
|
return getMinYBounds(spectrum) - getMinYBounds(slider) + offset;
|
|
};
|
|
var setPositionFromValue$1 = function (slider, thumb, detail, edges) {
|
|
var value = currentValue(detail);
|
|
var pos = findPositionOfValue(slider, edges.getSpectrum(slider), value.y, edges.getTopEdge(slider), edges.getBottomEdge(slider), detail);
|
|
var thumbRadius = get$b(thumb.element) / 2;
|
|
set$7(thumb.element, 'top', pos - thumbRadius + 'px');
|
|
};
|
|
var onLeft$1 = Optional.none;
|
|
var onRight$1 = Optional.none;
|
|
var onUp$1 = handleMovement$1(-1);
|
|
var onDown$1 = handleMovement$1(1);
|
|
var edgeActions$1 = {
|
|
'top-left': Optional.none(),
|
|
'top': Optional.some(setToTEdge),
|
|
'top-right': Optional.none(),
|
|
'right': Optional.none(),
|
|
'bottom-right': Optional.none(),
|
|
'bottom': Optional.some(setToBEdge),
|
|
'bottom-left': Optional.none(),
|
|
'left': Optional.none()
|
|
};
|
|
|
|
var VerticalModel = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setValueFrom: setValueFrom$1,
|
|
setToMin: setToMin$1,
|
|
setToMax: setToMax$1,
|
|
findValueOfOffset: findValueOfOffset,
|
|
getValueFromEvent: getValueFromEvent$1,
|
|
findPositionOfValue: findPositionOfValue,
|
|
setPositionFromValue: setPositionFromValue$1,
|
|
onLeft: onLeft$1,
|
|
onRight: onRight$1,
|
|
onUp: onUp$1,
|
|
onDown: onDown$1,
|
|
edgeActions: edgeActions$1
|
|
});
|
|
|
|
var fireSliderChange = function (spectrum, value) {
|
|
emitWith(spectrum, sliderChangeEvent(), { value: value });
|
|
};
|
|
var sliderValue = function (x, y) {
|
|
return {
|
|
x: x,
|
|
y: y
|
|
};
|
|
};
|
|
var setValueFrom = function (spectrum, detail, value) {
|
|
var xValue = findValueOfOffset$1(spectrum, detail, value.left);
|
|
var yValue = findValueOfOffset(spectrum, detail, value.top);
|
|
var val = sliderValue(xValue, yValue);
|
|
fireSliderChange(spectrum, val);
|
|
return val;
|
|
};
|
|
var moveBy = function (direction, isVerticalMovement, spectrum, detail) {
|
|
var f = direction > 0 ? increaseBy : reduceBy;
|
|
var xValue = isVerticalMovement ? currentValue(detail).x : f(currentValue(detail).x, minX(detail), maxX(detail), step(detail));
|
|
var yValue = !isVerticalMovement ? currentValue(detail).y : f(currentValue(detail).y, minY(detail), maxY(detail), step(detail));
|
|
fireSliderChange(spectrum, sliderValue(xValue, yValue));
|
|
return Optional.some(xValue);
|
|
};
|
|
var handleMovement = function (direction, isVerticalMovement) {
|
|
return function (spectrum, detail) {
|
|
return moveBy(direction, isVerticalMovement, spectrum, detail).map(always);
|
|
};
|
|
};
|
|
var setToMin = function (spectrum, detail) {
|
|
var mX = minX(detail);
|
|
var mY = minY(detail);
|
|
fireSliderChange(spectrum, sliderValue(mX, mY));
|
|
};
|
|
var setToMax = function (spectrum, detail) {
|
|
var mX = maxX(detail);
|
|
var mY = maxY(detail);
|
|
fireSliderChange(spectrum, sliderValue(mX, mY));
|
|
};
|
|
var getValueFromEvent = function (simulatedEvent) {
|
|
return getEventSource(simulatedEvent);
|
|
};
|
|
var setPositionFromValue = function (slider, thumb, detail, edges) {
|
|
var value = currentValue(detail);
|
|
var xPos = findPositionOfValue$1(slider, edges.getSpectrum(slider), value.x, edges.getLeftEdge(slider), edges.getRightEdge(slider), detail);
|
|
var yPos = findPositionOfValue(slider, edges.getSpectrum(slider), value.y, edges.getTopEdge(slider), edges.getBottomEdge(slider), detail);
|
|
var thumbXRadius = get$a(thumb.element) / 2;
|
|
var thumbYRadius = get$b(thumb.element) / 2;
|
|
set$7(thumb.element, 'left', xPos - thumbXRadius + 'px');
|
|
set$7(thumb.element, 'top', yPos - thumbYRadius + 'px');
|
|
};
|
|
var onLeft = handleMovement(-1, false);
|
|
var onRight = handleMovement(1, false);
|
|
var onUp = handleMovement(-1, true);
|
|
var onDown = handleMovement(1, true);
|
|
var edgeActions = {
|
|
'top-left': Optional.some(setToTLEdgeXY),
|
|
'top': Optional.some(setToTEdgeXY),
|
|
'top-right': Optional.some(setToTREdgeXY),
|
|
'right': Optional.some(setToREdgeXY),
|
|
'bottom-right': Optional.some(setToBREdgeXY),
|
|
'bottom': Optional.some(setToBEdgeXY),
|
|
'bottom-left': Optional.some(setToBLEdgeXY),
|
|
'left': Optional.some(setToLEdgeXY)
|
|
};
|
|
|
|
var TwoDModel = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setValueFrom: setValueFrom,
|
|
setToMin: setToMin,
|
|
setToMax: setToMax,
|
|
getValueFromEvent: getValueFromEvent,
|
|
setPositionFromValue: setPositionFromValue,
|
|
onLeft: onLeft,
|
|
onRight: onRight,
|
|
onUp: onUp,
|
|
onDown: onDown,
|
|
edgeActions: edgeActions
|
|
});
|
|
|
|
var SliderSchema = [
|
|
defaulted('stepSize', 1),
|
|
defaulted('onChange', noop),
|
|
defaulted('onChoose', noop),
|
|
defaulted('onInit', noop),
|
|
defaulted('onDragStart', noop),
|
|
defaulted('onDragEnd', noop),
|
|
defaulted('snapToGrid', false),
|
|
defaulted('rounded', true),
|
|
option('snapStart'),
|
|
requiredOf('model', choose$1('mode', {
|
|
x: [
|
|
defaulted('minX', 0),
|
|
defaulted('maxX', 100),
|
|
customField('value', function (spec) {
|
|
return Cell(spec.mode.minX);
|
|
}),
|
|
required$1('getInitialValue'),
|
|
output$1('manager', HorizontalModel)
|
|
],
|
|
y: [
|
|
defaulted('minY', 0),
|
|
defaulted('maxY', 100),
|
|
customField('value', function (spec) {
|
|
return Cell(spec.mode.minY);
|
|
}),
|
|
required$1('getInitialValue'),
|
|
output$1('manager', VerticalModel)
|
|
],
|
|
xy: [
|
|
defaulted('minX', 0),
|
|
defaulted('maxX', 100),
|
|
defaulted('minY', 0),
|
|
defaulted('maxY', 100),
|
|
customField('value', function (spec) {
|
|
return Cell({
|
|
x: spec.mode.minX,
|
|
y: spec.mode.minY
|
|
});
|
|
}),
|
|
required$1('getInitialValue'),
|
|
output$1('manager', TwoDModel)
|
|
]
|
|
})),
|
|
field('sliderBehaviours', [
|
|
Keying,
|
|
Representing
|
|
]),
|
|
customField('mouseIsDown', function () {
|
|
return Cell(false);
|
|
})
|
|
];
|
|
|
|
var sketch$2 = function (detail, components, _spec, _externals) {
|
|
var _a;
|
|
var getThumb = function (component) {
|
|
return getPartOrDie(component, detail, 'thumb');
|
|
};
|
|
var getSpectrum = function (component) {
|
|
return getPartOrDie(component, detail, 'spectrum');
|
|
};
|
|
var getLeftEdge = function (component) {
|
|
return getPart(component, detail, 'left-edge');
|
|
};
|
|
var getRightEdge = function (component) {
|
|
return getPart(component, detail, 'right-edge');
|
|
};
|
|
var getTopEdge = function (component) {
|
|
return getPart(component, detail, 'top-edge');
|
|
};
|
|
var getBottomEdge = function (component) {
|
|
return getPart(component, detail, 'bottom-edge');
|
|
};
|
|
var modelDetail = detail.model;
|
|
var model = modelDetail.manager;
|
|
var refresh = function (slider, thumb) {
|
|
model.setPositionFromValue(slider, thumb, detail, {
|
|
getLeftEdge: getLeftEdge,
|
|
getRightEdge: getRightEdge,
|
|
getTopEdge: getTopEdge,
|
|
getBottomEdge: getBottomEdge,
|
|
getSpectrum: getSpectrum
|
|
});
|
|
};
|
|
var setValue = function (slider, newValue) {
|
|
modelDetail.value.set(newValue);
|
|
var thumb = getThumb(slider);
|
|
refresh(slider, thumb);
|
|
};
|
|
var changeValue = function (slider, newValue) {
|
|
setValue(slider, newValue);
|
|
var thumb = getThumb(slider);
|
|
detail.onChange(slider, thumb, newValue);
|
|
return Optional.some(true);
|
|
};
|
|
var resetToMin = function (slider) {
|
|
model.setToMin(slider, detail);
|
|
};
|
|
var resetToMax = function (slider) {
|
|
model.setToMax(slider, detail);
|
|
};
|
|
var choose = function (slider) {
|
|
var fireOnChoose = function () {
|
|
getPart(slider, detail, 'thumb').each(function (thumb) {
|
|
var value = modelDetail.value.get();
|
|
detail.onChoose(slider, thumb, value);
|
|
});
|
|
};
|
|
var wasDown = detail.mouseIsDown.get();
|
|
detail.mouseIsDown.set(false);
|
|
if (wasDown) {
|
|
fireOnChoose();
|
|
}
|
|
};
|
|
var onDragStart = function (slider, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
detail.mouseIsDown.set(true);
|
|
detail.onDragStart(slider, getThumb(slider));
|
|
};
|
|
var onDragEnd = function (slider, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
detail.onDragEnd(slider, getThumb(slider));
|
|
choose(slider);
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.sliderBehaviours, [
|
|
Keying.config({
|
|
mode: 'special',
|
|
focusIn: function (slider) {
|
|
return getPart(slider, detail, 'spectrum').map(Keying.focusIn).map(always);
|
|
}
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (_) {
|
|
return modelDetail.value.get();
|
|
}
|
|
}
|
|
}),
|
|
Receiving.config({ channels: (_a = {}, _a[mouseReleased()] = { onReceive: choose }, _a) })
|
|
]),
|
|
events: derive$2([
|
|
run$1(sliderChangeEvent(), function (slider, simulatedEvent) {
|
|
changeValue(slider, simulatedEvent.event.value);
|
|
}),
|
|
runOnAttached(function (slider, _simulatedEvent) {
|
|
var getInitial = modelDetail.getInitialValue();
|
|
modelDetail.value.set(getInitial);
|
|
var thumb = getThumb(slider);
|
|
refresh(slider, thumb);
|
|
var spectrum = getSpectrum(slider);
|
|
detail.onInit(slider, thumb, spectrum, modelDetail.value.get());
|
|
}),
|
|
run$1(touchstart(), onDragStart),
|
|
run$1(touchend(), onDragEnd),
|
|
run$1(mousedown(), onDragStart),
|
|
run$1(mouseup(), onDragEnd)
|
|
]),
|
|
apis: {
|
|
resetToMin: resetToMin,
|
|
resetToMax: resetToMax,
|
|
setValue: setValue,
|
|
refresh: refresh
|
|
},
|
|
domModification: { styles: { position: 'relative' } }
|
|
};
|
|
};
|
|
|
|
var Slider = composite({
|
|
name: 'Slider',
|
|
configFields: SliderSchema,
|
|
partFields: SliderParts,
|
|
factory: sketch$2,
|
|
apis: {
|
|
setValue: function (apis, slider, value) {
|
|
apis.setValue(slider, value);
|
|
},
|
|
resetToMin: function (apis, slider) {
|
|
apis.resetToMin(slider);
|
|
},
|
|
resetToMax: function (apis, slider) {
|
|
apis.resetToMax(slider);
|
|
},
|
|
refresh: function (apis, slider) {
|
|
apis.refresh(slider);
|
|
}
|
|
}
|
|
});
|
|
|
|
var fieldsUpdate = generate$6('rgb-hex-update');
|
|
var sliderUpdate = generate$6('slider-update');
|
|
var paletteUpdate = generate$6('palette-update');
|
|
|
|
var sliderFactory = function (translate, getClass) {
|
|
var spectrum = Slider.parts.spectrum({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [getClass('hue-slider-spectrum')],
|
|
attributes: { role: 'presentation' }
|
|
}
|
|
});
|
|
var thumb = Slider.parts.thumb({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [getClass('hue-slider-thumb')],
|
|
attributes: { role: 'presentation' }
|
|
}
|
|
});
|
|
return Slider.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [getClass('hue-slider')],
|
|
attributes: { role: 'presentation' }
|
|
},
|
|
rounded: false,
|
|
model: {
|
|
mode: 'y',
|
|
getInitialValue: constant$1({ y: 0 })
|
|
},
|
|
components: [
|
|
spectrum,
|
|
thumb
|
|
],
|
|
sliderBehaviours: derive$1([Focusing.config({})]),
|
|
onChange: function (slider, _thumb, value) {
|
|
emitWith(slider, sliderUpdate, { value: value });
|
|
}
|
|
});
|
|
};
|
|
|
|
var owner$1 = 'form';
|
|
var schema$i = [field('formBehaviours', [Representing])];
|
|
var getPartName$1 = function (name) {
|
|
return '<alloy.field.' + name + '>';
|
|
};
|
|
var sketch$1 = function (fSpec) {
|
|
var parts = function () {
|
|
var record = [];
|
|
var field = function (name, config) {
|
|
record.push(name);
|
|
return generateOne$1(owner$1, getPartName$1(name), config);
|
|
};
|
|
return {
|
|
field: field,
|
|
record: constant$1(record)
|
|
};
|
|
}();
|
|
var spec = fSpec(parts);
|
|
var partNames = parts.record();
|
|
var fieldParts = map$2(partNames, function (n) {
|
|
return required({
|
|
name: n,
|
|
pname: getPartName$1(n)
|
|
});
|
|
});
|
|
return composite$1(owner$1, schema$i, fieldParts, make$4, spec);
|
|
};
|
|
var toResult = function (o, e) {
|
|
return o.fold(function () {
|
|
return Result.error(e);
|
|
}, Result.value);
|
|
};
|
|
var make$4 = function (detail, components) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.formBehaviours, [Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (form) {
|
|
var resPs = getAllParts(form, detail);
|
|
return map$1(resPs, function (resPThunk, pName) {
|
|
return resPThunk().bind(function (v) {
|
|
var opt = Composing.getCurrent(v);
|
|
return toResult(opt, new Error('Cannot find a current component to extract the value from for form part \'' + pName + '\': ' + element(v.element)));
|
|
}).map(Representing.getValue);
|
|
});
|
|
},
|
|
setValue: function (form, values) {
|
|
each(values, function (newValue, key) {
|
|
getPart(form, detail, key).each(function (wrapper) {
|
|
Composing.getCurrent(wrapper).each(function (field) {
|
|
Representing.setValue(field, newValue);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
})]),
|
|
apis: {
|
|
getField: function (form, key) {
|
|
return getPart(form, detail, key).bind(Composing.getCurrent);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var Form = {
|
|
getField: makeApi(function (apis, component, key) {
|
|
return apis.getField(component, key);
|
|
}),
|
|
sketch: sketch$1
|
|
};
|
|
|
|
var validInput = generate$6('valid-input');
|
|
var invalidInput = generate$6('invalid-input');
|
|
var validatingInput = generate$6('validating-input');
|
|
var translatePrefix = 'colorcustom.rgb.';
|
|
var rgbFormFactory = function (translate, getClass, onValidHexx, onInvalidHexx) {
|
|
var invalidation = function (label, isValid) {
|
|
return Invalidating.config({
|
|
invalidClass: getClass('invalid'),
|
|
notify: {
|
|
onValidate: function (comp) {
|
|
emitWith(comp, validatingInput, { type: label });
|
|
},
|
|
onValid: function (comp) {
|
|
emitWith(comp, validInput, {
|
|
type: label,
|
|
value: Representing.getValue(comp)
|
|
});
|
|
},
|
|
onInvalid: function (comp) {
|
|
emitWith(comp, invalidInput, {
|
|
type: label,
|
|
value: Representing.getValue(comp)
|
|
});
|
|
}
|
|
},
|
|
validator: {
|
|
validate: function (comp) {
|
|
var value = Representing.getValue(comp);
|
|
var res = isValid(value) ? Result.value(true) : Result.error(translate('aria.input.invalid'));
|
|
return Future.pure(res);
|
|
},
|
|
validateOnLoad: false
|
|
}
|
|
});
|
|
};
|
|
var renderTextField = function (isValid, name, label, description, data) {
|
|
var helptext = translate(translatePrefix + 'range');
|
|
var pLabel = FormField.parts.label({
|
|
dom: {
|
|
tag: 'label',
|
|
innerHtml: label,
|
|
attributes: { 'aria-label': description }
|
|
}
|
|
});
|
|
var pField = FormField.parts.field({
|
|
data: data,
|
|
factory: Input,
|
|
inputAttributes: __assign({ type: 'text' }, name === 'hex' ? { 'aria-live': 'polite' } : {}),
|
|
inputClasses: [getClass('textfield')],
|
|
inputBehaviours: derive$1([
|
|
invalidation(name, isValid),
|
|
Tabstopping.config({})
|
|
]),
|
|
onSetValue: function (input) {
|
|
if (Invalidating.isInvalid(input)) {
|
|
var run = Invalidating.run(input);
|
|
run.get(noop);
|
|
}
|
|
}
|
|
});
|
|
var comps = [
|
|
pLabel,
|
|
pField
|
|
];
|
|
var concats = name !== 'hex' ? [FormField.parts['aria-descriptor']({ text: helptext })] : [];
|
|
var components = comps.concat(concats);
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { role: 'presentation' }
|
|
},
|
|
components: components
|
|
};
|
|
};
|
|
var copyRgbToHex = function (form, rgba) {
|
|
var hex = fromRgba(rgba);
|
|
Form.getField(form, 'hex').each(function (hexField) {
|
|
if (!Focusing.isFocused(hexField)) {
|
|
Representing.setValue(form, { hex: hex.value });
|
|
}
|
|
});
|
|
return hex;
|
|
};
|
|
var copyRgbToForm = function (form, rgb) {
|
|
var red = rgb.red;
|
|
var green = rgb.green;
|
|
var blue = rgb.blue;
|
|
Representing.setValue(form, {
|
|
red: red,
|
|
green: green,
|
|
blue: blue
|
|
});
|
|
};
|
|
var memPreview = record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [getClass('rgba-preview')],
|
|
styles: { 'background-color': 'white' },
|
|
attributes: { role: 'presentation' }
|
|
}
|
|
});
|
|
var updatePreview = function (anyInSystem, hex) {
|
|
memPreview.getOpt(anyInSystem).each(function (preview) {
|
|
set$7(preview.element, 'background-color', '#' + hex.value);
|
|
});
|
|
};
|
|
var factory = function () {
|
|
var state = {
|
|
red: Cell(Optional.some(255)),
|
|
green: Cell(Optional.some(255)),
|
|
blue: Cell(Optional.some(255)),
|
|
hex: Cell(Optional.some('ffffff'))
|
|
};
|
|
var copyHexToRgb = function (form, hex) {
|
|
var rgb = fromHex(hex);
|
|
copyRgbToForm(form, rgb);
|
|
setValueRgb(rgb);
|
|
};
|
|
var get = function (prop) {
|
|
return state[prop].get();
|
|
};
|
|
var set = function (prop, value) {
|
|
state[prop].set(value);
|
|
};
|
|
var getValueRgb = function () {
|
|
return get('red').bind(function (red) {
|
|
return get('green').bind(function (green) {
|
|
return get('blue').map(function (blue) {
|
|
return rgbaColour(red, green, blue, 1);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var setValueRgb = function (rgb) {
|
|
var red = rgb.red;
|
|
var green = rgb.green;
|
|
var blue = rgb.blue;
|
|
set('red', Optional.some(red));
|
|
set('green', Optional.some(green));
|
|
set('blue', Optional.some(blue));
|
|
};
|
|
var onInvalidInput = function (form, simulatedEvent) {
|
|
var data = simulatedEvent.event;
|
|
if (data.type !== 'hex') {
|
|
set(data.type, Optional.none());
|
|
} else {
|
|
onInvalidHexx(form);
|
|
}
|
|
};
|
|
var onValidHex = function (form, value) {
|
|
onValidHexx(form);
|
|
var hex = hexColour(value);
|
|
set('hex', Optional.some(value));
|
|
var rgb = fromHex(hex);
|
|
copyRgbToForm(form, rgb);
|
|
setValueRgb(rgb);
|
|
emitWith(form, fieldsUpdate, { hex: hex });
|
|
updatePreview(form, hex);
|
|
};
|
|
var onValidRgb = function (form, prop, value) {
|
|
var val = parseInt(value, 10);
|
|
set(prop, Optional.some(val));
|
|
getValueRgb().each(function (rgb) {
|
|
var hex = copyRgbToHex(form, rgb);
|
|
emitWith(form, fieldsUpdate, { hex: hex });
|
|
updatePreview(form, hex);
|
|
});
|
|
};
|
|
var isHexInputEvent = function (data) {
|
|
return data.type === 'hex';
|
|
};
|
|
var onValidInput = function (form, simulatedEvent) {
|
|
var data = simulatedEvent.event;
|
|
if (isHexInputEvent(data)) {
|
|
onValidHex(form, data.value);
|
|
} else {
|
|
onValidRgb(form, data.type, data.value);
|
|
}
|
|
};
|
|
var formPartStrings = function (key) {
|
|
return {
|
|
label: translate(translatePrefix + key + '.label'),
|
|
description: translate(translatePrefix + key + '.description')
|
|
};
|
|
};
|
|
var redStrings = formPartStrings('red');
|
|
var greenStrings = formPartStrings('green');
|
|
var blueStrings = formPartStrings('blue');
|
|
var hexStrings = formPartStrings('hex');
|
|
return deepMerge(Form.sketch(function (parts) {
|
|
return {
|
|
dom: {
|
|
tag: 'form',
|
|
classes: [getClass('rgb-form')],
|
|
attributes: { 'aria-label': translate('aria.color.picker') }
|
|
},
|
|
components: [
|
|
parts.field('red', FormField.sketch(renderTextField(isRgbaComponent, 'red', redStrings.label, redStrings.description, 255))),
|
|
parts.field('green', FormField.sketch(renderTextField(isRgbaComponent, 'green', greenStrings.label, greenStrings.description, 255))),
|
|
parts.field('blue', FormField.sketch(renderTextField(isRgbaComponent, 'blue', blueStrings.label, blueStrings.description, 255))),
|
|
parts.field('hex', FormField.sketch(renderTextField(isHexString, 'hex', hexStrings.label, hexStrings.description, 'ffffff'))),
|
|
memPreview.asSpec()
|
|
],
|
|
formBehaviours: derive$1([
|
|
Invalidating.config({ invalidClass: getClass('form-invalid') }),
|
|
config('rgb-form-events', [
|
|
run$1(validInput, onValidInput),
|
|
run$1(invalidInput, onInvalidInput),
|
|
run$1(validatingInput, onInvalidInput)
|
|
])
|
|
])
|
|
};
|
|
}), {
|
|
apis: {
|
|
updateHex: function (form, hex) {
|
|
Representing.setValue(form, { hex: hex.value });
|
|
copyHexToRgb(form, hex);
|
|
updatePreview(form, hex);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
var rgbFormSketcher = single({
|
|
factory: factory,
|
|
name: 'RgbForm',
|
|
configFields: [],
|
|
apis: {
|
|
updateHex: function (apis, form, hex) {
|
|
apis.updateHex(form, hex);
|
|
}
|
|
},
|
|
extraApis: {}
|
|
});
|
|
return rgbFormSketcher;
|
|
};
|
|
|
|
var paletteFactory = function (_translate, getClass) {
|
|
var spectrumPart = Slider.parts.spectrum({
|
|
dom: {
|
|
tag: 'canvas',
|
|
attributes: { role: 'presentation' },
|
|
classes: [getClass('sv-palette-spectrum')]
|
|
}
|
|
});
|
|
var thumbPart = Slider.parts.thumb({
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { role: 'presentation' },
|
|
classes: [getClass('sv-palette-thumb')],
|
|
innerHtml: '<div class=' + getClass('sv-palette-inner-thumb') + ' role="presentation"></div>'
|
|
}
|
|
});
|
|
var setColour = function (canvas, rgba) {
|
|
var width = canvas.width, height = canvas.height;
|
|
var ctx = canvas.getContext('2d');
|
|
if (ctx === null) {
|
|
return;
|
|
}
|
|
ctx.fillStyle = rgba;
|
|
ctx.fillRect(0, 0, width, height);
|
|
var grdWhite = ctx.createLinearGradient(0, 0, width, 0);
|
|
grdWhite.addColorStop(0, 'rgba(255,255,255,1)');
|
|
grdWhite.addColorStop(1, 'rgba(255,255,255,0)');
|
|
ctx.fillStyle = grdWhite;
|
|
ctx.fillRect(0, 0, width, height);
|
|
var grdBlack = ctx.createLinearGradient(0, 0, 0, height);
|
|
grdBlack.addColorStop(0, 'rgba(0,0,0,0)');
|
|
grdBlack.addColorStop(1, 'rgba(0,0,0,1)');
|
|
ctx.fillStyle = grdBlack;
|
|
ctx.fillRect(0, 0, width, height);
|
|
};
|
|
var setPaletteHue = function (slider, hue) {
|
|
var canvas = slider.components()[0].element.dom;
|
|
var hsv = hsvColour(hue, 100, 100);
|
|
var rgba = fromHsv(hsv);
|
|
setColour(canvas, toString(rgba));
|
|
};
|
|
var setPaletteThumb = function (slider, hex) {
|
|
var hsv = fromRgb(fromHex(hex));
|
|
Slider.setValue(slider, {
|
|
x: hsv.saturation,
|
|
y: 100 - hsv.value
|
|
});
|
|
};
|
|
var factory = function (_detail) {
|
|
var getInitialValue = constant$1({
|
|
x: 0,
|
|
y: 0
|
|
});
|
|
var onChange = function (slider, _thumb, value) {
|
|
emitWith(slider, paletteUpdate, { value: value });
|
|
};
|
|
var onInit = function (_slider, _thumb, spectrum, _value) {
|
|
setColour(spectrum.element.dom, toString(red));
|
|
};
|
|
var sliderBehaviours = derive$1([
|
|
Composing.config({ find: Optional.some }),
|
|
Focusing.config({})
|
|
]);
|
|
return Slider.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { role: 'presentation' },
|
|
classes: [getClass('sv-palette')]
|
|
},
|
|
model: {
|
|
mode: 'xy',
|
|
getInitialValue: getInitialValue
|
|
},
|
|
rounded: false,
|
|
components: [
|
|
spectrumPart,
|
|
thumbPart
|
|
],
|
|
onChange: onChange,
|
|
onInit: onInit,
|
|
sliderBehaviours: sliderBehaviours
|
|
});
|
|
};
|
|
var saturationBrightnessPaletteSketcher = single({
|
|
factory: factory,
|
|
name: 'SaturationBrightnessPalette',
|
|
configFields: [],
|
|
apis: {
|
|
setHue: function (_apis, slider, hue) {
|
|
setPaletteHue(slider, hue);
|
|
},
|
|
setThumb: function (_apis, slider, hex) {
|
|
setPaletteThumb(slider, hex);
|
|
}
|
|
},
|
|
extraApis: {}
|
|
});
|
|
return saturationBrightnessPaletteSketcher;
|
|
};
|
|
|
|
var makeFactory = function (translate, getClass) {
|
|
var factory = function (detail) {
|
|
var rgbForm = rgbFormFactory(translate, getClass, detail.onValidHex, detail.onInvalidHex);
|
|
var sbPalette = paletteFactory(translate, getClass);
|
|
var hueSliderToDegrees = function (hue) {
|
|
return (100 - hue) / 100 * 360;
|
|
};
|
|
var hueDegreesToSlider = function (hue) {
|
|
return 100 - hue / 360 * 100;
|
|
};
|
|
var state = {
|
|
paletteRgba: Cell(red),
|
|
paletteHue: Cell(0)
|
|
};
|
|
var memSlider = record(sliderFactory(translate, getClass));
|
|
var memPalette = record(sbPalette.sketch({}));
|
|
var memRgb = record(rgbForm.sketch({}));
|
|
var updatePalette = function (anyInSystem, _hex, hue) {
|
|
memPalette.getOpt(anyInSystem).each(function (palette) {
|
|
sbPalette.setHue(palette, hue);
|
|
});
|
|
};
|
|
var updateFields = function (anyInSystem, hex) {
|
|
memRgb.getOpt(anyInSystem).each(function (form) {
|
|
rgbForm.updateHex(form, hex);
|
|
});
|
|
};
|
|
var updateSlider = function (anyInSystem, _hex, hue) {
|
|
memSlider.getOpt(anyInSystem).each(function (slider) {
|
|
Slider.setValue(slider, { y: hueDegreesToSlider(hue) });
|
|
});
|
|
};
|
|
var updatePaletteThumb = function (anyInSystem, hex) {
|
|
memPalette.getOpt(anyInSystem).each(function (palette) {
|
|
sbPalette.setThumb(palette, hex);
|
|
});
|
|
};
|
|
var updateState = function (hex, hue) {
|
|
var rgba = fromHex(hex);
|
|
state.paletteRgba.set(rgba);
|
|
state.paletteHue.set(hue);
|
|
};
|
|
var runUpdates = function (anyInSystem, hex, hue, updates) {
|
|
updateState(hex, hue);
|
|
each$1(updates, function (update) {
|
|
update(anyInSystem, hex, hue);
|
|
});
|
|
};
|
|
var onPaletteUpdate = function () {
|
|
var updates = [updateFields];
|
|
return function (form, simulatedEvent) {
|
|
var value = simulatedEvent.event.value;
|
|
var oldHue = state.paletteHue.get();
|
|
var newHsv = hsvColour(oldHue, value.x, 100 - value.y);
|
|
var newHex = hsvToHex(newHsv);
|
|
runUpdates(form, newHex, oldHue, updates);
|
|
};
|
|
};
|
|
var onSliderUpdate = function () {
|
|
var updates = [
|
|
updatePalette,
|
|
updateFields
|
|
];
|
|
return function (form, simulatedEvent) {
|
|
var hue = hueSliderToDegrees(simulatedEvent.event.value.y);
|
|
var oldRgb = state.paletteRgba.get();
|
|
var oldHsv = fromRgb(oldRgb);
|
|
var newHsv = hsvColour(hue, oldHsv.saturation, oldHsv.value);
|
|
var newHex = hsvToHex(newHsv);
|
|
runUpdates(form, newHex, hue, updates);
|
|
};
|
|
};
|
|
var onFieldsUpdate = function () {
|
|
var updates = [
|
|
updatePalette,
|
|
updateSlider,
|
|
updatePaletteThumb
|
|
];
|
|
return function (form, simulatedEvent) {
|
|
var hex = simulatedEvent.event.hex;
|
|
var hsv = hexToHsv(hex);
|
|
runUpdates(form, hex, hsv.hue, updates);
|
|
};
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: [
|
|
memPalette.asSpec(),
|
|
memSlider.asSpec(),
|
|
memRgb.asSpec()
|
|
],
|
|
behaviours: derive$1([
|
|
config('colour-picker-events', [
|
|
run$1(fieldsUpdate, onFieldsUpdate()),
|
|
run$1(paletteUpdate, onPaletteUpdate()),
|
|
run$1(sliderUpdate, onSliderUpdate())
|
|
]),
|
|
Composing.config({
|
|
find: function (comp) {
|
|
return memRgb.getOpt(comp);
|
|
}
|
|
}),
|
|
Keying.config({ mode: 'acyclic' })
|
|
])
|
|
};
|
|
};
|
|
var colourPickerSketcher = single({
|
|
name: 'ColourPicker',
|
|
configFields: [
|
|
required$1('dom'),
|
|
defaulted('onValidHex', noop),
|
|
defaulted('onInvalidHex', noop)
|
|
],
|
|
factory: factory
|
|
});
|
|
return colourPickerSketcher;
|
|
};
|
|
|
|
var self$1 = function () {
|
|
return Composing.config({ find: Optional.some });
|
|
};
|
|
var memento$1 = function (mem) {
|
|
return Composing.config({ find: mem.getOpt });
|
|
};
|
|
var childAt = function (index) {
|
|
return Composing.config({
|
|
find: function (comp) {
|
|
return child$2(comp.element, index).bind(function (element) {
|
|
return comp.getSystem().getByDom(element).toOptional();
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var ComposingConfigs = {
|
|
self: self$1,
|
|
memento: memento$1,
|
|
childAt: childAt
|
|
};
|
|
|
|
var english = {
|
|
'colorcustom.rgb.red.label': 'R',
|
|
'colorcustom.rgb.red.description': 'Red component',
|
|
'colorcustom.rgb.green.label': 'G',
|
|
'colorcustom.rgb.green.description': 'Green component',
|
|
'colorcustom.rgb.blue.label': 'B',
|
|
'colorcustom.rgb.blue.description': 'Blue component',
|
|
'colorcustom.rgb.hex.label': '#',
|
|
'colorcustom.rgb.hex.description': 'Hex color code',
|
|
'colorcustom.rgb.range': 'Range 0 to 255',
|
|
'colorcustom.sb.saturation': 'Saturation',
|
|
'colorcustom.sb.brightness': 'Brightness',
|
|
'colorcustom.sb.picker': 'Saturation and Brightness Picker',
|
|
'colorcustom.sb.palette': 'Saturation and Brightness Palette',
|
|
'colorcustom.sb.instructions': 'Use arrow keys to select saturation and brightness, on x and y axes',
|
|
'colorcustom.hue.hue': 'Hue',
|
|
'colorcustom.hue.slider': 'Hue Slider',
|
|
'colorcustom.hue.palette': 'Hue Palette',
|
|
'colorcustom.hue.instructions': 'Use arrow keys to select a hue',
|
|
'aria.color.picker': 'Color Picker',
|
|
'aria.input.invalid': 'Invalid input'
|
|
};
|
|
var getEnglishText = function (key) {
|
|
return english[key];
|
|
};
|
|
var translate$1 = function (key) {
|
|
return getEnglishText(key);
|
|
};
|
|
var renderColorPicker = function (_spec) {
|
|
var getClass = function (key) {
|
|
return 'tox-' + key;
|
|
};
|
|
var colourPickerFactory = makeFactory(translate$1, getClass);
|
|
var onValidHex = function (form) {
|
|
emitWith(form, formActionEvent, {
|
|
name: 'hex-valid',
|
|
value: true
|
|
});
|
|
};
|
|
var onInvalidHex = function (form) {
|
|
emitWith(form, formActionEvent, {
|
|
name: 'hex-valid',
|
|
value: false
|
|
});
|
|
};
|
|
var memPicker = record(colourPickerFactory.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [getClass('color-picker-container')],
|
|
attributes: { role: 'presentation' }
|
|
},
|
|
onValidHex: onValidHex,
|
|
onInvalidHex: onInvalidHex
|
|
}));
|
|
return {
|
|
dom: { tag: 'div' },
|
|
components: [memPicker.asSpec()],
|
|
behaviours: derive$1([
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (comp) {
|
|
var picker = memPicker.get(comp);
|
|
var optRgbForm = Composing.getCurrent(picker);
|
|
var optHex = optRgbForm.bind(function (rgbForm) {
|
|
var formValues = Representing.getValue(rgbForm);
|
|
return formValues.hex;
|
|
});
|
|
return optHex.map(function (hex) {
|
|
return '#' + hex;
|
|
}).getOr('');
|
|
},
|
|
setValue: function (comp, newValue) {
|
|
var pattern = /^#([a-fA-F0-9]{3}(?:[a-fA-F0-9]{3})?)/;
|
|
var m = pattern.exec(newValue);
|
|
var picker = memPicker.get(comp);
|
|
var optRgbForm = Composing.getCurrent(picker);
|
|
optRgbForm.fold(function () {
|
|
console.log('Can not find form');
|
|
}, function (rgbForm) {
|
|
Representing.setValue(rgbForm, { hex: Optional.from(m[1]).getOr('') });
|
|
Form.getField(rgbForm, 'hex').each(function (hexField) {
|
|
emit(hexField, input());
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}),
|
|
ComposingConfigs.self()
|
|
])
|
|
};
|
|
};
|
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.Resource');
|
|
|
|
var isOldCustomEditor = function (spec) {
|
|
return has$2(spec, 'init');
|
|
};
|
|
var renderCustomEditor = function (spec) {
|
|
var editorApi = value$1();
|
|
var memReplaced = record({ dom: { tag: spec.tag } });
|
|
var initialValue = value$1();
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-custom-editor']
|
|
},
|
|
behaviours: derive$1([
|
|
config('custom-editor-events', [runOnAttached(function (component) {
|
|
memReplaced.getOpt(component).each(function (ta) {
|
|
(isOldCustomEditor(spec) ? spec.init(ta.element.dom) : global$6.load(spec.scriptId, spec.scriptUrl).then(function (init) {
|
|
return init(ta.element.dom, spec.settings);
|
|
})).then(function (ea) {
|
|
initialValue.on(function (cvalue) {
|
|
ea.setValue(cvalue);
|
|
});
|
|
initialValue.clear();
|
|
editorApi.set(ea);
|
|
});
|
|
});
|
|
})]),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function () {
|
|
return editorApi.get().fold(function () {
|
|
return initialValue.get().getOr('');
|
|
}, function (ed) {
|
|
return ed.getValue();
|
|
});
|
|
},
|
|
setValue: function (component, value) {
|
|
editorApi.get().fold(function () {
|
|
initialValue.set(value);
|
|
}, function (ed) {
|
|
return ed.setValue(value);
|
|
});
|
|
}
|
|
}
|
|
}),
|
|
ComposingConfigs.self()
|
|
]),
|
|
components: [memReplaced.asSpec()]
|
|
};
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var processors = objOf([
|
|
defaulted('preprocess', identity$1),
|
|
defaulted('postprocess', identity$1)
|
|
]);
|
|
var memento = function (mem, rawProcessors) {
|
|
var ps = asRawOrDie$1('RepresentingConfigs.memento processors', processors, rawProcessors);
|
|
return Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (comp) {
|
|
var other = mem.get(comp);
|
|
var rawValue = Representing.getValue(other);
|
|
return ps.postprocess(rawValue);
|
|
},
|
|
setValue: function (comp, rawValue) {
|
|
var newValue = ps.preprocess(rawValue);
|
|
var other = mem.get(comp);
|
|
Representing.setValue(other, newValue);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
var withComp = function (optInitialValue, getter, setter) {
|
|
return Representing.config(deepMerge({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: getter,
|
|
setValue: setter
|
|
}
|
|
}, optInitialValue.map(function (initialValue) {
|
|
return { store: { initialValue: initialValue } };
|
|
}).getOr({})));
|
|
};
|
|
var withElement = function (initialValue, getter, setter) {
|
|
return withComp(initialValue, function (c) {
|
|
return getter(c.element);
|
|
}, function (c, v) {
|
|
return setter(c.element, v);
|
|
});
|
|
};
|
|
var domValue = function (optInitialValue) {
|
|
return withElement(optInitialValue, get$5, set$4);
|
|
};
|
|
var domHtml = function (optInitialValue) {
|
|
return withElement(optInitialValue, get$7, set$5);
|
|
};
|
|
var memory = function (initialValue) {
|
|
return Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: initialValue
|
|
}
|
|
});
|
|
};
|
|
var RepresentingConfigs = {
|
|
memento: memento,
|
|
withElement: withElement,
|
|
withComp: withComp,
|
|
domValue: domValue,
|
|
domHtml: domHtml,
|
|
memory: memory
|
|
};
|
|
|
|
var defaultImageFileTypes = 'jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp';
|
|
var filterByExtension = function (files, providersBackstage) {
|
|
var allowedImageFileTypes = global$5.explode(providersBackstage.getSetting('images_file_types', defaultImageFileTypes, 'string'));
|
|
var isFileInAllowedTypes = function (file) {
|
|
return exists(allowedImageFileTypes, function (type) {
|
|
return endsWith(file.name.toLowerCase(), '.' + type.toLowerCase());
|
|
});
|
|
};
|
|
return filter$2(from(files), isFileInAllowedTypes);
|
|
};
|
|
var renderDropZone = function (spec, providersBackstage) {
|
|
var stopper = function (_, se) {
|
|
se.stop();
|
|
};
|
|
var sequence = function (actions) {
|
|
return function (comp, se) {
|
|
each$1(actions, function (a) {
|
|
a(comp, se);
|
|
});
|
|
};
|
|
};
|
|
var onDrop = function (comp, se) {
|
|
if (!Disabling.isDisabled(comp)) {
|
|
var transferEvent = se.event.raw;
|
|
handleFiles(comp, transferEvent.dataTransfer.files);
|
|
}
|
|
};
|
|
var onSelect = function (component, simulatedEvent) {
|
|
var input = simulatedEvent.event.raw.target;
|
|
handleFiles(component, input.files);
|
|
};
|
|
var handleFiles = function (component, files) {
|
|
Representing.setValue(component, filterByExtension(files, providersBackstage));
|
|
emitWith(component, formChangeEvent, { name: spec.name });
|
|
};
|
|
var memInput = record({
|
|
dom: {
|
|
tag: 'input',
|
|
attributes: {
|
|
type: 'file',
|
|
accept: 'image/*'
|
|
},
|
|
styles: { display: 'none' }
|
|
},
|
|
behaviours: derive$1([config('input-file-events', [
|
|
cutter(click()),
|
|
cutter(tap())
|
|
])])
|
|
});
|
|
var renderField = function (s) {
|
|
return {
|
|
uid: s.uid,
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dropzone-container']
|
|
},
|
|
behaviours: derive$1([
|
|
RepresentingConfigs.memory([]),
|
|
ComposingConfigs.self(),
|
|
Disabling.config({}),
|
|
Toggling.config({
|
|
toggleClass: 'dragenter',
|
|
toggleOnExecute: false
|
|
}),
|
|
config('dropzone-events', [
|
|
run$1('dragenter', sequence([
|
|
stopper,
|
|
Toggling.toggle
|
|
])),
|
|
run$1('dragleave', sequence([
|
|
stopper,
|
|
Toggling.toggle
|
|
])),
|
|
run$1('dragover', stopper),
|
|
run$1('drop', sequence([
|
|
stopper,
|
|
onDrop
|
|
])),
|
|
run$1(change(), onSelect)
|
|
])
|
|
]),
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dropzone'],
|
|
styles: {}
|
|
},
|
|
components: [
|
|
{
|
|
dom: {
|
|
tag: 'p',
|
|
innerHtml: providersBackstage.translate('Drop an image here')
|
|
}
|
|
},
|
|
Button.sketch({
|
|
dom: {
|
|
tag: 'button',
|
|
innerHtml: providersBackstage.translate('Browse for an image'),
|
|
styles: { position: 'relative' },
|
|
classes: [
|
|
'tox-button',
|
|
'tox-button--secondary'
|
|
]
|
|
},
|
|
components: [memInput.asSpec()],
|
|
action: function (comp) {
|
|
var inputComp = memInput.get(comp);
|
|
inputComp.element.dom.click();
|
|
},
|
|
buttonBehaviours: derive$1([
|
|
Tabstopping.config({}),
|
|
DisablingConfigs.button(providersBackstage.isDisabled),
|
|
receivingConfig()
|
|
])
|
|
})
|
|
]
|
|
}]
|
|
};
|
|
};
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, providersBackstage);
|
|
});
|
|
var pField = FormField.parts.field({ factory: { sketch: renderField } });
|
|
return renderFormFieldWith(pLabel, pField, ['tox-form__group--stretched'], []);
|
|
};
|
|
|
|
var renderGrid = function (spec, backstage) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-form__grid',
|
|
'tox-form__grid--' + spec.columns + 'col'
|
|
]
|
|
},
|
|
components: map$2(spec.items, backstage.interpreter)
|
|
};
|
|
};
|
|
|
|
var beforeObject = generate$6('alloy-fake-before-tabstop');
|
|
var afterObject = generate$6('alloy-fake-after-tabstop');
|
|
var craftWithClasses = function (classes) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
styles: {
|
|
width: '1px',
|
|
height: '1px',
|
|
outline: 'none'
|
|
},
|
|
attributes: { tabindex: '0' },
|
|
classes: classes
|
|
},
|
|
behaviours: derive$1([
|
|
Focusing.config({ ignore: true }),
|
|
Tabstopping.config({})
|
|
])
|
|
};
|
|
};
|
|
var craft = function (spec) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-navobj']
|
|
},
|
|
components: [
|
|
craftWithClasses([beforeObject]),
|
|
spec,
|
|
craftWithClasses([afterObject])
|
|
],
|
|
behaviours: derive$1([ComposingConfigs.childAt(1)])
|
|
};
|
|
};
|
|
var triggerTab = function (placeholder, shiftKey) {
|
|
emitWith(placeholder, keydown(), {
|
|
raw: {
|
|
which: 9,
|
|
shiftKey: shiftKey
|
|
}
|
|
});
|
|
};
|
|
var onFocus = function (container, targetComp) {
|
|
var target = targetComp.element;
|
|
if (has(target, beforeObject)) {
|
|
triggerTab(container, true);
|
|
} else if (has(target, afterObject)) {
|
|
triggerTab(container, false);
|
|
}
|
|
};
|
|
var isPseudoStop = function (element) {
|
|
return closest(element, [
|
|
'.' + beforeObject,
|
|
'.' + afterObject
|
|
].join(','), never);
|
|
};
|
|
|
|
var platformNeedsSandboxing = !(detect$1().browser.isIE() || detect$1().browser.isEdge());
|
|
var getDynamicSource = function (isSandbox) {
|
|
var cachedValue = Cell('');
|
|
return {
|
|
getValue: function (_frameComponent) {
|
|
return cachedValue.get();
|
|
},
|
|
setValue: function (frameComponent, html) {
|
|
if (!isSandbox) {
|
|
set$8(frameComponent.element, 'src', 'javascript:\'\'');
|
|
var doc = frameComponent.element.dom.contentWindow.document;
|
|
doc.open();
|
|
doc.write(html);
|
|
doc.close();
|
|
} else {
|
|
set$8(frameComponent.element, 'srcdoc', html);
|
|
}
|
|
cachedValue.set(html);
|
|
}
|
|
};
|
|
};
|
|
var renderIFrame = function (spec, providersBackstage) {
|
|
var isSandbox = platformNeedsSandboxing && spec.sandboxed;
|
|
var attributes = __assign(__assign({}, spec.label.map(function (title) {
|
|
return { title: title };
|
|
}).getOr({})), isSandbox ? { sandbox: 'allow-scripts allow-same-origin' } : {});
|
|
var sourcing = getDynamicSource(isSandbox);
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, providersBackstage);
|
|
});
|
|
var factory = function (newSpec) {
|
|
return craft({
|
|
uid: newSpec.uid,
|
|
dom: {
|
|
tag: 'iframe',
|
|
attributes: attributes
|
|
},
|
|
behaviours: derive$1([
|
|
Tabstopping.config({}),
|
|
Focusing.config({}),
|
|
RepresentingConfigs.withComp(Optional.none(), sourcing.getValue, sourcing.setValue)
|
|
])
|
|
});
|
|
};
|
|
var pField = FormField.parts.field({ factory: { sketch: factory } });
|
|
return renderFormFieldWith(pLabel, pField, ['tox-form__group--stretched'], []);
|
|
};
|
|
|
|
var create$3 = function (width, height) {
|
|
return resize$3(document.createElement('canvas'), width, height);
|
|
};
|
|
var clone = function (canvas) {
|
|
var tCanvas = create$3(canvas.width, canvas.height);
|
|
var ctx = get2dContext(tCanvas);
|
|
ctx.drawImage(canvas, 0, 0);
|
|
return tCanvas;
|
|
};
|
|
var get2dContext = function (canvas) {
|
|
return canvas.getContext('2d');
|
|
};
|
|
var resize$3 = function (canvas, width, height) {
|
|
canvas.width = width;
|
|
canvas.height = height;
|
|
return canvas;
|
|
};
|
|
|
|
var getWidth$1 = function (image) {
|
|
return image.naturalWidth || image.width;
|
|
};
|
|
var getHeight$1 = function (image) {
|
|
return image.naturalHeight || image.height;
|
|
};
|
|
|
|
var blobToImage = function (blob) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
var blobUrl = URL.createObjectURL(blob);
|
|
var image = new Image();
|
|
var removeListeners = function () {
|
|
image.removeEventListener('load', loaded);
|
|
image.removeEventListener('error', error);
|
|
};
|
|
var loaded = function () {
|
|
removeListeners();
|
|
resolve(image);
|
|
};
|
|
var error = function () {
|
|
removeListeners();
|
|
reject('Unable to load data of type ' + blob.type + ': ' + blobUrl);
|
|
};
|
|
image.addEventListener('load', loaded);
|
|
image.addEventListener('error', error);
|
|
image.src = blobUrl;
|
|
if (image.complete) {
|
|
setTimeout(loaded, 0);
|
|
}
|
|
});
|
|
};
|
|
var dataUriToBlobSync = function (uri) {
|
|
var data = uri.split(',');
|
|
var matches = /data:([^;]+)/.exec(data[0]);
|
|
if (!matches) {
|
|
return Optional.none();
|
|
}
|
|
var mimetype = matches[1];
|
|
var base64 = data[1];
|
|
var sliceSize = 1024;
|
|
var byteCharacters = atob(base64);
|
|
var bytesLength = byteCharacters.length;
|
|
var slicesCount = Math.ceil(bytesLength / sliceSize);
|
|
var byteArrays = new Array(slicesCount);
|
|
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
|
var begin = sliceIndex * sliceSize;
|
|
var end = Math.min(begin + sliceSize, bytesLength);
|
|
var bytes = new Array(end - begin);
|
|
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
|
|
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
|
}
|
|
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
|
}
|
|
return Optional.some(new Blob(byteArrays, { type: mimetype }));
|
|
};
|
|
var dataUriToBlob = function (uri) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
dataUriToBlobSync(uri).fold(function () {
|
|
reject('uri is not base64: ' + uri);
|
|
}, resolve);
|
|
});
|
|
};
|
|
var canvasToBlob = function (canvas, type, quality) {
|
|
type = type || 'image/png';
|
|
if (isFunction(HTMLCanvasElement.prototype.toBlob)) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
canvas.toBlob(function (blob) {
|
|
if (blob) {
|
|
resolve(blob);
|
|
} else {
|
|
reject();
|
|
}
|
|
}, type, quality);
|
|
});
|
|
} else {
|
|
return dataUriToBlob(canvas.toDataURL(type, quality));
|
|
}
|
|
};
|
|
var canvasToDataURL = function (canvas, type, quality) {
|
|
type = type || 'image/png';
|
|
return canvas.toDataURL(type, quality);
|
|
};
|
|
var blobToCanvas = function (blob) {
|
|
return blobToImage(blob).then(function (image) {
|
|
revokeImageUrl(image);
|
|
var canvas = create$3(getWidth$1(image), getHeight$1(image));
|
|
var context = get2dContext(canvas);
|
|
context.drawImage(image, 0, 0);
|
|
return canvas;
|
|
});
|
|
};
|
|
var blobToDataUri = function (blob) {
|
|
return new Promise$1(function (resolve) {
|
|
var reader = new FileReader();
|
|
reader.onloadend = function () {
|
|
resolve(reader.result);
|
|
};
|
|
reader.readAsDataURL(blob);
|
|
});
|
|
};
|
|
var revokeImageUrl = function (image) {
|
|
URL.revokeObjectURL(image.src);
|
|
};
|
|
|
|
var create$2 = function (getCanvas, blob, uri) {
|
|
var initialType = blob.type;
|
|
var getType = constant$1(initialType);
|
|
var toBlob = function () {
|
|
return Promise$1.resolve(blob);
|
|
};
|
|
var toDataURL = constant$1(uri);
|
|
var toBase64 = function () {
|
|
return uri.split(',')[1];
|
|
};
|
|
var toAdjustedBlob = function (type, quality) {
|
|
return getCanvas.then(function (canvas) {
|
|
return canvasToBlob(canvas, type, quality);
|
|
});
|
|
};
|
|
var toAdjustedDataURL = function (type, quality) {
|
|
return getCanvas.then(function (canvas) {
|
|
return canvasToDataURL(canvas, type, quality);
|
|
});
|
|
};
|
|
var toAdjustedBase64 = function (type, quality) {
|
|
return toAdjustedDataURL(type, quality).then(function (dataurl) {
|
|
return dataurl.split(',')[1];
|
|
});
|
|
};
|
|
var toCanvas = function () {
|
|
return getCanvas.then(clone);
|
|
};
|
|
return {
|
|
getType: getType,
|
|
toBlob: toBlob,
|
|
toDataURL: toDataURL,
|
|
toBase64: toBase64,
|
|
toAdjustedBlob: toAdjustedBlob,
|
|
toAdjustedDataURL: toAdjustedDataURL,
|
|
toAdjustedBase64: toAdjustedBase64,
|
|
toCanvas: toCanvas
|
|
};
|
|
};
|
|
var fromBlob = function (blob) {
|
|
return blobToDataUri(blob).then(function (uri) {
|
|
return create$2(blobToCanvas(blob), blob, uri);
|
|
});
|
|
};
|
|
var fromCanvas = function (canvas, type) {
|
|
return canvasToBlob(canvas, type).then(function (blob) {
|
|
return create$2(Promise$1.resolve(canvas), blob, canvas.toDataURL());
|
|
});
|
|
};
|
|
|
|
var blobToImageResult = function (blob) {
|
|
return fromBlob(blob);
|
|
};
|
|
|
|
var clamp = function (value, min, max) {
|
|
var parsedValue = typeof value === 'string' ? parseFloat(value) : value;
|
|
if (parsedValue > max) {
|
|
parsedValue = max;
|
|
} else if (parsedValue < min) {
|
|
parsedValue = min;
|
|
}
|
|
return parsedValue;
|
|
};
|
|
var identity = function () {
|
|
return [
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1
|
|
];
|
|
};
|
|
var DELTA_INDEX = [
|
|
0,
|
|
0.01,
|
|
0.02,
|
|
0.04,
|
|
0.05,
|
|
0.06,
|
|
0.07,
|
|
0.08,
|
|
0.1,
|
|
0.11,
|
|
0.12,
|
|
0.14,
|
|
0.15,
|
|
0.16,
|
|
0.17,
|
|
0.18,
|
|
0.2,
|
|
0.21,
|
|
0.22,
|
|
0.24,
|
|
0.25,
|
|
0.27,
|
|
0.28,
|
|
0.3,
|
|
0.32,
|
|
0.34,
|
|
0.36,
|
|
0.38,
|
|
0.4,
|
|
0.42,
|
|
0.44,
|
|
0.46,
|
|
0.48,
|
|
0.5,
|
|
0.53,
|
|
0.56,
|
|
0.59,
|
|
0.62,
|
|
0.65,
|
|
0.68,
|
|
0.71,
|
|
0.74,
|
|
0.77,
|
|
0.8,
|
|
0.83,
|
|
0.86,
|
|
0.89,
|
|
0.92,
|
|
0.95,
|
|
0.98,
|
|
1,
|
|
1.06,
|
|
1.12,
|
|
1.18,
|
|
1.24,
|
|
1.3,
|
|
1.36,
|
|
1.42,
|
|
1.48,
|
|
1.54,
|
|
1.6,
|
|
1.66,
|
|
1.72,
|
|
1.78,
|
|
1.84,
|
|
1.9,
|
|
1.96,
|
|
2,
|
|
2.12,
|
|
2.25,
|
|
2.37,
|
|
2.5,
|
|
2.62,
|
|
2.75,
|
|
2.87,
|
|
3,
|
|
3.2,
|
|
3.4,
|
|
3.6,
|
|
3.8,
|
|
4,
|
|
4.3,
|
|
4.7,
|
|
4.9,
|
|
5,
|
|
5.5,
|
|
6,
|
|
6.5,
|
|
6.8,
|
|
7,
|
|
7.3,
|
|
7.5,
|
|
7.8,
|
|
8,
|
|
8.4,
|
|
8.7,
|
|
9,
|
|
9.4,
|
|
9.6,
|
|
9.8,
|
|
10
|
|
];
|
|
var multiply = function (matrix1, matrix2) {
|
|
var col = [];
|
|
var out = new Array(25);
|
|
var val;
|
|
for (var i = 0; i < 5; i++) {
|
|
for (var j = 0; j < 5; j++) {
|
|
col[j] = matrix2[j + i * 5];
|
|
}
|
|
for (var j = 0; j < 5; j++) {
|
|
val = 0;
|
|
for (var k = 0; k < 5; k++) {
|
|
val += matrix1[j + k * 5] * col[k];
|
|
}
|
|
out[j + i * 5] = val;
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
var adjustContrast = function (matrix, value) {
|
|
var x;
|
|
value = clamp(value, -1, 1);
|
|
value *= 100;
|
|
if (value < 0) {
|
|
x = 127 + value / 100 * 127;
|
|
} else {
|
|
x = value % 1;
|
|
if (x === 0) {
|
|
x = DELTA_INDEX[value];
|
|
} else {
|
|
x = DELTA_INDEX[Math.floor(value)] * (1 - x) + DELTA_INDEX[Math.floor(value) + 1] * x;
|
|
}
|
|
x = x * 127 + 127;
|
|
}
|
|
return multiply(matrix, [
|
|
x / 127,
|
|
0,
|
|
0,
|
|
0,
|
|
0.5 * (127 - x),
|
|
0,
|
|
x / 127,
|
|
0,
|
|
0,
|
|
0.5 * (127 - x),
|
|
0,
|
|
0,
|
|
x / 127,
|
|
0,
|
|
0.5 * (127 - x),
|
|
0,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1
|
|
]);
|
|
};
|
|
var adjustBrightness = function (matrix, value) {
|
|
value = clamp(255 * value, -255, 255);
|
|
return multiply(matrix, [
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
value,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
value,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
value,
|
|
0,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1
|
|
]);
|
|
};
|
|
var adjustColors = function (matrix, adjustR, adjustG, adjustB) {
|
|
adjustR = clamp(adjustR, 0, 2);
|
|
adjustG = clamp(adjustG, 0, 2);
|
|
adjustB = clamp(adjustB, 0, 2);
|
|
return multiply(matrix, [
|
|
adjustR,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
adjustG,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
adjustB,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1
|
|
]);
|
|
};
|
|
|
|
var colorFilter = function (ir, matrix) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return applyColorFilter(canvas, ir.getType(), matrix);
|
|
});
|
|
};
|
|
var applyColorFilter = function (canvas, type, matrix) {
|
|
var context = get2dContext(canvas);
|
|
var applyMatrix = function (pixelsData, m) {
|
|
var r, g, b, a;
|
|
var data = pixelsData.data, m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3], m4 = m[4], m5 = m[5], m6 = m[6], m7 = m[7], m8 = m[8], m9 = m[9], m10 = m[10], m11 = m[11], m12 = m[12], m13 = m[13], m14 = m[14], m15 = m[15], m16 = m[16], m17 = m[17], m18 = m[18], m19 = m[19];
|
|
for (var i = 0; i < data.length; i += 4) {
|
|
r = data[i];
|
|
g = data[i + 1];
|
|
b = data[i + 2];
|
|
a = data[i + 3];
|
|
data[i] = r * m0 + g * m1 + b * m2 + a * m3 + m4;
|
|
data[i + 1] = r * m5 + g * m6 + b * m7 + a * m8 + m9;
|
|
data[i + 2] = r * m10 + g * m11 + b * m12 + a * m13 + m14;
|
|
data[i + 3] = r * m15 + g * m16 + b * m17 + a * m18 + m19;
|
|
}
|
|
return pixelsData;
|
|
};
|
|
var pixels = applyMatrix(context.getImageData(0, 0, canvas.width, canvas.height), matrix);
|
|
context.putImageData(pixels, 0, 0);
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
var convoluteFilter = function (ir, matrix) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return applyConvoluteFilter(canvas, ir.getType(), matrix);
|
|
});
|
|
};
|
|
var applyConvoluteFilter = function (canvas, type, matrix) {
|
|
var context = get2dContext(canvas);
|
|
var applyMatrix = function (pIn, pOut, aMatrix) {
|
|
var clamp = function (value, min, max) {
|
|
if (value > max) {
|
|
value = max;
|
|
} else if (value < min) {
|
|
value = min;
|
|
}
|
|
return value;
|
|
};
|
|
var side = Math.round(Math.sqrt(aMatrix.length));
|
|
var halfSide = Math.floor(side / 2);
|
|
var rgba = pIn.data;
|
|
var drgba = pOut.data;
|
|
var w = pIn.width;
|
|
var h = pIn.height;
|
|
for (var y = 0; y < h; y++) {
|
|
for (var x = 0; x < w; x++) {
|
|
var r = 0;
|
|
var g = 0;
|
|
var b = 0;
|
|
for (var cy = 0; cy < side; cy++) {
|
|
for (var cx = 0; cx < side; cx++) {
|
|
var scx = clamp(x + cx - halfSide, 0, w - 1);
|
|
var scy = clamp(y + cy - halfSide, 0, h - 1);
|
|
var innerOffset = (scy * w + scx) * 4;
|
|
var wt = aMatrix[cy * side + cx];
|
|
r += rgba[innerOffset] * wt;
|
|
g += rgba[innerOffset + 1] * wt;
|
|
b += rgba[innerOffset + 2] * wt;
|
|
}
|
|
}
|
|
var offset = (y * w + x) * 4;
|
|
drgba[offset] = clamp(r, 0, 255);
|
|
drgba[offset + 1] = clamp(g, 0, 255);
|
|
drgba[offset + 2] = clamp(b, 0, 255);
|
|
}
|
|
}
|
|
return pOut;
|
|
};
|
|
var pixelsIn = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
var pixelsOut = context.getImageData(0, 0, canvas.width, canvas.height);
|
|
pixelsOut = applyMatrix(pixelsIn, pixelsOut, matrix);
|
|
context.putImageData(pixelsOut, 0, 0);
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
var functionColorFilter = function (colorFn) {
|
|
var filterImpl = function (canvas, type, value) {
|
|
var context = get2dContext(canvas);
|
|
var lookup = new Array(256);
|
|
var applyLookup = function (pixelsData, lookupData) {
|
|
var data = pixelsData.data;
|
|
for (var i = 0; i < data.length; i += 4) {
|
|
data[i] = lookupData[data[i]];
|
|
data[i + 1] = lookupData[data[i + 1]];
|
|
data[i + 2] = lookupData[data[i + 2]];
|
|
}
|
|
return pixelsData;
|
|
};
|
|
for (var i = 0; i < lookup.length; i++) {
|
|
lookup[i] = colorFn(i, value);
|
|
}
|
|
var pixels = applyLookup(context.getImageData(0, 0, canvas.width, canvas.height), lookup);
|
|
context.putImageData(pixels, 0, 0);
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
return function (ir, value) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return filterImpl(canvas, ir.getType(), value);
|
|
});
|
|
};
|
|
};
|
|
var complexAdjustableColorFilter = function (matrixAdjustFn) {
|
|
return function (ir, adjust) {
|
|
return colorFilter(ir, matrixAdjustFn(identity(), adjust));
|
|
};
|
|
};
|
|
var basicColorFilter = function (matrix) {
|
|
return function (ir) {
|
|
return colorFilter(ir, matrix);
|
|
};
|
|
};
|
|
var basicConvolutionFilter = function (kernel) {
|
|
return function (ir) {
|
|
return convoluteFilter(ir, kernel);
|
|
};
|
|
};
|
|
var invert$1 = basicColorFilter([
|
|
-1,
|
|
0,
|
|
0,
|
|
0,
|
|
255,
|
|
0,
|
|
-1,
|
|
0,
|
|
0,
|
|
255,
|
|
0,
|
|
0,
|
|
-1,
|
|
0,
|
|
255,
|
|
0,
|
|
0,
|
|
0,
|
|
1,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
1
|
|
]);
|
|
var brightness$1 = complexAdjustableColorFilter(adjustBrightness);
|
|
var contrast$1 = complexAdjustableColorFilter(adjustContrast);
|
|
var colorize$1 = function (ir, adjustR, adjustG, adjustB) {
|
|
return colorFilter(ir, adjustColors(identity(), adjustR, adjustG, adjustB));
|
|
};
|
|
var sharpen$1 = basicConvolutionFilter([
|
|
0,
|
|
-1,
|
|
0,
|
|
-1,
|
|
5,
|
|
-1,
|
|
0,
|
|
-1,
|
|
0
|
|
]);
|
|
var gamma$1 = functionColorFilter(function (color, value) {
|
|
return Math.pow(color / 255, 1 - value) * 255;
|
|
});
|
|
|
|
var scale = function (image, dW, dH) {
|
|
var sW = getWidth$1(image);
|
|
var sH = getHeight$1(image);
|
|
var wRatio = dW / sW;
|
|
var hRatio = dH / sH;
|
|
var scaleCapped = false;
|
|
if (wRatio < 0.5 || wRatio > 2) {
|
|
wRatio = wRatio < 0.5 ? 0.5 : 2;
|
|
scaleCapped = true;
|
|
}
|
|
if (hRatio < 0.5 || hRatio > 2) {
|
|
hRatio = hRatio < 0.5 ? 0.5 : 2;
|
|
scaleCapped = true;
|
|
}
|
|
var scaled = _scale(image, wRatio, hRatio);
|
|
return !scaleCapped ? scaled : scaled.then(function (tCanvas) {
|
|
return scale(tCanvas, dW, dH);
|
|
});
|
|
};
|
|
var _scale = function (image, wRatio, hRatio) {
|
|
return new Promise$1(function (resolve) {
|
|
var sW = getWidth$1(image);
|
|
var sH = getHeight$1(image);
|
|
var dW = Math.floor(sW * wRatio);
|
|
var dH = Math.floor(sH * hRatio);
|
|
var canvas = create$3(dW, dH);
|
|
var context = get2dContext(canvas);
|
|
context.drawImage(image, 0, 0, sW, sH, 0, 0, dW, dH);
|
|
resolve(canvas);
|
|
});
|
|
};
|
|
|
|
var ceilWithPrecision = function (num, precision) {
|
|
if (precision === void 0) {
|
|
precision = 2;
|
|
}
|
|
var mul = Math.pow(10, precision);
|
|
var upper = Math.round(num * mul);
|
|
return Math.ceil(upper / mul);
|
|
};
|
|
var rotate$1 = function (ir, angle) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return applyRotate(canvas, ir.getType(), angle);
|
|
});
|
|
};
|
|
var applyRotate = function (image, type, angle) {
|
|
var degrees = angle < 0 ? 360 + angle : angle;
|
|
var rad = degrees * Math.PI / 180;
|
|
var width = image.width;
|
|
var height = image.height;
|
|
var sin = Math.sin(rad);
|
|
var cos = Math.cos(rad);
|
|
var newWidth = ceilWithPrecision(Math.abs(width * cos) + Math.abs(height * sin));
|
|
var newHeight = ceilWithPrecision(Math.abs(width * sin) + Math.abs(height * cos));
|
|
var canvas = create$3(newWidth, newHeight);
|
|
var context = get2dContext(canvas);
|
|
context.translate(newWidth / 2, newHeight / 2);
|
|
context.rotate(rad);
|
|
context.drawImage(image, -width / 2, -height / 2);
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
var flip$1 = function (ir, axis) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return applyFlip(canvas, ir.getType(), axis);
|
|
});
|
|
};
|
|
var applyFlip = function (image, type, axis) {
|
|
var canvas = create$3(image.width, image.height);
|
|
var context = get2dContext(canvas);
|
|
if (axis === 'v') {
|
|
context.scale(1, -1);
|
|
context.drawImage(image, 0, -canvas.height);
|
|
} else {
|
|
context.scale(-1, 1);
|
|
context.drawImage(image, -canvas.width, 0);
|
|
}
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
var crop$1 = function (ir, x, y, w, h) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return applyCrop(canvas, ir.getType(), x, y, w, h);
|
|
});
|
|
};
|
|
var applyCrop = function (image, type, x, y, w, h) {
|
|
var canvas = create$3(w, h);
|
|
var context = get2dContext(canvas);
|
|
context.drawImage(image, -x, -y);
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
var resize$2 = function (ir, w, h) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return scale(canvas, w, h).then(function (newCanvas) {
|
|
return fromCanvas(newCanvas, ir.getType());
|
|
});
|
|
});
|
|
};
|
|
|
|
var invert = function (ir) {
|
|
return invert$1(ir);
|
|
};
|
|
var sharpen = function (ir) {
|
|
return sharpen$1(ir);
|
|
};
|
|
var gamma = function (ir, value) {
|
|
return gamma$1(ir, value);
|
|
};
|
|
var colorize = function (ir, adjustR, adjustG, adjustB) {
|
|
return colorize$1(ir, adjustR, adjustG, adjustB);
|
|
};
|
|
var brightness = function (ir, adjust) {
|
|
return brightness$1(ir, adjust);
|
|
};
|
|
var contrast = function (ir, adjust) {
|
|
return contrast$1(ir, adjust);
|
|
};
|
|
var flip = function (ir, axis) {
|
|
return flip$1(ir, axis);
|
|
};
|
|
var crop = function (ir, x, y, w, h) {
|
|
return crop$1(ir, x, y, w, h);
|
|
};
|
|
var resize$1 = function (ir, w, h) {
|
|
return resize$2(ir, w, h);
|
|
};
|
|
var rotate = function (ir, angle) {
|
|
return rotate$1(ir, angle);
|
|
};
|
|
|
|
var renderIcon = function (iconName, iconsProvider, behaviours) {
|
|
return render$3(iconName, {
|
|
tag: 'span',
|
|
classes: [
|
|
'tox-icon',
|
|
'tox-tbtn__icon-wrap'
|
|
],
|
|
behaviours: behaviours
|
|
}, iconsProvider);
|
|
};
|
|
var renderIconFromPack = function (iconName, iconsProvider) {
|
|
return renderIcon(iconName, iconsProvider, []);
|
|
};
|
|
var renderReplacableIconFromPack = function (iconName, iconsProvider) {
|
|
return renderIcon(iconName, iconsProvider, [Replacing.config({})]);
|
|
};
|
|
var renderLabel$1 = function (text, prefix, providersBackstage) {
|
|
return {
|
|
dom: {
|
|
tag: 'span',
|
|
innerHtml: providersBackstage.translate(text),
|
|
classes: [prefix + '__select-label']
|
|
},
|
|
behaviours: derive$1([Replacing.config({})])
|
|
};
|
|
};
|
|
|
|
var _a;
|
|
var internalToolbarButtonExecute = generate$6('toolbar.button.execute');
|
|
var onToolbarButtonExecute = function (info) {
|
|
return runOnExecute$1(function (comp, _simulatedEvent) {
|
|
runWithApi(info, comp)(function (itemApi) {
|
|
emitWith(comp, internalToolbarButtonExecute, { buttonApi: itemApi });
|
|
info.onAction(itemApi);
|
|
});
|
|
});
|
|
};
|
|
var toolbarButtonEventOrder = (_a = {}, _a[execute$5()] = [
|
|
'disabling',
|
|
'alloy.base.behaviour',
|
|
'toggling',
|
|
'toolbar-button-events'
|
|
], _a);
|
|
|
|
var updateMenuText = generate$6('update-menu-text');
|
|
var updateMenuIcon = generate$6('update-menu-icon');
|
|
var renderCommonDropdown = function (spec, prefix, sharedBackstage) {
|
|
var editorOffCell = Cell(noop);
|
|
var optMemDisplayText = spec.text.map(function (text) {
|
|
return record(renderLabel$1(text, prefix, sharedBackstage.providers));
|
|
});
|
|
var optMemDisplayIcon = spec.icon.map(function (iconName) {
|
|
return record(renderReplacableIconFromPack(iconName, sharedBackstage.providers.icons));
|
|
});
|
|
var onLeftOrRightInMenu = function (comp, se) {
|
|
var dropdown = Representing.getValue(comp);
|
|
Focusing.focus(dropdown);
|
|
emitWith(dropdown, 'keydown', { raw: se.event.raw });
|
|
Dropdown.close(dropdown);
|
|
return Optional.some(true);
|
|
};
|
|
var role = spec.role.fold(function () {
|
|
return {};
|
|
}, function (role) {
|
|
return { role: role };
|
|
});
|
|
var tooltipAttributes = spec.tooltip.fold(function () {
|
|
return {};
|
|
}, function (tooltip) {
|
|
var translatedTooltip = sharedBackstage.providers.translate(tooltip);
|
|
return {
|
|
'title': translatedTooltip,
|
|
'aria-label': translatedTooltip
|
|
};
|
|
});
|
|
var iconSpec = render$3('chevron-down', {
|
|
tag: 'div',
|
|
classes: [prefix + '__select-chevron']
|
|
}, sharedBackstage.providers.icons);
|
|
var memDropdown = record(Dropdown.sketch(__assign(__assign(__assign({}, spec.uid ? { uid: spec.uid } : {}), role), {
|
|
dom: {
|
|
tag: 'button',
|
|
classes: [
|
|
prefix,
|
|
prefix + '--select'
|
|
].concat(map$2(spec.classes, function (c) {
|
|
return prefix + '--' + c;
|
|
})),
|
|
attributes: __assign({}, tooltipAttributes)
|
|
},
|
|
components: componentRenderPipeline([
|
|
optMemDisplayIcon.map(function (mem) {
|
|
return mem.asSpec();
|
|
}),
|
|
optMemDisplayText.map(function (mem) {
|
|
return mem.asSpec();
|
|
}),
|
|
Optional.some(iconSpec)
|
|
]),
|
|
matchWidth: true,
|
|
useMinWidth: true,
|
|
dropdownBehaviours: derive$1(__spreadArray(__spreadArray([], spec.dropdownBehaviours, true), [
|
|
DisablingConfigs.button(function () {
|
|
return spec.disabled || sharedBackstage.providers.isDisabled();
|
|
}),
|
|
receivingConfig(),
|
|
Unselecting.config({}),
|
|
Replacing.config({}),
|
|
config('dropdown-events', [
|
|
onControlAttached(spec, editorOffCell),
|
|
onControlDetached(spec, editorOffCell)
|
|
]),
|
|
config('menubutton-update-display-text', [
|
|
run$1(updateMenuText, function (comp, se) {
|
|
optMemDisplayText.bind(function (mem) {
|
|
return mem.getOpt(comp);
|
|
}).each(function (displayText) {
|
|
Replacing.set(displayText, [text(sharedBackstage.providers.translate(se.event.text))]);
|
|
});
|
|
}),
|
|
run$1(updateMenuIcon, function (comp, se) {
|
|
optMemDisplayIcon.bind(function (mem) {
|
|
return mem.getOpt(comp);
|
|
}).each(function (displayIcon) {
|
|
Replacing.set(displayIcon, [renderReplacableIconFromPack(se.event.icon, sharedBackstage.providers.icons)]);
|
|
});
|
|
})
|
|
])
|
|
], false)),
|
|
eventOrder: deepMerge(toolbarButtonEventOrder, {
|
|
mousedown: [
|
|
'focusing',
|
|
'alloy.base.behaviour',
|
|
'item-type-events',
|
|
'normal-dropdown-events'
|
|
]
|
|
}),
|
|
sandboxBehaviours: derive$1([Keying.config({
|
|
mode: 'special',
|
|
onLeft: onLeftOrRightInMenu,
|
|
onRight: onLeftOrRightInMenu
|
|
})]),
|
|
lazySink: sharedBackstage.getSink,
|
|
toggleClass: prefix + '--active',
|
|
parts: { menu: part(false, spec.columns, spec.presets) },
|
|
fetch: function (comp) {
|
|
return Future.nu(curry(spec.fetch, comp));
|
|
}
|
|
})));
|
|
return memDropdown.asSpec();
|
|
};
|
|
|
|
var isMenuItemReference = function (item) {
|
|
return isString(item);
|
|
};
|
|
var isSeparator$1 = function (item) {
|
|
return item.type === 'separator';
|
|
};
|
|
var isExpandingMenuItem = function (item) {
|
|
return has$2(item, 'getSubmenuItems');
|
|
};
|
|
var separator$2 = { type: 'separator' };
|
|
var unwrapReferences = function (items, menuItems) {
|
|
var realItems = foldl(items, function (acc, item) {
|
|
if (isMenuItemReference(item)) {
|
|
if (item === '') {
|
|
return acc;
|
|
} else if (item === '|') {
|
|
return acc.length > 0 && !isSeparator$1(acc[acc.length - 1]) ? acc.concat([separator$2]) : acc;
|
|
} else if (has$2(menuItems, item.toLowerCase())) {
|
|
return acc.concat([menuItems[item.toLowerCase()]]);
|
|
} else {
|
|
return acc;
|
|
}
|
|
} else {
|
|
return acc.concat([item]);
|
|
}
|
|
}, []);
|
|
if (realItems.length > 0 && isSeparator$1(realItems[realItems.length - 1])) {
|
|
realItems.pop();
|
|
}
|
|
return realItems;
|
|
};
|
|
var getFromExpandingItem = function (item, menuItems) {
|
|
var submenuItems = item.getSubmenuItems();
|
|
var rest = expand(submenuItems, menuItems);
|
|
var newMenus = deepMerge(rest.menus, wrap$1(item.value, rest.items));
|
|
var newExpansions = deepMerge(rest.expansions, wrap$1(item.value, item.value));
|
|
return {
|
|
item: item,
|
|
menus: newMenus,
|
|
expansions: newExpansions
|
|
};
|
|
};
|
|
var getFromItem = function (item, menuItems) {
|
|
return isExpandingMenuItem(item) ? getFromExpandingItem(item, menuItems) : {
|
|
item: item,
|
|
menus: {},
|
|
expansions: {}
|
|
};
|
|
};
|
|
var generateValueIfRequired = function (item) {
|
|
if (isSeparator$1(item)) {
|
|
return item;
|
|
} else {
|
|
var itemValue = get$e(item, 'value').getOrThunk(function () {
|
|
return generate$6('generated-menu-item');
|
|
});
|
|
return deepMerge({ value: itemValue }, item);
|
|
}
|
|
};
|
|
var expand = function (items, menuItems) {
|
|
var realItems = unwrapReferences(isString(items) ? items.split(' ') : items, menuItems);
|
|
return foldr(realItems, function (acc, item) {
|
|
var itemWithValue = generateValueIfRequired(item);
|
|
var newData = getFromItem(itemWithValue, menuItems);
|
|
return {
|
|
menus: deepMerge(acc.menus, newData.menus),
|
|
items: [newData.item].concat(acc.items),
|
|
expansions: deepMerge(acc.expansions, newData.expansions)
|
|
};
|
|
}, {
|
|
menus: {},
|
|
expansions: {},
|
|
items: []
|
|
});
|
|
};
|
|
|
|
var build = function (items, itemResponse, backstage, isHorizontalMenu) {
|
|
var primary = generate$6('primary-menu');
|
|
var data = expand(items, backstage.shared.providers.menuItems());
|
|
if (data.items.length === 0) {
|
|
return Optional.none();
|
|
}
|
|
var mainMenu = createPartialMenu(primary, data.items, itemResponse, backstage, isHorizontalMenu);
|
|
var submenus = map$1(data.menus, function (menuItems, menuName) {
|
|
return createPartialMenu(menuName, menuItems, itemResponse, backstage, false);
|
|
});
|
|
var menus = deepMerge(submenus, wrap$1(primary, mainMenu));
|
|
return Optional.from(tieredMenu.tieredData(primary, menus, data.expansions));
|
|
};
|
|
|
|
var getMenuButtonApi = function (component) {
|
|
return {
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(component, state);
|
|
},
|
|
setActive: function (state) {
|
|
var elm = component.element;
|
|
if (state) {
|
|
add$2(elm, 'tox-tbtn--enabled');
|
|
set$8(elm, 'aria-pressed', true);
|
|
} else {
|
|
remove$2(elm, 'tox-tbtn--enabled');
|
|
remove$7(elm, 'aria-pressed');
|
|
}
|
|
},
|
|
isActive: function () {
|
|
return has(component.element, 'tox-tbtn--enabled');
|
|
}
|
|
};
|
|
};
|
|
var renderMenuButton = function (spec, prefix, backstage, role) {
|
|
return renderCommonDropdown({
|
|
text: spec.text,
|
|
icon: spec.icon,
|
|
tooltip: spec.tooltip,
|
|
role: role,
|
|
fetch: function (_comp, callback) {
|
|
spec.fetch(function (items) {
|
|
callback(build(items, ItemResponse$1.CLOSE_ON_EXECUTE, backstage, false));
|
|
});
|
|
},
|
|
onSetup: spec.onSetup,
|
|
getApi: getMenuButtonApi,
|
|
columns: 1,
|
|
presets: 'normal',
|
|
classes: [],
|
|
dropdownBehaviours: [Tabstopping.config({})]
|
|
}, prefix, backstage.shared);
|
|
};
|
|
var getFetch = function (items, getButton, backstage) {
|
|
var getMenuItemAction = function (item) {
|
|
return function (api) {
|
|
var newValue = !api.isActive();
|
|
api.setActive(newValue);
|
|
item.storage.set(newValue);
|
|
backstage.shared.getSink().each(function (sink) {
|
|
getButton().getOpt(sink).each(function (orig) {
|
|
focus$3(orig.element);
|
|
emitWith(orig, formActionEvent, {
|
|
name: item.name,
|
|
value: item.storage.get()
|
|
});
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var getMenuItemSetup = function (item) {
|
|
return function (api) {
|
|
api.setActive(item.storage.get());
|
|
};
|
|
};
|
|
return function (success) {
|
|
success(map$2(items, function (item) {
|
|
var text = item.text.fold(function () {
|
|
return {};
|
|
}, function (text) {
|
|
return { text: text };
|
|
});
|
|
return __assign(__assign({
|
|
type: item.type,
|
|
active: false
|
|
}, text), {
|
|
onAction: getMenuItemAction(item),
|
|
onSetup: getMenuItemSetup(item)
|
|
});
|
|
}));
|
|
};
|
|
};
|
|
|
|
var renderCommonSpec = function (spec, actionOpt, extraBehaviours, dom, components, providersBackstage) {
|
|
if (extraBehaviours === void 0) {
|
|
extraBehaviours = [];
|
|
}
|
|
var action = actionOpt.fold(function () {
|
|
return {};
|
|
}, function (action) {
|
|
return { action: action };
|
|
});
|
|
var common = __assign({
|
|
buttonBehaviours: derive$1([
|
|
DisablingConfigs.button(function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}),
|
|
receivingConfig(),
|
|
Tabstopping.config({}),
|
|
config('button press', [
|
|
preventDefault('click'),
|
|
preventDefault('mousedown')
|
|
])
|
|
].concat(extraBehaviours)),
|
|
eventOrder: {
|
|
click: [
|
|
'button press',
|
|
'alloy.base.behaviour'
|
|
],
|
|
mousedown: [
|
|
'button press',
|
|
'alloy.base.behaviour'
|
|
]
|
|
}
|
|
}, action);
|
|
var domFinal = deepMerge(common, { dom: dom });
|
|
return deepMerge(domFinal, { components: components });
|
|
};
|
|
var renderIconButtonSpec = function (spec, action, providersBackstage, extraBehaviours) {
|
|
if (extraBehaviours === void 0) {
|
|
extraBehaviours = [];
|
|
}
|
|
var tooltipAttributes = spec.tooltip.map(function (tooltip) {
|
|
return {
|
|
'aria-label': providersBackstage.translate(tooltip),
|
|
'title': providersBackstage.translate(tooltip)
|
|
};
|
|
}).getOr({});
|
|
var dom = {
|
|
tag: 'button',
|
|
classes: ['tox-tbtn'],
|
|
attributes: tooltipAttributes
|
|
};
|
|
var icon = spec.icon.map(function (iconName) {
|
|
return renderIconFromPack(iconName, providersBackstage.icons);
|
|
});
|
|
var components = componentRenderPipeline([icon]);
|
|
return renderCommonSpec(spec, action, extraBehaviours, dom, components, providersBackstage);
|
|
};
|
|
var renderIconButton = function (spec, action, providersBackstage, extraBehaviours) {
|
|
if (extraBehaviours === void 0) {
|
|
extraBehaviours = [];
|
|
}
|
|
var iconButtonSpec = renderIconButtonSpec(spec, Optional.some(action), providersBackstage, extraBehaviours);
|
|
return Button.sketch(iconButtonSpec);
|
|
};
|
|
var renderButtonSpec = function (spec, action, providersBackstage, extraBehaviours, extraClasses) {
|
|
if (extraBehaviours === void 0) {
|
|
extraBehaviours = [];
|
|
}
|
|
if (extraClasses === void 0) {
|
|
extraClasses = [];
|
|
}
|
|
var translatedText = providersBackstage.translate(spec.text);
|
|
var icon = spec.icon ? spec.icon.map(function (iconName) {
|
|
return renderIconFromPack(iconName, providersBackstage.icons);
|
|
}) : Optional.none();
|
|
var components = icon.isSome() ? componentRenderPipeline([icon]) : [];
|
|
var innerHtml = icon.isSome() ? {} : { innerHtml: translatedText };
|
|
var classes = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], !spec.primary && !spec.borderless ? [
|
|
'tox-button',
|
|
'tox-button--secondary'
|
|
] : ['tox-button'], true), icon.isSome() ? ['tox-button--icon'] : [], true), spec.borderless ? ['tox-button--naked'] : [], true), extraClasses, true);
|
|
var dom = __assign(__assign({
|
|
tag: 'button',
|
|
classes: classes
|
|
}, innerHtml), { attributes: { title: translatedText } });
|
|
return renderCommonSpec(spec, action, extraBehaviours, dom, components, providersBackstage);
|
|
};
|
|
var renderButton = function (spec, action, providersBackstage, extraBehaviours, extraClasses) {
|
|
if (extraBehaviours === void 0) {
|
|
extraBehaviours = [];
|
|
}
|
|
if (extraClasses === void 0) {
|
|
extraClasses = [];
|
|
}
|
|
var buttonSpec = renderButtonSpec(spec, Optional.some(action), providersBackstage, extraBehaviours, extraClasses);
|
|
return Button.sketch(buttonSpec);
|
|
};
|
|
var getAction = function (name, buttonType) {
|
|
return function (comp) {
|
|
if (buttonType === 'custom') {
|
|
emitWith(comp, formActionEvent, {
|
|
name: name,
|
|
value: {}
|
|
});
|
|
} else if (buttonType === 'submit') {
|
|
emit(comp, formSubmitEvent);
|
|
} else if (buttonType === 'cancel') {
|
|
emit(comp, formCancelEvent);
|
|
} else {
|
|
console.error('Unknown button type: ', buttonType);
|
|
}
|
|
};
|
|
};
|
|
var isMenuFooterButtonSpec = function (spec, buttonType) {
|
|
return buttonType === 'menu';
|
|
};
|
|
var isNormalFooterButtonSpec = function (spec, buttonType) {
|
|
return buttonType === 'custom' || buttonType === 'cancel' || buttonType === 'submit';
|
|
};
|
|
var renderFooterButton = function (spec, buttonType, backstage) {
|
|
if (isMenuFooterButtonSpec(spec, buttonType)) {
|
|
var getButton = function () {
|
|
return memButton_1;
|
|
};
|
|
var menuButtonSpec = spec;
|
|
var fixedSpec = __assign(__assign({}, spec), {
|
|
onSetup: function (api) {
|
|
api.setDisabled(spec.disabled);
|
|
return noop;
|
|
},
|
|
fetch: getFetch(menuButtonSpec.items, getButton, backstage)
|
|
});
|
|
var memButton_1 = record(renderMenuButton(fixedSpec, 'tox-tbtn', backstage, Optional.none()));
|
|
return memButton_1.asSpec();
|
|
} else if (isNormalFooterButtonSpec(spec, buttonType)) {
|
|
var action = getAction(spec.name, buttonType);
|
|
var buttonSpec = __assign(__assign({}, spec), { borderless: false });
|
|
return renderButton(buttonSpec, action, backstage.shared.providers, []);
|
|
} else {
|
|
console.error('Unknown footer button type: ', buttonType);
|
|
}
|
|
};
|
|
var renderDialogButton = function (spec, providersBackstage) {
|
|
var action = getAction(spec.name, 'custom');
|
|
return renderFormField(Optional.none(), FormField.parts.field(__assign({ factory: Button }, renderButtonSpec(spec, Optional.some(action), providersBackstage, [
|
|
RepresentingConfigs.memory(''),
|
|
ComposingConfigs.self()
|
|
]))));
|
|
};
|
|
|
|
var schema$h = constant$1([
|
|
defaulted('field1Name', 'field1'),
|
|
defaulted('field2Name', 'field2'),
|
|
onStrictHandler('onLockedChange'),
|
|
markers$1(['lockClass']),
|
|
defaulted('locked', false),
|
|
SketchBehaviours.field('coupledFieldBehaviours', [
|
|
Composing,
|
|
Representing
|
|
])
|
|
]);
|
|
var getField = function (comp, detail, partName) {
|
|
return getPart(comp, detail, partName).bind(Composing.getCurrent);
|
|
};
|
|
var coupledPart = function (selfName, otherName) {
|
|
return required({
|
|
factory: FormField,
|
|
name: selfName,
|
|
overrides: function (detail) {
|
|
return {
|
|
fieldBehaviours: derive$1([config('coupled-input-behaviour', [run$1(input(), function (me) {
|
|
getField(me, detail, otherName).each(function (other) {
|
|
getPart(me, detail, 'lock').each(function (lock) {
|
|
if (Toggling.isOn(lock)) {
|
|
detail.onLockedChange(me, other, lock);
|
|
}
|
|
});
|
|
});
|
|
})])])
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var parts$c = constant$1([
|
|
coupledPart('field1', 'field2'),
|
|
coupledPart('field2', 'field1'),
|
|
required({
|
|
factory: Button,
|
|
schema: [required$1('dom')],
|
|
name: 'lock',
|
|
overrides: function (detail) {
|
|
return {
|
|
buttonBehaviours: derive$1([Toggling.config({
|
|
selected: detail.locked,
|
|
toggleClass: detail.markers.lockClass,
|
|
aria: { mode: 'pressed' }
|
|
})])
|
|
};
|
|
}
|
|
})
|
|
]);
|
|
|
|
var factory$f = function (detail, components, _spec, _externals) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: SketchBehaviours.augment(detail.coupledFieldBehaviours, [
|
|
Composing.config({ find: Optional.some }),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (comp) {
|
|
var _a;
|
|
var parts = getPartsOrDie(comp, detail, [
|
|
'field1',
|
|
'field2'
|
|
]);
|
|
return _a = {}, _a[detail.field1Name] = Representing.getValue(parts.field1()), _a[detail.field2Name] = Representing.getValue(parts.field2()), _a;
|
|
},
|
|
setValue: function (comp, value) {
|
|
var parts = getPartsOrDie(comp, detail, [
|
|
'field1',
|
|
'field2'
|
|
]);
|
|
if (hasNonNullableKey(value, detail.field1Name)) {
|
|
Representing.setValue(parts.field1(), value[detail.field1Name]);
|
|
}
|
|
if (hasNonNullableKey(value, detail.field2Name)) {
|
|
Representing.setValue(parts.field2(), value[detail.field2Name]);
|
|
}
|
|
}
|
|
}
|
|
})
|
|
]),
|
|
apis: {
|
|
getField1: function (component) {
|
|
return getPart(component, detail, 'field1');
|
|
},
|
|
getField2: function (component) {
|
|
return getPart(component, detail, 'field2');
|
|
},
|
|
getLock: function (component) {
|
|
return getPart(component, detail, 'lock');
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var FormCoupledInputs = composite({
|
|
name: 'FormCoupledInputs',
|
|
configFields: schema$h(),
|
|
partFields: parts$c(),
|
|
factory: factory$f,
|
|
apis: {
|
|
getField1: function (apis, component) {
|
|
return apis.getField1(component);
|
|
},
|
|
getField2: function (apis, component) {
|
|
return apis.getField2(component);
|
|
},
|
|
getLock: function (apis, component) {
|
|
return apis.getLock(component);
|
|
}
|
|
}
|
|
});
|
|
|
|
var formatSize = function (size) {
|
|
var unitDec = {
|
|
'': 0,
|
|
'px': 0,
|
|
'pt': 1,
|
|
'mm': 1,
|
|
'pc': 2,
|
|
'ex': 2,
|
|
'em': 2,
|
|
'ch': 2,
|
|
'rem': 2,
|
|
'cm': 3,
|
|
'in': 4,
|
|
'%': 4
|
|
};
|
|
var maxDecimal = function (unit) {
|
|
return unit in unitDec ? unitDec[unit] : 1;
|
|
};
|
|
var numText = size.value.toFixed(maxDecimal(size.unit));
|
|
if (numText.indexOf('.') !== -1) {
|
|
numText = numText.replace(/\.?0*$/, '');
|
|
}
|
|
return numText + size.unit;
|
|
};
|
|
var parseSize = function (sizeText) {
|
|
var numPattern = /^\s*(\d+(?:\.\d+)?)\s*(|cm|mm|in|px|pt|pc|em|ex|ch|rem|vw|vh|vmin|vmax|%)\s*$/;
|
|
var match = numPattern.exec(sizeText);
|
|
if (match !== null) {
|
|
var value = parseFloat(match[1]);
|
|
var unit = match[2];
|
|
return Result.value({
|
|
value: value,
|
|
unit: unit
|
|
});
|
|
} else {
|
|
return Result.error(sizeText);
|
|
}
|
|
};
|
|
var convertUnit = function (size, unit) {
|
|
var inInch = {
|
|
'': 96,
|
|
'px': 96,
|
|
'pt': 72,
|
|
'cm': 2.54,
|
|
'pc': 12,
|
|
'mm': 25.4,
|
|
'in': 1
|
|
};
|
|
var supported = function (u) {
|
|
return has$2(inInch, u);
|
|
};
|
|
if (size.unit === unit) {
|
|
return Optional.some(size.value);
|
|
} else if (supported(size.unit) && supported(unit)) {
|
|
if (inInch[size.unit] === inInch[unit]) {
|
|
return Optional.some(size.value);
|
|
} else {
|
|
return Optional.some(size.value / inInch[size.unit] * inInch[unit]);
|
|
}
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var noSizeConversion = function (_input) {
|
|
return Optional.none();
|
|
};
|
|
var ratioSizeConversion = function (scale, unit) {
|
|
return function (size) {
|
|
return convertUnit(size, unit).map(function (value) {
|
|
return {
|
|
value: value * scale,
|
|
unit: unit
|
|
};
|
|
});
|
|
};
|
|
};
|
|
var makeRatioConverter = function (currentFieldText, otherFieldText) {
|
|
var cValue = parseSize(currentFieldText).toOptional();
|
|
var oValue = parseSize(otherFieldText).toOptional();
|
|
return lift2(cValue, oValue, function (cSize, oSize) {
|
|
return convertUnit(cSize, oSize.unit).map(function (val) {
|
|
return oSize.value / val;
|
|
}).map(function (r) {
|
|
return ratioSizeConversion(r, oSize.unit);
|
|
}).getOr(noSizeConversion);
|
|
}).getOr(noSizeConversion);
|
|
};
|
|
|
|
var renderSizeInput = function (spec, providersBackstage) {
|
|
var converter = noSizeConversion;
|
|
var ratioEvent = generate$6('ratio-event');
|
|
var makeIcon = function (iconName) {
|
|
return render$3(iconName, {
|
|
tag: 'span',
|
|
classes: [
|
|
'tox-icon',
|
|
'tox-lock-icon__' + iconName
|
|
]
|
|
}, providersBackstage.icons);
|
|
};
|
|
var pLock = FormCoupledInputs.parts.lock({
|
|
dom: {
|
|
tag: 'button',
|
|
classes: [
|
|
'tox-lock',
|
|
'tox-button',
|
|
'tox-button--naked',
|
|
'tox-button--icon'
|
|
],
|
|
attributes: { title: providersBackstage.translate(spec.label.getOr('Constrain proportions')) }
|
|
},
|
|
components: [
|
|
makeIcon('lock'),
|
|
makeIcon('unlock')
|
|
],
|
|
buttonBehaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}
|
|
}),
|
|
receivingConfig(),
|
|
Tabstopping.config({})
|
|
])
|
|
});
|
|
var formGroup = function (components) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group']
|
|
},
|
|
components: components
|
|
};
|
|
};
|
|
var getFieldPart = function (isField1) {
|
|
return FormField.parts.field({
|
|
factory: Input,
|
|
inputClasses: ['tox-textfield'],
|
|
inputBehaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}
|
|
}),
|
|
receivingConfig(),
|
|
Tabstopping.config({}),
|
|
config('size-input-events', [
|
|
run$1(focusin(), function (component, _simulatedEvent) {
|
|
emitWith(component, ratioEvent, { isField1: isField1 });
|
|
}),
|
|
run$1(change(), function (component, _simulatedEvent) {
|
|
emitWith(component, formChangeEvent, { name: spec.name });
|
|
})
|
|
])
|
|
]),
|
|
selectOnFocus: false
|
|
});
|
|
};
|
|
var getLabel = function (label) {
|
|
return {
|
|
dom: {
|
|
tag: 'label',
|
|
classes: ['tox-label'],
|
|
innerHtml: providersBackstage.translate(label)
|
|
}
|
|
};
|
|
};
|
|
var widthField = FormCoupledInputs.parts.field1(formGroup([
|
|
FormField.parts.label(getLabel('Width')),
|
|
getFieldPart(true)
|
|
]));
|
|
var heightField = FormCoupledInputs.parts.field2(formGroup([
|
|
FormField.parts.label(getLabel('Height')),
|
|
getFieldPart(false)
|
|
]));
|
|
return FormCoupledInputs.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group']
|
|
},
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__controls-h-stack']
|
|
},
|
|
components: [
|
|
widthField,
|
|
heightField,
|
|
formGroup([
|
|
getLabel(' '),
|
|
pLock
|
|
])
|
|
]
|
|
}],
|
|
field1Name: 'width',
|
|
field2Name: 'height',
|
|
locked: true,
|
|
markers: { lockClass: 'tox-locked' },
|
|
onLockedChange: function (current, other, _lock) {
|
|
parseSize(Representing.getValue(current)).each(function (size) {
|
|
converter(size).each(function (newSize) {
|
|
Representing.setValue(other, formatSize(newSize));
|
|
});
|
|
});
|
|
},
|
|
coupledFieldBehaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
},
|
|
onDisabled: function (comp) {
|
|
FormCoupledInputs.getField1(comp).bind(FormField.getField).each(Disabling.disable);
|
|
FormCoupledInputs.getField2(comp).bind(FormField.getField).each(Disabling.disable);
|
|
FormCoupledInputs.getLock(comp).each(Disabling.disable);
|
|
},
|
|
onEnabled: function (comp) {
|
|
FormCoupledInputs.getField1(comp).bind(FormField.getField).each(Disabling.enable);
|
|
FormCoupledInputs.getField2(comp).bind(FormField.getField).each(Disabling.enable);
|
|
FormCoupledInputs.getLock(comp).each(Disabling.enable);
|
|
}
|
|
}),
|
|
receivingConfig(),
|
|
config('size-input-events2', [run$1(ratioEvent, function (component, simulatedEvent) {
|
|
var isField1 = simulatedEvent.event.isField1;
|
|
var optCurrent = isField1 ? FormCoupledInputs.getField1(component) : FormCoupledInputs.getField2(component);
|
|
var optOther = isField1 ? FormCoupledInputs.getField2(component) : FormCoupledInputs.getField1(component);
|
|
var value1 = optCurrent.map(Representing.getValue).getOr('');
|
|
var value2 = optOther.map(Representing.getValue).getOr('');
|
|
converter = makeRatioConverter(value1, value2);
|
|
})])
|
|
])
|
|
});
|
|
};
|
|
|
|
var undo = constant$1(generate$6('undo'));
|
|
var redo = constant$1(generate$6('redo'));
|
|
var zoom = constant$1(generate$6('zoom'));
|
|
var back = constant$1(generate$6('back'));
|
|
var apply = constant$1(generate$6('apply'));
|
|
var swap = constant$1(generate$6('swap'));
|
|
var transform$1 = constant$1(generate$6('transform'));
|
|
var tempTransform = constant$1(generate$6('temp-transform'));
|
|
var transformApply = constant$1(generate$6('transform-apply'));
|
|
var internal = {
|
|
undo: undo,
|
|
redo: redo,
|
|
zoom: zoom,
|
|
back: back,
|
|
apply: apply,
|
|
swap: swap,
|
|
transform: transform$1,
|
|
tempTransform: tempTransform,
|
|
transformApply: transformApply
|
|
};
|
|
var saveState = constant$1('save-state');
|
|
var disable = constant$1('disable');
|
|
var enable = constant$1('enable');
|
|
var external = {
|
|
formActionEvent: formActionEvent,
|
|
saveState: saveState,
|
|
disable: disable,
|
|
enable: enable
|
|
};
|
|
|
|
var renderEditPanel = function (imagePanel, providersBackstage) {
|
|
var createButton = function (text, action, disabled, primary) {
|
|
return record(renderButton({
|
|
name: text,
|
|
text: text,
|
|
disabled: disabled,
|
|
primary: primary,
|
|
icon: Optional.none(),
|
|
borderless: false
|
|
}, action, providersBackstage));
|
|
};
|
|
var createIconButton = function (icon, tooltip, action, disabled) {
|
|
return record(renderIconButton({
|
|
name: icon,
|
|
icon: Optional.some(icon),
|
|
tooltip: Optional.some(tooltip),
|
|
disabled: disabled,
|
|
primary: false,
|
|
borderless: false
|
|
}, action, providersBackstage));
|
|
};
|
|
var disableAllComponents = function (comps, eventcomp) {
|
|
comps.map(function (mem) {
|
|
var component = mem.get(eventcomp);
|
|
if (component.hasConfigured(Disabling)) {
|
|
Disabling.disable(component);
|
|
}
|
|
});
|
|
};
|
|
var enableAllComponents = function (comps, eventcomp) {
|
|
comps.map(function (mem) {
|
|
var component = mem.get(eventcomp);
|
|
if (component.hasConfigured(Disabling)) {
|
|
Disabling.enable(component);
|
|
}
|
|
});
|
|
};
|
|
var panelDom = {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-image-tools__toolbar',
|
|
'tox-image-tools-edit-panel'
|
|
]
|
|
};
|
|
var noop$1 = noop;
|
|
var emit$1 = function (comp, event, data) {
|
|
emitWith(comp, event, data);
|
|
};
|
|
var emitDisable = function (component) {
|
|
return emit(component, external.disable());
|
|
};
|
|
var emitEnable = function (component) {
|
|
return emit(component, external.enable());
|
|
};
|
|
var emitTransform = function (comp, transform) {
|
|
emitDisable(comp);
|
|
emit$1(comp, internal.transform(), { transform: transform });
|
|
emitEnable(comp);
|
|
};
|
|
var emitTempTransform = function (comp, transform) {
|
|
emitDisable(comp);
|
|
emit$1(comp, internal.tempTransform(), { transform: transform });
|
|
emitEnable(comp);
|
|
};
|
|
var getBackSwap = function (anyInSystem) {
|
|
return function () {
|
|
memContainer.getOpt(anyInSystem).each(function (container) {
|
|
Replacing.set(container, [ButtonPanel]);
|
|
});
|
|
};
|
|
};
|
|
var emitTransformApply = function (comp, transform) {
|
|
emitDisable(comp);
|
|
emit$1(comp, internal.transformApply(), {
|
|
transform: transform,
|
|
swap: getBackSwap(comp)
|
|
});
|
|
emitEnable(comp);
|
|
};
|
|
var createBackButton = function () {
|
|
return createButton('Back', function (button) {
|
|
return emit$1(button, internal.back(), { swap: getBackSwap(button) });
|
|
}, false, false);
|
|
};
|
|
var createSpacer = function () {
|
|
return record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-spacer']
|
|
},
|
|
behaviours: derive$1([Disabling.config({})])
|
|
});
|
|
};
|
|
var createApplyButton = function () {
|
|
return createButton('Apply', function (button) {
|
|
return emit$1(button, internal.apply(), { swap: getBackSwap(button) });
|
|
}, true, true);
|
|
};
|
|
var makeCropTransform = function () {
|
|
return function (ir) {
|
|
var rect = imagePanel.getRect();
|
|
return crop(ir, rect.x, rect.y, rect.w, rect.h);
|
|
};
|
|
};
|
|
var cropPanelComponents = [
|
|
createBackButton(),
|
|
createSpacer(),
|
|
createButton('Apply', function (button) {
|
|
var transform = makeCropTransform();
|
|
emitTransformApply(button, transform);
|
|
imagePanel.hideCrop();
|
|
}, false, true)
|
|
];
|
|
var CropPanel = Container.sketch({
|
|
dom: panelDom,
|
|
components: cropPanelComponents.map(function (mem) {
|
|
return mem.asSpec();
|
|
}),
|
|
containerBehaviours: derive$1([config('image-tools-crop-buttons-events', [
|
|
run$1(external.disable(), function (comp, _se) {
|
|
disableAllComponents(cropPanelComponents, comp);
|
|
}),
|
|
run$1(external.enable(), function (comp, _se) {
|
|
enableAllComponents(cropPanelComponents, comp);
|
|
})
|
|
])])
|
|
});
|
|
var memSize = record(renderSizeInput({
|
|
name: 'size',
|
|
label: Optional.none(),
|
|
constrain: true,
|
|
disabled: false
|
|
}, providersBackstage));
|
|
var makeResizeTransform = function (width, height) {
|
|
return function (ir) {
|
|
return resize$1(ir, width, height);
|
|
};
|
|
};
|
|
var resizePanelComponents = [
|
|
createBackButton(),
|
|
createSpacer(),
|
|
memSize,
|
|
createSpacer(),
|
|
createButton('Apply', function (button) {
|
|
memSize.getOpt(button).each(function (sizeInput) {
|
|
var value = Representing.getValue(sizeInput);
|
|
var width = parseInt(value.width, 10);
|
|
var height = parseInt(value.height, 10);
|
|
var transform = makeResizeTransform(width, height);
|
|
emitTransformApply(button, transform);
|
|
});
|
|
}, false, true)
|
|
];
|
|
var ResizePanel = Container.sketch({
|
|
dom: panelDom,
|
|
components: resizePanelComponents.map(function (mem) {
|
|
return mem.asSpec();
|
|
}),
|
|
containerBehaviours: derive$1([config('image-tools-resize-buttons-events', [
|
|
run$1(external.disable(), function (comp, _se) {
|
|
disableAllComponents(resizePanelComponents, comp);
|
|
}),
|
|
run$1(external.enable(), function (comp, _se) {
|
|
enableAllComponents(resizePanelComponents, comp);
|
|
})
|
|
])])
|
|
});
|
|
var makeValueTransform = function (transform, value) {
|
|
return function (ir) {
|
|
return transform(ir, value);
|
|
};
|
|
};
|
|
var horizontalFlip = makeValueTransform(flip, 'h');
|
|
var verticalFlip = makeValueTransform(flip, 'v');
|
|
var counterclockwiseRotate = makeValueTransform(rotate, -90);
|
|
var clockwiseRotate = makeValueTransform(rotate, 90);
|
|
var flipRotateOnAction = function (comp, operation) {
|
|
emitTempTransform(comp, operation);
|
|
};
|
|
var flipRotateComponents = [
|
|
createBackButton(),
|
|
createSpacer(),
|
|
createIconButton('flip-horizontally', 'Flip horizontally', function (button) {
|
|
flipRotateOnAction(button, horizontalFlip);
|
|
}, false),
|
|
createIconButton('flip-vertically', 'Flip vertically', function (button) {
|
|
flipRotateOnAction(button, verticalFlip);
|
|
}, false),
|
|
createIconButton('rotate-left', 'Rotate counterclockwise', function (button) {
|
|
flipRotateOnAction(button, counterclockwiseRotate);
|
|
}, false),
|
|
createIconButton('rotate-right', 'Rotate clockwise', function (button) {
|
|
flipRotateOnAction(button, clockwiseRotate);
|
|
}, false),
|
|
createSpacer(),
|
|
createApplyButton()
|
|
];
|
|
var FlipRotatePanel = Container.sketch({
|
|
dom: panelDom,
|
|
components: flipRotateComponents.map(function (mem) {
|
|
return mem.asSpec();
|
|
}),
|
|
containerBehaviours: derive$1([config('image-tools-fliprotate-buttons-events', [
|
|
run$1(external.disable(), function (comp, _se) {
|
|
disableAllComponents(flipRotateComponents, comp);
|
|
}),
|
|
run$1(external.enable(), function (comp, _se) {
|
|
enableAllComponents(flipRotateComponents, comp);
|
|
})
|
|
])])
|
|
});
|
|
var makeSlider = function (label, onChoose, min, value, max) {
|
|
var labelPart = Slider.parts.label({
|
|
dom: {
|
|
tag: 'label',
|
|
classes: ['tox-label'],
|
|
innerHtml: providersBackstage.translate(label)
|
|
}
|
|
});
|
|
var spectrum = Slider.parts.spectrum({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-slider__rail'],
|
|
attributes: { role: 'presentation' }
|
|
}
|
|
});
|
|
var thumb = Slider.parts.thumb({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-slider__handle'],
|
|
attributes: { role: 'presentation' }
|
|
}
|
|
});
|
|
return record(Slider.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-slider'],
|
|
attributes: { role: 'presentation' }
|
|
},
|
|
model: {
|
|
mode: 'x',
|
|
minX: min,
|
|
maxX: max,
|
|
getInitialValue: constant$1({ x: value })
|
|
},
|
|
components: [
|
|
labelPart,
|
|
spectrum,
|
|
thumb
|
|
],
|
|
sliderBehaviours: derive$1([Focusing.config({})]),
|
|
onChoose: onChoose
|
|
}));
|
|
};
|
|
var makeVariableSlider = function (label, transform, min, value, max) {
|
|
var onChoose = function (slider, _thumb, value) {
|
|
var valTransform = makeValueTransform(transform, value.x / 100);
|
|
emitTransform(slider, valTransform);
|
|
};
|
|
return makeSlider(label, onChoose, min, value, max);
|
|
};
|
|
var variableFilterPanelComponents = function (label, transform, min, value, max) {
|
|
return [
|
|
createBackButton(),
|
|
makeVariableSlider(label, transform, min, value, max),
|
|
createApplyButton()
|
|
];
|
|
};
|
|
var createVariableFilterPanel = function (label, transform, min, value, max) {
|
|
var filterPanelComponents = variableFilterPanelComponents(label, transform, min, value, max);
|
|
return Container.sketch({
|
|
dom: panelDom,
|
|
components: filterPanelComponents.map(function (mem) {
|
|
return mem.asSpec();
|
|
}),
|
|
containerBehaviours: derive$1([config('image-tools-filter-panel-buttons-events', [
|
|
run$1(external.disable(), function (comp, _se) {
|
|
disableAllComponents(filterPanelComponents, comp);
|
|
}),
|
|
run$1(external.enable(), function (comp, _se) {
|
|
enableAllComponents(filterPanelComponents, comp);
|
|
})
|
|
])])
|
|
});
|
|
};
|
|
var filterPanelComponents = [
|
|
createBackButton(),
|
|
createSpacer(),
|
|
createApplyButton()
|
|
];
|
|
var FilterPanel = Container.sketch({
|
|
dom: panelDom,
|
|
components: filterPanelComponents.map(function (mem) {
|
|
return mem.asSpec();
|
|
})
|
|
});
|
|
var BrightnessPanel = createVariableFilterPanel('Brightness', brightness, -100, 0, 100);
|
|
var ContrastPanel = createVariableFilterPanel('Contrast', contrast, -100, 0, 100);
|
|
var GammaPanel = createVariableFilterPanel('Gamma', gamma, -100, 0, 100);
|
|
var makeColorTransform = function (red, green, blue) {
|
|
return function (ir) {
|
|
return colorize(ir, red, green, blue);
|
|
};
|
|
};
|
|
var makeColorSlider = function (label) {
|
|
var onChoose = function (slider, _thumb, _value) {
|
|
var redOpt = memRed.getOpt(slider);
|
|
var blueOpt = memBlue.getOpt(slider);
|
|
var greenOpt = memGreen.getOpt(slider);
|
|
redOpt.each(function (red) {
|
|
blueOpt.each(function (blue) {
|
|
greenOpt.each(function (green) {
|
|
var r = Representing.getValue(red).x / 100;
|
|
var g = Representing.getValue(green).x / 100;
|
|
var b = Representing.getValue(blue).x / 100;
|
|
var transform = makeColorTransform(r, g, b);
|
|
emitTransform(slider, transform);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
return makeSlider(label, onChoose, 0, 100, 200);
|
|
};
|
|
var memRed = makeColorSlider('R');
|
|
var memGreen = makeColorSlider('G');
|
|
var memBlue = makeColorSlider('B');
|
|
var colorizePanelComponents = [
|
|
createBackButton(),
|
|
memRed,
|
|
memGreen,
|
|
memBlue,
|
|
createApplyButton()
|
|
];
|
|
var ColorizePanel = Container.sketch({
|
|
dom: panelDom,
|
|
components: colorizePanelComponents.map(function (mem) {
|
|
return mem.asSpec();
|
|
})
|
|
});
|
|
var getTransformPanelEvent = function (panel, transform, update) {
|
|
return function (button) {
|
|
var swap = function () {
|
|
memContainer.getOpt(button).each(function (container) {
|
|
Replacing.set(container, [panel]);
|
|
update(container);
|
|
});
|
|
};
|
|
emit$1(button, internal.swap(), {
|
|
transform: transform,
|
|
swap: swap
|
|
});
|
|
};
|
|
};
|
|
var cropPanelUpdate = function (_anyInSystem) {
|
|
imagePanel.showCrop();
|
|
};
|
|
var resizePanelUpdate = function (anyInSystem) {
|
|
memSize.getOpt(anyInSystem).each(function (sizeInput) {
|
|
var measurements = imagePanel.getMeasurements();
|
|
var width = measurements.width;
|
|
var height = measurements.height;
|
|
Representing.setValue(sizeInput, {
|
|
width: width,
|
|
height: height
|
|
});
|
|
});
|
|
};
|
|
var sharpenTransform = Optional.some(sharpen);
|
|
var invertTransform = Optional.some(invert);
|
|
var buttonPanelComponents = [
|
|
createIconButton('crop', 'Crop', getTransformPanelEvent(CropPanel, Optional.none(), cropPanelUpdate), false),
|
|
createIconButton('resize', 'Resize', getTransformPanelEvent(ResizePanel, Optional.none(), resizePanelUpdate), false),
|
|
createIconButton('orientation', 'Orientation', getTransformPanelEvent(FlipRotatePanel, Optional.none(), noop$1), false),
|
|
createIconButton('brightness', 'Brightness', getTransformPanelEvent(BrightnessPanel, Optional.none(), noop$1), false),
|
|
createIconButton('sharpen', 'Sharpen', getTransformPanelEvent(FilterPanel, sharpenTransform, noop$1), false),
|
|
createIconButton('contrast', 'Contrast', getTransformPanelEvent(ContrastPanel, Optional.none(), noop$1), false),
|
|
createIconButton('color-levels', 'Color levels', getTransformPanelEvent(ColorizePanel, Optional.none(), noop$1), false),
|
|
createIconButton('gamma', 'Gamma', getTransformPanelEvent(GammaPanel, Optional.none(), noop$1), false),
|
|
createIconButton('invert', 'Invert', getTransformPanelEvent(FilterPanel, invertTransform, noop$1), false)
|
|
];
|
|
var ButtonPanel = Container.sketch({
|
|
dom: panelDom,
|
|
components: buttonPanelComponents.map(function (mem) {
|
|
return mem.asSpec();
|
|
})
|
|
});
|
|
var container = Container.sketch({
|
|
dom: { tag: 'div' },
|
|
components: [ButtonPanel],
|
|
containerBehaviours: derive$1([Replacing.config({})])
|
|
});
|
|
var memContainer = record(container);
|
|
var getApplyButton = function (anyInSystem) {
|
|
return memContainer.getOpt(anyInSystem).map(function (container) {
|
|
var panel = container.components()[0];
|
|
return panel.components()[panel.components().length - 1];
|
|
});
|
|
};
|
|
return {
|
|
memContainer: memContainer,
|
|
getApplyButton: getApplyButton
|
|
};
|
|
};
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.geom.Rect');
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Observable');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var getDocumentSize = function (doc) {
|
|
var max = Math.max;
|
|
var documentElement = doc.documentElement;
|
|
var body = doc.body;
|
|
var scrollWidth = max(documentElement.scrollWidth, body.scrollWidth);
|
|
var clientWidth = max(documentElement.clientWidth, body.clientWidth);
|
|
var offsetWidth = max(documentElement.offsetWidth, body.offsetWidth);
|
|
var scrollHeight = max(documentElement.scrollHeight, body.scrollHeight);
|
|
var clientHeight = max(documentElement.clientHeight, body.clientHeight);
|
|
var offsetHeight = max(documentElement.offsetHeight, body.offsetHeight);
|
|
return {
|
|
width: scrollWidth < offsetWidth ? clientWidth : scrollWidth,
|
|
height: scrollHeight < offsetHeight ? clientHeight : scrollHeight
|
|
};
|
|
};
|
|
var isTouchEvent$1 = function (e) {
|
|
return isNonNullable(e.changedTouches);
|
|
};
|
|
var updateWithTouchData = function (e) {
|
|
if (isTouchEvent$1(e)) {
|
|
var keys = 'screenX screenY pageX pageY clientX clientY'.split(' ');
|
|
for (var i = 0; i < keys.length; i++) {
|
|
e[keys[i]] = e.changedTouches[0][keys[i]];
|
|
}
|
|
}
|
|
};
|
|
function DragHelper (id, settings) {
|
|
var _a, _b, _c;
|
|
var eventOverlay;
|
|
var handleEvents = [];
|
|
var overlayEvents = [];
|
|
var doc = (_a = settings.document) !== null && _a !== void 0 ? _a : document;
|
|
var root = (_b = settings.root) !== null && _b !== void 0 ? _b : doc;
|
|
var sugarDoc = SugarElement.fromDom(doc);
|
|
var downButton;
|
|
var startX;
|
|
var startY;
|
|
var handleElement = SugarElement.fromDom(root.getElementById((_c = settings.handle) !== null && _c !== void 0 ? _c : id));
|
|
var start = function (e) {
|
|
var rawEvent = e.raw;
|
|
var docSize = getDocumentSize(doc);
|
|
updateWithTouchData(rawEvent);
|
|
e.prevent();
|
|
downButton = rawEvent.button;
|
|
startX = rawEvent.screenX;
|
|
startY = rawEvent.screenY;
|
|
var cursor = get$c(handleElement, 'cursor');
|
|
eventOverlay = SugarElement.fromTag('div', doc);
|
|
setAll(eventOverlay, {
|
|
'position': 'absolute',
|
|
'top': '0',
|
|
'left': '0',
|
|
'width': docSize.width + 'px',
|
|
'height': docSize.height + 'px',
|
|
'z-index': 2147483647 + '',
|
|
'opacity': '0.0001',
|
|
cursor: cursor
|
|
});
|
|
append$2(getBody(sugarDoc), eventOverlay);
|
|
overlayEvents.push(bind(sugarDoc, 'mousemove', drag), bind(sugarDoc, 'touchmove', drag), bind(sugarDoc, 'mouseup', stop), bind(sugarDoc, 'touchend', stop));
|
|
settings.start(rawEvent);
|
|
};
|
|
var drag = function (e) {
|
|
var rawEvent = e.raw;
|
|
updateWithTouchData(rawEvent);
|
|
if (rawEvent.button !== downButton) {
|
|
return stop(e);
|
|
}
|
|
rawEvent.deltaX = rawEvent.screenX - startX;
|
|
rawEvent.deltaY = rawEvent.screenY - startY;
|
|
e.prevent();
|
|
settings.drag(rawEvent);
|
|
};
|
|
var stop = function (e) {
|
|
updateWithTouchData(e.raw);
|
|
each$1(overlayEvents, function (e) {
|
|
return e.unbind();
|
|
});
|
|
overlayEvents = [];
|
|
remove$5(eventOverlay);
|
|
if (settings.stop) {
|
|
settings.stop(e.raw);
|
|
}
|
|
};
|
|
var destroy = function () {
|
|
each$1(overlayEvents.concat(handleEvents), function (e) {
|
|
return e.unbind();
|
|
});
|
|
overlayEvents = [];
|
|
handleEvents = [];
|
|
if (isNonNullable(eventOverlay)) {
|
|
remove$5(eventOverlay);
|
|
}
|
|
};
|
|
handleEvents.push(bind(handleElement, 'mousedown', start), bind(handleElement, 'touchstart', start));
|
|
return { destroy: destroy };
|
|
}
|
|
|
|
var count = 0;
|
|
var create$1 = function (currentRect, viewPortRect, clampRect, containerElm, action) {
|
|
var dragHelpers;
|
|
var events = [];
|
|
var prefix = 'tox-';
|
|
var id = prefix + 'crid-' + count++;
|
|
var container = SugarElement.fromDom(containerElm);
|
|
var handles = [
|
|
{
|
|
name: 'move',
|
|
xMul: 0,
|
|
yMul: 0,
|
|
deltaX: 1,
|
|
deltaY: 1,
|
|
deltaW: 0,
|
|
deltaH: 0,
|
|
label: 'Crop Mask'
|
|
},
|
|
{
|
|
name: 'nw',
|
|
xMul: 0,
|
|
yMul: 0,
|
|
deltaX: 1,
|
|
deltaY: 1,
|
|
deltaW: -1,
|
|
deltaH: -1,
|
|
label: 'Top Left Crop Handle'
|
|
},
|
|
{
|
|
name: 'ne',
|
|
xMul: 1,
|
|
yMul: 0,
|
|
deltaX: 0,
|
|
deltaY: 1,
|
|
deltaW: 1,
|
|
deltaH: -1,
|
|
label: 'Top Right Crop Handle'
|
|
},
|
|
{
|
|
name: 'sw',
|
|
xMul: 0,
|
|
yMul: 1,
|
|
deltaX: 1,
|
|
deltaY: 0,
|
|
deltaW: -1,
|
|
deltaH: 1,
|
|
label: 'Bottom Left Crop Handle'
|
|
},
|
|
{
|
|
name: 'se',
|
|
xMul: 1,
|
|
yMul: 1,
|
|
deltaX: 0,
|
|
deltaY: 0,
|
|
deltaW: 1,
|
|
deltaH: 1,
|
|
label: 'Bottom Right Crop Handle'
|
|
}
|
|
];
|
|
var blockers = [
|
|
'top',
|
|
'right',
|
|
'bottom',
|
|
'left'
|
|
];
|
|
var getAbsoluteRect = function (outerRect, relativeRect) {
|
|
return {
|
|
x: relativeRect.x + outerRect.x,
|
|
y: relativeRect.y + outerRect.y,
|
|
w: relativeRect.w,
|
|
h: relativeRect.h
|
|
};
|
|
};
|
|
var getRelativeRect = function (outerRect, innerRect) {
|
|
return {
|
|
x: innerRect.x - outerRect.x,
|
|
y: innerRect.y - outerRect.y,
|
|
w: innerRect.w,
|
|
h: innerRect.h
|
|
};
|
|
};
|
|
var getInnerRect = function () {
|
|
return getRelativeRect(clampRect, currentRect);
|
|
};
|
|
var moveRect = function (handle, startRect, deltaX, deltaY) {
|
|
var x = startRect.x + deltaX * handle.deltaX;
|
|
var y = startRect.y + deltaY * handle.deltaY;
|
|
var w = Math.max(20, startRect.w + deltaX * handle.deltaW);
|
|
var h = Math.max(20, startRect.h + deltaY * handle.deltaH);
|
|
var rect = currentRect = global$4.clamp({
|
|
x: x,
|
|
y: y,
|
|
w: w,
|
|
h: h
|
|
}, clampRect, handle.name === 'move');
|
|
rect = getRelativeRect(clampRect, rect);
|
|
instance.fire('updateRect', { rect: rect });
|
|
setInnerRect(rect);
|
|
};
|
|
var render = function () {
|
|
var createDragHelper = function (handle) {
|
|
var startRect;
|
|
return DragHelper(id, {
|
|
document: containerElm.ownerDocument,
|
|
root: getRootNode(container).dom,
|
|
handle: id + '-' + handle.name,
|
|
start: function () {
|
|
startRect = currentRect;
|
|
},
|
|
drag: function (e) {
|
|
moveRect(handle, startRect, e.deltaX, e.deltaY);
|
|
}
|
|
});
|
|
};
|
|
var cropContainer = SugarElement.fromTag('div');
|
|
setAll$1(cropContainer, {
|
|
id: id,
|
|
'class': prefix + 'croprect-container',
|
|
'role': 'grid',
|
|
'aria-dropeffect': 'execute'
|
|
});
|
|
append$2(container, cropContainer);
|
|
each$1(blockers, function (blocker) {
|
|
descendant(container, '#' + id).each(function (blockerElm) {
|
|
var cropBlocker = SugarElement.fromTag('div');
|
|
setAll$1(cropBlocker, {
|
|
'id': id + '-' + blocker,
|
|
'class': prefix + 'croprect-block',
|
|
'data-mce-bogus': 'all'
|
|
});
|
|
set$7(cropBlocker, 'display', 'none');
|
|
append$2(blockerElm, cropBlocker);
|
|
});
|
|
});
|
|
each$1(handles, function (handle) {
|
|
descendant(container, '#' + id).each(function (handleElm) {
|
|
var cropHandle = SugarElement.fromTag('div');
|
|
setAll$1(cropHandle, {
|
|
'id': id + '-' + handle.name,
|
|
'aria-label': handle.label,
|
|
'aria-grabbed': 'false',
|
|
'data-mce-bogus': 'all',
|
|
'role': 'gridcell',
|
|
'tabindex': '-1',
|
|
'title': handle.label
|
|
});
|
|
add$1(cropHandle, [
|
|
prefix + 'croprect-handle',
|
|
prefix + 'croprect-handle-' + handle.name
|
|
]);
|
|
set$7(cropHandle, 'display', 'none');
|
|
append$2(handleElm, cropHandle);
|
|
});
|
|
});
|
|
dragHelpers = map$2(handles, createDragHelper);
|
|
repaint(currentRect);
|
|
var handleFocus = function (e) {
|
|
set$8(e.target, 'aria-grabbed', e.raw.type === 'focus' ? 'true' : 'false');
|
|
};
|
|
var handleKeydown = function (e) {
|
|
var activeHandle;
|
|
each$1(handles, function (handle) {
|
|
if (get$d(e.target, 'id') === id + '-' + handle.name) {
|
|
activeHandle = handle;
|
|
return false;
|
|
}
|
|
});
|
|
var moveAndBlock = function (evt, handle, startRect, deltaX, deltaY) {
|
|
evt.stopPropagation();
|
|
evt.preventDefault();
|
|
moveRect(activeHandle, startRect, deltaX, deltaY);
|
|
};
|
|
switch (e.raw.keyCode) {
|
|
case global$2.LEFT:
|
|
moveAndBlock(e, activeHandle, currentRect, -10, 0);
|
|
break;
|
|
case global$2.RIGHT:
|
|
moveAndBlock(e, activeHandle, currentRect, 10, 0);
|
|
break;
|
|
case global$2.UP:
|
|
moveAndBlock(e, activeHandle, currentRect, 0, -10);
|
|
break;
|
|
case global$2.DOWN:
|
|
moveAndBlock(e, activeHandle, currentRect, 0, 10);
|
|
break;
|
|
case global$2.ENTER:
|
|
case global$2.SPACEBAR:
|
|
e.prevent();
|
|
action();
|
|
break;
|
|
}
|
|
};
|
|
events.push(bind(container, 'focusin', handleFocus), bind(container, 'focusout', handleFocus), bind(container, 'keydown', handleKeydown));
|
|
};
|
|
var toggleVisibility = function (state) {
|
|
var selectors = __spreadArray(__spreadArray([], map$2(handles, function (handle) {
|
|
return '#' + id + '-' + handle.name;
|
|
}), true), map$2(blockers, function (blocker) {
|
|
return '#' + id + '-' + blocker;
|
|
}), true).join(',');
|
|
var elems = descendants(container, selectors);
|
|
if (state) {
|
|
each$1(elems, function (elm) {
|
|
return remove$6(elm, 'display');
|
|
});
|
|
} else {
|
|
each$1(elems, function (elm) {
|
|
return set$7(elm, 'display', 'none');
|
|
});
|
|
}
|
|
};
|
|
var repaint = function (rect) {
|
|
var updateElementRect = function (name, newRect) {
|
|
descendant(container, '#' + id + '-' + name).each(function (elm) {
|
|
setAll(elm, {
|
|
left: newRect.x + 'px',
|
|
top: newRect.y + 'px',
|
|
width: Math.max(0, newRect.w) + 'px',
|
|
height: Math.max(0, newRect.h) + 'px'
|
|
});
|
|
});
|
|
};
|
|
each$1(handles, function (handle) {
|
|
descendant(container, '#' + id + '-' + handle.name).each(function (elm) {
|
|
setAll(elm, {
|
|
left: rect.w * handle.xMul + rect.x + 'px',
|
|
top: rect.h * handle.yMul + rect.y + 'px'
|
|
});
|
|
});
|
|
});
|
|
updateElementRect('top', {
|
|
x: viewPortRect.x,
|
|
y: viewPortRect.y,
|
|
w: viewPortRect.w,
|
|
h: rect.y - viewPortRect.y
|
|
});
|
|
updateElementRect('right', {
|
|
x: rect.x + rect.w,
|
|
y: rect.y,
|
|
w: viewPortRect.w - rect.x - rect.w + viewPortRect.x,
|
|
h: rect.h
|
|
});
|
|
updateElementRect('bottom', {
|
|
x: viewPortRect.x,
|
|
y: rect.y + rect.h,
|
|
w: viewPortRect.w,
|
|
h: viewPortRect.h - rect.y - rect.h + viewPortRect.y
|
|
});
|
|
updateElementRect('left', {
|
|
x: viewPortRect.x,
|
|
y: rect.y,
|
|
w: rect.x - viewPortRect.x,
|
|
h: rect.h
|
|
});
|
|
updateElementRect('move', rect);
|
|
};
|
|
var setRect = function (rect) {
|
|
currentRect = rect;
|
|
repaint(currentRect);
|
|
};
|
|
var setViewPortRect = function (rect) {
|
|
viewPortRect = rect;
|
|
repaint(currentRect);
|
|
};
|
|
var setInnerRect = function (rect) {
|
|
setRect(getAbsoluteRect(clampRect, rect));
|
|
};
|
|
var setClampRect = function (rect) {
|
|
clampRect = rect;
|
|
repaint(currentRect);
|
|
};
|
|
var destroy = function () {
|
|
each$1(dragHelpers, function (helper) {
|
|
return helper.destroy();
|
|
});
|
|
dragHelpers = [];
|
|
each$1(events, function (e) {
|
|
return e.unbind();
|
|
});
|
|
events = [];
|
|
};
|
|
render();
|
|
var instance = __assign(__assign({}, global$3), {
|
|
toggleVisibility: toggleVisibility,
|
|
setClampRect: setClampRect,
|
|
setRect: setRect,
|
|
getInnerRect: getInnerRect,
|
|
setInnerRect: setInnerRect,
|
|
setViewPortRect: setViewPortRect,
|
|
destroy: destroy
|
|
});
|
|
return instance;
|
|
};
|
|
var CropRect = { create: create$1 };
|
|
|
|
var loadImage = function (image) {
|
|
return new global$c(function (resolve) {
|
|
var loaded = function () {
|
|
image.removeEventListener('load', loaded);
|
|
resolve(image);
|
|
};
|
|
if (image.complete) {
|
|
resolve(image);
|
|
} else {
|
|
image.addEventListener('load', loaded);
|
|
}
|
|
});
|
|
};
|
|
var renderImagePanel = function (initialUrl) {
|
|
var memBg = record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-image-tools__image-bg'],
|
|
attributes: { role: 'presentation' }
|
|
}
|
|
});
|
|
var zoomState = Cell(1);
|
|
var cropRect = api$1();
|
|
var rectState = Cell({
|
|
x: 0,
|
|
y: 0,
|
|
w: 1,
|
|
h: 1
|
|
});
|
|
var viewRectState = Cell({
|
|
x: 0,
|
|
y: 0,
|
|
w: 1,
|
|
h: 1
|
|
});
|
|
var repaintImg = function (anyInSystem, img) {
|
|
memContainer.getOpt(anyInSystem).each(function (panel) {
|
|
var zoom = zoomState.get();
|
|
var panelW = get$a(panel.element);
|
|
var panelH = get$b(panel.element);
|
|
var width = img.dom.naturalWidth * zoom;
|
|
var height = img.dom.naturalHeight * zoom;
|
|
var left = Math.max(0, panelW / 2 - width / 2);
|
|
var top = Math.max(0, panelH / 2 - height / 2);
|
|
var css = {
|
|
left: left.toString() + 'px',
|
|
top: top.toString() + 'px',
|
|
width: width.toString() + 'px',
|
|
height: height.toString() + 'px',
|
|
position: 'absolute'
|
|
};
|
|
setAll(img, css);
|
|
memBg.getOpt(panel).each(function (bg) {
|
|
setAll(bg.element, css);
|
|
});
|
|
cropRect.run(function (cRect) {
|
|
var rect = rectState.get();
|
|
cRect.setRect({
|
|
x: rect.x * zoom + left,
|
|
y: rect.y * zoom + top,
|
|
w: rect.w * zoom,
|
|
h: rect.h * zoom
|
|
});
|
|
cRect.setClampRect({
|
|
x: left,
|
|
y: top,
|
|
w: width,
|
|
h: height
|
|
});
|
|
cRect.setViewPortRect({
|
|
x: 0,
|
|
y: 0,
|
|
w: panelW,
|
|
h: panelH
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var zoomFit = function (anyInSystem, img) {
|
|
memContainer.getOpt(anyInSystem).each(function (panel) {
|
|
var panelW = get$a(panel.element);
|
|
var panelH = get$b(panel.element);
|
|
var width = img.dom.naturalWidth;
|
|
var height = img.dom.naturalHeight;
|
|
var zoom = Math.min(panelW / width, panelH / height);
|
|
if (zoom >= 1) {
|
|
zoomState.set(1);
|
|
} else {
|
|
zoomState.set(zoom);
|
|
}
|
|
});
|
|
};
|
|
var updateSrc = function (anyInSystem, url) {
|
|
var img = SugarElement.fromTag('img');
|
|
set$8(img, 'src', url);
|
|
return loadImage(img.dom).then(function () {
|
|
if (anyInSystem.getSystem().isConnected()) {
|
|
memContainer.getOpt(anyInSystem).map(function (panel) {
|
|
var aImg = external$2({ element: img });
|
|
Replacing.replaceAt(panel, 1, Optional.some(aImg));
|
|
var lastViewRect = viewRectState.get();
|
|
var viewRect = {
|
|
x: 0,
|
|
y: 0,
|
|
w: img.dom.naturalWidth,
|
|
h: img.dom.naturalHeight
|
|
};
|
|
viewRectState.set(viewRect);
|
|
var rect = global$4.inflate(viewRect, -20, -20);
|
|
rectState.set(rect);
|
|
if (lastViewRect.w !== viewRect.w || lastViewRect.h !== viewRect.h) {
|
|
zoomFit(panel, img);
|
|
}
|
|
repaintImg(panel, img);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var zoom = function (anyInSystem, direction) {
|
|
var currentZoom = zoomState.get();
|
|
var newZoom = direction > 0 ? Math.min(2, currentZoom + 0.1) : Math.max(0.1, currentZoom - 0.1);
|
|
zoomState.set(newZoom);
|
|
memContainer.getOpt(anyInSystem).each(function (panel) {
|
|
var img = panel.components()[1].element;
|
|
repaintImg(panel, img);
|
|
});
|
|
};
|
|
var showCrop = function () {
|
|
cropRect.run(function (cRect) {
|
|
cRect.toggleVisibility(true);
|
|
});
|
|
};
|
|
var hideCrop = function () {
|
|
cropRect.run(function (cRect) {
|
|
cRect.toggleVisibility(false);
|
|
});
|
|
};
|
|
var getRect = function () {
|
|
return rectState.get();
|
|
};
|
|
var container = Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-image-tools__image']
|
|
},
|
|
components: [
|
|
memBg.asSpec(),
|
|
{
|
|
dom: {
|
|
tag: 'img',
|
|
attributes: { src: initialUrl }
|
|
}
|
|
},
|
|
{
|
|
dom: { tag: 'div' },
|
|
behaviours: derive$1([config('image-panel-crop-events', [
|
|
runOnAttached(function (comp) {
|
|
memContainer.getOpt(comp).each(function (container) {
|
|
var el = container.element.dom;
|
|
var cRect = CropRect.create({
|
|
x: 10,
|
|
y: 10,
|
|
w: 100,
|
|
h: 100
|
|
}, {
|
|
x: 0,
|
|
y: 0,
|
|
w: 200,
|
|
h: 200
|
|
}, {
|
|
x: 0,
|
|
y: 0,
|
|
w: 200,
|
|
h: 200
|
|
}, el, noop);
|
|
cRect.toggleVisibility(false);
|
|
cRect.on('updateRect', function (e) {
|
|
var rect = e.rect;
|
|
var zoom = zoomState.get();
|
|
var newRect = {
|
|
x: Math.round(rect.x / zoom),
|
|
y: Math.round(rect.y / zoom),
|
|
w: Math.round(rect.w / zoom),
|
|
h: Math.round(rect.h / zoom)
|
|
};
|
|
rectState.set(newRect);
|
|
});
|
|
cropRect.set(cRect);
|
|
});
|
|
}),
|
|
runOnDetached(function () {
|
|
cropRect.clear();
|
|
})
|
|
])])
|
|
}
|
|
],
|
|
containerBehaviours: derive$1([
|
|
Replacing.config({}),
|
|
config('image-panel-events', [runOnAttached(function (comp) {
|
|
updateSrc(comp, initialUrl);
|
|
})])
|
|
])
|
|
});
|
|
var memContainer = record(container);
|
|
var getMeasurements = function () {
|
|
var viewRect = viewRectState.get();
|
|
return {
|
|
width: viewRect.w,
|
|
height: viewRect.h
|
|
};
|
|
};
|
|
return {
|
|
memContainer: memContainer,
|
|
updateSrc: updateSrc,
|
|
zoom: zoom,
|
|
showCrop: showCrop,
|
|
hideCrop: hideCrop,
|
|
getRect: getRect,
|
|
getMeasurements: getMeasurements
|
|
};
|
|
};
|
|
|
|
var createButton = function (innerHtml, icon, disabled, action, providersBackstage) {
|
|
return renderIconButton({
|
|
name: innerHtml,
|
|
icon: Optional.some(icon),
|
|
disabled: disabled,
|
|
tooltip: Optional.some(innerHtml),
|
|
primary: false,
|
|
borderless: false
|
|
}, action, providersBackstage);
|
|
};
|
|
var setButtonEnabled = function (button, enabled) {
|
|
if (enabled) {
|
|
Disabling.enable(button);
|
|
} else {
|
|
Disabling.disable(button);
|
|
}
|
|
};
|
|
var renderSideBar = function (providersBackstage) {
|
|
var updateButtonUndoStates = function (anyInSystem, undoEnabled, redoEnabled) {
|
|
memUndo.getOpt(anyInSystem).each(function (undo) {
|
|
setButtonEnabled(undo, undoEnabled);
|
|
});
|
|
memRedo.getOpt(anyInSystem).each(function (redo) {
|
|
setButtonEnabled(redo, redoEnabled);
|
|
});
|
|
};
|
|
var memUndo = record(createButton('Undo', 'undo', true, function (button) {
|
|
emitWith(button, internal.undo(), { direction: 1 });
|
|
}, providersBackstage));
|
|
var memRedo = record(createButton('Redo', 'redo', true, function (button) {
|
|
emitWith(button, internal.redo(), { direction: 1 });
|
|
}, providersBackstage));
|
|
var container = Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-image-tools__toolbar',
|
|
'tox-image-tools__sidebar'
|
|
]
|
|
},
|
|
components: [
|
|
memUndo.asSpec(),
|
|
memRedo.asSpec(),
|
|
createButton('Zoom in', 'zoom-in', false, function (button) {
|
|
emitWith(button, internal.zoom(), { direction: 1 });
|
|
}, providersBackstage),
|
|
createButton('Zoom out', 'zoom-out', false, function (button) {
|
|
emitWith(button, internal.zoom(), { direction: -1 });
|
|
}, providersBackstage)
|
|
]
|
|
});
|
|
return {
|
|
container: container,
|
|
updateButtonUndoStates: updateButtonUndoStates
|
|
};
|
|
};
|
|
|
|
function UndoStack () {
|
|
var data = [];
|
|
var index = -1;
|
|
var add = function (state) {
|
|
var removed = data.splice(++index);
|
|
data.push(state);
|
|
return {
|
|
state: state,
|
|
removed: removed
|
|
};
|
|
};
|
|
var undo = function () {
|
|
if (canUndo()) {
|
|
return data[--index];
|
|
}
|
|
};
|
|
var redo = function () {
|
|
if (canRedo()) {
|
|
return data[++index];
|
|
}
|
|
};
|
|
var canUndo = function () {
|
|
return index > 0;
|
|
};
|
|
var canRedo = function () {
|
|
return index !== -1 && index < data.length - 1;
|
|
};
|
|
return {
|
|
data: data,
|
|
add: add,
|
|
undo: undo,
|
|
redo: redo,
|
|
canUndo: canUndo,
|
|
canRedo: canRedo
|
|
};
|
|
}
|
|
|
|
var makeState = function (initialState) {
|
|
var blobState = Cell(initialState);
|
|
var tempState = value$1();
|
|
var undoStack = UndoStack();
|
|
undoStack.add(initialState);
|
|
var getBlobState = function () {
|
|
return blobState.get();
|
|
};
|
|
var setBlobState = function (state) {
|
|
blobState.set(state);
|
|
};
|
|
var getTempState = function () {
|
|
return tempState.get().getOrThunk(blobState.get);
|
|
};
|
|
var updateTempState = function (blob) {
|
|
var newTempState = createState(blob);
|
|
destroyTempState();
|
|
tempState.set(newTempState);
|
|
return newTempState.url;
|
|
};
|
|
var createState = function (blob) {
|
|
return {
|
|
blob: blob,
|
|
url: URL.createObjectURL(blob)
|
|
};
|
|
};
|
|
var destroyState = function (state) {
|
|
URL.revokeObjectURL(state.url);
|
|
};
|
|
var destroyStates = function (states) {
|
|
global$5.each(states, destroyState);
|
|
};
|
|
var destroyTempState = function () {
|
|
tempState.on(destroyState);
|
|
tempState.clear();
|
|
};
|
|
var addBlobState = function (blob) {
|
|
var newState = createState(blob);
|
|
setBlobState(newState);
|
|
var removed = undoStack.add(newState).removed;
|
|
destroyStates(removed);
|
|
return newState.url;
|
|
};
|
|
var addTempState = function (blob) {
|
|
var newState = createState(blob);
|
|
tempState.set(newState);
|
|
return newState.url;
|
|
};
|
|
var applyTempState = function (postApply) {
|
|
return tempState.get().fold(noop, function (temp) {
|
|
addBlobState(temp.blob);
|
|
postApply();
|
|
});
|
|
};
|
|
var undo = function () {
|
|
var currentState = undoStack.undo();
|
|
setBlobState(currentState);
|
|
return currentState.url;
|
|
};
|
|
var redo = function () {
|
|
var currentState = undoStack.redo();
|
|
setBlobState(currentState);
|
|
return currentState.url;
|
|
};
|
|
var getHistoryStates = function () {
|
|
var undoEnabled = undoStack.canUndo();
|
|
var redoEnabled = undoStack.canRedo();
|
|
return {
|
|
undoEnabled: undoEnabled,
|
|
redoEnabled: redoEnabled
|
|
};
|
|
};
|
|
return {
|
|
getBlobState: getBlobState,
|
|
setBlobState: setBlobState,
|
|
addBlobState: addBlobState,
|
|
getTempState: getTempState,
|
|
updateTempState: updateTempState,
|
|
addTempState: addTempState,
|
|
applyTempState: applyTempState,
|
|
destroyTempState: destroyTempState,
|
|
undo: undo,
|
|
redo: redo,
|
|
getHistoryStates: getHistoryStates
|
|
};
|
|
};
|
|
|
|
var renderImageTools = function (detail, providersBackstage) {
|
|
var state = makeState(detail.currentState);
|
|
var zoom = function (anyInSystem, simulatedEvent) {
|
|
var direction = simulatedEvent.event.direction;
|
|
imagePanel.zoom(anyInSystem, direction);
|
|
};
|
|
var updateButtonUndoStates = function (anyInSystem) {
|
|
var historyStates = state.getHistoryStates();
|
|
sideBar.updateButtonUndoStates(anyInSystem, historyStates.undoEnabled, historyStates.redoEnabled);
|
|
emitWith(anyInSystem, external.formActionEvent, {
|
|
name: external.saveState(),
|
|
value: historyStates.undoEnabled
|
|
});
|
|
};
|
|
var disableUndoRedo = function (anyInSystem) {
|
|
sideBar.updateButtonUndoStates(anyInSystem, false, false);
|
|
};
|
|
var undo = function (anyInSystem, _simulatedEvent) {
|
|
var url = state.undo();
|
|
updateSrc(anyInSystem, url).then(function (_oImg) {
|
|
unblock(anyInSystem);
|
|
updateButtonUndoStates(anyInSystem);
|
|
});
|
|
};
|
|
var redo = function (anyInSystem, _simulatedEvent) {
|
|
var url = state.redo();
|
|
updateSrc(anyInSystem, url).then(function (_oImg) {
|
|
unblock(anyInSystem);
|
|
updateButtonUndoStates(anyInSystem);
|
|
});
|
|
};
|
|
var imageResultToBlob = function (ir) {
|
|
return ir.toBlob();
|
|
};
|
|
var block = function (anyInSystem) {
|
|
emitWith(anyInSystem, external.formActionEvent, {
|
|
name: external.disable(),
|
|
value: {}
|
|
});
|
|
};
|
|
var unblock = function (anyInSystem) {
|
|
editPanel.getApplyButton(anyInSystem).each(function (applyButton) {
|
|
Disabling.enable(applyButton);
|
|
});
|
|
emitWith(anyInSystem, external.formActionEvent, {
|
|
name: external.enable(),
|
|
value: {}
|
|
});
|
|
};
|
|
var updateSrc = function (anyInSystem, src) {
|
|
block(anyInSystem);
|
|
return imagePanel.updateSrc(anyInSystem, src);
|
|
};
|
|
var blobManipulate = function (anyInSystem, blob, filter, action, swap) {
|
|
block(anyInSystem);
|
|
blobToImageResult(blob).then(filter).then(imageResultToBlob).then(action).then(function (url) {
|
|
return updateSrc(anyInSystem, url);
|
|
}).then(function () {
|
|
updateButtonUndoStates(anyInSystem);
|
|
swap();
|
|
unblock(anyInSystem);
|
|
}).catch(function (err) {
|
|
console.log(err);
|
|
if (anyInSystem.getSystem().isConnected()) {
|
|
unblock(anyInSystem);
|
|
}
|
|
});
|
|
};
|
|
var manipulate = function (anyInSystem, filter, swap) {
|
|
var blob = state.getBlobState().blob;
|
|
var action = function (blob) {
|
|
return state.updateTempState(blob);
|
|
};
|
|
blobManipulate(anyInSystem, blob, filter, action, swap);
|
|
};
|
|
var tempManipulate = function (anyInSystem, filter) {
|
|
var blob = state.getTempState().blob;
|
|
var action = function (blob) {
|
|
return state.addTempState(blob);
|
|
};
|
|
blobManipulate(anyInSystem, blob, filter, action, noop);
|
|
};
|
|
var manipulateApply = function (anyInSystem, filter, swap) {
|
|
var blob = state.getBlobState().blob;
|
|
var action = function (blob) {
|
|
var url = state.addBlobState(blob);
|
|
destroyTempState(anyInSystem);
|
|
return url;
|
|
};
|
|
blobManipulate(anyInSystem, blob, filter, action, swap);
|
|
};
|
|
var apply = function (anyInSystem, simulatedEvent) {
|
|
var postApply = function () {
|
|
destroyTempState(anyInSystem);
|
|
var swap = simulatedEvent.event.swap;
|
|
swap();
|
|
};
|
|
state.applyTempState(postApply);
|
|
};
|
|
var destroyTempState = function (anyInSystem) {
|
|
var currentUrl = state.getBlobState().url;
|
|
state.destroyTempState();
|
|
updateButtonUndoStates(anyInSystem);
|
|
return currentUrl;
|
|
};
|
|
var cancel = function (anyInSystem) {
|
|
var currentUrl = destroyTempState(anyInSystem);
|
|
updateSrc(anyInSystem, currentUrl).then(function (_oImg) {
|
|
unblock(anyInSystem);
|
|
});
|
|
};
|
|
var back = function (anyInSystem, simulatedEvent) {
|
|
cancel(anyInSystem);
|
|
var swap = simulatedEvent.event.swap;
|
|
swap();
|
|
imagePanel.hideCrop();
|
|
};
|
|
var transform = function (anyInSystem, simulatedEvent) {
|
|
return manipulate(anyInSystem, simulatedEvent.event.transform, noop);
|
|
};
|
|
var tempTransform = function (anyInSystem, simulatedEvent) {
|
|
return tempManipulate(anyInSystem, simulatedEvent.event.transform);
|
|
};
|
|
var transformApply = function (anyInSystem, simulatedEvent) {
|
|
return manipulateApply(anyInSystem, simulatedEvent.event.transform, simulatedEvent.event.swap);
|
|
};
|
|
var imagePanel = renderImagePanel(detail.currentState.url);
|
|
var sideBar = renderSideBar(providersBackstage);
|
|
var editPanel = renderEditPanel(imagePanel, providersBackstage);
|
|
var swap = function (anyInSystem, simulatedEvent) {
|
|
disableUndoRedo(anyInSystem);
|
|
var transform = simulatedEvent.event.transform;
|
|
var swap = simulatedEvent.event.swap;
|
|
transform.fold(function () {
|
|
swap();
|
|
}, function (transform) {
|
|
manipulate(anyInSystem, transform, swap);
|
|
});
|
|
};
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { role: 'presentation' }
|
|
},
|
|
components: [
|
|
editPanel.memContainer.asSpec(),
|
|
imagePanel.memContainer.asSpec(),
|
|
sideBar.container
|
|
],
|
|
behaviours: derive$1([
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function () {
|
|
return state.getBlobState();
|
|
}
|
|
}
|
|
}),
|
|
config('image-tools-events', [
|
|
run$1(internal.undo(), undo),
|
|
run$1(internal.redo(), redo),
|
|
run$1(internal.zoom(), zoom),
|
|
run$1(internal.back(), back),
|
|
run$1(internal.apply(), apply),
|
|
run$1(internal.transform(), transform),
|
|
run$1(internal.tempTransform(), tempTransform),
|
|
run$1(internal.transformApply(), transformApply),
|
|
run$1(internal.swap(), swap)
|
|
]),
|
|
ComposingConfigs.self()
|
|
])
|
|
};
|
|
};
|
|
|
|
var renderLabel = function (spec, backstageShared) {
|
|
var label = {
|
|
dom: {
|
|
tag: 'label',
|
|
innerHtml: backstageShared.providers.translate(spec.label),
|
|
classes: ['tox-label']
|
|
}
|
|
};
|
|
var comps = map$2(spec.items, backstageShared.interpreter);
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group']
|
|
},
|
|
components: [label].concat(comps),
|
|
behaviours: derive$1([
|
|
ComposingConfigs.self(),
|
|
Replacing.config({}),
|
|
RepresentingConfigs.domHtml(Optional.none()),
|
|
Keying.config({ mode: 'acyclic' })
|
|
])
|
|
};
|
|
};
|
|
|
|
var isSingleListItem = function (item) {
|
|
return !has$2(item, 'items');
|
|
};
|
|
var dataAttribute = 'data-value';
|
|
var fetchItems = function (dropdownComp, name, items, selectedValue) {
|
|
return map$2(items, function (item) {
|
|
if (!isSingleListItem(item)) {
|
|
return {
|
|
type: 'nestedmenuitem',
|
|
text: item.text,
|
|
getSubmenuItems: function () {
|
|
return fetchItems(dropdownComp, name, item.items, selectedValue);
|
|
}
|
|
};
|
|
} else {
|
|
return {
|
|
type: 'togglemenuitem',
|
|
text: item.text,
|
|
value: item.value,
|
|
active: item.value === selectedValue,
|
|
onAction: function () {
|
|
Representing.setValue(dropdownComp, item.value);
|
|
emitWith(dropdownComp, formChangeEvent, { name: name });
|
|
Focusing.focus(dropdownComp);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var findItemByValue = function (items, value) {
|
|
return findMap(items, function (item) {
|
|
if (!isSingleListItem(item)) {
|
|
return findItemByValue(item.items, value);
|
|
} else {
|
|
return someIf(item.value === value, item);
|
|
}
|
|
});
|
|
};
|
|
var renderListBox = function (spec, backstage) {
|
|
var providersBackstage = backstage.shared.providers;
|
|
var initialItem = head(spec.items).filter(isSingleListItem);
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, providersBackstage);
|
|
});
|
|
var pField = FormField.parts.field({
|
|
dom: {},
|
|
factory: {
|
|
sketch: function (sketchSpec) {
|
|
return renderCommonDropdown({
|
|
uid: sketchSpec.uid,
|
|
text: initialItem.map(function (item) {
|
|
return item.text;
|
|
}),
|
|
icon: Optional.none(),
|
|
tooltip: spec.label,
|
|
role: Optional.none(),
|
|
fetch: function (comp, callback) {
|
|
var items = fetchItems(comp, spec.name, spec.items, Representing.getValue(comp));
|
|
callback(build(items, ItemResponse$1.CLOSE_ON_EXECUTE, backstage, false));
|
|
},
|
|
onSetup: constant$1(noop),
|
|
getApi: constant$1({}),
|
|
columns: 1,
|
|
presets: 'normal',
|
|
classes: [],
|
|
dropdownBehaviours: [
|
|
Tabstopping.config({}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
initialValue: initialItem.map(function (item) {
|
|
return item.value;
|
|
}).getOr(''),
|
|
getValue: function (comp) {
|
|
return get$d(comp.element, dataAttribute);
|
|
},
|
|
setValue: function (comp, data) {
|
|
findItemByValue(spec.items, data).each(function (item) {
|
|
set$8(comp.element, dataAttribute, item.value);
|
|
emitWith(comp, updateMenuText, { text: item.text });
|
|
});
|
|
}
|
|
}
|
|
})
|
|
]
|
|
}, 'tox-listbox', backstage.shared);
|
|
}
|
|
}
|
|
});
|
|
var listBoxWrap = {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-listboxfield']
|
|
},
|
|
components: [pField]
|
|
};
|
|
return FormField.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group']
|
|
},
|
|
components: flatten([
|
|
pLabel.toArray(),
|
|
[listBoxWrap]
|
|
]),
|
|
fieldBehaviours: derive$1([Disabling.config({
|
|
disabled: constant$1(spec.disabled),
|
|
onDisabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.disable);
|
|
},
|
|
onEnabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.enable);
|
|
}
|
|
})])
|
|
});
|
|
};
|
|
|
|
var renderPanel = function (spec, backstage) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: spec.classes
|
|
},
|
|
components: map$2(spec.items, backstage.shared.interpreter)
|
|
};
|
|
};
|
|
|
|
var factory$e = function (detail, _spec) {
|
|
var options = map$2(detail.options, function (option) {
|
|
return {
|
|
dom: {
|
|
tag: 'option',
|
|
value: option.value,
|
|
innerHtml: option.text
|
|
}
|
|
};
|
|
});
|
|
var initialValues = detail.data.map(function (v) {
|
|
return wrap$1('initialValue', v);
|
|
}).getOr({});
|
|
return {
|
|
uid: detail.uid,
|
|
dom: {
|
|
tag: 'select',
|
|
classes: detail.selectClasses,
|
|
attributes: detail.selectAttributes
|
|
},
|
|
components: options,
|
|
behaviours: augment(detail.selectBehaviours, [
|
|
Focusing.config({}),
|
|
Representing.config({
|
|
store: __assign({
|
|
mode: 'manual',
|
|
getValue: function (select) {
|
|
return get$5(select.element);
|
|
},
|
|
setValue: function (select, newValue) {
|
|
var found = find$5(detail.options, function (opt) {
|
|
return opt.value === newValue;
|
|
});
|
|
if (found.isSome()) {
|
|
set$4(select.element, newValue);
|
|
}
|
|
}
|
|
}, initialValues)
|
|
})
|
|
])
|
|
};
|
|
};
|
|
var HtmlSelect = single({
|
|
name: 'HtmlSelect',
|
|
configFields: [
|
|
required$1('options'),
|
|
field('selectBehaviours', [
|
|
Focusing,
|
|
Representing
|
|
]),
|
|
defaulted('selectClasses', []),
|
|
defaulted('selectAttributes', {}),
|
|
option('data')
|
|
],
|
|
factory: factory$e
|
|
});
|
|
|
|
var renderSelectBox = function (spec, providersBackstage) {
|
|
var translatedOptions = map$2(spec.items, function (item) {
|
|
return {
|
|
text: providersBackstage.translate(item.text),
|
|
value: item.value
|
|
};
|
|
});
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, providersBackstage);
|
|
});
|
|
var pField = FormField.parts.field({
|
|
dom: {},
|
|
selectAttributes: { size: spec.size },
|
|
options: translatedOptions,
|
|
factory: HtmlSelect,
|
|
selectBehaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}
|
|
}),
|
|
Tabstopping.config({}),
|
|
config('selectbox-change', [run$1(change(), function (component, _) {
|
|
emitWith(component, formChangeEvent, { name: spec.name });
|
|
})])
|
|
])
|
|
});
|
|
var chevron = spec.size > 1 ? Optional.none() : Optional.some(render$3('chevron-down', {
|
|
tag: 'div',
|
|
classes: ['tox-selectfield__icon-js']
|
|
}, providersBackstage.icons));
|
|
var selectWrap = {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-selectfield']
|
|
},
|
|
components: flatten([
|
|
[pField],
|
|
chevron.toArray()
|
|
])
|
|
};
|
|
return FormField.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group']
|
|
},
|
|
components: flatten([
|
|
pLabel.toArray(),
|
|
[selectWrap]
|
|
]),
|
|
fieldBehaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
},
|
|
onDisabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.disable);
|
|
},
|
|
onEnabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.enable);
|
|
}
|
|
}),
|
|
receivingConfig()
|
|
])
|
|
});
|
|
};
|
|
|
|
var renderTable = function (spec, providersBackstage) {
|
|
var renderTh = function (text) {
|
|
return {
|
|
dom: {
|
|
tag: 'th',
|
|
innerHtml: providersBackstage.translate(text)
|
|
}
|
|
};
|
|
};
|
|
var renderHeader = function (header) {
|
|
return {
|
|
dom: { tag: 'thead' },
|
|
components: [{
|
|
dom: { tag: 'tr' },
|
|
components: map$2(header, renderTh)
|
|
}]
|
|
};
|
|
};
|
|
var renderTd = function (text) {
|
|
return {
|
|
dom: {
|
|
tag: 'td',
|
|
innerHtml: providersBackstage.translate(text)
|
|
}
|
|
};
|
|
};
|
|
var renderTr = function (row) {
|
|
return {
|
|
dom: { tag: 'tr' },
|
|
components: map$2(row, renderTd)
|
|
};
|
|
};
|
|
var renderRows = function (rows) {
|
|
return {
|
|
dom: { tag: 'tbody' },
|
|
components: map$2(rows, renderTr)
|
|
};
|
|
};
|
|
return {
|
|
dom: {
|
|
tag: 'table',
|
|
classes: ['tox-dialog__table']
|
|
},
|
|
components: [
|
|
renderHeader(spec.header),
|
|
renderRows(spec.cells)
|
|
],
|
|
behaviours: derive$1([
|
|
Tabstopping.config({}),
|
|
Focusing.config({})
|
|
])
|
|
};
|
|
};
|
|
|
|
var renderTextField = function (spec, providersBackstage) {
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, providersBackstage);
|
|
});
|
|
var baseInputBehaviours = [
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}
|
|
}),
|
|
receivingConfig(),
|
|
Keying.config({
|
|
mode: 'execution',
|
|
useEnter: spec.multiline !== true,
|
|
useControlEnter: spec.multiline === true,
|
|
execute: function (comp) {
|
|
emit(comp, formSubmitEvent);
|
|
return Optional.some(true);
|
|
}
|
|
}),
|
|
config('textfield-change', [
|
|
run$1(input(), function (component, _) {
|
|
emitWith(component, formChangeEvent, { name: spec.name });
|
|
}),
|
|
run$1(postPaste(), function (component, _) {
|
|
emitWith(component, formChangeEvent, { name: spec.name });
|
|
})
|
|
]),
|
|
Tabstopping.config({})
|
|
];
|
|
var validatingBehaviours = spec.validation.map(function (vl) {
|
|
return Invalidating.config({
|
|
getRoot: function (input) {
|
|
return parent(input.element);
|
|
},
|
|
invalidClass: 'tox-invalid',
|
|
validator: {
|
|
validate: function (input) {
|
|
var v = Representing.getValue(input);
|
|
var result = vl.validator(v);
|
|
return Future.pure(result === true ? Result.value(v) : Result.error(result));
|
|
},
|
|
validateOnLoad: vl.validateOnLoad
|
|
}
|
|
});
|
|
}).toArray();
|
|
var placeholder = spec.placeholder.fold(constant$1({}), function (p) {
|
|
return { placeholder: providersBackstage.translate(p) };
|
|
});
|
|
var inputMode = spec.inputMode.fold(constant$1({}), function (mode) {
|
|
return { inputmode: mode };
|
|
});
|
|
var inputAttributes = __assign(__assign({}, placeholder), inputMode);
|
|
var pField = FormField.parts.field({
|
|
tag: spec.multiline === true ? 'textarea' : 'input',
|
|
inputAttributes: inputAttributes,
|
|
inputClasses: [spec.classname],
|
|
inputBehaviours: derive$1(flatten([
|
|
baseInputBehaviours,
|
|
validatingBehaviours
|
|
])),
|
|
selectOnFocus: false,
|
|
factory: Input
|
|
});
|
|
var extraClasses = spec.flex ? ['tox-form__group--stretched'] : [];
|
|
var extraClasses2 = extraClasses.concat(spec.maximized ? ['tox-form-group--maximize'] : []);
|
|
var extraBehaviours = [
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
},
|
|
onDisabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.disable);
|
|
},
|
|
onEnabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.enable);
|
|
}
|
|
}),
|
|
receivingConfig()
|
|
];
|
|
return renderFormFieldWith(pLabel, pField, extraClasses2, extraBehaviours);
|
|
};
|
|
var renderInput = function (spec, providersBackstage) {
|
|
return renderTextField({
|
|
name: spec.name,
|
|
multiline: false,
|
|
label: spec.label,
|
|
inputMode: spec.inputMode,
|
|
placeholder: spec.placeholder,
|
|
flex: false,
|
|
disabled: spec.disabled,
|
|
classname: 'tox-textfield',
|
|
validation: Optional.none(),
|
|
maximized: spec.maximized
|
|
}, providersBackstage);
|
|
};
|
|
var renderTextarea = function (spec, providersBackstage) {
|
|
return renderTextField({
|
|
name: spec.name,
|
|
multiline: true,
|
|
label: spec.label,
|
|
inputMode: Optional.none(),
|
|
placeholder: spec.placeholder,
|
|
flex: true,
|
|
disabled: spec.disabled,
|
|
classname: 'tox-textarea',
|
|
validation: Optional.none(),
|
|
maximized: spec.maximized
|
|
}, providersBackstage);
|
|
};
|
|
|
|
var events$6 = function (streamConfig, streamState) {
|
|
var streams = streamConfig.stream.streams;
|
|
var processor = streams.setup(streamConfig, streamState);
|
|
return derive$2([
|
|
run$1(streamConfig.event, processor),
|
|
runOnDetached(function () {
|
|
return streamState.cancel();
|
|
})
|
|
].concat(streamConfig.cancelEvent.map(function (e) {
|
|
return [run$1(e, function () {
|
|
return streamState.cancel();
|
|
})];
|
|
}).getOr([])));
|
|
};
|
|
|
|
var ActiveStreaming = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$6
|
|
});
|
|
|
|
var throttle = function (_config) {
|
|
var state = Cell(null);
|
|
var readState = function () {
|
|
return { timer: state.get() !== null ? 'set' : 'unset' };
|
|
};
|
|
var setTimer = function (t) {
|
|
state.set(t);
|
|
};
|
|
var cancel = function () {
|
|
var t = state.get();
|
|
if (t !== null) {
|
|
t.cancel();
|
|
}
|
|
};
|
|
return nu$8({
|
|
readState: readState,
|
|
setTimer: setTimer,
|
|
cancel: cancel
|
|
});
|
|
};
|
|
var init$9 = function (spec) {
|
|
return spec.stream.streams.state(spec);
|
|
};
|
|
|
|
var StreamingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
throttle: throttle,
|
|
init: init$9
|
|
});
|
|
|
|
var setup$c = function (streamInfo, streamState) {
|
|
var sInfo = streamInfo.stream;
|
|
var throttler = last(streamInfo.onStream, sInfo.delay);
|
|
streamState.setTimer(throttler);
|
|
return function (component, simulatedEvent) {
|
|
throttler.throttle(component, simulatedEvent);
|
|
if (sInfo.stopEvent) {
|
|
simulatedEvent.stop();
|
|
}
|
|
};
|
|
};
|
|
var StreamingSchema = [
|
|
requiredOf('stream', choose$1('mode', {
|
|
throttle: [
|
|
required$1('delay'),
|
|
defaulted('stopEvent', true),
|
|
output$1('streams', {
|
|
setup: setup$c,
|
|
state: throttle
|
|
})
|
|
]
|
|
})),
|
|
defaulted('event', 'input'),
|
|
option('cancelEvent'),
|
|
onStrictHandler('onStream')
|
|
];
|
|
|
|
var Streaming = create$7({
|
|
fields: StreamingSchema,
|
|
name: 'streaming',
|
|
active: ActiveStreaming,
|
|
state: StreamingState
|
|
});
|
|
|
|
var setValueFromItem = function (model, input, item) {
|
|
var itemData = Representing.getValue(item);
|
|
Representing.setValue(input, itemData);
|
|
setCursorAtEnd(input);
|
|
};
|
|
var setSelectionOn = function (input, f) {
|
|
var el = input.element;
|
|
var value = get$5(el);
|
|
var node = el.dom;
|
|
if (get$d(el, 'type') !== 'number') {
|
|
f(node, value);
|
|
}
|
|
};
|
|
var setCursorAtEnd = function (input) {
|
|
setSelectionOn(input, function (node, value) {
|
|
return node.setSelectionRange(value.length, value.length);
|
|
});
|
|
};
|
|
var setSelectionToEnd = function (input, startOffset) {
|
|
setSelectionOn(input, function (node, value) {
|
|
return node.setSelectionRange(startOffset, value.length);
|
|
});
|
|
};
|
|
var attemptSelectOver = function (model, input, item) {
|
|
if (!model.selectsOver) {
|
|
return Optional.none();
|
|
} else {
|
|
var currentValue = Representing.getValue(input);
|
|
var inputDisplay_1 = model.getDisplayText(currentValue);
|
|
var itemValue = Representing.getValue(item);
|
|
var itemDisplay = model.getDisplayText(itemValue);
|
|
return itemDisplay.indexOf(inputDisplay_1) === 0 ? Optional.some(function () {
|
|
setValueFromItem(model, input, item);
|
|
setSelectionToEnd(input, inputDisplay_1.length);
|
|
}) : Optional.none();
|
|
}
|
|
};
|
|
|
|
var itemExecute = constant$1('alloy.typeahead.itemexecute');
|
|
|
|
var make$3 = function (detail, components, spec, externals) {
|
|
var navigateList = function (comp, simulatedEvent, highlighter) {
|
|
detail.previewing.set(false);
|
|
var sandbox = Coupling.getCoupled(comp, 'sandbox');
|
|
if (Sandboxing.isOpen(sandbox)) {
|
|
Composing.getCurrent(sandbox).each(function (menu) {
|
|
Highlighting.getHighlighted(menu).fold(function () {
|
|
highlighter(menu);
|
|
}, function () {
|
|
dispatchEvent(sandbox, menu.element, 'keydown', simulatedEvent);
|
|
});
|
|
});
|
|
} else {
|
|
var onOpenSync = function (sandbox) {
|
|
Composing.getCurrent(sandbox).each(highlighter);
|
|
};
|
|
open(detail, mapFetch(comp), comp, sandbox, externals, onOpenSync, HighlightOnOpen.HighlightFirst).get(noop);
|
|
}
|
|
};
|
|
var focusBehaviours$1 = focusBehaviours(detail);
|
|
var mapFetch = function (comp) {
|
|
return function (tdata) {
|
|
return tdata.map(function (data) {
|
|
var menus = values(data.menus);
|
|
var items = bind$3(menus, function (menu) {
|
|
return filter$2(menu.items, function (item) {
|
|
return item.type === 'item';
|
|
});
|
|
});
|
|
var repState = Representing.getState(comp);
|
|
repState.update(map$2(items, function (item) {
|
|
return item.data;
|
|
}));
|
|
return data;
|
|
});
|
|
};
|
|
};
|
|
var behaviours = [
|
|
Focusing.config({}),
|
|
Representing.config({
|
|
onSetValue: detail.onSetValue,
|
|
store: __assign({
|
|
mode: 'dataset',
|
|
getDataKey: function (comp) {
|
|
return get$5(comp.element);
|
|
},
|
|
getFallbackEntry: function (itemString) {
|
|
return {
|
|
value: itemString,
|
|
meta: {}
|
|
};
|
|
},
|
|
setValue: function (comp, data) {
|
|
set$4(comp.element, detail.model.getDisplayText(data));
|
|
}
|
|
}, detail.initialData.map(function (d) {
|
|
return wrap$1('initialValue', d);
|
|
}).getOr({}))
|
|
}),
|
|
Streaming.config({
|
|
stream: {
|
|
mode: 'throttle',
|
|
delay: detail.responseTime,
|
|
stopEvent: false
|
|
},
|
|
onStream: function (component, _simulatedEvent) {
|
|
var sandbox = Coupling.getCoupled(component, 'sandbox');
|
|
var focusInInput = Focusing.isFocused(component);
|
|
if (focusInInput) {
|
|
if (get$5(component.element).length >= detail.minChars) {
|
|
var previousValue_1 = Composing.getCurrent(sandbox).bind(function (menu) {
|
|
return Highlighting.getHighlighted(menu).map(Representing.getValue);
|
|
});
|
|
detail.previewing.set(true);
|
|
var onOpenSync = function (_sandbox) {
|
|
Composing.getCurrent(sandbox).each(function (menu) {
|
|
previousValue_1.fold(function () {
|
|
if (detail.model.selectsOver) {
|
|
Highlighting.highlightFirst(menu);
|
|
}
|
|
}, function (pv) {
|
|
Highlighting.highlightBy(menu, function (item) {
|
|
var itemData = Representing.getValue(item);
|
|
return itemData.value === pv.value;
|
|
});
|
|
Highlighting.getHighlighted(menu).orThunk(function () {
|
|
Highlighting.highlightFirst(menu);
|
|
return Optional.none();
|
|
});
|
|
});
|
|
});
|
|
};
|
|
open(detail, mapFetch(component), component, sandbox, externals, onOpenSync, HighlightOnOpen.HighlightFirst).get(noop);
|
|
}
|
|
}
|
|
},
|
|
cancelEvent: typeaheadCancel()
|
|
}),
|
|
Keying.config({
|
|
mode: 'special',
|
|
onDown: function (comp, simulatedEvent) {
|
|
navigateList(comp, simulatedEvent, Highlighting.highlightFirst);
|
|
return Optional.some(true);
|
|
},
|
|
onEscape: function (comp) {
|
|
var sandbox = Coupling.getCoupled(comp, 'sandbox');
|
|
if (Sandboxing.isOpen(sandbox)) {
|
|
Sandboxing.close(sandbox);
|
|
return Optional.some(true);
|
|
}
|
|
return Optional.none();
|
|
},
|
|
onUp: function (comp, simulatedEvent) {
|
|
navigateList(comp, simulatedEvent, Highlighting.highlightLast);
|
|
return Optional.some(true);
|
|
},
|
|
onEnter: function (comp) {
|
|
var sandbox = Coupling.getCoupled(comp, 'sandbox');
|
|
var sandboxIsOpen = Sandboxing.isOpen(sandbox);
|
|
if (sandboxIsOpen && !detail.previewing.get()) {
|
|
return Composing.getCurrent(sandbox).bind(function (menu) {
|
|
return Highlighting.getHighlighted(menu);
|
|
}).map(function (item) {
|
|
emitWith(comp, itemExecute(), { item: item });
|
|
return true;
|
|
});
|
|
} else {
|
|
var currentValue = Representing.getValue(comp);
|
|
emit(comp, typeaheadCancel());
|
|
detail.onExecute(sandbox, comp, currentValue);
|
|
if (sandboxIsOpen) {
|
|
Sandboxing.close(sandbox);
|
|
}
|
|
return Optional.some(true);
|
|
}
|
|
}
|
|
}),
|
|
Toggling.config({
|
|
toggleClass: detail.markers.openClass,
|
|
aria: { mode: 'expanded' }
|
|
}),
|
|
Coupling.config({
|
|
others: {
|
|
sandbox: function (hotspot) {
|
|
return makeSandbox$1(detail, hotspot, {
|
|
onOpen: function () {
|
|
return Toggling.on(hotspot);
|
|
},
|
|
onClose: function () {
|
|
return Toggling.off(hotspot);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}),
|
|
config('typeaheadevents', [
|
|
runOnExecute$1(function (comp) {
|
|
var onOpenSync = noop;
|
|
togglePopup(detail, mapFetch(comp), comp, externals, onOpenSync, HighlightOnOpen.HighlightFirst).get(noop);
|
|
}),
|
|
run$1(itemExecute(), function (comp, se) {
|
|
var sandbox = Coupling.getCoupled(comp, 'sandbox');
|
|
setValueFromItem(detail.model, comp, se.event.item);
|
|
emit(comp, typeaheadCancel());
|
|
detail.onItemExecute(comp, sandbox, se.event.item, Representing.getValue(comp));
|
|
Sandboxing.close(sandbox);
|
|
setCursorAtEnd(comp);
|
|
})
|
|
].concat(detail.dismissOnBlur ? [run$1(postBlur(), function (typeahead) {
|
|
var sandbox = Coupling.getCoupled(typeahead, 'sandbox');
|
|
if (search(sandbox.element).isNone()) {
|
|
Sandboxing.close(sandbox);
|
|
}
|
|
})] : []))
|
|
];
|
|
return {
|
|
uid: detail.uid,
|
|
dom: dom(deepMerge(detail, {
|
|
inputAttributes: {
|
|
'role': 'combobox',
|
|
'aria-autocomplete': 'list',
|
|
'aria-haspopup': 'true'
|
|
}
|
|
})),
|
|
behaviours: __assign(__assign({}, focusBehaviours$1), augment(detail.typeaheadBehaviours, behaviours)),
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
|
|
var schema$g = constant$1([
|
|
option('lazySink'),
|
|
required$1('fetch'),
|
|
defaulted('minChars', 5),
|
|
defaulted('responseTime', 1000),
|
|
onHandler('onOpen'),
|
|
defaulted('getHotspot', Optional.some),
|
|
defaulted('getAnchorOverrides', constant$1({})),
|
|
defaulted('layouts', Optional.none()),
|
|
defaulted('eventOrder', {}),
|
|
defaultedObjOf('model', {}, [
|
|
defaulted('getDisplayText', function (itemData) {
|
|
return itemData.meta !== undefined && itemData.meta.text !== undefined ? itemData.meta.text : itemData.value;
|
|
}),
|
|
defaulted('selectsOver', true),
|
|
defaulted('populateFromBrowse', true)
|
|
]),
|
|
onHandler('onSetValue'),
|
|
onKeyboardHandler('onExecute'),
|
|
onHandler('onItemExecute'),
|
|
defaulted('inputClasses', []),
|
|
defaulted('inputAttributes', {}),
|
|
defaulted('inputStyles', {}),
|
|
defaulted('matchWidth', true),
|
|
defaulted('useMinWidth', false),
|
|
defaulted('dismissOnBlur', true),
|
|
markers$1(['openClass']),
|
|
option('initialData'),
|
|
field('typeaheadBehaviours', [
|
|
Focusing,
|
|
Representing,
|
|
Streaming,
|
|
Keying,
|
|
Toggling,
|
|
Coupling
|
|
]),
|
|
customField('previewing', function () {
|
|
return Cell(true);
|
|
})
|
|
].concat(schema$k()).concat(sandboxFields()));
|
|
var parts$b = constant$1([external$1({
|
|
schema: [tieredMenuMarkers()],
|
|
name: 'menu',
|
|
overrides: function (detail) {
|
|
return {
|
|
fakeFocus: true,
|
|
onHighlight: function (menu, item) {
|
|
if (!detail.previewing.get()) {
|
|
menu.getSystem().getByUid(detail.uid).each(function (input) {
|
|
if (detail.model.populateFromBrowse) {
|
|
setValueFromItem(detail.model, input, item);
|
|
}
|
|
});
|
|
} else {
|
|
menu.getSystem().getByUid(detail.uid).each(function (input) {
|
|
attemptSelectOver(detail.model, input, item).fold(function () {
|
|
return Highlighting.dehighlight(menu, item);
|
|
}, function (fn) {
|
|
return fn();
|
|
});
|
|
});
|
|
}
|
|
detail.previewing.set(false);
|
|
},
|
|
onExecute: function (menu, item) {
|
|
return menu.getSystem().getByUid(detail.uid).toOptional().map(function (typeahead) {
|
|
emitWith(typeahead, itemExecute(), { item: item });
|
|
return true;
|
|
});
|
|
},
|
|
onHover: function (menu, item) {
|
|
detail.previewing.set(false);
|
|
menu.getSystem().getByUid(detail.uid).each(function (input) {
|
|
if (detail.model.populateFromBrowse) {
|
|
setValueFromItem(detail.model, input, item);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
})]);
|
|
|
|
var Typeahead = composite({
|
|
name: 'Typeahead',
|
|
configFields: schema$g(),
|
|
partFields: parts$b(),
|
|
factory: make$3
|
|
});
|
|
|
|
var wrap = function (delegate) {
|
|
var toCached = function () {
|
|
return wrap(delegate.toCached());
|
|
};
|
|
var bindFuture = function (f) {
|
|
return wrap(delegate.bind(function (resA) {
|
|
return resA.fold(function (err) {
|
|
return Future.pure(Result.error(err));
|
|
}, function (a) {
|
|
return f(a);
|
|
});
|
|
}));
|
|
};
|
|
var bindResult = function (f) {
|
|
return wrap(delegate.map(function (resA) {
|
|
return resA.bind(f);
|
|
}));
|
|
};
|
|
var mapResult = function (f) {
|
|
return wrap(delegate.map(function (resA) {
|
|
return resA.map(f);
|
|
}));
|
|
};
|
|
var mapError = function (f) {
|
|
return wrap(delegate.map(function (resA) {
|
|
return resA.mapError(f);
|
|
}));
|
|
};
|
|
var foldResult = function (whenError, whenValue) {
|
|
return delegate.map(function (res) {
|
|
return res.fold(whenError, whenValue);
|
|
});
|
|
};
|
|
var withTimeout = function (timeout, errorThunk) {
|
|
return wrap(Future.nu(function (callback) {
|
|
var timedOut = false;
|
|
var timer = setTimeout(function () {
|
|
timedOut = true;
|
|
callback(Result.error(errorThunk()));
|
|
}, timeout);
|
|
delegate.get(function (result) {
|
|
if (!timedOut) {
|
|
clearTimeout(timer);
|
|
callback(result);
|
|
}
|
|
});
|
|
}));
|
|
};
|
|
return __assign(__assign({}, delegate), {
|
|
toCached: toCached,
|
|
bindFuture: bindFuture,
|
|
bindResult: bindResult,
|
|
mapResult: mapResult,
|
|
mapError: mapError,
|
|
foldResult: foldResult,
|
|
withTimeout: withTimeout
|
|
});
|
|
};
|
|
var nu$1 = function (worker) {
|
|
return wrap(Future.nu(worker));
|
|
};
|
|
var value = function (value) {
|
|
return wrap(Future.pure(Result.value(value)));
|
|
};
|
|
var error = function (error) {
|
|
return wrap(Future.pure(Result.error(error)));
|
|
};
|
|
var fromResult = function (result) {
|
|
return wrap(Future.pure(result));
|
|
};
|
|
var fromFuture = function (future) {
|
|
return wrap(future.map(Result.value));
|
|
};
|
|
var fromPromise = function (promise) {
|
|
return nu$1(function (completer) {
|
|
promise.then(function (value) {
|
|
completer(Result.value(value));
|
|
}, function (error) {
|
|
completer(Result.error(error));
|
|
});
|
|
});
|
|
};
|
|
var FutureResult = {
|
|
nu: nu$1,
|
|
wrap: wrap,
|
|
pure: value,
|
|
value: value,
|
|
error: error,
|
|
fromResult: fromResult,
|
|
fromFuture: fromFuture,
|
|
fromPromise: fromPromise
|
|
};
|
|
|
|
var separator$1 = { type: 'separator' };
|
|
var toMenuItem = function (target) {
|
|
return {
|
|
type: 'menuitem',
|
|
value: target.url,
|
|
text: target.title,
|
|
meta: { attach: target.attach },
|
|
onAction: noop
|
|
};
|
|
};
|
|
var staticMenuItem = function (title, url) {
|
|
return {
|
|
type: 'menuitem',
|
|
value: url,
|
|
text: title,
|
|
meta: { attach: undefined },
|
|
onAction: noop
|
|
};
|
|
};
|
|
var toMenuItems = function (targets) {
|
|
return map$2(targets, toMenuItem);
|
|
};
|
|
var filterLinkTargets = function (type, targets) {
|
|
return filter$2(targets, function (target) {
|
|
return target.type === type;
|
|
});
|
|
};
|
|
var filteredTargets = function (type, targets) {
|
|
return toMenuItems(filterLinkTargets(type, targets));
|
|
};
|
|
var headerTargets = function (linkInfo) {
|
|
return filteredTargets('header', linkInfo.targets);
|
|
};
|
|
var anchorTargets = function (linkInfo) {
|
|
return filteredTargets('anchor', linkInfo.targets);
|
|
};
|
|
var anchorTargetTop = function (linkInfo) {
|
|
return Optional.from(linkInfo.anchorTop).map(function (url) {
|
|
return staticMenuItem('<top>', url);
|
|
}).toArray();
|
|
};
|
|
var anchorTargetBottom = function (linkInfo) {
|
|
return Optional.from(linkInfo.anchorBottom).map(function (url) {
|
|
return staticMenuItem('<bottom>', url);
|
|
}).toArray();
|
|
};
|
|
var historyTargets = function (history) {
|
|
return map$2(history, function (url) {
|
|
return staticMenuItem(url, url);
|
|
});
|
|
};
|
|
var joinMenuLists = function (items) {
|
|
return foldl(items, function (a, b) {
|
|
var bothEmpty = a.length === 0 || b.length === 0;
|
|
return bothEmpty ? a.concat(b) : a.concat(separator$1, b);
|
|
}, []);
|
|
};
|
|
var filterByQuery = function (term, menuItems) {
|
|
var lowerCaseTerm = term.toLowerCase();
|
|
return filter$2(menuItems, function (item) {
|
|
var text = item.meta !== undefined && item.meta.text !== undefined ? item.meta.text : item.text;
|
|
return contains$1(text.toLowerCase(), lowerCaseTerm) || contains$1(item.value.toLowerCase(), lowerCaseTerm);
|
|
});
|
|
};
|
|
|
|
var getItems = function (fileType, input, urlBackstage) {
|
|
var urlInputValue = Representing.getValue(input);
|
|
var term = urlInputValue.meta.text !== undefined ? urlInputValue.meta.text : urlInputValue.value;
|
|
var info = urlBackstage.getLinkInformation();
|
|
return info.fold(function () {
|
|
return [];
|
|
}, function (linkInfo) {
|
|
var history = filterByQuery(term, historyTargets(urlBackstage.getHistory(fileType)));
|
|
return fileType === 'file' ? joinMenuLists([
|
|
history,
|
|
filterByQuery(term, headerTargets(linkInfo)),
|
|
filterByQuery(term, flatten([
|
|
anchorTargetTop(linkInfo),
|
|
anchorTargets(linkInfo),
|
|
anchorTargetBottom(linkInfo)
|
|
]))
|
|
]) : history;
|
|
});
|
|
};
|
|
var errorId = generate$6('aria-invalid');
|
|
var renderUrlInput = function (spec, backstage, urlBackstage) {
|
|
var _a;
|
|
var providersBackstage = backstage.shared.providers;
|
|
var updateHistory = function (component) {
|
|
var urlEntry = Representing.getValue(component);
|
|
urlBackstage.addToHistory(urlEntry.value, spec.filetype);
|
|
};
|
|
var pField = FormField.parts.field({
|
|
factory: Typeahead,
|
|
dismissOnBlur: true,
|
|
inputClasses: ['tox-textfield'],
|
|
sandboxClasses: ['tox-dialog__popups'],
|
|
inputAttributes: {
|
|
'aria-errormessage': errorId,
|
|
'type': 'url'
|
|
},
|
|
minChars: 0,
|
|
responseTime: 0,
|
|
fetch: function (input) {
|
|
var items = getItems(spec.filetype, input, urlBackstage);
|
|
var tdata = build(items, ItemResponse$1.BUBBLE_TO_SANDBOX, backstage, false);
|
|
return Future.pure(tdata);
|
|
},
|
|
getHotspot: function (comp) {
|
|
return memUrlBox.getOpt(comp);
|
|
},
|
|
onSetValue: function (comp, _newValue) {
|
|
if (comp.hasConfigured(Invalidating)) {
|
|
Invalidating.run(comp).get(noop);
|
|
}
|
|
},
|
|
typeaheadBehaviours: derive$1(flatten([
|
|
urlBackstage.getValidationHandler().map(function (handler) {
|
|
return Invalidating.config({
|
|
getRoot: function (comp) {
|
|
return parent(comp.element);
|
|
},
|
|
invalidClass: 'tox-control-wrap--status-invalid',
|
|
notify: {
|
|
onInvalid: function (comp, err) {
|
|
memInvalidIcon.getOpt(comp).each(function (invalidComp) {
|
|
set$8(invalidComp.element, 'title', providersBackstage.translate(err));
|
|
});
|
|
}
|
|
},
|
|
validator: {
|
|
validate: function (input) {
|
|
var urlEntry = Representing.getValue(input);
|
|
return FutureResult.nu(function (completer) {
|
|
handler({
|
|
type: spec.filetype,
|
|
url: urlEntry.value
|
|
}, function (validation) {
|
|
if (validation.status === 'invalid') {
|
|
var err = Result.error(validation.message);
|
|
completer(err);
|
|
} else {
|
|
var val = Result.value(validation.message);
|
|
completer(val);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
validateOnLoad: false
|
|
}
|
|
});
|
|
}).toArray(),
|
|
[
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}
|
|
}),
|
|
Tabstopping.config({}),
|
|
config('urlinput-events', flatten([
|
|
spec.filetype === 'file' ? [run$1(input(), function (comp) {
|
|
emitWith(comp, formChangeEvent, { name: spec.name });
|
|
})] : [],
|
|
[
|
|
run$1(change(), function (comp) {
|
|
emitWith(comp, formChangeEvent, { name: spec.name });
|
|
updateHistory(comp);
|
|
}),
|
|
run$1(postPaste(), function (comp) {
|
|
emitWith(comp, formChangeEvent, { name: spec.name });
|
|
updateHistory(comp);
|
|
})
|
|
]
|
|
]))
|
|
]
|
|
])),
|
|
eventOrder: (_a = {}, _a[input()] = [
|
|
'streaming',
|
|
'urlinput-events',
|
|
'invalidating'
|
|
], _a),
|
|
model: {
|
|
getDisplayText: function (itemData) {
|
|
return itemData.value;
|
|
},
|
|
selectsOver: false,
|
|
populateFromBrowse: false
|
|
},
|
|
markers: { openClass: 'tox-textfield--popup-open' },
|
|
lazySink: backstage.shared.getSink,
|
|
parts: { menu: part(false, 1, 'normal') },
|
|
onExecute: function (_menu, component, _entry) {
|
|
emitWith(component, formSubmitEvent, {});
|
|
},
|
|
onItemExecute: function (typeahead, _sandbox, _item, _value) {
|
|
updateHistory(typeahead);
|
|
emitWith(typeahead, formChangeEvent, { name: spec.name });
|
|
}
|
|
});
|
|
var pLabel = spec.label.map(function (label) {
|
|
return renderLabel$2(label, providersBackstage);
|
|
});
|
|
var makeIcon = function (name, errId, icon, label) {
|
|
if (icon === void 0) {
|
|
icon = name;
|
|
}
|
|
if (label === void 0) {
|
|
label = name;
|
|
}
|
|
return render$3(icon, {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-icon',
|
|
'tox-control-wrap__status-icon-' + name
|
|
],
|
|
attributes: __assign({
|
|
'title': providersBackstage.translate(label),
|
|
'aria-live': 'polite'
|
|
}, errId.fold(function () {
|
|
return {};
|
|
}, function (id) {
|
|
return { id: id };
|
|
}))
|
|
}, providersBackstage.icons);
|
|
};
|
|
var memInvalidIcon = record(makeIcon('invalid', Optional.some(errorId), 'warning'));
|
|
var memStatus = record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-control-wrap__status-icon-wrap']
|
|
},
|
|
components: [memInvalidIcon.asSpec()]
|
|
});
|
|
var optUrlPicker = urlBackstage.getUrlPicker(spec.filetype);
|
|
var browseUrlEvent = generate$6('browser.url.event');
|
|
var memUrlBox = record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-control-wrap']
|
|
},
|
|
components: [
|
|
pField,
|
|
memStatus.asSpec()
|
|
],
|
|
behaviours: derive$1([Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}
|
|
})])
|
|
});
|
|
var memUrlPickerButton = record(renderButton({
|
|
name: spec.name,
|
|
icon: Optional.some('browse'),
|
|
text: spec.label.getOr(''),
|
|
disabled: spec.disabled,
|
|
primary: false,
|
|
borderless: true
|
|
}, function (component) {
|
|
return emit(component, browseUrlEvent);
|
|
}, providersBackstage, [], ['tox-browse-url']));
|
|
var controlHWrapper = function () {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__controls-h-stack']
|
|
},
|
|
components: flatten([
|
|
[memUrlBox.asSpec()],
|
|
optUrlPicker.map(function () {
|
|
return memUrlPickerButton.asSpec();
|
|
}).toArray()
|
|
])
|
|
};
|
|
};
|
|
var openUrlPicker = function (comp) {
|
|
Composing.getCurrent(comp).each(function (field) {
|
|
var componentData = Representing.getValue(field);
|
|
var urlData = __assign({ fieldname: spec.name }, componentData);
|
|
optUrlPicker.each(function (picker) {
|
|
picker(urlData).get(function (chosenData) {
|
|
Representing.setValue(field, chosenData);
|
|
emitWith(comp, formChangeEvent, { name: spec.name });
|
|
});
|
|
});
|
|
});
|
|
};
|
|
return FormField.sketch({
|
|
dom: renderFormFieldDom(),
|
|
components: pLabel.toArray().concat([controlHWrapper()]),
|
|
fieldBehaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
},
|
|
onDisabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.disable);
|
|
memUrlPickerButton.getOpt(comp).each(Disabling.disable);
|
|
},
|
|
onEnabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.enable);
|
|
memUrlPickerButton.getOpt(comp).each(Disabling.enable);
|
|
}
|
|
}),
|
|
receivingConfig(),
|
|
config('url-input-events', [run$1(browseUrlEvent, openUrlPicker)])
|
|
])
|
|
});
|
|
};
|
|
|
|
var renderAlertBanner = function (spec, providersBackstage) {
|
|
return Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { role: 'alert' },
|
|
classes: [
|
|
'tox-notification',
|
|
'tox-notification--in',
|
|
'tox-notification--' + spec.level
|
|
]
|
|
},
|
|
components: [
|
|
{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-notification__icon']
|
|
},
|
|
components: [Button.sketch({
|
|
dom: {
|
|
tag: 'button',
|
|
classes: [
|
|
'tox-button',
|
|
'tox-button--naked',
|
|
'tox-button--icon'
|
|
],
|
|
innerHtml: get$1(spec.icon, providersBackstage.icons),
|
|
attributes: { title: providersBackstage.translate(spec.iconTooltip) }
|
|
},
|
|
action: function (comp) {
|
|
emitWith(comp, formActionEvent, {
|
|
name: 'alert-banner',
|
|
value: spec.url
|
|
});
|
|
},
|
|
buttonBehaviours: derive$1([addFocusableBehaviour()])
|
|
})]
|
|
},
|
|
{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-notification__body'],
|
|
innerHtml: providersBackstage.translate(spec.text)
|
|
}
|
|
}
|
|
]
|
|
});
|
|
};
|
|
|
|
var renderCheckbox = function (spec, providerBackstage) {
|
|
var repBehaviour = Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (comp) {
|
|
var el = comp.element.dom;
|
|
return el.checked;
|
|
},
|
|
setValue: function (comp, value) {
|
|
var el = comp.element.dom;
|
|
el.checked = value;
|
|
}
|
|
}
|
|
});
|
|
var toggleCheckboxHandler = function (comp) {
|
|
comp.element.dom.click();
|
|
return Optional.some(true);
|
|
};
|
|
var pField = FormField.parts.field({
|
|
factory: { sketch: identity$1 },
|
|
dom: {
|
|
tag: 'input',
|
|
classes: ['tox-checkbox__input'],
|
|
attributes: { type: 'checkbox' }
|
|
},
|
|
behaviours: derive$1([
|
|
ComposingConfigs.self(),
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providerBackstage.isDisabled();
|
|
}
|
|
}),
|
|
Tabstopping.config({}),
|
|
Focusing.config({}),
|
|
repBehaviour,
|
|
Keying.config({
|
|
mode: 'special',
|
|
onEnter: toggleCheckboxHandler,
|
|
onSpace: toggleCheckboxHandler,
|
|
stopSpaceKeyup: true
|
|
}),
|
|
config('checkbox-events', [run$1(change(), function (component, _) {
|
|
emitWith(component, formChangeEvent, { name: spec.name });
|
|
})])
|
|
])
|
|
});
|
|
var pLabel = FormField.parts.label({
|
|
dom: {
|
|
tag: 'span',
|
|
classes: ['tox-checkbox__label'],
|
|
innerHtml: providerBackstage.translate(spec.label)
|
|
},
|
|
behaviours: derive$1([Unselecting.config({})])
|
|
});
|
|
var makeIcon = function (className) {
|
|
var iconName = className === 'checked' ? 'selected' : 'unselected';
|
|
return render$3(iconName, {
|
|
tag: 'span',
|
|
classes: [
|
|
'tox-icon',
|
|
'tox-checkbox-icon__' + className
|
|
]
|
|
}, providerBackstage.icons);
|
|
};
|
|
var memIcons = record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-checkbox__icons']
|
|
},
|
|
components: [
|
|
makeIcon('checked'),
|
|
makeIcon('unchecked')
|
|
]
|
|
});
|
|
return FormField.sketch({
|
|
dom: {
|
|
tag: 'label',
|
|
classes: ['tox-checkbox']
|
|
},
|
|
components: [
|
|
pField,
|
|
memIcons.asSpec(),
|
|
pLabel
|
|
],
|
|
fieldBehaviours: derive$1([
|
|
Disabling.config({
|
|
disabled: function () {
|
|
return spec.disabled || providerBackstage.isDisabled();
|
|
},
|
|
disableClass: 'tox-checkbox--disabled',
|
|
onDisabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.disable);
|
|
},
|
|
onEnabled: function (comp) {
|
|
FormField.getField(comp).each(Disabling.enable);
|
|
}
|
|
}),
|
|
receivingConfig()
|
|
])
|
|
});
|
|
};
|
|
|
|
var renderHtmlPanel = function (spec) {
|
|
if (spec.presets === 'presentation') {
|
|
return Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group'],
|
|
innerHtml: spec.html
|
|
}
|
|
});
|
|
} else {
|
|
return Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form__group'],
|
|
innerHtml: spec.html,
|
|
attributes: { role: 'document' }
|
|
},
|
|
containerBehaviours: derive$1([
|
|
Tabstopping.config({}),
|
|
Focusing.config({})
|
|
])
|
|
});
|
|
}
|
|
};
|
|
|
|
var make$2 = function (render) {
|
|
return function (parts, spec, backstage) {
|
|
return get$e(spec, 'name').fold(function () {
|
|
return render(spec, backstage);
|
|
}, function (fieldName) {
|
|
return parts.field(fieldName, render(spec, backstage));
|
|
});
|
|
};
|
|
};
|
|
var makeIframe = function (render) {
|
|
return function (parts, spec, backstage) {
|
|
var iframeSpec = deepMerge(spec, { source: 'dynamic' });
|
|
return make$2(render)(parts, iframeSpec, backstage);
|
|
};
|
|
};
|
|
var factories = {
|
|
bar: make$2(function (spec, backstage) {
|
|
return renderBar(spec, backstage.shared);
|
|
}),
|
|
collection: make$2(function (spec, backstage) {
|
|
return renderCollection(spec, backstage.shared.providers);
|
|
}),
|
|
alertbanner: make$2(function (spec, backstage) {
|
|
return renderAlertBanner(spec, backstage.shared.providers);
|
|
}),
|
|
input: make$2(function (spec, backstage) {
|
|
return renderInput(spec, backstage.shared.providers);
|
|
}),
|
|
textarea: make$2(function (spec, backstage) {
|
|
return renderTextarea(spec, backstage.shared.providers);
|
|
}),
|
|
label: make$2(function (spec, backstage) {
|
|
return renderLabel(spec, backstage.shared);
|
|
}),
|
|
iframe: makeIframe(function (spec, backstage) {
|
|
return renderIFrame(spec, backstage.shared.providers);
|
|
}),
|
|
button: make$2(function (spec, backstage) {
|
|
return renderDialogButton(spec, backstage.shared.providers);
|
|
}),
|
|
checkbox: make$2(function (spec, backstage) {
|
|
return renderCheckbox(spec, backstage.shared.providers);
|
|
}),
|
|
colorinput: make$2(function (spec, backstage) {
|
|
return renderColorInput(spec, backstage.shared, backstage.colorinput);
|
|
}),
|
|
colorpicker: make$2(renderColorPicker),
|
|
dropzone: make$2(function (spec, backstage) {
|
|
return renderDropZone(spec, backstage.shared.providers);
|
|
}),
|
|
grid: make$2(function (spec, backstage) {
|
|
return renderGrid(spec, backstage.shared);
|
|
}),
|
|
listbox: make$2(function (spec, backstage) {
|
|
return renderListBox(spec, backstage);
|
|
}),
|
|
selectbox: make$2(function (spec, backstage) {
|
|
return renderSelectBox(spec, backstage.shared.providers);
|
|
}),
|
|
sizeinput: make$2(function (spec, backstage) {
|
|
return renderSizeInput(spec, backstage.shared.providers);
|
|
}),
|
|
urlinput: make$2(function (spec, backstage) {
|
|
return renderUrlInput(spec, backstage, backstage.urlinput);
|
|
}),
|
|
customeditor: make$2(renderCustomEditor),
|
|
htmlpanel: make$2(renderHtmlPanel),
|
|
imagetools: make$2(function (spec, backstage) {
|
|
return renderImageTools(spec, backstage.shared.providers);
|
|
}),
|
|
table: make$2(function (spec, backstage) {
|
|
return renderTable(spec, backstage.shared.providers);
|
|
}),
|
|
panel: make$2(function (spec, backstage) {
|
|
return renderPanel(spec, backstage);
|
|
})
|
|
};
|
|
var noFormParts = {
|
|
field: function (_name, spec) {
|
|
return spec;
|
|
}
|
|
};
|
|
var interpretInForm = function (parts, spec, oldBackstage) {
|
|
var newBackstage = deepMerge(oldBackstage, {
|
|
shared: {
|
|
interpreter: function (childSpec) {
|
|
return interpretParts(parts, childSpec, newBackstage);
|
|
}
|
|
}
|
|
});
|
|
return interpretParts(parts, spec, newBackstage);
|
|
};
|
|
var interpretParts = function (parts, spec, backstage) {
|
|
return get$e(factories, spec.type).fold(function () {
|
|
console.error('Unknown factory type "' + spec.type + '", defaulting to container: ', spec);
|
|
return spec;
|
|
}, function (factory) {
|
|
return factory(parts, spec, backstage);
|
|
});
|
|
};
|
|
var interpretWithoutForm = function (spec, backstage) {
|
|
var parts = noFormParts;
|
|
return interpretParts(parts, spec, backstage);
|
|
};
|
|
|
|
var bubbleAlignments$2 = {
|
|
valignCentre: [],
|
|
alignCentre: [],
|
|
alignLeft: [],
|
|
alignRight: [],
|
|
right: [],
|
|
left: [],
|
|
bottom: [],
|
|
top: []
|
|
};
|
|
var getInlineDialogAnchor = function (contentAreaElement, lazyAnchorbar, lazyUseEditableAreaAnchor) {
|
|
var bubbleSize = 12;
|
|
var overrides = { maxHeightFunction: expandable$1() };
|
|
var editableAreaAnchor = function () {
|
|
return {
|
|
type: 'node',
|
|
root: getContentContainer(contentAreaElement()),
|
|
node: Optional.from(contentAreaElement()),
|
|
bubble: nu$5(bubbleSize, bubbleSize, bubbleAlignments$2),
|
|
layouts: {
|
|
onRtl: function () {
|
|
return [northeast];
|
|
},
|
|
onLtr: function () {
|
|
return [northwest];
|
|
}
|
|
},
|
|
overrides: overrides
|
|
};
|
|
};
|
|
var standardAnchor = function () {
|
|
return {
|
|
type: 'hotspot',
|
|
hotspot: lazyAnchorbar(),
|
|
bubble: nu$5(-bubbleSize, bubbleSize, bubbleAlignments$2),
|
|
layouts: {
|
|
onRtl: function () {
|
|
return [southeast$2];
|
|
},
|
|
onLtr: function () {
|
|
return [southwest$2];
|
|
}
|
|
},
|
|
overrides: overrides
|
|
};
|
|
};
|
|
return function () {
|
|
return lazyUseEditableAreaAnchor() ? editableAreaAnchor() : standardAnchor();
|
|
};
|
|
};
|
|
var getBannerAnchor = function (contentAreaElement, lazyAnchorbar, lazyUseEditableAreaAnchor) {
|
|
var editableAreaAnchor = function () {
|
|
return {
|
|
type: 'node',
|
|
root: getContentContainer(contentAreaElement()),
|
|
node: Optional.from(contentAreaElement()),
|
|
layouts: {
|
|
onRtl: function () {
|
|
return [north];
|
|
},
|
|
onLtr: function () {
|
|
return [north];
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var standardAnchor = function () {
|
|
return {
|
|
type: 'hotspot',
|
|
hotspot: lazyAnchorbar(),
|
|
layouts: {
|
|
onRtl: function () {
|
|
return [south$2];
|
|
},
|
|
onLtr: function () {
|
|
return [south$2];
|
|
}
|
|
}
|
|
};
|
|
};
|
|
return function () {
|
|
return lazyUseEditableAreaAnchor() ? editableAreaAnchor() : standardAnchor();
|
|
};
|
|
};
|
|
var getCursorAnchor = function (editor, bodyElement) {
|
|
return function () {
|
|
return {
|
|
type: 'selection',
|
|
root: bodyElement(),
|
|
getSelection: function () {
|
|
var rng = editor.selection.getRng();
|
|
return Optional.some(SimSelection.range(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset));
|
|
}
|
|
};
|
|
};
|
|
};
|
|
var getNodeAnchor$1 = function (bodyElement) {
|
|
return function (element) {
|
|
return {
|
|
type: 'node',
|
|
root: bodyElement(),
|
|
node: element
|
|
};
|
|
};
|
|
};
|
|
var getAnchors = function (editor, lazyAnchorbar, isToolbarTop) {
|
|
var useFixedToolbarContainer = useFixedContainer(editor);
|
|
var bodyElement = function () {
|
|
return SugarElement.fromDom(editor.getBody());
|
|
};
|
|
var contentAreaElement = function () {
|
|
return SugarElement.fromDom(editor.getContentAreaContainer());
|
|
};
|
|
var lazyUseEditableAreaAnchor = function () {
|
|
return useFixedToolbarContainer || !isToolbarTop();
|
|
};
|
|
return {
|
|
inlineDialog: getInlineDialogAnchor(contentAreaElement, lazyAnchorbar, lazyUseEditableAreaAnchor),
|
|
banner: getBannerAnchor(contentAreaElement, lazyAnchorbar, lazyUseEditableAreaAnchor),
|
|
cursor: getCursorAnchor(editor, bodyElement),
|
|
node: getNodeAnchor$1(bodyElement)
|
|
};
|
|
};
|
|
|
|
var colorPicker = function (editor) {
|
|
return function (callback, value) {
|
|
var dialog = colorPickerDialog(editor);
|
|
dialog(callback, value);
|
|
};
|
|
};
|
|
var hasCustomColors = function (editor) {
|
|
return function () {
|
|
return hasCustomColors$1(editor);
|
|
};
|
|
};
|
|
var getColors = function (editor) {
|
|
return function () {
|
|
return getColors$2(editor);
|
|
};
|
|
};
|
|
var getColorCols = function (editor) {
|
|
return function () {
|
|
return getColorCols$1(editor);
|
|
};
|
|
};
|
|
var ColorInputBackstage = function (editor) {
|
|
return {
|
|
colorPicker: colorPicker(editor),
|
|
hasCustomColors: hasCustomColors(editor),
|
|
getColors: getColors(editor),
|
|
getColorCols: getColorCols(editor)
|
|
};
|
|
};
|
|
|
|
var isDraggableModal = function (editor) {
|
|
return function () {
|
|
return isDraggableModal$1(editor);
|
|
};
|
|
};
|
|
var DialogBackstage = function (editor) {
|
|
return { isDraggableModal: isDraggableModal(editor) };
|
|
};
|
|
|
|
var HeaderBackstage = function (editor) {
|
|
var mode = Cell(isToolbarLocationBottom(editor) ? 'bottom' : 'top');
|
|
return {
|
|
isPositionedAtTop: function () {
|
|
return mode.get() === 'top';
|
|
},
|
|
getDockingMode: mode.get,
|
|
setDockingMode: mode.set
|
|
};
|
|
};
|
|
|
|
var defaultStyleFormats = [
|
|
{
|
|
title: 'Headings',
|
|
items: [
|
|
{
|
|
title: 'Heading 1',
|
|
format: 'h1'
|
|
},
|
|
{
|
|
title: 'Heading 2',
|
|
format: 'h2'
|
|
},
|
|
{
|
|
title: 'Heading 3',
|
|
format: 'h3'
|
|
},
|
|
{
|
|
title: 'Heading 4',
|
|
format: 'h4'
|
|
},
|
|
{
|
|
title: 'Heading 5',
|
|
format: 'h5'
|
|
},
|
|
{
|
|
title: 'Heading 6',
|
|
format: 'h6'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
title: 'Inline',
|
|
items: [
|
|
{
|
|
title: 'Bold',
|
|
format: 'bold'
|
|
},
|
|
{
|
|
title: 'Italic',
|
|
format: 'italic'
|
|
},
|
|
{
|
|
title: 'Underline',
|
|
format: 'underline'
|
|
},
|
|
{
|
|
title: 'Strikethrough',
|
|
format: 'strikethrough'
|
|
},
|
|
{
|
|
title: 'Superscript',
|
|
format: 'superscript'
|
|
},
|
|
{
|
|
title: 'Subscript',
|
|
format: 'subscript'
|
|
},
|
|
{
|
|
title: 'Code',
|
|
format: 'code'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
title: 'Blocks',
|
|
items: [
|
|
{
|
|
title: 'Paragraph',
|
|
format: 'p'
|
|
},
|
|
{
|
|
title: 'Blockquote',
|
|
format: 'blockquote'
|
|
},
|
|
{
|
|
title: 'Div',
|
|
format: 'div'
|
|
},
|
|
{
|
|
title: 'Pre',
|
|
format: 'pre'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
title: 'Align',
|
|
items: [
|
|
{
|
|
title: 'Left',
|
|
format: 'alignleft'
|
|
},
|
|
{
|
|
title: 'Center',
|
|
format: 'aligncenter'
|
|
},
|
|
{
|
|
title: 'Right',
|
|
format: 'alignright'
|
|
},
|
|
{
|
|
title: 'Justify',
|
|
format: 'alignjustify'
|
|
}
|
|
]
|
|
}
|
|
];
|
|
var isNestedFormat = function (format) {
|
|
return has$2(format, 'items');
|
|
};
|
|
var isBlockFormat = function (format) {
|
|
return has$2(format, 'block');
|
|
};
|
|
var isInlineFormat = function (format) {
|
|
return has$2(format, 'inline');
|
|
};
|
|
var isSelectorFormat = function (format) {
|
|
return has$2(format, 'selector');
|
|
};
|
|
var mapFormats = function (userFormats) {
|
|
return foldl(userFormats, function (acc, fmt) {
|
|
if (isNestedFormat(fmt)) {
|
|
var result = mapFormats(fmt.items);
|
|
return {
|
|
customFormats: acc.customFormats.concat(result.customFormats),
|
|
formats: acc.formats.concat([{
|
|
title: fmt.title,
|
|
items: result.formats
|
|
}])
|
|
};
|
|
} else if (isInlineFormat(fmt) || isBlockFormat(fmt) || isSelectorFormat(fmt)) {
|
|
var formatName = isString(fmt.name) ? fmt.name : fmt.title.toLowerCase();
|
|
var formatNameWithPrefix = 'custom-' + formatName;
|
|
return {
|
|
customFormats: acc.customFormats.concat([{
|
|
name: formatNameWithPrefix,
|
|
format: fmt
|
|
}]),
|
|
formats: acc.formats.concat([{
|
|
title: fmt.title,
|
|
format: formatNameWithPrefix,
|
|
icon: fmt.icon
|
|
}])
|
|
};
|
|
} else {
|
|
return __assign(__assign({}, acc), { formats: acc.formats.concat(fmt) });
|
|
}
|
|
}, {
|
|
customFormats: [],
|
|
formats: []
|
|
});
|
|
};
|
|
var registerCustomFormats = function (editor, userFormats) {
|
|
var result = mapFormats(userFormats);
|
|
var registerFormats = function (customFormats) {
|
|
each$1(customFormats, function (fmt) {
|
|
if (!editor.formatter.has(fmt.name)) {
|
|
editor.formatter.register(fmt.name, fmt.format);
|
|
}
|
|
});
|
|
};
|
|
if (editor.formatter) {
|
|
registerFormats(result.customFormats);
|
|
} else {
|
|
editor.on('init', function () {
|
|
registerFormats(result.customFormats);
|
|
});
|
|
}
|
|
return result.formats;
|
|
};
|
|
var getStyleFormats = function (editor) {
|
|
return getUserStyleFormats(editor).map(function (userFormats) {
|
|
var registeredUserFormats = registerCustomFormats(editor, userFormats);
|
|
return isMergeStyleFormats(editor) ? defaultStyleFormats.concat(registeredUserFormats) : registeredUserFormats;
|
|
}).getOr(defaultStyleFormats);
|
|
};
|
|
|
|
var processBasic = function (item, isSelectedFor, getPreviewFor) {
|
|
var formatterSpec = {
|
|
type: 'formatter',
|
|
isSelected: isSelectedFor(item.format),
|
|
getStylePreview: getPreviewFor(item.format)
|
|
};
|
|
return deepMerge(item, formatterSpec);
|
|
};
|
|
var register$8 = function (editor, formats, isSelectedFor, getPreviewFor) {
|
|
var enrichSupported = function (item) {
|
|
return processBasic(item, isSelectedFor, getPreviewFor);
|
|
};
|
|
var enrichMenu = function (item) {
|
|
var submenuSpec = { type: 'submenu' };
|
|
return deepMerge(item, submenuSpec);
|
|
};
|
|
var enrichCustom = function (item) {
|
|
var formatName = isString(item.name) ? item.name : generate$6(item.title);
|
|
var formatNameWithPrefix = 'custom-' + formatName;
|
|
var customSpec = {
|
|
type: 'formatter',
|
|
format: formatNameWithPrefix,
|
|
isSelected: isSelectedFor(formatNameWithPrefix),
|
|
getStylePreview: getPreviewFor(formatNameWithPrefix)
|
|
};
|
|
var newItem = deepMerge(item, customSpec);
|
|
editor.formatter.register(formatName, newItem);
|
|
return newItem;
|
|
};
|
|
var doEnrich = function (items) {
|
|
return map$2(items, function (item) {
|
|
var keys$1 = keys(item);
|
|
if (hasNonNullableKey(item, 'items')) {
|
|
var newItems = doEnrich(item.items);
|
|
return deepMerge(enrichMenu(item), { getStyleItems: constant$1(newItems) });
|
|
} else if (hasNonNullableKey(item, 'format')) {
|
|
return enrichSupported(item);
|
|
} else if (keys$1.length === 1 && contains$2(keys$1, 'title')) {
|
|
return deepMerge(item, { type: 'separator' });
|
|
} else {
|
|
return enrichCustom(item);
|
|
}
|
|
});
|
|
};
|
|
return doEnrich(formats);
|
|
};
|
|
|
|
var init$8 = function (editor) {
|
|
var isSelectedFor = function (format) {
|
|
return function () {
|
|
return editor.formatter.match(format);
|
|
};
|
|
};
|
|
var getPreviewFor = function (format) {
|
|
return function () {
|
|
var fmt = editor.formatter.get(format);
|
|
return fmt !== undefined ? Optional.some({
|
|
tag: fmt.length > 0 ? fmt[0].inline || fmt[0].block || 'div' : 'div',
|
|
styles: editor.dom.parseStyle(editor.formatter.getCssText(format))
|
|
}) : Optional.none();
|
|
};
|
|
};
|
|
var flatten = function (fmt) {
|
|
var subs = fmt.items;
|
|
return subs !== undefined && subs.length > 0 ? bind$3(subs, flatten) : [fmt.format];
|
|
};
|
|
var settingsFormats = Cell([]);
|
|
var settingsFlattenedFormats = Cell([]);
|
|
var eventsFormats = Cell([]);
|
|
var eventsFlattenedFormats = Cell([]);
|
|
var replaceSettings = Cell(false);
|
|
editor.on('PreInit', function (_e) {
|
|
var formats = getStyleFormats(editor);
|
|
var enriched = register$8(editor, formats, isSelectedFor, getPreviewFor);
|
|
settingsFormats.set(enriched);
|
|
settingsFlattenedFormats.set(bind$3(enriched, flatten));
|
|
});
|
|
editor.on('addStyleModifications', function (e) {
|
|
var modifications = register$8(editor, e.items, isSelectedFor, getPreviewFor);
|
|
eventsFormats.set(modifications);
|
|
replaceSettings.set(e.replace);
|
|
eventsFlattenedFormats.set(bind$3(modifications, flatten));
|
|
});
|
|
var getData = function () {
|
|
var fromSettings = replaceSettings.get() ? [] : settingsFormats.get();
|
|
var fromEvents = eventsFormats.get();
|
|
return fromSettings.concat(fromEvents);
|
|
};
|
|
var getFlattenedKeys = function () {
|
|
var fromSettings = replaceSettings.get() ? [] : settingsFlattenedFormats.get();
|
|
var fromEvents = eventsFlattenedFormats.get();
|
|
return fromSettings.concat(fromEvents);
|
|
};
|
|
return {
|
|
getData: getData,
|
|
getFlattenedKeys: getFlattenedKeys
|
|
};
|
|
};
|
|
|
|
var isElement = function (node) {
|
|
return isNonNullable(node) && node.nodeType === 1;
|
|
};
|
|
var trim = global$5.trim;
|
|
var hasContentEditableState = function (value) {
|
|
return function (node) {
|
|
if (isElement(node)) {
|
|
if (node.contentEditable === value) {
|
|
return true;
|
|
}
|
|
if (node.getAttribute('data-mce-contenteditable') === value) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
};
|
|
var isContentEditableTrue = hasContentEditableState('true');
|
|
var isContentEditableFalse = hasContentEditableState('false');
|
|
var create = function (type, title, url, level, attach) {
|
|
return {
|
|
type: type,
|
|
title: title,
|
|
url: url,
|
|
level: level,
|
|
attach: attach
|
|
};
|
|
};
|
|
var isChildOfContentEditableTrue = function (node) {
|
|
while (node = node.parentNode) {
|
|
var value = node.contentEditable;
|
|
if (value && value !== 'inherit') {
|
|
return isContentEditableTrue(node);
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var select = function (selector, root) {
|
|
return map$2(descendants(SugarElement.fromDom(root), selector), function (element) {
|
|
return element.dom;
|
|
});
|
|
};
|
|
var getElementText = function (elm) {
|
|
return elm.innerText || elm.textContent;
|
|
};
|
|
var getOrGenerateId = function (elm) {
|
|
return elm.id ? elm.id : generate$6('h');
|
|
};
|
|
var isAnchor = function (elm) {
|
|
return elm && elm.nodeName === 'A' && (elm.id || elm.name) !== undefined;
|
|
};
|
|
var isValidAnchor = function (elm) {
|
|
return isAnchor(elm) && isEditable(elm);
|
|
};
|
|
var isHeader = function (elm) {
|
|
return elm && /^(H[1-6])$/.test(elm.nodeName);
|
|
};
|
|
var isEditable = function (elm) {
|
|
return isChildOfContentEditableTrue(elm) && !isContentEditableFalse(elm);
|
|
};
|
|
var isValidHeader = function (elm) {
|
|
return isHeader(elm) && isEditable(elm);
|
|
};
|
|
var getLevel = function (elm) {
|
|
return isHeader(elm) ? parseInt(elm.nodeName.substr(1), 10) : 0;
|
|
};
|
|
var headerTarget = function (elm) {
|
|
var headerId = getOrGenerateId(elm);
|
|
var attach = function () {
|
|
elm.id = headerId;
|
|
};
|
|
return create('header', getElementText(elm), '#' + headerId, getLevel(elm), attach);
|
|
};
|
|
var anchorTarget = function (elm) {
|
|
var anchorId = elm.id || elm.name;
|
|
var anchorText = getElementText(elm);
|
|
return create('anchor', anchorText ? anchorText : '#' + anchorId, '#' + anchorId, 0, noop);
|
|
};
|
|
var getHeaderTargets = function (elms) {
|
|
return map$2(filter$2(elms, isValidHeader), headerTarget);
|
|
};
|
|
var getAnchorTargets = function (elms) {
|
|
return map$2(filter$2(elms, isValidAnchor), anchorTarget);
|
|
};
|
|
var getTargetElements = function (elm) {
|
|
var elms = select('h1,h2,h3,h4,h5,h6,a:not([href])', elm);
|
|
return elms;
|
|
};
|
|
var hasTitle = function (target) {
|
|
return trim(target.title).length > 0;
|
|
};
|
|
var find = function (elm) {
|
|
var elms = getTargetElements(elm);
|
|
return filter$2(getHeaderTargets(elms).concat(getAnchorTargets(elms)), hasTitle);
|
|
};
|
|
var LinkTargets = { find: find };
|
|
|
|
var STORAGE_KEY = 'tinymce-url-history';
|
|
var HISTORY_LENGTH = 5;
|
|
var isHttpUrl = function (url) {
|
|
return isString(url) && /^https?/.test(url);
|
|
};
|
|
var isArrayOfUrl = function (a) {
|
|
return isArray(a) && a.length <= HISTORY_LENGTH && forall(a, isHttpUrl);
|
|
};
|
|
var isRecordOfUrlArray = function (r) {
|
|
return isObject(r) && find$4(r, function (value) {
|
|
return !isArrayOfUrl(value);
|
|
}).isNone();
|
|
};
|
|
var getAllHistory = function () {
|
|
var unparsedHistory = global$8.getItem(STORAGE_KEY);
|
|
if (unparsedHistory === null) {
|
|
return {};
|
|
}
|
|
var history;
|
|
try {
|
|
history = JSON.parse(unparsedHistory);
|
|
} catch (e) {
|
|
if (e instanceof SyntaxError) {
|
|
console.log('Local storage ' + STORAGE_KEY + ' was not valid JSON', e);
|
|
return {};
|
|
}
|
|
throw e;
|
|
}
|
|
if (!isRecordOfUrlArray(history)) {
|
|
console.log('Local storage ' + STORAGE_KEY + ' was not valid format', history);
|
|
return {};
|
|
}
|
|
return history;
|
|
};
|
|
var setAllHistory = function (history) {
|
|
if (!isRecordOfUrlArray(history)) {
|
|
throw new Error('Bad format for history:\n' + JSON.stringify(history));
|
|
}
|
|
global$8.setItem(STORAGE_KEY, JSON.stringify(history));
|
|
};
|
|
var getHistory = function (fileType) {
|
|
var history = getAllHistory();
|
|
return get$e(history, fileType).getOr([]);
|
|
};
|
|
var addToHistory = function (url, fileType) {
|
|
if (!isHttpUrl(url)) {
|
|
return;
|
|
}
|
|
var history = getAllHistory();
|
|
var items = get$e(history, fileType).getOr([]);
|
|
var itemsWithoutUrl = filter$2(items, function (item) {
|
|
return item !== url;
|
|
});
|
|
history[fileType] = [url].concat(itemsWithoutUrl).slice(0, HISTORY_LENGTH);
|
|
setAllHistory(history);
|
|
};
|
|
|
|
var isTruthy = function (value) {
|
|
return !!value;
|
|
};
|
|
var makeMap = function (value) {
|
|
return map$1(global$5.makeMap(value, /[, ]/), isTruthy);
|
|
};
|
|
var getPicker = function (editor) {
|
|
return Optional.from(getFilePickerCallback(editor)).filter(isFunction);
|
|
};
|
|
var getPickerTypes = function (editor) {
|
|
var optFileTypes = Optional.some(getFilePickerTypes(editor)).filter(isTruthy);
|
|
var optLegacyTypes = Optional.some(getFileBrowserCallbackTypes(editor)).filter(isTruthy);
|
|
var optTypes = optFileTypes.or(optLegacyTypes).map(makeMap);
|
|
return getPicker(editor).fold(never, function (_picker) {
|
|
return optTypes.fold(always, function (types) {
|
|
return keys(types).length > 0 ? types : false;
|
|
});
|
|
});
|
|
};
|
|
var getPickerSetting = function (editor, filetype) {
|
|
var pickerTypes = getPickerTypes(editor);
|
|
if (isBoolean(pickerTypes)) {
|
|
return pickerTypes ? getPicker(editor) : Optional.none();
|
|
} else {
|
|
return pickerTypes[filetype] ? getPicker(editor) : Optional.none();
|
|
}
|
|
};
|
|
var getUrlPicker = function (editor, filetype) {
|
|
return getPickerSetting(editor, filetype).map(function (picker) {
|
|
return function (entry) {
|
|
return Future.nu(function (completer) {
|
|
var handler = function (value, meta) {
|
|
if (!isString(value)) {
|
|
throw new Error('Expected value to be string');
|
|
}
|
|
if (meta !== undefined && !isObject(meta)) {
|
|
throw new Error('Expected meta to be a object');
|
|
}
|
|
var r = {
|
|
value: value,
|
|
meta: meta
|
|
};
|
|
completer(r);
|
|
};
|
|
var meta = __assign({
|
|
filetype: filetype,
|
|
fieldname: entry.fieldname
|
|
}, Optional.from(entry.meta).getOr({}));
|
|
picker.call(editor, handler, entry.value, meta);
|
|
});
|
|
};
|
|
});
|
|
};
|
|
var getTextSetting = function (value) {
|
|
return Optional.from(value).filter(isString).getOrUndefined();
|
|
};
|
|
var getLinkInformation = function (editor) {
|
|
if (noTypeaheadUrls(editor)) {
|
|
return Optional.none();
|
|
}
|
|
return Optional.some({
|
|
targets: LinkTargets.find(editor.getBody()),
|
|
anchorTop: getTextSetting(getAnchorTop(editor)),
|
|
anchorBottom: getTextSetting(getAnchorBottom(editor))
|
|
});
|
|
};
|
|
var getValidationHandler = function (editor) {
|
|
return Optional.from(getFilePickerValidatorHandler(editor));
|
|
};
|
|
var UrlInputBackstage = function (editor) {
|
|
return {
|
|
getHistory: getHistory,
|
|
addToHistory: addToHistory,
|
|
getLinkInformation: function () {
|
|
return getLinkInformation(editor);
|
|
},
|
|
getValidationHandler: function () {
|
|
return getValidationHandler(editor);
|
|
},
|
|
getUrlPicker: function (filetype) {
|
|
return getUrlPicker(editor, filetype);
|
|
}
|
|
};
|
|
};
|
|
|
|
var init$7 = function (sink, editor, lazyAnchorbar) {
|
|
var contextMenuState = Cell(false);
|
|
var toolbar = HeaderBackstage(editor);
|
|
var backstage = {
|
|
shared: {
|
|
providers: {
|
|
icons: function () {
|
|
return editor.ui.registry.getAll().icons;
|
|
},
|
|
menuItems: function () {
|
|
return editor.ui.registry.getAll().menuItems;
|
|
},
|
|
translate: global$e.translate,
|
|
isDisabled: function () {
|
|
return editor.mode.isReadOnly() || editor.ui.isDisabled();
|
|
},
|
|
getSetting: editor.getParam.bind(editor)
|
|
},
|
|
interpreter: function (s) {
|
|
return interpretWithoutForm(s, backstage);
|
|
},
|
|
anchors: getAnchors(editor, lazyAnchorbar, toolbar.isPositionedAtTop),
|
|
header: toolbar,
|
|
getSink: function () {
|
|
return Result.value(sink);
|
|
}
|
|
},
|
|
urlinput: UrlInputBackstage(editor),
|
|
styleselect: init$8(editor),
|
|
colorinput: ColorInputBackstage(editor),
|
|
dialog: DialogBackstage(editor),
|
|
isContextMenuOpen: function () {
|
|
return contextMenuState.get();
|
|
},
|
|
setContextMenuState: function (state) {
|
|
return contextMenuState.set(state);
|
|
}
|
|
};
|
|
return backstage;
|
|
};
|
|
|
|
var setup$b = function (editor, mothership, uiMothership) {
|
|
var broadcastEvent = function (name, evt) {
|
|
each$1([
|
|
mothership,
|
|
uiMothership
|
|
], function (ship) {
|
|
ship.broadcastEvent(name, evt);
|
|
});
|
|
};
|
|
var broadcastOn = function (channel, message) {
|
|
each$1([
|
|
mothership,
|
|
uiMothership
|
|
], function (ship) {
|
|
ship.broadcastOn([channel], message);
|
|
});
|
|
};
|
|
var fireDismissPopups = function (evt) {
|
|
return broadcastOn(dismissPopups(), { target: evt.target });
|
|
};
|
|
var doc = getDocument();
|
|
var onTouchstart = bind(doc, 'touchstart', fireDismissPopups);
|
|
var onTouchmove = bind(doc, 'touchmove', function (evt) {
|
|
return broadcastEvent(documentTouchmove(), evt);
|
|
});
|
|
var onTouchend = bind(doc, 'touchend', function (evt) {
|
|
return broadcastEvent(documentTouchend(), evt);
|
|
});
|
|
var onMousedown = bind(doc, 'mousedown', fireDismissPopups);
|
|
var onMouseup = bind(doc, 'mouseup', function (evt) {
|
|
if (evt.raw.button === 0) {
|
|
broadcastOn(mouseReleased(), { target: evt.target });
|
|
}
|
|
});
|
|
var onContentClick = function (raw) {
|
|
return broadcastOn(dismissPopups(), { target: SugarElement.fromDom(raw.target) });
|
|
};
|
|
var onContentMouseup = function (raw) {
|
|
if (raw.button === 0) {
|
|
broadcastOn(mouseReleased(), { target: SugarElement.fromDom(raw.target) });
|
|
}
|
|
};
|
|
var onContentMousedown = function () {
|
|
each$1(editor.editorManager.get(), function (loopEditor) {
|
|
if (editor !== loopEditor) {
|
|
loopEditor.fire('DismissPopups', { relatedTarget: editor });
|
|
}
|
|
});
|
|
};
|
|
var onWindowScroll = function (evt) {
|
|
return broadcastEvent(windowScroll(), fromRawEvent(evt));
|
|
};
|
|
var onWindowResize = function (evt) {
|
|
broadcastOn(repositionPopups(), {});
|
|
broadcastEvent(windowResize(), fromRawEvent(evt));
|
|
};
|
|
var onEditorResize = function () {
|
|
return broadcastOn(repositionPopups(), {});
|
|
};
|
|
var onEditorProgress = function (evt) {
|
|
if (evt.state) {
|
|
broadcastOn(dismissPopups(), { target: SugarElement.fromDom(editor.getContainer()) });
|
|
}
|
|
};
|
|
var onDismissPopups = function (event) {
|
|
broadcastOn(dismissPopups(), { target: SugarElement.fromDom(event.relatedTarget.getContainer()) });
|
|
};
|
|
editor.on('PostRender', function () {
|
|
editor.on('click', onContentClick);
|
|
editor.on('tap', onContentClick);
|
|
editor.on('mouseup', onContentMouseup);
|
|
editor.on('mousedown', onContentMousedown);
|
|
editor.on('ScrollWindow', onWindowScroll);
|
|
editor.on('ResizeWindow', onWindowResize);
|
|
editor.on('ResizeEditor', onEditorResize);
|
|
editor.on('AfterProgressState', onEditorProgress);
|
|
editor.on('DismissPopups', onDismissPopups);
|
|
});
|
|
editor.on('remove', function () {
|
|
editor.off('click', onContentClick);
|
|
editor.off('tap', onContentClick);
|
|
editor.off('mouseup', onContentMouseup);
|
|
editor.off('mousedown', onContentMousedown);
|
|
editor.off('ScrollWindow', onWindowScroll);
|
|
editor.off('ResizeWindow', onWindowResize);
|
|
editor.off('ResizeEditor', onEditorResize);
|
|
editor.off('AfterProgressState', onEditorProgress);
|
|
editor.off('DismissPopups', onDismissPopups);
|
|
onMousedown.unbind();
|
|
onTouchstart.unbind();
|
|
onTouchmove.unbind();
|
|
onTouchend.unbind();
|
|
onMouseup.unbind();
|
|
});
|
|
editor.on('detach', function () {
|
|
detachSystem(mothership);
|
|
detachSystem(uiMothership);
|
|
mothership.destroy();
|
|
uiMothership.destroy();
|
|
});
|
|
};
|
|
|
|
var parts$a = AlloyParts;
|
|
var partType = PartType;
|
|
|
|
var schema$f = constant$1([
|
|
defaulted('shell', false),
|
|
required$1('makeItem'),
|
|
defaulted('setupItem', noop),
|
|
SketchBehaviours.field('listBehaviours', [Replacing])
|
|
]);
|
|
var customListDetail = function () {
|
|
return { behaviours: derive$1([Replacing.config({})]) };
|
|
};
|
|
var itemsPart = optional({
|
|
name: 'items',
|
|
overrides: customListDetail
|
|
});
|
|
var parts$9 = constant$1([itemsPart]);
|
|
var name = constant$1('CustomList');
|
|
|
|
var factory$d = function (detail, components, _spec, _external) {
|
|
var setItems = function (list, items) {
|
|
getListContainer(list).fold(function () {
|
|
console.error('Custom List was defined to not be a shell, but no item container was specified in components');
|
|
throw new Error('Custom List was defined to not be a shell, but no item container was specified in components');
|
|
}, function (container) {
|
|
var itemComps = Replacing.contents(container);
|
|
var numListsRequired = items.length;
|
|
var numListsToAdd = numListsRequired - itemComps.length;
|
|
var itemsToAdd = numListsToAdd > 0 ? range$2(numListsToAdd, function () {
|
|
return detail.makeItem();
|
|
}) : [];
|
|
var itemsToRemove = itemComps.slice(numListsRequired);
|
|
each$1(itemsToRemove, function (item) {
|
|
return Replacing.remove(container, item);
|
|
});
|
|
each$1(itemsToAdd, function (item) {
|
|
return Replacing.append(container, item);
|
|
});
|
|
var builtLists = Replacing.contents(container);
|
|
each$1(builtLists, function (item, i) {
|
|
detail.setupItem(list, item, items[i], i);
|
|
});
|
|
});
|
|
};
|
|
var extra = detail.shell ? {
|
|
behaviours: [Replacing.config({})],
|
|
components: []
|
|
} : {
|
|
behaviours: [],
|
|
components: components
|
|
};
|
|
var getListContainer = function (component) {
|
|
return detail.shell ? Optional.some(component) : getPart(component, detail, 'items');
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: extra.components,
|
|
behaviours: augment(detail.listBehaviours, extra.behaviours),
|
|
apis: { setItems: setItems }
|
|
};
|
|
};
|
|
var CustomList = composite({
|
|
name: name(),
|
|
configFields: schema$f(),
|
|
partFields: parts$9(),
|
|
factory: factory$d,
|
|
apis: {
|
|
setItems: function (apis, list, items) {
|
|
apis.setItems(list, items);
|
|
}
|
|
}
|
|
});
|
|
|
|
var schema$e = constant$1([
|
|
required$1('dom'),
|
|
defaulted('shell', true),
|
|
field('toolbarBehaviours', [Replacing])
|
|
]);
|
|
var enhanceGroups = function () {
|
|
return { behaviours: derive$1([Replacing.config({})]) };
|
|
};
|
|
var parts$8 = constant$1([optional({
|
|
name: 'groups',
|
|
overrides: enhanceGroups
|
|
})]);
|
|
|
|
var factory$c = function (detail, components, _spec, _externals) {
|
|
var setGroups = function (toolbar, groups) {
|
|
getGroupContainer(toolbar).fold(function () {
|
|
console.error('Toolbar was defined to not be a shell, but no groups container was specified in components');
|
|
throw new Error('Toolbar was defined to not be a shell, but no groups container was specified in components');
|
|
}, function (container) {
|
|
Replacing.set(container, groups);
|
|
});
|
|
};
|
|
var getGroupContainer = function (component) {
|
|
return detail.shell ? Optional.some(component) : getPart(component, detail, 'groups');
|
|
};
|
|
var extra = detail.shell ? {
|
|
behaviours: [Replacing.config({})],
|
|
components: []
|
|
} : {
|
|
behaviours: [],
|
|
components: components
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: extra.components,
|
|
behaviours: augment(detail.toolbarBehaviours, extra.behaviours),
|
|
apis: { setGroups: setGroups },
|
|
domModification: { attributes: { role: 'group' } }
|
|
};
|
|
};
|
|
var Toolbar = composite({
|
|
name: 'Toolbar',
|
|
configFields: schema$e(),
|
|
partFields: parts$8(),
|
|
factory: factory$c,
|
|
apis: {
|
|
setGroups: function (apis, toolbar, groups) {
|
|
apis.setGroups(toolbar, groups);
|
|
}
|
|
}
|
|
});
|
|
|
|
var setup$a = noop;
|
|
var isDocked$2 = never;
|
|
var getBehaviours$1 = constant$1([]);
|
|
|
|
var StaticHeader = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setup: setup$a,
|
|
isDocked: isDocked$2,
|
|
getBehaviours: getBehaviours$1
|
|
});
|
|
|
|
var getOffsetParent = function (element) {
|
|
var isFixed = is$1(getRaw(element, 'position'), 'fixed');
|
|
var offsetParent$1 = isFixed ? Optional.none() : offsetParent(element);
|
|
return offsetParent$1.orThunk(function () {
|
|
var marker = SugarElement.fromTag('span');
|
|
return parent(element).bind(function (parent) {
|
|
append$2(parent, marker);
|
|
var offsetParent$1 = offsetParent(marker);
|
|
remove$5(marker);
|
|
return offsetParent$1;
|
|
});
|
|
});
|
|
};
|
|
var getOrigin = function (element) {
|
|
return getOffsetParent(element).map(absolute$3).getOrThunk(function () {
|
|
return SugarPosition(0, 0);
|
|
});
|
|
};
|
|
|
|
var morphAdt = Adt.generate([
|
|
{ static: [] },
|
|
{ absolute: ['positionCss'] },
|
|
{ fixed: ['positionCss'] }
|
|
]);
|
|
var appear = function (component, contextualInfo) {
|
|
var elem = component.element;
|
|
add$2(elem, contextualInfo.transitionClass);
|
|
remove$2(elem, contextualInfo.fadeOutClass);
|
|
add$2(elem, contextualInfo.fadeInClass);
|
|
contextualInfo.onShow(component);
|
|
};
|
|
var disappear = function (component, contextualInfo) {
|
|
var elem = component.element;
|
|
add$2(elem, contextualInfo.transitionClass);
|
|
remove$2(elem, contextualInfo.fadeInClass);
|
|
add$2(elem, contextualInfo.fadeOutClass);
|
|
contextualInfo.onHide(component);
|
|
};
|
|
var isPartiallyVisible = function (box, viewport) {
|
|
return box.y < viewport.bottom && box.bottom > viewport.y;
|
|
};
|
|
var isTopCompletelyVisible = function (box, viewport) {
|
|
return box.y >= viewport.y;
|
|
};
|
|
var isBottomCompletelyVisible = function (box, viewport) {
|
|
return box.bottom <= viewport.bottom;
|
|
};
|
|
var isVisibleForModes = function (modes, box, viewport) {
|
|
return forall(modes, function (mode) {
|
|
switch (mode) {
|
|
case 'bottom':
|
|
return isBottomCompletelyVisible(box, viewport);
|
|
case 'top':
|
|
return isTopCompletelyVisible(box, viewport);
|
|
}
|
|
});
|
|
};
|
|
var getPrior = function (elem, state) {
|
|
return state.getInitialPos().map(function (pos) {
|
|
return bounds(pos.bounds.x, pos.bounds.y, get$a(elem), get$b(elem));
|
|
});
|
|
};
|
|
var storePrior = function (elem, box, state) {
|
|
state.setInitialPos({
|
|
style: getAllRaw(elem),
|
|
position: get$c(elem, 'position') || 'static',
|
|
bounds: box
|
|
});
|
|
};
|
|
var revertToOriginal = function (elem, box, state) {
|
|
return state.getInitialPos().bind(function (position) {
|
|
state.clearInitialPos();
|
|
switch (position.position) {
|
|
case 'static':
|
|
return Optional.some(morphAdt.static());
|
|
case 'absolute':
|
|
var offsetBox_1 = getOffsetParent(elem).map(box$1).getOrThunk(function () {
|
|
return box$1(body());
|
|
});
|
|
return Optional.some(morphAdt.absolute(NuPositionCss('absolute', get$e(position.style, 'left').map(function (_left) {
|
|
return box.x - offsetBox_1.x;
|
|
}), get$e(position.style, 'top').map(function (_top) {
|
|
return box.y - offsetBox_1.y;
|
|
}), get$e(position.style, 'right').map(function (_right) {
|
|
return offsetBox_1.right - box.right;
|
|
}), get$e(position.style, 'bottom').map(function (_bottom) {
|
|
return offsetBox_1.bottom - box.bottom;
|
|
}))));
|
|
default:
|
|
return Optional.none();
|
|
}
|
|
});
|
|
};
|
|
var morphToOriginal = function (elem, viewport, state) {
|
|
return getPrior(elem, state).filter(function (box) {
|
|
return isVisibleForModes(state.getModes(), box, viewport);
|
|
}).bind(function (box) {
|
|
return revertToOriginal(elem, box, state);
|
|
});
|
|
};
|
|
var morphToFixed = function (elem, viewport, state) {
|
|
var box = box$1(elem);
|
|
if (!isVisibleForModes(state.getModes(), box, viewport)) {
|
|
storePrior(elem, box, state);
|
|
var winBox = win();
|
|
var left = box.x - winBox.x;
|
|
var top_1 = viewport.y - winBox.y;
|
|
var bottom = winBox.bottom - viewport.bottom;
|
|
var isTop = box.y <= viewport.y;
|
|
return Optional.some(morphAdt.fixed(NuPositionCss('fixed', Optional.some(left), isTop ? Optional.some(top_1) : Optional.none(), Optional.none(), !isTop ? Optional.some(bottom) : Optional.none())));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var getMorph = function (component, viewport, state) {
|
|
var elem = component.element;
|
|
var isDocked = is$1(getRaw(elem, 'position'), 'fixed');
|
|
return isDocked ? morphToOriginal(elem, viewport, state) : morphToFixed(elem, viewport, state);
|
|
};
|
|
var getMorphToOriginal = function (component, state) {
|
|
var elem = component.element;
|
|
return getPrior(elem, state).bind(function (box) {
|
|
return revertToOriginal(elem, box, state);
|
|
});
|
|
};
|
|
|
|
var morphToStatic = function (component, config, state) {
|
|
state.setDocked(false);
|
|
each$1([
|
|
'left',
|
|
'right',
|
|
'top',
|
|
'bottom',
|
|
'position'
|
|
], function (prop) {
|
|
return remove$6(component.element, prop);
|
|
});
|
|
config.onUndocked(component);
|
|
};
|
|
var morphToCoord = function (component, config, state, position) {
|
|
var isDocked = position.position === 'fixed';
|
|
state.setDocked(isDocked);
|
|
applyPositionCss(component.element, position);
|
|
var method = isDocked ? config.onDocked : config.onUndocked;
|
|
method(component);
|
|
};
|
|
var updateVisibility = function (component, config, state, viewport, morphToDocked) {
|
|
if (morphToDocked === void 0) {
|
|
morphToDocked = false;
|
|
}
|
|
config.contextual.each(function (contextInfo) {
|
|
contextInfo.lazyContext(component).each(function (box) {
|
|
var isVisible = isPartiallyVisible(box, viewport);
|
|
if (isVisible !== state.isVisible()) {
|
|
state.setVisible(isVisible);
|
|
if (morphToDocked && !isVisible) {
|
|
add$1(component.element, [contextInfo.fadeOutClass]);
|
|
contextInfo.onHide(component);
|
|
} else {
|
|
var method = isVisible ? appear : disappear;
|
|
method(component, contextInfo);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var refreshInternal = function (component, config, state) {
|
|
var viewport = config.lazyViewport(component);
|
|
var isDocked = state.isDocked();
|
|
if (isDocked) {
|
|
updateVisibility(component, config, state, viewport);
|
|
}
|
|
getMorph(component, viewport, state).each(function (morph) {
|
|
morph.fold(function () {
|
|
return morphToStatic(component, config, state);
|
|
}, function (position) {
|
|
return morphToCoord(component, config, state, position);
|
|
}, function (position) {
|
|
updateVisibility(component, config, state, viewport, true);
|
|
morphToCoord(component, config, state, position);
|
|
});
|
|
});
|
|
};
|
|
var resetInternal = function (component, config, state) {
|
|
var elem = component.element;
|
|
state.setDocked(false);
|
|
getMorphToOriginal(component, state).each(function (morph) {
|
|
morph.fold(function () {
|
|
return morphToStatic(component, config, state);
|
|
}, function (position) {
|
|
return morphToCoord(component, config, state, position);
|
|
}, noop);
|
|
});
|
|
state.setVisible(true);
|
|
config.contextual.each(function (contextInfo) {
|
|
remove$1(elem, [
|
|
contextInfo.fadeInClass,
|
|
contextInfo.fadeOutClass,
|
|
contextInfo.transitionClass
|
|
]);
|
|
contextInfo.onShow(component);
|
|
});
|
|
refresh$4(component, config, state);
|
|
};
|
|
var refresh$4 = function (component, config, state) {
|
|
if (component.getSystem().isConnected()) {
|
|
refreshInternal(component, config, state);
|
|
}
|
|
};
|
|
var reset = function (component, config, state) {
|
|
if (state.isDocked()) {
|
|
resetInternal(component, config, state);
|
|
}
|
|
};
|
|
var isDocked$1 = function (component, config, state) {
|
|
return state.isDocked();
|
|
};
|
|
var setModes = function (component, config, state, modes) {
|
|
return state.setModes(modes);
|
|
};
|
|
var getModes = function (component, config, state) {
|
|
return state.getModes();
|
|
};
|
|
|
|
var DockingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
refresh: refresh$4,
|
|
reset: reset,
|
|
isDocked: isDocked$1,
|
|
getModes: getModes,
|
|
setModes: setModes
|
|
});
|
|
|
|
var events$5 = function (dockInfo, dockState) {
|
|
return derive$2([
|
|
runOnSource(transitionend(), function (component, simulatedEvent) {
|
|
dockInfo.contextual.each(function (contextInfo) {
|
|
if (has(component.element, contextInfo.transitionClass)) {
|
|
remove$1(component.element, [
|
|
contextInfo.transitionClass,
|
|
contextInfo.fadeInClass
|
|
]);
|
|
var notify = dockState.isVisible() ? contextInfo.onShown : contextInfo.onHidden;
|
|
notify(component);
|
|
}
|
|
simulatedEvent.stop();
|
|
});
|
|
}),
|
|
run$1(windowScroll(), function (component, _) {
|
|
refresh$4(component, dockInfo, dockState);
|
|
}),
|
|
run$1(windowResize(), function (component, _) {
|
|
reset(component, dockInfo, dockState);
|
|
})
|
|
]);
|
|
};
|
|
|
|
var ActiveDocking = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$5
|
|
});
|
|
|
|
var DockingSchema = [
|
|
optionObjOf('contextual', [
|
|
requiredString('fadeInClass'),
|
|
requiredString('fadeOutClass'),
|
|
requiredString('transitionClass'),
|
|
requiredFunction('lazyContext'),
|
|
onHandler('onShow'),
|
|
onHandler('onShown'),
|
|
onHandler('onHide'),
|
|
onHandler('onHidden')
|
|
]),
|
|
defaultedFunction('lazyViewport', win),
|
|
defaultedArrayOf('modes', [
|
|
'top',
|
|
'bottom'
|
|
], string),
|
|
onHandler('onDocked'),
|
|
onHandler('onUndocked')
|
|
];
|
|
|
|
var init$6 = function (spec) {
|
|
var docked = Cell(false);
|
|
var visible = Cell(true);
|
|
var initialBounds = value$1();
|
|
var modes = Cell(spec.modes);
|
|
var readState = function () {
|
|
return 'docked: ' + docked.get() + ', visible: ' + visible.get() + ', modes: ' + modes.get().join(',');
|
|
};
|
|
return nu$8({
|
|
isDocked: docked.get,
|
|
setDocked: docked.set,
|
|
getInitialPos: initialBounds.get,
|
|
setInitialPos: initialBounds.set,
|
|
clearInitialPos: initialBounds.clear,
|
|
isVisible: visible.get,
|
|
setVisible: visible.set,
|
|
getModes: modes.get,
|
|
setModes: modes.set,
|
|
readState: readState
|
|
});
|
|
};
|
|
|
|
var DockingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$6
|
|
});
|
|
|
|
var Docking = create$7({
|
|
fields: DockingSchema,
|
|
name: 'docking',
|
|
active: ActiveDocking,
|
|
apis: DockingApis,
|
|
state: DockingState
|
|
});
|
|
|
|
var toolbarHeightChange = constant$1(generate$6('toolbar-height-change'));
|
|
|
|
var visibility = {
|
|
fadeInClass: 'tox-editor-dock-fadein',
|
|
fadeOutClass: 'tox-editor-dock-fadeout',
|
|
transitionClass: 'tox-editor-dock-transition'
|
|
};
|
|
var editorStickyOnClass = 'tox-tinymce--toolbar-sticky-on';
|
|
var editorStickyOffClass = 'tox-tinymce--toolbar-sticky-off';
|
|
var scrollFromBehindHeader = function (e, containerHeader) {
|
|
var doc = owner$4(containerHeader);
|
|
var viewHeight = doc.dom.defaultView.innerHeight;
|
|
var scrollPos = get$9(doc);
|
|
var markerElement = SugarElement.fromDom(e.elm);
|
|
var markerPos = absolute$2(markerElement);
|
|
var markerHeight = get$b(markerElement);
|
|
var markerTop = markerPos.y;
|
|
var markerBottom = markerTop + markerHeight;
|
|
var editorHeaderPos = absolute$3(containerHeader);
|
|
var editorHeaderHeight = get$b(containerHeader);
|
|
var editorHeaderTop = editorHeaderPos.top;
|
|
var editorHeaderBottom = editorHeaderTop + editorHeaderHeight;
|
|
var editorHeaderDockedAtTop = Math.abs(editorHeaderTop - scrollPos.top) < 2;
|
|
var editorHeaderDockedAtBottom = Math.abs(editorHeaderBottom - (scrollPos.top + viewHeight)) < 2;
|
|
if (editorHeaderDockedAtTop && markerTop < editorHeaderBottom) {
|
|
to(scrollPos.left, markerTop - editorHeaderHeight, doc);
|
|
} else if (editorHeaderDockedAtBottom && markerBottom > editorHeaderTop) {
|
|
var y = markerTop - viewHeight + markerHeight + editorHeaderHeight;
|
|
to(scrollPos.left, y, doc);
|
|
}
|
|
};
|
|
var isDockedMode = function (header, mode) {
|
|
return contains$2(Docking.getModes(header), mode);
|
|
};
|
|
var updateIframeContentFlow = function (header) {
|
|
var getOccupiedHeight = function (elm) {
|
|
return getOuter$2(elm) + (parseInt(get$c(elm, 'margin-top'), 10) || 0) + (parseInt(get$c(elm, 'margin-bottom'), 10) || 0);
|
|
};
|
|
var elm = header.element;
|
|
parent(elm).each(function (parentElem) {
|
|
var padding = 'padding-' + Docking.getModes(header)[0];
|
|
if (Docking.isDocked(header)) {
|
|
var parentWidth = get$a(parentElem);
|
|
set$7(elm, 'width', parentWidth + 'px');
|
|
set$7(parentElem, padding, getOccupiedHeight(elm) + 'px');
|
|
} else {
|
|
remove$6(elm, 'width');
|
|
remove$6(parentElem, padding);
|
|
}
|
|
});
|
|
};
|
|
var updateSinkVisibility = function (sinkElem, visible) {
|
|
if (visible) {
|
|
remove$2(sinkElem, visibility.fadeOutClass);
|
|
add$1(sinkElem, [
|
|
visibility.transitionClass,
|
|
visibility.fadeInClass
|
|
]);
|
|
} else {
|
|
remove$2(sinkElem, visibility.fadeInClass);
|
|
add$1(sinkElem, [
|
|
visibility.fadeOutClass,
|
|
visibility.transitionClass
|
|
]);
|
|
}
|
|
};
|
|
var updateEditorClasses = function (editor, docked) {
|
|
var editorContainer = SugarElement.fromDom(editor.getContainer());
|
|
if (docked) {
|
|
add$2(editorContainer, editorStickyOnClass);
|
|
remove$2(editorContainer, editorStickyOffClass);
|
|
} else {
|
|
add$2(editorContainer, editorStickyOffClass);
|
|
remove$2(editorContainer, editorStickyOnClass);
|
|
}
|
|
};
|
|
var restoreFocus = function (headerElem, focusedElem) {
|
|
var ownerDoc = owner$4(focusedElem);
|
|
active(ownerDoc).filter(function (activeElm) {
|
|
return !eq(focusedElem, activeElm);
|
|
}).filter(function (activeElm) {
|
|
return eq(activeElm, SugarElement.fromDom(ownerDoc.dom.body)) || contains(headerElem, activeElm);
|
|
}).each(function () {
|
|
return focus$3(focusedElem);
|
|
});
|
|
};
|
|
var findFocusedElem = function (rootElm, lazySink) {
|
|
return search(rootElm).orThunk(function () {
|
|
return lazySink().toOptional().bind(function (sink) {
|
|
return search(sink.element);
|
|
});
|
|
});
|
|
};
|
|
var setup$9 = function (editor, sharedBackstage, lazyHeader) {
|
|
if (!editor.inline) {
|
|
if (!sharedBackstage.header.isPositionedAtTop()) {
|
|
editor.on('ResizeEditor', function () {
|
|
lazyHeader().each(Docking.reset);
|
|
});
|
|
}
|
|
editor.on('ResizeWindow ResizeEditor', function () {
|
|
lazyHeader().each(updateIframeContentFlow);
|
|
});
|
|
editor.on('SkinLoaded', function () {
|
|
lazyHeader().each(function (comp) {
|
|
Docking.isDocked(comp) ? Docking.reset(comp) : Docking.refresh(comp);
|
|
});
|
|
});
|
|
editor.on('FullscreenStateChanged', function () {
|
|
lazyHeader().each(Docking.reset);
|
|
});
|
|
}
|
|
editor.on('AfterScrollIntoView', function (e) {
|
|
lazyHeader().each(function (header) {
|
|
Docking.refresh(header);
|
|
var headerElem = header.element;
|
|
if (isVisible(headerElem)) {
|
|
scrollFromBehindHeader(e, headerElem);
|
|
}
|
|
});
|
|
});
|
|
editor.on('PostRender', function () {
|
|
updateEditorClasses(editor, false);
|
|
});
|
|
};
|
|
var isDocked = function (lazyHeader) {
|
|
return lazyHeader().map(Docking.isDocked).getOr(false);
|
|
};
|
|
var getIframeBehaviours = function () {
|
|
var _a;
|
|
return [Receiving.config({ channels: (_a = {}, _a[toolbarHeightChange()] = { onReceive: updateIframeContentFlow }, _a) })];
|
|
};
|
|
var getBehaviours = function (editor, sharedBackstage) {
|
|
var focusedElm = value$1();
|
|
var lazySink = sharedBackstage.getSink;
|
|
var runOnSinkElement = function (f) {
|
|
lazySink().each(function (sink) {
|
|
return f(sink.element);
|
|
});
|
|
};
|
|
var onDockingSwitch = function (comp) {
|
|
if (!editor.inline) {
|
|
updateIframeContentFlow(comp);
|
|
}
|
|
updateEditorClasses(editor, Docking.isDocked(comp));
|
|
comp.getSystem().broadcastOn([repositionPopups()], {});
|
|
lazySink().each(function (sink) {
|
|
return sink.getSystem().broadcastOn([repositionPopups()], {});
|
|
});
|
|
};
|
|
var additionalBehaviours = editor.inline ? [] : getIframeBehaviours();
|
|
return __spreadArray([
|
|
Focusing.config({}),
|
|
Docking.config({
|
|
contextual: __assign({
|
|
lazyContext: function (comp) {
|
|
var headerHeight = getOuter$2(comp.element);
|
|
var container = editor.inline ? editor.getContentAreaContainer() : editor.getContainer();
|
|
var box = box$1(SugarElement.fromDom(container));
|
|
var boxHeight = box.height - headerHeight;
|
|
var topBound = box.y + (isDockedMode(comp, 'top') ? 0 : headerHeight);
|
|
return Optional.some(bounds(box.x, topBound, box.width, boxHeight));
|
|
},
|
|
onShow: function () {
|
|
runOnSinkElement(function (elem) {
|
|
return updateSinkVisibility(elem, true);
|
|
});
|
|
},
|
|
onShown: function (comp) {
|
|
runOnSinkElement(function (elem) {
|
|
return remove$1(elem, [
|
|
visibility.transitionClass,
|
|
visibility.fadeInClass
|
|
]);
|
|
});
|
|
focusedElm.get().each(function (elem) {
|
|
restoreFocus(comp.element, elem);
|
|
focusedElm.clear();
|
|
});
|
|
},
|
|
onHide: function (comp) {
|
|
findFocusedElem(comp.element, lazySink).fold(focusedElm.clear, focusedElm.set);
|
|
runOnSinkElement(function (elem) {
|
|
return updateSinkVisibility(elem, false);
|
|
});
|
|
},
|
|
onHidden: function () {
|
|
runOnSinkElement(function (elem) {
|
|
return remove$1(elem, [visibility.transitionClass]);
|
|
});
|
|
}
|
|
}, visibility),
|
|
lazyViewport: function (comp) {
|
|
var win$1 = win();
|
|
var offset = getStickyToolbarOffset(editor);
|
|
var top = win$1.y + (isDockedMode(comp, 'top') ? offset : 0);
|
|
var height = win$1.height - (isDockedMode(comp, 'bottom') ? offset : 0);
|
|
return bounds(win$1.x, top, win$1.width, height);
|
|
},
|
|
modes: [sharedBackstage.header.getDockingMode()],
|
|
onDocked: onDockingSwitch,
|
|
onUndocked: onDockingSwitch
|
|
})
|
|
], additionalBehaviours, true);
|
|
};
|
|
|
|
var StickyHeader = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setup: setup$9,
|
|
isDocked: isDocked,
|
|
getBehaviours: getBehaviours
|
|
});
|
|
|
|
var renderHeader = function (spec) {
|
|
var editor = spec.editor;
|
|
var getBehaviours$2 = spec.sticky ? getBehaviours : getBehaviours$1;
|
|
return {
|
|
uid: spec.uid,
|
|
dom: spec.dom,
|
|
components: spec.components,
|
|
behaviours: derive$1(getBehaviours$2(editor, spec.sharedBackstage))
|
|
};
|
|
};
|
|
|
|
var groupToolbarButtonSchema = objOf([
|
|
requiredString('type'),
|
|
requiredOf('items', oneOf([
|
|
arrOfObj([
|
|
requiredString('name'),
|
|
requiredArrayOf('items', string)
|
|
]),
|
|
string
|
|
]))
|
|
].concat(baseToolbarButtonFields));
|
|
var createGroupToolbarButton = function (spec) {
|
|
return asRaw('GroupToolbarButton', groupToolbarButtonSchema, spec);
|
|
};
|
|
|
|
var baseMenuButtonFields = [
|
|
optionString('text'),
|
|
optionString('tooltip'),
|
|
optionString('icon'),
|
|
requiredFunction('fetch'),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
})
|
|
];
|
|
|
|
var MenuButtonSchema = objOf(__spreadArray([requiredString('type')], baseMenuButtonFields, true));
|
|
var createMenuButton = function (spec) {
|
|
return asRaw('menubutton', MenuButtonSchema, spec);
|
|
};
|
|
|
|
var splitButtonSchema = objOf([
|
|
requiredString('type'),
|
|
optionString('tooltip'),
|
|
optionString('icon'),
|
|
optionString('text'),
|
|
optionFunction('select'),
|
|
requiredFunction('fetch'),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
}),
|
|
defaultedStringEnum('presets', 'normal', [
|
|
'normal',
|
|
'color',
|
|
'listpreview'
|
|
]),
|
|
defaulted('columns', 1),
|
|
requiredFunction('onAction'),
|
|
requiredFunction('onItemAction')
|
|
]);
|
|
var createSplitButton = function (spec) {
|
|
return asRaw('SplitButton', splitButtonSchema, spec);
|
|
};
|
|
|
|
var factory$b = function (detail, spec) {
|
|
var setMenus = function (comp, menus) {
|
|
var newMenus = map$2(menus, function (m) {
|
|
var buttonSpec = {
|
|
type: 'menubutton',
|
|
text: m.text,
|
|
fetch: function (callback) {
|
|
callback(m.getItems());
|
|
}
|
|
};
|
|
var internal = createMenuButton(buttonSpec).mapError(function (errInfo) {
|
|
return formatError(errInfo);
|
|
}).getOrDie();
|
|
return renderMenuButton(internal, 'tox-mbtn', spec.backstage, Optional.some('menuitem'));
|
|
});
|
|
Replacing.set(comp, newMenus);
|
|
};
|
|
var apis = {
|
|
focus: Keying.focusIn,
|
|
setMenus: setMenus
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: [],
|
|
behaviours: derive$1([
|
|
Replacing.config({}),
|
|
config('menubar-events', [
|
|
runOnAttached(function (component) {
|
|
detail.onSetup(component);
|
|
}),
|
|
run$1(mouseover(), function (comp, se) {
|
|
descendant(comp.element, '.' + 'tox-mbtn--active').each(function (activeButton) {
|
|
closest$1(se.event.target, '.' + 'tox-mbtn').each(function (hoveredButton) {
|
|
if (!eq(activeButton, hoveredButton)) {
|
|
comp.getSystem().getByDom(activeButton).each(function (activeComp) {
|
|
comp.getSystem().getByDom(hoveredButton).each(function (hoveredComp) {
|
|
Dropdown.expand(hoveredComp);
|
|
Dropdown.close(activeComp);
|
|
Focusing.focus(hoveredComp);
|
|
});
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}),
|
|
run$1(focusShifted(), function (comp, se) {
|
|
se.event.prevFocus.bind(function (prev) {
|
|
return comp.getSystem().getByDom(prev).toOptional();
|
|
}).each(function (prev) {
|
|
se.event.newFocus.bind(function (nu) {
|
|
return comp.getSystem().getByDom(nu).toOptional();
|
|
}).each(function (nu) {
|
|
if (Dropdown.isOpen(prev)) {
|
|
Dropdown.expand(nu);
|
|
Dropdown.close(prev);
|
|
}
|
|
});
|
|
});
|
|
})
|
|
]),
|
|
Keying.config({
|
|
mode: 'flow',
|
|
selector: '.' + 'tox-mbtn',
|
|
onEscape: function (comp) {
|
|
detail.onEscape(comp);
|
|
return Optional.some(true);
|
|
}
|
|
}),
|
|
Tabstopping.config({})
|
|
]),
|
|
apis: apis,
|
|
domModification: { attributes: { role: 'menubar' } }
|
|
};
|
|
};
|
|
var SilverMenubar = single({
|
|
factory: factory$b,
|
|
name: 'silver.Menubar',
|
|
configFields: [
|
|
required$1('dom'),
|
|
required$1('uid'),
|
|
required$1('onEscape'),
|
|
required$1('backstage'),
|
|
defaulted('onSetup', noop)
|
|
],
|
|
apis: {
|
|
focus: function (apis, comp) {
|
|
apis.focus(comp);
|
|
},
|
|
setMenus: function (apis, comp, menus) {
|
|
apis.setMenus(comp, menus);
|
|
}
|
|
}
|
|
});
|
|
|
|
var getAnimationRoot = function (component, slideConfig) {
|
|
return slideConfig.getAnimationRoot.fold(function () {
|
|
return component.element;
|
|
}, function (get) {
|
|
return get(component);
|
|
});
|
|
};
|
|
|
|
var getDimensionProperty = function (slideConfig) {
|
|
return slideConfig.dimension.property;
|
|
};
|
|
var getDimension = function (slideConfig, elem) {
|
|
return slideConfig.dimension.getDimension(elem);
|
|
};
|
|
var disableTransitions = function (component, slideConfig) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
remove$1(root, [
|
|
slideConfig.shrinkingClass,
|
|
slideConfig.growingClass
|
|
]);
|
|
};
|
|
var setShrunk = function (component, slideConfig) {
|
|
remove$2(component.element, slideConfig.openClass);
|
|
add$2(component.element, slideConfig.closedClass);
|
|
set$7(component.element, getDimensionProperty(slideConfig), '0px');
|
|
reflow(component.element);
|
|
};
|
|
var setGrown = function (component, slideConfig) {
|
|
remove$2(component.element, slideConfig.closedClass);
|
|
add$2(component.element, slideConfig.openClass);
|
|
remove$6(component.element, getDimensionProperty(slideConfig));
|
|
};
|
|
var doImmediateShrink = function (component, slideConfig, slideState, _calculatedSize) {
|
|
slideState.setCollapsed();
|
|
set$7(component.element, getDimensionProperty(slideConfig), getDimension(slideConfig, component.element));
|
|
reflow(component.element);
|
|
disableTransitions(component, slideConfig);
|
|
setShrunk(component, slideConfig);
|
|
slideConfig.onStartShrink(component);
|
|
slideConfig.onShrunk(component);
|
|
};
|
|
var doStartShrink = function (component, slideConfig, slideState, calculatedSize) {
|
|
var size = calculatedSize.getOrThunk(function () {
|
|
return getDimension(slideConfig, component.element);
|
|
});
|
|
slideState.setCollapsed();
|
|
set$7(component.element, getDimensionProperty(slideConfig), size);
|
|
reflow(component.element);
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
remove$2(root, slideConfig.growingClass);
|
|
add$2(root, slideConfig.shrinkingClass);
|
|
setShrunk(component, slideConfig);
|
|
slideConfig.onStartShrink(component);
|
|
};
|
|
var doStartSmartShrink = function (component, slideConfig, slideState) {
|
|
var size = getDimension(slideConfig, component.element);
|
|
var shrinker = size === '0px' ? doImmediateShrink : doStartShrink;
|
|
shrinker(component, slideConfig, slideState, Optional.some(size));
|
|
};
|
|
var doStartGrow = function (component, slideConfig, slideState) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
var wasShrinking = has(root, slideConfig.shrinkingClass);
|
|
var beforeSize = getDimension(slideConfig, component.element);
|
|
setGrown(component, slideConfig);
|
|
var fullSize = getDimension(slideConfig, component.element);
|
|
var startPartialGrow = function () {
|
|
set$7(component.element, getDimensionProperty(slideConfig), beforeSize);
|
|
reflow(component.element);
|
|
};
|
|
var startCompleteGrow = function () {
|
|
setShrunk(component, slideConfig);
|
|
};
|
|
var setStartSize = wasShrinking ? startPartialGrow : startCompleteGrow;
|
|
setStartSize();
|
|
remove$2(root, slideConfig.shrinkingClass);
|
|
add$2(root, slideConfig.growingClass);
|
|
setGrown(component, slideConfig);
|
|
set$7(component.element, getDimensionProperty(slideConfig), fullSize);
|
|
slideState.setExpanded();
|
|
slideConfig.onStartGrow(component);
|
|
};
|
|
var refresh$3 = function (component, slideConfig, slideState) {
|
|
if (slideState.isExpanded()) {
|
|
remove$6(component.element, getDimensionProperty(slideConfig));
|
|
var fullSize = getDimension(slideConfig, component.element);
|
|
set$7(component.element, getDimensionProperty(slideConfig), fullSize);
|
|
}
|
|
};
|
|
var grow = function (component, slideConfig, slideState) {
|
|
if (!slideState.isExpanded()) {
|
|
doStartGrow(component, slideConfig, slideState);
|
|
}
|
|
};
|
|
var shrink = function (component, slideConfig, slideState) {
|
|
if (slideState.isExpanded()) {
|
|
doStartSmartShrink(component, slideConfig, slideState);
|
|
}
|
|
};
|
|
var immediateShrink = function (component, slideConfig, slideState) {
|
|
if (slideState.isExpanded()) {
|
|
doImmediateShrink(component, slideConfig, slideState);
|
|
}
|
|
};
|
|
var hasGrown = function (component, slideConfig, slideState) {
|
|
return slideState.isExpanded();
|
|
};
|
|
var hasShrunk = function (component, slideConfig, slideState) {
|
|
return slideState.isCollapsed();
|
|
};
|
|
var isGrowing = function (component, slideConfig, _slideState) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
return has(root, slideConfig.growingClass) === true;
|
|
};
|
|
var isShrinking = function (component, slideConfig, _slideState) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
return has(root, slideConfig.shrinkingClass) === true;
|
|
};
|
|
var isTransitioning = function (component, slideConfig, slideState) {
|
|
return isGrowing(component, slideConfig) || isShrinking(component, slideConfig);
|
|
};
|
|
var toggleGrow = function (component, slideConfig, slideState) {
|
|
var f = slideState.isExpanded() ? doStartSmartShrink : doStartGrow;
|
|
f(component, slideConfig, slideState);
|
|
};
|
|
|
|
var SlidingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
refresh: refresh$3,
|
|
grow: grow,
|
|
shrink: shrink,
|
|
immediateShrink: immediateShrink,
|
|
hasGrown: hasGrown,
|
|
hasShrunk: hasShrunk,
|
|
isGrowing: isGrowing,
|
|
isShrinking: isShrinking,
|
|
isTransitioning: isTransitioning,
|
|
toggleGrow: toggleGrow,
|
|
disableTransitions: disableTransitions
|
|
});
|
|
|
|
var exhibit = function (base, slideConfig, _slideState) {
|
|
var expanded = slideConfig.expanded;
|
|
return expanded ? nu$7({
|
|
classes: [slideConfig.openClass],
|
|
styles: {}
|
|
}) : nu$7({
|
|
classes: [slideConfig.closedClass],
|
|
styles: wrap$1(slideConfig.dimension.property, '0px')
|
|
});
|
|
};
|
|
var events$4 = function (slideConfig, slideState) {
|
|
return derive$2([runOnSource(transitionend(), function (component, simulatedEvent) {
|
|
var raw = simulatedEvent.event.raw;
|
|
if (raw.propertyName === slideConfig.dimension.property) {
|
|
disableTransitions(component, slideConfig);
|
|
if (slideState.isExpanded()) {
|
|
remove$6(component.element, slideConfig.dimension.property);
|
|
}
|
|
var notify = slideState.isExpanded() ? slideConfig.onGrown : slideConfig.onShrunk;
|
|
notify(component);
|
|
}
|
|
})]);
|
|
};
|
|
|
|
var ActiveSliding = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit,
|
|
events: events$4
|
|
});
|
|
|
|
var SlidingSchema = [
|
|
required$1('closedClass'),
|
|
required$1('openClass'),
|
|
required$1('shrinkingClass'),
|
|
required$1('growingClass'),
|
|
option('getAnimationRoot'),
|
|
onHandler('onShrunk'),
|
|
onHandler('onStartShrink'),
|
|
onHandler('onGrown'),
|
|
onHandler('onStartGrow'),
|
|
defaulted('expanded', false),
|
|
requiredOf('dimension', choose$1('property', {
|
|
width: [
|
|
output$1('property', 'width'),
|
|
output$1('getDimension', function (elem) {
|
|
return get$a(elem) + 'px';
|
|
})
|
|
],
|
|
height: [
|
|
output$1('property', 'height'),
|
|
output$1('getDimension', function (elem) {
|
|
return get$b(elem) + 'px';
|
|
})
|
|
]
|
|
}))
|
|
];
|
|
|
|
var init$5 = function (spec) {
|
|
var state = Cell(spec.expanded);
|
|
var readState = function () {
|
|
return 'expanded: ' + state.get();
|
|
};
|
|
return nu$8({
|
|
isExpanded: function () {
|
|
return state.get() === true;
|
|
},
|
|
isCollapsed: function () {
|
|
return state.get() === false;
|
|
},
|
|
setCollapsed: curry(state.set, false),
|
|
setExpanded: curry(state.set, true),
|
|
readState: readState
|
|
});
|
|
};
|
|
|
|
var SlidingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$5
|
|
});
|
|
|
|
var Sliding = create$7({
|
|
fields: SlidingSchema,
|
|
name: 'sliding',
|
|
active: ActiveSliding,
|
|
apis: SlidingApis,
|
|
state: SlidingState
|
|
});
|
|
|
|
var owner = 'container';
|
|
var schema$d = [field('slotBehaviours', [])];
|
|
var getPartName = function (name) {
|
|
return '<alloy.field.' + name + '>';
|
|
};
|
|
var sketch = function (sSpec) {
|
|
var parts = function () {
|
|
var record = [];
|
|
var slot = function (name, config) {
|
|
record.push(name);
|
|
return generateOne$1(owner, getPartName(name), config);
|
|
};
|
|
return {
|
|
slot: slot,
|
|
record: constant$1(record)
|
|
};
|
|
}();
|
|
var spec = sSpec(parts);
|
|
var partNames = parts.record();
|
|
var fieldParts = map$2(partNames, function (n) {
|
|
return required({
|
|
name: n,
|
|
pname: getPartName(n)
|
|
});
|
|
});
|
|
return composite$1(owner, schema$d, fieldParts, make$1, spec);
|
|
};
|
|
var make$1 = function (detail, components) {
|
|
var getSlotNames = function (_) {
|
|
return getAllPartNames(detail);
|
|
};
|
|
var getSlot = function (container, key) {
|
|
return getPart(container, detail, key);
|
|
};
|
|
var onSlot = function (f, def) {
|
|
return function (container, key) {
|
|
return getPart(container, detail, key).map(function (slot) {
|
|
return f(slot, key);
|
|
}).getOr(def);
|
|
};
|
|
};
|
|
var onSlots = function (f) {
|
|
return function (container, keys) {
|
|
each$1(keys, function (key) {
|
|
return f(container, key);
|
|
});
|
|
};
|
|
};
|
|
var doShowing = function (comp, _key) {
|
|
return get$d(comp.element, 'aria-hidden') !== 'true';
|
|
};
|
|
var doShow = function (comp, key) {
|
|
if (!doShowing(comp)) {
|
|
var element = comp.element;
|
|
remove$6(element, 'display');
|
|
remove$7(element, 'aria-hidden');
|
|
emitWith(comp, slotVisibility(), {
|
|
name: key,
|
|
visible: true
|
|
});
|
|
}
|
|
};
|
|
var doHide = function (comp, key) {
|
|
if (doShowing(comp)) {
|
|
var element = comp.element;
|
|
set$7(element, 'display', 'none');
|
|
set$8(element, 'aria-hidden', 'true');
|
|
emitWith(comp, slotVisibility(), {
|
|
name: key,
|
|
visible: false
|
|
});
|
|
}
|
|
};
|
|
var isShowing = onSlot(doShowing, false);
|
|
var hideSlot = onSlot(doHide);
|
|
var hideSlots = onSlots(hideSlot);
|
|
var hideAllSlots = function (container) {
|
|
return hideSlots(container, getSlotNames());
|
|
};
|
|
var showSlot = onSlot(doShow);
|
|
var apis = {
|
|
getSlotNames: getSlotNames,
|
|
getSlot: getSlot,
|
|
isShowing: isShowing,
|
|
hideSlot: hideSlot,
|
|
hideAllSlots: hideAllSlots,
|
|
showSlot: showSlot
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: get$2(detail.slotBehaviours),
|
|
apis: apis
|
|
};
|
|
};
|
|
var slotApis = map$1({
|
|
getSlotNames: function (apis, c) {
|
|
return apis.getSlotNames(c);
|
|
},
|
|
getSlot: function (apis, c, key) {
|
|
return apis.getSlot(c, key);
|
|
},
|
|
isShowing: function (apis, c, key) {
|
|
return apis.isShowing(c, key);
|
|
},
|
|
hideSlot: function (apis, c, key) {
|
|
return apis.hideSlot(c, key);
|
|
},
|
|
hideAllSlots: function (apis, c) {
|
|
return apis.hideAllSlots(c);
|
|
},
|
|
showSlot: function (apis, c, key) {
|
|
return apis.showSlot(c, key);
|
|
}
|
|
}, function (value) {
|
|
return makeApi(value);
|
|
});
|
|
var SlotContainer = __assign(__assign({}, slotApis), { sketch: sketch });
|
|
|
|
var sidebarSchema = objOf([
|
|
optionString('icon'),
|
|
optionString('tooltip'),
|
|
defaultedFunction('onShow', noop),
|
|
defaultedFunction('onHide', noop),
|
|
defaultedFunction('onSetup', function () {
|
|
return noop;
|
|
})
|
|
]);
|
|
var createSidebar = function (spec) {
|
|
return asRaw('sidebar', sidebarSchema, spec);
|
|
};
|
|
|
|
var setup$8 = function (editor) {
|
|
var sidebars = editor.ui.registry.getAll().sidebars;
|
|
each$1(keys(sidebars), function (name) {
|
|
var spec = sidebars[name];
|
|
var isActive = function () {
|
|
return is$1(Optional.from(editor.queryCommandValue('ToggleSidebar')), name);
|
|
};
|
|
editor.ui.registry.addToggleButton(name, {
|
|
icon: spec.icon,
|
|
tooltip: spec.tooltip,
|
|
onAction: function (buttonApi) {
|
|
editor.execCommand('ToggleSidebar', false, name);
|
|
buttonApi.setActive(isActive());
|
|
},
|
|
onSetup: function (buttonApi) {
|
|
var handleToggle = function () {
|
|
return buttonApi.setActive(isActive());
|
|
};
|
|
editor.on('ToggleSidebar', handleToggle);
|
|
return function () {
|
|
editor.off('ToggleSidebar', handleToggle);
|
|
};
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var getApi = function (comp) {
|
|
return {
|
|
element: function () {
|
|
return comp.element.dom;
|
|
}
|
|
};
|
|
};
|
|
var makePanels = function (parts, panelConfigs) {
|
|
var specs = map$2(keys(panelConfigs), function (name) {
|
|
var spec = panelConfigs[name];
|
|
var bridged = getOrDie(createSidebar(spec));
|
|
return {
|
|
name: name,
|
|
getApi: getApi,
|
|
onSetup: bridged.onSetup,
|
|
onShow: bridged.onShow,
|
|
onHide: bridged.onHide
|
|
};
|
|
});
|
|
return map$2(specs, function (spec) {
|
|
var editorOffCell = Cell(noop);
|
|
return parts.slot(spec.name, {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-sidebar__pane']
|
|
},
|
|
behaviours: SimpleBehaviours.unnamedEvents([
|
|
onControlAttached(spec, editorOffCell),
|
|
onControlDetached(spec, editorOffCell),
|
|
run$1(slotVisibility(), function (sidepanel, se) {
|
|
var data = se.event;
|
|
var optSidePanelSpec = find$5(specs, function (config) {
|
|
return config.name === data.name;
|
|
});
|
|
optSidePanelSpec.each(function (sidePanelSpec) {
|
|
var handler = data.visible ? sidePanelSpec.onShow : sidePanelSpec.onHide;
|
|
handler(sidePanelSpec.getApi(sidepanel));
|
|
});
|
|
})
|
|
])
|
|
});
|
|
});
|
|
};
|
|
var makeSidebar = function (panelConfigs) {
|
|
return SlotContainer.sketch(function (parts) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-sidebar__pane-container']
|
|
},
|
|
components: makePanels(parts, panelConfigs),
|
|
slotBehaviours: SimpleBehaviours.unnamedEvents([runOnAttached(function (slotContainer) {
|
|
return SlotContainer.hideAllSlots(slotContainer);
|
|
})])
|
|
};
|
|
});
|
|
};
|
|
var setSidebar = function (sidebar, panelConfigs) {
|
|
var optSlider = Composing.getCurrent(sidebar);
|
|
optSlider.each(function (slider) {
|
|
return Replacing.set(slider, [makeSidebar(panelConfigs)]);
|
|
});
|
|
};
|
|
var toggleSidebar = function (sidebar, name) {
|
|
var optSlider = Composing.getCurrent(sidebar);
|
|
optSlider.each(function (slider) {
|
|
var optSlotContainer = Composing.getCurrent(slider);
|
|
optSlotContainer.each(function (slotContainer) {
|
|
if (Sliding.hasGrown(slider)) {
|
|
if (SlotContainer.isShowing(slotContainer, name)) {
|
|
Sliding.shrink(slider);
|
|
} else {
|
|
SlotContainer.hideAllSlots(slotContainer);
|
|
SlotContainer.showSlot(slotContainer, name);
|
|
}
|
|
} else {
|
|
SlotContainer.hideAllSlots(slotContainer);
|
|
SlotContainer.showSlot(slotContainer, name);
|
|
Sliding.grow(slider);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var whichSidebar = function (sidebar) {
|
|
var optSlider = Composing.getCurrent(sidebar);
|
|
return optSlider.bind(function (slider) {
|
|
var sidebarOpen = Sliding.isGrowing(slider) || Sliding.hasGrown(slider);
|
|
if (sidebarOpen) {
|
|
var optSlotContainer = Composing.getCurrent(slider);
|
|
return optSlotContainer.bind(function (slotContainer) {
|
|
return find$5(SlotContainer.getSlotNames(slotContainer), function (name) {
|
|
return SlotContainer.isShowing(slotContainer, name);
|
|
});
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
};
|
|
var fixSize = generate$6('FixSizeEvent');
|
|
var autoSize = generate$6('AutoSizeEvent');
|
|
var renderSidebar = function (spec) {
|
|
return {
|
|
uid: spec.uid,
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-sidebar'],
|
|
attributes: { role: 'complementary' }
|
|
},
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-sidebar__slider']
|
|
},
|
|
components: [],
|
|
behaviours: derive$1([
|
|
Tabstopping.config({}),
|
|
Focusing.config({}),
|
|
Sliding.config({
|
|
dimension: { property: 'width' },
|
|
closedClass: 'tox-sidebar--sliding-closed',
|
|
openClass: 'tox-sidebar--sliding-open',
|
|
shrinkingClass: 'tox-sidebar--sliding-shrinking',
|
|
growingClass: 'tox-sidebar--sliding-growing',
|
|
onShrunk: function (slider) {
|
|
var optSlotContainer = Composing.getCurrent(slider);
|
|
optSlotContainer.each(SlotContainer.hideAllSlots);
|
|
emit(slider, autoSize);
|
|
},
|
|
onGrown: function (slider) {
|
|
emit(slider, autoSize);
|
|
},
|
|
onStartGrow: function (slider) {
|
|
emitWith(slider, fixSize, { width: getRaw(slider.element, 'width').getOr('') });
|
|
},
|
|
onStartShrink: function (slider) {
|
|
emitWith(slider, fixSize, { width: get$a(slider.element) + 'px' });
|
|
}
|
|
}),
|
|
Replacing.config({}),
|
|
Composing.config({
|
|
find: function (comp) {
|
|
var children = Replacing.contents(comp);
|
|
return head(children);
|
|
}
|
|
})
|
|
])
|
|
}],
|
|
behaviours: derive$1([
|
|
ComposingConfigs.childAt(0),
|
|
config('sidebar-sliding-events', [
|
|
run$1(fixSize, function (comp, se) {
|
|
set$7(comp.element, 'width', se.event.width);
|
|
}),
|
|
run$1(autoSize, function (comp, _se) {
|
|
remove$6(comp.element, 'width');
|
|
})
|
|
])
|
|
])
|
|
};
|
|
};
|
|
|
|
var block = function (component, config, state, getBusySpec) {
|
|
set$8(component.element, 'aria-busy', true);
|
|
var root = config.getRoot(component).getOr(component);
|
|
var blockerBehaviours = derive$1([
|
|
Keying.config({
|
|
mode: 'special',
|
|
onTab: function () {
|
|
return Optional.some(true);
|
|
},
|
|
onShiftTab: function () {
|
|
return Optional.some(true);
|
|
}
|
|
}),
|
|
Focusing.config({})
|
|
]);
|
|
var blockSpec = getBusySpec(root, blockerBehaviours);
|
|
var blocker = root.getSystem().build(blockSpec);
|
|
Replacing.append(root, premade(blocker));
|
|
if (blocker.hasConfigured(Keying) && config.focus) {
|
|
Keying.focusIn(blocker);
|
|
}
|
|
if (!state.isBlocked()) {
|
|
config.onBlock(component);
|
|
}
|
|
state.blockWith(function () {
|
|
return Replacing.remove(root, blocker);
|
|
});
|
|
};
|
|
var unblock = function (component, config, state) {
|
|
remove$7(component.element, 'aria-busy');
|
|
if (state.isBlocked()) {
|
|
config.onUnblock(component);
|
|
}
|
|
state.clear();
|
|
};
|
|
|
|
var BlockingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
block: block,
|
|
unblock: unblock
|
|
});
|
|
|
|
var BlockingSchema = [
|
|
defaultedFunction('getRoot', Optional.none),
|
|
defaultedBoolean('focus', true),
|
|
onHandler('onBlock'),
|
|
onHandler('onUnblock')
|
|
];
|
|
|
|
var init$4 = function () {
|
|
var blocker = destroyable();
|
|
var blockWith = function (destroy) {
|
|
blocker.set({ destroy: destroy });
|
|
};
|
|
return nu$8({
|
|
readState: blocker.isSet,
|
|
blockWith: blockWith,
|
|
clear: blocker.clear,
|
|
isBlocked: blocker.isSet
|
|
});
|
|
};
|
|
|
|
var BlockingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$4
|
|
});
|
|
|
|
var Blocking = create$7({
|
|
fields: BlockingSchema,
|
|
name: 'blocking',
|
|
apis: BlockingApis,
|
|
state: BlockingState
|
|
});
|
|
|
|
var getAttrs = function (elem) {
|
|
var attributes = elem.dom.attributes !== undefined ? elem.dom.attributes : [];
|
|
return foldl(attributes, function (b, attr) {
|
|
var _a;
|
|
if (attr.name === 'class') {
|
|
return b;
|
|
} else {
|
|
return __assign(__assign({}, b), (_a = {}, _a[attr.name] = attr.value, _a));
|
|
}
|
|
}, {});
|
|
};
|
|
var getClasses = function (elem) {
|
|
return Array.prototype.slice.call(elem.dom.classList, 0);
|
|
};
|
|
var fromHtml = function (html) {
|
|
var elem = SugarElement.fromHtml(html);
|
|
var children$1 = children(elem);
|
|
var attrs = getAttrs(elem);
|
|
var classes = getClasses(elem);
|
|
var contents = children$1.length === 0 ? {} : { innerHtml: get$7(elem) };
|
|
return __assign({
|
|
tag: name$2(elem),
|
|
classes: classes,
|
|
attributes: attrs
|
|
}, contents);
|
|
};
|
|
|
|
var getBusySpec$1 = function (providerBackstage) {
|
|
return function (_root, _behaviours) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: {
|
|
'aria-label': providerBackstage.translate('Loading...'),
|
|
'tabindex': '0'
|
|
},
|
|
classes: ['tox-throbber__busy-spinner']
|
|
},
|
|
components: [{ dom: fromHtml('<div class="tox-spinner"><div></div><div></div><div></div></div>') }]
|
|
};
|
|
};
|
|
};
|
|
var focusBusyComponent = function (throbber) {
|
|
return Composing.getCurrent(throbber).each(function (comp) {
|
|
return focus$3(comp.element);
|
|
});
|
|
};
|
|
var toggleEditorTabIndex = function (editor, state) {
|
|
var tabIndexAttr = 'tabindex';
|
|
var dataTabIndexAttr = 'data-mce-' + tabIndexAttr;
|
|
Optional.from(editor.iframeElement).map(SugarElement.fromDom).each(function (iframe) {
|
|
if (state) {
|
|
getOpt(iframe, tabIndexAttr).each(function (tabIndex) {
|
|
return set$8(iframe, dataTabIndexAttr, tabIndex);
|
|
});
|
|
set$8(iframe, tabIndexAttr, -1);
|
|
} else {
|
|
remove$7(iframe, tabIndexAttr);
|
|
getOpt(iframe, dataTabIndexAttr).each(function (tabIndex) {
|
|
set$8(iframe, tabIndexAttr, tabIndex);
|
|
remove$7(iframe, dataTabIndexAttr);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var toggleThrobber = function (editor, comp, state, providerBackstage) {
|
|
var element = comp.element;
|
|
toggleEditorTabIndex(editor, state);
|
|
if (state) {
|
|
Blocking.block(comp, getBusySpec$1(providerBackstage));
|
|
remove$6(element, 'display');
|
|
remove$7(element, 'aria-hidden');
|
|
if (editor.hasFocus()) {
|
|
focusBusyComponent(comp);
|
|
}
|
|
} else {
|
|
var throbberFocus = Composing.getCurrent(comp).exists(function (busyComp) {
|
|
return hasFocus(busyComp.element);
|
|
});
|
|
Blocking.unblock(comp);
|
|
set$7(element, 'display', 'none');
|
|
set$8(element, 'aria-hidden', 'true');
|
|
if (throbberFocus) {
|
|
editor.focus();
|
|
}
|
|
}
|
|
};
|
|
var renderThrobber = function (spec) {
|
|
return {
|
|
uid: spec.uid,
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { 'aria-hidden': 'true' },
|
|
classes: ['tox-throbber'],
|
|
styles: { display: 'none' }
|
|
},
|
|
behaviours: derive$1([
|
|
Replacing.config({}),
|
|
Blocking.config({ focus: false }),
|
|
Composing.config({
|
|
find: function (comp) {
|
|
return head(comp.components());
|
|
}
|
|
})
|
|
]),
|
|
components: []
|
|
};
|
|
};
|
|
var isFocusEvent = function (event) {
|
|
return event.type === 'focusin';
|
|
};
|
|
var isPasteBinTarget = function (event) {
|
|
if (isFocusEvent(event)) {
|
|
var node = event.composed ? head(event.composedPath()) : Optional.from(event.target);
|
|
return node.map(SugarElement.fromDom).filter(isElement$2).exists(function (targetElm) {
|
|
return has(targetElm, 'mce-pastebin');
|
|
});
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
var setup$7 = function (editor, lazyThrobber, sharedBackstage) {
|
|
var throbberState = Cell(false);
|
|
var timer = value$1();
|
|
var stealFocus = function (e) {
|
|
if (throbberState.get() && !isPasteBinTarget(e)) {
|
|
e.preventDefault();
|
|
focusBusyComponent(lazyThrobber());
|
|
editor.editorManager.setActive(editor);
|
|
}
|
|
};
|
|
if (!editor.inline) {
|
|
editor.on('PreInit', function () {
|
|
editor.dom.bind(editor.getWin(), 'focusin', stealFocus);
|
|
editor.on('BeforeExecCommand', function (e) {
|
|
if (e.command.toLowerCase() === 'mcefocus' && e.value !== true) {
|
|
stealFocus(e);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
var toggle = function (state) {
|
|
if (state !== throbberState.get()) {
|
|
throbberState.set(state);
|
|
toggleThrobber(editor, lazyThrobber(), state, sharedBackstage.providers);
|
|
editor.fire('AfterProgressState', { state: state });
|
|
}
|
|
};
|
|
editor.on('ProgressState', function (e) {
|
|
timer.on(global$f.clearTimeout);
|
|
if (isNumber(e.time)) {
|
|
var timerId = global$f.setEditorTimeout(editor, function () {
|
|
return toggle(e.state);
|
|
}, e.time);
|
|
timer.set(timerId);
|
|
} else {
|
|
toggle(e.state);
|
|
timer.clear();
|
|
}
|
|
});
|
|
};
|
|
|
|
var generate$1 = function (xs, f) {
|
|
var init = {
|
|
len: 0,
|
|
list: []
|
|
};
|
|
var r = foldl(xs, function (b, a) {
|
|
var value = f(a, b.len);
|
|
return value.fold(constant$1(b), function (v) {
|
|
return {
|
|
len: v.finish,
|
|
list: b.list.concat([v])
|
|
};
|
|
});
|
|
}, init);
|
|
return r.list;
|
|
};
|
|
|
|
var output = function (within, extra, withinWidth) {
|
|
return {
|
|
within: within,
|
|
extra: extra,
|
|
withinWidth: withinWidth
|
|
};
|
|
};
|
|
var apportion = function (units, total, len) {
|
|
var parray = generate$1(units, function (unit, current) {
|
|
var width = len(unit);
|
|
return Optional.some({
|
|
element: unit,
|
|
start: current,
|
|
finish: current + width,
|
|
width: width
|
|
});
|
|
});
|
|
var within = filter$2(parray, function (unit) {
|
|
return unit.finish <= total;
|
|
});
|
|
var withinWidth = foldr(within, function (acc, el) {
|
|
return acc + el.width;
|
|
}, 0);
|
|
var extra = parray.slice(within.length);
|
|
return {
|
|
within: within,
|
|
extra: extra,
|
|
withinWidth: withinWidth
|
|
};
|
|
};
|
|
var toUnit = function (parray) {
|
|
return map$2(parray, function (unit) {
|
|
return unit.element;
|
|
});
|
|
};
|
|
var fitLast = function (within, extra, withinWidth) {
|
|
var fits = toUnit(within.concat(extra));
|
|
return output(fits, [], withinWidth);
|
|
};
|
|
var overflow = function (within, extra, overflower, withinWidth) {
|
|
var fits = toUnit(within).concat([overflower]);
|
|
return output(fits, toUnit(extra), withinWidth);
|
|
};
|
|
var fitAll = function (within, extra, withinWidth) {
|
|
return output(toUnit(within), [], withinWidth);
|
|
};
|
|
var tryFit = function (total, units, len) {
|
|
var divide = apportion(units, total, len);
|
|
return divide.extra.length === 0 ? Optional.some(divide) : Optional.none();
|
|
};
|
|
var partition = function (total, units, len, overflower) {
|
|
var divide = tryFit(total, units, len).getOrThunk(function () {
|
|
return apportion(units, total - len(overflower), len);
|
|
});
|
|
var within = divide.within;
|
|
var extra = divide.extra;
|
|
var withinWidth = divide.withinWidth;
|
|
if (extra.length === 1 && extra[0].width <= len(overflower)) {
|
|
return fitLast(within, extra, withinWidth);
|
|
} else if (extra.length >= 1) {
|
|
return overflow(within, extra, overflower, withinWidth);
|
|
} else {
|
|
return fitAll(within, extra, withinWidth);
|
|
}
|
|
};
|
|
|
|
var setGroups$1 = function (toolbar, storedGroups) {
|
|
var bGroups = map$2(storedGroups, function (g) {
|
|
return premade(g);
|
|
});
|
|
Toolbar.setGroups(toolbar, bGroups);
|
|
};
|
|
var findFocusedComp = function (comps) {
|
|
return findMap(comps, function (comp) {
|
|
return search(comp.element).bind(function (focusedElm) {
|
|
return comp.getSystem().getByDom(focusedElm).toOptional();
|
|
});
|
|
});
|
|
};
|
|
var refresh$2 = function (toolbar, detail, setOverflow) {
|
|
var builtGroups = detail.builtGroups.get();
|
|
if (builtGroups.length === 0) {
|
|
return;
|
|
}
|
|
var primary = getPartOrDie(toolbar, detail, 'primary');
|
|
var overflowGroup = Coupling.getCoupled(toolbar, 'overflowGroup');
|
|
set$7(primary.element, 'visibility', 'hidden');
|
|
var groups = builtGroups.concat([overflowGroup]);
|
|
var focusedComp = findFocusedComp(groups);
|
|
setOverflow([]);
|
|
setGroups$1(primary, groups);
|
|
var availableWidth = get$a(primary.element);
|
|
var overflows = partition(availableWidth, detail.builtGroups.get(), function (comp) {
|
|
return get$a(comp.element);
|
|
}, overflowGroup);
|
|
if (overflows.extra.length === 0) {
|
|
Replacing.remove(primary, overflowGroup);
|
|
setOverflow([]);
|
|
} else {
|
|
setGroups$1(primary, overflows.within);
|
|
setOverflow(overflows.extra);
|
|
}
|
|
remove$6(primary.element, 'visibility');
|
|
reflow(primary.element);
|
|
focusedComp.each(Focusing.focus);
|
|
};
|
|
|
|
var schema$c = constant$1([
|
|
field('splitToolbarBehaviours', [Coupling]),
|
|
customField('builtGroups', function () {
|
|
return Cell([]);
|
|
})
|
|
]);
|
|
|
|
var schema$b = constant$1([
|
|
markers$1(['overflowToggledClass']),
|
|
optionFunction('getOverflowBounds'),
|
|
required$1('lazySink'),
|
|
customField('overflowGroups', function () {
|
|
return Cell([]);
|
|
})
|
|
].concat(schema$c()));
|
|
var parts$7 = constant$1([
|
|
required({
|
|
factory: Toolbar,
|
|
schema: schema$e(),
|
|
name: 'primary'
|
|
}),
|
|
external$1({
|
|
schema: schema$e(),
|
|
name: 'overflow'
|
|
}),
|
|
external$1({ name: 'overflow-button' }),
|
|
external$1({ name: 'overflow-group' })
|
|
]);
|
|
|
|
var expandable = constant$1(function (element, available) {
|
|
setMax(element, Math.floor(available));
|
|
});
|
|
|
|
var schema$a = constant$1([
|
|
markers$1(['toggledClass']),
|
|
required$1('lazySink'),
|
|
requiredFunction('fetch'),
|
|
optionFunction('getBounds'),
|
|
optionObjOf('fireDismissalEventInstead', [defaulted('event', dismissRequested())]),
|
|
schema$y()
|
|
]);
|
|
var parts$6 = constant$1([
|
|
external$1({
|
|
name: 'button',
|
|
overrides: function (detail) {
|
|
return {
|
|
dom: { attributes: { 'aria-haspopup': 'true' } },
|
|
buttonBehaviours: derive$1([Toggling.config({
|
|
toggleClass: detail.markers.toggledClass,
|
|
aria: { mode: 'expanded' },
|
|
toggleOnExecute: false
|
|
})])
|
|
};
|
|
}
|
|
}),
|
|
external$1({
|
|
factory: Toolbar,
|
|
schema: schema$e(),
|
|
name: 'toolbar',
|
|
overrides: function (detail) {
|
|
return {
|
|
toolbarBehaviours: derive$1([Keying.config({
|
|
mode: 'cyclic',
|
|
onEscape: function (comp) {
|
|
getPart(comp, detail, 'button').each(Focusing.focus);
|
|
return Optional.none();
|
|
}
|
|
})])
|
|
};
|
|
}
|
|
})
|
|
]);
|
|
|
|
var toggle = function (button, externals) {
|
|
var toolbarSandbox = Coupling.getCoupled(button, 'toolbarSandbox');
|
|
if (Sandboxing.isOpen(toolbarSandbox)) {
|
|
Sandboxing.close(toolbarSandbox);
|
|
} else {
|
|
Sandboxing.open(toolbarSandbox, externals.toolbar());
|
|
}
|
|
};
|
|
var position = function (button, toolbar, detail, layouts) {
|
|
var bounds = detail.getBounds.map(function (bounder) {
|
|
return bounder();
|
|
});
|
|
var sink = detail.lazySink(button).getOrDie();
|
|
Positioning.positionWithinBounds(sink, toolbar, {
|
|
anchor: {
|
|
type: 'hotspot',
|
|
hotspot: button,
|
|
layouts: layouts,
|
|
overrides: { maxWidthFunction: expandable() }
|
|
}
|
|
}, bounds);
|
|
};
|
|
var setGroups = function (button, toolbar, detail, layouts, groups) {
|
|
Toolbar.setGroups(toolbar, groups);
|
|
position(button, toolbar, detail, layouts);
|
|
Toggling.on(button);
|
|
};
|
|
var makeSandbox = function (button, spec, detail) {
|
|
var ariaOwner = manager();
|
|
var onOpen = function (sandbox, toolbar) {
|
|
detail.fetch().get(function (groups) {
|
|
setGroups(button, toolbar, detail, spec.layouts, groups);
|
|
ariaOwner.link(button.element);
|
|
Keying.focusIn(toolbar);
|
|
});
|
|
};
|
|
var onClose = function () {
|
|
Toggling.off(button);
|
|
Focusing.focus(button);
|
|
ariaOwner.unlink(button.element);
|
|
};
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { id: ariaOwner.id }
|
|
},
|
|
behaviours: derive$1([
|
|
Keying.config({
|
|
mode: 'special',
|
|
onEscape: function (comp) {
|
|
Sandboxing.close(comp);
|
|
return Optional.some(true);
|
|
}
|
|
}),
|
|
Sandboxing.config({
|
|
onOpen: onOpen,
|
|
onClose: onClose,
|
|
isPartOf: function (container, data, queryElem) {
|
|
return isPartOf$1(data, queryElem) || isPartOf$1(button, queryElem);
|
|
},
|
|
getAttachPoint: function () {
|
|
return detail.lazySink(button).getOrDie();
|
|
}
|
|
}),
|
|
Receiving.config({
|
|
channels: __assign(__assign({}, receivingChannel$1(__assign({ isExtraPart: never }, detail.fireDismissalEventInstead.map(function (fe) {
|
|
return { fireEventInstead: { event: fe.event } };
|
|
}).getOr({})))), receivingChannel({
|
|
doReposition: function () {
|
|
Sandboxing.getState(Coupling.getCoupled(button, 'toolbarSandbox')).each(function (toolbar) {
|
|
position(button, toolbar, detail, spec.layouts);
|
|
});
|
|
}
|
|
}))
|
|
})
|
|
])
|
|
};
|
|
};
|
|
var factory$a = function (detail, components, spec, externals) {
|
|
return __assign(__assign({}, Button.sketch(__assign(__assign({}, externals.button()), {
|
|
action: function (button) {
|
|
toggle(button, externals);
|
|
},
|
|
buttonBehaviours: SketchBehaviours.augment({ dump: externals.button().buttonBehaviours }, [Coupling.config({
|
|
others: {
|
|
toolbarSandbox: function (button) {
|
|
return makeSandbox(button, spec, detail);
|
|
}
|
|
}
|
|
})])
|
|
}))), {
|
|
apis: {
|
|
setGroups: function (button, groups) {
|
|
Sandboxing.getState(Coupling.getCoupled(button, 'toolbarSandbox')).each(function (toolbar) {
|
|
setGroups(button, toolbar, detail, spec.layouts, groups);
|
|
});
|
|
},
|
|
reposition: function (button) {
|
|
Sandboxing.getState(Coupling.getCoupled(button, 'toolbarSandbox')).each(function (toolbar) {
|
|
position(button, toolbar, detail, spec.layouts);
|
|
});
|
|
},
|
|
toggle: function (button) {
|
|
toggle(button, externals);
|
|
},
|
|
getToolbar: function (button) {
|
|
return Sandboxing.getState(Coupling.getCoupled(button, 'toolbarSandbox'));
|
|
},
|
|
isOpen: function (button) {
|
|
return Sandboxing.isOpen(Coupling.getCoupled(button, 'toolbarSandbox'));
|
|
}
|
|
}
|
|
});
|
|
};
|
|
var FloatingToolbarButton = composite({
|
|
name: 'FloatingToolbarButton',
|
|
factory: factory$a,
|
|
configFields: schema$a(),
|
|
partFields: parts$6(),
|
|
apis: {
|
|
setGroups: function (apis, button, groups) {
|
|
apis.setGroups(button, groups);
|
|
},
|
|
reposition: function (apis, button) {
|
|
apis.reposition(button);
|
|
},
|
|
toggle: function (apis, button) {
|
|
apis.toggle(button);
|
|
},
|
|
getToolbar: function (apis, button) {
|
|
return apis.getToolbar(button);
|
|
},
|
|
isOpen: function (apis, button) {
|
|
return apis.isOpen(button);
|
|
}
|
|
}
|
|
});
|
|
|
|
var schema$9 = constant$1([
|
|
required$1('items'),
|
|
markers$1(['itemSelector']),
|
|
field('tgroupBehaviours', [Keying])
|
|
]);
|
|
var parts$5 = constant$1([group({
|
|
name: 'items',
|
|
unit: 'item'
|
|
})]);
|
|
|
|
var factory$9 = function (detail, components, _spec, _externals) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.tgroupBehaviours, [Keying.config({
|
|
mode: 'flow',
|
|
selector: detail.markers.itemSelector
|
|
})]),
|
|
domModification: { attributes: { role: 'toolbar' } }
|
|
};
|
|
};
|
|
var ToolbarGroup = composite({
|
|
name: 'ToolbarGroup',
|
|
configFields: schema$9(),
|
|
partFields: parts$5(),
|
|
factory: factory$9
|
|
});
|
|
|
|
var buildGroups = function (comps) {
|
|
return map$2(comps, function (g) {
|
|
return premade(g);
|
|
});
|
|
};
|
|
var refresh$1 = function (toolbar, memFloatingToolbarButton, detail) {
|
|
refresh$2(toolbar, detail, function (overflowGroups) {
|
|
detail.overflowGroups.set(overflowGroups);
|
|
memFloatingToolbarButton.getOpt(toolbar).each(function (floatingToolbarButton) {
|
|
FloatingToolbarButton.setGroups(floatingToolbarButton, buildGroups(overflowGroups));
|
|
});
|
|
});
|
|
};
|
|
var factory$8 = function (detail, components, spec, externals) {
|
|
var memFloatingToolbarButton = record(FloatingToolbarButton.sketch({
|
|
fetch: function () {
|
|
return Future.nu(function (resolve) {
|
|
resolve(buildGroups(detail.overflowGroups.get()));
|
|
});
|
|
},
|
|
layouts: {
|
|
onLtr: function () {
|
|
return [
|
|
southwest$2,
|
|
southeast$2
|
|
];
|
|
},
|
|
onRtl: function () {
|
|
return [
|
|
southeast$2,
|
|
southwest$2
|
|
];
|
|
},
|
|
onBottomLtr: function () {
|
|
return [
|
|
northwest$2,
|
|
northeast$2
|
|
];
|
|
},
|
|
onBottomRtl: function () {
|
|
return [
|
|
northeast$2,
|
|
northwest$2
|
|
];
|
|
}
|
|
},
|
|
getBounds: spec.getOverflowBounds,
|
|
lazySink: detail.lazySink,
|
|
fireDismissalEventInstead: {},
|
|
markers: { toggledClass: detail.markers.overflowToggledClass },
|
|
parts: {
|
|
button: externals['overflow-button'](),
|
|
toolbar: externals.overflow()
|
|
}
|
|
}));
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.splitToolbarBehaviours, [Coupling.config({
|
|
others: {
|
|
overflowGroup: function () {
|
|
return ToolbarGroup.sketch(__assign(__assign({}, externals['overflow-group']()), { items: [memFloatingToolbarButton.asSpec()] }));
|
|
}
|
|
}
|
|
})]),
|
|
apis: {
|
|
setGroups: function (toolbar, groups) {
|
|
detail.builtGroups.set(map$2(groups, toolbar.getSystem().build));
|
|
refresh$1(toolbar, memFloatingToolbarButton, detail);
|
|
},
|
|
refresh: function (toolbar) {
|
|
return refresh$1(toolbar, memFloatingToolbarButton, detail);
|
|
},
|
|
toggle: function (toolbar) {
|
|
memFloatingToolbarButton.getOpt(toolbar).each(function (floatingToolbarButton) {
|
|
FloatingToolbarButton.toggle(floatingToolbarButton);
|
|
});
|
|
},
|
|
isOpen: function (toolbar) {
|
|
return memFloatingToolbarButton.getOpt(toolbar).map(FloatingToolbarButton.isOpen).getOr(false);
|
|
},
|
|
reposition: function (toolbar) {
|
|
memFloatingToolbarButton.getOpt(toolbar).each(function (floatingToolbarButton) {
|
|
FloatingToolbarButton.reposition(floatingToolbarButton);
|
|
});
|
|
},
|
|
getOverflow: function (toolbar) {
|
|
return memFloatingToolbarButton.getOpt(toolbar).bind(FloatingToolbarButton.getToolbar);
|
|
}
|
|
},
|
|
domModification: { attributes: { role: 'group' } }
|
|
};
|
|
};
|
|
var SplitFloatingToolbar = composite({
|
|
name: 'SplitFloatingToolbar',
|
|
configFields: schema$b(),
|
|
partFields: parts$7(),
|
|
factory: factory$8,
|
|
apis: {
|
|
setGroups: function (apis, toolbar, groups) {
|
|
apis.setGroups(toolbar, groups);
|
|
},
|
|
refresh: function (apis, toolbar) {
|
|
apis.refresh(toolbar);
|
|
},
|
|
reposition: function (apis, toolbar) {
|
|
apis.reposition(toolbar);
|
|
},
|
|
toggle: function (apis, toolbar) {
|
|
apis.toggle(toolbar);
|
|
},
|
|
isOpen: function (apis, toolbar) {
|
|
return apis.isOpen(toolbar);
|
|
},
|
|
getOverflow: function (apis, toolbar) {
|
|
return apis.getOverflow(toolbar);
|
|
}
|
|
}
|
|
});
|
|
|
|
var schema$8 = constant$1([
|
|
markers$1([
|
|
'closedClass',
|
|
'openClass',
|
|
'shrinkingClass',
|
|
'growingClass',
|
|
'overflowToggledClass'
|
|
]),
|
|
onHandler('onOpened'),
|
|
onHandler('onClosed')
|
|
].concat(schema$c()));
|
|
var parts$4 = constant$1([
|
|
required({
|
|
factory: Toolbar,
|
|
schema: schema$e(),
|
|
name: 'primary'
|
|
}),
|
|
required({
|
|
factory: Toolbar,
|
|
schema: schema$e(),
|
|
name: 'overflow',
|
|
overrides: function (detail) {
|
|
return {
|
|
toolbarBehaviours: derive$1([
|
|
Sliding.config({
|
|
dimension: { property: 'height' },
|
|
closedClass: detail.markers.closedClass,
|
|
openClass: detail.markers.openClass,
|
|
shrinkingClass: detail.markers.shrinkingClass,
|
|
growingClass: detail.markers.growingClass,
|
|
onShrunk: function (comp) {
|
|
getPart(comp, detail, 'overflow-button').each(function (button) {
|
|
Toggling.off(button);
|
|
Focusing.focus(button);
|
|
});
|
|
detail.onClosed(comp);
|
|
},
|
|
onGrown: function (comp) {
|
|
Keying.focusIn(comp);
|
|
detail.onOpened(comp);
|
|
},
|
|
onStartGrow: function (comp) {
|
|
getPart(comp, detail, 'overflow-button').each(Toggling.on);
|
|
}
|
|
}),
|
|
Keying.config({
|
|
mode: 'acyclic',
|
|
onEscape: function (comp) {
|
|
getPart(comp, detail, 'overflow-button').each(Focusing.focus);
|
|
return Optional.some(true);
|
|
}
|
|
})
|
|
])
|
|
};
|
|
}
|
|
}),
|
|
external$1({
|
|
name: 'overflow-button',
|
|
overrides: function (detail) {
|
|
return {
|
|
buttonBehaviours: derive$1([Toggling.config({
|
|
toggleClass: detail.markers.overflowToggledClass,
|
|
aria: { mode: 'pressed' },
|
|
toggleOnExecute: false
|
|
})])
|
|
};
|
|
}
|
|
}),
|
|
external$1({ name: 'overflow-group' })
|
|
]);
|
|
|
|
var isOpen = function (toolbar, detail) {
|
|
return getPart(toolbar, detail, 'overflow').map(Sliding.hasGrown).getOr(false);
|
|
};
|
|
var toggleToolbar = function (toolbar, detail) {
|
|
getPart(toolbar, detail, 'overflow-button').bind(function () {
|
|
return getPart(toolbar, detail, 'overflow');
|
|
}).each(function (overf) {
|
|
refresh(toolbar, detail);
|
|
Sliding.toggleGrow(overf);
|
|
});
|
|
};
|
|
var refresh = function (toolbar, detail) {
|
|
getPart(toolbar, detail, 'overflow').each(function (overflow) {
|
|
refresh$2(toolbar, detail, function (groups) {
|
|
var builtGroups = map$2(groups, function (g) {
|
|
return premade(g);
|
|
});
|
|
Toolbar.setGroups(overflow, builtGroups);
|
|
});
|
|
getPart(toolbar, detail, 'overflow-button').each(function (button) {
|
|
if (Sliding.hasGrown(overflow)) {
|
|
Toggling.on(button);
|
|
}
|
|
});
|
|
Sliding.refresh(overflow);
|
|
});
|
|
};
|
|
var factory$7 = function (detail, components, spec, externals) {
|
|
var toolbarToggleEvent = 'alloy.toolbar.toggle';
|
|
var doSetGroups = function (toolbar, groups) {
|
|
var built = map$2(groups, toolbar.getSystem().build);
|
|
detail.builtGroups.set(built);
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.splitToolbarBehaviours, [
|
|
Coupling.config({
|
|
others: {
|
|
overflowGroup: function (toolbar) {
|
|
return ToolbarGroup.sketch(__assign(__assign({}, externals['overflow-group']()), {
|
|
items: [Button.sketch(__assign(__assign({}, externals['overflow-button']()), {
|
|
action: function (_button) {
|
|
emit(toolbar, toolbarToggleEvent);
|
|
}
|
|
}))]
|
|
}));
|
|
}
|
|
}
|
|
}),
|
|
config('toolbar-toggle-events', [run$1(toolbarToggleEvent, function (toolbar) {
|
|
toggleToolbar(toolbar, detail);
|
|
})])
|
|
]),
|
|
apis: {
|
|
setGroups: function (toolbar, groups) {
|
|
doSetGroups(toolbar, groups);
|
|
refresh(toolbar, detail);
|
|
},
|
|
refresh: function (toolbar) {
|
|
return refresh(toolbar, detail);
|
|
},
|
|
toggle: function (toolbar) {
|
|
return toggleToolbar(toolbar, detail);
|
|
},
|
|
isOpen: function (toolbar) {
|
|
return isOpen(toolbar, detail);
|
|
}
|
|
},
|
|
domModification: { attributes: { role: 'group' } }
|
|
};
|
|
};
|
|
var SplitSlidingToolbar = composite({
|
|
name: 'SplitSlidingToolbar',
|
|
configFields: schema$8(),
|
|
partFields: parts$4(),
|
|
factory: factory$7,
|
|
apis: {
|
|
setGroups: function (apis, toolbar, groups) {
|
|
apis.setGroups(toolbar, groups);
|
|
},
|
|
refresh: function (apis, toolbar) {
|
|
apis.refresh(toolbar);
|
|
},
|
|
toggle: function (apis, toolbar) {
|
|
apis.toggle(toolbar);
|
|
},
|
|
isOpen: function (apis, toolbar) {
|
|
return apis.isOpen(toolbar);
|
|
}
|
|
}
|
|
});
|
|
|
|
var renderToolbarGroupCommon = function (toolbarGroup) {
|
|
var attributes = toolbarGroup.title.fold(function () {
|
|
return {};
|
|
}, function (title) {
|
|
return { attributes: { title: title } };
|
|
});
|
|
return {
|
|
dom: __assign({
|
|
tag: 'div',
|
|
classes: ['tox-toolbar__group']
|
|
}, attributes),
|
|
components: [ToolbarGroup.parts.items({})],
|
|
items: toolbarGroup.items,
|
|
markers: { itemSelector: '*:not(.tox-split-button) > .tox-tbtn:not([disabled]), ' + '.tox-split-button:not([disabled]), ' + '.tox-toolbar-nav-js:not([disabled])' },
|
|
tgroupBehaviours: derive$1([
|
|
Tabstopping.config({}),
|
|
Focusing.config({})
|
|
])
|
|
};
|
|
};
|
|
var renderToolbarGroup = function (toolbarGroup) {
|
|
return ToolbarGroup.sketch(renderToolbarGroupCommon(toolbarGroup));
|
|
};
|
|
var getToolbarbehaviours = function (toolbarSpec, modeName) {
|
|
var onAttached = runOnAttached(function (component) {
|
|
var groups = map$2(toolbarSpec.initGroups, renderToolbarGroup);
|
|
Toolbar.setGroups(component, groups);
|
|
});
|
|
return derive$1([
|
|
DisablingConfigs.toolbarButton(toolbarSpec.providers.isDisabled),
|
|
receivingConfig(),
|
|
Keying.config({
|
|
mode: modeName,
|
|
onEscape: toolbarSpec.onEscape,
|
|
selector: '.tox-toolbar__group'
|
|
}),
|
|
config('toolbar-events', [onAttached])
|
|
]);
|
|
};
|
|
var renderMoreToolbarCommon = function (toolbarSpec) {
|
|
var modeName = toolbarSpec.cyclicKeying ? 'cyclic' : 'acyclic';
|
|
return {
|
|
uid: toolbarSpec.uid,
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar-overlord']
|
|
},
|
|
parts: {
|
|
'overflow-group': renderToolbarGroupCommon({
|
|
title: Optional.none(),
|
|
items: []
|
|
}),
|
|
'overflow-button': renderIconButtonSpec({
|
|
name: 'more',
|
|
icon: Optional.some('more-drawer'),
|
|
disabled: false,
|
|
tooltip: Optional.some('More...'),
|
|
primary: false,
|
|
borderless: false
|
|
}, Optional.none(), toolbarSpec.providers)
|
|
},
|
|
splitToolbarBehaviours: getToolbarbehaviours(toolbarSpec, modeName)
|
|
};
|
|
};
|
|
var renderFloatingMoreToolbar = function (toolbarSpec) {
|
|
var baseSpec = renderMoreToolbarCommon(toolbarSpec);
|
|
var overflowXOffset = 4;
|
|
var primary = SplitFloatingToolbar.parts.primary({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar__primary']
|
|
}
|
|
});
|
|
return SplitFloatingToolbar.sketch(__assign(__assign({}, baseSpec), {
|
|
lazySink: toolbarSpec.getSink,
|
|
getOverflowBounds: function () {
|
|
var headerElem = toolbarSpec.moreDrawerData.lazyHeader().element;
|
|
var headerBounds = absolute$2(headerElem);
|
|
var docElem = documentElement(headerElem);
|
|
var docBounds = absolute$2(docElem);
|
|
var height = Math.max(docElem.dom.scrollHeight, docBounds.height);
|
|
return bounds(headerBounds.x + overflowXOffset, docBounds.y, headerBounds.width - overflowXOffset * 2, height);
|
|
},
|
|
parts: __assign(__assign({}, baseSpec.parts), {
|
|
overflow: {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar__overflow'],
|
|
attributes: toolbarSpec.attributes
|
|
}
|
|
}
|
|
}),
|
|
components: [primary],
|
|
markers: { overflowToggledClass: 'tox-tbtn--enabled' }
|
|
}));
|
|
};
|
|
var renderSlidingMoreToolbar = function (toolbarSpec) {
|
|
var primary = SplitSlidingToolbar.parts.primary({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar__primary']
|
|
}
|
|
});
|
|
var overflow = SplitSlidingToolbar.parts.overflow({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar__overflow']
|
|
}
|
|
});
|
|
var baseSpec = renderMoreToolbarCommon(toolbarSpec);
|
|
return SplitSlidingToolbar.sketch(__assign(__assign({}, baseSpec), {
|
|
components: [
|
|
primary,
|
|
overflow
|
|
],
|
|
markers: {
|
|
openClass: 'tox-toolbar__overflow--open',
|
|
closedClass: 'tox-toolbar__overflow--closed',
|
|
growingClass: 'tox-toolbar__overflow--growing',
|
|
shrinkingClass: 'tox-toolbar__overflow--shrinking',
|
|
overflowToggledClass: 'tox-tbtn--enabled'
|
|
},
|
|
onOpened: function (comp) {
|
|
comp.getSystem().broadcastOn([toolbarHeightChange()], { type: 'opened' });
|
|
},
|
|
onClosed: function (comp) {
|
|
comp.getSystem().broadcastOn([toolbarHeightChange()], { type: 'closed' });
|
|
}
|
|
}));
|
|
};
|
|
var renderToolbar = function (toolbarSpec) {
|
|
var modeName = toolbarSpec.cyclicKeying ? 'cyclic' : 'acyclic';
|
|
return Toolbar.sketch({
|
|
uid: toolbarSpec.uid,
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar'].concat(toolbarSpec.type === ToolbarMode.scrolling ? ['tox-toolbar--scrolling'] : [])
|
|
},
|
|
components: [Toolbar.parts.groups({})],
|
|
toolbarBehaviours: getToolbarbehaviours(toolbarSpec, modeName)
|
|
});
|
|
};
|
|
|
|
var factory$6 = function (detail, components, _spec) {
|
|
var apis = {
|
|
getSocket: function (comp) {
|
|
return parts$a.getPart(comp, detail, 'socket');
|
|
},
|
|
setSidebar: function (comp, panelConfigs) {
|
|
parts$a.getPart(comp, detail, 'sidebar').each(function (sidebar) {
|
|
return setSidebar(sidebar, panelConfigs);
|
|
});
|
|
},
|
|
toggleSidebar: function (comp, name) {
|
|
parts$a.getPart(comp, detail, 'sidebar').each(function (sidebar) {
|
|
return toggleSidebar(sidebar, name);
|
|
});
|
|
},
|
|
whichSidebar: function (comp) {
|
|
return parts$a.getPart(comp, detail, 'sidebar').bind(whichSidebar).getOrNull();
|
|
},
|
|
getHeader: function (comp) {
|
|
return parts$a.getPart(comp, detail, 'header');
|
|
},
|
|
getToolbar: function (comp) {
|
|
return parts$a.getPart(comp, detail, 'toolbar');
|
|
},
|
|
setToolbar: function (comp, groups) {
|
|
parts$a.getPart(comp, detail, 'toolbar').each(function (toolbar) {
|
|
toolbar.getApis().setGroups(toolbar, groups);
|
|
});
|
|
},
|
|
setToolbars: function (comp, toolbars) {
|
|
parts$a.getPart(comp, detail, 'multiple-toolbar').each(function (mToolbar) {
|
|
CustomList.setItems(mToolbar, toolbars);
|
|
});
|
|
},
|
|
refreshToolbar: function (comp) {
|
|
var toolbar = parts$a.getPart(comp, detail, 'toolbar');
|
|
toolbar.each(function (toolbar) {
|
|
return toolbar.getApis().refresh(toolbar);
|
|
});
|
|
},
|
|
toggleToolbarDrawer: function (comp) {
|
|
parts$a.getPart(comp, detail, 'toolbar').each(function (toolbar) {
|
|
mapFrom(toolbar.getApis().toggle, function (toggle) {
|
|
return toggle(toolbar);
|
|
});
|
|
});
|
|
},
|
|
isToolbarDrawerToggled: function (comp) {
|
|
return parts$a.getPart(comp, detail, 'toolbar').bind(function (toolbar) {
|
|
return Optional.from(toolbar.getApis().isOpen).map(function (isOpen) {
|
|
return isOpen(toolbar);
|
|
});
|
|
}).getOr(false);
|
|
},
|
|
getThrobber: function (comp) {
|
|
return parts$a.getPart(comp, detail, 'throbber');
|
|
},
|
|
focusToolbar: function (comp) {
|
|
var optToolbar = parts$a.getPart(comp, detail, 'toolbar').orThunk(function () {
|
|
return parts$a.getPart(comp, detail, 'multiple-toolbar');
|
|
});
|
|
optToolbar.each(function (toolbar) {
|
|
Keying.focusIn(toolbar);
|
|
});
|
|
},
|
|
setMenubar: function (comp, menus) {
|
|
parts$a.getPart(comp, detail, 'menubar').each(function (menubar) {
|
|
SilverMenubar.setMenus(menubar, menus);
|
|
});
|
|
},
|
|
focusMenubar: function (comp) {
|
|
parts$a.getPart(comp, detail, 'menubar').each(function (menubar) {
|
|
SilverMenubar.focus(menubar);
|
|
});
|
|
}
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
apis: apis,
|
|
behaviours: detail.behaviours
|
|
};
|
|
};
|
|
var partMenubar = partType.optional({
|
|
factory: SilverMenubar,
|
|
name: 'menubar',
|
|
schema: [required$1('backstage')]
|
|
});
|
|
var toolbarFactory = function (spec) {
|
|
if (spec.type === ToolbarMode.sliding) {
|
|
return renderSlidingMoreToolbar;
|
|
} else if (spec.type === ToolbarMode.floating) {
|
|
return renderFloatingMoreToolbar;
|
|
} else {
|
|
return renderToolbar;
|
|
}
|
|
};
|
|
var partMultipleToolbar = partType.optional({
|
|
factory: {
|
|
sketch: function (spec) {
|
|
return CustomList.sketch({
|
|
uid: spec.uid,
|
|
dom: spec.dom,
|
|
listBehaviours: derive$1([Keying.config({
|
|
mode: 'acyclic',
|
|
selector: '.tox-toolbar'
|
|
})]),
|
|
makeItem: function () {
|
|
return renderToolbar({
|
|
type: spec.type,
|
|
uid: generate$6('multiple-toolbar-item'),
|
|
cyclicKeying: false,
|
|
initGroups: [],
|
|
providers: spec.providers,
|
|
onEscape: function () {
|
|
spec.onEscape();
|
|
return Optional.some(true);
|
|
}
|
|
});
|
|
},
|
|
setupItem: function (_mToolbar, tc, data, _index) {
|
|
Toolbar.setGroups(tc, data);
|
|
},
|
|
shell: true
|
|
});
|
|
}
|
|
},
|
|
name: 'multiple-toolbar',
|
|
schema: [
|
|
required$1('dom'),
|
|
required$1('onEscape')
|
|
]
|
|
});
|
|
var partToolbar = partType.optional({
|
|
factory: {
|
|
sketch: function (spec) {
|
|
var renderer = toolbarFactory(spec);
|
|
var toolbarSpec = {
|
|
type: spec.type,
|
|
uid: spec.uid,
|
|
onEscape: function () {
|
|
spec.onEscape();
|
|
return Optional.some(true);
|
|
},
|
|
cyclicKeying: false,
|
|
initGroups: [],
|
|
getSink: spec.getSink,
|
|
providers: spec.providers,
|
|
moreDrawerData: {
|
|
lazyToolbar: spec.lazyToolbar,
|
|
lazyMoreButton: spec.lazyMoreButton,
|
|
lazyHeader: spec.lazyHeader
|
|
},
|
|
attributes: spec.attributes
|
|
};
|
|
return renderer(toolbarSpec);
|
|
}
|
|
},
|
|
name: 'toolbar',
|
|
schema: [
|
|
required$1('dom'),
|
|
required$1('onEscape'),
|
|
required$1('getSink')
|
|
]
|
|
});
|
|
var partHeader = partType.optional({
|
|
factory: { sketch: renderHeader },
|
|
name: 'header',
|
|
schema: [required$1('dom')]
|
|
});
|
|
var partSocket = partType.optional({
|
|
name: 'socket',
|
|
schema: [required$1('dom')]
|
|
});
|
|
var partSidebar = partType.optional({
|
|
factory: { sketch: renderSidebar },
|
|
name: 'sidebar',
|
|
schema: [required$1('dom')]
|
|
});
|
|
var partThrobber = partType.optional({
|
|
factory: { sketch: renderThrobber },
|
|
name: 'throbber',
|
|
schema: [required$1('dom')]
|
|
});
|
|
var OuterContainer = composite({
|
|
name: 'OuterContainer',
|
|
factory: factory$6,
|
|
configFields: [
|
|
required$1('dom'),
|
|
required$1('behaviours')
|
|
],
|
|
partFields: [
|
|
partHeader,
|
|
partMenubar,
|
|
partToolbar,
|
|
partMultipleToolbar,
|
|
partSocket,
|
|
partSidebar,
|
|
partThrobber
|
|
],
|
|
apis: {
|
|
getSocket: function (apis, comp) {
|
|
return apis.getSocket(comp);
|
|
},
|
|
setSidebar: function (apis, comp, panelConfigs) {
|
|
apis.setSidebar(comp, panelConfigs);
|
|
},
|
|
toggleSidebar: function (apis, comp, name) {
|
|
apis.toggleSidebar(comp, name);
|
|
},
|
|
whichSidebar: function (apis, comp) {
|
|
return apis.whichSidebar(comp);
|
|
},
|
|
getHeader: function (apis, comp) {
|
|
return apis.getHeader(comp);
|
|
},
|
|
getToolbar: function (apis, comp) {
|
|
return apis.getToolbar(comp);
|
|
},
|
|
setToolbar: function (apis, comp, grps) {
|
|
var groups = map$2(grps, function (grp) {
|
|
return renderToolbarGroup(grp);
|
|
});
|
|
apis.setToolbar(comp, groups);
|
|
},
|
|
setToolbars: function (apis, comp, ts) {
|
|
var renderedToolbars = map$2(ts, function (g) {
|
|
return map$2(g, renderToolbarGroup);
|
|
});
|
|
apis.setToolbars(comp, renderedToolbars);
|
|
},
|
|
refreshToolbar: function (apis, comp) {
|
|
return apis.refreshToolbar(comp);
|
|
},
|
|
toggleToolbarDrawer: function (apis, comp) {
|
|
apis.toggleToolbarDrawer(comp);
|
|
},
|
|
isToolbarDrawerToggled: function (apis, comp) {
|
|
return apis.isToolbarDrawerToggled(comp);
|
|
},
|
|
getThrobber: function (apis, comp) {
|
|
return apis.getThrobber(comp);
|
|
},
|
|
setMenubar: function (apis, comp, menus) {
|
|
apis.setMenubar(comp, menus);
|
|
},
|
|
focusMenubar: function (apis, comp) {
|
|
apis.focusMenubar(comp);
|
|
},
|
|
focusToolbar: function (apis, comp) {
|
|
apis.focusToolbar(comp);
|
|
}
|
|
}
|
|
});
|
|
|
|
var defaultMenubar = 'file edit view insert format tools table help';
|
|
var defaultMenus = {
|
|
file: {
|
|
title: 'File',
|
|
items: 'newdocument restoredraft | preview | export print | deleteallconversations'
|
|
},
|
|
edit: {
|
|
title: 'Edit',
|
|
items: 'undo redo | cut copy paste pastetext | selectall | searchreplace'
|
|
},
|
|
view: {
|
|
title: 'View',
|
|
items: 'code | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments'
|
|
},
|
|
insert: {
|
|
title: 'Insert',
|
|
items: 'image link media addcomment pageembed template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor toc | insertdatetime'
|
|
},
|
|
format: {
|
|
title: 'Format',
|
|
items: 'bold italic underline strikethrough superscript subscript codeformat | formats blockformats fontformats fontsizes align lineheight | forecolor backcolor | language | removeformat'
|
|
},
|
|
tools: {
|
|
title: 'Tools',
|
|
items: 'spellchecker spellcheckerlanguage | a11ycheck code wordcount'
|
|
},
|
|
table: {
|
|
title: 'Table',
|
|
items: 'inserttable | cell row column | advtablesort | tableprops deletetable'
|
|
},
|
|
help: {
|
|
title: 'Help',
|
|
items: 'help'
|
|
}
|
|
};
|
|
var make = function (menu, registry, editor) {
|
|
var removedMenuItems = getRemovedMenuItems(editor).split(/[ ,]/);
|
|
return {
|
|
text: menu.title,
|
|
getItems: function () {
|
|
return bind$3(menu.items, function (i) {
|
|
var itemName = i.toLowerCase();
|
|
if (itemName.trim().length === 0) {
|
|
return [];
|
|
} else if (exists(removedMenuItems, function (removedMenuItem) {
|
|
return removedMenuItem === itemName;
|
|
})) {
|
|
return [];
|
|
} else if (itemName === 'separator' || itemName === '|') {
|
|
return [{ type: 'separator' }];
|
|
} else if (registry.menuItems[itemName]) {
|
|
return [registry.menuItems[itemName]];
|
|
} else {
|
|
return [];
|
|
}
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var parseItemsString = function (items) {
|
|
if (typeof items === 'string') {
|
|
return items.split(' ');
|
|
}
|
|
return items;
|
|
};
|
|
var identifyMenus = function (editor, registry) {
|
|
var rawMenuData = __assign(__assign({}, defaultMenus), registry.menus);
|
|
var userDefinedMenus = keys(registry.menus).length > 0;
|
|
var menubar = registry.menubar === undefined || registry.menubar === true ? parseItemsString(defaultMenubar) : parseItemsString(registry.menubar === false ? '' : registry.menubar);
|
|
var validMenus = filter$2(menubar, function (menuName) {
|
|
var isDefaultMenu = has$2(defaultMenus, menuName);
|
|
if (userDefinedMenus) {
|
|
return isDefaultMenu || get$e(registry.menus, menuName).exists(function (menu) {
|
|
return has$2(menu, 'items');
|
|
});
|
|
} else {
|
|
return isDefaultMenu;
|
|
}
|
|
});
|
|
var menus = map$2(validMenus, function (menuName) {
|
|
var menuData = rawMenuData[menuName];
|
|
return make({
|
|
title: menuData.title,
|
|
items: parseItemsString(menuData.items)
|
|
}, registry, editor);
|
|
});
|
|
return filter$2(menus, function (menu) {
|
|
var isNotSeparator = function (item) {
|
|
return item.type !== 'separator';
|
|
};
|
|
return menu.getItems().length > 0 && exists(menu.getItems(), isNotSeparator);
|
|
});
|
|
};
|
|
|
|
var fireSkinLoaded = function (editor) {
|
|
var done = function () {
|
|
editor._skinLoaded = true;
|
|
fireSkinLoaded$1(editor);
|
|
};
|
|
return function () {
|
|
if (editor.initialized) {
|
|
done();
|
|
} else {
|
|
editor.on('init', done);
|
|
}
|
|
};
|
|
};
|
|
var fireSkinLoadError = function (editor, err) {
|
|
return function () {
|
|
return fireSkinLoadError$1(editor, { message: err });
|
|
};
|
|
};
|
|
|
|
var loadStylesheet = function (editor, stylesheetUrl, styleSheetLoader) {
|
|
return new global$c(function (resolve, reject) {
|
|
styleSheetLoader.load(stylesheetUrl, resolve, reject);
|
|
editor.on('remove', function () {
|
|
return styleSheetLoader.unload(stylesheetUrl);
|
|
});
|
|
});
|
|
};
|
|
var loadUiSkins = function (editor, skinUrl) {
|
|
var skinUiCss = skinUrl + '/skin.min.css';
|
|
return loadStylesheet(editor, skinUiCss, editor.ui.styleSheetLoader);
|
|
};
|
|
var loadShadowDomUiSkins = function (editor, skinUrl) {
|
|
var isInShadowRoot$1 = isInShadowRoot(SugarElement.fromDom(editor.getElement()));
|
|
if (isInShadowRoot$1) {
|
|
var shadowDomSkinCss = skinUrl + '/skin.shadowdom.min.css';
|
|
return loadStylesheet(editor, shadowDomSkinCss, global$b.DOM.styleSheetLoader);
|
|
} else {
|
|
return global$c.resolve();
|
|
}
|
|
};
|
|
var loadSkin = function (isInline, editor) {
|
|
var skinUrl = getSkinUrl(editor);
|
|
if (skinUrl) {
|
|
editor.contentCSS.push(skinUrl + (isInline ? '/content.inline' : '/content') + '.min.css');
|
|
}
|
|
if (isSkinDisabled(editor) === false && isString(skinUrl)) {
|
|
global$c.all([
|
|
loadUiSkins(editor, skinUrl),
|
|
loadShadowDomUiSkins(editor, skinUrl)
|
|
]).then(fireSkinLoaded(editor), fireSkinLoadError(editor, 'Skin could not be loaded'));
|
|
} else {
|
|
fireSkinLoaded(editor)();
|
|
}
|
|
};
|
|
var iframe = curry(loadSkin, false);
|
|
var inline = curry(loadSkin, true);
|
|
|
|
var onSetupFormatToggle = function (editor, name) {
|
|
return function (api) {
|
|
var boundCallback = unbindable();
|
|
var init = function () {
|
|
api.setActive(editor.formatter.match(name));
|
|
var binding = editor.formatter.formatChanged(name, api.setActive);
|
|
boundCallback.set(binding);
|
|
};
|
|
editor.initialized ? init() : editor.once('init', init);
|
|
return function () {
|
|
editor.off('init', init);
|
|
boundCallback.clear();
|
|
};
|
|
};
|
|
};
|
|
var onSetupEvent = function (editor, event, f) {
|
|
return function (api) {
|
|
var handleEvent = function () {
|
|
return f(api);
|
|
};
|
|
var init = function () {
|
|
f(api);
|
|
editor.on(event, handleEvent);
|
|
};
|
|
editor.initialized ? init() : editor.once('init', init);
|
|
return function () {
|
|
editor.off('init', init);
|
|
editor.off(event, handleEvent);
|
|
};
|
|
};
|
|
};
|
|
var onActionToggleFormat$1 = function (editor) {
|
|
return function (rawItem) {
|
|
return function () {
|
|
editor.undoManager.transact(function () {
|
|
editor.focus();
|
|
editor.execCommand('mceToggleFormat', false, rawItem.format);
|
|
});
|
|
};
|
|
};
|
|
};
|
|
var onActionExecCommand = function (editor, command) {
|
|
return function () {
|
|
return editor.execCommand(command);
|
|
};
|
|
};
|
|
|
|
var generateSelectItems = function (_editor, backstage, spec) {
|
|
var generateItem = function (rawItem, response, disabled, value) {
|
|
var translatedText = backstage.shared.providers.translate(rawItem.title);
|
|
if (rawItem.type === 'separator') {
|
|
return Optional.some({
|
|
type: 'separator',
|
|
text: translatedText
|
|
});
|
|
} else if (rawItem.type === 'submenu') {
|
|
var items = bind$3(rawItem.getStyleItems(), function (si) {
|
|
return validate(si, response, value);
|
|
});
|
|
if (response === 0 && items.length <= 0) {
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.some({
|
|
type: 'nestedmenuitem',
|
|
text: translatedText,
|
|
disabled: items.length <= 0,
|
|
getSubmenuItems: function () {
|
|
return bind$3(rawItem.getStyleItems(), function (si) {
|
|
return validate(si, response, value);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
} else {
|
|
return Optional.some(__assign({
|
|
type: 'togglemenuitem',
|
|
text: translatedText,
|
|
icon: rawItem.icon,
|
|
active: rawItem.isSelected(value),
|
|
disabled: disabled,
|
|
onAction: spec.onAction(rawItem)
|
|
}, rawItem.getStylePreview().fold(function () {
|
|
return {};
|
|
}, function (preview) {
|
|
return { meta: { style: preview } };
|
|
})));
|
|
}
|
|
};
|
|
var validate = function (item, response, value) {
|
|
var invalid = item.type === 'formatter' && spec.isInvalid(item);
|
|
if (response === 0) {
|
|
return invalid ? [] : generateItem(item, response, false, value).toArray();
|
|
} else {
|
|
return generateItem(item, response, invalid, value).toArray();
|
|
}
|
|
};
|
|
var validateItems = function (preItems) {
|
|
var value = spec.getCurrentValue();
|
|
var response = spec.shouldHide ? 0 : 1;
|
|
return bind$3(preItems, function (item) {
|
|
return validate(item, response, value);
|
|
});
|
|
};
|
|
var getFetch = function (backstage, getStyleItems) {
|
|
return function (comp, callback) {
|
|
var preItems = getStyleItems();
|
|
var items = validateItems(preItems);
|
|
var menu = build(items, ItemResponse$1.CLOSE_ON_EXECUTE, backstage, false);
|
|
callback(menu);
|
|
};
|
|
};
|
|
return {
|
|
validateItems: validateItems,
|
|
getFetch: getFetch
|
|
};
|
|
};
|
|
var createMenuItems = function (editor, backstage, spec) {
|
|
var dataset = spec.dataset;
|
|
var getStyleItems = dataset.type === 'basic' ? function () {
|
|
return map$2(dataset.data, function (d) {
|
|
return processBasic(d, spec.isSelectedFor, spec.getPreviewFor);
|
|
});
|
|
} : dataset.getData;
|
|
return {
|
|
items: generateSelectItems(editor, backstage, spec),
|
|
getStyleItems: getStyleItems
|
|
};
|
|
};
|
|
var createSelectButton = function (editor, backstage, spec) {
|
|
var _a = createMenuItems(editor, backstage, spec), items = _a.items, getStyleItems = _a.getStyleItems;
|
|
var getApi = function (comp) {
|
|
return { getComponent: constant$1(comp) };
|
|
};
|
|
var onSetup = onSetupEvent(editor, 'NodeChange', function (api) {
|
|
var comp = api.getComponent();
|
|
spec.updateText(comp);
|
|
});
|
|
return renderCommonDropdown({
|
|
text: spec.icon.isSome() ? Optional.none() : spec.text,
|
|
icon: spec.icon,
|
|
tooltip: Optional.from(spec.tooltip),
|
|
role: Optional.none(),
|
|
fetch: items.getFetch(backstage, getStyleItems),
|
|
onSetup: onSetup,
|
|
getApi: getApi,
|
|
columns: 1,
|
|
presets: 'normal',
|
|
classes: spec.icon.isSome() ? [] : ['bespoke'],
|
|
dropdownBehaviours: []
|
|
}, 'tox-tbtn', backstage.shared);
|
|
};
|
|
|
|
var process = function (rawFormats) {
|
|
return map$2(rawFormats, function (item) {
|
|
var title = item, format = item;
|
|
var values = item.split('=');
|
|
if (values.length > 1) {
|
|
title = values[0];
|
|
format = values[1];
|
|
}
|
|
return {
|
|
title: title,
|
|
format: format
|
|
};
|
|
});
|
|
};
|
|
var buildBasicStaticDataset = function (data) {
|
|
return {
|
|
type: 'basic',
|
|
data: data
|
|
};
|
|
};
|
|
var Delimiter;
|
|
(function (Delimiter) {
|
|
Delimiter[Delimiter['SemiColon'] = 0] = 'SemiColon';
|
|
Delimiter[Delimiter['Space'] = 1] = 'Space';
|
|
}(Delimiter || (Delimiter = {})));
|
|
var split = function (rawFormats, delimiter) {
|
|
if (delimiter === Delimiter.SemiColon) {
|
|
return rawFormats.replace(/;$/, '').split(';');
|
|
} else {
|
|
return rawFormats.split(' ');
|
|
}
|
|
};
|
|
var buildBasicSettingsDataset = function (editor, settingName, defaults, delimiter) {
|
|
var rawFormats = editor.getParam(settingName, defaults, 'string');
|
|
var data = process(split(rawFormats, delimiter));
|
|
return {
|
|
type: 'basic',
|
|
data: data
|
|
};
|
|
};
|
|
|
|
var alignMenuItems = [
|
|
{
|
|
title: 'Left',
|
|
icon: 'align-left',
|
|
format: 'alignleft',
|
|
command: 'JustifyLeft'
|
|
},
|
|
{
|
|
title: 'Center',
|
|
icon: 'align-center',
|
|
format: 'aligncenter',
|
|
command: 'JustifyCenter'
|
|
},
|
|
{
|
|
title: 'Right',
|
|
icon: 'align-right',
|
|
format: 'alignright',
|
|
command: 'JustifyRight'
|
|
},
|
|
{
|
|
title: 'Justify',
|
|
icon: 'align-justify',
|
|
format: 'alignjustify',
|
|
command: 'JustifyFull'
|
|
}
|
|
];
|
|
var getSpec$4 = function (editor) {
|
|
var getMatchingValue = function () {
|
|
return find$5(alignMenuItems, function (item) {
|
|
return editor.formatter.match(item.format);
|
|
});
|
|
};
|
|
var isSelectedFor = function (format) {
|
|
return function () {
|
|
return editor.formatter.match(format);
|
|
};
|
|
};
|
|
var getPreviewFor = function (_format) {
|
|
return Optional.none;
|
|
};
|
|
var updateSelectMenuIcon = function (comp) {
|
|
var match = getMatchingValue();
|
|
var alignment = match.fold(constant$1('left'), function (item) {
|
|
return item.title.toLowerCase();
|
|
});
|
|
emitWith(comp, updateMenuIcon, { icon: 'align-' + alignment });
|
|
};
|
|
var dataset = buildBasicStaticDataset(alignMenuItems);
|
|
var onAction = function (rawItem) {
|
|
return function () {
|
|
return find$5(alignMenuItems, function (item) {
|
|
return item.format === rawItem.format;
|
|
}).each(function (item) {
|
|
return editor.execCommand(item.command);
|
|
});
|
|
};
|
|
};
|
|
return {
|
|
tooltip: 'Align',
|
|
text: Optional.none(),
|
|
icon: Optional.some('align-left'),
|
|
isSelectedFor: isSelectedFor,
|
|
getCurrentValue: Optional.none,
|
|
getPreviewFor: getPreviewFor,
|
|
onAction: onAction,
|
|
updateText: updateSelectMenuIcon,
|
|
dataset: dataset,
|
|
shouldHide: false,
|
|
isInvalid: function (item) {
|
|
return !editor.formatter.canApply(item.format);
|
|
}
|
|
};
|
|
};
|
|
var createAlignSelect = function (editor, backstage) {
|
|
return createSelectButton(editor, backstage, getSpec$4(editor));
|
|
};
|
|
var alignSelectMenu = function (editor, backstage) {
|
|
var menuItems = createMenuItems(editor, backstage, getSpec$4(editor));
|
|
editor.ui.registry.addNestedMenuItem('align', {
|
|
text: backstage.shared.providers.translate('Align'),
|
|
getSubmenuItems: function () {
|
|
return menuItems.items.validateItems(menuItems.getStyleItems());
|
|
}
|
|
});
|
|
};
|
|
|
|
var defaultFontsFormats = 'Andale Mono=andale mono,monospace;' + 'Arial=arial,helvetica,sans-serif;' + 'Arial Black=arial black,sans-serif;' + 'Book Antiqua=book antiqua,palatino,serif;' + 'Comic Sans MS=comic sans ms,sans-serif;' + 'Courier New=courier new,courier,monospace;' + 'Georgia=georgia,palatino,serif;' + 'Helvetica=helvetica,arial,sans-serif;' + 'Impact=impact,sans-serif;' + 'Symbol=symbol;' + 'Tahoma=tahoma,arial,helvetica,sans-serif;' + 'Terminal=terminal,monaco,monospace;' + 'Times New Roman=times new roman,times,serif;' + 'Trebuchet MS=trebuchet ms,geneva,sans-serif;' + 'Verdana=verdana,geneva,sans-serif;' + 'Webdings=webdings;' + 'Wingdings=wingdings,zapf dingbats';
|
|
var systemStackFonts = [
|
|
'-apple-system',
|
|
'Segoe UI',
|
|
'Roboto',
|
|
'Helvetica Neue',
|
|
'sans-serif'
|
|
];
|
|
var splitFonts = function (fontFamily) {
|
|
var fonts = fontFamily.split(/\s*,\s*/);
|
|
return map$2(fonts, function (font) {
|
|
return font.replace(/^['"]+|['"]+$/g, '');
|
|
});
|
|
};
|
|
var isSystemFontStack = function (fontFamily) {
|
|
var matchesSystemStack = function () {
|
|
var fonts = splitFonts(fontFamily.toLowerCase());
|
|
return forall(systemStackFonts, function (font) {
|
|
return fonts.indexOf(font.toLowerCase()) > -1;
|
|
});
|
|
};
|
|
return fontFamily.indexOf('-apple-system') === 0 && matchesSystemStack();
|
|
};
|
|
var getSpec$3 = function (editor) {
|
|
var systemFont = 'System Font';
|
|
var getMatchingValue = function () {
|
|
var getFirstFont = function (fontFamily) {
|
|
return fontFamily ? splitFonts(fontFamily)[0] : '';
|
|
};
|
|
var fontFamily = editor.queryCommandValue('FontName');
|
|
var items = dataset.data;
|
|
var font = fontFamily ? fontFamily.toLowerCase() : '';
|
|
var matchOpt = find$5(items, function (item) {
|
|
var format = item.format;
|
|
return format.toLowerCase() === font || getFirstFont(format).toLowerCase() === getFirstFont(font).toLowerCase();
|
|
}).orThunk(function () {
|
|
return someIf(isSystemFontStack(font), {
|
|
title: systemFont,
|
|
format: font
|
|
});
|
|
});
|
|
return {
|
|
matchOpt: matchOpt,
|
|
font: fontFamily
|
|
};
|
|
};
|
|
var isSelectedFor = function (item) {
|
|
return function (valueOpt) {
|
|
return valueOpt.exists(function (value) {
|
|
return value.format === item;
|
|
});
|
|
};
|
|
};
|
|
var getCurrentValue = function () {
|
|
var matchOpt = getMatchingValue().matchOpt;
|
|
return matchOpt;
|
|
};
|
|
var getPreviewFor = function (item) {
|
|
return function () {
|
|
return Optional.some({
|
|
tag: 'div',
|
|
styles: item.indexOf('dings') === -1 ? { 'font-family': item } : {}
|
|
});
|
|
};
|
|
};
|
|
var onAction = function (rawItem) {
|
|
return function () {
|
|
editor.undoManager.transact(function () {
|
|
editor.focus();
|
|
editor.execCommand('FontName', false, rawItem.format);
|
|
});
|
|
};
|
|
};
|
|
var updateSelectMenuText = function (comp) {
|
|
var _a = getMatchingValue(), matchOpt = _a.matchOpt, font = _a.font;
|
|
var text = matchOpt.fold(constant$1(font), function (item) {
|
|
return item.title;
|
|
});
|
|
emitWith(comp, updateMenuText, { text: text });
|
|
};
|
|
var dataset = buildBasicSettingsDataset(editor, 'font_formats', defaultFontsFormats, Delimiter.SemiColon);
|
|
return {
|
|
tooltip: 'Fonts',
|
|
text: Optional.some(systemFont),
|
|
icon: Optional.none(),
|
|
isSelectedFor: isSelectedFor,
|
|
getCurrentValue: getCurrentValue,
|
|
getPreviewFor: getPreviewFor,
|
|
onAction: onAction,
|
|
updateText: updateSelectMenuText,
|
|
dataset: dataset,
|
|
shouldHide: false,
|
|
isInvalid: never
|
|
};
|
|
};
|
|
var createFontSelect = function (editor, backstage) {
|
|
return createSelectButton(editor, backstage, getSpec$3(editor));
|
|
};
|
|
var fontSelectMenu = function (editor, backstage) {
|
|
var menuItems = createMenuItems(editor, backstage, getSpec$3(editor));
|
|
editor.ui.registry.addNestedMenuItem('fontformats', {
|
|
text: backstage.shared.providers.translate('Fonts'),
|
|
getSubmenuItems: function () {
|
|
return menuItems.items.validateItems(menuItems.getStyleItems());
|
|
}
|
|
});
|
|
};
|
|
|
|
var defaultFontsizeFormats = '8pt 10pt 12pt 14pt 18pt 24pt 36pt';
|
|
var legacyFontSizes = {
|
|
'8pt': '1',
|
|
'10pt': '2',
|
|
'12pt': '3',
|
|
'14pt': '4',
|
|
'18pt': '5',
|
|
'24pt': '6',
|
|
'36pt': '7'
|
|
};
|
|
var keywordFontSizes = {
|
|
'xx-small': '7pt',
|
|
'x-small': '8pt',
|
|
'small': '10pt',
|
|
'medium': '12pt',
|
|
'large': '14pt',
|
|
'x-large': '18pt',
|
|
'xx-large': '24pt'
|
|
};
|
|
var round = function (number, precision) {
|
|
var factor = Math.pow(10, precision);
|
|
return Math.round(number * factor) / factor;
|
|
};
|
|
var toPt = function (fontSize, precision) {
|
|
if (/[0-9.]+px$/.test(fontSize)) {
|
|
return round(parseInt(fontSize, 10) * 72 / 96, precision || 0) + 'pt';
|
|
} else {
|
|
return get$e(keywordFontSizes, fontSize).getOr(fontSize);
|
|
}
|
|
};
|
|
var toLegacy = function (fontSize) {
|
|
return get$e(legacyFontSizes, fontSize).getOr('');
|
|
};
|
|
var getSpec$2 = function (editor) {
|
|
var getMatchingValue = function () {
|
|
var matchOpt = Optional.none();
|
|
var items = dataset.data;
|
|
var fontSize = editor.queryCommandValue('FontSize');
|
|
if (fontSize) {
|
|
var _loop_1 = function (precision) {
|
|
var pt = toPt(fontSize, precision);
|
|
var legacy = toLegacy(pt);
|
|
matchOpt = find$5(items, function (item) {
|
|
return item.format === fontSize || item.format === pt || item.format === legacy;
|
|
});
|
|
};
|
|
for (var precision = 3; matchOpt.isNone() && precision >= 0; precision--) {
|
|
_loop_1(precision);
|
|
}
|
|
}
|
|
return {
|
|
matchOpt: matchOpt,
|
|
size: fontSize
|
|
};
|
|
};
|
|
var isSelectedFor = function (item) {
|
|
return function (valueOpt) {
|
|
return valueOpt.exists(function (value) {
|
|
return value.format === item;
|
|
});
|
|
};
|
|
};
|
|
var getCurrentValue = function () {
|
|
var matchOpt = getMatchingValue().matchOpt;
|
|
return matchOpt;
|
|
};
|
|
var getPreviewFor = constant$1(Optional.none);
|
|
var onAction = function (rawItem) {
|
|
return function () {
|
|
editor.undoManager.transact(function () {
|
|
editor.focus();
|
|
editor.execCommand('FontSize', false, rawItem.format);
|
|
});
|
|
};
|
|
};
|
|
var updateSelectMenuText = function (comp) {
|
|
var _a = getMatchingValue(), matchOpt = _a.matchOpt, size = _a.size;
|
|
var text = matchOpt.fold(constant$1(size), function (match) {
|
|
return match.title;
|
|
});
|
|
emitWith(comp, updateMenuText, { text: text });
|
|
};
|
|
var dataset = buildBasicSettingsDataset(editor, 'fontsize_formats', defaultFontsizeFormats, Delimiter.Space);
|
|
return {
|
|
tooltip: 'Font sizes',
|
|
text: Optional.some('12pt'),
|
|
icon: Optional.none(),
|
|
isSelectedFor: isSelectedFor,
|
|
getPreviewFor: getPreviewFor,
|
|
getCurrentValue: getCurrentValue,
|
|
onAction: onAction,
|
|
updateText: updateSelectMenuText,
|
|
dataset: dataset,
|
|
shouldHide: false,
|
|
isInvalid: never
|
|
};
|
|
};
|
|
var createFontsizeSelect = function (editor, backstage) {
|
|
return createSelectButton(editor, backstage, getSpec$2(editor));
|
|
};
|
|
var fontsizeSelectMenu = function (editor, backstage) {
|
|
var menuItems = createMenuItems(editor, backstage, getSpec$2(editor));
|
|
editor.ui.registry.addNestedMenuItem('fontsizes', {
|
|
text: 'Font sizes',
|
|
getSubmenuItems: function () {
|
|
return menuItems.items.validateItems(menuItems.getStyleItems());
|
|
}
|
|
});
|
|
};
|
|
|
|
var findNearest = function (editor, getStyles) {
|
|
var styles = getStyles();
|
|
var formats = map$2(styles, function (style) {
|
|
return style.format;
|
|
});
|
|
return Optional.from(editor.formatter.closest(formats)).bind(function (fmt) {
|
|
return find$5(styles, function (data) {
|
|
return data.format === fmt;
|
|
});
|
|
}).orThunk(function () {
|
|
return someIf(editor.formatter.match('p'), {
|
|
title: 'Paragraph',
|
|
format: 'p'
|
|
});
|
|
});
|
|
};
|
|
|
|
var defaultBlocks = 'Paragraph=p;' + 'Heading 1=h1;' + 'Heading 2=h2;' + 'Heading 3=h3;' + 'Heading 4=h4;' + 'Heading 5=h5;' + 'Heading 6=h6;' + 'Preformatted=pre';
|
|
var getSpec$1 = function (editor) {
|
|
var fallbackFormat = 'Paragraph';
|
|
var isSelectedFor = function (format) {
|
|
return function () {
|
|
return editor.formatter.match(format);
|
|
};
|
|
};
|
|
var getPreviewFor = function (format) {
|
|
return function () {
|
|
var fmt = editor.formatter.get(format);
|
|
return Optional.some({
|
|
tag: fmt.length > 0 ? fmt[0].inline || fmt[0].block || 'div' : 'div',
|
|
styles: editor.dom.parseStyle(editor.formatter.getCssText(format))
|
|
});
|
|
};
|
|
};
|
|
var updateSelectMenuText = function (comp) {
|
|
var detectedFormat = findNearest(editor, function () {
|
|
return dataset.data;
|
|
});
|
|
var text = detectedFormat.fold(constant$1(fallbackFormat), function (fmt) {
|
|
return fmt.title;
|
|
});
|
|
emitWith(comp, updateMenuText, { text: text });
|
|
};
|
|
var dataset = buildBasicSettingsDataset(editor, 'block_formats', defaultBlocks, Delimiter.SemiColon);
|
|
return {
|
|
tooltip: 'Blocks',
|
|
text: Optional.some(fallbackFormat),
|
|
icon: Optional.none(),
|
|
isSelectedFor: isSelectedFor,
|
|
getCurrentValue: Optional.none,
|
|
getPreviewFor: getPreviewFor,
|
|
onAction: onActionToggleFormat$1(editor),
|
|
updateText: updateSelectMenuText,
|
|
dataset: dataset,
|
|
shouldHide: false,
|
|
isInvalid: function (item) {
|
|
return !editor.formatter.canApply(item.format);
|
|
}
|
|
};
|
|
};
|
|
var createFormatSelect = function (editor, backstage) {
|
|
return createSelectButton(editor, backstage, getSpec$1(editor));
|
|
};
|
|
var formatSelectMenu = function (editor, backstage) {
|
|
var menuItems = createMenuItems(editor, backstage, getSpec$1(editor));
|
|
editor.ui.registry.addNestedMenuItem('blockformats', {
|
|
text: 'Blocks',
|
|
getSubmenuItems: function () {
|
|
return menuItems.items.validateItems(menuItems.getStyleItems());
|
|
}
|
|
});
|
|
};
|
|
|
|
var getSpec = function (editor, dataset) {
|
|
var fallbackFormat = 'Paragraph';
|
|
var isSelectedFor = function (format) {
|
|
return function () {
|
|
return editor.formatter.match(format);
|
|
};
|
|
};
|
|
var getPreviewFor = function (format) {
|
|
return function () {
|
|
var fmt = editor.formatter.get(format);
|
|
return fmt !== undefined ? Optional.some({
|
|
tag: fmt.length > 0 ? fmt[0].inline || fmt[0].block || 'div' : 'div',
|
|
styles: editor.dom.parseStyle(editor.formatter.getCssText(format))
|
|
}) : Optional.none();
|
|
};
|
|
};
|
|
var updateSelectMenuText = function (comp) {
|
|
var getFormatItems = function (fmt) {
|
|
var subs = fmt.items;
|
|
return subs !== undefined && subs.length > 0 ? bind$3(subs, getFormatItems) : [{
|
|
title: fmt.title,
|
|
format: fmt.format
|
|
}];
|
|
};
|
|
var flattenedItems = bind$3(getStyleFormats(editor), getFormatItems);
|
|
var detectedFormat = findNearest(editor, constant$1(flattenedItems));
|
|
var text = detectedFormat.fold(constant$1(fallbackFormat), function (fmt) {
|
|
return fmt.title;
|
|
});
|
|
emitWith(comp, updateMenuText, { text: text });
|
|
};
|
|
return {
|
|
tooltip: 'Formats',
|
|
text: Optional.some(fallbackFormat),
|
|
icon: Optional.none(),
|
|
isSelectedFor: isSelectedFor,
|
|
getCurrentValue: Optional.none,
|
|
getPreviewFor: getPreviewFor,
|
|
onAction: onActionToggleFormat$1(editor),
|
|
updateText: updateSelectMenuText,
|
|
shouldHide: editor.getParam('style_formats_autohide', false, 'boolean'),
|
|
isInvalid: function (item) {
|
|
return !editor.formatter.canApply(item.format);
|
|
},
|
|
dataset: dataset
|
|
};
|
|
};
|
|
var createStyleSelect = function (editor, backstage) {
|
|
var dataset = __assign({ type: 'advanced' }, backstage.styleselect);
|
|
return createSelectButton(editor, backstage, getSpec(editor, dataset));
|
|
};
|
|
var styleSelectMenu = function (editor, backstage) {
|
|
var dataset = __assign({ type: 'advanced' }, backstage.styleselect);
|
|
var menuItems = createMenuItems(editor, backstage, getSpec(editor, dataset));
|
|
editor.ui.registry.addNestedMenuItem('formats', {
|
|
text: 'Formats',
|
|
getSubmenuItems: function () {
|
|
return menuItems.items.validateItems(menuItems.getStyleItems());
|
|
}
|
|
});
|
|
};
|
|
|
|
var events$3 = function (reflectingConfig, reflectingState) {
|
|
var update = function (component, data) {
|
|
reflectingConfig.updateState.each(function (updateState) {
|
|
var newState = updateState(component, data);
|
|
reflectingState.set(newState);
|
|
});
|
|
reflectingConfig.renderComponents.each(function (renderComponents) {
|
|
var newComponents = renderComponents(data, reflectingState.get());
|
|
var newChildren = map$2(newComponents, component.getSystem().build);
|
|
replaceChildren(component, newChildren);
|
|
});
|
|
};
|
|
return derive$2([
|
|
run$1(receive(), function (component, message) {
|
|
var receivingData = message;
|
|
if (!receivingData.universal) {
|
|
var channel = reflectingConfig.channel;
|
|
if (contains$2(receivingData.channels, channel)) {
|
|
update(component, receivingData.data);
|
|
}
|
|
}
|
|
}),
|
|
runOnAttached(function (comp, _se) {
|
|
reflectingConfig.initialData.each(function (rawData) {
|
|
update(comp, rawData);
|
|
});
|
|
})
|
|
]);
|
|
};
|
|
|
|
var ActiveReflecting = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$3
|
|
});
|
|
|
|
var getState = function (component, replaceConfig, reflectState) {
|
|
return reflectState;
|
|
};
|
|
|
|
var ReflectingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
getState: getState
|
|
});
|
|
|
|
var ReflectingSchema = [
|
|
required$1('channel'),
|
|
option('renderComponents'),
|
|
option('updateState'),
|
|
option('initialData')
|
|
];
|
|
|
|
var init$3 = function () {
|
|
var cell = Cell(Optional.none());
|
|
var clear = function () {
|
|
return cell.set(Optional.none());
|
|
};
|
|
var readState = function () {
|
|
return cell.get().getOr('none');
|
|
};
|
|
return {
|
|
readState: readState,
|
|
get: cell.get,
|
|
set: cell.set,
|
|
clear: clear
|
|
};
|
|
};
|
|
|
|
var ReflectingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$3
|
|
});
|
|
|
|
var Reflecting = create$7({
|
|
fields: ReflectingSchema,
|
|
name: 'reflecting',
|
|
active: ActiveReflecting,
|
|
apis: ReflectingApis,
|
|
state: ReflectingState
|
|
});
|
|
|
|
var schema$7 = constant$1([
|
|
required$1('toggleClass'),
|
|
required$1('fetch'),
|
|
onStrictHandler('onExecute'),
|
|
defaulted('getHotspot', Optional.some),
|
|
defaulted('getAnchorOverrides', constant$1({})),
|
|
schema$y(),
|
|
onStrictHandler('onItemExecute'),
|
|
option('lazySink'),
|
|
required$1('dom'),
|
|
onHandler('onOpen'),
|
|
field('splitDropdownBehaviours', [
|
|
Coupling,
|
|
Keying,
|
|
Focusing
|
|
]),
|
|
defaulted('matchWidth', false),
|
|
defaulted('useMinWidth', false),
|
|
defaulted('eventOrder', {}),
|
|
option('role')
|
|
].concat(sandboxFields()));
|
|
var arrowPart = required({
|
|
factory: Button,
|
|
schema: [required$1('dom')],
|
|
name: 'arrow',
|
|
defaults: function () {
|
|
return { buttonBehaviours: derive$1([Focusing.revoke()]) };
|
|
},
|
|
overrides: function (detail) {
|
|
return {
|
|
dom: {
|
|
tag: 'span',
|
|
attributes: { role: 'presentation' }
|
|
},
|
|
action: function (arrow) {
|
|
arrow.getSystem().getByUid(detail.uid).each(emitExecute);
|
|
},
|
|
buttonBehaviours: derive$1([Toggling.config({
|
|
toggleOnExecute: false,
|
|
toggleClass: detail.toggleClass
|
|
})])
|
|
};
|
|
}
|
|
});
|
|
var buttonPart = required({
|
|
factory: Button,
|
|
schema: [required$1('dom')],
|
|
name: 'button',
|
|
defaults: function () {
|
|
return { buttonBehaviours: derive$1([Focusing.revoke()]) };
|
|
},
|
|
overrides: function (detail) {
|
|
return {
|
|
dom: {
|
|
tag: 'span',
|
|
attributes: { role: 'presentation' }
|
|
},
|
|
action: function (btn) {
|
|
btn.getSystem().getByUid(detail.uid).each(function (splitDropdown) {
|
|
detail.onExecute(splitDropdown, btn);
|
|
});
|
|
}
|
|
};
|
|
}
|
|
});
|
|
var parts$3 = constant$1([
|
|
arrowPart,
|
|
buttonPart,
|
|
optional({
|
|
factory: {
|
|
sketch: function (spec) {
|
|
return {
|
|
uid: spec.uid,
|
|
dom: {
|
|
tag: 'span',
|
|
styles: { display: 'none' },
|
|
attributes: { 'aria-hidden': 'true' },
|
|
innerHtml: spec.text
|
|
}
|
|
};
|
|
}
|
|
},
|
|
schema: [required$1('text')],
|
|
name: 'aria-descriptor'
|
|
}),
|
|
external$1({
|
|
schema: [tieredMenuMarkers()],
|
|
name: 'menu',
|
|
defaults: function (detail) {
|
|
return {
|
|
onExecute: function (tmenu, item) {
|
|
tmenu.getSystem().getByUid(detail.uid).each(function (splitDropdown) {
|
|
detail.onItemExecute(splitDropdown, tmenu, item);
|
|
});
|
|
}
|
|
};
|
|
}
|
|
}),
|
|
partType$1()
|
|
]);
|
|
|
|
var factory$5 = function (detail, components, spec, externals) {
|
|
var _a;
|
|
var switchToMenu = function (sandbox) {
|
|
Composing.getCurrent(sandbox).each(function (current) {
|
|
Highlighting.highlightFirst(current);
|
|
Keying.focusIn(current);
|
|
});
|
|
};
|
|
var action = function (component) {
|
|
var onOpenSync = switchToMenu;
|
|
togglePopup(detail, identity$1, component, externals, onOpenSync, HighlightOnOpen.HighlightFirst).get(noop);
|
|
};
|
|
var openMenu = function (comp) {
|
|
action(comp);
|
|
return Optional.some(true);
|
|
};
|
|
var executeOnButton = function (comp) {
|
|
var button = getPartOrDie(comp, detail, 'button');
|
|
emitExecute(button);
|
|
return Optional.some(true);
|
|
};
|
|
var buttonEvents = __assign(__assign({}, derive$2([runOnAttached(function (component, _simulatedEvent) {
|
|
var ariaDescriptor = getPart(component, detail, 'aria-descriptor');
|
|
ariaDescriptor.each(function (descriptor) {
|
|
var descriptorId = generate$6('aria');
|
|
set$8(descriptor.element, 'id', descriptorId);
|
|
set$8(component.element, 'aria-describedby', descriptorId);
|
|
});
|
|
})])), events$a(Optional.some(action)));
|
|
var apis = {
|
|
repositionMenus: function (comp) {
|
|
if (Toggling.isOn(comp)) {
|
|
repositionMenus(comp);
|
|
}
|
|
}
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
apis: apis,
|
|
eventOrder: __assign(__assign({}, detail.eventOrder), (_a = {}, _a[execute$5()] = [
|
|
'disabling',
|
|
'toggling',
|
|
'alloy.base.behaviour'
|
|
], _a)),
|
|
events: buttonEvents,
|
|
behaviours: augment(detail.splitDropdownBehaviours, [
|
|
Coupling.config({
|
|
others: {
|
|
sandbox: function (hotspot) {
|
|
var arrow = getPartOrDie(hotspot, detail, 'arrow');
|
|
var extras = {
|
|
onOpen: function () {
|
|
Toggling.on(arrow);
|
|
Toggling.on(hotspot);
|
|
},
|
|
onClose: function () {
|
|
Toggling.off(arrow);
|
|
Toggling.off(hotspot);
|
|
}
|
|
};
|
|
return makeSandbox$1(detail, hotspot, extras);
|
|
}
|
|
}
|
|
}),
|
|
Keying.config({
|
|
mode: 'special',
|
|
onSpace: executeOnButton,
|
|
onEnter: executeOnButton,
|
|
onDown: openMenu
|
|
}),
|
|
Focusing.config({}),
|
|
Toggling.config({
|
|
toggleOnExecute: false,
|
|
aria: { mode: 'expanded' }
|
|
})
|
|
]),
|
|
domModification: {
|
|
attributes: {
|
|
'role': detail.role.getOr('button'),
|
|
'aria-haspopup': true
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var SplitDropdown = composite({
|
|
name: 'SplitDropdown',
|
|
configFields: schema$7(),
|
|
partFields: parts$3(),
|
|
factory: factory$5,
|
|
apis: {
|
|
repositionMenus: function (apis, comp) {
|
|
return apis.repositionMenus(comp);
|
|
}
|
|
}
|
|
});
|
|
|
|
var getButtonApi = function (component) {
|
|
return {
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(component, state);
|
|
}
|
|
};
|
|
};
|
|
var getToggleApi = function (component) {
|
|
return {
|
|
setActive: function (state) {
|
|
Toggling.set(component, state);
|
|
},
|
|
isActive: function () {
|
|
return Toggling.isOn(component);
|
|
},
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(component);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(component, state);
|
|
}
|
|
};
|
|
};
|
|
var getTooltipAttributes = function (tooltip, providersBackstage) {
|
|
return tooltip.map(function (tooltip) {
|
|
return {
|
|
'aria-label': providersBackstage.translate(tooltip),
|
|
'title': providersBackstage.translate(tooltip)
|
|
};
|
|
}).getOr({});
|
|
};
|
|
var focusButtonEvent = generate$6('focus-button');
|
|
var renderCommonStructure = function (icon, text, tooltip, receiver, behaviours, providersBackstage) {
|
|
var _d;
|
|
return {
|
|
dom: {
|
|
tag: 'button',
|
|
classes: ['tox-tbtn'].concat(text.isSome() ? ['tox-tbtn--select'] : []),
|
|
attributes: getTooltipAttributes(tooltip, providersBackstage)
|
|
},
|
|
components: componentRenderPipeline([
|
|
icon.map(function (iconName) {
|
|
return renderIconFromPack(iconName, providersBackstage.icons);
|
|
}),
|
|
text.map(function (text) {
|
|
return renderLabel$1(text, 'tox-tbtn', providersBackstage);
|
|
})
|
|
]),
|
|
eventOrder: (_d = {}, _d[mousedown()] = [
|
|
'focusing',
|
|
'alloy.base.behaviour',
|
|
'common-button-display-events'
|
|
], _d),
|
|
buttonBehaviours: derive$1([
|
|
DisablingConfigs.toolbarButton(providersBackstage.isDisabled),
|
|
receivingConfig(),
|
|
config('common-button-display-events', [run$1(mousedown(), function (button, se) {
|
|
se.event.prevent();
|
|
emit(button, focusButtonEvent);
|
|
})])
|
|
].concat(receiver.map(function (r) {
|
|
return Reflecting.config({
|
|
channel: r,
|
|
initialData: {
|
|
icon: icon,
|
|
text: text
|
|
},
|
|
renderComponents: function (data, _state) {
|
|
return componentRenderPipeline([
|
|
data.icon.map(function (iconName) {
|
|
return renderIconFromPack(iconName, providersBackstage.icons);
|
|
}),
|
|
data.text.map(function (text) {
|
|
return renderLabel$1(text, 'tox-tbtn', providersBackstage);
|
|
})
|
|
]);
|
|
}
|
|
});
|
|
}).toArray()).concat(behaviours.getOr([])))
|
|
};
|
|
};
|
|
var renderFloatingToolbarButton = function (spec, backstage, identifyButtons, attributes) {
|
|
var sharedBackstage = backstage.shared;
|
|
return FloatingToolbarButton.sketch({
|
|
lazySink: sharedBackstage.getSink,
|
|
fetch: function () {
|
|
return Future.nu(function (resolve) {
|
|
resolve(map$2(identifyButtons(spec.items), renderToolbarGroup));
|
|
});
|
|
},
|
|
markers: { toggledClass: 'tox-tbtn--enabled' },
|
|
parts: {
|
|
button: renderCommonStructure(spec.icon, spec.text, spec.tooltip, Optional.none(), Optional.none(), sharedBackstage.providers),
|
|
toolbar: {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar__overflow'],
|
|
attributes: attributes
|
|
}
|
|
}
|
|
}
|
|
});
|
|
};
|
|
var renderCommonToolbarButton = function (spec, specialisation, providersBackstage) {
|
|
var editorOffCell = Cell(noop);
|
|
var structure = renderCommonStructure(spec.icon, spec.text, spec.tooltip, Optional.none(), Optional.none(), providersBackstage);
|
|
return Button.sketch({
|
|
dom: structure.dom,
|
|
components: structure.components,
|
|
eventOrder: toolbarButtonEventOrder,
|
|
buttonBehaviours: derive$1([
|
|
config('toolbar-button-events', [
|
|
onToolbarButtonExecute({
|
|
onAction: spec.onAction,
|
|
getApi: specialisation.getApi
|
|
}),
|
|
onControlAttached(specialisation, editorOffCell),
|
|
onControlDetached(specialisation, editorOffCell)
|
|
]),
|
|
DisablingConfigs.toolbarButton(function () {
|
|
return spec.disabled || providersBackstage.isDisabled();
|
|
}),
|
|
receivingConfig()
|
|
].concat(specialisation.toolbarButtonBehaviours))
|
|
});
|
|
};
|
|
var renderToolbarButton = function (spec, providersBackstage) {
|
|
return renderToolbarButtonWith(spec, providersBackstage, []);
|
|
};
|
|
var renderToolbarButtonWith = function (spec, providersBackstage, bonusEvents) {
|
|
return renderCommonToolbarButton(spec, {
|
|
toolbarButtonBehaviours: [].concat(bonusEvents.length > 0 ? [config('toolbarButtonWith', bonusEvents)] : []),
|
|
getApi: getButtonApi,
|
|
onSetup: spec.onSetup
|
|
}, providersBackstage);
|
|
};
|
|
var renderToolbarToggleButton = function (spec, providersBackstage) {
|
|
return renderToolbarToggleButtonWith(spec, providersBackstage, []);
|
|
};
|
|
var renderToolbarToggleButtonWith = function (spec, providersBackstage, bonusEvents) {
|
|
return deepMerge(renderCommonToolbarButton(spec, {
|
|
toolbarButtonBehaviours: [
|
|
Replacing.config({}),
|
|
Toggling.config({
|
|
toggleClass: 'tox-tbtn--enabled',
|
|
aria: { mode: 'pressed' },
|
|
toggleOnExecute: false
|
|
})
|
|
].concat(bonusEvents.length > 0 ? [config('toolbarToggleButtonWith', bonusEvents)] : []),
|
|
getApi: getToggleApi,
|
|
onSetup: spec.onSetup
|
|
}, providersBackstage));
|
|
};
|
|
var fetchChoices = function (getApi, spec, providersBackstage) {
|
|
return function (comp) {
|
|
return Future.nu(function (callback) {
|
|
return spec.fetch(callback);
|
|
}).map(function (items) {
|
|
return Optional.from(createTieredDataFrom(deepMerge(createPartialChoiceMenu(generate$6('menu-value'), items, function (value) {
|
|
spec.onItemAction(getApi(comp), value);
|
|
}, spec.columns, spec.presets, ItemResponse$1.CLOSE_ON_EXECUTE, spec.select.getOr(never), providersBackstage), {
|
|
movement: deriveMenuMovement(spec.columns, spec.presets),
|
|
menuBehaviours: SimpleBehaviours.unnamedEvents(spec.columns !== 'auto' ? [] : [runOnAttached(function (comp, _se) {
|
|
detectSize(comp, 4, classForPreset(spec.presets)).each(function (_d) {
|
|
var numRows = _d.numRows, numColumns = _d.numColumns;
|
|
Keying.setGridSize(comp, numRows, numColumns);
|
|
});
|
|
})])
|
|
})));
|
|
});
|
|
};
|
|
};
|
|
var renderSplitButton = function (spec, sharedBackstage) {
|
|
var _d;
|
|
var displayChannel = generate$6('channel-update-split-dropdown-display');
|
|
var getApi = function (comp) {
|
|
return {
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(comp);
|
|
},
|
|
setDisabled: function (state) {
|
|
return Disabling.set(comp, state);
|
|
},
|
|
setIconFill: function (id, value) {
|
|
descendant(comp.element, 'svg path[id="' + id + '"], rect[id="' + id + '"]').each(function (underlinePath) {
|
|
set$8(underlinePath, 'fill', value);
|
|
});
|
|
},
|
|
setIconStroke: function (id, value) {
|
|
descendant(comp.element, 'svg path[id="' + id + '"], rect[id="' + id + '"]').each(function (underlinePath) {
|
|
set$8(underlinePath, 'stroke', value);
|
|
});
|
|
},
|
|
setActive: function (state) {
|
|
set$8(comp.element, 'aria-pressed', state);
|
|
descendant(comp.element, 'span').each(function (button) {
|
|
comp.getSystem().getByDom(button).each(function (buttonComp) {
|
|
return Toggling.set(buttonComp, state);
|
|
});
|
|
});
|
|
},
|
|
isActive: function () {
|
|
return descendant(comp.element, 'span').exists(function (button) {
|
|
return comp.getSystem().getByDom(button).exists(Toggling.isOn);
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var editorOffCell = Cell(noop);
|
|
var specialisation = {
|
|
getApi: getApi,
|
|
onSetup: spec.onSetup
|
|
};
|
|
return SplitDropdown.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-split-button'],
|
|
attributes: __assign({ 'aria-pressed': false }, getTooltipAttributes(spec.tooltip, sharedBackstage.providers))
|
|
},
|
|
onExecute: function (button) {
|
|
spec.onAction(getApi(button));
|
|
},
|
|
onItemExecute: function (_a, _b, _c) {
|
|
},
|
|
splitDropdownBehaviours: derive$1([
|
|
DisablingConfigs.splitButton(sharedBackstage.providers.isDisabled),
|
|
receivingConfig(),
|
|
config('split-dropdown-events', [
|
|
run$1(focusButtonEvent, Focusing.focus),
|
|
onControlAttached(specialisation, editorOffCell),
|
|
onControlDetached(specialisation, editorOffCell)
|
|
]),
|
|
Unselecting.config({})
|
|
]),
|
|
eventOrder: (_d = {}, _d[attachedToDom()] = [
|
|
'alloy.base.behaviour',
|
|
'split-dropdown-events'
|
|
], _d),
|
|
toggleClass: 'tox-tbtn--enabled',
|
|
lazySink: sharedBackstage.getSink,
|
|
fetch: fetchChoices(getApi, spec, sharedBackstage.providers),
|
|
parts: { menu: part(false, spec.columns, spec.presets) },
|
|
components: [
|
|
SplitDropdown.parts.button(renderCommonStructure(spec.icon, spec.text, Optional.none(), Optional.some(displayChannel), Optional.some([Toggling.config({
|
|
toggleClass: 'tox-tbtn--enabled',
|
|
toggleOnExecute: false
|
|
})]), sharedBackstage.providers)),
|
|
SplitDropdown.parts.arrow({
|
|
dom: {
|
|
tag: 'button',
|
|
classes: [
|
|
'tox-tbtn',
|
|
'tox-split-button__chevron'
|
|
],
|
|
innerHtml: get$1('chevron-down', sharedBackstage.providers.icons)
|
|
},
|
|
buttonBehaviours: derive$1([
|
|
DisablingConfigs.splitButton(sharedBackstage.providers.isDisabled),
|
|
receivingConfig(),
|
|
addFocusableBehaviour()
|
|
])
|
|
}),
|
|
SplitDropdown.parts['aria-descriptor']({ text: sharedBackstage.providers.translate('To open the popup, press Shift+Enter') })
|
|
]
|
|
});
|
|
};
|
|
|
|
var defaultToolbar = [
|
|
{
|
|
name: 'history',
|
|
items: [
|
|
'undo',
|
|
'redo'
|
|
]
|
|
},
|
|
{
|
|
name: 'styles',
|
|
items: ['styleselect']
|
|
},
|
|
{
|
|
name: 'formatting',
|
|
items: [
|
|
'bold',
|
|
'italic'
|
|
]
|
|
},
|
|
{
|
|
name: 'alignment',
|
|
items: [
|
|
'alignleft',
|
|
'aligncenter',
|
|
'alignright',
|
|
'alignjustify'
|
|
]
|
|
},
|
|
{
|
|
name: 'indentation',
|
|
items: [
|
|
'outdent',
|
|
'indent'
|
|
]
|
|
},
|
|
{
|
|
name: 'permanent pen',
|
|
items: ['permanentpen']
|
|
},
|
|
{
|
|
name: 'comments',
|
|
items: ['addcomment']
|
|
}
|
|
];
|
|
var renderFromBridge = function (bridgeBuilder, render) {
|
|
return function (spec, extras, editor) {
|
|
var internal = bridgeBuilder(spec).mapError(function (errInfo) {
|
|
return formatError(errInfo);
|
|
}).getOrDie();
|
|
return render(internal, extras, editor);
|
|
};
|
|
};
|
|
var types = {
|
|
button: renderFromBridge(createToolbarButton, function (s, extras) {
|
|
return renderToolbarButton(s, extras.backstage.shared.providers);
|
|
}),
|
|
togglebutton: renderFromBridge(createToggleButton, function (s, extras) {
|
|
return renderToolbarToggleButton(s, extras.backstage.shared.providers);
|
|
}),
|
|
menubutton: renderFromBridge(createMenuButton, function (s, extras) {
|
|
return renderMenuButton(s, 'tox-tbtn', extras.backstage, Optional.none());
|
|
}),
|
|
splitbutton: renderFromBridge(createSplitButton, function (s, extras) {
|
|
return renderSplitButton(s, extras.backstage.shared);
|
|
}),
|
|
grouptoolbarbutton: renderFromBridge(createGroupToolbarButton, function (s, extras, editor) {
|
|
var _a;
|
|
var buttons = editor.ui.registry.getAll().buttons;
|
|
var identify = function (toolbar) {
|
|
return identifyButtons(editor, {
|
|
buttons: buttons,
|
|
toolbar: toolbar,
|
|
allowToolbarGroups: false
|
|
}, extras, Optional.none());
|
|
};
|
|
var attributes = (_a = {}, _a[Attribute] = extras.backstage.shared.header.isPositionedAtTop() ? AttributeValue.TopToBottom : AttributeValue.BottomToTop, _a);
|
|
switch (getToolbarMode(editor)) {
|
|
case ToolbarMode.floating:
|
|
return renderFloatingToolbarButton(s, extras.backstage, identify, attributes);
|
|
default:
|
|
throw new Error('Toolbar groups are only supported when using floating toolbar mode');
|
|
}
|
|
}),
|
|
styleSelectButton: function (editor, extras) {
|
|
return createStyleSelect(editor, extras.backstage);
|
|
},
|
|
fontsizeSelectButton: function (editor, extras) {
|
|
return createFontsizeSelect(editor, extras.backstage);
|
|
},
|
|
fontSelectButton: function (editor, extras) {
|
|
return createFontSelect(editor, extras.backstage);
|
|
},
|
|
formatButton: function (editor, extras) {
|
|
return createFormatSelect(editor, extras.backstage);
|
|
},
|
|
alignMenuButton: function (editor, extras) {
|
|
return createAlignSelect(editor, extras.backstage);
|
|
}
|
|
};
|
|
var extractFrom = function (spec, extras, editor) {
|
|
return get$e(types, spec.type).fold(function () {
|
|
console.error('skipping button defined by', spec);
|
|
return Optional.none();
|
|
}, function (render) {
|
|
return Optional.some(render(spec, extras, editor));
|
|
});
|
|
};
|
|
var bespokeButtons = {
|
|
styleselect: types.styleSelectButton,
|
|
fontsizeselect: types.fontsizeSelectButton,
|
|
fontselect: types.fontSelectButton,
|
|
formatselect: types.formatButton,
|
|
align: types.alignMenuButton
|
|
};
|
|
var removeUnusedDefaults = function (buttons) {
|
|
var filteredItemGroups = map$2(defaultToolbar, function (group) {
|
|
var items = filter$2(group.items, function (subItem) {
|
|
return has$2(buttons, subItem) || has$2(bespokeButtons, subItem);
|
|
});
|
|
return {
|
|
name: group.name,
|
|
items: items
|
|
};
|
|
});
|
|
return filter$2(filteredItemGroups, function (group) {
|
|
return group.items.length > 0;
|
|
});
|
|
};
|
|
var convertStringToolbar = function (strToolbar) {
|
|
var groupsStrings = strToolbar.split('|');
|
|
return map$2(groupsStrings, function (g) {
|
|
return { items: g.trim().split(' ') };
|
|
});
|
|
};
|
|
var isToolbarGroupSettingArray = function (toolbar) {
|
|
return isArrayOf(toolbar, function (t) {
|
|
return has$2(t, 'name') && has$2(t, 'items');
|
|
});
|
|
};
|
|
var createToolbar = function (toolbarConfig) {
|
|
var toolbar = toolbarConfig.toolbar;
|
|
var buttons = toolbarConfig.buttons;
|
|
if (toolbar === false) {
|
|
return [];
|
|
} else if (toolbar === undefined || toolbar === true) {
|
|
return removeUnusedDefaults(buttons);
|
|
} else if (isString(toolbar)) {
|
|
return convertStringToolbar(toolbar);
|
|
} else if (isToolbarGroupSettingArray(toolbar)) {
|
|
return toolbar;
|
|
} else {
|
|
console.error('Toolbar type should be string, string[], boolean or ToolbarGroup[]');
|
|
return [];
|
|
}
|
|
};
|
|
var lookupButton = function (editor, buttons, toolbarItem, allowToolbarGroups, extras, prefixes) {
|
|
return get$e(buttons, toolbarItem.toLowerCase()).orThunk(function () {
|
|
return prefixes.bind(function (ps) {
|
|
return findMap(ps, function (prefix) {
|
|
return get$e(buttons, prefix + toolbarItem.toLowerCase());
|
|
});
|
|
});
|
|
}).fold(function () {
|
|
return get$e(bespokeButtons, toolbarItem.toLowerCase()).map(function (r) {
|
|
return r(editor, extras);
|
|
}).orThunk(function () {
|
|
return Optional.none();
|
|
});
|
|
}, function (spec) {
|
|
if (spec.type === 'grouptoolbarbutton' && !allowToolbarGroups) {
|
|
console.warn('Ignoring the \'' + toolbarItem + '\' toolbar button. Group toolbar buttons are only supported when using floating toolbar mode and cannot be nested.');
|
|
return Optional.none();
|
|
} else {
|
|
return extractFrom(spec, extras, editor);
|
|
}
|
|
});
|
|
};
|
|
var identifyButtons = function (editor, toolbarConfig, extras, prefixes) {
|
|
var toolbarGroups = createToolbar(toolbarConfig);
|
|
var groups = map$2(toolbarGroups, function (group) {
|
|
var items = bind$3(group.items, function (toolbarItem) {
|
|
return toolbarItem.trim().length === 0 ? [] : lookupButton(editor, toolbarConfig.buttons, toolbarItem, toolbarConfig.allowToolbarGroups, extras, prefixes).toArray();
|
|
});
|
|
return {
|
|
title: Optional.from(editor.translate(group.name)),
|
|
items: items
|
|
};
|
|
});
|
|
return filter$2(groups, function (group) {
|
|
return group.items.length > 0;
|
|
});
|
|
};
|
|
|
|
var setToolbar = function (editor, uiComponents, rawUiConfig, backstage) {
|
|
var comp = uiComponents.outerContainer;
|
|
var toolbarConfig = rawUiConfig.toolbar;
|
|
var toolbarButtonsConfig = rawUiConfig.buttons;
|
|
if (isArrayOf(toolbarConfig, isString)) {
|
|
var toolbars = toolbarConfig.map(function (t) {
|
|
var config = {
|
|
toolbar: t,
|
|
buttons: toolbarButtonsConfig,
|
|
allowToolbarGroups: rawUiConfig.allowToolbarGroups
|
|
};
|
|
return identifyButtons(editor, config, { backstage: backstage }, Optional.none());
|
|
});
|
|
OuterContainer.setToolbars(comp, toolbars);
|
|
} else {
|
|
OuterContainer.setToolbar(comp, identifyButtons(editor, rawUiConfig, { backstage: backstage }, Optional.none()));
|
|
}
|
|
};
|
|
|
|
var detection = detect$1();
|
|
var isiOS12 = detection.os.isiOS() && detection.os.version.major <= 12;
|
|
var setupEvents$1 = function (editor, uiComponents) {
|
|
var dom = editor.dom;
|
|
var contentWindow = editor.getWin();
|
|
var initialDocEle = editor.getDoc().documentElement;
|
|
var lastWindowDimensions = Cell(SugarPosition(contentWindow.innerWidth, contentWindow.innerHeight));
|
|
var lastDocumentDimensions = Cell(SugarPosition(initialDocEle.offsetWidth, initialDocEle.offsetHeight));
|
|
var resizeWindow = function () {
|
|
var outer = lastWindowDimensions.get();
|
|
if (outer.left !== contentWindow.innerWidth || outer.top !== contentWindow.innerHeight) {
|
|
lastWindowDimensions.set(SugarPosition(contentWindow.innerWidth, contentWindow.innerHeight));
|
|
fireResizeContent(editor);
|
|
}
|
|
};
|
|
var resizeDocument = function () {
|
|
var docEle = editor.getDoc().documentElement;
|
|
var inner = lastDocumentDimensions.get();
|
|
if (inner.left !== docEle.offsetWidth || inner.top !== docEle.offsetHeight) {
|
|
lastDocumentDimensions.set(SugarPosition(docEle.offsetWidth, docEle.offsetHeight));
|
|
fireResizeContent(editor);
|
|
}
|
|
};
|
|
var scroll = function (e) {
|
|
return fireScrollContent(editor, e);
|
|
};
|
|
dom.bind(contentWindow, 'resize', resizeWindow);
|
|
dom.bind(contentWindow, 'scroll', scroll);
|
|
var elementLoad = capture(SugarElement.fromDom(editor.getBody()), 'load', resizeDocument);
|
|
var mothership = uiComponents.uiMothership.element;
|
|
editor.on('hide', function () {
|
|
set$7(mothership, 'display', 'none');
|
|
});
|
|
editor.on('show', function () {
|
|
remove$6(mothership, 'display');
|
|
});
|
|
editor.on('NodeChange', resizeDocument);
|
|
editor.on('remove', function () {
|
|
elementLoad.unbind();
|
|
dom.unbind(contentWindow, 'resize', resizeWindow);
|
|
dom.unbind(contentWindow, 'scroll', scroll);
|
|
contentWindow = null;
|
|
});
|
|
};
|
|
var render$1 = function (editor, uiComponents, rawUiConfig, backstage, args) {
|
|
var lastToolbarWidth = Cell(0);
|
|
var outerContainer = uiComponents.outerContainer;
|
|
iframe(editor);
|
|
var eTargetNode = SugarElement.fromDom(args.targetNode);
|
|
var uiRoot = getContentContainer(getRootNode(eTargetNode));
|
|
attachSystemAfter(eTargetNode, uiComponents.mothership);
|
|
attachSystem(uiRoot, uiComponents.uiMothership);
|
|
editor.on('PostRender', function () {
|
|
setToolbar(editor, uiComponents, rawUiConfig, backstage);
|
|
lastToolbarWidth.set(editor.getWin().innerWidth);
|
|
OuterContainer.setMenubar(outerContainer, identifyMenus(editor, rawUiConfig));
|
|
OuterContainer.setSidebar(outerContainer, rawUiConfig.sidebar);
|
|
setupEvents$1(editor, uiComponents);
|
|
});
|
|
var socket = OuterContainer.getSocket(outerContainer).getOrDie('Could not find expected socket element');
|
|
if (isiOS12) {
|
|
setAll(socket.element, {
|
|
'overflow': 'scroll',
|
|
'-webkit-overflow-scrolling': 'touch'
|
|
});
|
|
var limit = first(function () {
|
|
editor.fire('ScrollContent');
|
|
}, 20);
|
|
var unbinder = bind(socket.element, 'scroll', limit.throttle);
|
|
editor.on('remove', unbinder.unbind);
|
|
}
|
|
setupReadonlyModeSwitch(editor, uiComponents);
|
|
editor.addCommand('ToggleSidebar', function (_ui, value) {
|
|
OuterContainer.toggleSidebar(outerContainer, value);
|
|
editor.fire('ToggleSidebar');
|
|
});
|
|
editor.addQueryValueHandler('ToggleSidebar', function () {
|
|
return OuterContainer.whichSidebar(outerContainer);
|
|
});
|
|
var toolbarMode = getToolbarMode(editor);
|
|
var refreshDrawer = function () {
|
|
OuterContainer.refreshToolbar(uiComponents.outerContainer);
|
|
};
|
|
if (toolbarMode === ToolbarMode.sliding || toolbarMode === ToolbarMode.floating) {
|
|
editor.on('ResizeWindow ResizeEditor ResizeContent', function () {
|
|
var width = editor.getWin().innerWidth;
|
|
if (width !== lastToolbarWidth.get()) {
|
|
refreshDrawer();
|
|
lastToolbarWidth.set(width);
|
|
}
|
|
});
|
|
}
|
|
var api = {
|
|
enable: function () {
|
|
broadcastReadonly(uiComponents, false);
|
|
},
|
|
disable: function () {
|
|
broadcastReadonly(uiComponents, true);
|
|
},
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(outerContainer);
|
|
}
|
|
};
|
|
return {
|
|
iframeContainer: socket.element.dom,
|
|
editorContainer: outerContainer.element.dom,
|
|
api: api
|
|
};
|
|
};
|
|
|
|
var Iframe = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
render: render$1
|
|
});
|
|
|
|
var parseToInt = function (val) {
|
|
var re = /^[0-9\.]+(|px)$/i;
|
|
if (re.test('' + val)) {
|
|
return Optional.some(parseInt('' + val, 10));
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var numToPx = function (val) {
|
|
return isNumber(val) ? val + 'px' : val;
|
|
};
|
|
var calcCappedSize = function (size, minSize, maxSize) {
|
|
var minOverride = minSize.filter(function (min) {
|
|
return size < min;
|
|
});
|
|
var maxOverride = maxSize.filter(function (max) {
|
|
return size > max;
|
|
});
|
|
return minOverride.or(maxOverride).getOr(size);
|
|
};
|
|
|
|
var getHeight = function (editor) {
|
|
var baseHeight = getHeightSetting(editor);
|
|
var minHeight = getMinHeightSetting(editor);
|
|
var maxHeight = getMaxHeightSetting(editor);
|
|
return parseToInt(baseHeight).map(function (height) {
|
|
return calcCappedSize(height, minHeight, maxHeight);
|
|
});
|
|
};
|
|
var getHeightWithFallback = function (editor) {
|
|
var height = getHeight(editor);
|
|
return height.getOr(getHeightSetting(editor));
|
|
};
|
|
var getWidth = function (editor) {
|
|
var baseWidth = getWidthSetting(editor);
|
|
var minWidth = getMinWidthSetting(editor);
|
|
var maxWidth = getMaxWidthSetting(editor);
|
|
return parseToInt(baseWidth).map(function (width) {
|
|
return calcCappedSize(width, minWidth, maxWidth);
|
|
});
|
|
};
|
|
var getWidthWithFallback = function (editor) {
|
|
var width = getWidth(editor);
|
|
return width.getOr(getWidthSetting(editor));
|
|
};
|
|
|
|
var InlineHeader = function (editor, targetElm, uiComponents, backstage, floatContainer) {
|
|
var uiMothership = uiComponents.uiMothership, outerContainer = uiComponents.outerContainer;
|
|
var DOM = global$b.DOM;
|
|
var useFixedToolbarContainer = useFixedContainer(editor);
|
|
var isSticky = isStickyToolbar(editor);
|
|
var editorMaxWidthOpt = getMaxWidthSetting(editor).or(getWidth(editor));
|
|
var headerBackstage = backstage.shared.header;
|
|
var isPositionedAtTop = headerBackstage.isPositionedAtTop;
|
|
var toolbarMode = getToolbarMode(editor);
|
|
var isSplitToolbar = toolbarMode === ToolbarMode.sliding || toolbarMode === ToolbarMode.floating;
|
|
var visible = Cell(false);
|
|
var isVisible = function () {
|
|
return visible.get() && !editor.removed;
|
|
};
|
|
var calcToolbarOffset = function (toolbar) {
|
|
return isSplitToolbar ? toolbar.fold(constant$1(0), function (tbar) {
|
|
return tbar.components().length > 1 ? get$b(tbar.components()[1].element) : 0;
|
|
}) : 0;
|
|
};
|
|
var calcMode = function (container) {
|
|
switch (getToolbarLocation(editor)) {
|
|
case ToolbarLocation.auto:
|
|
var toolbar_1 = OuterContainer.getToolbar(outerContainer);
|
|
var offset = calcToolbarOffset(toolbar_1);
|
|
var toolbarHeight = get$b(container.element) - offset;
|
|
var targetBounds = box$1(targetElm);
|
|
var roomAtTop = targetBounds.y > toolbarHeight;
|
|
if (roomAtTop) {
|
|
return 'top';
|
|
} else {
|
|
var doc = documentElement(targetElm);
|
|
var docHeight = Math.max(doc.dom.scrollHeight, get$b(doc));
|
|
var roomAtBottom = targetBounds.bottom < docHeight - toolbarHeight;
|
|
if (roomAtBottom) {
|
|
return 'bottom';
|
|
} else {
|
|
var winBounds = win();
|
|
var isRoomAtBottomViewport = winBounds.bottom < targetBounds.bottom - toolbarHeight;
|
|
return isRoomAtBottomViewport ? 'bottom' : 'top';
|
|
}
|
|
}
|
|
case ToolbarLocation.bottom:
|
|
return 'bottom';
|
|
case ToolbarLocation.top:
|
|
default:
|
|
return 'top';
|
|
}
|
|
};
|
|
var setupMode = function (mode) {
|
|
var container = floatContainer.get();
|
|
Docking.setModes(container, [mode]);
|
|
headerBackstage.setDockingMode(mode);
|
|
var verticalDir = isPositionedAtTop() ? AttributeValue.TopToBottom : AttributeValue.BottomToTop;
|
|
set$8(container.element, Attribute, verticalDir);
|
|
};
|
|
var updateChromeWidth = function () {
|
|
var maxWidth = editorMaxWidthOpt.getOrThunk(function () {
|
|
var bodyMargin = parseToInt(get$c(body(), 'margin-left')).getOr(0);
|
|
return get$a(body()) - absolute$3(targetElm).left + bodyMargin;
|
|
});
|
|
set$7(floatContainer.get().element, 'max-width', maxWidth + 'px');
|
|
};
|
|
var updateChromePosition = function () {
|
|
var toolbar = OuterContainer.getToolbar(outerContainer);
|
|
var offset = calcToolbarOffset(toolbar);
|
|
var targetBounds = box$1(targetElm);
|
|
var top = isPositionedAtTop() ? Math.max(targetBounds.y - get$b(floatContainer.get().element) + offset, 0) : targetBounds.bottom;
|
|
setAll(outerContainer.element, {
|
|
position: 'absolute',
|
|
top: Math.round(top) + 'px',
|
|
left: Math.round(targetBounds.x) + 'px'
|
|
});
|
|
};
|
|
var repositionPopups$1 = function () {
|
|
uiMothership.broadcastOn([repositionPopups()], {});
|
|
};
|
|
var updateChromeUi = function (resetDocking) {
|
|
if (resetDocking === void 0) {
|
|
resetDocking = false;
|
|
}
|
|
if (!isVisible()) {
|
|
return;
|
|
}
|
|
if (!useFixedToolbarContainer) {
|
|
updateChromeWidth();
|
|
}
|
|
if (isSplitToolbar) {
|
|
OuterContainer.refreshToolbar(outerContainer);
|
|
}
|
|
if (!useFixedToolbarContainer) {
|
|
updateChromePosition();
|
|
}
|
|
if (isSticky) {
|
|
var floatContainerComp = floatContainer.get();
|
|
resetDocking ? Docking.reset(floatContainerComp) : Docking.refresh(floatContainerComp);
|
|
}
|
|
repositionPopups$1();
|
|
};
|
|
var updateMode = function (updateUi) {
|
|
if (updateUi === void 0) {
|
|
updateUi = true;
|
|
}
|
|
if (useFixedToolbarContainer || !isSticky || !isVisible()) {
|
|
return;
|
|
}
|
|
var currentMode = headerBackstage.getDockingMode();
|
|
var newMode = calcMode(floatContainer.get());
|
|
if (newMode !== currentMode) {
|
|
setupMode(newMode);
|
|
if (updateUi) {
|
|
updateChromeUi(true);
|
|
}
|
|
}
|
|
};
|
|
var show = function () {
|
|
visible.set(true);
|
|
set$7(outerContainer.element, 'display', 'flex');
|
|
DOM.addClass(editor.getBody(), 'mce-edit-focus');
|
|
remove$6(uiMothership.element, 'display');
|
|
updateMode(false);
|
|
updateChromeUi();
|
|
};
|
|
var hide = function () {
|
|
visible.set(false);
|
|
if (uiComponents.outerContainer) {
|
|
set$7(outerContainer.element, 'display', 'none');
|
|
DOM.removeClass(editor.getBody(), 'mce-edit-focus');
|
|
}
|
|
set$7(uiMothership.element, 'display', 'none');
|
|
};
|
|
return {
|
|
isVisible: isVisible,
|
|
isPositionedAtTop: isPositionedAtTop,
|
|
show: show,
|
|
hide: hide,
|
|
update: updateChromeUi,
|
|
updateMode: updateMode,
|
|
repositionPopups: repositionPopups$1
|
|
};
|
|
};
|
|
|
|
var getTargetPosAndBounds = function (targetElm, isToolbarTop) {
|
|
var bounds = box$1(targetElm);
|
|
return {
|
|
pos: isToolbarTop ? bounds.y : bounds.bottom,
|
|
bounds: bounds
|
|
};
|
|
};
|
|
var setupEvents = function (editor, targetElm, ui, toolbarPersist) {
|
|
var prevPosAndBounds = Cell(getTargetPosAndBounds(targetElm, ui.isPositionedAtTop()));
|
|
var resizeContent = function (e) {
|
|
var _a = getTargetPosAndBounds(targetElm, ui.isPositionedAtTop()), pos = _a.pos, bounds = _a.bounds;
|
|
var _b = prevPosAndBounds.get(), prevPos = _b.pos, prevBounds = _b.bounds;
|
|
var hasResized = bounds.height !== prevBounds.height || bounds.width !== prevBounds.width;
|
|
prevPosAndBounds.set({
|
|
pos: pos,
|
|
bounds: bounds
|
|
});
|
|
if (hasResized) {
|
|
fireResizeContent(editor, e);
|
|
}
|
|
if (ui.isVisible()) {
|
|
if (prevPos !== pos) {
|
|
ui.update(true);
|
|
} else if (hasResized) {
|
|
ui.updateMode();
|
|
ui.repositionPopups();
|
|
}
|
|
}
|
|
};
|
|
if (!toolbarPersist) {
|
|
editor.on('activate', ui.show);
|
|
editor.on('deactivate', ui.hide);
|
|
}
|
|
editor.on('SkinLoaded ResizeWindow', function () {
|
|
return ui.update(true);
|
|
});
|
|
editor.on('NodeChange keydown', function (e) {
|
|
global$f.requestAnimationFrame(function () {
|
|
return resizeContent(e);
|
|
});
|
|
});
|
|
editor.on('ScrollWindow', function () {
|
|
return ui.updateMode();
|
|
});
|
|
var elementLoad = unbindable();
|
|
elementLoad.set(capture(SugarElement.fromDom(editor.getBody()), 'load', resizeContent));
|
|
editor.on('remove', function () {
|
|
elementLoad.clear();
|
|
});
|
|
};
|
|
var render = function (editor, uiComponents, rawUiConfig, backstage, args) {
|
|
var mothership = uiComponents.mothership, uiMothership = uiComponents.uiMothership, outerContainer = uiComponents.outerContainer;
|
|
var floatContainer = Cell(null);
|
|
var targetElm = SugarElement.fromDom(args.targetNode);
|
|
var ui = InlineHeader(editor, targetElm, uiComponents, backstage, floatContainer);
|
|
var toolbarPersist = isToolbarPersist(editor);
|
|
inline(editor);
|
|
var render = function () {
|
|
if (floatContainer.get()) {
|
|
ui.show();
|
|
return;
|
|
}
|
|
floatContainer.set(OuterContainer.getHeader(outerContainer).getOrDie());
|
|
var uiContainer = getUiContainer(editor);
|
|
attachSystem(uiContainer, mothership);
|
|
attachSystem(uiContainer, uiMothership);
|
|
setToolbar(editor, uiComponents, rawUiConfig, backstage);
|
|
OuterContainer.setMenubar(outerContainer, identifyMenus(editor, rawUiConfig));
|
|
ui.show();
|
|
setupEvents(editor, targetElm, ui, toolbarPersist);
|
|
editor.nodeChanged();
|
|
};
|
|
editor.on('show', render);
|
|
editor.on('hide', ui.hide);
|
|
if (!toolbarPersist) {
|
|
editor.on('focus', render);
|
|
editor.on('blur', ui.hide);
|
|
}
|
|
editor.on('init', function () {
|
|
if (editor.hasFocus() || toolbarPersist) {
|
|
render();
|
|
}
|
|
});
|
|
setupReadonlyModeSwitch(editor, uiComponents);
|
|
var api = {
|
|
show: function () {
|
|
ui.show();
|
|
},
|
|
hide: function () {
|
|
ui.hide();
|
|
},
|
|
enable: function () {
|
|
broadcastReadonly(uiComponents, false);
|
|
},
|
|
disable: function () {
|
|
broadcastReadonly(uiComponents, true);
|
|
},
|
|
isDisabled: function () {
|
|
return Disabling.isDisabled(outerContainer);
|
|
}
|
|
};
|
|
return {
|
|
editorContainer: outerContainer.element.dom,
|
|
api: api
|
|
};
|
|
};
|
|
|
|
var Inline = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
render: render
|
|
});
|
|
|
|
var showContextToolbarEvent = 'contexttoolbar-show';
|
|
var hideContextToolbarEvent = 'contexttoolbar-hide';
|
|
|
|
var getFormApi = function (input) {
|
|
return {
|
|
hide: function () {
|
|
return emit(input, sandboxClose());
|
|
},
|
|
getValue: function () {
|
|
return Representing.getValue(input);
|
|
}
|
|
};
|
|
};
|
|
var runOnExecute = function (memInput, original) {
|
|
return run$1(internalToolbarButtonExecute, function (comp, se) {
|
|
var input = memInput.get(comp);
|
|
var formApi = getFormApi(input);
|
|
original.onAction(formApi, se.event.buttonApi);
|
|
});
|
|
};
|
|
var renderContextButton = function (memInput, button, extras) {
|
|
var _a = button.original; _a.primary; var rest = __rest(_a, ['primary']);
|
|
var bridged = getOrDie(createToolbarButton(__assign(__assign({}, rest), {
|
|
type: 'button',
|
|
onAction: noop
|
|
})));
|
|
return renderToolbarButtonWith(bridged, extras.backstage.shared.providers, [runOnExecute(memInput, button)]);
|
|
};
|
|
var renderContextToggleButton = function (memInput, button, extras) {
|
|
var _a = button.original; _a.primary; var rest = __rest(_a, ['primary']);
|
|
var bridged = getOrDie(createToggleButton(__assign(__assign({}, rest), {
|
|
type: 'togglebutton',
|
|
onAction: noop
|
|
})));
|
|
return renderToolbarToggleButtonWith(bridged, extras.backstage.shared.providers, [runOnExecute(memInput, button)]);
|
|
};
|
|
var generateOne = function (memInput, button, providersBackstage) {
|
|
var extras = { backstage: { shared: { providers: providersBackstage } } };
|
|
if (button.type === 'contextformtogglebutton') {
|
|
return renderContextToggleButton(memInput, button, extras);
|
|
} else {
|
|
return renderContextButton(memInput, button, extras);
|
|
}
|
|
};
|
|
var generate = function (memInput, buttons, providersBackstage) {
|
|
var mementos = map$2(buttons, function (button) {
|
|
return record(generateOne(memInput, button, providersBackstage));
|
|
});
|
|
var asSpecs = function () {
|
|
return map$2(mementos, function (mem) {
|
|
return mem.asSpec();
|
|
});
|
|
};
|
|
var findPrimary = function (compInSystem) {
|
|
return findMap(buttons, function (button, i) {
|
|
if (button.primary) {
|
|
return Optional.from(mementos[i]).bind(function (mem) {
|
|
return mem.getOpt(compInSystem);
|
|
}).filter(not(Disabling.isDisabled));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
};
|
|
return {
|
|
asSpecs: asSpecs,
|
|
findPrimary: findPrimary
|
|
};
|
|
};
|
|
|
|
var buildInitGroups = function (ctx, providers) {
|
|
var inputAttributes = ctx.label.fold(function () {
|
|
return {};
|
|
}, function (label) {
|
|
return { 'aria-label': label };
|
|
});
|
|
var memInput = record(Input.sketch({
|
|
inputClasses: [
|
|
'tox-toolbar-textfield',
|
|
'tox-toolbar-nav-js'
|
|
],
|
|
data: ctx.initValue(),
|
|
inputAttributes: inputAttributes,
|
|
selectOnFocus: true,
|
|
inputBehaviours: derive$1([Keying.config({
|
|
mode: 'special',
|
|
onEnter: function (input) {
|
|
return commands.findPrimary(input).map(function (primary) {
|
|
emitExecute(primary);
|
|
return true;
|
|
});
|
|
},
|
|
onLeft: function (comp, se) {
|
|
se.cut();
|
|
return Optional.none();
|
|
},
|
|
onRight: function (comp, se) {
|
|
se.cut();
|
|
return Optional.none();
|
|
}
|
|
})])
|
|
}));
|
|
var commands = generate(memInput, ctx.commands, providers);
|
|
return [
|
|
{
|
|
title: Optional.none(),
|
|
items: [memInput.asSpec()]
|
|
},
|
|
{
|
|
title: Optional.none(),
|
|
items: commands.asSpecs()
|
|
}
|
|
];
|
|
};
|
|
var renderContextForm = function (toolbarType, ctx, providers) {
|
|
return renderToolbar({
|
|
type: toolbarType,
|
|
uid: generate$6('context-toolbar'),
|
|
initGroups: buildInitGroups(ctx, providers),
|
|
onEscape: Optional.none,
|
|
cyclicKeying: true,
|
|
providers: providers
|
|
});
|
|
};
|
|
var ContextForm = {
|
|
renderContextForm: renderContextForm,
|
|
buildInitGroups: buildInitGroups
|
|
};
|
|
|
|
var isVerticalOverlap = function (a, b, threshold) {
|
|
if (threshold === void 0) {
|
|
threshold = 0.01;
|
|
}
|
|
return b.bottom - a.y >= threshold && a.bottom - b.y >= threshold;
|
|
};
|
|
var getRangeRect = function (rng) {
|
|
var rect = rng.getBoundingClientRect();
|
|
if (rect.height <= 0 && rect.width <= 0) {
|
|
var leaf$1 = leaf(SugarElement.fromDom(rng.startContainer), rng.startOffset).element;
|
|
var elm = isText$1(leaf$1) ? parent(leaf$1) : Optional.some(leaf$1);
|
|
return elm.filter(isElement$2).map(function (e) {
|
|
return e.dom.getBoundingClientRect();
|
|
}).getOr(rect);
|
|
} else {
|
|
return rect;
|
|
}
|
|
};
|
|
var getSelectionBounds = function (editor) {
|
|
var rng = editor.selection.getRng();
|
|
var rect = getRangeRect(rng);
|
|
if (editor.inline) {
|
|
var scroll_1 = get$9();
|
|
return bounds(scroll_1.left + rect.left, scroll_1.top + rect.top, rect.width, rect.height);
|
|
} else {
|
|
var bodyPos = absolute$2(SugarElement.fromDom(editor.getBody()));
|
|
return bounds(bodyPos.x + rect.left, bodyPos.y + rect.top, rect.width, rect.height);
|
|
}
|
|
};
|
|
var getAnchorElementBounds = function (editor, lastElement) {
|
|
return lastElement.filter(inBody).map(absolute$2).getOrThunk(function () {
|
|
return getSelectionBounds(editor);
|
|
});
|
|
};
|
|
var getHorizontalBounds = function (contentAreaBox, viewportBounds, margin) {
|
|
var x = Math.max(contentAreaBox.x + margin, viewportBounds.x);
|
|
var right = Math.min(contentAreaBox.right - margin, viewportBounds.right);
|
|
return {
|
|
x: x,
|
|
width: right - x
|
|
};
|
|
};
|
|
var getVerticalBounds = function (editor, contentAreaBox, viewportBounds, isToolbarLocationTop, toolbarType, margin) {
|
|
var container = SugarElement.fromDom(editor.getContainer());
|
|
var header = descendant(container, '.tox-editor-header').getOr(container);
|
|
var headerBox = box$1(header);
|
|
var isToolbarBelowContentArea = headerBox.y >= contentAreaBox.bottom;
|
|
var isToolbarAbove = isToolbarLocationTop && !isToolbarBelowContentArea;
|
|
if (editor.inline && isToolbarAbove) {
|
|
return {
|
|
y: Math.max(headerBox.bottom + margin, viewportBounds.y),
|
|
bottom: viewportBounds.bottom
|
|
};
|
|
}
|
|
if (editor.inline && !isToolbarAbove) {
|
|
return {
|
|
y: viewportBounds.y,
|
|
bottom: Math.min(headerBox.y - margin, viewportBounds.bottom)
|
|
};
|
|
}
|
|
var containerBounds = toolbarType === 'line' ? box$1(container) : contentAreaBox;
|
|
if (isToolbarAbove) {
|
|
return {
|
|
y: Math.max(headerBox.bottom + margin, viewportBounds.y),
|
|
bottom: Math.min(containerBounds.bottom - margin, viewportBounds.bottom)
|
|
};
|
|
}
|
|
return {
|
|
y: Math.max(containerBounds.y + margin, viewportBounds.y),
|
|
bottom: Math.min(headerBox.y - margin, viewportBounds.bottom)
|
|
};
|
|
};
|
|
var getContextToolbarBounds = function (editor, sharedBackstage, toolbarType, margin) {
|
|
if (margin === void 0) {
|
|
margin = 0;
|
|
}
|
|
var viewportBounds = getBounds$3(window);
|
|
var contentAreaBox = box$1(SugarElement.fromDom(editor.getContentAreaContainer()));
|
|
var toolbarOrMenubarEnabled = isMenubarEnabled(editor) || isToolbarEnabled(editor) || isMultipleToolbars(editor);
|
|
var _a = getHorizontalBounds(contentAreaBox, viewportBounds, margin), x = _a.x, width = _a.width;
|
|
if (editor.inline && !toolbarOrMenubarEnabled) {
|
|
return bounds(x, viewportBounds.y, width, viewportBounds.height);
|
|
} else {
|
|
var isToolbarTop = sharedBackstage.header.isPositionedAtTop();
|
|
var _b = getVerticalBounds(editor, contentAreaBox, viewportBounds, isToolbarTop, toolbarType, margin), y = _b.y, bottom = _b.bottom;
|
|
return bounds(x, y, width, bottom - y);
|
|
}
|
|
};
|
|
|
|
var bubbleSize$1 = 12;
|
|
var bubbleAlignments$1 = {
|
|
valignCentre: [],
|
|
alignCentre: [],
|
|
alignLeft: ['tox-pop--align-left'],
|
|
alignRight: ['tox-pop--align-right'],
|
|
right: ['tox-pop--right'],
|
|
left: ['tox-pop--left'],
|
|
bottom: ['tox-pop--bottom'],
|
|
top: ['tox-pop--top'],
|
|
inset: ['tox-pop--inset']
|
|
};
|
|
var anchorOverrides = {
|
|
maxHeightFunction: expandable$1(),
|
|
maxWidthFunction: expandable()
|
|
};
|
|
var isEntireElementSelected = function (editor, elem) {
|
|
var rng = editor.selection.getRng();
|
|
var leaf$1 = leaf(SugarElement.fromDom(rng.startContainer), rng.startOffset);
|
|
return rng.startContainer === rng.endContainer && rng.startOffset === rng.endOffset - 1 && eq(leaf$1.element, elem);
|
|
};
|
|
var preservePosition = function (elem, position, f) {
|
|
var currentPosition = getRaw(elem, 'position');
|
|
set$7(elem, 'position', position);
|
|
var result = f(elem);
|
|
currentPosition.each(function (pos) {
|
|
return set$7(elem, 'position', pos);
|
|
});
|
|
return result;
|
|
};
|
|
var shouldUseInsetLayouts = function (position) {
|
|
return position === 'node';
|
|
};
|
|
var determineInsetLayout = function (editor, contextbar, elem, data, bounds) {
|
|
var selectionBounds = getSelectionBounds(editor);
|
|
var isSameAnchorElement = data.lastElement().exists(function (prev) {
|
|
return eq(elem, prev);
|
|
});
|
|
if (isEntireElementSelected(editor, elem)) {
|
|
return isSameAnchorElement ? preserve : north;
|
|
} else if (isSameAnchorElement) {
|
|
return preservePosition(contextbar, data.getMode(), function () {
|
|
var isOverlapping = isVerticalOverlap(selectionBounds, box$1(contextbar));
|
|
return isOverlapping && !data.isReposition() ? flip$2 : preserve;
|
|
});
|
|
} else {
|
|
var yBounds = data.getMode() === 'fixed' ? bounds.y + get$9().top : bounds.y;
|
|
var contextbarHeight = get$b(contextbar) + bubbleSize$1;
|
|
return yBounds + contextbarHeight <= selectionBounds.y ? north : south;
|
|
}
|
|
};
|
|
var getAnchorSpec$2 = function (editor, mobile, data, position) {
|
|
var smartInsetLayout = function (elem) {
|
|
return function (anchor, element, bubbles, placee, bounds) {
|
|
var layout = determineInsetLayout(editor, placee, elem, data, bounds);
|
|
var newAnchor = __assign(__assign({}, anchor), {
|
|
y: bounds.y,
|
|
height: bounds.height
|
|
});
|
|
return __assign(__assign({}, layout(newAnchor, element, bubbles, placee, bounds)), { alwaysFit: true });
|
|
};
|
|
};
|
|
var getInsetLayouts = function (elem) {
|
|
return shouldUseInsetLayouts(position) ? [smartInsetLayout(elem)] : [];
|
|
};
|
|
var desktopAnchorSpecLayouts = {
|
|
onLtr: function (elem) {
|
|
return [
|
|
north$2,
|
|
south$2,
|
|
northeast$2,
|
|
southeast$2,
|
|
northwest$2,
|
|
southwest$2
|
|
].concat(getInsetLayouts(elem));
|
|
},
|
|
onRtl: function (elem) {
|
|
return [
|
|
north$2,
|
|
south$2,
|
|
northwest$2,
|
|
southwest$2,
|
|
northeast$2,
|
|
southeast$2
|
|
].concat(getInsetLayouts(elem));
|
|
}
|
|
};
|
|
var mobileAnchorSpecLayouts = {
|
|
onLtr: function (elem) {
|
|
return [
|
|
south$2,
|
|
southeast$2,
|
|
southwest$2,
|
|
northeast$2,
|
|
northwest$2,
|
|
north$2
|
|
].concat(getInsetLayouts(elem));
|
|
},
|
|
onRtl: function (elem) {
|
|
return [
|
|
south$2,
|
|
southwest$2,
|
|
southeast$2,
|
|
northwest$2,
|
|
northeast$2,
|
|
north$2
|
|
].concat(getInsetLayouts(elem));
|
|
}
|
|
};
|
|
return mobile ? mobileAnchorSpecLayouts : desktopAnchorSpecLayouts;
|
|
};
|
|
var getAnchorLayout = function (editor, position, isTouch, data) {
|
|
if (position === 'line') {
|
|
return {
|
|
bubble: nu$5(bubbleSize$1, 0, bubbleAlignments$1),
|
|
layouts: {
|
|
onLtr: function () {
|
|
return [east$2];
|
|
},
|
|
onRtl: function () {
|
|
return [west$2];
|
|
}
|
|
},
|
|
overrides: anchorOverrides
|
|
};
|
|
} else {
|
|
return {
|
|
bubble: nu$5(0, bubbleSize$1, bubbleAlignments$1, 1 / bubbleSize$1),
|
|
layouts: getAnchorSpec$2(editor, isTouch, data, position),
|
|
overrides: anchorOverrides
|
|
};
|
|
}
|
|
};
|
|
|
|
var matchTargetWith = function (elem, candidates) {
|
|
var ctxs = filter$2(candidates, function (toolbarApi) {
|
|
return toolbarApi.predicate(elem.dom);
|
|
});
|
|
var _a = partition$3(ctxs, function (t) {
|
|
return t.type === 'contexttoolbar';
|
|
}), pass = _a.pass, fail = _a.fail;
|
|
return {
|
|
contextToolbars: pass,
|
|
contextForms: fail
|
|
};
|
|
};
|
|
var filterByPositionForStartNode = function (toolbars) {
|
|
if (toolbars.length <= 1) {
|
|
return toolbars;
|
|
} else {
|
|
var doesPositionExist = function (value) {
|
|
return exists(toolbars, function (t) {
|
|
return t.position === value;
|
|
});
|
|
};
|
|
var filterToolbarsByPosition = function (value) {
|
|
return filter$2(toolbars, function (t) {
|
|
return t.position === value;
|
|
});
|
|
};
|
|
var hasSelectionToolbars = doesPositionExist('selection');
|
|
var hasNodeToolbars = doesPositionExist('node');
|
|
if (hasSelectionToolbars || hasNodeToolbars) {
|
|
if (hasNodeToolbars && hasSelectionToolbars) {
|
|
var nodeToolbars = filterToolbarsByPosition('node');
|
|
var selectionToolbars = map$2(filterToolbarsByPosition('selection'), function (t) {
|
|
return __assign(__assign({}, t), { position: 'node' });
|
|
});
|
|
return nodeToolbars.concat(selectionToolbars);
|
|
} else {
|
|
return hasSelectionToolbars ? filterToolbarsByPosition('selection') : filterToolbarsByPosition('node');
|
|
}
|
|
} else {
|
|
return filterToolbarsByPosition('line');
|
|
}
|
|
}
|
|
};
|
|
var filterByPositionForAncestorNode = function (toolbars) {
|
|
if (toolbars.length <= 1) {
|
|
return toolbars;
|
|
} else {
|
|
var findPosition_1 = function (value) {
|
|
return find$5(toolbars, function (t) {
|
|
return t.position === value;
|
|
});
|
|
};
|
|
var basePosition = findPosition_1('selection').orThunk(function () {
|
|
return findPosition_1('node');
|
|
}).orThunk(function () {
|
|
return findPosition_1('line');
|
|
}).map(function (t) {
|
|
return t.position;
|
|
});
|
|
return basePosition.fold(function () {
|
|
return [];
|
|
}, function (pos) {
|
|
return filter$2(toolbars, function (t) {
|
|
return t.position === pos;
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var matchStartNode = function (elem, nodeCandidates, editorCandidates) {
|
|
var nodeMatches = matchTargetWith(elem, nodeCandidates);
|
|
if (nodeMatches.contextForms.length > 0) {
|
|
return Optional.some({
|
|
elem: elem,
|
|
toolbars: [nodeMatches.contextForms[0]]
|
|
});
|
|
} else {
|
|
var editorMatches = matchTargetWith(elem, editorCandidates);
|
|
if (editorMatches.contextForms.length > 0) {
|
|
return Optional.some({
|
|
elem: elem,
|
|
toolbars: [editorMatches.contextForms[0]]
|
|
});
|
|
} else if (nodeMatches.contextToolbars.length > 0 || editorMatches.contextToolbars.length > 0) {
|
|
var toolbars = filterByPositionForStartNode(nodeMatches.contextToolbars.concat(editorMatches.contextToolbars));
|
|
return Optional.some({
|
|
elem: elem,
|
|
toolbars: toolbars
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
};
|
|
var matchAncestor = function (isRoot, startNode, scopes) {
|
|
if (isRoot(startNode)) {
|
|
return Optional.none();
|
|
} else {
|
|
return ancestor$2(startNode, function (ancestorElem) {
|
|
if (isElement$2(ancestorElem)) {
|
|
var _a = matchTargetWith(ancestorElem, scopes.inNodeScope), contextToolbars = _a.contextToolbars, contextForms = _a.contextForms;
|
|
var toolbars = contextForms.length > 0 ? contextForms : filterByPositionForAncestorNode(contextToolbars);
|
|
return toolbars.length > 0 ? Optional.some({
|
|
elem: ancestorElem,
|
|
toolbars: toolbars
|
|
}) : Optional.none();
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}, isRoot);
|
|
}
|
|
};
|
|
var lookup$1 = function (scopes, editor) {
|
|
var rootElem = SugarElement.fromDom(editor.getBody());
|
|
var isRoot = function (elem) {
|
|
return eq(elem, rootElem);
|
|
};
|
|
var isOutsideRoot = function (startNode) {
|
|
return !isRoot(startNode) && !contains(rootElem, startNode);
|
|
};
|
|
var startNode = SugarElement.fromDom(editor.selection.getNode());
|
|
if (isOutsideRoot(startNode)) {
|
|
return Optional.none();
|
|
}
|
|
return matchStartNode(startNode, scopes.inNodeScope, scopes.inEditorScope).orThunk(function () {
|
|
return matchAncestor(isRoot, startNode, scopes);
|
|
});
|
|
};
|
|
|
|
var categorise = function (contextToolbars, navigate) {
|
|
var forms = {};
|
|
var inNodeScope = [];
|
|
var inEditorScope = [];
|
|
var formNavigators = {};
|
|
var lookupTable = {};
|
|
var registerForm = function (key, toolbarSpec) {
|
|
var contextForm = getOrDie(createContextForm(toolbarSpec));
|
|
forms[key] = contextForm;
|
|
contextForm.launch.map(function (launch) {
|
|
formNavigators['form:' + key + ''] = __assign(__assign({}, toolbarSpec.launch), {
|
|
type: launch.type === 'contextformtogglebutton' ? 'togglebutton' : 'button',
|
|
onAction: function () {
|
|
navigate(contextForm);
|
|
}
|
|
});
|
|
});
|
|
if (contextForm.scope === 'editor') {
|
|
inEditorScope.push(contextForm);
|
|
} else {
|
|
inNodeScope.push(contextForm);
|
|
}
|
|
lookupTable[key] = contextForm;
|
|
};
|
|
var registerToolbar = function (key, toolbarSpec) {
|
|
createContextToolbar(toolbarSpec).each(function (contextToolbar) {
|
|
if (toolbarSpec.scope === 'editor') {
|
|
inEditorScope.push(contextToolbar);
|
|
} else {
|
|
inNodeScope.push(contextToolbar);
|
|
}
|
|
lookupTable[key] = contextToolbar;
|
|
});
|
|
};
|
|
var keys$1 = keys(contextToolbars);
|
|
each$1(keys$1, function (key) {
|
|
var toolbarApi = contextToolbars[key];
|
|
if (toolbarApi.type === 'contextform') {
|
|
registerForm(key, toolbarApi);
|
|
} else if (toolbarApi.type === 'contexttoolbar') {
|
|
registerToolbar(key, toolbarApi);
|
|
}
|
|
});
|
|
return {
|
|
forms: forms,
|
|
inNodeScope: inNodeScope,
|
|
inEditorScope: inEditorScope,
|
|
lookupTable: lookupTable,
|
|
formNavigators: formNavigators
|
|
};
|
|
};
|
|
|
|
var forwardSlideEvent = generate$6('forward-slide');
|
|
var backSlideEvent = generate$6('backward-slide');
|
|
var changeSlideEvent = generate$6('change-slide-event');
|
|
var resizingClass = 'tox-pop--resizing';
|
|
var renderContextToolbar = function (spec) {
|
|
var stack = Cell([]);
|
|
return InlineView.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-pop']
|
|
},
|
|
fireDismissalEventInstead: { event: 'doNotDismissYet' },
|
|
onShow: function (comp) {
|
|
stack.set([]);
|
|
InlineView.getContent(comp).each(function (c) {
|
|
remove$6(c.element, 'visibility');
|
|
});
|
|
remove$2(comp.element, resizingClass);
|
|
remove$6(comp.element, 'width');
|
|
},
|
|
inlineBehaviours: derive$1([
|
|
config('context-toolbar-events', [
|
|
runOnSource(transitionend(), function (comp, se) {
|
|
if (se.event.raw.propertyName === 'width') {
|
|
remove$2(comp.element, resizingClass);
|
|
remove$6(comp.element, 'width');
|
|
}
|
|
}),
|
|
run$1(changeSlideEvent, function (comp, se) {
|
|
var elem = comp.element;
|
|
remove$6(elem, 'width');
|
|
var currentWidth = get$a(elem);
|
|
InlineView.setContent(comp, se.event.contents);
|
|
add$2(elem, resizingClass);
|
|
var newWidth = get$a(elem);
|
|
set$7(elem, 'width', currentWidth + 'px');
|
|
InlineView.getContent(comp).each(function (newContents) {
|
|
se.event.focus.bind(function (f) {
|
|
focus$3(f);
|
|
return search(elem);
|
|
}).orThunk(function () {
|
|
Keying.focusIn(newContents);
|
|
return active(getRootNode(elem));
|
|
});
|
|
});
|
|
global$f.setTimeout(function () {
|
|
set$7(comp.element, 'width', newWidth + 'px');
|
|
}, 0);
|
|
}),
|
|
run$1(forwardSlideEvent, function (comp, se) {
|
|
InlineView.getContent(comp).each(function (oldContents) {
|
|
stack.set(stack.get().concat([{
|
|
bar: oldContents,
|
|
focus: active(getRootNode(comp.element))
|
|
}]));
|
|
});
|
|
emitWith(comp, changeSlideEvent, {
|
|
contents: se.event.forwardContents,
|
|
focus: Optional.none()
|
|
});
|
|
}),
|
|
run$1(backSlideEvent, function (comp, _se) {
|
|
last$2(stack.get()).each(function (last) {
|
|
stack.set(stack.get().slice(0, stack.get().length - 1));
|
|
emitWith(comp, changeSlideEvent, {
|
|
contents: premade(last.bar),
|
|
focus: last.focus
|
|
});
|
|
});
|
|
})
|
|
]),
|
|
Keying.config({
|
|
mode: 'special',
|
|
onEscape: function (comp) {
|
|
return last$2(stack.get()).fold(function () {
|
|
return spec.onEscape();
|
|
}, function (_) {
|
|
emit(comp, backSlideEvent);
|
|
return Optional.some(true);
|
|
});
|
|
}
|
|
})
|
|
]),
|
|
lazySink: function () {
|
|
return Result.value(spec.sink);
|
|
}
|
|
});
|
|
};
|
|
|
|
var transitionClass = 'tox-pop--transition';
|
|
var register$7 = function (editor, registryContextToolbars, sink, extras) {
|
|
var backstage = extras.backstage;
|
|
var sharedBackstage = backstage.shared;
|
|
var isTouch = detect$1().deviceType.isTouch;
|
|
var lastElement = value$1();
|
|
var lastTrigger = value$1();
|
|
var lastContextPosition = value$1();
|
|
var contextbar = build$1(renderContextToolbar({
|
|
sink: sink,
|
|
onEscape: function () {
|
|
editor.focus();
|
|
return Optional.some(true);
|
|
}
|
|
}));
|
|
var getBounds = function () {
|
|
var position = lastContextPosition.get().getOr('node');
|
|
var margin = shouldUseInsetLayouts(position) ? 1 : 0;
|
|
return getContextToolbarBounds(editor, sharedBackstage, position, margin);
|
|
};
|
|
var canLaunchToolbar = function () {
|
|
return !editor.removed && !(isTouch() && backstage.isContextMenuOpen());
|
|
};
|
|
var isSameLaunchElement = function (elem) {
|
|
return is$1(lift2(elem, lastElement.get(), eq), true);
|
|
};
|
|
var shouldContextToolbarHide = function () {
|
|
if (!canLaunchToolbar()) {
|
|
return true;
|
|
} else {
|
|
var contextToolbarBounds = getBounds();
|
|
var anchorBounds = is$1(lastContextPosition.get(), 'node') ? getAnchorElementBounds(editor, lastElement.get()) : getSelectionBounds(editor);
|
|
return contextToolbarBounds.height <= 0 || !isVerticalOverlap(anchorBounds, contextToolbarBounds);
|
|
}
|
|
};
|
|
var close = function () {
|
|
lastElement.clear();
|
|
lastTrigger.clear();
|
|
lastContextPosition.clear();
|
|
InlineView.hide(contextbar);
|
|
};
|
|
var hideOrRepositionIfNecessary = function () {
|
|
if (InlineView.isOpen(contextbar)) {
|
|
var contextBarEle = contextbar.element;
|
|
remove$6(contextBarEle, 'display');
|
|
if (shouldContextToolbarHide()) {
|
|
set$7(contextBarEle, 'display', 'none');
|
|
} else {
|
|
lastTrigger.set(0);
|
|
InlineView.reposition(contextbar);
|
|
}
|
|
}
|
|
};
|
|
var wrapInPopDialog = function (toolbarSpec) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-pop__dialog']
|
|
},
|
|
components: [toolbarSpec],
|
|
behaviours: derive$1([
|
|
Keying.config({ mode: 'acyclic' }),
|
|
config('pop-dialog-wrap-events', [
|
|
runOnAttached(function (comp) {
|
|
editor.shortcuts.add('ctrl+F9', 'focus statusbar', function () {
|
|
return Keying.focusIn(comp);
|
|
});
|
|
}),
|
|
runOnDetached(function (_comp) {
|
|
editor.shortcuts.remove('ctrl+F9');
|
|
})
|
|
])
|
|
])
|
|
};
|
|
};
|
|
var getScopes = cached(function () {
|
|
return categorise(registryContextToolbars, function (toolbarApi) {
|
|
var alloySpec = buildToolbar([toolbarApi]);
|
|
emitWith(contextbar, forwardSlideEvent, { forwardContents: wrapInPopDialog(alloySpec) });
|
|
});
|
|
});
|
|
var buildContextToolbarGroups = function (allButtons, ctx) {
|
|
return identifyButtons(editor, {
|
|
buttons: allButtons,
|
|
toolbar: ctx.items,
|
|
allowToolbarGroups: false
|
|
}, extras, Optional.some(['form:']));
|
|
};
|
|
var buildContextFormGroups = function (ctx, providers) {
|
|
return ContextForm.buildInitGroups(ctx, providers);
|
|
};
|
|
var buildToolbar = function (toolbars) {
|
|
var buttons = editor.ui.registry.getAll().buttons;
|
|
var scopes = getScopes();
|
|
var allButtons = __assign(__assign({}, buttons), scopes.formNavigators);
|
|
var toolbarType = getToolbarMode(editor) === ToolbarMode.scrolling ? ToolbarMode.scrolling : ToolbarMode.default;
|
|
var initGroups = flatten(map$2(toolbars, function (ctx) {
|
|
return ctx.type === 'contexttoolbar' ? buildContextToolbarGroups(allButtons, ctx) : buildContextFormGroups(ctx, sharedBackstage.providers);
|
|
}));
|
|
return renderToolbar({
|
|
type: toolbarType,
|
|
uid: generate$6('context-toolbar'),
|
|
initGroups: initGroups,
|
|
onEscape: Optional.none,
|
|
cyclicKeying: true,
|
|
providers: sharedBackstage.providers
|
|
});
|
|
};
|
|
var getAnchor = function (position, element) {
|
|
var anchorage = position === 'node' ? sharedBackstage.anchors.node(element) : sharedBackstage.anchors.cursor();
|
|
var anchorLayout = getAnchorLayout(editor, position, isTouch(), {
|
|
lastElement: lastElement.get,
|
|
isReposition: function () {
|
|
return is$1(lastTrigger.get(), 0);
|
|
},
|
|
getMode: function () {
|
|
return Positioning.getMode(sink);
|
|
}
|
|
});
|
|
return deepMerge(anchorage, anchorLayout);
|
|
};
|
|
var launchContext = function (toolbarApi, elem) {
|
|
launchContextToolbar.cancel();
|
|
if (!canLaunchToolbar()) {
|
|
return;
|
|
}
|
|
var toolbarSpec = buildToolbar(toolbarApi);
|
|
var position = toolbarApi[0].position;
|
|
var anchor = getAnchor(position, elem);
|
|
lastContextPosition.set(position);
|
|
lastTrigger.set(1);
|
|
var contextBarEle = contextbar.element;
|
|
remove$6(contextBarEle, 'display');
|
|
if (!isSameLaunchElement(elem)) {
|
|
remove$2(contextBarEle, transitionClass);
|
|
Positioning.reset(sink, contextbar);
|
|
}
|
|
InlineView.showWithinBounds(contextbar, wrapInPopDialog(toolbarSpec), {
|
|
anchor: anchor,
|
|
transition: {
|
|
classes: [transitionClass],
|
|
mode: 'placement'
|
|
}
|
|
}, function () {
|
|
return Optional.some(getBounds());
|
|
});
|
|
elem.fold(lastElement.clear, lastElement.set);
|
|
if (shouldContextToolbarHide()) {
|
|
set$7(contextBarEle, 'display', 'none');
|
|
}
|
|
};
|
|
var launchContextToolbar = last(function () {
|
|
if (!editor.hasFocus() || editor.removed) {
|
|
return;
|
|
}
|
|
if (has(contextbar.element, transitionClass)) {
|
|
launchContextToolbar.throttle();
|
|
} else {
|
|
var scopes = getScopes();
|
|
lookup$1(scopes, editor).fold(close, function (info) {
|
|
launchContext(info.toolbars, Optional.some(info.elem));
|
|
});
|
|
}
|
|
}, 17);
|
|
editor.on('init', function () {
|
|
editor.on('remove', close);
|
|
editor.on('ScrollContent ScrollWindow ObjectResized ResizeEditor longpress', hideOrRepositionIfNecessary);
|
|
editor.on('click keyup focus SetContent', launchContextToolbar.throttle);
|
|
editor.on(hideContextToolbarEvent, close);
|
|
editor.on(showContextToolbarEvent, function (e) {
|
|
var scopes = getScopes();
|
|
get$e(scopes.lookupTable, e.toolbarKey).each(function (ctx) {
|
|
launchContext([ctx], someIf(e.target !== editor, e.target));
|
|
InlineView.getContent(contextbar).each(Keying.focusIn);
|
|
});
|
|
});
|
|
editor.on('focusout', function (_e) {
|
|
global$f.setEditorTimeout(editor, function () {
|
|
if (search(sink.element).isNone() && search(contextbar.element).isNone()) {
|
|
close();
|
|
}
|
|
}, 0);
|
|
});
|
|
editor.on('SwitchMode', function () {
|
|
if (editor.mode.isReadOnly()) {
|
|
close();
|
|
}
|
|
});
|
|
editor.on('AfterProgressState', function (event) {
|
|
if (event.state) {
|
|
close();
|
|
} else if (editor.hasFocus()) {
|
|
launchContextToolbar.throttle();
|
|
}
|
|
});
|
|
editor.on('NodeChange', function (_e) {
|
|
search(contextbar.element).fold(launchContextToolbar.throttle, noop);
|
|
});
|
|
});
|
|
};
|
|
|
|
var register$6 = function (editor) {
|
|
var alignToolbarButtons = [
|
|
{
|
|
name: 'alignleft',
|
|
text: 'Align left',
|
|
cmd: 'JustifyLeft',
|
|
icon: 'align-left'
|
|
},
|
|
{
|
|
name: 'aligncenter',
|
|
text: 'Align center',
|
|
cmd: 'JustifyCenter',
|
|
icon: 'align-center'
|
|
},
|
|
{
|
|
name: 'alignright',
|
|
text: 'Align right',
|
|
cmd: 'JustifyRight',
|
|
icon: 'align-right'
|
|
},
|
|
{
|
|
name: 'alignjustify',
|
|
text: 'Justify',
|
|
cmd: 'JustifyFull',
|
|
icon: 'align-justify'
|
|
}
|
|
];
|
|
each$1(alignToolbarButtons, function (item) {
|
|
editor.ui.registry.addToggleButton(item.name, {
|
|
tooltip: item.text,
|
|
icon: item.icon,
|
|
onAction: onActionExecCommand(editor, item.cmd),
|
|
onSetup: onSetupFormatToggle(editor, item.name)
|
|
});
|
|
});
|
|
editor.ui.registry.addButton('alignnone', {
|
|
tooltip: 'No alignment',
|
|
icon: 'align-none',
|
|
onAction: onActionExecCommand(editor, 'JustifyNone')
|
|
});
|
|
};
|
|
|
|
var units = {
|
|
unsupportedLength: [
|
|
'em',
|
|
'ex',
|
|
'cap',
|
|
'ch',
|
|
'ic',
|
|
'rem',
|
|
'lh',
|
|
'rlh',
|
|
'vw',
|
|
'vh',
|
|
'vi',
|
|
'vb',
|
|
'vmin',
|
|
'vmax',
|
|
'cm',
|
|
'mm',
|
|
'Q',
|
|
'in',
|
|
'pc',
|
|
'pt',
|
|
'px'
|
|
],
|
|
fixed: [
|
|
'px',
|
|
'pt'
|
|
],
|
|
relative: ['%'],
|
|
empty: ['']
|
|
};
|
|
var pattern = function () {
|
|
var decimalDigits = '[0-9]+';
|
|
var signedInteger = '[+-]?' + decimalDigits;
|
|
var exponentPart = '[eE]' + signedInteger;
|
|
var dot = '\\.';
|
|
var opt = function (input) {
|
|
return '(?:' + input + ')?';
|
|
};
|
|
var unsignedDecimalLiteral = [
|
|
'Infinity',
|
|
decimalDigits + dot + opt(decimalDigits) + opt(exponentPart),
|
|
dot + decimalDigits + opt(exponentPart),
|
|
decimalDigits + opt(exponentPart)
|
|
].join('|');
|
|
var float = '[+-]?(?:' + unsignedDecimalLiteral + ')';
|
|
return new RegExp('^(' + float + ')(.*)$');
|
|
}();
|
|
var isUnit = function (unit, accepted) {
|
|
return exists(accepted, function (acc) {
|
|
return exists(units[acc], function (check) {
|
|
return unit === check;
|
|
});
|
|
});
|
|
};
|
|
var parse = function (input, accepted) {
|
|
var match = Optional.from(pattern.exec(input));
|
|
return match.bind(function (array) {
|
|
var value = Number(array[1]);
|
|
var unitRaw = array[2];
|
|
if (isUnit(unitRaw, accepted)) {
|
|
return Optional.some({
|
|
value: value,
|
|
unit: unitRaw
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
};
|
|
var normalise = function (input, accepted) {
|
|
return parse(input, accepted).map(function (_a) {
|
|
var value = _a.value, unit = _a.unit;
|
|
return value + unit;
|
|
});
|
|
};
|
|
|
|
var registerController = function (editor, spec) {
|
|
var getMenuItems = function () {
|
|
var options = spec.getOptions(editor);
|
|
var initial = spec.getCurrent(editor).map(spec.hash);
|
|
var current = value$1();
|
|
return map$2(options, function (value) {
|
|
return {
|
|
type: 'togglemenuitem',
|
|
text: spec.display(value),
|
|
onSetup: function (api) {
|
|
var setActive = function (active) {
|
|
if (active) {
|
|
current.on(function (oldApi) {
|
|
return oldApi.setActive(false);
|
|
});
|
|
current.set(api);
|
|
}
|
|
api.setActive(active);
|
|
};
|
|
setActive(is$1(initial, spec.hash(value)));
|
|
var unbindWatcher = spec.watcher(editor, value, setActive);
|
|
return function () {
|
|
current.clear();
|
|
unbindWatcher();
|
|
};
|
|
},
|
|
onAction: function () {
|
|
return spec.setCurrent(editor, value);
|
|
}
|
|
};
|
|
});
|
|
};
|
|
editor.ui.registry.addMenuButton(spec.name, {
|
|
tooltip: spec.text,
|
|
icon: spec.icon,
|
|
fetch: function (callback) {
|
|
return callback(getMenuItems());
|
|
},
|
|
onSetup: spec.onToolbarSetup
|
|
});
|
|
editor.ui.registry.addNestedMenuItem(spec.name, {
|
|
type: 'nestedmenuitem',
|
|
text: spec.text,
|
|
getSubmenuItems: getMenuItems,
|
|
onSetup: spec.onMenuSetup
|
|
});
|
|
};
|
|
var lineHeightSpec = {
|
|
name: 'lineheight',
|
|
text: 'Line height',
|
|
icon: 'line-height',
|
|
getOptions: getLineHeightFormats,
|
|
hash: function (input) {
|
|
return normalise(input, [
|
|
'fixed',
|
|
'relative',
|
|
'empty'
|
|
]).getOr(input);
|
|
},
|
|
display: identity$1,
|
|
watcher: function (editor, value, callback) {
|
|
return editor.formatter.formatChanged('lineheight', callback, false, { value: value }).unbind;
|
|
},
|
|
getCurrent: function (editor) {
|
|
return Optional.from(editor.queryCommandValue('LineHeight'));
|
|
},
|
|
setCurrent: function (editor, value) {
|
|
return editor.execCommand('LineHeight', false, value);
|
|
}
|
|
};
|
|
var languageSpec = function (editor) {
|
|
var settingsOpt = Optional.from(getContentLanguages(editor));
|
|
return settingsOpt.map(function (settings) {
|
|
return {
|
|
name: 'language',
|
|
text: 'Language',
|
|
icon: 'language',
|
|
getOptions: constant$1(settings),
|
|
hash: function (input) {
|
|
return isUndefined(input.customCode) ? input.code : input.code + '/' + input.customCode;
|
|
},
|
|
display: function (input) {
|
|
return input.title;
|
|
},
|
|
watcher: function (editor, value, callback) {
|
|
return editor.formatter.formatChanged('lang', callback, false, {
|
|
value: value.code,
|
|
customValue: value.customCode
|
|
}).unbind;
|
|
},
|
|
getCurrent: function (editor) {
|
|
var node = SugarElement.fromDom(editor.selection.getNode());
|
|
return closest$4(node, function (n) {
|
|
return Optional.some(n).filter(isElement$2).bind(function (ele) {
|
|
var codeOpt = getOpt(ele, 'lang');
|
|
return codeOpt.map(function (code) {
|
|
var customCode = getOpt(ele, 'data-mce-lang').getOrUndefined();
|
|
return {
|
|
code: code,
|
|
customCode: customCode,
|
|
title: ''
|
|
};
|
|
});
|
|
});
|
|
});
|
|
},
|
|
setCurrent: function (editor, lang) {
|
|
return editor.execCommand('Lang', false, lang);
|
|
},
|
|
onToolbarSetup: function (api) {
|
|
var unbinder = unbindable();
|
|
api.setActive(editor.formatter.match('lang', {}, undefined, true));
|
|
unbinder.set(editor.formatter.formatChanged('lang', api.setActive, true));
|
|
return unbinder.clear;
|
|
}
|
|
};
|
|
});
|
|
};
|
|
var register$5 = function (editor) {
|
|
registerController(editor, lineHeightSpec);
|
|
languageSpec(editor).each(function (spec) {
|
|
return registerController(editor, spec);
|
|
});
|
|
};
|
|
|
|
var register$4 = function (editor, backstage) {
|
|
alignSelectMenu(editor, backstage);
|
|
fontSelectMenu(editor, backstage);
|
|
styleSelectMenu(editor, backstage);
|
|
formatSelectMenu(editor, backstage);
|
|
fontsizeSelectMenu(editor, backstage);
|
|
};
|
|
|
|
var onSetupOutdentState = function (editor) {
|
|
return onSetupEvent(editor, 'NodeChange', function (api) {
|
|
api.setDisabled(!editor.queryCommandState('outdent'));
|
|
});
|
|
};
|
|
var registerButtons$2 = function (editor) {
|
|
editor.ui.registry.addButton('outdent', {
|
|
tooltip: 'Decrease indent',
|
|
icon: 'outdent',
|
|
onSetup: onSetupOutdentState(editor),
|
|
onAction: onActionExecCommand(editor, 'outdent')
|
|
});
|
|
editor.ui.registry.addButton('indent', {
|
|
tooltip: 'Increase indent',
|
|
icon: 'indent',
|
|
onAction: onActionExecCommand(editor, 'indent')
|
|
});
|
|
};
|
|
var register$3 = function (editor) {
|
|
registerButtons$2(editor);
|
|
};
|
|
|
|
var onActionToggleFormat = function (editor, fmt) {
|
|
return function () {
|
|
editor.execCommand('mceToggleFormat', false, fmt);
|
|
};
|
|
};
|
|
var registerFormatButtons = function (editor) {
|
|
global$5.each([
|
|
{
|
|
name: 'bold',
|
|
text: 'Bold',
|
|
icon: 'bold'
|
|
},
|
|
{
|
|
name: 'italic',
|
|
text: 'Italic',
|
|
icon: 'italic'
|
|
},
|
|
{
|
|
name: 'underline',
|
|
text: 'Underline',
|
|
icon: 'underline'
|
|
},
|
|
{
|
|
name: 'strikethrough',
|
|
text: 'Strikethrough',
|
|
icon: 'strike-through'
|
|
},
|
|
{
|
|
name: 'subscript',
|
|
text: 'Subscript',
|
|
icon: 'subscript'
|
|
},
|
|
{
|
|
name: 'superscript',
|
|
text: 'Superscript',
|
|
icon: 'superscript'
|
|
}
|
|
], function (btn, _idx) {
|
|
editor.ui.registry.addToggleButton(btn.name, {
|
|
tooltip: btn.text,
|
|
icon: btn.icon,
|
|
onSetup: onSetupFormatToggle(editor, btn.name),
|
|
onAction: onActionToggleFormat(editor, btn.name)
|
|
});
|
|
});
|
|
for (var i = 1; i <= 6; i++) {
|
|
var name_1 = 'h' + i;
|
|
editor.ui.registry.addToggleButton(name_1, {
|
|
text: name_1.toUpperCase(),
|
|
tooltip: 'Heading ' + i,
|
|
onSetup: onSetupFormatToggle(editor, name_1),
|
|
onAction: onActionToggleFormat(editor, name_1)
|
|
});
|
|
}
|
|
};
|
|
var registerCommandButtons = function (editor) {
|
|
global$5.each([
|
|
{
|
|
name: 'cut',
|
|
text: 'Cut',
|
|
action: 'Cut',
|
|
icon: 'cut'
|
|
},
|
|
{
|
|
name: 'copy',
|
|
text: 'Copy',
|
|
action: 'Copy',
|
|
icon: 'copy'
|
|
},
|
|
{
|
|
name: 'paste',
|
|
text: 'Paste',
|
|
action: 'Paste',
|
|
icon: 'paste'
|
|
},
|
|
{
|
|
name: 'help',
|
|
text: 'Help',
|
|
action: 'mceHelp',
|
|
icon: 'help'
|
|
},
|
|
{
|
|
name: 'selectall',
|
|
text: 'Select all',
|
|
action: 'SelectAll',
|
|
icon: 'select-all'
|
|
},
|
|
{
|
|
name: 'newdocument',
|
|
text: 'New document',
|
|
action: 'mceNewDocument',
|
|
icon: 'new-document'
|
|
},
|
|
{
|
|
name: 'removeformat',
|
|
text: 'Clear formatting',
|
|
action: 'RemoveFormat',
|
|
icon: 'remove-formatting'
|
|
},
|
|
{
|
|
name: 'remove',
|
|
text: 'Remove',
|
|
action: 'Delete',
|
|
icon: 'remove'
|
|
}
|
|
], function (btn) {
|
|
editor.ui.registry.addButton(btn.name, {
|
|
tooltip: btn.text,
|
|
icon: btn.icon,
|
|
onAction: onActionExecCommand(editor, btn.action)
|
|
});
|
|
});
|
|
};
|
|
var registerCommandToggleButtons = function (editor) {
|
|
global$5.each([{
|
|
name: 'blockquote',
|
|
text: 'Blockquote',
|
|
action: 'mceBlockQuote',
|
|
icon: 'quote'
|
|
}], function (btn) {
|
|
editor.ui.registry.addToggleButton(btn.name, {
|
|
tooltip: btn.text,
|
|
icon: btn.icon,
|
|
onAction: onActionExecCommand(editor, btn.action),
|
|
onSetup: onSetupFormatToggle(editor, btn.name)
|
|
});
|
|
});
|
|
};
|
|
var registerButtons$1 = function (editor) {
|
|
registerFormatButtons(editor);
|
|
registerCommandButtons(editor);
|
|
registerCommandToggleButtons(editor);
|
|
};
|
|
var registerMenuItems$2 = function (editor) {
|
|
global$5.each([
|
|
{
|
|
name: 'bold',
|
|
text: 'Bold',
|
|
action: 'Bold',
|
|
icon: 'bold',
|
|
shortcut: 'Meta+B'
|
|
},
|
|
{
|
|
name: 'italic',
|
|
text: 'Italic',
|
|
action: 'Italic',
|
|
icon: 'italic',
|
|
shortcut: 'Meta+I'
|
|
},
|
|
{
|
|
name: 'underline',
|
|
text: 'Underline',
|
|
action: 'Underline',
|
|
icon: 'underline',
|
|
shortcut: 'Meta+U'
|
|
},
|
|
{
|
|
name: 'strikethrough',
|
|
text: 'Strikethrough',
|
|
action: 'Strikethrough',
|
|
icon: 'strike-through',
|
|
shortcut: ''
|
|
},
|
|
{
|
|
name: 'subscript',
|
|
text: 'Subscript',
|
|
action: 'Subscript',
|
|
icon: 'subscript',
|
|
shortcut: ''
|
|
},
|
|
{
|
|
name: 'superscript',
|
|
text: 'Superscript',
|
|
action: 'Superscript',
|
|
icon: 'superscript',
|
|
shortcut: ''
|
|
},
|
|
{
|
|
name: 'removeformat',
|
|
text: 'Clear formatting',
|
|
action: 'RemoveFormat',
|
|
icon: 'remove-formatting',
|
|
shortcut: ''
|
|
},
|
|
{
|
|
name: 'newdocument',
|
|
text: 'New document',
|
|
action: 'mceNewDocument',
|
|
icon: 'new-document',
|
|
shortcut: ''
|
|
},
|
|
{
|
|
name: 'cut',
|
|
text: 'Cut',
|
|
action: 'Cut',
|
|
icon: 'cut',
|
|
shortcut: 'Meta+X'
|
|
},
|
|
{
|
|
name: 'copy',
|
|
text: 'Copy',
|
|
action: 'Copy',
|
|
icon: 'copy',
|
|
shortcut: 'Meta+C'
|
|
},
|
|
{
|
|
name: 'paste',
|
|
text: 'Paste',
|
|
action: 'Paste',
|
|
icon: 'paste',
|
|
shortcut: 'Meta+V'
|
|
},
|
|
{
|
|
name: 'selectall',
|
|
text: 'Select all',
|
|
action: 'SelectAll',
|
|
icon: 'select-all',
|
|
shortcut: 'Meta+A'
|
|
}
|
|
], function (btn) {
|
|
editor.ui.registry.addMenuItem(btn.name, {
|
|
text: btn.text,
|
|
icon: btn.icon,
|
|
shortcut: btn.shortcut,
|
|
onAction: onActionExecCommand(editor, btn.action)
|
|
});
|
|
});
|
|
editor.ui.registry.addMenuItem('codeformat', {
|
|
text: 'Code',
|
|
icon: 'sourcecode',
|
|
onAction: onActionToggleFormat(editor, 'code')
|
|
});
|
|
};
|
|
var register$2 = function (editor) {
|
|
registerButtons$1(editor);
|
|
registerMenuItems$2(editor);
|
|
};
|
|
|
|
var onSetupUndoRedoState = function (editor, type) {
|
|
return onSetupEvent(editor, 'Undo Redo AddUndo TypingUndo ClearUndos SwitchMode', function (api) {
|
|
api.setDisabled(editor.mode.isReadOnly() || !editor.undoManager[type]());
|
|
});
|
|
};
|
|
var registerMenuItems$1 = function (editor) {
|
|
editor.ui.registry.addMenuItem('undo', {
|
|
text: 'Undo',
|
|
icon: 'undo',
|
|
shortcut: 'Meta+Z',
|
|
onSetup: onSetupUndoRedoState(editor, 'hasUndo'),
|
|
onAction: onActionExecCommand(editor, 'undo')
|
|
});
|
|
editor.ui.registry.addMenuItem('redo', {
|
|
text: 'Redo',
|
|
icon: 'redo',
|
|
shortcut: 'Meta+Y',
|
|
onSetup: onSetupUndoRedoState(editor, 'hasRedo'),
|
|
onAction: onActionExecCommand(editor, 'redo')
|
|
});
|
|
};
|
|
var registerButtons = function (editor) {
|
|
editor.ui.registry.addButton('undo', {
|
|
tooltip: 'Undo',
|
|
icon: 'undo',
|
|
disabled: true,
|
|
onSetup: onSetupUndoRedoState(editor, 'hasUndo'),
|
|
onAction: onActionExecCommand(editor, 'undo')
|
|
});
|
|
editor.ui.registry.addButton('redo', {
|
|
tooltip: 'Redo',
|
|
icon: 'redo',
|
|
disabled: true,
|
|
onSetup: onSetupUndoRedoState(editor, 'hasRedo'),
|
|
onAction: onActionExecCommand(editor, 'redo')
|
|
});
|
|
};
|
|
var register$1 = function (editor) {
|
|
registerMenuItems$1(editor);
|
|
registerButtons(editor);
|
|
};
|
|
|
|
var onSetupVisualAidState = function (editor) {
|
|
return onSetupEvent(editor, 'VisualAid', function (api) {
|
|
api.setActive(editor.hasVisual);
|
|
});
|
|
};
|
|
var registerMenuItems = function (editor) {
|
|
editor.ui.registry.addToggleMenuItem('visualaid', {
|
|
text: 'Visual aids',
|
|
onSetup: onSetupVisualAidState(editor),
|
|
onAction: onActionExecCommand(editor, 'mceToggleVisualAid')
|
|
});
|
|
};
|
|
var registerToolbarButton = function (editor) {
|
|
editor.ui.registry.addButton('visualaid', {
|
|
tooltip: 'Visual aids',
|
|
text: 'Visual aids',
|
|
onAction: onActionExecCommand(editor, 'mceToggleVisualAid')
|
|
});
|
|
};
|
|
var register = function (editor) {
|
|
registerToolbarButton(editor);
|
|
registerMenuItems(editor);
|
|
};
|
|
|
|
var setup$6 = function (editor, backstage) {
|
|
register$6(editor);
|
|
register$2(editor);
|
|
register$4(editor, backstage);
|
|
register$1(editor);
|
|
register$a(editor);
|
|
register(editor);
|
|
register$3(editor);
|
|
register$5(editor);
|
|
};
|
|
|
|
var nu = function (x, y) {
|
|
return {
|
|
type: 'makeshift',
|
|
x: x,
|
|
y: y
|
|
};
|
|
};
|
|
var transpose = function (pos, dx, dy) {
|
|
return nu(pos.x + dx, pos.y + dy);
|
|
};
|
|
var isTouchEvent = function (e) {
|
|
return e.type === 'longpress' || e.type.indexOf('touch') === 0;
|
|
};
|
|
var fromPageXY = function (e) {
|
|
if (isTouchEvent(e)) {
|
|
var touch = e.touches[0];
|
|
return nu(touch.pageX, touch.pageY);
|
|
} else {
|
|
return nu(e.pageX, e.pageY);
|
|
}
|
|
};
|
|
var fromClientXY = function (e) {
|
|
if (isTouchEvent(e)) {
|
|
var touch = e.touches[0];
|
|
return nu(touch.clientX, touch.clientY);
|
|
} else {
|
|
return nu(e.clientX, e.clientY);
|
|
}
|
|
};
|
|
var transposeContentAreaContainer = function (element, pos) {
|
|
var containerPos = global$b.DOM.getPos(element);
|
|
return transpose(pos, containerPos.x, containerPos.y);
|
|
};
|
|
var getPointAnchor = function (editor, e) {
|
|
if (e.type === 'contextmenu' || e.type === 'longpress') {
|
|
if (editor.inline) {
|
|
return fromPageXY(e);
|
|
} else {
|
|
return transposeContentAreaContainer(editor.getContentAreaContainer(), fromClientXY(e));
|
|
}
|
|
} else {
|
|
return getSelectionAnchor(editor);
|
|
}
|
|
};
|
|
var getSelectionAnchor = function (editor) {
|
|
return {
|
|
type: 'selection',
|
|
root: SugarElement.fromDom(editor.selection.getNode())
|
|
};
|
|
};
|
|
var getNodeAnchor = function (editor) {
|
|
return {
|
|
type: 'node',
|
|
node: Optional.some(SugarElement.fromDom(editor.selection.getNode())),
|
|
root: SugarElement.fromDom(editor.getBody())
|
|
};
|
|
};
|
|
var getAnchorSpec$1 = function (editor, e, anchorType) {
|
|
switch (anchorType) {
|
|
case 'node':
|
|
return getNodeAnchor(editor);
|
|
case 'point':
|
|
return getPointAnchor(editor, e);
|
|
case 'selection':
|
|
return getSelectionAnchor(editor);
|
|
}
|
|
};
|
|
|
|
var initAndShow$1 = function (editor, e, buildMenu, backstage, contextmenu, anchorType) {
|
|
var items = buildMenu();
|
|
var anchorSpec = getAnchorSpec$1(editor, e, anchorType);
|
|
build(items, ItemResponse$1.CLOSE_ON_EXECUTE, backstage, false).map(function (menuData) {
|
|
e.preventDefault();
|
|
InlineView.showMenuAt(contextmenu, { anchor: anchorSpec }, {
|
|
menu: { markers: markers('normal') },
|
|
data: menuData
|
|
});
|
|
});
|
|
};
|
|
|
|
var layouts = {
|
|
onLtr: function () {
|
|
return [
|
|
south$2,
|
|
southeast$2,
|
|
southwest$2,
|
|
northeast$2,
|
|
northwest$2,
|
|
north$2,
|
|
north,
|
|
south,
|
|
northeast,
|
|
southeast,
|
|
northwest,
|
|
southwest
|
|
];
|
|
},
|
|
onRtl: function () {
|
|
return [
|
|
south$2,
|
|
southwest$2,
|
|
southeast$2,
|
|
northwest$2,
|
|
northeast$2,
|
|
north$2,
|
|
north,
|
|
south,
|
|
northwest,
|
|
southwest,
|
|
northeast,
|
|
southeast
|
|
];
|
|
}
|
|
};
|
|
var bubbleSize = 12;
|
|
var bubbleAlignments = {
|
|
valignCentre: [],
|
|
alignCentre: [],
|
|
alignLeft: ['tox-pop--align-left'],
|
|
alignRight: ['tox-pop--align-right'],
|
|
right: ['tox-pop--right'],
|
|
left: ['tox-pop--left'],
|
|
bottom: ['tox-pop--bottom'],
|
|
top: ['tox-pop--top']
|
|
};
|
|
var isTouchWithinSelection = function (editor, e) {
|
|
var selection = editor.selection;
|
|
if (selection.isCollapsed() || e.touches.length < 1) {
|
|
return false;
|
|
} else {
|
|
var touch_1 = e.touches[0];
|
|
var rng = selection.getRng();
|
|
var rngRectOpt = getFirstRect(editor.getWin(), SimSelection.domRange(rng));
|
|
return rngRectOpt.exists(function (rngRect) {
|
|
return rngRect.left <= touch_1.clientX && rngRect.right >= touch_1.clientX && rngRect.top <= touch_1.clientY && rngRect.bottom >= touch_1.clientY;
|
|
});
|
|
}
|
|
};
|
|
var setupiOSOverrides = function (editor) {
|
|
var originalSelection = editor.selection.getRng();
|
|
var selectionReset = function () {
|
|
global$f.setEditorTimeout(editor, function () {
|
|
editor.selection.setRng(originalSelection);
|
|
}, 10);
|
|
unbindEventListeners();
|
|
};
|
|
editor.once('touchend', selectionReset);
|
|
var preventMousedown = function (e) {
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
};
|
|
editor.on('mousedown', preventMousedown, true);
|
|
var clearSelectionReset = function () {
|
|
return unbindEventListeners();
|
|
};
|
|
editor.once('longpresscancel', clearSelectionReset);
|
|
var unbindEventListeners = function () {
|
|
editor.off('touchend', selectionReset);
|
|
editor.off('longpresscancel', clearSelectionReset);
|
|
editor.off('mousedown', preventMousedown);
|
|
};
|
|
};
|
|
var getAnchorSpec = function (editor, e, anchorType) {
|
|
var anchorSpec = getAnchorSpec$1(editor, e, anchorType);
|
|
var bubbleYOffset = anchorType === 'point' ? bubbleSize : 0;
|
|
return __assign({
|
|
bubble: nu$5(0, bubbleYOffset, bubbleAlignments),
|
|
layouts: layouts,
|
|
overrides: {
|
|
maxWidthFunction: expandable(),
|
|
maxHeightFunction: expandable$1()
|
|
}
|
|
}, anchorSpec);
|
|
};
|
|
var show = function (editor, e, items, backstage, contextmenu, anchorType, highlightImmediately) {
|
|
var anchorSpec = getAnchorSpec(editor, e, anchorType);
|
|
build(items, ItemResponse$1.CLOSE_ON_EXECUTE, backstage, true).map(function (menuData) {
|
|
e.preventDefault();
|
|
InlineView.showMenuWithinBounds(contextmenu, { anchor: anchorSpec }, {
|
|
menu: {
|
|
markers: markers('normal'),
|
|
highlightImmediately: highlightImmediately
|
|
},
|
|
data: menuData,
|
|
type: 'horizontal'
|
|
}, function () {
|
|
return Optional.some(getContextToolbarBounds(editor, backstage.shared, anchorType === 'node' ? 'node' : 'selection'));
|
|
});
|
|
editor.fire(hideContextToolbarEvent);
|
|
});
|
|
};
|
|
var initAndShow = function (editor, e, buildMenu, backstage, contextmenu, anchorType) {
|
|
var detection = detect$1();
|
|
var isiOS = detection.os.isiOS();
|
|
var isOSX = detection.os.isOSX();
|
|
var isAndroid = detection.os.isAndroid();
|
|
var isTouch = detection.deviceType.isTouch();
|
|
var shouldHighlightImmediately = function () {
|
|
return !(isAndroid || isiOS || isOSX && isTouch);
|
|
};
|
|
var open = function () {
|
|
var items = buildMenu();
|
|
show(editor, e, items, backstage, contextmenu, anchorType, shouldHighlightImmediately());
|
|
};
|
|
if ((isOSX || isiOS) && anchorType !== 'node') {
|
|
var openiOS_1 = function () {
|
|
setupiOSOverrides(editor);
|
|
open();
|
|
};
|
|
if (isTouchWithinSelection(editor, e)) {
|
|
openiOS_1();
|
|
} else {
|
|
editor.once('selectionchange', openiOS_1);
|
|
editor.once('touchend', function () {
|
|
return editor.off('selectionchange', openiOS_1);
|
|
});
|
|
}
|
|
} else {
|
|
open();
|
|
}
|
|
};
|
|
|
|
var patchPipeConfig = function (config) {
|
|
return typeof config === 'string' ? config.split(/[ ,]/) : config;
|
|
};
|
|
var shouldNeverUseNative = function (editor) {
|
|
return editor.getParam('contextmenu_never_use_native', false, 'boolean');
|
|
};
|
|
var getMenuItems = function (editor, name, defaultItems) {
|
|
var contextMenus = editor.ui.registry.getAll().contextMenus;
|
|
return Optional.from(editor.getParam(name)).map(patchPipeConfig).getOrThunk(function () {
|
|
return filter$2(patchPipeConfig(defaultItems), function (item) {
|
|
return has$2(contextMenus, item);
|
|
});
|
|
});
|
|
};
|
|
var isContextMenuDisabled = function (editor) {
|
|
return editor.getParam('contextmenu') === false;
|
|
};
|
|
var getContextMenu = function (editor) {
|
|
return getMenuItems(editor, 'contextmenu', 'link linkchecker image imagetools table spellchecker configurepermanentpen');
|
|
};
|
|
var getAvoidOverlapSelector = function (editor) {
|
|
return editor.getParam('contextmenu_avoid_overlap', '', 'string');
|
|
};
|
|
|
|
var isSeparator = function (item) {
|
|
return isString(item) ? item === '|' : item.type === 'separator';
|
|
};
|
|
var separator = { type: 'separator' };
|
|
var makeContextItem = function (item) {
|
|
var commonMenuItem = function (item) {
|
|
return {
|
|
text: item.text,
|
|
icon: item.icon,
|
|
disabled: item.disabled,
|
|
shortcut: item.shortcut
|
|
};
|
|
};
|
|
if (isString(item)) {
|
|
return item;
|
|
} else {
|
|
switch (item.type) {
|
|
case 'separator':
|
|
return separator;
|
|
case 'submenu':
|
|
return __assign(__assign({ type: 'nestedmenuitem' }, commonMenuItem(item)), {
|
|
getSubmenuItems: function () {
|
|
var items = item.getSubmenuItems();
|
|
if (isString(items)) {
|
|
return items;
|
|
} else {
|
|
return map$2(items, makeContextItem);
|
|
}
|
|
}
|
|
});
|
|
default:
|
|
return __assign(__assign({ type: 'menuitem' }, commonMenuItem(item)), { onAction: noarg(item.onAction) });
|
|
}
|
|
}
|
|
};
|
|
var addContextMenuGroup = function (xs, groupItems) {
|
|
if (groupItems.length === 0) {
|
|
return xs;
|
|
}
|
|
var lastMenuItem = last$2(xs).filter(function (item) {
|
|
return !isSeparator(item);
|
|
});
|
|
var before = lastMenuItem.fold(function () {
|
|
return [];
|
|
}, function (_) {
|
|
return [separator];
|
|
});
|
|
return xs.concat(before).concat(groupItems).concat([separator]);
|
|
};
|
|
var generateContextMenu = function (contextMenus, menuConfig, selectedElement) {
|
|
var sections = foldl(menuConfig, function (acc, name) {
|
|
return get$e(contextMenus, name.toLowerCase()).map(function (menu) {
|
|
var items = menu.update(selectedElement);
|
|
if (isString(items)) {
|
|
return addContextMenuGroup(acc, items.split(' '));
|
|
} else if (items.length > 0) {
|
|
var allItems = map$2(items, makeContextItem);
|
|
return addContextMenuGroup(acc, allItems);
|
|
} else {
|
|
return acc;
|
|
}
|
|
}).getOrThunk(function () {
|
|
return acc.concat([name]);
|
|
});
|
|
}, []);
|
|
if (sections.length > 0 && isSeparator(sections[sections.length - 1])) {
|
|
sections.pop();
|
|
}
|
|
return sections;
|
|
};
|
|
var isNativeOverrideKeyEvent = function (editor, e) {
|
|
return e.ctrlKey && !shouldNeverUseNative(editor);
|
|
};
|
|
var isTriggeredByKeyboard = function (editor, e) {
|
|
return e.type !== 'longpress' && (e.button !== 2 || e.target === editor.getBody() && e.pointerType === '');
|
|
};
|
|
var getSelectedElement = function (editor, e) {
|
|
return isTriggeredByKeyboard(editor, e) ? editor.selection.getStart(true) : e.target;
|
|
};
|
|
var getAnchorType = function (editor, e) {
|
|
var selector = getAvoidOverlapSelector(editor);
|
|
var anchorType = isTriggeredByKeyboard(editor, e) ? 'selection' : 'point';
|
|
if (isNotEmpty(selector)) {
|
|
var target = getSelectedElement(editor, e);
|
|
var selectorExists = closest(SugarElement.fromDom(target), selector);
|
|
return selectorExists ? 'node' : anchorType;
|
|
} else {
|
|
return anchorType;
|
|
}
|
|
};
|
|
var setup$5 = function (editor, lazySink, backstage) {
|
|
var detection = detect$1();
|
|
var isTouch = detection.deviceType.isTouch;
|
|
var contextmenu = build$1(InlineView.sketch({
|
|
dom: { tag: 'div' },
|
|
lazySink: lazySink,
|
|
onEscape: function () {
|
|
return editor.focus();
|
|
},
|
|
onShow: function () {
|
|
return backstage.setContextMenuState(true);
|
|
},
|
|
onHide: function () {
|
|
return backstage.setContextMenuState(false);
|
|
},
|
|
fireDismissalEventInstead: {},
|
|
inlineBehaviours: derive$1([config('dismissContextMenu', [run$1(dismissRequested(), function (comp, _se) {
|
|
Sandboxing.close(comp);
|
|
editor.focus();
|
|
})])])
|
|
}));
|
|
var hideContextMenu = function (_e) {
|
|
return InlineView.hide(contextmenu);
|
|
};
|
|
var showContextMenu = function (e) {
|
|
if (shouldNeverUseNative(editor)) {
|
|
e.preventDefault();
|
|
}
|
|
if (isNativeOverrideKeyEvent(editor, e) || isContextMenuDisabled(editor)) {
|
|
return;
|
|
}
|
|
var anchorType = getAnchorType(editor, e);
|
|
var buildMenu = function () {
|
|
var selectedElement = getSelectedElement(editor, e);
|
|
var registry = editor.ui.registry.getAll();
|
|
var menuConfig = getContextMenu(editor);
|
|
return generateContextMenu(registry.contextMenus, menuConfig, selectedElement);
|
|
};
|
|
var initAndShow$2 = isTouch() ? initAndShow : initAndShow$1;
|
|
initAndShow$2(editor, e, buildMenu, backstage, contextmenu, anchorType);
|
|
};
|
|
editor.on('init', function () {
|
|
var hideEvents = 'ResizeEditor ScrollContent ScrollWindow longpresscancel' + (isTouch() ? '' : ' ResizeWindow');
|
|
editor.on(hideEvents, hideContextMenu);
|
|
editor.on('longpress contextmenu', showContextMenu);
|
|
});
|
|
};
|
|
|
|
var adt = Adt.generate([
|
|
{
|
|
offset: [
|
|
'x',
|
|
'y'
|
|
]
|
|
},
|
|
{
|
|
absolute: [
|
|
'x',
|
|
'y'
|
|
]
|
|
},
|
|
{
|
|
fixed: [
|
|
'x',
|
|
'y'
|
|
]
|
|
}
|
|
]);
|
|
var subtract = function (change) {
|
|
return function (point) {
|
|
return point.translate(-change.left, -change.top);
|
|
};
|
|
};
|
|
var add = function (change) {
|
|
return function (point) {
|
|
return point.translate(change.left, change.top);
|
|
};
|
|
};
|
|
var transform = function (changes) {
|
|
return function (x, y) {
|
|
return foldl(changes, function (rest, f) {
|
|
return f(rest);
|
|
}, SugarPosition(x, y));
|
|
};
|
|
};
|
|
var asFixed = function (coord, scroll, origin) {
|
|
return coord.fold(transform([
|
|
add(origin),
|
|
subtract(scroll)
|
|
]), transform([subtract(scroll)]), transform([]));
|
|
};
|
|
var asAbsolute = function (coord, scroll, origin) {
|
|
return coord.fold(transform([add(origin)]), transform([]), transform([add(scroll)]));
|
|
};
|
|
var asOffset = function (coord, scroll, origin) {
|
|
return coord.fold(transform([]), transform([subtract(origin)]), transform([
|
|
add(scroll),
|
|
subtract(origin)
|
|
]));
|
|
};
|
|
var withinRange = function (coord1, coord2, xRange, yRange, scroll, origin) {
|
|
var a1 = asAbsolute(coord1, scroll, origin);
|
|
var a2 = asAbsolute(coord2, scroll, origin);
|
|
return Math.abs(a1.left - a2.left) <= xRange && Math.abs(a1.top - a2.top) <= yRange;
|
|
};
|
|
var getDeltas = function (coord1, coord2, xRange, yRange, scroll, origin) {
|
|
var a1 = asAbsolute(coord1, scroll, origin);
|
|
var a2 = asAbsolute(coord2, scroll, origin);
|
|
var left = Math.abs(a1.left - a2.left);
|
|
var top = Math.abs(a1.top - a2.top);
|
|
return SugarPosition(left, top);
|
|
};
|
|
var toStyles = function (coord, scroll, origin) {
|
|
var stylesOpt = coord.fold(function (x, y) {
|
|
return {
|
|
position: Optional.some('absolute'),
|
|
left: Optional.some(x + 'px'),
|
|
top: Optional.some(y + 'px')
|
|
};
|
|
}, function (x, y) {
|
|
return {
|
|
position: Optional.some('absolute'),
|
|
left: Optional.some(x - origin.left + 'px'),
|
|
top: Optional.some(y - origin.top + 'px')
|
|
};
|
|
}, function (x, y) {
|
|
return {
|
|
position: Optional.some('fixed'),
|
|
left: Optional.some(x + 'px'),
|
|
top: Optional.some(y + 'px')
|
|
};
|
|
});
|
|
return __assign({
|
|
right: Optional.none(),
|
|
bottom: Optional.none()
|
|
}, stylesOpt);
|
|
};
|
|
var translate = function (coord, deltaX, deltaY) {
|
|
return coord.fold(function (x, y) {
|
|
return offset(x + deltaX, y + deltaY);
|
|
}, function (x, y) {
|
|
return absolute(x + deltaX, y + deltaY);
|
|
}, function (x, y) {
|
|
return fixed(x + deltaX, y + deltaY);
|
|
});
|
|
};
|
|
var absorb = function (partialCoord, originalCoord, scroll, origin) {
|
|
var absorbOne = function (stencil, nu) {
|
|
return function (optX, optY) {
|
|
var original = stencil(originalCoord, scroll, origin);
|
|
return nu(optX.getOr(original.left), optY.getOr(original.top));
|
|
};
|
|
};
|
|
return partialCoord.fold(absorbOne(asOffset, offset), absorbOne(asAbsolute, absolute), absorbOne(asFixed, fixed));
|
|
};
|
|
var offset = adt.offset;
|
|
var absolute = adt.absolute;
|
|
var fixed = adt.fixed;
|
|
|
|
var parseAttrToInt = function (element, name) {
|
|
var value = get$d(element, name);
|
|
return isUndefined(value) ? NaN : parseInt(value, 10);
|
|
};
|
|
var get = function (component, snapsInfo) {
|
|
var element = component.element;
|
|
var x = parseAttrToInt(element, snapsInfo.leftAttr);
|
|
var y = parseAttrToInt(element, snapsInfo.topAttr);
|
|
return isNaN(x) || isNaN(y) ? Optional.none() : Optional.some(SugarPosition(x, y));
|
|
};
|
|
var set = function (component, snapsInfo, pt) {
|
|
var element = component.element;
|
|
set$8(element, snapsInfo.leftAttr, pt.left + 'px');
|
|
set$8(element, snapsInfo.topAttr, pt.top + 'px');
|
|
};
|
|
var clear = function (component, snapsInfo) {
|
|
var element = component.element;
|
|
remove$7(element, snapsInfo.leftAttr);
|
|
remove$7(element, snapsInfo.topAttr);
|
|
};
|
|
|
|
var getCoords = function (component, snapInfo, coord, delta) {
|
|
return get(component, snapInfo).fold(function () {
|
|
return coord;
|
|
}, function (fixed$1) {
|
|
return fixed(fixed$1.left + delta.left, fixed$1.top + delta.top);
|
|
});
|
|
};
|
|
var moveOrSnap = function (component, snapInfo, coord, delta, scroll, origin) {
|
|
var newCoord = getCoords(component, snapInfo, coord, delta);
|
|
var snap = snapInfo.mustSnap ? findClosestSnap(component, snapInfo, newCoord, scroll, origin) : findSnap(component, snapInfo, newCoord, scroll, origin);
|
|
var fixedCoord = asFixed(newCoord, scroll, origin);
|
|
set(component, snapInfo, fixedCoord);
|
|
return snap.fold(function () {
|
|
return {
|
|
coord: fixed(fixedCoord.left, fixedCoord.top),
|
|
extra: Optional.none()
|
|
};
|
|
}, function (spanned) {
|
|
return {
|
|
coord: spanned.output,
|
|
extra: spanned.extra
|
|
};
|
|
});
|
|
};
|
|
var stopDrag = function (component, snapInfo) {
|
|
clear(component, snapInfo);
|
|
};
|
|
var findMatchingSnap = function (snaps, newCoord, scroll, origin) {
|
|
return findMap(snaps, function (snap) {
|
|
var sensor = snap.sensor;
|
|
var inRange = withinRange(newCoord, sensor, snap.range.left, snap.range.top, scroll, origin);
|
|
return inRange ? Optional.some({
|
|
output: absorb(snap.output, newCoord, scroll, origin),
|
|
extra: snap.extra
|
|
}) : Optional.none();
|
|
});
|
|
};
|
|
var findClosestSnap = function (component, snapInfo, newCoord, scroll, origin) {
|
|
var snaps = snapInfo.getSnapPoints(component);
|
|
var matchSnap = findMatchingSnap(snaps, newCoord, scroll, origin);
|
|
return matchSnap.orThunk(function () {
|
|
var bestSnap = foldl(snaps, function (acc, snap) {
|
|
var sensor = snap.sensor;
|
|
var deltas = getDeltas(newCoord, sensor, snap.range.left, snap.range.top, scroll, origin);
|
|
return acc.deltas.fold(function () {
|
|
return {
|
|
deltas: Optional.some(deltas),
|
|
snap: Optional.some(snap)
|
|
};
|
|
}, function (bestDeltas) {
|
|
var currAvg = (deltas.left + deltas.top) / 2;
|
|
var bestAvg = (bestDeltas.left + bestDeltas.top) / 2;
|
|
if (currAvg <= bestAvg) {
|
|
return {
|
|
deltas: Optional.some(deltas),
|
|
snap: Optional.some(snap)
|
|
};
|
|
} else {
|
|
return acc;
|
|
}
|
|
});
|
|
}, {
|
|
deltas: Optional.none(),
|
|
snap: Optional.none()
|
|
});
|
|
return bestSnap.snap.map(function (snap) {
|
|
return {
|
|
output: absorb(snap.output, newCoord, scroll, origin),
|
|
extra: snap.extra
|
|
};
|
|
});
|
|
});
|
|
};
|
|
var findSnap = function (component, snapInfo, newCoord, scroll, origin) {
|
|
var snaps = snapInfo.getSnapPoints(component);
|
|
return findMatchingSnap(snaps, newCoord, scroll, origin);
|
|
};
|
|
var snapTo$1 = function (snap, scroll, origin) {
|
|
return {
|
|
coord: absorb(snap.output, snap.output, scroll, origin),
|
|
extra: snap.extra
|
|
};
|
|
};
|
|
|
|
var snapTo = function (component, dragConfig, _state, snap) {
|
|
var target = dragConfig.getTarget(component.element);
|
|
if (dragConfig.repositionTarget) {
|
|
var doc = owner$4(component.element);
|
|
var scroll_1 = get$9(doc);
|
|
var origin_1 = getOrigin(target);
|
|
var snapPin = snapTo$1(snap, scroll_1, origin_1);
|
|
var styles = toStyles(snapPin.coord, scroll_1, origin_1);
|
|
setOptions(target, styles);
|
|
}
|
|
};
|
|
|
|
var DraggingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
snapTo: snapTo
|
|
});
|
|
|
|
var initialAttribute = 'data-initial-z-index';
|
|
var resetZIndex = function (blocker) {
|
|
parent(blocker.element).filter(isElement$2).each(function (root) {
|
|
getOpt(root, initialAttribute).fold(function () {
|
|
return remove$6(root, 'z-index');
|
|
}, function (zIndex) {
|
|
return set$7(root, 'z-index', zIndex);
|
|
});
|
|
remove$7(root, initialAttribute);
|
|
});
|
|
};
|
|
var changeZIndex = function (blocker) {
|
|
parent(blocker.element).filter(isElement$2).each(function (root) {
|
|
getRaw(root, 'z-index').each(function (zindex) {
|
|
set$8(root, initialAttribute, zindex);
|
|
});
|
|
set$7(root, 'z-index', get$c(blocker.element, 'z-index'));
|
|
});
|
|
};
|
|
var instigate = function (anyComponent, blocker) {
|
|
anyComponent.getSystem().addToGui(blocker);
|
|
changeZIndex(blocker);
|
|
};
|
|
var discard = function (blocker) {
|
|
resetZIndex(blocker);
|
|
blocker.getSystem().removeFromGui(blocker);
|
|
};
|
|
var createComponent = function (component, blockerClass, blockerEvents) {
|
|
return component.getSystem().build(Container.sketch({
|
|
dom: {
|
|
styles: {
|
|
'left': '0px',
|
|
'top': '0px',
|
|
'width': '100%',
|
|
'height': '100%',
|
|
'position': 'fixed',
|
|
'z-index': '1000000000000000'
|
|
},
|
|
classes: [blockerClass]
|
|
},
|
|
events: blockerEvents
|
|
}));
|
|
};
|
|
|
|
var SnapSchema = optionObjOf('snaps', [
|
|
required$1('getSnapPoints'),
|
|
onHandler('onSensor'),
|
|
required$1('leftAttr'),
|
|
required$1('topAttr'),
|
|
defaulted('lazyViewport', win),
|
|
defaulted('mustSnap', false)
|
|
]);
|
|
|
|
var schema$6 = [
|
|
defaulted('useFixed', never),
|
|
required$1('blockerClass'),
|
|
defaulted('getTarget', identity$1),
|
|
defaulted('onDrag', noop),
|
|
defaulted('repositionTarget', true),
|
|
defaulted('onDrop', noop),
|
|
defaultedFunction('getBounds', win),
|
|
SnapSchema
|
|
];
|
|
|
|
var getCurrentCoord = function (target) {
|
|
return lift3(getRaw(target, 'left'), getRaw(target, 'top'), getRaw(target, 'position'), function (left, top, position) {
|
|
var nu = position === 'fixed' ? fixed : offset;
|
|
return nu(parseInt(left, 10), parseInt(top, 10));
|
|
}).getOrThunk(function () {
|
|
var location = absolute$3(target);
|
|
return absolute(location.left, location.top);
|
|
});
|
|
};
|
|
var clampCoords = function (component, coords, scroll, origin, startData) {
|
|
var bounds = startData.bounds;
|
|
var absoluteCoord = asAbsolute(coords, scroll, origin);
|
|
var newX = clamp$1(absoluteCoord.left, bounds.x, bounds.x + bounds.width - startData.width);
|
|
var newY = clamp$1(absoluteCoord.top, bounds.y, bounds.y + bounds.height - startData.height);
|
|
var newCoords = absolute(newX, newY);
|
|
return coords.fold(function () {
|
|
var offset$1 = asOffset(newCoords, scroll, origin);
|
|
return offset(offset$1.left, offset$1.top);
|
|
}, constant$1(newCoords), function () {
|
|
var fixed$1 = asFixed(newCoords, scroll, origin);
|
|
return fixed(fixed$1.left, fixed$1.top);
|
|
});
|
|
};
|
|
var calcNewCoord = function (component, optSnaps, currentCoord, scroll, origin, delta, startData) {
|
|
var newCoord = optSnaps.fold(function () {
|
|
var translated = translate(currentCoord, delta.left, delta.top);
|
|
var fixedCoord = asFixed(translated, scroll, origin);
|
|
return fixed(fixedCoord.left, fixedCoord.top);
|
|
}, function (snapInfo) {
|
|
var snapping = moveOrSnap(component, snapInfo, currentCoord, delta, scroll, origin);
|
|
snapping.extra.each(function (extra) {
|
|
snapInfo.onSensor(component, extra);
|
|
});
|
|
return snapping.coord;
|
|
});
|
|
return clampCoords(component, newCoord, scroll, origin, startData);
|
|
};
|
|
var dragBy = function (component, dragConfig, startData, delta) {
|
|
var target = dragConfig.getTarget(component.element);
|
|
if (dragConfig.repositionTarget) {
|
|
var doc = owner$4(component.element);
|
|
var scroll_1 = get$9(doc);
|
|
var origin_1 = getOrigin(target);
|
|
var currentCoord = getCurrentCoord(target);
|
|
var newCoord = calcNewCoord(component, dragConfig.snaps, currentCoord, scroll_1, origin_1, delta, startData);
|
|
var styles = toStyles(newCoord, scroll_1, origin_1);
|
|
setOptions(target, styles);
|
|
}
|
|
dragConfig.onDrag(component, target, delta);
|
|
};
|
|
|
|
var calcStartData = function (dragConfig, comp) {
|
|
return {
|
|
bounds: dragConfig.getBounds(),
|
|
height: getOuter$2(comp.element),
|
|
width: getOuter$1(comp.element)
|
|
};
|
|
};
|
|
var move = function (component, dragConfig, dragState, dragMode, event) {
|
|
var delta = dragState.update(dragMode, event);
|
|
var dragStartData = dragState.getStartData().getOrThunk(function () {
|
|
return calcStartData(dragConfig, component);
|
|
});
|
|
delta.each(function (dlt) {
|
|
dragBy(component, dragConfig, dragStartData, dlt);
|
|
});
|
|
};
|
|
var stop = function (component, blocker, dragConfig, dragState) {
|
|
blocker.each(discard);
|
|
dragConfig.snaps.each(function (snapInfo) {
|
|
stopDrag(component, snapInfo);
|
|
});
|
|
var target = dragConfig.getTarget(component.element);
|
|
dragState.reset();
|
|
dragConfig.onDrop(component, target);
|
|
};
|
|
var handlers = function (events) {
|
|
return function (dragConfig, dragState) {
|
|
var updateStartState = function (comp) {
|
|
dragState.setStartData(calcStartData(dragConfig, comp));
|
|
};
|
|
return derive$2(__spreadArray([run$1(windowScroll(), function (comp) {
|
|
dragState.getStartData().each(function () {
|
|
return updateStartState(comp);
|
|
});
|
|
})], events(dragConfig, dragState, updateStartState), true));
|
|
};
|
|
};
|
|
|
|
var init$2 = function (dragApi) {
|
|
return derive$2([
|
|
run$1(mousedown(), dragApi.forceDrop),
|
|
run$1(mouseup(), dragApi.drop),
|
|
run$1(mousemove(), function (comp, simulatedEvent) {
|
|
dragApi.move(simulatedEvent.event);
|
|
}),
|
|
run$1(mouseout(), dragApi.delayDrop)
|
|
]);
|
|
};
|
|
|
|
var getData$1 = function (event) {
|
|
return Optional.from(SugarPosition(event.x, event.y));
|
|
};
|
|
var getDelta$1 = function (old, nu) {
|
|
return SugarPosition(nu.left - old.left, nu.top - old.top);
|
|
};
|
|
|
|
var MouseData = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
getData: getData$1,
|
|
getDelta: getDelta$1
|
|
});
|
|
|
|
var events$2 = function (dragConfig, dragState, updateStartState) {
|
|
return [run$1(mousedown(), function (component, simulatedEvent) {
|
|
var raw = simulatedEvent.event.raw;
|
|
if (raw.button !== 0) {
|
|
return;
|
|
}
|
|
simulatedEvent.stop();
|
|
var stop$1 = function () {
|
|
return stop(component, Optional.some(blocker), dragConfig, dragState);
|
|
};
|
|
var delayDrop = DelayedFunction(stop$1, 200);
|
|
var dragApi = {
|
|
drop: stop$1,
|
|
delayDrop: delayDrop.schedule,
|
|
forceDrop: stop$1,
|
|
move: function (event) {
|
|
delayDrop.cancel();
|
|
move(component, dragConfig, dragState, MouseData, event);
|
|
}
|
|
};
|
|
var blocker = createComponent(component, dragConfig.blockerClass, init$2(dragApi));
|
|
var start = function () {
|
|
updateStartState(component);
|
|
instigate(component, blocker);
|
|
};
|
|
start();
|
|
})];
|
|
};
|
|
var schema$5 = __spreadArray(__spreadArray([], schema$6, true), [output$1('dragger', { handlers: handlers(events$2) })], false);
|
|
|
|
var init$1 = function (dragApi) {
|
|
return derive$2([
|
|
run$1(touchstart(), dragApi.forceDrop),
|
|
run$1(touchend(), dragApi.drop),
|
|
run$1(touchcancel(), dragApi.drop),
|
|
run$1(touchmove(), function (comp, simulatedEvent) {
|
|
dragApi.move(simulatedEvent.event);
|
|
})
|
|
]);
|
|
};
|
|
|
|
var getDataFrom = function (touches) {
|
|
var touch = touches[0];
|
|
return Optional.some(SugarPosition(touch.clientX, touch.clientY));
|
|
};
|
|
var getData = function (event) {
|
|
var raw = event.raw;
|
|
var touches = raw.touches;
|
|
return touches.length === 1 ? getDataFrom(touches) : Optional.none();
|
|
};
|
|
var getDelta = function (old, nu) {
|
|
return SugarPosition(nu.left - old.left, nu.top - old.top);
|
|
};
|
|
|
|
var TouchData = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
getData: getData,
|
|
getDelta: getDelta
|
|
});
|
|
|
|
var events$1 = function (dragConfig, dragState, updateStartState) {
|
|
var blockerSingleton = value$1();
|
|
var stopBlocking = function (component) {
|
|
stop(component, blockerSingleton.get(), dragConfig, dragState);
|
|
blockerSingleton.clear();
|
|
};
|
|
return [
|
|
run$1(touchstart(), function (component, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
var stop = function () {
|
|
return stopBlocking(component);
|
|
};
|
|
var dragApi = {
|
|
drop: stop,
|
|
delayDrop: noop,
|
|
forceDrop: stop,
|
|
move: function (event) {
|
|
move(component, dragConfig, dragState, TouchData, event);
|
|
}
|
|
};
|
|
var blocker = createComponent(component, dragConfig.blockerClass, init$1(dragApi));
|
|
blockerSingleton.set(blocker);
|
|
var start = function () {
|
|
updateStartState(component);
|
|
instigate(component, blocker);
|
|
};
|
|
start();
|
|
}),
|
|
run$1(touchmove(), function (component, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
move(component, dragConfig, dragState, TouchData, simulatedEvent.event);
|
|
}),
|
|
run$1(touchend(), function (component, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
stopBlocking(component);
|
|
}),
|
|
run$1(touchcancel(), stopBlocking)
|
|
];
|
|
};
|
|
var schema$4 = __spreadArray(__spreadArray([], schema$6, true), [output$1('dragger', { handlers: handlers(events$1) })], false);
|
|
|
|
var events = function (dragConfig, dragState, updateStartState) {
|
|
return __spreadArray(__spreadArray([], events$2(dragConfig, dragState, updateStartState), true), events$1(dragConfig, dragState, updateStartState), true);
|
|
};
|
|
var schema$3 = __spreadArray(__spreadArray([], schema$6, true), [output$1('dragger', { handlers: handlers(events) })], false);
|
|
|
|
var mouse = schema$5;
|
|
var touch = schema$4;
|
|
var mouseOrTouch = schema$3;
|
|
|
|
var DraggingBranches = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
mouse: mouse,
|
|
touch: touch,
|
|
mouseOrTouch: mouseOrTouch
|
|
});
|
|
|
|
var init = function () {
|
|
var previous = Optional.none();
|
|
var startData = Optional.none();
|
|
var reset = function () {
|
|
previous = Optional.none();
|
|
startData = Optional.none();
|
|
};
|
|
var calculateDelta = function (mode, nu) {
|
|
var result = previous.map(function (old) {
|
|
return mode.getDelta(old, nu);
|
|
});
|
|
previous = Optional.some(nu);
|
|
return result;
|
|
};
|
|
var update = function (mode, dragEvent) {
|
|
return mode.getData(dragEvent).bind(function (nuData) {
|
|
return calculateDelta(mode, nuData);
|
|
});
|
|
};
|
|
var setStartData = function (data) {
|
|
startData = Optional.some(data);
|
|
};
|
|
var getStartData = function () {
|
|
return startData;
|
|
};
|
|
var readState = constant$1({});
|
|
return nu$8({
|
|
readState: readState,
|
|
reset: reset,
|
|
update: update,
|
|
getStartData: getStartData,
|
|
setStartData: setStartData
|
|
});
|
|
};
|
|
|
|
var DragState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init
|
|
});
|
|
|
|
var Dragging = createModes({
|
|
branchKey: 'mode',
|
|
branches: DraggingBranches,
|
|
name: 'dragging',
|
|
active: {
|
|
events: function (dragConfig, dragState) {
|
|
var dragger = dragConfig.dragger;
|
|
return dragger.handlers(dragConfig, dragState);
|
|
}
|
|
},
|
|
extra: {
|
|
snap: function (sConfig) {
|
|
return {
|
|
sensor: sConfig.sensor,
|
|
range: sConfig.range,
|
|
output: sConfig.output,
|
|
extra: Optional.from(sConfig.extra)
|
|
};
|
|
}
|
|
},
|
|
state: DragState,
|
|
apis: DraggingApis
|
|
});
|
|
|
|
var snapWidth = 40;
|
|
var snapOffset = snapWidth / 2;
|
|
var calcSnap = function (selectorOpt, td, x, y, width, height) {
|
|
return selectorOpt.fold(function () {
|
|
return Dragging.snap({
|
|
sensor: absolute(x - snapOffset, y - snapOffset),
|
|
range: SugarPosition(width, height),
|
|
output: absolute(Optional.some(x), Optional.some(y)),
|
|
extra: { td: td }
|
|
});
|
|
}, function (selectorHandle) {
|
|
var sensorLeft = x - snapOffset;
|
|
var sensorTop = y - snapOffset;
|
|
var sensorWidth = snapWidth;
|
|
var sensorHeight = snapWidth;
|
|
var rect = selectorHandle.element.dom.getBoundingClientRect();
|
|
return Dragging.snap({
|
|
sensor: absolute(sensorLeft, sensorTop),
|
|
range: SugarPosition(sensorWidth, sensorHeight),
|
|
output: absolute(Optional.some(x - rect.width / 2), Optional.some(y - rect.height / 2)),
|
|
extra: { td: td }
|
|
});
|
|
});
|
|
};
|
|
var getSnapsConfig = function (getSnapPoints, cell, onChange) {
|
|
var isSameCell = function (cellOpt, td) {
|
|
return cellOpt.exists(function (currentTd) {
|
|
return eq(currentTd, td);
|
|
});
|
|
};
|
|
return {
|
|
getSnapPoints: getSnapPoints,
|
|
leftAttr: 'data-drag-left',
|
|
topAttr: 'data-drag-top',
|
|
onSensor: function (component, extra) {
|
|
var td = extra.td;
|
|
if (!isSameCell(cell.get(), td)) {
|
|
cell.set(td);
|
|
onChange(td);
|
|
}
|
|
},
|
|
mustSnap: true
|
|
};
|
|
};
|
|
var createSelector = function (snaps) {
|
|
return record(Button.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-selector']
|
|
},
|
|
buttonBehaviours: derive$1([
|
|
Dragging.config({
|
|
mode: 'mouseOrTouch',
|
|
blockerClass: 'blocker',
|
|
snaps: snaps
|
|
}),
|
|
Unselecting.config({})
|
|
]),
|
|
eventOrder: {
|
|
mousedown: [
|
|
'dragging',
|
|
'alloy.base.behaviour'
|
|
],
|
|
touchstart: [
|
|
'dragging',
|
|
'alloy.base.behaviour'
|
|
]
|
|
}
|
|
}));
|
|
};
|
|
var setup$4 = function (editor, sink) {
|
|
var tlTds = Cell([]);
|
|
var brTds = Cell([]);
|
|
var isVisible = Cell(false);
|
|
var startCell = value$1();
|
|
var finishCell = value$1();
|
|
var getTopLeftSnap = function (td) {
|
|
var box = absolute$2(td);
|
|
return calcSnap(memTopLeft.getOpt(sink), td, box.x, box.y, box.width, box.height);
|
|
};
|
|
var getTopLeftSnaps = function () {
|
|
return map$2(tlTds.get(), function (td) {
|
|
return getTopLeftSnap(td);
|
|
});
|
|
};
|
|
var getBottomRightSnap = function (td) {
|
|
var box = absolute$2(td);
|
|
return calcSnap(memBottomRight.getOpt(sink), td, box.right, box.bottom, box.width, box.height);
|
|
};
|
|
var getBottomRightSnaps = function () {
|
|
return map$2(brTds.get(), function (td) {
|
|
return getBottomRightSnap(td);
|
|
});
|
|
};
|
|
var topLeftSnaps = getSnapsConfig(getTopLeftSnaps, startCell, function (start) {
|
|
finishCell.get().each(function (finish) {
|
|
editor.fire('TableSelectorChange', {
|
|
start: start,
|
|
finish: finish
|
|
});
|
|
});
|
|
});
|
|
var bottomRightSnaps = getSnapsConfig(getBottomRightSnaps, finishCell, function (finish) {
|
|
startCell.get().each(function (start) {
|
|
editor.fire('TableSelectorChange', {
|
|
start: start,
|
|
finish: finish
|
|
});
|
|
});
|
|
});
|
|
var memTopLeft = createSelector(topLeftSnaps);
|
|
var memBottomRight = createSelector(bottomRightSnaps);
|
|
var topLeft = build$1(memTopLeft.asSpec());
|
|
var bottomRight = build$1(memBottomRight.asSpec());
|
|
var showOrHideHandle = function (selector, cell, isAbove, isBelow) {
|
|
var cellRect = cell.dom.getBoundingClientRect();
|
|
remove$6(selector.element, 'display');
|
|
var viewportHeight = defaultView(SugarElement.fromDom(editor.getBody())).dom.innerHeight;
|
|
var aboveViewport = isAbove(cellRect);
|
|
var belowViewport = isBelow(cellRect, viewportHeight);
|
|
if (aboveViewport || belowViewport) {
|
|
set$7(selector.element, 'display', 'none');
|
|
}
|
|
};
|
|
var snapTo = function (selector, cell, getSnapConfig, pos) {
|
|
var snap = getSnapConfig(cell);
|
|
Dragging.snapTo(selector, snap);
|
|
var isAbove = function (rect) {
|
|
return rect[pos] < 0;
|
|
};
|
|
var isBelow = function (rect, viewportHeight) {
|
|
return rect[pos] > viewportHeight;
|
|
};
|
|
showOrHideHandle(selector, cell, isAbove, isBelow);
|
|
};
|
|
var snapTopLeft = function (cell) {
|
|
return snapTo(topLeft, cell, getTopLeftSnap, 'top');
|
|
};
|
|
var snapLastTopLeft = function () {
|
|
return startCell.get().each(snapTopLeft);
|
|
};
|
|
var snapBottomRight = function (cell) {
|
|
return snapTo(bottomRight, cell, getBottomRightSnap, 'bottom');
|
|
};
|
|
var snapLastBottomRight = function () {
|
|
return finishCell.get().each(snapBottomRight);
|
|
};
|
|
if (detect$1().deviceType.isTouch()) {
|
|
editor.on('TableSelectionChange', function (e) {
|
|
if (!isVisible.get()) {
|
|
attach(sink, topLeft);
|
|
attach(sink, bottomRight);
|
|
isVisible.set(true);
|
|
}
|
|
startCell.set(e.start);
|
|
finishCell.set(e.finish);
|
|
e.otherCells.each(function (otherCells) {
|
|
tlTds.set(otherCells.upOrLeftCells);
|
|
brTds.set(otherCells.downOrRightCells);
|
|
snapTopLeft(e.start);
|
|
snapBottomRight(e.finish);
|
|
});
|
|
});
|
|
editor.on('ResizeEditor ResizeWindow ScrollContent', function () {
|
|
snapLastTopLeft();
|
|
snapLastBottomRight();
|
|
});
|
|
editor.on('TableSelectionClear', function () {
|
|
if (isVisible.get()) {
|
|
detach(topLeft);
|
|
detach(bottomRight);
|
|
isVisible.set(false);
|
|
}
|
|
startCell.clear();
|
|
finishCell.clear();
|
|
});
|
|
}
|
|
};
|
|
|
|
var isHidden = function (elm) {
|
|
if (elm.nodeType === 1) {
|
|
if (elm.nodeName === 'BR' || !!elm.getAttribute('data-mce-bogus')) {
|
|
return true;
|
|
}
|
|
if (elm.getAttribute('data-mce-type') === 'bookmark') {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var renderElementPath = function (editor, settings, providersBackstage) {
|
|
if (!settings.delimiter) {
|
|
settings.delimiter = '\xBB';
|
|
}
|
|
var getDataPath = function (data) {
|
|
var parts = data || [];
|
|
var newPathElements = map$2(parts, function (part, index) {
|
|
return Button.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-statusbar__path-item'],
|
|
attributes: {
|
|
'role': 'button',
|
|
'data-index': index,
|
|
'tab-index': -1,
|
|
'aria-level': index + 1
|
|
},
|
|
innerHtml: part.name
|
|
},
|
|
action: function (_btn) {
|
|
editor.focus();
|
|
editor.selection.select(part.element);
|
|
editor.nodeChanged();
|
|
},
|
|
buttonBehaviours: derive$1([
|
|
DisablingConfigs.button(providersBackstage.isDisabled),
|
|
receivingConfig()
|
|
])
|
|
});
|
|
});
|
|
var divider = {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-statusbar__path-divider'],
|
|
attributes: { 'aria-hidden': true },
|
|
innerHtml: ' ' + settings.delimiter + ' '
|
|
}
|
|
};
|
|
return foldl(newPathElements.slice(1), function (acc, element) {
|
|
var newAcc = acc;
|
|
newAcc.push(divider);
|
|
newAcc.push(element);
|
|
return newAcc;
|
|
}, [newPathElements[0]]);
|
|
};
|
|
var updatePath = function (parents) {
|
|
var newPath = [];
|
|
var i = parents.length;
|
|
while (i-- > 0) {
|
|
var parent_1 = parents[i];
|
|
if (parent_1.nodeType === 1 && !isHidden(parent_1)) {
|
|
var args = editor.fire('ResolveName', {
|
|
name: parent_1.nodeName.toLowerCase(),
|
|
target: parent_1
|
|
});
|
|
if (!args.isDefaultPrevented()) {
|
|
newPath.push({
|
|
name: args.name,
|
|
element: parent_1
|
|
});
|
|
}
|
|
if (args.isPropagationStopped()) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return newPath;
|
|
};
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-statusbar__path'],
|
|
attributes: { role: 'navigation' }
|
|
},
|
|
behaviours: derive$1([
|
|
Keying.config({
|
|
mode: 'flow',
|
|
selector: 'div[role=button]'
|
|
}),
|
|
Disabling.config({ disabled: providersBackstage.isDisabled }),
|
|
receivingConfig(),
|
|
Tabstopping.config({}),
|
|
Replacing.config({}),
|
|
config('elementPathEvents', [runOnAttached(function (comp, _e) {
|
|
editor.shortcuts.add('alt+F11', 'focus statusbar elementpath', function () {
|
|
return Keying.focusIn(comp);
|
|
});
|
|
editor.on('NodeChange', function (e) {
|
|
var newPath = updatePath(e.parents);
|
|
if (newPath.length > 0) {
|
|
Replacing.set(comp, getDataPath(newPath));
|
|
} else {
|
|
Replacing.set(comp, []);
|
|
}
|
|
});
|
|
})])
|
|
]),
|
|
components: []
|
|
};
|
|
};
|
|
|
|
var ResizeTypes;
|
|
(function (ResizeTypes) {
|
|
ResizeTypes[ResizeTypes['None'] = 0] = 'None';
|
|
ResizeTypes[ResizeTypes['Both'] = 1] = 'Both';
|
|
ResizeTypes[ResizeTypes['Vertical'] = 2] = 'Vertical';
|
|
}(ResizeTypes || (ResizeTypes = {})));
|
|
var getDimensions = function (editor, deltas, resizeType, originalHeight, originalWidth) {
|
|
var dimensions = {};
|
|
dimensions.height = calcCappedSize(originalHeight + deltas.top, getMinHeightSetting(editor), getMaxHeightSetting(editor));
|
|
if (resizeType === ResizeTypes.Both) {
|
|
dimensions.width = calcCappedSize(originalWidth + deltas.left, getMinWidthSetting(editor), getMaxWidthSetting(editor));
|
|
}
|
|
return dimensions;
|
|
};
|
|
var resize = function (editor, deltas, resizeType) {
|
|
var container = SugarElement.fromDom(editor.getContainer());
|
|
var dimensions = getDimensions(editor, deltas, resizeType, get$b(container), get$a(container));
|
|
each(dimensions, function (val, dim) {
|
|
return set$7(container, dim, numToPx(val));
|
|
});
|
|
fireResizeEditor(editor);
|
|
};
|
|
|
|
var getResizeType = function (editor) {
|
|
var fallback = !editor.hasPlugin('autoresize');
|
|
var resize = editor.getParam('resize', fallback);
|
|
if (resize === false) {
|
|
return ResizeTypes.None;
|
|
} else if (resize === 'both') {
|
|
return ResizeTypes.Both;
|
|
} else {
|
|
return ResizeTypes.Vertical;
|
|
}
|
|
};
|
|
var keyboardHandler = function (editor, resizeType, x, y) {
|
|
var scale = 20;
|
|
var delta = SugarPosition(x * scale, y * scale);
|
|
resize(editor, delta, resizeType);
|
|
return Optional.some(true);
|
|
};
|
|
var renderResizeHandler = function (editor, providersBackstage) {
|
|
var resizeType = getResizeType(editor);
|
|
if (resizeType === ResizeTypes.None) {
|
|
return Optional.none();
|
|
}
|
|
return Optional.some(render$3('resize-handle', {
|
|
tag: 'div',
|
|
classes: ['tox-statusbar__resize-handle'],
|
|
attributes: { title: providersBackstage.translate('Resize') },
|
|
behaviours: [
|
|
Dragging.config({
|
|
mode: 'mouse',
|
|
repositionTarget: false,
|
|
onDrag: function (_comp, _target, delta) {
|
|
return resize(editor, delta, resizeType);
|
|
},
|
|
blockerClass: 'tox-blocker'
|
|
}),
|
|
Keying.config({
|
|
mode: 'special',
|
|
onLeft: function () {
|
|
return keyboardHandler(editor, resizeType, -1, 0);
|
|
},
|
|
onRight: function () {
|
|
return keyboardHandler(editor, resizeType, 1, 0);
|
|
},
|
|
onUp: function () {
|
|
return keyboardHandler(editor, resizeType, 0, -1);
|
|
},
|
|
onDown: function () {
|
|
return keyboardHandler(editor, resizeType, 0, 1);
|
|
}
|
|
}),
|
|
Tabstopping.config({}),
|
|
Focusing.config({})
|
|
]
|
|
}, providersBackstage.icons));
|
|
};
|
|
|
|
var renderWordCount = function (editor, providersBackstage) {
|
|
var _a;
|
|
var replaceCountText = function (comp, count, mode) {
|
|
return Replacing.set(comp, [text(providersBackstage.translate([
|
|
'{0} ' + mode,
|
|
count[mode]
|
|
]))]);
|
|
};
|
|
return Button.sketch({
|
|
dom: {
|
|
tag: 'button',
|
|
classes: ['tox-statusbar__wordcount']
|
|
},
|
|
components: [],
|
|
buttonBehaviours: derive$1([
|
|
DisablingConfigs.button(providersBackstage.isDisabled),
|
|
receivingConfig(),
|
|
Tabstopping.config({}),
|
|
Replacing.config({}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: {
|
|
mode: 'words',
|
|
count: {
|
|
words: 0,
|
|
characters: 0
|
|
}
|
|
}
|
|
}
|
|
}),
|
|
config('wordcount-events', [
|
|
runOnExecute$1(function (comp) {
|
|
var currentVal = Representing.getValue(comp);
|
|
var newMode = currentVal.mode === 'words' ? 'characters' : 'words';
|
|
Representing.setValue(comp, {
|
|
mode: newMode,
|
|
count: currentVal.count
|
|
});
|
|
replaceCountText(comp, currentVal.count, newMode);
|
|
}),
|
|
runOnAttached(function (comp) {
|
|
editor.on('wordCountUpdate', function (e) {
|
|
var mode = Representing.getValue(comp).mode;
|
|
Representing.setValue(comp, {
|
|
mode: mode,
|
|
count: e.wordCount
|
|
});
|
|
replaceCountText(comp, e.wordCount, mode);
|
|
});
|
|
})
|
|
])
|
|
]),
|
|
eventOrder: (_a = {}, _a[execute$5()] = [
|
|
'disabling',
|
|
'alloy.base.behaviour',
|
|
'wordcount-events'
|
|
], _a)
|
|
});
|
|
};
|
|
|
|
var renderStatusbar = function (editor, providersBackstage) {
|
|
var renderBranding = function () {
|
|
var label = global$e.translate([
|
|
'Powered by {0}',
|
|
'Tiny'
|
|
]);
|
|
var linkHtml = '<a href="https://www.tiny.cloud/?utm_campaign=editor_referral&utm_medium=poweredby&utm_source=tinymce&utm_content=v5" rel="noopener" target="_blank" tabindex="-1" aria-label="' + label + '">' + label + '</a>';
|
|
return {
|
|
dom: {
|
|
tag: 'span',
|
|
classes: ['tox-statusbar__branding'],
|
|
innerHtml: linkHtml
|
|
}
|
|
};
|
|
};
|
|
var getTextComponents = function () {
|
|
var components = [];
|
|
if (editor.getParam('elementpath', true, 'boolean')) {
|
|
components.push(renderElementPath(editor, {}, providersBackstage));
|
|
}
|
|
if (editor.hasPlugin('wordcount')) {
|
|
components.push(renderWordCount(editor, providersBackstage));
|
|
}
|
|
if (editor.getParam('branding', true, 'boolean')) {
|
|
components.push(renderBranding());
|
|
}
|
|
if (components.length > 0) {
|
|
return [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-statusbar__text-container']
|
|
},
|
|
components: components
|
|
}];
|
|
}
|
|
return [];
|
|
};
|
|
var getComponents = function () {
|
|
var components = getTextComponents();
|
|
var resizeHandler = renderResizeHandler(editor, providersBackstage);
|
|
return components.concat(resizeHandler.toArray());
|
|
};
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-statusbar']
|
|
},
|
|
components: getComponents()
|
|
};
|
|
};
|
|
|
|
var setup$3 = function (editor) {
|
|
var _a;
|
|
var isInline = editor.inline;
|
|
var mode = isInline ? Inline : Iframe;
|
|
var header = isStickyToolbar(editor) ? StickyHeader : StaticHeader;
|
|
var lazyOuterContainer = Optional.none();
|
|
var platform = detect$1();
|
|
var isIE = platform.browser.isIE();
|
|
var platformClasses = isIE ? ['tox-platform-ie'] : [];
|
|
var isTouch = platform.deviceType.isTouch();
|
|
var touchPlatformClass = 'tox-platform-touch';
|
|
var deviceClasses = isTouch ? [touchPlatformClass] : [];
|
|
var isToolbarBottom = isToolbarLocationBottom(editor);
|
|
var uiContainer = getUiContainer(editor);
|
|
var dirAttributes = global$e.isRtl() ? { attributes: { dir: 'rtl' } } : {};
|
|
var verticalDirAttributes = { attributes: (_a = {}, _a[Attribute] = isToolbarBottom ? AttributeValue.BottomToTop : AttributeValue.TopToBottom, _a) };
|
|
var lazyHeader = function () {
|
|
return lazyOuterContainer.bind(OuterContainer.getHeader);
|
|
};
|
|
var isHeaderDocked = function () {
|
|
return header.isDocked(lazyHeader);
|
|
};
|
|
var resizeUiMothership = function () {
|
|
set$7(uiMothership.element, 'width', document.body.clientWidth + 'px');
|
|
};
|
|
var makeSinkDefinition = function () {
|
|
var isGridUiContainer = eq(body(), uiContainer) && get$c(uiContainer, 'display') === 'grid';
|
|
var sinkSpec = {
|
|
dom: __assign({
|
|
tag: 'div',
|
|
classes: [
|
|
'tox',
|
|
'tox-silver-sink',
|
|
'tox-tinymce-aux'
|
|
].concat(platformClasses).concat(deviceClasses)
|
|
}, dirAttributes),
|
|
behaviours: derive$1([Positioning.config({
|
|
useFixed: function () {
|
|
return isHeaderDocked();
|
|
}
|
|
})])
|
|
};
|
|
var reactiveWidthSpec = {
|
|
dom: { styles: { width: document.body.clientWidth + 'px' } },
|
|
events: derive$2([run$1(windowResize(), resizeUiMothership)])
|
|
};
|
|
return deepMerge(sinkSpec, isGridUiContainer ? reactiveWidthSpec : {});
|
|
};
|
|
var sink = build$1(makeSinkDefinition());
|
|
var lazySink = function () {
|
|
return Result.value(sink);
|
|
};
|
|
var memAnchorBar = record({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-anchorbar']
|
|
}
|
|
});
|
|
var lazyAnchorBar = function () {
|
|
return lazyOuterContainer.bind(function (container) {
|
|
return memAnchorBar.getOpt(container);
|
|
}).getOrDie('Could not find a anchor bar element');
|
|
};
|
|
var lazyToolbar = function () {
|
|
return lazyOuterContainer.bind(function (container) {
|
|
return OuterContainer.getToolbar(container);
|
|
}).getOrDie('Could not find more toolbar element');
|
|
};
|
|
var lazyThrobber = function () {
|
|
return lazyOuterContainer.bind(function (container) {
|
|
return OuterContainer.getThrobber(container);
|
|
}).getOrDie('Could not find throbber element');
|
|
};
|
|
var backstage = init$7(sink, editor, lazyAnchorBar);
|
|
var partMenubar = OuterContainer.parts.menubar({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-menubar']
|
|
},
|
|
backstage: backstage,
|
|
onEscape: function () {
|
|
editor.focus();
|
|
}
|
|
});
|
|
var toolbarMode = getToolbarMode(editor);
|
|
var partToolbar = OuterContainer.parts.toolbar(__assign({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar']
|
|
},
|
|
getSink: lazySink,
|
|
providers: backstage.shared.providers,
|
|
onEscape: function () {
|
|
editor.focus();
|
|
},
|
|
type: toolbarMode,
|
|
lazyToolbar: lazyToolbar,
|
|
lazyHeader: function () {
|
|
return lazyHeader().getOrDie('Could not find header element');
|
|
}
|
|
}, verticalDirAttributes));
|
|
var partMultipleToolbar = OuterContainer.parts['multiple-toolbar']({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-toolbar-overlord']
|
|
},
|
|
providers: backstage.shared.providers,
|
|
onEscape: function () {
|
|
editor.focus();
|
|
},
|
|
type: toolbarMode
|
|
});
|
|
var partSocket = OuterContainer.parts.socket({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-edit-area']
|
|
}
|
|
});
|
|
var partSidebar = OuterContainer.parts.sidebar({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-sidebar']
|
|
}
|
|
});
|
|
var partThrobber = OuterContainer.parts.throbber({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-throbber']
|
|
},
|
|
backstage: backstage
|
|
});
|
|
var sb = editor.getParam('statusbar', true, 'boolean');
|
|
var statusbar = sb && !isInline ? Optional.some(renderStatusbar(editor, backstage.shared.providers)) : Optional.none();
|
|
var socketSidebarContainer = {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-sidebar-wrap']
|
|
},
|
|
components: [
|
|
partSocket,
|
|
partSidebar
|
|
]
|
|
};
|
|
var hasMultipleToolbar = isMultipleToolbars(editor);
|
|
var hasToolbar = isToolbarEnabled(editor);
|
|
var hasMenubar = isMenubarEnabled(editor);
|
|
var getPartToolbar = function () {
|
|
if (hasMultipleToolbar) {
|
|
return [partMultipleToolbar];
|
|
} else if (hasToolbar) {
|
|
return [partToolbar];
|
|
} else {
|
|
return [];
|
|
}
|
|
};
|
|
var partHeader = OuterContainer.parts.header({
|
|
dom: __assign({
|
|
tag: 'div',
|
|
classes: ['tox-editor-header']
|
|
}, verticalDirAttributes),
|
|
components: flatten([
|
|
hasMenubar ? [partMenubar] : [],
|
|
getPartToolbar(),
|
|
useFixedContainer(editor) ? [] : [memAnchorBar.asSpec()]
|
|
]),
|
|
sticky: isStickyToolbar(editor),
|
|
editor: editor,
|
|
sharedBackstage: backstage.shared
|
|
});
|
|
var editorComponents = flatten([
|
|
isToolbarBottom ? [] : [partHeader],
|
|
isInline ? [] : [socketSidebarContainer],
|
|
isToolbarBottom ? [partHeader] : []
|
|
]);
|
|
var editorContainer = {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-editor-container']
|
|
},
|
|
components: editorComponents
|
|
};
|
|
var containerComponents = flatten([
|
|
[editorContainer],
|
|
isInline ? [] : statusbar.toArray(),
|
|
[partThrobber]
|
|
]);
|
|
var isHidden = isDistractionFree(editor);
|
|
var attributes = __assign(__assign({ role: 'application' }, global$e.isRtl() ? { dir: 'rtl' } : {}), isHidden ? { 'aria-hidden': 'true' } : {});
|
|
var outerContainer = build$1(OuterContainer.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox',
|
|
'tox-tinymce'
|
|
].concat(isInline ? ['tox-tinymce-inline'] : []).concat(isToolbarBottom ? ['tox-tinymce--toolbar-bottom'] : []).concat(deviceClasses).concat(platformClasses),
|
|
styles: __assign({ visibility: 'hidden' }, isHidden ? {
|
|
opacity: '0',
|
|
border: '0'
|
|
} : {}),
|
|
attributes: attributes
|
|
},
|
|
components: containerComponents,
|
|
behaviours: derive$1([
|
|
receivingConfig(),
|
|
Disabling.config({ disableClass: 'tox-tinymce--disabled' }),
|
|
Keying.config({
|
|
mode: 'cyclic',
|
|
selector: '.tox-menubar, .tox-toolbar, .tox-toolbar__primary, .tox-toolbar__overflow--open, .tox-sidebar__overflow--open, .tox-statusbar__path, .tox-statusbar__wordcount, .tox-statusbar__branding a, .tox-statusbar__resize-handle'
|
|
})
|
|
])
|
|
}));
|
|
lazyOuterContainer = Optional.some(outerContainer);
|
|
editor.shortcuts.add('alt+F9', 'focus menubar', function () {
|
|
OuterContainer.focusMenubar(outerContainer);
|
|
});
|
|
editor.shortcuts.add('alt+F10', 'focus toolbar', function () {
|
|
OuterContainer.focusToolbar(outerContainer);
|
|
});
|
|
editor.addCommand('ToggleToolbarDrawer', function () {
|
|
OuterContainer.toggleToolbarDrawer(outerContainer);
|
|
});
|
|
editor.addQueryStateHandler('ToggleToolbarDrawer', function () {
|
|
return OuterContainer.isToolbarDrawerToggled(outerContainer);
|
|
});
|
|
var mothership = takeover(outerContainer);
|
|
var uiMothership = takeover(sink);
|
|
setup$b(editor, mothership, uiMothership);
|
|
var getUi = function () {
|
|
var channels = {
|
|
broadcastAll: uiMothership.broadcast,
|
|
broadcastOn: uiMothership.broadcastOn,
|
|
register: noop
|
|
};
|
|
return { channels: channels };
|
|
};
|
|
var setEditorSize = function () {
|
|
var parsedHeight = numToPx(getHeightWithFallback(editor));
|
|
var parsedWidth = numToPx(getWidthWithFallback(editor));
|
|
if (!editor.inline) {
|
|
if (isValidValue('div', 'width', parsedWidth)) {
|
|
set$7(outerContainer.element, 'width', parsedWidth);
|
|
}
|
|
if (isValidValue('div', 'height', parsedHeight)) {
|
|
set$7(outerContainer.element, 'height', parsedHeight);
|
|
} else {
|
|
set$7(outerContainer.element, 'height', '200px');
|
|
}
|
|
}
|
|
return parsedHeight;
|
|
};
|
|
var renderUI = function () {
|
|
header.setup(editor, backstage.shared, lazyHeader);
|
|
setup$6(editor, backstage);
|
|
setup$5(editor, lazySink, backstage);
|
|
setup$8(editor);
|
|
setup$7(editor, lazyThrobber, backstage.shared);
|
|
map$1(getToolbarGroups(editor), function (toolbarGroupButtonConfig, name) {
|
|
editor.ui.registry.addGroupToolbarButton(name, toolbarGroupButtonConfig);
|
|
});
|
|
var _a = editor.ui.registry.getAll(), buttons = _a.buttons, menuItems = _a.menuItems, contextToolbars = _a.contextToolbars, sidebars = _a.sidebars;
|
|
var toolbarOpt = getMultipleToolbarsSetting(editor);
|
|
var rawUiConfig = {
|
|
menuItems: menuItems,
|
|
menus: getMenus(editor),
|
|
menubar: getMenubar(editor),
|
|
toolbar: toolbarOpt.getOrThunk(function () {
|
|
return getToolbar(editor);
|
|
}),
|
|
allowToolbarGroups: toolbarMode === ToolbarMode.floating,
|
|
buttons: buttons,
|
|
sidebar: sidebars
|
|
};
|
|
register$7(editor, contextToolbars, sink, { backstage: backstage });
|
|
setup$4(editor, sink);
|
|
var elm = editor.getElement();
|
|
var height = setEditorSize();
|
|
var uiComponents = {
|
|
mothership: mothership,
|
|
uiMothership: uiMothership,
|
|
outerContainer: outerContainer
|
|
};
|
|
var args = {
|
|
targetNode: elm,
|
|
height: height
|
|
};
|
|
return mode.render(editor, uiComponents, rawUiConfig, backstage, args);
|
|
};
|
|
return {
|
|
mothership: mothership,
|
|
uiMothership: uiMothership,
|
|
backstage: backstage,
|
|
renderUI: renderUI,
|
|
getUi: getUi
|
|
};
|
|
};
|
|
|
|
var describedBy = function (describedElement, describeElement) {
|
|
var describeId = Optional.from(get$d(describedElement, 'id')).fold(function () {
|
|
var id = generate$6('dialog-describe');
|
|
set$8(describeElement, 'id', id);
|
|
return id;
|
|
}, identity$1);
|
|
set$8(describedElement, 'aria-describedby', describeId);
|
|
};
|
|
|
|
var labelledBy = function (labelledElement, labelElement) {
|
|
var labelId = getOpt(labelledElement, 'id').fold(function () {
|
|
var id = generate$6('dialog-label');
|
|
set$8(labelElement, 'id', id);
|
|
return id;
|
|
}, identity$1);
|
|
set$8(labelledElement, 'aria-labelledby', labelId);
|
|
};
|
|
|
|
var schema$2 = constant$1([
|
|
required$1('lazySink'),
|
|
option('dragBlockClass'),
|
|
defaultedFunction('getBounds', win),
|
|
defaulted('useTabstopAt', always),
|
|
defaulted('eventOrder', {}),
|
|
field('modalBehaviours', [Keying]),
|
|
onKeyboardHandler('onExecute'),
|
|
onStrictKeyboardHandler('onEscape')
|
|
]);
|
|
var basic = { sketch: identity$1 };
|
|
var parts$2 = constant$1([
|
|
optional({
|
|
name: 'draghandle',
|
|
overrides: function (detail, spec) {
|
|
return {
|
|
behaviours: derive$1([Dragging.config({
|
|
mode: 'mouse',
|
|
getTarget: function (handle) {
|
|
return ancestor(handle, '[role="dialog"]').getOr(handle);
|
|
},
|
|
blockerClass: detail.dragBlockClass.getOrDie(new Error('The drag blocker class was not specified for a dialog with a drag handle: \n' + JSON.stringify(spec, null, 2)).message),
|
|
getBounds: detail.getDragBounds
|
|
})])
|
|
};
|
|
}
|
|
}),
|
|
required({
|
|
schema: [required$1('dom')],
|
|
name: 'title'
|
|
}),
|
|
required({
|
|
factory: basic,
|
|
schema: [required$1('dom')],
|
|
name: 'close'
|
|
}),
|
|
required({
|
|
factory: basic,
|
|
schema: [required$1('dom')],
|
|
name: 'body'
|
|
}),
|
|
optional({
|
|
factory: basic,
|
|
schema: [required$1('dom')],
|
|
name: 'footer'
|
|
}),
|
|
external$1({
|
|
factory: {
|
|
sketch: function (spec, detail) {
|
|
return __assign(__assign({}, spec), {
|
|
dom: detail.dom,
|
|
components: detail.components
|
|
});
|
|
}
|
|
},
|
|
schema: [
|
|
defaulted('dom', {
|
|
tag: 'div',
|
|
styles: {
|
|
position: 'fixed',
|
|
left: '0px',
|
|
top: '0px',
|
|
right: '0px',
|
|
bottom: '0px'
|
|
}
|
|
}),
|
|
defaulted('components', [])
|
|
],
|
|
name: 'blocker'
|
|
})
|
|
]);
|
|
|
|
var factory$4 = function (detail, components, spec, externals) {
|
|
var _a;
|
|
var dialogComp = value$1();
|
|
var showDialog = function (dialog) {
|
|
dialogComp.set(dialog);
|
|
var sink = detail.lazySink(dialog).getOrDie();
|
|
var externalBlocker = externals.blocker();
|
|
var blocker = sink.getSystem().build(__assign(__assign({}, externalBlocker), {
|
|
components: externalBlocker.components.concat([premade(dialog)]),
|
|
behaviours: derive$1([
|
|
Focusing.config({}),
|
|
config('dialog-blocker-events', [runOnSource(focusin(), function () {
|
|
Keying.focusIn(dialog);
|
|
})])
|
|
])
|
|
}));
|
|
attach(sink, blocker);
|
|
Keying.focusIn(dialog);
|
|
};
|
|
var hideDialog = function (dialog) {
|
|
dialogComp.clear();
|
|
parent(dialog.element).each(function (blockerDom) {
|
|
dialog.getSystem().getByDom(blockerDom).each(function (blocker) {
|
|
detach(blocker);
|
|
});
|
|
});
|
|
};
|
|
var getDialogBody = function (dialog) {
|
|
return getPartOrDie(dialog, detail, 'body');
|
|
};
|
|
var getDialogFooter = function (dialog) {
|
|
return getPartOrDie(dialog, detail, 'footer');
|
|
};
|
|
var setBusy = function (dialog, getBusySpec) {
|
|
Blocking.block(dialog, getBusySpec);
|
|
};
|
|
var setIdle = function (dialog) {
|
|
Blocking.unblock(dialog);
|
|
};
|
|
var modalEventsId = generate$6('modal-events');
|
|
var eventOrder = __assign(__assign({}, detail.eventOrder), (_a = {}, _a[attachedToDom()] = [modalEventsId].concat(detail.eventOrder['alloy.system.attached'] || []), _a));
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
apis: {
|
|
show: showDialog,
|
|
hide: hideDialog,
|
|
getBody: getDialogBody,
|
|
getFooter: getDialogFooter,
|
|
setIdle: setIdle,
|
|
setBusy: setBusy
|
|
},
|
|
eventOrder: eventOrder,
|
|
domModification: {
|
|
attributes: {
|
|
'role': 'dialog',
|
|
'aria-modal': 'true'
|
|
}
|
|
},
|
|
behaviours: augment(detail.modalBehaviours, [
|
|
Replacing.config({}),
|
|
Keying.config({
|
|
mode: 'cyclic',
|
|
onEnter: detail.onExecute,
|
|
onEscape: detail.onEscape,
|
|
useTabstopAt: detail.useTabstopAt
|
|
}),
|
|
Blocking.config({ getRoot: dialogComp.get }),
|
|
config(modalEventsId, [runOnAttached(function (c) {
|
|
labelledBy(c.element, getPartOrDie(c, detail, 'title').element);
|
|
describedBy(c.element, getPartOrDie(c, detail, 'body').element);
|
|
})])
|
|
])
|
|
};
|
|
};
|
|
var ModalDialog = composite({
|
|
name: 'ModalDialog',
|
|
configFields: schema$2(),
|
|
partFields: parts$2(),
|
|
factory: factory$4,
|
|
apis: {
|
|
show: function (apis, dialog) {
|
|
apis.show(dialog);
|
|
},
|
|
hide: function (apis, dialog) {
|
|
apis.hide(dialog);
|
|
},
|
|
getBody: function (apis, dialog) {
|
|
return apis.getBody(dialog);
|
|
},
|
|
getFooter: function (apis, dialog) {
|
|
return apis.getFooter(dialog);
|
|
},
|
|
setBusy: function (apis, dialog, getBusySpec) {
|
|
apis.setBusy(dialog, getBusySpec);
|
|
},
|
|
setIdle: function (apis, dialog) {
|
|
apis.setIdle(dialog);
|
|
}
|
|
}
|
|
});
|
|
|
|
var dialogToggleMenuItemSchema = objOf([
|
|
requiredString('type'),
|
|
requiredString('name')
|
|
].concat(commonMenuItemFields));
|
|
var dialogToggleMenuItemDataProcessor = boolean;
|
|
|
|
var baseFooterButtonFields = [
|
|
field$1('name', 'name', defaultedThunk(function () {
|
|
return generate$6('button-name');
|
|
}), string),
|
|
optionString('icon'),
|
|
defaultedStringEnum('align', 'end', [
|
|
'start',
|
|
'end'
|
|
]),
|
|
defaultedBoolean('primary', false),
|
|
defaultedBoolean('disabled', false)
|
|
];
|
|
var dialogFooterButtonFields = __spreadArray(__spreadArray([], baseFooterButtonFields, true), [requiredString('text')], false);
|
|
var normalFooterButtonFields = __spreadArray([requiredStringEnum('type', [
|
|
'submit',
|
|
'cancel',
|
|
'custom'
|
|
])], dialogFooterButtonFields, true);
|
|
var menuFooterButtonFields = __spreadArray([
|
|
requiredStringEnum('type', ['menu']),
|
|
optionString('text'),
|
|
optionString('tooltip'),
|
|
optionString('icon'),
|
|
requiredArrayOf('items', dialogToggleMenuItemSchema)
|
|
], baseFooterButtonFields, true);
|
|
var dialogFooterButtonSchema = choose$1('type', {
|
|
submit: normalFooterButtonFields,
|
|
cancel: normalFooterButtonFields,
|
|
custom: normalFooterButtonFields,
|
|
menu: menuFooterButtonFields
|
|
});
|
|
|
|
var alertBannerFields = [
|
|
requiredString('type'),
|
|
requiredString('text'),
|
|
requiredStringEnum('level', [
|
|
'info',
|
|
'warn',
|
|
'error',
|
|
'success'
|
|
]),
|
|
requiredString('icon'),
|
|
defaulted('url', '')
|
|
];
|
|
var alertBannerSchema = objOf(alertBannerFields);
|
|
|
|
var createBarFields = function (itemsField) {
|
|
return [
|
|
requiredString('type'),
|
|
itemsField
|
|
];
|
|
};
|
|
|
|
var buttonFields = [
|
|
requiredString('type'),
|
|
requiredString('text'),
|
|
defaultedBoolean('disabled', false),
|
|
defaultedBoolean('primary', false),
|
|
field$1('name', 'name', defaultedThunk(function () {
|
|
return generate$6('button-name');
|
|
}), string),
|
|
optionString('icon'),
|
|
defaultedBoolean('borderless', false)
|
|
];
|
|
var buttonSchema = objOf(buttonFields);
|
|
|
|
var checkboxFields = [
|
|
requiredString('type'),
|
|
requiredString('name'),
|
|
requiredString('label'),
|
|
defaultedBoolean('disabled', false)
|
|
];
|
|
var checkboxSchema = objOf(checkboxFields);
|
|
var checkboxDataProcessor = boolean;
|
|
|
|
var formComponentFields = [
|
|
requiredString('type'),
|
|
requiredString('name')
|
|
];
|
|
var formComponentWithLabelFields = formComponentFields.concat([optionString('label')]);
|
|
|
|
var collectionFields = formComponentWithLabelFields.concat([defaulted('columns', 'auto')]);
|
|
var collectionSchema = objOf(collectionFields);
|
|
var collectionDataProcessor = arrOfObj([
|
|
requiredString('value'),
|
|
requiredString('text'),
|
|
requiredString('icon')
|
|
]);
|
|
|
|
var colorInputFields = formComponentWithLabelFields;
|
|
var colorInputSchema = objOf(colorInputFields);
|
|
var colorInputDataProcessor = string;
|
|
|
|
var colorPickerFields = formComponentWithLabelFields;
|
|
var colorPickerSchema = objOf(colorPickerFields);
|
|
var colorPickerDataProcessor = string;
|
|
|
|
var customEditorFields = formComponentFields.concat([
|
|
defaultedString('tag', 'textarea'),
|
|
requiredString('scriptId'),
|
|
requiredString('scriptUrl'),
|
|
defaultedPostMsg('settings', undefined)
|
|
]);
|
|
var customEditorFieldsOld = formComponentFields.concat([
|
|
defaultedString('tag', 'textarea'),
|
|
requiredFunction('init')
|
|
]);
|
|
var customEditorSchema = valueOf(function (v) {
|
|
return asRaw('customeditor.old', objOfOnly(customEditorFieldsOld), v).orThunk(function () {
|
|
return asRaw('customeditor.new', objOfOnly(customEditorFields), v);
|
|
});
|
|
});
|
|
var customEditorDataProcessor = string;
|
|
|
|
var dropZoneFields = formComponentWithLabelFields;
|
|
var dropZoneSchema = objOf(dropZoneFields);
|
|
var dropZoneDataProcessor = arrOfVal();
|
|
|
|
var createGridFields = function (itemsField) {
|
|
return [
|
|
requiredString('type'),
|
|
requiredNumber('columns'),
|
|
itemsField
|
|
];
|
|
};
|
|
|
|
var htmlPanelFields = [
|
|
requiredString('type'),
|
|
requiredString('html'),
|
|
defaultedStringEnum('presets', 'presentation', [
|
|
'presentation',
|
|
'document'
|
|
])
|
|
];
|
|
var htmlPanelSchema = objOf(htmlPanelFields);
|
|
|
|
var iframeFields = formComponentWithLabelFields.concat([defaultedBoolean('sandboxed', true)]);
|
|
var iframeSchema = objOf(iframeFields);
|
|
var iframeDataProcessor = string;
|
|
|
|
var imageToolsFields = formComponentWithLabelFields.concat([requiredOf('currentState', objOf([
|
|
required$1('blob'),
|
|
requiredString('url')
|
|
]))]);
|
|
var imageToolsSchema = objOf(imageToolsFields);
|
|
|
|
var inputFields = formComponentWithLabelFields.concat([
|
|
optionString('inputMode'),
|
|
optionString('placeholder'),
|
|
defaultedBoolean('maximized', false),
|
|
defaultedBoolean('disabled', false)
|
|
]);
|
|
var inputSchema = objOf(inputFields);
|
|
var inputDataProcessor = string;
|
|
|
|
var createLabelFields = function (itemsField) {
|
|
return [
|
|
requiredString('type'),
|
|
requiredString('label'),
|
|
itemsField
|
|
];
|
|
};
|
|
|
|
var listBoxSingleItemFields = [
|
|
requiredString('text'),
|
|
requiredString('value')
|
|
];
|
|
var listBoxNestedItemFields = [
|
|
requiredString('text'),
|
|
requiredArrayOf('items', thunkOf('items', function () {
|
|
return listBoxItemSchema;
|
|
}))
|
|
];
|
|
var listBoxItemSchema = oneOf([
|
|
objOf(listBoxSingleItemFields),
|
|
objOf(listBoxNestedItemFields)
|
|
]);
|
|
var listBoxFields = formComponentWithLabelFields.concat([
|
|
requiredArrayOf('items', listBoxItemSchema),
|
|
defaultedBoolean('disabled', false)
|
|
]);
|
|
var listBoxSchema = objOf(listBoxFields);
|
|
var listBoxDataProcessor = string;
|
|
|
|
var selectBoxFields = formComponentWithLabelFields.concat([
|
|
requiredArrayOfObj('items', [
|
|
requiredString('text'),
|
|
requiredString('value')
|
|
]),
|
|
defaultedNumber('size', 1),
|
|
defaultedBoolean('disabled', false)
|
|
]);
|
|
var selectBoxSchema = objOf(selectBoxFields);
|
|
var selectBoxDataProcessor = string;
|
|
|
|
var sizeInputFields = formComponentWithLabelFields.concat([
|
|
defaultedBoolean('constrain', true),
|
|
defaultedBoolean('disabled', false)
|
|
]);
|
|
var sizeInputSchema = objOf(sizeInputFields);
|
|
var sizeInputDataProcessor = objOf([
|
|
requiredString('width'),
|
|
requiredString('height')
|
|
]);
|
|
|
|
var tableFields = [
|
|
requiredString('type'),
|
|
requiredArrayOf('header', string),
|
|
requiredArrayOf('cells', arrOf(string))
|
|
];
|
|
var tableSchema = objOf(tableFields);
|
|
|
|
var textAreaFields = formComponentWithLabelFields.concat([
|
|
optionString('placeholder'),
|
|
defaultedBoolean('maximized', false),
|
|
defaultedBoolean('disabled', false)
|
|
]);
|
|
var textAreaSchema = objOf(textAreaFields);
|
|
var textAreaDataProcessor = string;
|
|
|
|
var urlInputFields = formComponentWithLabelFields.concat([
|
|
defaultedStringEnum('filetype', 'file', [
|
|
'image',
|
|
'media',
|
|
'file'
|
|
]),
|
|
defaulted('disabled', false)
|
|
]);
|
|
var urlInputSchema = objOf(urlInputFields);
|
|
var urlInputDataProcessor = objOf([
|
|
requiredString('value'),
|
|
defaulted('meta', {})
|
|
]);
|
|
|
|
var createItemsField = function (name) {
|
|
return field$1('items', 'items', required$2(), arrOf(valueOf(function (v) {
|
|
return asRaw('Checking item of ' + name, itemSchema, v).fold(function (sErr) {
|
|
return Result.error(formatError(sErr));
|
|
}, function (passValue) {
|
|
return Result.value(passValue);
|
|
});
|
|
})));
|
|
};
|
|
var itemSchema = valueThunk(function () {
|
|
return choose$2('type', {
|
|
alertbanner: alertBannerSchema,
|
|
bar: objOf(createBarFields(createItemsField('bar'))),
|
|
button: buttonSchema,
|
|
checkbox: checkboxSchema,
|
|
colorinput: colorInputSchema,
|
|
colorpicker: colorPickerSchema,
|
|
dropzone: dropZoneSchema,
|
|
grid: objOf(createGridFields(createItemsField('grid'))),
|
|
iframe: iframeSchema,
|
|
input: inputSchema,
|
|
listbox: listBoxSchema,
|
|
selectbox: selectBoxSchema,
|
|
sizeinput: sizeInputSchema,
|
|
textarea: textAreaSchema,
|
|
urlinput: urlInputSchema,
|
|
customeditor: customEditorSchema,
|
|
htmlpanel: htmlPanelSchema,
|
|
imagetools: imageToolsSchema,
|
|
collection: collectionSchema,
|
|
label: objOf(createLabelFields(createItemsField('label'))),
|
|
table: tableSchema,
|
|
panel: panelSchema
|
|
});
|
|
});
|
|
var panelFields = [
|
|
requiredString('type'),
|
|
defaulted('classes', []),
|
|
requiredArrayOf('items', itemSchema)
|
|
];
|
|
var panelSchema = objOf(panelFields);
|
|
|
|
var tabFields = [
|
|
field$1('name', 'name', defaultedThunk(function () {
|
|
return generate$6('tab-name');
|
|
}), string),
|
|
requiredString('title'),
|
|
requiredArrayOf('items', itemSchema)
|
|
];
|
|
var tabPanelFields = [
|
|
requiredString('type'),
|
|
requiredArrayOfObj('tabs', tabFields)
|
|
];
|
|
var tabPanelSchema = objOf(tabPanelFields);
|
|
|
|
var dialogButtonFields = dialogFooterButtonFields;
|
|
var dialogButtonSchema = dialogFooterButtonSchema;
|
|
var dialogSchema = objOf([
|
|
requiredString('title'),
|
|
requiredOf('body', choose$2('type', {
|
|
panel: panelSchema,
|
|
tabpanel: tabPanelSchema
|
|
})),
|
|
defaultedString('size', 'normal'),
|
|
requiredArrayOf('buttons', dialogButtonSchema),
|
|
defaulted('initialData', {}),
|
|
defaultedFunction('onAction', noop),
|
|
defaultedFunction('onChange', noop),
|
|
defaultedFunction('onSubmit', noop),
|
|
defaultedFunction('onClose', noop),
|
|
defaultedFunction('onCancel', noop),
|
|
defaulted('onTabChange', noop)
|
|
]);
|
|
var createDialog = function (spec) {
|
|
return asRaw('dialog', dialogSchema, spec);
|
|
};
|
|
|
|
var urlDialogButtonSchema = objOf(__spreadArray([requiredStringEnum('type', [
|
|
'cancel',
|
|
'custom'
|
|
])], dialogButtonFields, true));
|
|
var urlDialogSchema = objOf([
|
|
requiredString('title'),
|
|
requiredString('url'),
|
|
optionNumber('height'),
|
|
optionNumber('width'),
|
|
optionArrayOf('buttons', urlDialogButtonSchema),
|
|
defaultedFunction('onAction', noop),
|
|
defaultedFunction('onCancel', noop),
|
|
defaultedFunction('onClose', noop),
|
|
defaultedFunction('onMessage', noop)
|
|
]);
|
|
var createUrlDialog = function (spec) {
|
|
return asRaw('dialog', urlDialogSchema, spec);
|
|
};
|
|
|
|
var getAllObjects = function (obj) {
|
|
if (isObject(obj)) {
|
|
return [obj].concat(bind$3(values(obj), getAllObjects));
|
|
} else if (isArray(obj)) {
|
|
return bind$3(obj, getAllObjects);
|
|
} else {
|
|
return [];
|
|
}
|
|
};
|
|
|
|
var isNamedItem = function (obj) {
|
|
return isString(obj.type) && isString(obj.name);
|
|
};
|
|
var dataProcessors = {
|
|
checkbox: checkboxDataProcessor,
|
|
colorinput: colorInputDataProcessor,
|
|
colorpicker: colorPickerDataProcessor,
|
|
dropzone: dropZoneDataProcessor,
|
|
input: inputDataProcessor,
|
|
iframe: iframeDataProcessor,
|
|
sizeinput: sizeInputDataProcessor,
|
|
selectbox: selectBoxDataProcessor,
|
|
listbox: listBoxDataProcessor,
|
|
size: sizeInputDataProcessor,
|
|
textarea: textAreaDataProcessor,
|
|
urlinput: urlInputDataProcessor,
|
|
customeditor: customEditorDataProcessor,
|
|
collection: collectionDataProcessor,
|
|
togglemenuitem: dialogToggleMenuItemDataProcessor
|
|
};
|
|
var getDataProcessor = function (item) {
|
|
return Optional.from(dataProcessors[item.type]);
|
|
};
|
|
var getNamedItems = function (structure) {
|
|
return filter$2(getAllObjects(structure), isNamedItem);
|
|
};
|
|
|
|
var createDataValidator = function (structure) {
|
|
var namedItems = getNamedItems(structure);
|
|
var fields = bind$3(namedItems, function (item) {
|
|
return getDataProcessor(item).fold(function () {
|
|
return [];
|
|
}, function (schema) {
|
|
return [requiredOf(item.name, schema)];
|
|
});
|
|
});
|
|
return objOf(fields);
|
|
};
|
|
|
|
var extract = function (structure) {
|
|
var internalDialog = getOrDie(createDialog(structure));
|
|
var dataValidator = createDataValidator(structure);
|
|
var initialData = structure.initialData;
|
|
return {
|
|
internalDialog: internalDialog,
|
|
dataValidator: dataValidator,
|
|
initialData: initialData
|
|
};
|
|
};
|
|
var DialogManager = {
|
|
open: function (factory, structure) {
|
|
var extraction = extract(structure);
|
|
return factory(extraction.internalDialog, extraction.initialData, extraction.dataValidator);
|
|
},
|
|
openUrl: function (factory, structure) {
|
|
var internalDialog = getOrDie(createUrlDialog(structure));
|
|
return factory(internalDialog);
|
|
},
|
|
redial: function (structure) {
|
|
return extract(structure);
|
|
}
|
|
};
|
|
|
|
var toValidValues = function (values) {
|
|
var errors = [];
|
|
var result = {};
|
|
each(values, function (value, name) {
|
|
value.fold(function () {
|
|
errors.push(name);
|
|
}, function (v) {
|
|
result[name] = v;
|
|
});
|
|
});
|
|
return errors.length > 0 ? Result.error(errors) : Result.value(result);
|
|
};
|
|
|
|
var renderBodyPanel = function (spec, backstage) {
|
|
var memForm = record(Form.sketch(function (parts) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form'].concat(spec.classes)
|
|
},
|
|
components: map$2(spec.items, function (item) {
|
|
return interpretInForm(parts, item, backstage);
|
|
})
|
|
};
|
|
}));
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body']
|
|
},
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body-content']
|
|
},
|
|
components: [memForm.asSpec()]
|
|
}],
|
|
behaviours: derive$1([
|
|
Keying.config({
|
|
mode: 'acyclic',
|
|
useTabstopAt: not(isPseudoStop)
|
|
}),
|
|
ComposingConfigs.memento(memForm),
|
|
RepresentingConfigs.memento(memForm, {
|
|
postprocess: function (formValue) {
|
|
return toValidValues(formValue).fold(function (err) {
|
|
console.error(err);
|
|
return {};
|
|
}, identity$1);
|
|
}
|
|
})
|
|
])
|
|
};
|
|
};
|
|
|
|
var factory$3 = function (detail, _spec) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: detail.components,
|
|
events: events$a(detail.action),
|
|
behaviours: augment(detail.tabButtonBehaviours, [
|
|
Focusing.config({}),
|
|
Keying.config({
|
|
mode: 'execution',
|
|
useSpace: true,
|
|
useEnter: true
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.value
|
|
}
|
|
})
|
|
]),
|
|
domModification: detail.domModification
|
|
};
|
|
};
|
|
var TabButton = single({
|
|
name: 'TabButton',
|
|
configFields: [
|
|
defaulted('uid', undefined),
|
|
required$1('value'),
|
|
field$1('dom', 'dom', mergeWithThunk(function () {
|
|
return {
|
|
attributes: {
|
|
'role': 'tab',
|
|
'id': generate$6('aria'),
|
|
'aria-selected': 'false'
|
|
}
|
|
};
|
|
}), anyValue()),
|
|
option('action'),
|
|
defaulted('domModification', {}),
|
|
field('tabButtonBehaviours', [
|
|
Focusing,
|
|
Keying,
|
|
Representing
|
|
]),
|
|
required$1('view')
|
|
],
|
|
factory: factory$3
|
|
});
|
|
|
|
var schema$1 = constant$1([
|
|
required$1('tabs'),
|
|
required$1('dom'),
|
|
defaulted('clickToDismiss', false),
|
|
field('tabbarBehaviours', [
|
|
Highlighting,
|
|
Keying
|
|
]),
|
|
markers$1([
|
|
'tabClass',
|
|
'selectedClass'
|
|
])
|
|
]);
|
|
var tabsPart = group({
|
|
factory: TabButton,
|
|
name: 'tabs',
|
|
unit: 'tab',
|
|
overrides: function (barDetail) {
|
|
var dismissTab$1 = function (tabbar, button) {
|
|
Highlighting.dehighlight(tabbar, button);
|
|
emitWith(tabbar, dismissTab(), {
|
|
tabbar: tabbar,
|
|
button: button
|
|
});
|
|
};
|
|
var changeTab$1 = function (tabbar, button) {
|
|
Highlighting.highlight(tabbar, button);
|
|
emitWith(tabbar, changeTab(), {
|
|
tabbar: tabbar,
|
|
button: button
|
|
});
|
|
};
|
|
return {
|
|
action: function (button) {
|
|
var tabbar = button.getSystem().getByUid(barDetail.uid).getOrDie();
|
|
var activeButton = Highlighting.isHighlighted(tabbar, button);
|
|
var response = function () {
|
|
if (activeButton && barDetail.clickToDismiss) {
|
|
return dismissTab$1;
|
|
} else if (!activeButton) {
|
|
return changeTab$1;
|
|
} else {
|
|
return noop;
|
|
}
|
|
}();
|
|
response(tabbar, button);
|
|
},
|
|
domModification: { classes: [barDetail.markers.tabClass] }
|
|
};
|
|
}
|
|
});
|
|
var parts$1 = constant$1([tabsPart]);
|
|
|
|
var factory$2 = function (detail, components, _spec, _externals) {
|
|
return {
|
|
'uid': detail.uid,
|
|
'dom': detail.dom,
|
|
components: components,
|
|
'debug.sketcher': 'Tabbar',
|
|
'domModification': { attributes: { role: 'tablist' } },
|
|
'behaviours': augment(detail.tabbarBehaviours, [
|
|
Highlighting.config({
|
|
highlightClass: detail.markers.selectedClass,
|
|
itemClass: detail.markers.tabClass,
|
|
onHighlight: function (tabbar, tab) {
|
|
set$8(tab.element, 'aria-selected', 'true');
|
|
},
|
|
onDehighlight: function (tabbar, tab) {
|
|
set$8(tab.element, 'aria-selected', 'false');
|
|
}
|
|
}),
|
|
Keying.config({
|
|
mode: 'flow',
|
|
getInitial: function (tabbar) {
|
|
return Highlighting.getHighlighted(tabbar).map(function (tab) {
|
|
return tab.element;
|
|
});
|
|
},
|
|
selector: '.' + detail.markers.tabClass,
|
|
executeOnMove: true
|
|
})
|
|
])
|
|
};
|
|
};
|
|
var Tabbar = composite({
|
|
name: 'Tabbar',
|
|
configFields: schema$1(),
|
|
partFields: parts$1(),
|
|
factory: factory$2
|
|
});
|
|
|
|
var factory$1 = function (detail, _spec) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
behaviours: augment(detail.tabviewBehaviours, [Replacing.config({})]),
|
|
domModification: { attributes: { role: 'tabpanel' } }
|
|
};
|
|
};
|
|
var Tabview = single({
|
|
name: 'Tabview',
|
|
configFields: [field('tabviewBehaviours', [Replacing])],
|
|
factory: factory$1
|
|
});
|
|
|
|
var schema = constant$1([
|
|
defaulted('selectFirst', true),
|
|
onHandler('onChangeTab'),
|
|
onHandler('onDismissTab'),
|
|
defaulted('tabs', []),
|
|
field('tabSectionBehaviours', [])
|
|
]);
|
|
var barPart = required({
|
|
factory: Tabbar,
|
|
schema: [
|
|
required$1('dom'),
|
|
requiredObjOf('markers', [
|
|
required$1('tabClass'),
|
|
required$1('selectedClass')
|
|
])
|
|
],
|
|
name: 'tabbar',
|
|
defaults: function (detail) {
|
|
return { tabs: detail.tabs };
|
|
}
|
|
});
|
|
var viewPart = required({
|
|
factory: Tabview,
|
|
name: 'tabview'
|
|
});
|
|
var parts = constant$1([
|
|
barPart,
|
|
viewPart
|
|
]);
|
|
|
|
var factory = function (detail, components, _spec, _externals) {
|
|
var changeTab$1 = function (button) {
|
|
var tabValue = Representing.getValue(button);
|
|
getPart(button, detail, 'tabview').each(function (tabview) {
|
|
var tabWithValue = find$5(detail.tabs, function (t) {
|
|
return t.value === tabValue;
|
|
});
|
|
tabWithValue.each(function (tabData) {
|
|
var panel = tabData.view();
|
|
getOpt(button.element, 'id').each(function (id) {
|
|
set$8(tabview.element, 'aria-labelledby', id);
|
|
});
|
|
Replacing.set(tabview, panel);
|
|
detail.onChangeTab(tabview, button, panel);
|
|
});
|
|
});
|
|
};
|
|
var changeTabBy = function (section, byPred) {
|
|
getPart(section, detail, 'tabbar').each(function (tabbar) {
|
|
byPred(tabbar).each(emitExecute);
|
|
});
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: get$2(detail.tabSectionBehaviours),
|
|
events: derive$2(flatten([
|
|
detail.selectFirst ? [runOnAttached(function (section, _simulatedEvent) {
|
|
changeTabBy(section, Highlighting.getFirst);
|
|
})] : [],
|
|
[
|
|
run$1(changeTab(), function (section, simulatedEvent) {
|
|
var button = simulatedEvent.event.button;
|
|
changeTab$1(button);
|
|
}),
|
|
run$1(dismissTab(), function (section, simulatedEvent) {
|
|
var button = simulatedEvent.event.button;
|
|
detail.onDismissTab(section, button);
|
|
})
|
|
]
|
|
])),
|
|
apis: {
|
|
getViewItems: function (section) {
|
|
return getPart(section, detail, 'tabview').map(function (tabview) {
|
|
return Replacing.contents(tabview);
|
|
}).getOr([]);
|
|
},
|
|
showTab: function (section, tabKey) {
|
|
var getTabIfNotActive = function (tabbar) {
|
|
var candidates = Highlighting.getCandidates(tabbar);
|
|
var optTab = find$5(candidates, function (c) {
|
|
return Representing.getValue(c) === tabKey;
|
|
});
|
|
return optTab.filter(function (tab) {
|
|
return !Highlighting.isHighlighted(tabbar, tab);
|
|
});
|
|
};
|
|
changeTabBy(section, getTabIfNotActive);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var TabSection = composite({
|
|
name: 'TabSection',
|
|
configFields: schema(),
|
|
partFields: parts(),
|
|
factory: factory,
|
|
apis: {
|
|
getViewItems: function (apis, component) {
|
|
return apis.getViewItems(component);
|
|
},
|
|
showTab: function (apis, component, tabKey) {
|
|
apis.showTab(component, tabKey);
|
|
}
|
|
}
|
|
});
|
|
|
|
var measureHeights = function (allTabs, tabview, tabviewComp) {
|
|
return map$2(allTabs, function (_tab, i) {
|
|
Replacing.set(tabviewComp, allTabs[i].view());
|
|
var rect = tabview.dom.getBoundingClientRect();
|
|
Replacing.set(tabviewComp, []);
|
|
return rect.height;
|
|
});
|
|
};
|
|
var getMaxHeight = function (heights) {
|
|
return head(sort(heights, function (a, b) {
|
|
if (a > b) {
|
|
return -1;
|
|
} else if (a < b) {
|
|
return +1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}));
|
|
};
|
|
var getMaxTabviewHeight = function (dialog, tabview, tablist) {
|
|
var documentElement$1 = documentElement(dialog).dom;
|
|
var rootElm = ancestor(dialog, '.tox-dialog-wrap').getOr(dialog);
|
|
var isFixed = get$c(rootElm, 'position') === 'fixed';
|
|
var maxHeight;
|
|
if (isFixed) {
|
|
maxHeight = Math.max(documentElement$1.clientHeight, window.innerHeight);
|
|
} else {
|
|
maxHeight = Math.max(documentElement$1.offsetHeight, documentElement$1.scrollHeight);
|
|
}
|
|
var tabviewHeight = get$b(tabview);
|
|
var isTabListBeside = tabview.dom.offsetLeft >= tablist.dom.offsetLeft + get$a(tablist);
|
|
var currentTabHeight = isTabListBeside ? Math.max(get$b(tablist), tabviewHeight) : tabviewHeight;
|
|
var dialogTopMargin = parseInt(get$c(dialog, 'margin-top'), 10) || 0;
|
|
var dialogBottomMargin = parseInt(get$c(dialog, 'margin-bottom'), 10) || 0;
|
|
var dialogHeight = get$b(dialog) + dialogTopMargin + dialogBottomMargin;
|
|
var chromeHeight = dialogHeight - currentTabHeight;
|
|
return maxHeight - chromeHeight;
|
|
};
|
|
var showTab = function (allTabs, comp) {
|
|
head(allTabs).each(function (tab) {
|
|
return TabSection.showTab(comp, tab.value);
|
|
});
|
|
};
|
|
var setTabviewHeight = function (tabview, height) {
|
|
set$7(tabview, 'height', height + 'px');
|
|
if (!detect$1().browser.isIE()) {
|
|
set$7(tabview, 'flex-basis', height + 'px');
|
|
} else {
|
|
remove$6(tabview, 'flex-basis');
|
|
}
|
|
};
|
|
var updateTabviewHeight = function (dialogBody, tabview, maxTabHeight) {
|
|
ancestor(dialogBody, '[role="dialog"]').each(function (dialog) {
|
|
descendant(dialog, '[role="tablist"]').each(function (tablist) {
|
|
maxTabHeight.get().map(function (height) {
|
|
set$7(tabview, 'height', '0');
|
|
set$7(tabview, 'flex-basis', '0');
|
|
return Math.min(height, getMaxTabviewHeight(dialog, tabview, tablist));
|
|
}).each(function (height) {
|
|
setTabviewHeight(tabview, height);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var getTabview = function (dialog) {
|
|
return descendant(dialog, '[role="tabpanel"]');
|
|
};
|
|
var setMode = function (allTabs) {
|
|
var smartTabHeight = function () {
|
|
var maxTabHeight = value$1();
|
|
var extraEvents = [
|
|
runOnAttached(function (comp) {
|
|
var dialog = comp.element;
|
|
getTabview(dialog).each(function (tabview) {
|
|
set$7(tabview, 'visibility', 'hidden');
|
|
comp.getSystem().getByDom(tabview).toOptional().each(function (tabviewComp) {
|
|
var heights = measureHeights(allTabs, tabview, tabviewComp);
|
|
var maxTabHeightOpt = getMaxHeight(heights);
|
|
maxTabHeightOpt.fold(maxTabHeight.clear, maxTabHeight.set);
|
|
});
|
|
updateTabviewHeight(dialog, tabview, maxTabHeight);
|
|
remove$6(tabview, 'visibility');
|
|
showTab(allTabs, comp);
|
|
global$f.requestAnimationFrame(function () {
|
|
updateTabviewHeight(dialog, tabview, maxTabHeight);
|
|
});
|
|
});
|
|
}),
|
|
run$1(windowResize(), function (comp) {
|
|
var dialog = comp.element;
|
|
getTabview(dialog).each(function (tabview) {
|
|
updateTabviewHeight(dialog, tabview, maxTabHeight);
|
|
});
|
|
}),
|
|
run$1(formResizeEvent, function (comp, _se) {
|
|
var dialog = comp.element;
|
|
getTabview(dialog).each(function (tabview) {
|
|
var oldFocus = active(getRootNode(tabview));
|
|
set$7(tabview, 'visibility', 'hidden');
|
|
var oldHeight = getRaw(tabview, 'height').map(function (h) {
|
|
return parseInt(h, 10);
|
|
});
|
|
remove$6(tabview, 'height');
|
|
remove$6(tabview, 'flex-basis');
|
|
var newHeight = tabview.dom.getBoundingClientRect().height;
|
|
var hasGrown = oldHeight.forall(function (h) {
|
|
return newHeight > h;
|
|
});
|
|
if (hasGrown) {
|
|
maxTabHeight.set(newHeight);
|
|
updateTabviewHeight(dialog, tabview, maxTabHeight);
|
|
} else {
|
|
oldHeight.each(function (h) {
|
|
setTabviewHeight(tabview, h);
|
|
});
|
|
}
|
|
remove$6(tabview, 'visibility');
|
|
oldFocus.each(focus$3);
|
|
});
|
|
})
|
|
];
|
|
var selectFirst = false;
|
|
return {
|
|
extraEvents: extraEvents,
|
|
selectFirst: selectFirst
|
|
};
|
|
}();
|
|
var naiveTabHeight = function () {
|
|
var extraEvents = [];
|
|
var selectFirst = true;
|
|
return {
|
|
extraEvents: extraEvents,
|
|
selectFirst: selectFirst
|
|
};
|
|
}();
|
|
return {
|
|
smartTabHeight: smartTabHeight,
|
|
naiveTabHeight: naiveTabHeight
|
|
};
|
|
};
|
|
|
|
var SendDataToSectionChannel = 'send-data-to-section';
|
|
var SendDataToViewChannel = 'send-data-to-view';
|
|
var renderTabPanel = function (spec, backstage) {
|
|
var storedValue = Cell({});
|
|
var updateDataWithForm = function (form) {
|
|
var formData = Representing.getValue(form);
|
|
var validData = toValidValues(formData).getOr({});
|
|
var currentData = storedValue.get();
|
|
var newData = deepMerge(currentData, validData);
|
|
storedValue.set(newData);
|
|
};
|
|
var setDataOnForm = function (form) {
|
|
var tabData = storedValue.get();
|
|
Representing.setValue(form, tabData);
|
|
};
|
|
var oldTab = Cell(null);
|
|
var allTabs = map$2(spec.tabs, function (tab) {
|
|
return {
|
|
value: tab.name,
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body-nav-item'],
|
|
innerHtml: backstage.shared.providers.translate(tab.title)
|
|
},
|
|
view: function () {
|
|
return [Form.sketch(function (parts) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-form']
|
|
},
|
|
components: map$2(tab.items, function (item) {
|
|
return interpretInForm(parts, item, backstage);
|
|
}),
|
|
formBehaviours: derive$1([
|
|
Keying.config({
|
|
mode: 'acyclic',
|
|
useTabstopAt: not(isPseudoStop)
|
|
}),
|
|
config('TabView.form.events', [
|
|
runOnAttached(setDataOnForm),
|
|
runOnDetached(updateDataWithForm)
|
|
]),
|
|
Receiving.config({
|
|
channels: wrapAll([
|
|
{
|
|
key: SendDataToSectionChannel,
|
|
value: { onReceive: updateDataWithForm }
|
|
},
|
|
{
|
|
key: SendDataToViewChannel,
|
|
value: { onReceive: setDataOnForm }
|
|
}
|
|
])
|
|
})
|
|
])
|
|
};
|
|
})];
|
|
}
|
|
};
|
|
});
|
|
var tabMode = setMode(allTabs).smartTabHeight;
|
|
return TabSection.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body']
|
|
},
|
|
onChangeTab: function (section, button, _viewItems) {
|
|
var name = Representing.getValue(button);
|
|
emitWith(section, formTabChangeEvent, {
|
|
name: name,
|
|
oldName: oldTab.get()
|
|
});
|
|
oldTab.set(name);
|
|
},
|
|
tabs: allTabs,
|
|
components: [
|
|
TabSection.parts.tabbar({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body-nav']
|
|
},
|
|
components: [Tabbar.parts.tabs({})],
|
|
markers: {
|
|
tabClass: 'tox-tab',
|
|
selectedClass: 'tox-dialog__body-nav-item--active'
|
|
},
|
|
tabbarBehaviours: derive$1([Tabstopping.config({})])
|
|
}),
|
|
TabSection.parts.tabview({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body-content']
|
|
}
|
|
})
|
|
],
|
|
selectFirst: tabMode.selectFirst,
|
|
tabSectionBehaviours: derive$1([
|
|
config('tabpanel', tabMode.extraEvents),
|
|
Keying.config({ mode: 'acyclic' }),
|
|
Composing.config({
|
|
find: function (comp) {
|
|
return head(TabSection.getViewItems(comp));
|
|
}
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (tsection) {
|
|
tsection.getSystem().broadcastOn([SendDataToSectionChannel], {});
|
|
return storedValue.get();
|
|
},
|
|
setValue: function (tsection, value) {
|
|
storedValue.set(value);
|
|
tsection.getSystem().broadcastOn([SendDataToViewChannel], {});
|
|
}
|
|
}
|
|
})
|
|
])
|
|
});
|
|
};
|
|
|
|
var dialogChannel = generate$6('update-dialog');
|
|
var titleChannel = generate$6('update-title');
|
|
var bodyChannel = generate$6('update-body');
|
|
var footerChannel = generate$6('update-footer');
|
|
var bodySendMessageChannel = generate$6('body-send-message');
|
|
|
|
var renderBody = function (spec, id, backstage, ariaAttrs) {
|
|
var renderComponents = function (incoming) {
|
|
switch (incoming.body.type) {
|
|
case 'tabpanel': {
|
|
return [renderTabPanel(incoming.body, backstage)];
|
|
}
|
|
default: {
|
|
return [renderBodyPanel(incoming.body, backstage)];
|
|
}
|
|
}
|
|
};
|
|
var updateState = function (_comp, incoming) {
|
|
return Optional.some({
|
|
isTabPanel: function () {
|
|
return incoming.body.type === 'tabpanel';
|
|
}
|
|
});
|
|
};
|
|
var ariaAttributes = { 'aria-live': 'polite' };
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__content-js'],
|
|
attributes: __assign(__assign({}, id.map(function (x) {
|
|
return { id: x };
|
|
}).getOr({})), ariaAttrs ? ariaAttributes : {})
|
|
},
|
|
components: [],
|
|
behaviours: derive$1([
|
|
ComposingConfigs.childAt(0),
|
|
Reflecting.config({
|
|
channel: bodyChannel,
|
|
updateState: updateState,
|
|
renderComponents: renderComponents,
|
|
initialData: spec
|
|
})
|
|
])
|
|
};
|
|
};
|
|
var renderInlineBody = function (spec, contentId, backstage, ariaAttrs) {
|
|
return renderBody(spec, Optional.some(contentId), backstage, ariaAttrs);
|
|
};
|
|
var renderModalBody = function (spec, backstage) {
|
|
var bodySpec = renderBody(spec, Optional.none(), backstage, false);
|
|
return ModalDialog.parts.body(bodySpec);
|
|
};
|
|
var renderIframeBody = function (spec) {
|
|
var bodySpec = {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__content-js']
|
|
},
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body-iframe']
|
|
},
|
|
components: [craft({
|
|
dom: {
|
|
tag: 'iframe',
|
|
attributes: { src: spec.url }
|
|
},
|
|
behaviours: derive$1([
|
|
Tabstopping.config({}),
|
|
Focusing.config({})
|
|
])
|
|
})]
|
|
}],
|
|
behaviours: derive$1([Keying.config({
|
|
mode: 'acyclic',
|
|
useTabstopAt: not(isPseudoStop)
|
|
})])
|
|
};
|
|
return ModalDialog.parts.body(bodySpec);
|
|
};
|
|
|
|
var isTouch = global$9.deviceType.isTouch();
|
|
var hiddenHeader = function (title, close) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
styles: { display: 'none' },
|
|
classes: ['tox-dialog__header']
|
|
},
|
|
components: [
|
|
title,
|
|
close
|
|
]
|
|
};
|
|
};
|
|
var pClose = function (onClose, providersBackstage) {
|
|
return ModalDialog.parts.close(Button.sketch({
|
|
dom: {
|
|
tag: 'button',
|
|
classes: [
|
|
'tox-button',
|
|
'tox-button--icon',
|
|
'tox-button--naked'
|
|
],
|
|
attributes: {
|
|
'type': 'button',
|
|
'aria-label': providersBackstage.translate('Close')
|
|
}
|
|
},
|
|
action: onClose,
|
|
buttonBehaviours: derive$1([Tabstopping.config({})])
|
|
}));
|
|
};
|
|
var pUntitled = function () {
|
|
return ModalDialog.parts.title({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__title'],
|
|
innerHtml: '',
|
|
styles: { display: 'none' }
|
|
}
|
|
});
|
|
};
|
|
var pBodyMessage = function (message, providersBackstage) {
|
|
return ModalDialog.parts.body({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body']
|
|
},
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__body-content']
|
|
},
|
|
components: [{ dom: fromHtml('<p>' + providersBackstage.translate(message) + '</p>') }]
|
|
}]
|
|
});
|
|
};
|
|
var pFooter = function (buttons) {
|
|
return ModalDialog.parts.footer({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__footer']
|
|
},
|
|
components: buttons
|
|
});
|
|
};
|
|
var pFooterGroup = function (startButtons, endButtons) {
|
|
return [
|
|
Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__footer-start']
|
|
},
|
|
components: startButtons
|
|
}),
|
|
Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__footer-end']
|
|
},
|
|
components: endButtons
|
|
})
|
|
];
|
|
};
|
|
var renderDialog$1 = function (spec) {
|
|
var _a;
|
|
var dialogClass = 'tox-dialog';
|
|
var blockerClass = dialogClass + '-wrap';
|
|
var blockerBackdropClass = blockerClass + '__backdrop';
|
|
var scrollLockClass = dialogClass + '__disable-scroll';
|
|
return ModalDialog.sketch({
|
|
lazySink: spec.lazySink,
|
|
onEscape: function (comp) {
|
|
spec.onEscape(comp);
|
|
return Optional.some(true);
|
|
},
|
|
useTabstopAt: function (elem) {
|
|
return !isPseudoStop(elem);
|
|
},
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [dialogClass].concat(spec.extraClasses),
|
|
styles: __assign({ position: 'relative' }, spec.extraStyles)
|
|
},
|
|
components: __spreadArray([
|
|
spec.header,
|
|
spec.body
|
|
], spec.footer.toArray(), true),
|
|
parts: {
|
|
blocker: {
|
|
dom: fromHtml('<div class="' + blockerClass + '"></div>'),
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: isTouch ? [
|
|
blockerBackdropClass,
|
|
blockerBackdropClass + '--opaque'
|
|
] : [blockerBackdropClass]
|
|
}
|
|
}]
|
|
}
|
|
},
|
|
dragBlockClass: blockerClass,
|
|
modalBehaviours: derive$1(__spreadArray([
|
|
Focusing.config({}),
|
|
config('dialog-events', spec.dialogEvents.concat([runOnSource(focusin(), function (comp, _se) {
|
|
Keying.focusIn(comp);
|
|
})])),
|
|
config('scroll-lock', [
|
|
runOnAttached(function () {
|
|
add$2(body(), scrollLockClass);
|
|
}),
|
|
runOnDetached(function () {
|
|
remove$2(body(), scrollLockClass);
|
|
})
|
|
])
|
|
], spec.extraBehaviours, true)),
|
|
eventOrder: __assign((_a = {}, _a[execute$5()] = ['dialog-events'], _a[attachedToDom()] = [
|
|
'scroll-lock',
|
|
'dialog-events',
|
|
'alloy.base.behaviour'
|
|
], _a[detachedFromDom()] = [
|
|
'alloy.base.behaviour',
|
|
'dialog-events',
|
|
'scroll-lock'
|
|
], _a), spec.eventOrder)
|
|
});
|
|
};
|
|
|
|
var renderClose = function (providersBackstage) {
|
|
return Button.sketch({
|
|
dom: {
|
|
tag: 'button',
|
|
classes: [
|
|
'tox-button',
|
|
'tox-button--icon',
|
|
'tox-button--naked'
|
|
],
|
|
attributes: {
|
|
'type': 'button',
|
|
'aria-label': providersBackstage.translate('Close'),
|
|
'title': providersBackstage.translate('Close')
|
|
}
|
|
},
|
|
components: [render$3('close', {
|
|
tag: 'div',
|
|
classes: ['tox-icon']
|
|
}, providersBackstage.icons)],
|
|
action: function (comp) {
|
|
emit(comp, formCancelEvent);
|
|
}
|
|
});
|
|
};
|
|
var renderTitle = function (spec, id, providersBackstage) {
|
|
var renderComponents = function (data) {
|
|
return [text(providersBackstage.translate(data.title))];
|
|
};
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__title'],
|
|
attributes: __assign({}, id.map(function (x) {
|
|
return { id: x };
|
|
}).getOr({}))
|
|
},
|
|
components: renderComponents(spec),
|
|
behaviours: derive$1([Reflecting.config({
|
|
channel: titleChannel,
|
|
renderComponents: renderComponents
|
|
})])
|
|
};
|
|
};
|
|
var renderDragHandle = function () {
|
|
return { dom: fromHtml('<div class="tox-dialog__draghandle"></div>') };
|
|
};
|
|
var renderInlineHeader = function (spec, titleId, providersBackstage) {
|
|
return Container.sketch({
|
|
dom: fromHtml('<div class="tox-dialog__header"></div>'),
|
|
components: [
|
|
renderTitle(spec, Optional.some(titleId), providersBackstage),
|
|
renderDragHandle(),
|
|
renderClose(providersBackstage)
|
|
],
|
|
containerBehaviours: derive$1([Dragging.config({
|
|
mode: 'mouse',
|
|
blockerClass: 'blocker',
|
|
getTarget: function (handle) {
|
|
return closest$1(handle, '[role="dialog"]').getOrDie();
|
|
},
|
|
snaps: {
|
|
getSnapPoints: function () {
|
|
return [];
|
|
},
|
|
leftAttr: 'data-drag-left',
|
|
topAttr: 'data-drag-top'
|
|
}
|
|
})])
|
|
});
|
|
};
|
|
var renderModalHeader = function (spec, providersBackstage) {
|
|
var pTitle = ModalDialog.parts.title(renderTitle(spec, Optional.none(), providersBackstage));
|
|
var pHandle = ModalDialog.parts.draghandle(renderDragHandle());
|
|
var pClose = ModalDialog.parts.close(renderClose(providersBackstage));
|
|
var components = [pTitle].concat(spec.draggable ? [pHandle] : []).concat([pClose]);
|
|
return Container.sketch({
|
|
dom: fromHtml('<div class="tox-dialog__header"></div>'),
|
|
components: components
|
|
});
|
|
};
|
|
|
|
var getHeader = function (title, backstage) {
|
|
return renderModalHeader({
|
|
title: backstage.shared.providers.translate(title),
|
|
draggable: backstage.dialog.isDraggableModal()
|
|
}, backstage.shared.providers);
|
|
};
|
|
var getBusySpec = function (message, bs, providers) {
|
|
return {
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__busy-spinner'],
|
|
attributes: { 'aria-label': providers.translate(message) },
|
|
styles: {
|
|
left: '0px',
|
|
right: '0px',
|
|
bottom: '0px',
|
|
top: '0px',
|
|
position: 'absolute'
|
|
}
|
|
},
|
|
behaviours: bs,
|
|
components: [{ dom: fromHtml('<div class="tox-spinner"><div></div><div></div><div></div></div>') }]
|
|
};
|
|
};
|
|
var getEventExtras = function (lazyDialog, providers, extra) {
|
|
return {
|
|
onClose: function () {
|
|
return extra.closeWindow();
|
|
},
|
|
onBlock: function (blockEvent) {
|
|
ModalDialog.setBusy(lazyDialog(), function (_comp, bs) {
|
|
return getBusySpec(blockEvent.message, bs, providers);
|
|
});
|
|
},
|
|
onUnblock: function () {
|
|
ModalDialog.setIdle(lazyDialog());
|
|
}
|
|
};
|
|
};
|
|
var renderModalDialog = function (spec, initialData, dialogEvents, backstage) {
|
|
var _a;
|
|
var updateState = function (_comp, incoming) {
|
|
return Optional.some(incoming);
|
|
};
|
|
return build$1(renderDialog$1(__assign(__assign({}, spec), {
|
|
lazySink: backstage.shared.getSink,
|
|
extraBehaviours: __spreadArray([
|
|
Reflecting.config({
|
|
channel: dialogChannel,
|
|
updateState: updateState,
|
|
initialData: initialData
|
|
}),
|
|
RepresentingConfigs.memory({})
|
|
], spec.extraBehaviours, true),
|
|
onEscape: function (comp) {
|
|
emit(comp, formCancelEvent);
|
|
},
|
|
dialogEvents: dialogEvents,
|
|
eventOrder: (_a = {}, _a[receive()] = [
|
|
Reflecting.name(),
|
|
Receiving.name()
|
|
], _a[attachedToDom()] = [
|
|
'scroll-lock',
|
|
Reflecting.name(),
|
|
'messages',
|
|
'dialog-events',
|
|
'alloy.base.behaviour'
|
|
], _a[detachedFromDom()] = [
|
|
'alloy.base.behaviour',
|
|
'dialog-events',
|
|
'messages',
|
|
Reflecting.name(),
|
|
'scroll-lock'
|
|
], _a)
|
|
})));
|
|
};
|
|
var mapMenuButtons = function (buttons) {
|
|
var mapItems = function (button) {
|
|
var items = map$2(button.items, function (item) {
|
|
var cell = Cell(false);
|
|
return __assign(__assign({}, item), { storage: cell });
|
|
});
|
|
return __assign(__assign({}, button), { items: items });
|
|
};
|
|
return map$2(buttons, function (button) {
|
|
if (button.type === 'menu') {
|
|
return mapItems(button);
|
|
}
|
|
return button;
|
|
});
|
|
};
|
|
var extractCellsToObject = function (buttons) {
|
|
return foldl(buttons, function (acc, button) {
|
|
if (button.type === 'menu') {
|
|
var menuButton = button;
|
|
return foldl(menuButton.items, function (innerAcc, item) {
|
|
innerAcc[item.name] = item.storage;
|
|
return innerAcc;
|
|
}, acc);
|
|
}
|
|
return acc;
|
|
}, {});
|
|
};
|
|
|
|
var initCommonEvents = function (fireApiEvent, extras) {
|
|
return [
|
|
runWithTarget(focusin(), onFocus),
|
|
fireApiEvent(formCloseEvent, function (_api, spec) {
|
|
extras.onClose();
|
|
spec.onClose();
|
|
}),
|
|
fireApiEvent(formCancelEvent, function (api, spec, _event, self) {
|
|
spec.onCancel(api);
|
|
emit(self, formCloseEvent);
|
|
}),
|
|
run$1(formUnblockEvent, function (_c, _se) {
|
|
return extras.onUnblock();
|
|
}),
|
|
run$1(formBlockEvent, function (_c, se) {
|
|
return extras.onBlock(se.event);
|
|
})
|
|
];
|
|
};
|
|
var initUrlDialog = function (getInstanceApi, extras) {
|
|
var fireApiEvent = function (eventName, f) {
|
|
return run$1(eventName, function (c, se) {
|
|
withSpec(c, function (spec, _c) {
|
|
f(getInstanceApi(), spec, se.event, c);
|
|
});
|
|
});
|
|
};
|
|
var withSpec = function (c, f) {
|
|
Reflecting.getState(c).get().each(function (currentDialog) {
|
|
f(currentDialog, c);
|
|
});
|
|
};
|
|
return __spreadArray(__spreadArray([], initCommonEvents(fireApiEvent, extras), true), [fireApiEvent(formActionEvent, function (api, spec, event) {
|
|
spec.onAction(api, { name: event.name });
|
|
})], false);
|
|
};
|
|
var initDialog = function (getInstanceApi, extras, getSink) {
|
|
var fireApiEvent = function (eventName, f) {
|
|
return run$1(eventName, function (c, se) {
|
|
withSpec(c, function (spec, _c) {
|
|
f(getInstanceApi(), spec, se.event, c);
|
|
});
|
|
});
|
|
};
|
|
var withSpec = function (c, f) {
|
|
Reflecting.getState(c).get().each(function (currentDialogInit) {
|
|
f(currentDialogInit.internalDialog, c);
|
|
});
|
|
};
|
|
return __spreadArray(__spreadArray([], initCommonEvents(fireApiEvent, extras), true), [
|
|
fireApiEvent(formSubmitEvent, function (api, spec) {
|
|
return spec.onSubmit(api);
|
|
}),
|
|
fireApiEvent(formChangeEvent, function (api, spec, event) {
|
|
spec.onChange(api, { name: event.name });
|
|
}),
|
|
fireApiEvent(formActionEvent, function (api, spec, event, component) {
|
|
var focusIn = function () {
|
|
return Keying.focusIn(component);
|
|
};
|
|
var isDisabled = function (focused) {
|
|
return has$1(focused, 'disabled') || getOpt(focused, 'aria-disabled').exists(function (val) {
|
|
return val === 'true';
|
|
});
|
|
};
|
|
var rootNode = getRootNode(component.element);
|
|
var current = active(rootNode);
|
|
spec.onAction(api, {
|
|
name: event.name,
|
|
value: event.value
|
|
});
|
|
active(rootNode).fold(focusIn, function (focused) {
|
|
if (isDisabled(focused)) {
|
|
focusIn();
|
|
} else if (current.exists(function (cur) {
|
|
return contains(focused, cur) && isDisabled(cur);
|
|
})) {
|
|
focusIn();
|
|
} else {
|
|
getSink().toOptional().filter(function (sink) {
|
|
return !contains(sink.element, focused);
|
|
}).each(focusIn);
|
|
}
|
|
});
|
|
}),
|
|
fireApiEvent(formTabChangeEvent, function (api, spec, event) {
|
|
spec.onTabChange(api, {
|
|
newTabName: event.name,
|
|
oldTabName: event.oldName
|
|
});
|
|
}),
|
|
runOnDetached(function (component) {
|
|
var api = getInstanceApi();
|
|
Representing.setValue(component, api.getData());
|
|
})
|
|
], false);
|
|
};
|
|
var SilverDialogEvents = {
|
|
initUrlDialog: initUrlDialog,
|
|
initDialog: initDialog
|
|
};
|
|
|
|
var makeButton = function (button, backstage) {
|
|
return renderFooterButton(button, button.type, backstage);
|
|
};
|
|
var lookup = function (compInSystem, footerButtons, buttonName) {
|
|
return find$5(footerButtons, function (button) {
|
|
return button.name === buttonName;
|
|
}).bind(function (memButton) {
|
|
return memButton.memento.getOpt(compInSystem);
|
|
});
|
|
};
|
|
var renderComponents = function (_data, state) {
|
|
var footerButtons = state.map(function (s) {
|
|
return s.footerButtons;
|
|
}).getOr([]);
|
|
var buttonGroups = partition$3(footerButtons, function (button) {
|
|
return button.align === 'start';
|
|
});
|
|
var makeGroup = function (edge, buttons) {
|
|
return Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: ['tox-dialog__footer-' + edge]
|
|
},
|
|
components: map$2(buttons, function (button) {
|
|
return button.memento.asSpec();
|
|
})
|
|
});
|
|
};
|
|
var startButtons = makeGroup('start', buttonGroups.pass);
|
|
var endButtons = makeGroup('end', buttonGroups.fail);
|
|
return [
|
|
startButtons,
|
|
endButtons
|
|
];
|
|
};
|
|
var renderFooter = function (initSpec, backstage) {
|
|
var updateState = function (_comp, data) {
|
|
var footerButtons = map$2(data.buttons, function (button) {
|
|
var memButton = record(makeButton(button, backstage));
|
|
return {
|
|
name: button.name,
|
|
align: button.align,
|
|
memento: memButton
|
|
};
|
|
});
|
|
var lookupByName = function (compInSystem, buttonName) {
|
|
return lookup(compInSystem, footerButtons, buttonName);
|
|
};
|
|
return Optional.some({
|
|
lookupByName: lookupByName,
|
|
footerButtons: footerButtons
|
|
});
|
|
};
|
|
return {
|
|
dom: fromHtml('<div class="tox-dialog__footer"></div>'),
|
|
components: [],
|
|
behaviours: derive$1([Reflecting.config({
|
|
channel: footerChannel,
|
|
initialData: initSpec,
|
|
updateState: updateState,
|
|
renderComponents: renderComponents
|
|
})])
|
|
};
|
|
};
|
|
var renderInlineFooter = function (initSpec, backstage) {
|
|
return renderFooter(initSpec, backstage);
|
|
};
|
|
var renderModalFooter = function (initSpec, backstage) {
|
|
return ModalDialog.parts.footer(renderFooter(initSpec, backstage));
|
|
};
|
|
|
|
var getCompByName = function (access, name) {
|
|
var root = access.getRoot();
|
|
if (root.getSystem().isConnected()) {
|
|
var form_1 = Composing.getCurrent(access.getFormWrapper()).getOr(access.getFormWrapper());
|
|
return Form.getField(form_1, name).fold(function () {
|
|
var footer = access.getFooter();
|
|
var footerState = Reflecting.getState(footer);
|
|
return footerState.get().bind(function (f) {
|
|
return f.lookupByName(form_1, name);
|
|
});
|
|
}, function (comp) {
|
|
return Optional.some(comp);
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var validateData$1 = function (access, data) {
|
|
var root = access.getRoot();
|
|
return Reflecting.getState(root).get().map(function (dialogState) {
|
|
return getOrDie(asRaw('data', dialogState.dataValidator, data));
|
|
}).getOr(data);
|
|
};
|
|
var getDialogApi = function (access, doRedial, menuItemStates) {
|
|
var withRoot = function (f) {
|
|
var root = access.getRoot();
|
|
if (root.getSystem().isConnected()) {
|
|
f(root);
|
|
}
|
|
};
|
|
var getData = function () {
|
|
var root = access.getRoot();
|
|
var valueComp = root.getSystem().isConnected() ? access.getFormWrapper() : root;
|
|
var representedValues = Representing.getValue(valueComp);
|
|
var menuItemCurrentState = map$1(menuItemStates, function (cell) {
|
|
return cell.get();
|
|
});
|
|
return __assign(__assign({}, representedValues), menuItemCurrentState);
|
|
};
|
|
var setData = function (newData) {
|
|
withRoot(function (_) {
|
|
var prevData = instanceApi.getData();
|
|
var mergedData = __assign(__assign({}, prevData), newData);
|
|
var newInternalData = validateData$1(access, mergedData);
|
|
var form = access.getFormWrapper();
|
|
Representing.setValue(form, newInternalData);
|
|
each(menuItemStates, function (v, k) {
|
|
if (has$2(mergedData, k)) {
|
|
v.set(mergedData[k]);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var disable = function (name) {
|
|
getCompByName(access, name).each(Disabling.disable);
|
|
};
|
|
var enable = function (name) {
|
|
getCompByName(access, name).each(Disabling.enable);
|
|
};
|
|
var focus = function (name) {
|
|
getCompByName(access, name).each(Focusing.focus);
|
|
};
|
|
var block = function (message) {
|
|
if (!isString(message)) {
|
|
throw new Error('The dialogInstanceAPI.block function should be passed a blocking message of type string as an argument');
|
|
}
|
|
withRoot(function (root) {
|
|
emitWith(root, formBlockEvent, { message: message });
|
|
});
|
|
};
|
|
var unblock = function () {
|
|
withRoot(function (root) {
|
|
emit(root, formUnblockEvent);
|
|
});
|
|
};
|
|
var showTab = function (name) {
|
|
withRoot(function (_) {
|
|
var body = access.getBody();
|
|
var bodyState = Reflecting.getState(body);
|
|
if (bodyState.get().exists(function (b) {
|
|
return b.isTabPanel();
|
|
})) {
|
|
Composing.getCurrent(body).each(function (tabSection) {
|
|
TabSection.showTab(tabSection, name);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var redial = function (d) {
|
|
withRoot(function (root) {
|
|
var dialogInit = doRedial(d);
|
|
root.getSystem().broadcastOn([dialogChannel], dialogInit);
|
|
root.getSystem().broadcastOn([titleChannel], dialogInit.internalDialog);
|
|
root.getSystem().broadcastOn([bodyChannel], dialogInit.internalDialog);
|
|
root.getSystem().broadcastOn([footerChannel], dialogInit.internalDialog);
|
|
instanceApi.setData(dialogInit.initialData);
|
|
});
|
|
};
|
|
var close = function () {
|
|
withRoot(function (root) {
|
|
emit(root, formCloseEvent);
|
|
});
|
|
};
|
|
var instanceApi = {
|
|
getData: getData,
|
|
setData: setData,
|
|
disable: disable,
|
|
enable: enable,
|
|
focus: focus,
|
|
block: block,
|
|
unblock: unblock,
|
|
showTab: showTab,
|
|
redial: redial,
|
|
close: close
|
|
};
|
|
return instanceApi;
|
|
};
|
|
|
|
var getDialogSizeClasses = function (size) {
|
|
switch (size) {
|
|
case 'large':
|
|
return ['tox-dialog--width-lg'];
|
|
case 'medium':
|
|
return ['tox-dialog--width-md'];
|
|
default:
|
|
return [];
|
|
}
|
|
};
|
|
var renderDialog = function (dialogInit, extra, backstage) {
|
|
var header = getHeader(dialogInit.internalDialog.title, backstage);
|
|
var body = renderModalBody({ body: dialogInit.internalDialog.body }, backstage);
|
|
var storagedMenuButtons = mapMenuButtons(dialogInit.internalDialog.buttons);
|
|
var objOfCells = extractCellsToObject(storagedMenuButtons);
|
|
var footer = renderModalFooter({ buttons: storagedMenuButtons }, backstage);
|
|
var dialogEvents = SilverDialogEvents.initDialog(function () {
|
|
return instanceApi;
|
|
}, getEventExtras(function () {
|
|
return dialog;
|
|
}, backstage.shared.providers, extra), backstage.shared.getSink);
|
|
var dialogSize = getDialogSizeClasses(dialogInit.internalDialog.size);
|
|
var spec = {
|
|
header: header,
|
|
body: body,
|
|
footer: Optional.some(footer),
|
|
extraClasses: dialogSize,
|
|
extraBehaviours: [],
|
|
extraStyles: {}
|
|
};
|
|
var dialog = renderModalDialog(spec, dialogInit, dialogEvents, backstage);
|
|
var modalAccess = function () {
|
|
var getForm = function () {
|
|
var outerForm = ModalDialog.getBody(dialog);
|
|
return Composing.getCurrent(outerForm).getOr(outerForm);
|
|
};
|
|
return {
|
|
getRoot: constant$1(dialog),
|
|
getBody: function () {
|
|
return ModalDialog.getBody(dialog);
|
|
},
|
|
getFooter: function () {
|
|
return ModalDialog.getFooter(dialog);
|
|
},
|
|
getFormWrapper: getForm
|
|
};
|
|
}();
|
|
var instanceApi = getDialogApi(modalAccess, extra.redial, objOfCells);
|
|
return {
|
|
dialog: dialog,
|
|
instanceApi: instanceApi
|
|
};
|
|
};
|
|
|
|
var renderInlineDialog = function (dialogInit, extra, backstage, ariaAttrs) {
|
|
var _a, _b;
|
|
var dialogLabelId = generate$6('dialog-label');
|
|
var dialogContentId = generate$6('dialog-content');
|
|
var updateState = function (_comp, incoming) {
|
|
return Optional.some(incoming);
|
|
};
|
|
var memHeader = record(renderInlineHeader({
|
|
title: dialogInit.internalDialog.title,
|
|
draggable: true
|
|
}, dialogLabelId, backstage.shared.providers));
|
|
var memBody = record(renderInlineBody({ body: dialogInit.internalDialog.body }, dialogContentId, backstage, ariaAttrs));
|
|
var storagedMenuButtons = mapMenuButtons(dialogInit.internalDialog.buttons);
|
|
var objOfCells = extractCellsToObject(storagedMenuButtons);
|
|
var memFooter = record(renderInlineFooter({ buttons: storagedMenuButtons }, backstage));
|
|
var dialogEvents = SilverDialogEvents.initDialog(function () {
|
|
return instanceApi;
|
|
}, {
|
|
onBlock: function (event) {
|
|
Blocking.block(dialog, function (_comp, bs) {
|
|
return getBusySpec(event.message, bs, backstage.shared.providers);
|
|
});
|
|
},
|
|
onUnblock: function () {
|
|
Blocking.unblock(dialog);
|
|
},
|
|
onClose: function () {
|
|
return extra.closeWindow();
|
|
}
|
|
}, backstage.shared.getSink);
|
|
var dialog = build$1({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
'tox-dialog',
|
|
'tox-dialog-inline'
|
|
],
|
|
attributes: (_a = { role: 'dialog' }, _a['aria-labelledby'] = dialogLabelId, _a['aria-describedby'] = dialogContentId, _a)
|
|
},
|
|
eventOrder: (_b = {}, _b[receive()] = [
|
|
Reflecting.name(),
|
|
Receiving.name()
|
|
], _b[execute$5()] = ['execute-on-form'], _b[attachedToDom()] = [
|
|
'reflecting',
|
|
'execute-on-form'
|
|
], _b),
|
|
behaviours: derive$1([
|
|
Keying.config({
|
|
mode: 'cyclic',
|
|
onEscape: function (c) {
|
|
emit(c, formCloseEvent);
|
|
return Optional.some(true);
|
|
},
|
|
useTabstopAt: function (elem) {
|
|
return !isPseudoStop(elem) && (name$2(elem) !== 'button' || get$d(elem, 'disabled') !== 'disabled');
|
|
}
|
|
}),
|
|
Reflecting.config({
|
|
channel: dialogChannel,
|
|
updateState: updateState,
|
|
initialData: dialogInit
|
|
}),
|
|
Focusing.config({}),
|
|
config('execute-on-form', dialogEvents.concat([runOnSource(focusin(), function (comp, _se) {
|
|
Keying.focusIn(comp);
|
|
})])),
|
|
Blocking.config({
|
|
getRoot: function () {
|
|
return Optional.some(dialog);
|
|
}
|
|
}),
|
|
Replacing.config({}),
|
|
RepresentingConfigs.memory({})
|
|
]),
|
|
components: [
|
|
memHeader.asSpec(),
|
|
memBody.asSpec(),
|
|
memFooter.asSpec()
|
|
]
|
|
});
|
|
var instanceApi = getDialogApi({
|
|
getRoot: constant$1(dialog),
|
|
getFooter: function () {
|
|
return memFooter.get(dialog);
|
|
},
|
|
getBody: function () {
|
|
return memBody.get(dialog);
|
|
},
|
|
getFormWrapper: function () {
|
|
var body = memBody.get(dialog);
|
|
return Composing.getCurrent(body).getOr(body);
|
|
}
|
|
}, extra.redial, objOfCells);
|
|
return {
|
|
dialog: dialog,
|
|
instanceApi: instanceApi
|
|
};
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
|
|
var getUrlDialogApi = function (root) {
|
|
var withRoot = function (f) {
|
|
if (root.getSystem().isConnected()) {
|
|
f(root);
|
|
}
|
|
};
|
|
var block = function (message) {
|
|
if (!isString(message)) {
|
|
throw new Error('The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument');
|
|
}
|
|
withRoot(function (root) {
|
|
emitWith(root, formBlockEvent, { message: message });
|
|
});
|
|
};
|
|
var unblock = function () {
|
|
withRoot(function (root) {
|
|
emit(root, formUnblockEvent);
|
|
});
|
|
};
|
|
var close = function () {
|
|
withRoot(function (root) {
|
|
emit(root, formCloseEvent);
|
|
});
|
|
};
|
|
var sendMessage = function (data) {
|
|
withRoot(function (root) {
|
|
root.getSystem().broadcastOn([bodySendMessageChannel], data);
|
|
});
|
|
};
|
|
return {
|
|
block: block,
|
|
unblock: unblock,
|
|
close: close,
|
|
sendMessage: sendMessage
|
|
};
|
|
};
|
|
|
|
var SUPPORTED_MESSAGE_ACTIONS = [
|
|
'insertContent',
|
|
'setContent',
|
|
'execCommand',
|
|
'close',
|
|
'block',
|
|
'unblock'
|
|
];
|
|
var isSupportedMessage = function (data) {
|
|
return isObject(data) && SUPPORTED_MESSAGE_ACTIONS.indexOf(data.mceAction) !== -1;
|
|
};
|
|
var isCustomMessage = function (data) {
|
|
return !isSupportedMessage(data) && isObject(data) && has$2(data, 'mceAction');
|
|
};
|
|
var handleMessage = function (editor, api, data) {
|
|
switch (data.mceAction) {
|
|
case 'insertContent':
|
|
editor.insertContent(data.content);
|
|
break;
|
|
case 'setContent':
|
|
editor.setContent(data.content);
|
|
break;
|
|
case 'execCommand':
|
|
var ui = isBoolean(data.ui) ? data.ui : false;
|
|
editor.execCommand(data.cmd, ui, data.value);
|
|
break;
|
|
case 'close':
|
|
api.close();
|
|
break;
|
|
case 'block':
|
|
api.block(data.message);
|
|
break;
|
|
case 'unblock':
|
|
api.unblock();
|
|
break;
|
|
}
|
|
};
|
|
var renderUrlDialog = function (internalDialog, extra, editor, backstage) {
|
|
var _a;
|
|
var header = getHeader(internalDialog.title, backstage);
|
|
var body = renderIframeBody(internalDialog);
|
|
var footer = internalDialog.buttons.bind(function (buttons) {
|
|
if (buttons.length === 0) {
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.some(renderModalFooter({ buttons: buttons }, backstage));
|
|
}
|
|
});
|
|
var dialogEvents = SilverDialogEvents.initUrlDialog(function () {
|
|
return instanceApi;
|
|
}, getEventExtras(function () {
|
|
return dialog;
|
|
}, backstage.shared.providers, extra));
|
|
var styles = __assign(__assign({}, internalDialog.height.fold(function () {
|
|
return {};
|
|
}, function (height) {
|
|
return {
|
|
'height': height + 'px',
|
|
'max-height': height + 'px'
|
|
};
|
|
})), internalDialog.width.fold(function () {
|
|
return {};
|
|
}, function (width) {
|
|
return {
|
|
'width': width + 'px',
|
|
'max-width': width + 'px'
|
|
};
|
|
}));
|
|
var classes = internalDialog.width.isNone() && internalDialog.height.isNone() ? ['tox-dialog--width-lg'] : [];
|
|
var iframeUri = new global$1(internalDialog.url, { base_uri: new global$1(window.location.href) });
|
|
var iframeDomain = iframeUri.protocol + '://' + iframeUri.host + (iframeUri.port ? ':' + iframeUri.port : '');
|
|
var messageHandlerUnbinder = unbindable();
|
|
var extraBehaviours = [
|
|
config('messages', [
|
|
runOnAttached(function () {
|
|
var unbind = bind(SugarElement.fromDom(window), 'message', function (e) {
|
|
if (iframeUri.isSameOrigin(new global$1(e.raw.origin))) {
|
|
var data = e.raw.data;
|
|
if (isSupportedMessage(data)) {
|
|
handleMessage(editor, instanceApi, data);
|
|
} else if (isCustomMessage(data)) {
|
|
internalDialog.onMessage(instanceApi, data);
|
|
}
|
|
}
|
|
});
|
|
messageHandlerUnbinder.set(unbind);
|
|
}),
|
|
runOnDetached(messageHandlerUnbinder.clear)
|
|
]),
|
|
Receiving.config({
|
|
channels: (_a = {}, _a[bodySendMessageChannel] = {
|
|
onReceive: function (comp, data) {
|
|
descendant(comp.element, 'iframe').each(function (iframeEle) {
|
|
var iframeWin = iframeEle.dom.contentWindow;
|
|
iframeWin.postMessage(data, iframeDomain);
|
|
});
|
|
}
|
|
}, _a)
|
|
})
|
|
];
|
|
var spec = {
|
|
header: header,
|
|
body: body,
|
|
footer: footer,
|
|
extraClasses: classes,
|
|
extraBehaviours: extraBehaviours,
|
|
extraStyles: styles
|
|
};
|
|
var dialog = renderModalDialog(spec, internalDialog, dialogEvents, backstage);
|
|
var instanceApi = getUrlDialogApi(dialog);
|
|
return {
|
|
dialog: dialog,
|
|
instanceApi: instanceApi
|
|
};
|
|
};
|
|
|
|
var setup$2 = function (extras) {
|
|
var sharedBackstage = extras.backstage.shared;
|
|
var open = function (message, callback) {
|
|
var closeDialog = function () {
|
|
ModalDialog.hide(alertDialog);
|
|
callback();
|
|
};
|
|
var memFooterClose = record(renderFooterButton({
|
|
name: 'close-alert',
|
|
text: 'OK',
|
|
primary: true,
|
|
align: 'end',
|
|
disabled: false,
|
|
icon: Optional.none()
|
|
}, 'cancel', extras.backstage));
|
|
var titleSpec = pUntitled();
|
|
var closeSpec = pClose(closeDialog, sharedBackstage.providers);
|
|
var alertDialog = build$1(renderDialog$1({
|
|
lazySink: function () {
|
|
return sharedBackstage.getSink();
|
|
},
|
|
header: hiddenHeader(titleSpec, closeSpec),
|
|
body: pBodyMessage(message, sharedBackstage.providers),
|
|
footer: Optional.some(pFooter(pFooterGroup([], [memFooterClose.asSpec()]))),
|
|
onEscape: closeDialog,
|
|
extraClasses: ['tox-alert-dialog'],
|
|
extraBehaviours: [],
|
|
extraStyles: {},
|
|
dialogEvents: [run$1(formCancelEvent, closeDialog)],
|
|
eventOrder: {}
|
|
}));
|
|
ModalDialog.show(alertDialog);
|
|
var footerCloseButton = memFooterClose.get(alertDialog);
|
|
Focusing.focus(footerCloseButton);
|
|
};
|
|
return { open: open };
|
|
};
|
|
|
|
var setup$1 = function (extras) {
|
|
var sharedBackstage = extras.backstage.shared;
|
|
var open = function (message, callback) {
|
|
var closeDialog = function (state) {
|
|
ModalDialog.hide(confirmDialog);
|
|
callback(state);
|
|
};
|
|
var memFooterYes = record(renderFooterButton({
|
|
name: 'yes',
|
|
text: 'Yes',
|
|
primary: true,
|
|
align: 'end',
|
|
disabled: false,
|
|
icon: Optional.none()
|
|
}, 'submit', extras.backstage));
|
|
var footerNo = renderFooterButton({
|
|
name: 'no',
|
|
text: 'No',
|
|
primary: false,
|
|
align: 'end',
|
|
disabled: false,
|
|
icon: Optional.none()
|
|
}, 'cancel', extras.backstage);
|
|
var titleSpec = pUntitled();
|
|
var closeSpec = pClose(function () {
|
|
return closeDialog(false);
|
|
}, sharedBackstage.providers);
|
|
var confirmDialog = build$1(renderDialog$1({
|
|
lazySink: function () {
|
|
return sharedBackstage.getSink();
|
|
},
|
|
header: hiddenHeader(titleSpec, closeSpec),
|
|
body: pBodyMessage(message, sharedBackstage.providers),
|
|
footer: Optional.some(pFooter(pFooterGroup([], [
|
|
footerNo,
|
|
memFooterYes.asSpec()
|
|
]))),
|
|
onEscape: function () {
|
|
return closeDialog(false);
|
|
},
|
|
extraClasses: ['tox-confirm-dialog'],
|
|
extraBehaviours: [],
|
|
extraStyles: {},
|
|
dialogEvents: [
|
|
run$1(formCancelEvent, function () {
|
|
return closeDialog(false);
|
|
}),
|
|
run$1(formSubmitEvent, function () {
|
|
return closeDialog(true);
|
|
})
|
|
],
|
|
eventOrder: {}
|
|
}));
|
|
ModalDialog.show(confirmDialog);
|
|
var footerYesButton = memFooterYes.get(confirmDialog);
|
|
Focusing.focus(footerYesButton);
|
|
};
|
|
return { open: open };
|
|
};
|
|
|
|
var validateData = function (data, validator) {
|
|
return getOrDie(asRaw('data', validator, data));
|
|
};
|
|
var isAlertOrConfirmDialog = function (target) {
|
|
return closest(target, '.tox-alert-dialog') || closest(target, '.tox-confirm-dialog');
|
|
};
|
|
var inlineAdditionalBehaviours = function (editor, isStickyToolbar, isToolbarLocationTop) {
|
|
if (isStickyToolbar && isToolbarLocationTop) {
|
|
return [];
|
|
} else {
|
|
return [Docking.config({
|
|
contextual: {
|
|
lazyContext: function () {
|
|
return Optional.some(box$1(SugarElement.fromDom(editor.getContentAreaContainer())));
|
|
},
|
|
fadeInClass: 'tox-dialog-dock-fadein',
|
|
fadeOutClass: 'tox-dialog-dock-fadeout',
|
|
transitionClass: 'tox-dialog-dock-transition'
|
|
},
|
|
modes: ['top']
|
|
})];
|
|
}
|
|
};
|
|
var setup = function (extras) {
|
|
var backstage = extras.backstage;
|
|
var editor = extras.editor;
|
|
var isStickyToolbar$1 = isStickyToolbar(editor);
|
|
var alertDialog = setup$2(extras);
|
|
var confirmDialog = setup$1(extras);
|
|
var open = function (config, params, closeWindow) {
|
|
if (params !== undefined && params.inline === 'toolbar') {
|
|
return openInlineDialog(config, backstage.shared.anchors.inlineDialog(), closeWindow, params.ariaAttrs);
|
|
} else if (params !== undefined && params.inline === 'cursor') {
|
|
return openInlineDialog(config, backstage.shared.anchors.cursor(), closeWindow, params.ariaAttrs);
|
|
} else {
|
|
return openModalDialog(config, closeWindow);
|
|
}
|
|
};
|
|
var openUrl = function (config, closeWindow) {
|
|
return openModalUrlDialog(config, closeWindow);
|
|
};
|
|
var openModalUrlDialog = function (config, closeWindow) {
|
|
var factory = function (contents) {
|
|
var dialog = renderUrlDialog(contents, {
|
|
closeWindow: function () {
|
|
ModalDialog.hide(dialog.dialog);
|
|
closeWindow(dialog.instanceApi);
|
|
}
|
|
}, editor, backstage);
|
|
ModalDialog.show(dialog.dialog);
|
|
return dialog.instanceApi;
|
|
};
|
|
return DialogManager.openUrl(factory, config);
|
|
};
|
|
var openModalDialog = function (config, closeWindow) {
|
|
var factory = function (contents, internalInitialData, dataValidator) {
|
|
var initialData = internalInitialData;
|
|
var dialogInit = {
|
|
dataValidator: dataValidator,
|
|
initialData: initialData,
|
|
internalDialog: contents
|
|
};
|
|
var dialog = renderDialog(dialogInit, {
|
|
redial: DialogManager.redial,
|
|
closeWindow: function () {
|
|
ModalDialog.hide(dialog.dialog);
|
|
closeWindow(dialog.instanceApi);
|
|
}
|
|
}, backstage);
|
|
ModalDialog.show(dialog.dialog);
|
|
dialog.instanceApi.setData(initialData);
|
|
return dialog.instanceApi;
|
|
};
|
|
return DialogManager.open(factory, config);
|
|
};
|
|
var openInlineDialog = function (config$1, anchor, closeWindow, ariaAttrs) {
|
|
var factory = function (contents, internalInitialData, dataValidator) {
|
|
var initialData = validateData(internalInitialData, dataValidator);
|
|
var inlineDialog = value$1();
|
|
var isToolbarLocationTop = backstage.shared.header.isPositionedAtTop();
|
|
var dialogInit = {
|
|
dataValidator: dataValidator,
|
|
initialData: initialData,
|
|
internalDialog: contents
|
|
};
|
|
var refreshDocking = function () {
|
|
return inlineDialog.on(function (dialog) {
|
|
InlineView.reposition(dialog);
|
|
Docking.refresh(dialog);
|
|
});
|
|
};
|
|
var dialogUi = renderInlineDialog(dialogInit, {
|
|
redial: DialogManager.redial,
|
|
closeWindow: function () {
|
|
inlineDialog.on(InlineView.hide);
|
|
editor.off('ResizeEditor', refreshDocking);
|
|
inlineDialog.clear();
|
|
closeWindow(dialogUi.instanceApi);
|
|
}
|
|
}, backstage, ariaAttrs);
|
|
var inlineDialogComp = build$1(InlineView.sketch(__assign(__assign({
|
|
lazySink: backstage.shared.getSink,
|
|
dom: {
|
|
tag: 'div',
|
|
classes: []
|
|
},
|
|
fireDismissalEventInstead: {}
|
|
}, isToolbarLocationTop ? {} : { fireRepositionEventInstead: {} }), {
|
|
inlineBehaviours: derive$1(__spreadArray([config('window-manager-inline-events', [run$1(dismissRequested(), function (_comp, _se) {
|
|
emit(dialogUi.dialog, formCancelEvent);
|
|
})])], inlineAdditionalBehaviours(editor, isStickyToolbar$1, isToolbarLocationTop), true)),
|
|
isExtraPart: function (_comp, target) {
|
|
return isAlertOrConfirmDialog(target);
|
|
}
|
|
})));
|
|
inlineDialog.set(inlineDialogComp);
|
|
InlineView.showWithin(inlineDialogComp, premade(dialogUi.dialog), { anchor: anchor }, Optional.some(body()));
|
|
if (!isStickyToolbar$1 || !isToolbarLocationTop) {
|
|
Docking.refresh(inlineDialogComp);
|
|
editor.on('ResizeEditor', refreshDocking);
|
|
}
|
|
dialogUi.instanceApi.setData(initialData);
|
|
Keying.focusIn(dialogUi.dialog);
|
|
return dialogUi.instanceApi;
|
|
};
|
|
return DialogManager.open(factory, config$1);
|
|
};
|
|
var confirm = function (message, callback) {
|
|
confirmDialog.open(message, function (state) {
|
|
callback(state);
|
|
});
|
|
};
|
|
var alert = function (message, callback) {
|
|
alertDialog.open(message, function () {
|
|
callback();
|
|
});
|
|
};
|
|
var close = function (instanceApi) {
|
|
instanceApi.close();
|
|
};
|
|
return {
|
|
open: open,
|
|
openUrl: openUrl,
|
|
alert: alert,
|
|
close: close,
|
|
confirm: confirm
|
|
};
|
|
};
|
|
|
|
function Theme () {
|
|
global$g.add('silver', function (editor) {
|
|
var _a = setup$3(editor), uiMothership = _a.uiMothership, backstage = _a.backstage, renderUI = _a.renderUI, getUi = _a.getUi;
|
|
Autocompleter.register(editor, backstage.shared);
|
|
var windowMgr = setup({
|
|
editor: editor,
|
|
backstage: backstage
|
|
});
|
|
return {
|
|
renderUI: renderUI,
|
|
getWindowManagerImpl: constant$1(windowMgr),
|
|
getNotificationManagerImpl: function () {
|
|
return NotificationManagerImpl(editor, { backstage: backstage }, uiMothership);
|
|
},
|
|
ui: getUi()
|
|
};
|
|
});
|
|
}
|
|
|
|
Theme();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
function __rest(s, e) {
|
|
var t = {};
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
t[p] = s[p];
|
|
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
|
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
t[p[i]] = s[p[i]];
|
|
}
|
|
return t;
|
|
}
|
|
function __spreadArray(to, from, pack) {
|
|
if (pack || arguments.length === 2)
|
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
if (ar || !(i in from)) {
|
|
if (!ar)
|
|
ar = Array.prototype.slice.call(from, 0, i);
|
|
ar[i] = from[i];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
}
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var eq$1 = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isObject = isType$1('object');
|
|
var isArray = isType$1('array');
|
|
var isNull = eq$1(null);
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isUndefined = eq$1(undefined);
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var compose = function (fa, fb) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return fa(fb.apply(null, args));
|
|
};
|
|
};
|
|
var compose1 = function (fbc, fab) {
|
|
return function (a) {
|
|
return fbc(fab(a));
|
|
};
|
|
};
|
|
var constant$1 = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var tripleEquals = function (a, b) {
|
|
return a === b;
|
|
};
|
|
function curry(fn) {
|
|
var initialArgs = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
initialArgs[_i - 1] = arguments[_i];
|
|
}
|
|
return function () {
|
|
var restArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
restArgs[_i] = arguments[_i];
|
|
}
|
|
var all = initialArgs.concat(restArgs);
|
|
return fn.apply(null, all);
|
|
};
|
|
}
|
|
var not = function (f) {
|
|
return function (t) {
|
|
return !f(t);
|
|
};
|
|
};
|
|
var die = function (msg) {
|
|
return function () {
|
|
throw new Error(msg);
|
|
};
|
|
};
|
|
var apply$1 = function (f) {
|
|
return f();
|
|
};
|
|
var never = constant$1(false);
|
|
var always = constant$1(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant$1(null),
|
|
getOrUndefined: constant$1(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant$1('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant$1(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var cached = function (f) {
|
|
var called = false;
|
|
var r;
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (!called) {
|
|
called = true;
|
|
r = f.apply(null, args);
|
|
}
|
|
return r;
|
|
};
|
|
};
|
|
|
|
var DeviceType = function (os, browser, userAgent, mediaMatch) {
|
|
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
|
|
var isiPhone = os.isiOS() && !isiPad;
|
|
var isMobile = os.isiOS() || os.isAndroid();
|
|
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
|
|
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
|
|
var isPhone = isiPhone || isMobile && !isTablet;
|
|
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
|
|
var isDesktop = !isPhone && !isTablet && !iOSwebview;
|
|
return {
|
|
isiPad: constant$1(isiPad),
|
|
isiPhone: constant$1(isiPhone),
|
|
isTablet: constant$1(isTablet),
|
|
isPhone: constant$1(isPhone),
|
|
isTouch: constant$1(isTouch),
|
|
isAndroid: os.isAndroid,
|
|
isiOS: os.isiOS,
|
|
isWebView: constant$1(iOSwebview),
|
|
isDesktop: constant$1(isDesktop)
|
|
};
|
|
};
|
|
|
|
var nativeSlice = Array.prototype.slice;
|
|
var nativeIndexOf = Array.prototype.indexOf;
|
|
var nativePush = Array.prototype.push;
|
|
var rawIndexOf = function (ts, t) {
|
|
return nativeIndexOf.call(ts, t);
|
|
};
|
|
var contains$1 = function (xs, x) {
|
|
return rawIndexOf(xs, x) > -1;
|
|
};
|
|
var exists = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var map$2 = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var eachr = function (xs, f) {
|
|
for (var i = xs.length - 1; i >= 0; i--) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter$2 = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var foldr = function (xs, f, acc) {
|
|
eachr(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each$1(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find$2 = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var findIndex$1 = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(i);
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind$3 = function (xs, f) {
|
|
return flatten(map$2(xs, f));
|
|
};
|
|
var forall = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
var x = xs[i];
|
|
if (pred(x, i) !== true) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
var reverse = function (xs) {
|
|
var r = nativeSlice.call(xs, 0);
|
|
r.reverse();
|
|
return r;
|
|
};
|
|
var difference = function (a1, a2) {
|
|
return filter$2(a1, function (x) {
|
|
return !contains$1(a2, x);
|
|
});
|
|
};
|
|
var pure$2 = function (x) {
|
|
return [x];
|
|
};
|
|
var sort = function (xs, comparator) {
|
|
var copy = nativeSlice.call(xs, 0);
|
|
copy.sort(comparator);
|
|
return copy;
|
|
};
|
|
var get$d = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get$d(xs, 0);
|
|
};
|
|
var findMap = function (arr, f) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var r = f(arr[i], i);
|
|
if (r.isSome()) {
|
|
return r;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var firstMatch = function (regexes, s) {
|
|
for (var i = 0; i < regexes.length; i++) {
|
|
var x = regexes[i];
|
|
if (x.test(s)) {
|
|
return x;
|
|
}
|
|
}
|
|
return undefined;
|
|
};
|
|
var find$1 = function (regexes, agent) {
|
|
var r = firstMatch(regexes, agent);
|
|
if (!r) {
|
|
return {
|
|
major: 0,
|
|
minor: 0
|
|
};
|
|
}
|
|
var group = function (i) {
|
|
return Number(agent.replace(r, '$' + i));
|
|
};
|
|
return nu$8(group(1), group(2));
|
|
};
|
|
var detect$4 = function (versionRegexes, agent) {
|
|
var cleanedAgent = String(agent).toLowerCase();
|
|
if (versionRegexes.length === 0) {
|
|
return unknown$3();
|
|
}
|
|
return find$1(versionRegexes, cleanedAgent);
|
|
};
|
|
var unknown$3 = function () {
|
|
return nu$8(0, 0);
|
|
};
|
|
var nu$8 = function (major, minor) {
|
|
return {
|
|
major: major,
|
|
minor: minor
|
|
};
|
|
};
|
|
var Version = {
|
|
nu: nu$8,
|
|
detect: detect$4,
|
|
unknown: unknown$3
|
|
};
|
|
|
|
var detectBrowser$1 = function (browsers, userAgentData) {
|
|
return findMap(userAgentData.brands, function (uaBrand) {
|
|
var lcBrand = uaBrand.brand.toLowerCase();
|
|
return find$2(browsers, function (browser) {
|
|
var _a;
|
|
return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
}).map(function (info) {
|
|
return {
|
|
current: info.name,
|
|
version: Version.nu(parseInt(uaBrand.version, 10), 0)
|
|
};
|
|
});
|
|
});
|
|
};
|
|
|
|
var detect$3 = function (candidates, userAgent) {
|
|
var agent = String(userAgent).toLowerCase();
|
|
return find$2(candidates, function (candidate) {
|
|
return candidate.search(agent);
|
|
});
|
|
};
|
|
var detectBrowser = function (browsers, userAgent) {
|
|
return detect$3(browsers, userAgent).map(function (browser) {
|
|
var version = Version.detect(browser.versionRegexes, userAgent);
|
|
return {
|
|
current: browser.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
var detectOs = function (oses, userAgent) {
|
|
return detect$3(oses, userAgent).map(function (os) {
|
|
var version = Version.detect(os.versionRegexes, userAgent);
|
|
return {
|
|
current: os.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
|
|
var checkRange = function (str, substr, start) {
|
|
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
};
|
|
var supplant = function (str, obj) {
|
|
var isStringOrNumber = function (a) {
|
|
var t = typeof a;
|
|
return t === 'string' || t === 'number';
|
|
};
|
|
return str.replace(/\$\{([^{}]*)\}/g, function (fullMatch, key) {
|
|
var value = obj[key];
|
|
return isStringOrNumber(value) ? value.toString() : fullMatch;
|
|
});
|
|
};
|
|
var contains = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
var endsWith = function (str, suffix) {
|
|
return checkRange(str, suffix, str.length - suffix.length);
|
|
};
|
|
var blank = function (r) {
|
|
return function (s) {
|
|
return s.replace(r, '');
|
|
};
|
|
};
|
|
var trim = blank(/^\s+|\s+$/g);
|
|
|
|
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
|
|
var checkContains = function (target) {
|
|
return function (uastring) {
|
|
return contains(uastring, target);
|
|
};
|
|
};
|
|
var browsers = [
|
|
{
|
|
name: 'Edge',
|
|
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
|
|
search: function (uastring) {
|
|
return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
|
|
}
|
|
},
|
|
{
|
|
name: 'Chrome',
|
|
brand: 'Chromium',
|
|
versionRegexes: [
|
|
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
|
|
normalVersionRegex
|
|
],
|
|
search: function (uastring) {
|
|
return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
|
|
}
|
|
},
|
|
{
|
|
name: 'IE',
|
|
versionRegexes: [
|
|
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*?rv:([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return contains(uastring, 'msie') || contains(uastring, 'trident');
|
|
}
|
|
},
|
|
{
|
|
name: 'Opera',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?opera\/([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: checkContains('opera')
|
|
},
|
|
{
|
|
name: 'Firefox',
|
|
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
|
|
search: checkContains('firefox')
|
|
},
|
|
{
|
|
name: 'Safari',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?cpu os ([0-9]+)_([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
|
|
}
|
|
}
|
|
];
|
|
var oses = [
|
|
{
|
|
name: 'Windows',
|
|
search: checkContains('win'),
|
|
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'iOS',
|
|
search: function (uastring) {
|
|
return contains(uastring, 'iphone') || contains(uastring, 'ipad');
|
|
},
|
|
versionRegexes: [
|
|
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*cpu os ([0-9]+)_([0-9]+).*/,
|
|
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
|
|
]
|
|
},
|
|
{
|
|
name: 'Android',
|
|
search: checkContains('android'),
|
|
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'OSX',
|
|
search: checkContains('mac os x'),
|
|
versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'Linux',
|
|
search: checkContains('linux'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'Solaris',
|
|
search: checkContains('sunos'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'FreeBSD',
|
|
search: checkContains('freebsd'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'ChromeOS',
|
|
search: checkContains('cros'),
|
|
versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
|
|
}
|
|
];
|
|
var PlatformInfo = {
|
|
browsers: constant$1(browsers),
|
|
oses: constant$1(oses)
|
|
};
|
|
|
|
var edge = 'Edge';
|
|
var chrome = 'Chrome';
|
|
var ie = 'IE';
|
|
var opera = 'Opera';
|
|
var firefox = 'Firefox';
|
|
var safari = 'Safari';
|
|
var unknown$2 = function () {
|
|
return nu$7({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu$7 = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isBrowser = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isEdge: isBrowser(edge),
|
|
isChrome: isBrowser(chrome),
|
|
isIE: isBrowser(ie),
|
|
isOpera: isBrowser(opera),
|
|
isFirefox: isBrowser(firefox),
|
|
isSafari: isBrowser(safari)
|
|
};
|
|
};
|
|
var Browser = {
|
|
unknown: unknown$2,
|
|
nu: nu$7,
|
|
edge: constant$1(edge),
|
|
chrome: constant$1(chrome),
|
|
ie: constant$1(ie),
|
|
opera: constant$1(opera),
|
|
firefox: constant$1(firefox),
|
|
safari: constant$1(safari)
|
|
};
|
|
|
|
var windows = 'Windows';
|
|
var ios = 'iOS';
|
|
var android = 'Android';
|
|
var linux = 'Linux';
|
|
var osx = 'OSX';
|
|
var solaris = 'Solaris';
|
|
var freebsd = 'FreeBSD';
|
|
var chromeos = 'ChromeOS';
|
|
var unknown$1 = function () {
|
|
return nu$6({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu$6 = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isOS = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isWindows: isOS(windows),
|
|
isiOS: isOS(ios),
|
|
isAndroid: isOS(android),
|
|
isOSX: isOS(osx),
|
|
isLinux: isOS(linux),
|
|
isSolaris: isOS(solaris),
|
|
isFreeBSD: isOS(freebsd),
|
|
isChromeOS: isOS(chromeos)
|
|
};
|
|
};
|
|
var OperatingSystem = {
|
|
unknown: unknown$1,
|
|
nu: nu$6,
|
|
windows: constant$1(windows),
|
|
ios: constant$1(ios),
|
|
android: constant$1(android),
|
|
linux: constant$1(linux),
|
|
osx: constant$1(osx),
|
|
solaris: constant$1(solaris),
|
|
freebsd: constant$1(freebsd),
|
|
chromeos: constant$1(chromeos)
|
|
};
|
|
|
|
var detect$2 = function (userAgent, userAgentDataOpt, mediaMatch) {
|
|
var browsers = PlatformInfo.browsers();
|
|
var oses = PlatformInfo.oses();
|
|
var browser = userAgentDataOpt.bind(function (userAgentData) {
|
|
return detectBrowser$1(browsers, userAgentData);
|
|
}).orThunk(function () {
|
|
return detectBrowser(browsers, userAgent);
|
|
}).fold(Browser.unknown, Browser.nu);
|
|
var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
|
|
var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
|
|
return {
|
|
browser: browser,
|
|
os: os,
|
|
deviceType: deviceType
|
|
};
|
|
};
|
|
var PlatformDetection = { detect: detect$2 };
|
|
|
|
var mediaMatch = function (query) {
|
|
return window.matchMedia(query).matches;
|
|
};
|
|
var platform$1 = cached(function () {
|
|
return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
|
|
});
|
|
var detect$1 = function () {
|
|
return platform$1();
|
|
};
|
|
|
|
var constant = constant$1;
|
|
var touchstart = constant('touchstart');
|
|
var touchmove = constant('touchmove');
|
|
var touchend = constant('touchend');
|
|
var mousedown = constant('mousedown');
|
|
var mousemove = constant('mousemove');
|
|
var mouseup = constant('mouseup');
|
|
var mouseover = constant('mouseover');
|
|
var keydown = constant('keydown');
|
|
var keyup = constant('keyup');
|
|
var input$1 = constant('input');
|
|
var change = constant('change');
|
|
var click = constant('click');
|
|
var transitionend = constant('transitionend');
|
|
var selectstart = constant('selectstart');
|
|
|
|
var prefixName = function (name) {
|
|
return constant$1('alloy.' + name);
|
|
};
|
|
var alloy = { tap: prefixName('tap') };
|
|
var focus$4 = prefixName('focus');
|
|
var postBlur = prefixName('blur.post');
|
|
var postPaste = prefixName('paste.post');
|
|
var receive$1 = prefixName('receive');
|
|
var execute$5 = prefixName('execute');
|
|
var focusItem = prefixName('focus.item');
|
|
var tap = alloy.tap;
|
|
var longpress = prefixName('longpress');
|
|
var systemInit = prefixName('system.init');
|
|
var attachedToDom = prefixName('system.attached');
|
|
var detachedFromDom = prefixName('system.detached');
|
|
var focusShifted = prefixName('focusmanager.shifted');
|
|
var highlight$1 = prefixName('highlight');
|
|
var dehighlight$1 = prefixName('dehighlight');
|
|
|
|
var emit = function (component, event) {
|
|
dispatchWith(component, component.element, event, {});
|
|
};
|
|
var emitWith = function (component, event, properties) {
|
|
dispatchWith(component, component.element, event, properties);
|
|
};
|
|
var emitExecute = function (component) {
|
|
emit(component, execute$5());
|
|
};
|
|
var dispatch = function (component, target, event) {
|
|
dispatchWith(component, target, event, {});
|
|
};
|
|
var dispatchWith = function (component, target, event, properties) {
|
|
var data = __assign({ target: target }, properties);
|
|
component.getSystem().triggerEvent(event, target, data);
|
|
};
|
|
var dispatchEvent = function (component, target, event, simulatedEvent) {
|
|
component.getSystem().triggerEvent(event, target, simulatedEvent.event);
|
|
};
|
|
var dispatchFocus = function (component, target) {
|
|
component.getSystem().triggerFocus(target, component.element);
|
|
};
|
|
|
|
var DOCUMENT = 9;
|
|
var DOCUMENT_FRAGMENT = 11;
|
|
var ELEMENT = 1;
|
|
var TEXT = 3;
|
|
|
|
var fromHtml$2 = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml$2,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var is$1 = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
var bypassSelector = function (dom) {
|
|
return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
|
|
};
|
|
var all$2 = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? [] : map$2(base.querySelectorAll(selector), SugarElement.fromDom);
|
|
};
|
|
var one = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
|
|
};
|
|
|
|
var eq = function (e1, e2) {
|
|
return e1.dom === e2.dom;
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var name$1 = function (element) {
|
|
var r = element.dom.nodeName;
|
|
return r.toLowerCase();
|
|
};
|
|
var type = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type(element) === t;
|
|
};
|
|
};
|
|
var isElement = isType(ELEMENT);
|
|
var isText = isType(TEXT);
|
|
var isDocument = isType(DOCUMENT);
|
|
var isDocumentFragment = isType(DOCUMENT_FRAGMENT);
|
|
|
|
var owner$2 = function (element) {
|
|
return SugarElement.fromDom(element.dom.ownerDocument);
|
|
};
|
|
var documentOrOwner = function (dos) {
|
|
return isDocument(dos) ? dos : owner$2(dos);
|
|
};
|
|
var defaultView = function (element) {
|
|
return SugarElement.fromDom(documentOrOwner(element).dom.defaultView);
|
|
};
|
|
var parent = function (element) {
|
|
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
};
|
|
var parents = function (element, isRoot) {
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
var dom = element.dom;
|
|
var ret = [];
|
|
while (dom.parentNode !== null && dom.parentNode !== undefined) {
|
|
var rawParent = dom.parentNode;
|
|
var p = SugarElement.fromDom(rawParent);
|
|
ret.push(p);
|
|
if (stop(p) === true) {
|
|
break;
|
|
} else {
|
|
dom = rawParent;
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
var siblings$2 = function (element) {
|
|
var filterSelf = function (elements) {
|
|
return filter$2(elements, function (x) {
|
|
return !eq(element, x);
|
|
});
|
|
};
|
|
return parent(element).map(children).map(filterSelf).getOr([]);
|
|
};
|
|
var nextSibling = function (element) {
|
|
return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
|
|
};
|
|
var children = function (element) {
|
|
return map$2(element.dom.childNodes, SugarElement.fromDom);
|
|
};
|
|
var child = function (element, index) {
|
|
var cs = element.dom.childNodes;
|
|
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
|
};
|
|
var firstChild = function (element) {
|
|
return child(element, 0);
|
|
};
|
|
|
|
var before$1 = function (marker, element) {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
v.dom.insertBefore(element.dom, marker.dom);
|
|
});
|
|
};
|
|
var after$2 = function (marker, element) {
|
|
var sibling = nextSibling(marker);
|
|
sibling.fold(function () {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
append$2(v, element);
|
|
});
|
|
}, function (v) {
|
|
before$1(v, element);
|
|
});
|
|
};
|
|
var prepend$1 = function (parent, element) {
|
|
var firstChild$1 = firstChild(parent);
|
|
firstChild$1.fold(function () {
|
|
append$2(parent, element);
|
|
}, function (v) {
|
|
parent.dom.insertBefore(element.dom, v.dom);
|
|
});
|
|
};
|
|
var append$2 = function (parent, element) {
|
|
parent.dom.appendChild(element.dom);
|
|
};
|
|
var appendAt = function (parent, element, index) {
|
|
child(parent, index).fold(function () {
|
|
append$2(parent, element);
|
|
}, function (v) {
|
|
before$1(v, element);
|
|
});
|
|
};
|
|
|
|
var append$1 = function (parent, elements) {
|
|
each$1(elements, function (x) {
|
|
append$2(parent, x);
|
|
});
|
|
};
|
|
|
|
var empty = function (element) {
|
|
element.dom.textContent = '';
|
|
each$1(children(element), function (rogue) {
|
|
remove$7(rogue);
|
|
});
|
|
};
|
|
var remove$7 = function (element) {
|
|
var dom = element.dom;
|
|
if (dom.parentNode !== null) {
|
|
dom.parentNode.removeChild(dom);
|
|
}
|
|
};
|
|
|
|
var isShadowRoot = function (dos) {
|
|
return isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
};
|
|
var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
|
|
var isSupported$1 = constant$1(supported);
|
|
var getRootNode = supported ? function (e) {
|
|
return SugarElement.fromDom(e.dom.getRootNode());
|
|
} : documentOrOwner;
|
|
var getShadowRoot = function (e) {
|
|
var r = getRootNode(e);
|
|
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
};
|
|
var getShadowHost = function (e) {
|
|
return SugarElement.fromDom(e.dom.host);
|
|
};
|
|
var getOriginalEventTarget = function (event) {
|
|
if (isSupported$1() && isNonNullable(event.target)) {
|
|
var el = SugarElement.fromDom(event.target);
|
|
if (isElement(el) && isOpenShadowHost(el)) {
|
|
if (event.composed && event.composedPath) {
|
|
var composedPath = event.composedPath();
|
|
if (composedPath) {
|
|
return head(composedPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Optional.from(event.target);
|
|
};
|
|
var isOpenShadowHost = function (element) {
|
|
return isNonNullable(element.dom.shadowRoot);
|
|
};
|
|
|
|
var inBody = function (element) {
|
|
var dom = isText(element) ? element.dom.parentNode : element.dom;
|
|
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
return false;
|
|
}
|
|
var doc = dom.ownerDocument;
|
|
return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {
|
|
return doc.body.contains(dom);
|
|
}, compose1(inBody, getShadowHost));
|
|
};
|
|
var body = function () {
|
|
return getBody(SugarElement.fromDom(document));
|
|
};
|
|
var getBody = function (doc) {
|
|
var b = doc.dom.body;
|
|
if (b === null || b === undefined) {
|
|
throw new Error('Body is not available yet');
|
|
}
|
|
return SugarElement.fromDom(b);
|
|
};
|
|
|
|
var fireDetaching = function (component) {
|
|
emit(component, detachedFromDom());
|
|
var children = component.components();
|
|
each$1(children, fireDetaching);
|
|
};
|
|
var fireAttaching = function (component) {
|
|
var children = component.components();
|
|
each$1(children, fireAttaching);
|
|
emit(component, attachedToDom());
|
|
};
|
|
var attach$1 = function (parent, child) {
|
|
append$2(parent.element, child.element);
|
|
};
|
|
var detachChildren = function (component) {
|
|
each$1(component.components(), function (childComp) {
|
|
return remove$7(childComp.element);
|
|
});
|
|
empty(component.element);
|
|
component.syncComponents();
|
|
};
|
|
var replaceChildren = function (component, newChildren) {
|
|
var subs = component.components();
|
|
detachChildren(component);
|
|
var deleted = difference(subs, newChildren);
|
|
each$1(deleted, function (comp) {
|
|
fireDetaching(comp);
|
|
component.getSystem().removeFromWorld(comp);
|
|
});
|
|
each$1(newChildren, function (childComp) {
|
|
if (!childComp.getSystem().isConnected()) {
|
|
component.getSystem().addToWorld(childComp);
|
|
attach$1(component, childComp);
|
|
if (inBody(component.element)) {
|
|
fireAttaching(childComp);
|
|
}
|
|
} else {
|
|
attach$1(component, childComp);
|
|
}
|
|
component.syncComponents();
|
|
});
|
|
};
|
|
|
|
var attach = function (parent, child) {
|
|
attachWith(parent, child, append$2);
|
|
};
|
|
var attachWith = function (parent, child, insertion) {
|
|
parent.getSystem().addToWorld(child);
|
|
insertion(parent.element, child.element);
|
|
if (inBody(parent.element)) {
|
|
fireAttaching(child);
|
|
}
|
|
parent.syncComponents();
|
|
};
|
|
var doDetach = function (component) {
|
|
fireDetaching(component);
|
|
remove$7(component.element);
|
|
component.getSystem().removeFromWorld(component);
|
|
};
|
|
var detach = function (component) {
|
|
var parent$1 = parent(component.element).bind(function (p) {
|
|
return component.getSystem().getByDom(p).toOptional();
|
|
});
|
|
doDetach(component);
|
|
parent$1.each(function (p) {
|
|
p.syncComponents();
|
|
});
|
|
};
|
|
var attachSystemAfter = function (element, guiSystem) {
|
|
attachSystemWith(element, guiSystem, after$2);
|
|
};
|
|
var attachSystemWith = function (element, guiSystem, inserter) {
|
|
inserter(element, guiSystem.element);
|
|
var children$1 = children(guiSystem.element);
|
|
each$1(children$1, function (child) {
|
|
guiSystem.getByDom(child).each(fireAttaching);
|
|
});
|
|
};
|
|
var detachSystem = function (guiSystem) {
|
|
var children$1 = children(guiSystem.element);
|
|
each$1(children$1, function (child) {
|
|
guiSystem.getByDom(child).each(fireDetaching);
|
|
});
|
|
remove$7(guiSystem.element);
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var map$1 = function (obj, f) {
|
|
return tupleMap(obj, function (x, i) {
|
|
return {
|
|
k: i,
|
|
v: f(x, i)
|
|
};
|
|
});
|
|
};
|
|
var tupleMap = function (obj, f) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
var tuple = f(x, i);
|
|
r[tuple.k] = tuple.v;
|
|
});
|
|
return r;
|
|
};
|
|
var objAcc = function (r) {
|
|
return function (x, i) {
|
|
r[i] = x;
|
|
};
|
|
};
|
|
var internalFilter = function (obj, pred, onTrue, onFalse) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
});
|
|
return r;
|
|
};
|
|
var filter$1 = function (obj, pred) {
|
|
var t = {};
|
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
return t;
|
|
};
|
|
var mapToArray = function (obj, f) {
|
|
var r = [];
|
|
each(obj, function (value, name) {
|
|
r.push(f(value, name));
|
|
});
|
|
return r;
|
|
};
|
|
var find = function (obj, pred) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
if (pred(x, i, obj)) {
|
|
return Optional.some(x);
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var values = function (obj) {
|
|
return mapToArray(obj, identity);
|
|
};
|
|
var get$c = function (obj, key) {
|
|
return has$2(obj, key) ? Optional.from(obj[key]) : Optional.none();
|
|
};
|
|
var has$2 = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
var hasNonNullableKey = function (obj, key) {
|
|
return has$2(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
};
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set$8 = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
var setAll$1 = function (element, attrs) {
|
|
var dom = element.dom;
|
|
each(attrs, function (v, k) {
|
|
rawSet(dom, k, v);
|
|
});
|
|
};
|
|
var get$b = function (element, key) {
|
|
var v = element.dom.getAttribute(key);
|
|
return v === null ? undefined : v;
|
|
};
|
|
var getOpt = function (element, key) {
|
|
return Optional.from(get$b(element, key));
|
|
};
|
|
var has$1 = function (element, key) {
|
|
var dom = element.dom;
|
|
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
|
|
};
|
|
var remove$6 = function (element, key) {
|
|
element.dom.removeAttribute(key);
|
|
};
|
|
|
|
var read$2 = function (element, attr) {
|
|
var value = get$b(element, attr);
|
|
return value === undefined || value === '' ? [] : value.split(' ');
|
|
};
|
|
var add$3 = function (element, attr, id) {
|
|
var old = read$2(element, attr);
|
|
var nu = old.concat([id]);
|
|
set$8(element, attr, nu.join(' '));
|
|
return true;
|
|
};
|
|
var remove$5 = function (element, attr, id) {
|
|
var nu = filter$2(read$2(element, attr), function (v) {
|
|
return v !== id;
|
|
});
|
|
if (nu.length > 0) {
|
|
set$8(element, attr, nu.join(' '));
|
|
} else {
|
|
remove$6(element, attr);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
var supports = function (element) {
|
|
return element.dom.classList !== undefined;
|
|
};
|
|
var get$a = function (element) {
|
|
return read$2(element, 'class');
|
|
};
|
|
var add$2 = function (element, clazz) {
|
|
return add$3(element, 'class', clazz);
|
|
};
|
|
var remove$4 = function (element, clazz) {
|
|
return remove$5(element, 'class', clazz);
|
|
};
|
|
|
|
var add$1 = function (element, clazz) {
|
|
if (supports(element)) {
|
|
element.dom.classList.add(clazz);
|
|
} else {
|
|
add$2(element, clazz);
|
|
}
|
|
};
|
|
var cleanClass = function (element) {
|
|
var classList = supports(element) ? element.dom.classList : get$a(element);
|
|
if (classList.length === 0) {
|
|
remove$6(element, 'class');
|
|
}
|
|
};
|
|
var remove$3 = function (element, clazz) {
|
|
if (supports(element)) {
|
|
var classList = element.dom.classList;
|
|
classList.remove(clazz);
|
|
} else {
|
|
remove$4(element, clazz);
|
|
}
|
|
cleanClass(element);
|
|
};
|
|
var has = function (element, clazz) {
|
|
return supports(element) && element.dom.classList.contains(clazz);
|
|
};
|
|
|
|
var swap = function (element, addCls, removeCls) {
|
|
remove$3(element, removeCls);
|
|
add$1(element, addCls);
|
|
};
|
|
var toAlpha = function (component, swapConfig, _swapState) {
|
|
swap(component.element, swapConfig.alpha, swapConfig.omega);
|
|
};
|
|
var toOmega = function (component, swapConfig, _swapState) {
|
|
swap(component.element, swapConfig.omega, swapConfig.alpha);
|
|
};
|
|
var clear$1 = function (component, swapConfig, _swapState) {
|
|
remove$3(component.element, swapConfig.alpha);
|
|
remove$3(component.element, swapConfig.omega);
|
|
};
|
|
var isAlpha = function (component, swapConfig, _swapState) {
|
|
return has(component.element, swapConfig.alpha);
|
|
};
|
|
var isOmega = function (component, swapConfig, _swapState) {
|
|
return has(component.element, swapConfig.omega);
|
|
};
|
|
|
|
var SwapApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
toAlpha: toAlpha,
|
|
toOmega: toOmega,
|
|
isAlpha: isAlpha,
|
|
isOmega: isOmega,
|
|
clear: clear$1
|
|
});
|
|
|
|
var value$2 = function (o) {
|
|
var or = function (_opt) {
|
|
return value$2(o);
|
|
};
|
|
var orThunk = function (_f) {
|
|
return value$2(o);
|
|
};
|
|
var map = function (f) {
|
|
return value$2(f(o));
|
|
};
|
|
var mapError = function (_f) {
|
|
return value$2(o);
|
|
};
|
|
var each = function (f) {
|
|
f(o);
|
|
};
|
|
var bind = function (f) {
|
|
return f(o);
|
|
};
|
|
var fold = function (_, onValue) {
|
|
return onValue(o);
|
|
};
|
|
var exists = function (f) {
|
|
return f(o);
|
|
};
|
|
var forall = function (f) {
|
|
return f(o);
|
|
};
|
|
var toOptional = function () {
|
|
return Optional.some(o);
|
|
};
|
|
return {
|
|
isValue: always,
|
|
isError: never,
|
|
getOr: constant$1(o),
|
|
getOrThunk: constant$1(o),
|
|
getOrDie: constant$1(o),
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: each,
|
|
bind: bind,
|
|
exists: exists,
|
|
forall: forall,
|
|
toOptional: toOptional
|
|
};
|
|
};
|
|
var error = function (message) {
|
|
var getOrThunk = function (f) {
|
|
return f();
|
|
};
|
|
var getOrDie = function () {
|
|
return die(String(message))();
|
|
};
|
|
var or = identity;
|
|
var orThunk = function (f) {
|
|
return f();
|
|
};
|
|
var map = function (_f) {
|
|
return error(message);
|
|
};
|
|
var mapError = function (f) {
|
|
return error(f(message));
|
|
};
|
|
var bind = function (_f) {
|
|
return error(message);
|
|
};
|
|
var fold = function (onError, _) {
|
|
return onError(message);
|
|
};
|
|
return {
|
|
isValue: never,
|
|
isError: always,
|
|
getOr: identity,
|
|
getOrThunk: getOrThunk,
|
|
getOrDie: getOrDie,
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: noop,
|
|
bind: bind,
|
|
exists: never,
|
|
forall: always,
|
|
toOptional: Optional.none
|
|
};
|
|
};
|
|
var fromOption = function (opt, err) {
|
|
return opt.fold(function () {
|
|
return error(err);
|
|
}, value$2);
|
|
};
|
|
var Result = {
|
|
value: value$2,
|
|
error: error,
|
|
fromOption: fromOption
|
|
};
|
|
|
|
var SimpleResultType;
|
|
(function (SimpleResultType) {
|
|
SimpleResultType[SimpleResultType['Error'] = 0] = 'Error';
|
|
SimpleResultType[SimpleResultType['Value'] = 1] = 'Value';
|
|
}(SimpleResultType || (SimpleResultType = {})));
|
|
var fold$1 = function (res, onError, onValue) {
|
|
return res.stype === SimpleResultType.Error ? onError(res.serror) : onValue(res.svalue);
|
|
};
|
|
var partition$1 = function (results) {
|
|
var values = [];
|
|
var errors = [];
|
|
each$1(results, function (obj) {
|
|
fold$1(obj, function (err) {
|
|
return errors.push(err);
|
|
}, function (val) {
|
|
return values.push(val);
|
|
});
|
|
});
|
|
return {
|
|
values: values,
|
|
errors: errors
|
|
};
|
|
};
|
|
var mapError = function (res, f) {
|
|
if (res.stype === SimpleResultType.Error) {
|
|
return {
|
|
stype: SimpleResultType.Error,
|
|
serror: f(res.serror)
|
|
};
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var map = function (res, f) {
|
|
if (res.stype === SimpleResultType.Value) {
|
|
return {
|
|
stype: SimpleResultType.Value,
|
|
svalue: f(res.svalue)
|
|
};
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var bind$2 = function (res, f) {
|
|
if (res.stype === SimpleResultType.Value) {
|
|
return f(res.svalue);
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var bindError = function (res, f) {
|
|
if (res.stype === SimpleResultType.Error) {
|
|
return f(res.serror);
|
|
} else {
|
|
return res;
|
|
}
|
|
};
|
|
var svalue = function (v) {
|
|
return {
|
|
stype: SimpleResultType.Value,
|
|
svalue: v
|
|
};
|
|
};
|
|
var serror = function (e) {
|
|
return {
|
|
stype: SimpleResultType.Error,
|
|
serror: e
|
|
};
|
|
};
|
|
var toResult$1 = function (res) {
|
|
return fold$1(res, Result.error, Result.value);
|
|
};
|
|
var fromResult = function (res) {
|
|
return res.fold(serror, svalue);
|
|
};
|
|
var SimpleResult = {
|
|
fromResult: fromResult,
|
|
toResult: toResult$1,
|
|
svalue: svalue,
|
|
partition: partition$1,
|
|
serror: serror,
|
|
bind: bind$2,
|
|
bindError: bindError,
|
|
map: map,
|
|
mapError: mapError,
|
|
fold: fold$1
|
|
};
|
|
|
|
var field$3 = function (key, newKey, presence, prop) {
|
|
return {
|
|
tag: 'field',
|
|
key: key,
|
|
newKey: newKey,
|
|
presence: presence,
|
|
prop: prop
|
|
};
|
|
};
|
|
var customField$1 = function (newKey, instantiator) {
|
|
return {
|
|
tag: 'custom',
|
|
newKey: newKey,
|
|
instantiator: instantiator
|
|
};
|
|
};
|
|
var fold = function (value, ifField, ifCustom) {
|
|
switch (value.tag) {
|
|
case 'field':
|
|
return ifField(value.key, value.newKey, value.presence, value.prop);
|
|
case 'custom':
|
|
return ifCustom(value.newKey, value.instantiator);
|
|
}
|
|
};
|
|
|
|
var shallow$1 = function (old, nu) {
|
|
return nu;
|
|
};
|
|
var deep = function (old, nu) {
|
|
var bothObjects = isObject(old) && isObject(nu);
|
|
return bothObjects ? deepMerge(old, nu) : nu;
|
|
};
|
|
var baseMerge = function (merger) {
|
|
return function () {
|
|
var objects = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
objects[_i] = arguments[_i];
|
|
}
|
|
if (objects.length === 0) {
|
|
throw new Error('Can\'t merge zero objects');
|
|
}
|
|
var ret = {};
|
|
for (var j = 0; j < objects.length; j++) {
|
|
var curObject = objects[j];
|
|
for (var key in curObject) {
|
|
if (has$2(curObject, key)) {
|
|
ret[key] = merger(ret[key], curObject[key]);
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
};
|
|
var deepMerge = baseMerge(deep);
|
|
var merge$1 = baseMerge(shallow$1);
|
|
|
|
var required$2 = function () {
|
|
return {
|
|
tag: 'required',
|
|
process: {}
|
|
};
|
|
};
|
|
var defaultedThunk = function (fallbackThunk) {
|
|
return {
|
|
tag: 'defaultedThunk',
|
|
process: fallbackThunk
|
|
};
|
|
};
|
|
var defaulted$1 = function (fallback) {
|
|
return defaultedThunk(constant$1(fallback));
|
|
};
|
|
var asOption = function () {
|
|
return {
|
|
tag: 'option',
|
|
process: {}
|
|
};
|
|
};
|
|
var mergeWithThunk = function (baseThunk) {
|
|
return {
|
|
tag: 'mergeWithThunk',
|
|
process: baseThunk
|
|
};
|
|
};
|
|
var mergeWith = function (base) {
|
|
return mergeWithThunk(constant$1(base));
|
|
};
|
|
|
|
var mergeValues$1 = function (values, base) {
|
|
return values.length > 0 ? SimpleResult.svalue(deepMerge(base, merge$1.apply(undefined, values))) : SimpleResult.svalue(base);
|
|
};
|
|
var mergeErrors$1 = function (errors) {
|
|
return compose(SimpleResult.serror, flatten)(errors);
|
|
};
|
|
var consolidateObj = function (objects, base) {
|
|
var partition = SimpleResult.partition(objects);
|
|
return partition.errors.length > 0 ? mergeErrors$1(partition.errors) : mergeValues$1(partition.values, base);
|
|
};
|
|
var consolidateArr = function (objects) {
|
|
var partitions = SimpleResult.partition(objects);
|
|
return partitions.errors.length > 0 ? mergeErrors$1(partitions.errors) : SimpleResult.svalue(partitions.values);
|
|
};
|
|
var ResultCombine = {
|
|
consolidateObj: consolidateObj,
|
|
consolidateArr: consolidateArr
|
|
};
|
|
|
|
var formatObj = function (input) {
|
|
return isObject(input) && keys(input).length > 100 ? ' removed due to size' : JSON.stringify(input, null, 2);
|
|
};
|
|
var formatErrors = function (errors) {
|
|
var es = errors.length > 10 ? errors.slice(0, 10).concat([{
|
|
path: [],
|
|
getErrorInfo: constant$1('... (only showing first ten failures)')
|
|
}]) : errors;
|
|
return map$2(es, function (e) {
|
|
return 'Failed path: (' + e.path.join(' > ') + ')\n' + e.getErrorInfo();
|
|
});
|
|
};
|
|
|
|
var nu$5 = function (path, getErrorInfo) {
|
|
return SimpleResult.serror([{
|
|
path: path,
|
|
getErrorInfo: getErrorInfo
|
|
}]);
|
|
};
|
|
var missingRequired = function (path, key, obj) {
|
|
return nu$5(path, function () {
|
|
return 'Could not find valid *required* value for "' + key + '" in ' + formatObj(obj);
|
|
});
|
|
};
|
|
var missingKey = function (path, key) {
|
|
return nu$5(path, function () {
|
|
return 'Choice schema did not contain choice key: "' + key + '"';
|
|
});
|
|
};
|
|
var missingBranch = function (path, branches, branch) {
|
|
return nu$5(path, function () {
|
|
return 'The chosen schema: "' + branch + '" did not exist in branches: ' + formatObj(branches);
|
|
});
|
|
};
|
|
var unsupportedFields = function (path, unsupported) {
|
|
return nu$5(path, function () {
|
|
return 'There are unsupported fields: [' + unsupported.join(', ') + '] specified';
|
|
});
|
|
};
|
|
var custom = function (path, err) {
|
|
return nu$5(path, constant$1(err));
|
|
};
|
|
|
|
var value$1 = function (validator) {
|
|
var extract = function (path, val) {
|
|
return SimpleResult.bindError(validator(val), function (err) {
|
|
return custom(path, err);
|
|
});
|
|
};
|
|
var toString = constant$1('val');
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var anyValue$1 = value$1(SimpleResult.svalue);
|
|
|
|
var requiredAccess = function (path, obj, key, bundle) {
|
|
return get$c(obj, key).fold(function () {
|
|
return missingRequired(path, key, obj);
|
|
}, bundle);
|
|
};
|
|
var fallbackAccess = function (obj, key, fallback, bundle) {
|
|
var v = get$c(obj, key).getOrThunk(function () {
|
|
return fallback(obj);
|
|
});
|
|
return bundle(v);
|
|
};
|
|
var optionAccess = function (obj, key, bundle) {
|
|
return bundle(get$c(obj, key));
|
|
};
|
|
var optionDefaultedAccess = function (obj, key, fallback, bundle) {
|
|
var opt = get$c(obj, key).map(function (val) {
|
|
return val === true ? fallback(obj) : val;
|
|
});
|
|
return bundle(opt);
|
|
};
|
|
var extractField = function (field, path, obj, key, prop) {
|
|
var bundle = function (av) {
|
|
return prop.extract(path.concat([key]), av);
|
|
};
|
|
var bundleAsOption = function (optValue) {
|
|
return optValue.fold(function () {
|
|
return SimpleResult.svalue(Optional.none());
|
|
}, function (ov) {
|
|
var result = prop.extract(path.concat([key]), ov);
|
|
return SimpleResult.map(result, Optional.some);
|
|
});
|
|
};
|
|
switch (field.tag) {
|
|
case 'required':
|
|
return requiredAccess(path, obj, key, bundle);
|
|
case 'defaultedThunk':
|
|
return fallbackAccess(obj, key, field.process, bundle);
|
|
case 'option':
|
|
return optionAccess(obj, key, bundleAsOption);
|
|
case 'defaultedOptionThunk':
|
|
return optionDefaultedAccess(obj, key, field.process, bundleAsOption);
|
|
case 'mergeWithThunk': {
|
|
return fallbackAccess(obj, key, constant$1({}), function (v) {
|
|
var result = deepMerge(field.process(obj), v);
|
|
return bundle(result);
|
|
});
|
|
}
|
|
}
|
|
};
|
|
var extractFields = function (path, obj, fields) {
|
|
var success = {};
|
|
var errors = [];
|
|
for (var _i = 0, fields_1 = fields; _i < fields_1.length; _i++) {
|
|
var field = fields_1[_i];
|
|
fold(field, function (key, newKey, presence, prop) {
|
|
var result = extractField(presence, path, obj, key, prop);
|
|
SimpleResult.fold(result, function (err) {
|
|
errors.push.apply(errors, err);
|
|
}, function (res) {
|
|
success[newKey] = res;
|
|
});
|
|
}, function (newKey, instantiator) {
|
|
success[newKey] = instantiator(obj);
|
|
});
|
|
}
|
|
return errors.length > 0 ? SimpleResult.serror(errors) : SimpleResult.svalue(success);
|
|
};
|
|
var getSetKeys = function (obj) {
|
|
return keys(filter$1(obj, isNonNullable));
|
|
};
|
|
var objOfOnly = function (fields) {
|
|
var delegate = objOf(fields);
|
|
var fieldNames = foldr(fields, function (acc, value) {
|
|
return fold(value, function (key) {
|
|
var _a;
|
|
return deepMerge(acc, (_a = {}, _a[key] = true, _a));
|
|
}, constant$1(acc));
|
|
}, {});
|
|
var extract = function (path, o) {
|
|
var keys = isBoolean(o) ? [] : getSetKeys(o);
|
|
var extra = filter$2(keys, function (k) {
|
|
return !hasNonNullableKey(fieldNames, k);
|
|
});
|
|
return extra.length === 0 ? delegate.extract(path, o) : unsupportedFields(path, extra);
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: delegate.toString
|
|
};
|
|
};
|
|
var objOf = function (values) {
|
|
var extract = function (path, o) {
|
|
return extractFields(path, o, values);
|
|
};
|
|
var toString = function () {
|
|
var fieldStrings = map$2(values, function (value) {
|
|
return fold(value, function (key, _okey, _presence, prop) {
|
|
return key + ' -> ' + prop.toString();
|
|
}, function (newKey, _instantiator) {
|
|
return 'state(' + newKey + ')';
|
|
});
|
|
});
|
|
return 'obj{\n' + fieldStrings.join('\n') + '}';
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var arrOf = function (prop) {
|
|
var extract = function (path, array) {
|
|
var results = map$2(array, function (a, i) {
|
|
return prop.extract(path.concat(['[' + i + ']']), a);
|
|
});
|
|
return ResultCombine.consolidateArr(results);
|
|
};
|
|
var toString = function () {
|
|
return 'array(' + prop.toString() + ')';
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
var setOf$1 = function (validator, prop) {
|
|
var validateKeys = function (path, keys) {
|
|
return arrOf(value$1(validator)).extract(path, keys);
|
|
};
|
|
var extract = function (path, o) {
|
|
var keys$1 = keys(o);
|
|
var validatedKeys = validateKeys(path, keys$1);
|
|
return SimpleResult.bind(validatedKeys, function (validKeys) {
|
|
var schema = map$2(validKeys, function (vk) {
|
|
return field$3(vk, vk, required$2(), prop);
|
|
});
|
|
return objOf(schema).extract(path, o);
|
|
});
|
|
};
|
|
var toString = function () {
|
|
return 'setOf(' + prop.toString() + ')';
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
|
|
var anyValue = constant$1(anyValue$1);
|
|
var typedValue = function (validator, expectedType) {
|
|
return value$1(function (a) {
|
|
var actualType = typeof a;
|
|
return validator(a) ? SimpleResult.svalue(a) : SimpleResult.serror('Expected type: ' + expectedType + ' but got: ' + actualType);
|
|
});
|
|
};
|
|
var functionProcessor = typedValue(isFunction, 'function');
|
|
|
|
var chooseFrom = function (path, input, branches, ch) {
|
|
var fields = get$c(branches, ch);
|
|
return fields.fold(function () {
|
|
return missingBranch(path, branches, ch);
|
|
}, function (vp) {
|
|
return vp.extract(path.concat(['branch: ' + ch]), input);
|
|
});
|
|
};
|
|
var choose$2 = function (key, branches) {
|
|
var extract = function (path, input) {
|
|
var choice = get$c(input, key);
|
|
return choice.fold(function () {
|
|
return missingKey(path, key);
|
|
}, function (chosen) {
|
|
return chooseFrom(path, input, branches, chosen);
|
|
});
|
|
};
|
|
var toString = function () {
|
|
return 'chooseOn(' + key + '). Possible values: ' + keys(branches);
|
|
};
|
|
return {
|
|
extract: extract,
|
|
toString: toString
|
|
};
|
|
};
|
|
|
|
var valueOf = function (validator) {
|
|
return value$1(function (v) {
|
|
return validator(v).fold(SimpleResult.serror, SimpleResult.svalue);
|
|
});
|
|
};
|
|
var setOf = function (validator, prop) {
|
|
return setOf$1(function (v) {
|
|
return SimpleResult.fromResult(validator(v));
|
|
}, prop);
|
|
};
|
|
var extractValue = function (label, prop, obj) {
|
|
var res = prop.extract([label], obj);
|
|
return SimpleResult.mapError(res, function (errs) {
|
|
return {
|
|
input: obj,
|
|
errors: errs
|
|
};
|
|
});
|
|
};
|
|
var asRaw = function (label, prop, obj) {
|
|
return SimpleResult.toResult(extractValue(label, prop, obj));
|
|
};
|
|
var getOrDie = function (extraction) {
|
|
return extraction.fold(function (errInfo) {
|
|
throw new Error(formatError(errInfo));
|
|
}, identity);
|
|
};
|
|
var asRawOrDie$1 = function (label, prop, obj) {
|
|
return getOrDie(asRaw(label, prop, obj));
|
|
};
|
|
var formatError = function (errInfo) {
|
|
return 'Errors: \n' + formatErrors(errInfo.errors).join('\n') + '\n\nInput object: ' + formatObj(errInfo.input);
|
|
};
|
|
var choose$1 = function (key, branches) {
|
|
return choose$2(key, map$1(branches, objOf));
|
|
};
|
|
|
|
var field$2 = field$3;
|
|
var customField = customField$1;
|
|
var required$1 = function (key) {
|
|
return field$2(key, key, required$2(), anyValue());
|
|
};
|
|
var requiredOf = function (key, schema) {
|
|
return field$2(key, key, required$2(), schema);
|
|
};
|
|
var forbid = function (key, message) {
|
|
return field$2(key, key, asOption(), value$1(function (_v) {
|
|
return SimpleResult.serror('The field: ' + key + ' is forbidden. ' + message);
|
|
}));
|
|
};
|
|
var requiredObjOf = function (key, objSchema) {
|
|
return field$2(key, key, required$2(), objOf(objSchema));
|
|
};
|
|
var option = function (key) {
|
|
return field$2(key, key, asOption(), anyValue());
|
|
};
|
|
var optionOf = function (key, schema) {
|
|
return field$2(key, key, asOption(), schema);
|
|
};
|
|
var optionObjOf = function (key, objSchema) {
|
|
return optionOf(key, objOf(objSchema));
|
|
};
|
|
var optionObjOfOnly = function (key, objSchema) {
|
|
return optionOf(key, objOfOnly(objSchema));
|
|
};
|
|
var defaulted = function (key, fallback) {
|
|
return field$2(key, key, defaulted$1(fallback), anyValue());
|
|
};
|
|
var defaultedOf = function (key, fallback, schema) {
|
|
return field$2(key, key, defaulted$1(fallback), schema);
|
|
};
|
|
var defaultedFunction = function (key, fallback) {
|
|
return defaultedOf(key, fallback, functionProcessor);
|
|
};
|
|
var defaultedObjOf = function (key, fallback, objSchema) {
|
|
return defaultedOf(key, fallback, objOf(objSchema));
|
|
};
|
|
|
|
var SwapSchema = [
|
|
required$1('alpha'),
|
|
required$1('omega')
|
|
];
|
|
|
|
var generate$5 = function (cases) {
|
|
if (!isArray(cases)) {
|
|
throw new Error('cases must be an array');
|
|
}
|
|
if (cases.length === 0) {
|
|
throw new Error('there must be at least one case');
|
|
}
|
|
var constructors = [];
|
|
var adt = {};
|
|
each$1(cases, function (acase, count) {
|
|
var keys$1 = keys(acase);
|
|
if (keys$1.length !== 1) {
|
|
throw new Error('one and only one name per case');
|
|
}
|
|
var key = keys$1[0];
|
|
var value = acase[key];
|
|
if (adt[key] !== undefined) {
|
|
throw new Error('duplicate key detected:' + key);
|
|
} else if (key === 'cata') {
|
|
throw new Error('cannot have a case named cata (sorry)');
|
|
} else if (!isArray(value)) {
|
|
throw new Error('case arguments must be an array');
|
|
}
|
|
constructors.push(key);
|
|
adt[key] = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var argLength = args.length;
|
|
if (argLength !== value.length) {
|
|
throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
|
|
}
|
|
var match = function (branches) {
|
|
var branchKeys = keys(branches);
|
|
if (constructors.length !== branchKeys.length) {
|
|
throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
|
|
}
|
|
var allReqd = forall(constructors, function (reqKey) {
|
|
return contains$1(branchKeys, reqKey);
|
|
});
|
|
if (!allReqd) {
|
|
throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
|
|
}
|
|
return branches[key].apply(null, args);
|
|
};
|
|
return {
|
|
fold: function () {
|
|
var foldArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
foldArgs[_i] = arguments[_i];
|
|
}
|
|
if (foldArgs.length !== cases.length) {
|
|
throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
|
|
}
|
|
var target = foldArgs[count];
|
|
return target.apply(null, args);
|
|
},
|
|
match: match,
|
|
log: function (label) {
|
|
console.log(label, {
|
|
constructors: constructors,
|
|
constructor: key,
|
|
params: args
|
|
});
|
|
}
|
|
};
|
|
};
|
|
});
|
|
return adt;
|
|
};
|
|
var Adt = { generate: generate$5 };
|
|
|
|
Adt.generate([
|
|
{
|
|
bothErrors: [
|
|
'error1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
firstError: [
|
|
'error1',
|
|
'value2'
|
|
]
|
|
},
|
|
{
|
|
secondError: [
|
|
'value1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
bothValues: [
|
|
'value1',
|
|
'value2'
|
|
]
|
|
}
|
|
]);
|
|
var partition = function (results) {
|
|
var errors = [];
|
|
var values = [];
|
|
each$1(results, function (result) {
|
|
result.fold(function (err) {
|
|
errors.push(err);
|
|
}, function (value) {
|
|
values.push(value);
|
|
});
|
|
});
|
|
return {
|
|
errors: errors,
|
|
values: values
|
|
};
|
|
};
|
|
|
|
var exclude$1 = function (obj, fields) {
|
|
var r = {};
|
|
each(obj, function (v, k) {
|
|
if (!contains$1(fields, k)) {
|
|
r[k] = v;
|
|
}
|
|
});
|
|
return r;
|
|
};
|
|
|
|
var wrap$1 = function (key, value) {
|
|
var _a;
|
|
return _a = {}, _a[key] = value, _a;
|
|
};
|
|
var wrapAll$1 = function (keyvalues) {
|
|
var r = {};
|
|
each$1(keyvalues, function (kv) {
|
|
r[kv.key] = kv.value;
|
|
});
|
|
return r;
|
|
};
|
|
|
|
var exclude = function (obj, fields) {
|
|
return exclude$1(obj, fields);
|
|
};
|
|
var wrap = function (key, value) {
|
|
return wrap$1(key, value);
|
|
};
|
|
var wrapAll = function (keyvalues) {
|
|
return wrapAll$1(keyvalues);
|
|
};
|
|
var mergeValues = function (values, base) {
|
|
return values.length === 0 ? Result.value(base) : Result.value(deepMerge(base, merge$1.apply(undefined, values)));
|
|
};
|
|
var mergeErrors = function (errors) {
|
|
return Result.error(flatten(errors));
|
|
};
|
|
var consolidate = function (objs, base) {
|
|
var partitions = partition(objs);
|
|
return partitions.errors.length > 0 ? mergeErrors(partitions.errors) : mergeValues(partitions.values, base);
|
|
};
|
|
|
|
var is = function (lhs, rhs, comparator) {
|
|
if (comparator === void 0) {
|
|
comparator = tripleEquals;
|
|
}
|
|
return lhs.exists(function (left) {
|
|
return comparator(left, rhs);
|
|
});
|
|
};
|
|
var cat = function (arr) {
|
|
var r = [];
|
|
var push = function (x) {
|
|
r.push(x);
|
|
};
|
|
for (var i = 0; i < arr.length; i++) {
|
|
arr[i].each(push);
|
|
}
|
|
return r;
|
|
};
|
|
var sequence = function (arr) {
|
|
var r = [];
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var x = arr[i];
|
|
if (x.isSome()) {
|
|
r.push(x.getOrDie());
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
return Optional.some(r);
|
|
};
|
|
var lift2 = function (oa, ob, f) {
|
|
return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
|
|
};
|
|
var someIf = function (b, a) {
|
|
return b ? Optional.some(a) : Optional.none();
|
|
};
|
|
|
|
var ensureIsRoot = function (isRoot) {
|
|
return isFunction(isRoot) ? isRoot : never;
|
|
};
|
|
var ancestor$2 = function (scope, transform, isRoot) {
|
|
var element = scope.dom;
|
|
var stop = ensureIsRoot(isRoot);
|
|
while (element.parentNode) {
|
|
element = element.parentNode;
|
|
var el = SugarElement.fromDom(element);
|
|
var transformed = transform(el);
|
|
if (transformed.isSome()) {
|
|
return transformed;
|
|
} else if (stop(el)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var closest$3 = function (scope, transform, isRoot) {
|
|
var current = transform(scope);
|
|
var stop = ensureIsRoot(isRoot);
|
|
return current.orThunk(function () {
|
|
return stop(scope) ? Optional.none() : ancestor$2(scope, transform, stop);
|
|
});
|
|
};
|
|
|
|
var isSource = function (component, simulatedEvent) {
|
|
return eq(component.element, simulatedEvent.event.target);
|
|
};
|
|
|
|
var defaultEventHandler = {
|
|
can: always,
|
|
abort: never,
|
|
run: noop
|
|
};
|
|
var nu$4 = function (parts) {
|
|
if (!hasNonNullableKey(parts, 'can') && !hasNonNullableKey(parts, 'abort') && !hasNonNullableKey(parts, 'run')) {
|
|
throw new Error('EventHandler defined by: ' + JSON.stringify(parts, null, 2) + ' does not have can, abort, or run!');
|
|
}
|
|
return __assign(__assign({}, defaultEventHandler), parts);
|
|
};
|
|
var all$1 = function (handlers, f) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return foldl(handlers, function (acc, handler) {
|
|
return acc && f(handler).apply(undefined, args);
|
|
}, true);
|
|
};
|
|
};
|
|
var any = function (handlers, f) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return foldl(handlers, function (acc, handler) {
|
|
return acc || f(handler).apply(undefined, args);
|
|
}, false);
|
|
};
|
|
};
|
|
var read$1 = function (handler) {
|
|
return isFunction(handler) ? {
|
|
can: always,
|
|
abort: never,
|
|
run: handler
|
|
} : handler;
|
|
};
|
|
var fuse$1 = function (handlers) {
|
|
var can = all$1(handlers, function (handler) {
|
|
return handler.can;
|
|
});
|
|
var abort = any(handlers, function (handler) {
|
|
return handler.abort;
|
|
});
|
|
var run = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
each$1(handlers, function (handler) {
|
|
handler.run.apply(undefined, args);
|
|
});
|
|
};
|
|
return {
|
|
can: can,
|
|
abort: abort,
|
|
run: run
|
|
};
|
|
};
|
|
|
|
var derive$3 = function (configs) {
|
|
return wrapAll(configs);
|
|
};
|
|
var abort = function (name, predicate) {
|
|
return {
|
|
key: name,
|
|
value: nu$4({ abort: predicate })
|
|
};
|
|
};
|
|
var can = function (name, predicate) {
|
|
return {
|
|
key: name,
|
|
value: nu$4({ can: predicate })
|
|
};
|
|
};
|
|
var run = function (name, handler) {
|
|
return {
|
|
key: name,
|
|
value: nu$4({ run: handler })
|
|
};
|
|
};
|
|
var runActionExtra = function (name, action, extra) {
|
|
return {
|
|
key: name,
|
|
value: nu$4({
|
|
run: function (component, simulatedEvent) {
|
|
action.apply(undefined, [
|
|
component,
|
|
simulatedEvent
|
|
].concat(extra));
|
|
}
|
|
})
|
|
};
|
|
};
|
|
var runOnName = function (name) {
|
|
return function (handler) {
|
|
return run(name, handler);
|
|
};
|
|
};
|
|
var runOnSourceName = function (name) {
|
|
return function (handler) {
|
|
return {
|
|
key: name,
|
|
value: nu$4({
|
|
run: function (component, simulatedEvent) {
|
|
if (isSource(component, simulatedEvent)) {
|
|
handler(component, simulatedEvent);
|
|
}
|
|
}
|
|
})
|
|
};
|
|
};
|
|
};
|
|
var redirectToUid = function (name, uid) {
|
|
return run(name, function (component, simulatedEvent) {
|
|
component.getSystem().getByUid(uid).each(function (redirectee) {
|
|
dispatchEvent(redirectee, redirectee.element, name, simulatedEvent);
|
|
});
|
|
});
|
|
};
|
|
var redirectToPart = function (name, detail, partName) {
|
|
var uid = detail.partUids[partName];
|
|
return redirectToUid(name, uid);
|
|
};
|
|
var cutter = function (name) {
|
|
return run(name, function (component, simulatedEvent) {
|
|
simulatedEvent.cut();
|
|
});
|
|
};
|
|
var stopper = function (name) {
|
|
return run(name, function (component, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
});
|
|
};
|
|
var runOnSource = function (name, f) {
|
|
return runOnSourceName(name)(f);
|
|
};
|
|
var runOnAttached = runOnSourceName(attachedToDom());
|
|
var runOnDetached = runOnSourceName(detachedFromDom());
|
|
var runOnInit = runOnSourceName(systemInit());
|
|
var runOnExecute = runOnName(execute$5());
|
|
|
|
var markAsBehaviourApi = function (f, apiName, apiFunction) {
|
|
var delegate = apiFunction.toString();
|
|
var endIndex = delegate.indexOf(')') + 1;
|
|
var openBracketIndex = delegate.indexOf('(');
|
|
var parameters = delegate.substring(openBracketIndex + 1, endIndex - 1).split(/,\s*/);
|
|
f.toFunctionAnnotation = function () {
|
|
return {
|
|
name: apiName,
|
|
parameters: cleanParameters(parameters.slice(0, 1).concat(parameters.slice(3)))
|
|
};
|
|
};
|
|
return f;
|
|
};
|
|
var cleanParameters = function (parameters) {
|
|
return map$2(parameters, function (p) {
|
|
return endsWith(p, '/*') ? p.substring(0, p.length - '/*'.length) : p;
|
|
});
|
|
};
|
|
var markAsExtraApi = function (f, extraName) {
|
|
var delegate = f.toString();
|
|
var endIndex = delegate.indexOf(')') + 1;
|
|
var openBracketIndex = delegate.indexOf('(');
|
|
var parameters = delegate.substring(openBracketIndex + 1, endIndex - 1).split(/,\s*/);
|
|
f.toFunctionAnnotation = function () {
|
|
return {
|
|
name: extraName,
|
|
parameters: cleanParameters(parameters)
|
|
};
|
|
};
|
|
return f;
|
|
};
|
|
var markAsSketchApi = function (f, apiFunction) {
|
|
var delegate = apiFunction.toString();
|
|
var endIndex = delegate.indexOf(')') + 1;
|
|
var openBracketIndex = delegate.indexOf('(');
|
|
var parameters = delegate.substring(openBracketIndex + 1, endIndex - 1).split(/,\s*/);
|
|
f.toFunctionAnnotation = function () {
|
|
return {
|
|
name: 'OVERRIDE',
|
|
parameters: cleanParameters(parameters.slice(1))
|
|
};
|
|
};
|
|
return f;
|
|
};
|
|
|
|
var nu$3 = function (s) {
|
|
return {
|
|
classes: isUndefined(s.classes) ? [] : s.classes,
|
|
attributes: isUndefined(s.attributes) ? {} : s.attributes,
|
|
styles: isUndefined(s.styles) ? {} : s.styles
|
|
};
|
|
};
|
|
var merge = function (defnA, mod) {
|
|
return __assign(__assign({}, defnA), {
|
|
attributes: __assign(__assign({}, defnA.attributes), mod.attributes),
|
|
styles: __assign(__assign({}, defnA.styles), mod.styles),
|
|
classes: defnA.classes.concat(mod.classes)
|
|
});
|
|
};
|
|
|
|
var executeEvent = function (bConfig, bState, executor) {
|
|
return runOnExecute(function (component) {
|
|
executor(component, bConfig, bState);
|
|
});
|
|
};
|
|
var loadEvent = function (bConfig, bState, f) {
|
|
return runOnInit(function (component, _simulatedEvent) {
|
|
f(component, bConfig, bState);
|
|
});
|
|
};
|
|
var create$6 = function (schema, name, active, apis, extra, state) {
|
|
var configSchema = objOfOnly(schema);
|
|
var schemaSchema = optionObjOf(name, [optionObjOfOnly('config', schema)]);
|
|
return doCreate(configSchema, schemaSchema, name, active, apis, extra, state);
|
|
};
|
|
var createModes$1 = function (modes, name, active, apis, extra, state) {
|
|
var configSchema = modes;
|
|
var schemaSchema = optionObjOf(name, [optionOf('config', modes)]);
|
|
return doCreate(configSchema, schemaSchema, name, active, apis, extra, state);
|
|
};
|
|
var wrapApi = function (bName, apiFunction, apiName) {
|
|
var f = function (component) {
|
|
var rest = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
rest[_i - 1] = arguments[_i];
|
|
}
|
|
var args = [component].concat(rest);
|
|
return component.config({ name: constant$1(bName) }).fold(function () {
|
|
throw new Error('We could not find any behaviour configuration for: ' + bName + '. Using API: ' + apiName);
|
|
}, function (info) {
|
|
var rest = Array.prototype.slice.call(args, 1);
|
|
return apiFunction.apply(undefined, [
|
|
component,
|
|
info.config,
|
|
info.state
|
|
].concat(rest));
|
|
});
|
|
};
|
|
return markAsBehaviourApi(f, apiName, apiFunction);
|
|
};
|
|
var revokeBehaviour = function (name) {
|
|
return {
|
|
key: name,
|
|
value: undefined
|
|
};
|
|
};
|
|
var doCreate = function (configSchema, schemaSchema, name, active, apis, extra, state) {
|
|
var getConfig = function (info) {
|
|
return hasNonNullableKey(info, name) ? info[name]() : Optional.none();
|
|
};
|
|
var wrappedApis = map$1(apis, function (apiF, apiName) {
|
|
return wrapApi(name, apiF, apiName);
|
|
});
|
|
var wrappedExtra = map$1(extra, function (extraF, extraName) {
|
|
return markAsExtraApi(extraF, extraName);
|
|
});
|
|
var me = __assign(__assign(__assign({}, wrappedExtra), wrappedApis), {
|
|
revoke: curry(revokeBehaviour, name),
|
|
config: function (spec) {
|
|
var prepared = asRawOrDie$1(name + '-config', configSchema, spec);
|
|
return {
|
|
key: name,
|
|
value: {
|
|
config: prepared,
|
|
me: me,
|
|
configAsRaw: cached(function () {
|
|
return asRawOrDie$1(name + '-config', configSchema, spec);
|
|
}),
|
|
initialConfig: spec,
|
|
state: state
|
|
}
|
|
};
|
|
},
|
|
schema: constant$1(schemaSchema),
|
|
exhibit: function (info, base) {
|
|
return lift2(getConfig(info), get$c(active, 'exhibit'), function (behaviourInfo, exhibitor) {
|
|
return exhibitor(base, behaviourInfo.config, behaviourInfo.state);
|
|
}).getOrThunk(function () {
|
|
return nu$3({});
|
|
});
|
|
},
|
|
name: constant$1(name),
|
|
handlers: function (info) {
|
|
return getConfig(info).map(function (behaviourInfo) {
|
|
var getEvents = get$c(active, 'events').getOr(function () {
|
|
return {};
|
|
});
|
|
return getEvents(behaviourInfo.config, behaviourInfo.state);
|
|
}).getOr({});
|
|
}
|
|
});
|
|
return me;
|
|
};
|
|
|
|
var NoState = {
|
|
init: function () {
|
|
return nu$2({ readState: constant$1('No State required') });
|
|
}
|
|
};
|
|
var nu$2 = function (spec) {
|
|
return spec;
|
|
};
|
|
|
|
var derive$2 = function (capabilities) {
|
|
return wrapAll(capabilities);
|
|
};
|
|
var simpleSchema = objOfOnly([
|
|
required$1('fields'),
|
|
required$1('name'),
|
|
defaulted('active', {}),
|
|
defaulted('apis', {}),
|
|
defaulted('state', NoState),
|
|
defaulted('extra', {})
|
|
]);
|
|
var create$5 = function (data) {
|
|
var value = asRawOrDie$1('Creating behaviour: ' + data.name, simpleSchema, data);
|
|
return create$6(value.fields, value.name, value.active, value.apis, value.extra, value.state);
|
|
};
|
|
var modeSchema = objOfOnly([
|
|
required$1('branchKey'),
|
|
required$1('branches'),
|
|
required$1('name'),
|
|
defaulted('active', {}),
|
|
defaulted('apis', {}),
|
|
defaulted('state', NoState),
|
|
defaulted('extra', {})
|
|
]);
|
|
var createModes = function (data) {
|
|
var value = asRawOrDie$1('Creating behaviour: ' + data.name, modeSchema, data);
|
|
return createModes$1(choose$1(value.branchKey, value.branches), value.name, value.active, value.apis, value.extra, value.state);
|
|
};
|
|
var revoke = constant$1(undefined);
|
|
|
|
var Swapping = create$5({
|
|
fields: SwapSchema,
|
|
name: 'swapping',
|
|
apis: SwapApis
|
|
});
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var getDocument = function () {
|
|
return SugarElement.fromDom(document);
|
|
};
|
|
|
|
var focus$3 = function (element) {
|
|
return element.dom.focus();
|
|
};
|
|
var blur$1 = function (element) {
|
|
return element.dom.blur();
|
|
};
|
|
var hasFocus = function (element) {
|
|
var root = getRootNode(element).dom;
|
|
return element.dom === root.activeElement;
|
|
};
|
|
var active = function (root) {
|
|
if (root === void 0) {
|
|
root = getDocument();
|
|
}
|
|
return Optional.from(root.dom.activeElement).map(SugarElement.fromDom);
|
|
};
|
|
var search = function (element) {
|
|
return active(getRootNode(element)).filter(function (e) {
|
|
return element.dom.contains(e.dom);
|
|
});
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.ThemeManager');
|
|
|
|
var openLink = function (target) {
|
|
var link = document.createElement('a');
|
|
link.target = '_blank';
|
|
link.href = target.href;
|
|
link.rel = 'noreferrer noopener';
|
|
var nuEvt = document.createEvent('MouseEvents');
|
|
nuEvt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
document.body.appendChild(link);
|
|
link.dispatchEvent(nuEvt);
|
|
document.body.removeChild(link);
|
|
};
|
|
|
|
var DefaultStyleFormats = [
|
|
{
|
|
title: 'Headings',
|
|
items: [
|
|
{
|
|
title: 'Heading 1',
|
|
format: 'h1'
|
|
},
|
|
{
|
|
title: 'Heading 2',
|
|
format: 'h2'
|
|
},
|
|
{
|
|
title: 'Heading 3',
|
|
format: 'h3'
|
|
},
|
|
{
|
|
title: 'Heading 4',
|
|
format: 'h4'
|
|
},
|
|
{
|
|
title: 'Heading 5',
|
|
format: 'h5'
|
|
},
|
|
{
|
|
title: 'Heading 6',
|
|
format: 'h6'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
title: 'Inline',
|
|
items: [
|
|
{
|
|
title: 'Bold',
|
|
icon: 'bold',
|
|
format: 'bold'
|
|
},
|
|
{
|
|
title: 'Italic',
|
|
icon: 'italic',
|
|
format: 'italic'
|
|
},
|
|
{
|
|
title: 'Underline',
|
|
icon: 'underline',
|
|
format: 'underline'
|
|
},
|
|
{
|
|
title: 'Strikethrough',
|
|
icon: 'strikethrough',
|
|
format: 'strikethrough'
|
|
},
|
|
{
|
|
title: 'Superscript',
|
|
icon: 'superscript',
|
|
format: 'superscript'
|
|
},
|
|
{
|
|
title: 'Subscript',
|
|
icon: 'subscript',
|
|
format: 'subscript'
|
|
},
|
|
{
|
|
title: 'Code',
|
|
icon: 'code',
|
|
format: 'code'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
title: 'Blocks',
|
|
items: [
|
|
{
|
|
title: 'Paragraph',
|
|
format: 'p'
|
|
},
|
|
{
|
|
title: 'Blockquote',
|
|
format: 'blockquote'
|
|
},
|
|
{
|
|
title: 'Div',
|
|
format: 'div'
|
|
},
|
|
{
|
|
title: 'Pre',
|
|
format: 'pre'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
title: 'Alignment',
|
|
items: [
|
|
{
|
|
title: 'Left',
|
|
icon: 'alignleft',
|
|
format: 'alignleft'
|
|
},
|
|
{
|
|
title: 'Center',
|
|
icon: 'aligncenter',
|
|
format: 'aligncenter'
|
|
},
|
|
{
|
|
title: 'Right',
|
|
icon: 'alignright',
|
|
format: 'alignright'
|
|
},
|
|
{
|
|
title: 'Justify',
|
|
icon: 'alignjustify',
|
|
format: 'alignjustify'
|
|
}
|
|
]
|
|
}
|
|
];
|
|
|
|
var defaults = [
|
|
'undo',
|
|
'bold',
|
|
'italic',
|
|
'link',
|
|
'image',
|
|
'bullist',
|
|
'styleselect'
|
|
];
|
|
var isSkinDisabled = function (editor) {
|
|
return editor.getParam('skin') === false;
|
|
};
|
|
var readOnlyOnInit = function (_editor) {
|
|
return false;
|
|
};
|
|
var getToolbar = function (editor) {
|
|
return editor.getParam('toolbar', defaults, 'array');
|
|
};
|
|
var getStyleFormats = function (editor) {
|
|
return editor.getParam('style_formats', DefaultStyleFormats, 'array');
|
|
};
|
|
var getSkinUrl = function (editor) {
|
|
return editor.getParam('skin_url');
|
|
};
|
|
|
|
var formatChanged = 'formatChanged';
|
|
var orientationChanged = 'orientationChanged';
|
|
var dropupDismissed = 'dropupDismissed';
|
|
|
|
var fromHtml$1 = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
return children(SugarElement.fromDom(div));
|
|
};
|
|
|
|
var get$9 = function (element) {
|
|
return element.dom.innerHTML;
|
|
};
|
|
var set$7 = function (element, content) {
|
|
var owner = owner$2(element);
|
|
var docDom = owner.dom;
|
|
var fragment = SugarElement.fromDom(docDom.createDocumentFragment());
|
|
var contentElements = fromHtml$1(content, docDom);
|
|
append$1(fragment, contentElements);
|
|
empty(element);
|
|
append$2(element, fragment);
|
|
};
|
|
var getOuter = function (element) {
|
|
var container = SugarElement.fromTag('div');
|
|
var clone = SugarElement.fromDom(element.dom.cloneNode(true));
|
|
append$2(container, clone);
|
|
return get$9(container);
|
|
};
|
|
|
|
var clone = function (original, isDeep) {
|
|
return SugarElement.fromDom(original.dom.cloneNode(isDeep));
|
|
};
|
|
var shallow = function (original) {
|
|
return clone(original, false);
|
|
};
|
|
|
|
var getHtml = function (element) {
|
|
if (isShadowRoot(element)) {
|
|
return '#shadow-root';
|
|
} else {
|
|
var clone = shallow(element);
|
|
return getOuter(clone);
|
|
}
|
|
};
|
|
|
|
var element = function (elem) {
|
|
return getHtml(elem);
|
|
};
|
|
|
|
var chooseChannels = function (channels, message) {
|
|
return message.universal ? channels : filter$2(channels, function (ch) {
|
|
return contains$1(message.channels, ch);
|
|
});
|
|
};
|
|
var events$a = function (receiveConfig) {
|
|
return derive$3([run(receive$1(), function (component, message) {
|
|
var channelMap = receiveConfig.channels;
|
|
var channels = keys(channelMap);
|
|
var receivingData = message;
|
|
var targetChannels = chooseChannels(channels, receivingData);
|
|
each$1(targetChannels, function (ch) {
|
|
var channelInfo = channelMap[ch];
|
|
var channelSchema = channelInfo.schema;
|
|
var data = asRawOrDie$1('channel[' + ch + '] data\nReceiver: ' + element(component.element), channelSchema, receivingData.data);
|
|
channelInfo.onReceive(component, data);
|
|
});
|
|
})]);
|
|
};
|
|
|
|
var ActiveReceiving = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$a
|
|
});
|
|
|
|
var unknown = 'unknown';
|
|
var EventConfiguration;
|
|
(function (EventConfiguration) {
|
|
EventConfiguration[EventConfiguration['STOP'] = 0] = 'STOP';
|
|
EventConfiguration[EventConfiguration['NORMAL'] = 1] = 'NORMAL';
|
|
EventConfiguration[EventConfiguration['LOGGING'] = 2] = 'LOGGING';
|
|
}(EventConfiguration || (EventConfiguration = {})));
|
|
var eventConfig = Cell({});
|
|
var makeEventLogger = function (eventName, initialTarget) {
|
|
var sequence = [];
|
|
var startTime = new Date().getTime();
|
|
return {
|
|
logEventCut: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'cut',
|
|
target: target,
|
|
purpose: purpose
|
|
});
|
|
},
|
|
logEventStopped: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'stopped',
|
|
target: target,
|
|
purpose: purpose
|
|
});
|
|
},
|
|
logNoParent: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'no-parent',
|
|
target: target,
|
|
purpose: purpose
|
|
});
|
|
},
|
|
logEventNoHandlers: function (_name, target) {
|
|
sequence.push({
|
|
outcome: 'no-handlers-left',
|
|
target: target
|
|
});
|
|
},
|
|
logEventResponse: function (_name, target, purpose) {
|
|
sequence.push({
|
|
outcome: 'response',
|
|
purpose: purpose,
|
|
target: target
|
|
});
|
|
},
|
|
write: function () {
|
|
var finishTime = new Date().getTime();
|
|
if (contains$1([
|
|
'mousemove',
|
|
'mouseover',
|
|
'mouseout',
|
|
systemInit()
|
|
], eventName)) {
|
|
return;
|
|
}
|
|
console.log(eventName, {
|
|
event: eventName,
|
|
time: finishTime - startTime,
|
|
target: initialTarget.dom,
|
|
sequence: map$2(sequence, function (s) {
|
|
if (!contains$1([
|
|
'cut',
|
|
'stopped',
|
|
'response'
|
|
], s.outcome)) {
|
|
return s.outcome;
|
|
} else {
|
|
return '{' + s.purpose + '} ' + s.outcome + ' at (' + element(s.target) + ')';
|
|
}
|
|
})
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var processEvent = function (eventName, initialTarget, f) {
|
|
var status = get$c(eventConfig.get(), eventName).orThunk(function () {
|
|
var patterns = keys(eventConfig.get());
|
|
return findMap(patterns, function (p) {
|
|
return eventName.indexOf(p) > -1 ? Optional.some(eventConfig.get()[p]) : Optional.none();
|
|
});
|
|
}).getOr(EventConfiguration.NORMAL);
|
|
switch (status) {
|
|
case EventConfiguration.NORMAL:
|
|
return f(noLogger());
|
|
case EventConfiguration.LOGGING: {
|
|
var logger = makeEventLogger(eventName, initialTarget);
|
|
var output = f(logger);
|
|
logger.write();
|
|
return output;
|
|
}
|
|
case EventConfiguration.STOP:
|
|
return true;
|
|
}
|
|
};
|
|
var path = [
|
|
'alloy/data/Fields',
|
|
'alloy/debugging/Debugging'
|
|
];
|
|
var getTrace = function () {
|
|
var err = new Error();
|
|
if (err.stack !== undefined) {
|
|
var lines = err.stack.split('\n');
|
|
return find$2(lines, function (line) {
|
|
return line.indexOf('alloy') > 0 && !exists(path, function (p) {
|
|
return line.indexOf(p) > -1;
|
|
});
|
|
}).getOr(unknown);
|
|
} else {
|
|
return unknown;
|
|
}
|
|
};
|
|
var ignoreEvent = {
|
|
logEventCut: noop,
|
|
logEventStopped: noop,
|
|
logNoParent: noop,
|
|
logEventNoHandlers: noop,
|
|
logEventResponse: noop,
|
|
write: noop
|
|
};
|
|
var monitorEvent = function (eventName, initialTarget, f) {
|
|
return processEvent(eventName, initialTarget, f);
|
|
};
|
|
var noLogger = constant$1(ignoreEvent);
|
|
|
|
var menuFields = constant$1([
|
|
required$1('menu'),
|
|
required$1('selectedMenu')
|
|
]);
|
|
var itemFields = constant$1([
|
|
required$1('item'),
|
|
required$1('selectedItem')
|
|
]);
|
|
constant$1(objOf(itemFields().concat(menuFields())));
|
|
var itemSchema$1 = constant$1(objOf(itemFields()));
|
|
|
|
var _initSize = requiredObjOf('initSize', [
|
|
required$1('numColumns'),
|
|
required$1('numRows')
|
|
]);
|
|
var itemMarkers = function () {
|
|
return requiredOf('markers', itemSchema$1());
|
|
};
|
|
var tieredMenuMarkers = function () {
|
|
return requiredObjOf('markers', [required$1('backgroundMenu')].concat(menuFields()).concat(itemFields()));
|
|
};
|
|
var markers = function (required) {
|
|
return requiredObjOf('markers', map$2(required, required$1));
|
|
};
|
|
var onPresenceHandler = function (label, fieldName, presence) {
|
|
getTrace();
|
|
return field$2(fieldName, fieldName, presence, valueOf(function (f) {
|
|
return Result.value(function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return f.apply(undefined, args);
|
|
});
|
|
}));
|
|
};
|
|
var onHandler = function (fieldName) {
|
|
return onPresenceHandler('onHandler', fieldName, defaulted$1(noop));
|
|
};
|
|
var onKeyboardHandler = function (fieldName) {
|
|
return onPresenceHandler('onKeyboardHandler', fieldName, defaulted$1(Optional.none));
|
|
};
|
|
var onStrictHandler = function (fieldName) {
|
|
return onPresenceHandler('onHandler', fieldName, required$2());
|
|
};
|
|
var onStrictKeyboardHandler = function (fieldName) {
|
|
return onPresenceHandler('onKeyboardHandler', fieldName, required$2());
|
|
};
|
|
var output = function (name, value) {
|
|
return customField(name, constant$1(value));
|
|
};
|
|
var snapshot = function (name) {
|
|
return customField(name, identity);
|
|
};
|
|
var initSize = constant$1(_initSize);
|
|
|
|
var ReceivingSchema = [requiredOf('channels', setOf(Result.value, objOfOnly([
|
|
onStrictHandler('onReceive'),
|
|
defaulted('schema', anyValue())
|
|
])))];
|
|
|
|
var Receiving = create$5({
|
|
fields: ReceivingSchema,
|
|
name: 'receiving',
|
|
active: ActiveReceiving
|
|
});
|
|
|
|
var SetupBehaviourCellState = function (initialState) {
|
|
var init = function () {
|
|
var cell = Cell(initialState);
|
|
var get = function () {
|
|
return cell.get();
|
|
};
|
|
var set = function (newState) {
|
|
return cell.set(newState);
|
|
};
|
|
var clear = function () {
|
|
return cell.set(initialState);
|
|
};
|
|
var readState = function () {
|
|
return cell.get();
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set,
|
|
clear: clear,
|
|
readState: readState
|
|
};
|
|
};
|
|
return { init: init };
|
|
};
|
|
|
|
var updateAriaState = function (component, toggleConfig, toggleState) {
|
|
var ariaInfo = toggleConfig.aria;
|
|
ariaInfo.update(component, ariaInfo, toggleState.get());
|
|
};
|
|
var updateClass = function (component, toggleConfig, toggleState) {
|
|
toggleConfig.toggleClass.each(function (toggleClass) {
|
|
if (toggleState.get()) {
|
|
add$1(component.element, toggleClass);
|
|
} else {
|
|
remove$3(component.element, toggleClass);
|
|
}
|
|
});
|
|
};
|
|
var toggle = function (component, toggleConfig, toggleState) {
|
|
set$6(component, toggleConfig, toggleState, !toggleState.get());
|
|
};
|
|
var on$1 = function (component, toggleConfig, toggleState) {
|
|
toggleState.set(true);
|
|
updateClass(component, toggleConfig, toggleState);
|
|
updateAriaState(component, toggleConfig, toggleState);
|
|
};
|
|
var off = function (component, toggleConfig, toggleState) {
|
|
toggleState.set(false);
|
|
updateClass(component, toggleConfig, toggleState);
|
|
updateAriaState(component, toggleConfig, toggleState);
|
|
};
|
|
var set$6 = function (component, toggleConfig, toggleState, state) {
|
|
var action = state ? on$1 : off;
|
|
action(component, toggleConfig, toggleState);
|
|
};
|
|
var isOn = function (component, toggleConfig, toggleState) {
|
|
return toggleState.get();
|
|
};
|
|
var onLoad$5 = function (component, toggleConfig, toggleState) {
|
|
set$6(component, toggleConfig, toggleState, toggleConfig.selected);
|
|
};
|
|
|
|
var ToggleApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
onLoad: onLoad$5,
|
|
toggle: toggle,
|
|
isOn: isOn,
|
|
on: on$1,
|
|
off: off,
|
|
set: set$6
|
|
});
|
|
|
|
var exhibit$5 = function () {
|
|
return nu$3({});
|
|
};
|
|
var events$9 = function (toggleConfig, toggleState) {
|
|
var execute = executeEvent(toggleConfig, toggleState, toggle);
|
|
var load = loadEvent(toggleConfig, toggleState, onLoad$5);
|
|
return derive$3(flatten([
|
|
toggleConfig.toggleOnExecute ? [execute] : [],
|
|
[load]
|
|
]));
|
|
};
|
|
|
|
var ActiveToggle = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$5,
|
|
events: events$9
|
|
});
|
|
|
|
var updatePressed = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-pressed', status);
|
|
if (ariaInfo.syncWithExpanded) {
|
|
updateExpanded(component, ariaInfo, status);
|
|
}
|
|
};
|
|
var updateSelected = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-selected', status);
|
|
};
|
|
var updateChecked = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-checked', status);
|
|
};
|
|
var updateExpanded = function (component, ariaInfo, status) {
|
|
set$8(component.element, 'aria-expanded', status);
|
|
};
|
|
|
|
var ToggleSchema = [
|
|
defaulted('selected', false),
|
|
option('toggleClass'),
|
|
defaulted('toggleOnExecute', true),
|
|
defaultedOf('aria', { mode: 'none' }, choose$1('mode', {
|
|
pressed: [
|
|
defaulted('syncWithExpanded', false),
|
|
output('update', updatePressed)
|
|
],
|
|
checked: [output('update', updateChecked)],
|
|
expanded: [output('update', updateExpanded)],
|
|
selected: [output('update', updateSelected)],
|
|
none: [output('update', noop)]
|
|
}))
|
|
];
|
|
|
|
var Toggling = create$5({
|
|
fields: ToggleSchema,
|
|
name: 'toggling',
|
|
active: ActiveToggle,
|
|
apis: ToggleApis,
|
|
state: SetupBehaviourCellState(false)
|
|
});
|
|
|
|
var format = function (command, update) {
|
|
return Receiving.config({
|
|
channels: wrap(formatChanged, {
|
|
onReceive: function (button, data) {
|
|
if (data.command === command) {
|
|
update(button, data.state);
|
|
}
|
|
}
|
|
})
|
|
});
|
|
};
|
|
var orientation = function (onReceive) {
|
|
return Receiving.config({ channels: wrap(orientationChanged, { onReceive: onReceive }) });
|
|
};
|
|
var receive = function (channel, onReceive) {
|
|
return {
|
|
key: channel,
|
|
value: { onReceive: onReceive }
|
|
};
|
|
};
|
|
|
|
var prefix$2 = 'tinymce-mobile';
|
|
var resolve = function (p) {
|
|
return prefix$2 + '-' + p;
|
|
};
|
|
|
|
var pointerEvents = function () {
|
|
var onClick = function (component, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
emitExecute(component);
|
|
};
|
|
return [
|
|
run(click(), onClick),
|
|
run(tap(), onClick),
|
|
cutter(touchstart()),
|
|
cutter(mousedown())
|
|
];
|
|
};
|
|
var events$8 = function (optAction) {
|
|
var executeHandler = function (action) {
|
|
return runOnExecute(function (component, simulatedEvent) {
|
|
action(component);
|
|
simulatedEvent.stop();
|
|
});
|
|
};
|
|
return derive$3(flatten([
|
|
optAction.map(executeHandler).toArray(),
|
|
pointerEvents()
|
|
]));
|
|
};
|
|
|
|
var focus$2 = function (component, focusConfig) {
|
|
if (!focusConfig.ignore) {
|
|
focus$3(component.element);
|
|
focusConfig.onFocus(component);
|
|
}
|
|
};
|
|
var blur = function (component, focusConfig) {
|
|
if (!focusConfig.ignore) {
|
|
blur$1(component.element);
|
|
}
|
|
};
|
|
var isFocused = function (component) {
|
|
return hasFocus(component.element);
|
|
};
|
|
|
|
var FocusApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
focus: focus$2,
|
|
blur: blur,
|
|
isFocused: isFocused
|
|
});
|
|
|
|
var exhibit$4 = function (base, focusConfig) {
|
|
var mod = focusConfig.ignore ? {} : { attributes: { tabindex: '-1' } };
|
|
return nu$3(mod);
|
|
};
|
|
var events$7 = function (focusConfig) {
|
|
return derive$3([run(focus$4(), function (component, simulatedEvent) {
|
|
focus$2(component, focusConfig);
|
|
simulatedEvent.stop();
|
|
})].concat(focusConfig.stopMousedown ? [run(mousedown(), function (_, simulatedEvent) {
|
|
simulatedEvent.event.prevent();
|
|
})] : []));
|
|
};
|
|
|
|
var ActiveFocus = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$4,
|
|
events: events$7
|
|
});
|
|
|
|
var FocusSchema = [
|
|
onHandler('onFocus'),
|
|
defaulted('stopMousedown', false),
|
|
defaulted('ignore', false)
|
|
];
|
|
|
|
var Focusing = create$5({
|
|
fields: FocusSchema,
|
|
name: 'focusing',
|
|
active: ActiveFocus,
|
|
apis: FocusApis
|
|
});
|
|
|
|
var isSupported = function (dom) {
|
|
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
};
|
|
|
|
var internalSet = function (dom, property, value) {
|
|
if (!isString(value)) {
|
|
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('CSS value must be a string: ' + value);
|
|
}
|
|
if (isSupported(dom)) {
|
|
dom.style.setProperty(property, value);
|
|
}
|
|
};
|
|
var internalRemove = function (dom, property) {
|
|
if (isSupported(dom)) {
|
|
dom.style.removeProperty(property);
|
|
}
|
|
};
|
|
var set$5 = function (element, property, value) {
|
|
var dom = element.dom;
|
|
internalSet(dom, property, value);
|
|
};
|
|
var setAll = function (element, css) {
|
|
var dom = element.dom;
|
|
each(css, function (v, k) {
|
|
internalSet(dom, k, v);
|
|
});
|
|
};
|
|
var get$8 = function (element, property) {
|
|
var dom = element.dom;
|
|
var styles = window.getComputedStyle(dom);
|
|
var r = styles.getPropertyValue(property);
|
|
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
|
|
};
|
|
var getUnsafeProperty = function (dom, property) {
|
|
return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
|
|
};
|
|
var getRaw = function (element, property) {
|
|
var dom = element.dom;
|
|
var raw = getUnsafeProperty(dom, property);
|
|
return Optional.from(raw).filter(function (r) {
|
|
return r.length > 0;
|
|
});
|
|
};
|
|
var remove$2 = function (element, property) {
|
|
var dom = element.dom;
|
|
internalRemove(dom, property);
|
|
if (is(getOpt(element, 'style').map(trim), '')) {
|
|
remove$6(element, 'style');
|
|
}
|
|
};
|
|
var reflow = function (e) {
|
|
return e.dom.offsetWidth;
|
|
};
|
|
|
|
var Dimension = function (name, getOffset) {
|
|
var set = function (element, h) {
|
|
if (!isNumber(h) && !h.match(/^[0-9]+$/)) {
|
|
throw new Error(name + '.set accepts only positive integer values. Value was ' + h);
|
|
}
|
|
var dom = element.dom;
|
|
if (isSupported(dom)) {
|
|
dom.style[name] = h + 'px';
|
|
}
|
|
};
|
|
var get = function (element) {
|
|
var r = getOffset(element);
|
|
if (r <= 0 || r === null) {
|
|
var css = get$8(element, name);
|
|
return parseFloat(css) || 0;
|
|
}
|
|
return r;
|
|
};
|
|
var getOuter = get;
|
|
var aggregate = function (element, properties) {
|
|
return foldl(properties, function (acc, property) {
|
|
var val = get$8(element, property);
|
|
var value = val === undefined ? 0 : parseInt(val, 10);
|
|
return isNaN(value) ? acc : acc + value;
|
|
}, 0);
|
|
};
|
|
var max = function (element, value, properties) {
|
|
var cumulativeInclusions = aggregate(element, properties);
|
|
var absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;
|
|
return absoluteMax;
|
|
};
|
|
return {
|
|
set: set,
|
|
get: get,
|
|
getOuter: getOuter,
|
|
aggregate: aggregate,
|
|
max: max
|
|
};
|
|
};
|
|
|
|
var api$3 = Dimension('height', function (element) {
|
|
var dom = element.dom;
|
|
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
|
|
});
|
|
var get$7 = function (element) {
|
|
return api$3.get(element);
|
|
};
|
|
|
|
var ancestors$1 = function (scope, predicate, isRoot) {
|
|
return filter$2(parents(scope, isRoot), predicate);
|
|
};
|
|
var siblings$1 = function (scope, predicate) {
|
|
return filter$2(siblings$2(scope), predicate);
|
|
};
|
|
|
|
var all = function (selector) {
|
|
return all$2(selector);
|
|
};
|
|
var ancestors = function (scope, selector, isRoot) {
|
|
return ancestors$1(scope, function (e) {
|
|
return is$1(e, selector);
|
|
}, isRoot);
|
|
};
|
|
var siblings = function (scope, selector) {
|
|
return siblings$1(scope, function (e) {
|
|
return is$1(e, selector);
|
|
});
|
|
};
|
|
var descendants = function (scope, selector) {
|
|
return all$2(selector, scope);
|
|
};
|
|
|
|
function ClosestOrAncestor (is, ancestor, scope, a, isRoot) {
|
|
if (is(scope, a)) {
|
|
return Optional.some(scope);
|
|
} else if (isFunction(isRoot) && isRoot(scope)) {
|
|
return Optional.none();
|
|
} else {
|
|
return ancestor(scope, a, isRoot);
|
|
}
|
|
}
|
|
|
|
var ancestor$1 = function (scope, predicate, isRoot) {
|
|
var element = scope.dom;
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
while (element.parentNode) {
|
|
element = element.parentNode;
|
|
var el = SugarElement.fromDom(element);
|
|
if (predicate(el)) {
|
|
return Optional.some(el);
|
|
} else if (stop(el)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var closest$2 = function (scope, predicate, isRoot) {
|
|
var is = function (s, test) {
|
|
return test(s);
|
|
};
|
|
return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
|
|
};
|
|
var descendant$1 = function (scope, predicate) {
|
|
var descend = function (node) {
|
|
for (var i = 0; i < node.childNodes.length; i++) {
|
|
var child_1 = SugarElement.fromDom(node.childNodes[i]);
|
|
if (predicate(child_1)) {
|
|
return Optional.some(child_1);
|
|
}
|
|
var res = descend(node.childNodes[i]);
|
|
if (res.isSome()) {
|
|
return res;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
return descend(scope.dom);
|
|
};
|
|
|
|
var first$1 = function (selector) {
|
|
return one(selector);
|
|
};
|
|
var ancestor = function (scope, selector, isRoot) {
|
|
return ancestor$1(scope, function (e) {
|
|
return is$1(e, selector);
|
|
}, isRoot);
|
|
};
|
|
var descendant = function (scope, selector) {
|
|
return one(selector, scope);
|
|
};
|
|
var closest$1 = function (scope, selector, isRoot) {
|
|
var is = function (element, selector) {
|
|
return is$1(element, selector);
|
|
};
|
|
return ClosestOrAncestor(is, ancestor, scope, selector, isRoot);
|
|
};
|
|
|
|
var BACKSPACE = [8];
|
|
var TAB = [9];
|
|
var ENTER = [13];
|
|
var ESCAPE = [27];
|
|
var SPACE = [32];
|
|
var LEFT = [37];
|
|
var UP = [38];
|
|
var RIGHT = [39];
|
|
var DOWN = [40];
|
|
|
|
var cyclePrev = function (values, index, predicate) {
|
|
var before = reverse(values.slice(0, index));
|
|
var after = reverse(values.slice(index + 1));
|
|
return find$2(before.concat(after), predicate);
|
|
};
|
|
var tryPrev = function (values, index, predicate) {
|
|
var before = reverse(values.slice(0, index));
|
|
return find$2(before, predicate);
|
|
};
|
|
var cycleNext = function (values, index, predicate) {
|
|
var before = values.slice(0, index);
|
|
var after = values.slice(index + 1);
|
|
return find$2(after.concat(before), predicate);
|
|
};
|
|
var tryNext = function (values, index, predicate) {
|
|
var after = values.slice(index + 1);
|
|
return find$2(after, predicate);
|
|
};
|
|
|
|
var inSet = function (keys) {
|
|
return function (event) {
|
|
var raw = event.raw;
|
|
return contains$1(keys, raw.which);
|
|
};
|
|
};
|
|
var and = function (preds) {
|
|
return function (event) {
|
|
return forall(preds, function (pred) {
|
|
return pred(event);
|
|
});
|
|
};
|
|
};
|
|
var isShift = function (event) {
|
|
var raw = event.raw;
|
|
return raw.shiftKey === true;
|
|
};
|
|
var isControl = function (event) {
|
|
var raw = event.raw;
|
|
return raw.ctrlKey === true;
|
|
};
|
|
var isNotShift = not(isShift);
|
|
|
|
var rule = function (matches, action) {
|
|
return {
|
|
matches: matches,
|
|
classification: action
|
|
};
|
|
};
|
|
var choose = function (transitions, event) {
|
|
var transition = find$2(transitions, function (t) {
|
|
return t.matches(event);
|
|
});
|
|
return transition.map(function (t) {
|
|
return t.classification;
|
|
});
|
|
};
|
|
|
|
var cycleBy = function (value, delta, min, max) {
|
|
var r = value + delta;
|
|
if (r > max) {
|
|
return min;
|
|
} else if (r < min) {
|
|
return max;
|
|
} else {
|
|
return r;
|
|
}
|
|
};
|
|
var clamp = function (value, min, max) {
|
|
return Math.min(Math.max(value, min), max);
|
|
};
|
|
|
|
var dehighlightAllExcept = function (component, hConfig, hState, skip) {
|
|
var highlighted = descendants(component.element, '.' + hConfig.highlightClass);
|
|
each$1(highlighted, function (h) {
|
|
if (!exists(skip, function (skipComp) {
|
|
return skipComp.element === h;
|
|
})) {
|
|
remove$3(h, hConfig.highlightClass);
|
|
component.getSystem().getByDom(h).each(function (target) {
|
|
hConfig.onDehighlight(component, target);
|
|
emit(target, dehighlight$1());
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var dehighlightAll = function (component, hConfig, hState) {
|
|
return dehighlightAllExcept(component, hConfig, hState, []);
|
|
};
|
|
var dehighlight = function (component, hConfig, hState, target) {
|
|
if (isHighlighted(component, hConfig, hState, target)) {
|
|
remove$3(target.element, hConfig.highlightClass);
|
|
hConfig.onDehighlight(component, target);
|
|
emit(target, dehighlight$1());
|
|
}
|
|
};
|
|
var highlight = function (component, hConfig, hState, target) {
|
|
dehighlightAllExcept(component, hConfig, hState, [target]);
|
|
if (!isHighlighted(component, hConfig, hState, target)) {
|
|
add$1(target.element, hConfig.highlightClass);
|
|
hConfig.onHighlight(component, target);
|
|
emit(target, highlight$1());
|
|
}
|
|
};
|
|
var highlightFirst = function (component, hConfig, hState) {
|
|
getFirst(component, hConfig).each(function (firstComp) {
|
|
highlight(component, hConfig, hState, firstComp);
|
|
});
|
|
};
|
|
var highlightLast = function (component, hConfig, hState) {
|
|
getLast(component, hConfig).each(function (lastComp) {
|
|
highlight(component, hConfig, hState, lastComp);
|
|
});
|
|
};
|
|
var highlightAt = function (component, hConfig, hState, index) {
|
|
getByIndex(component, hConfig, hState, index).fold(function (err) {
|
|
throw err;
|
|
}, function (firstComp) {
|
|
highlight(component, hConfig, hState, firstComp);
|
|
});
|
|
};
|
|
var highlightBy = function (component, hConfig, hState, predicate) {
|
|
var candidates = getCandidates(component, hConfig);
|
|
var targetComp = find$2(candidates, predicate);
|
|
targetComp.each(function (c) {
|
|
highlight(component, hConfig, hState, c);
|
|
});
|
|
};
|
|
var isHighlighted = function (component, hConfig, hState, queryTarget) {
|
|
return has(queryTarget.element, hConfig.highlightClass);
|
|
};
|
|
var getHighlighted = function (component, hConfig, _hState) {
|
|
return descendant(component.element, '.' + hConfig.highlightClass).bind(function (e) {
|
|
return component.getSystem().getByDom(e).toOptional();
|
|
});
|
|
};
|
|
var getByIndex = function (component, hConfig, hState, index) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
return Optional.from(items[index]).fold(function () {
|
|
return Result.error(new Error('No element found with index ' + index));
|
|
}, component.getSystem().getByDom);
|
|
};
|
|
var getFirst = function (component, hConfig, _hState) {
|
|
return descendant(component.element, '.' + hConfig.itemClass).bind(function (e) {
|
|
return component.getSystem().getByDom(e).toOptional();
|
|
});
|
|
};
|
|
var getLast = function (component, hConfig, _hState) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
var last = items.length > 0 ? Optional.some(items[items.length - 1]) : Optional.none();
|
|
return last.bind(function (c) {
|
|
return component.getSystem().getByDom(c).toOptional();
|
|
});
|
|
};
|
|
var getDelta = function (component, hConfig, hState, delta) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
var current = findIndex$1(items, function (item) {
|
|
return has(item, hConfig.highlightClass);
|
|
});
|
|
return current.bind(function (selected) {
|
|
var dest = cycleBy(selected, delta, 0, items.length - 1);
|
|
return component.getSystem().getByDom(items[dest]).toOptional();
|
|
});
|
|
};
|
|
var getPrevious = function (component, hConfig, hState) {
|
|
return getDelta(component, hConfig, hState, -1);
|
|
};
|
|
var getNext = function (component, hConfig, hState) {
|
|
return getDelta(component, hConfig, hState, +1);
|
|
};
|
|
var getCandidates = function (component, hConfig, _hState) {
|
|
var items = descendants(component.element, '.' + hConfig.itemClass);
|
|
return cat(map$2(items, function (i) {
|
|
return component.getSystem().getByDom(i).toOptional();
|
|
}));
|
|
};
|
|
|
|
var HighlightApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
dehighlightAll: dehighlightAll,
|
|
dehighlight: dehighlight,
|
|
highlight: highlight,
|
|
highlightFirst: highlightFirst,
|
|
highlightLast: highlightLast,
|
|
highlightAt: highlightAt,
|
|
highlightBy: highlightBy,
|
|
isHighlighted: isHighlighted,
|
|
getHighlighted: getHighlighted,
|
|
getFirst: getFirst,
|
|
getLast: getLast,
|
|
getPrevious: getPrevious,
|
|
getNext: getNext,
|
|
getCandidates: getCandidates
|
|
});
|
|
|
|
var HighlightSchema = [
|
|
required$1('highlightClass'),
|
|
required$1('itemClass'),
|
|
onHandler('onHighlight'),
|
|
onHandler('onDehighlight')
|
|
];
|
|
|
|
var Highlighting = create$5({
|
|
fields: HighlightSchema,
|
|
name: 'highlighting',
|
|
apis: HighlightApis
|
|
});
|
|
|
|
var reportFocusShifting = function (component, prevFocus, newFocus) {
|
|
var noChange = prevFocus.exists(function (p) {
|
|
return newFocus.exists(function (n) {
|
|
return eq(n, p);
|
|
});
|
|
});
|
|
if (!noChange) {
|
|
emitWith(component, focusShifted(), {
|
|
prevFocus: prevFocus,
|
|
newFocus: newFocus
|
|
});
|
|
}
|
|
};
|
|
var dom$2 = function () {
|
|
var get = function (component) {
|
|
return search(component.element);
|
|
};
|
|
var set = function (component, focusee) {
|
|
var prevFocus = get(component);
|
|
component.getSystem().triggerFocus(focusee, component.element);
|
|
var newFocus = get(component);
|
|
reportFocusShifting(component, prevFocus, newFocus);
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var highlights = function () {
|
|
var get = function (component) {
|
|
return Highlighting.getHighlighted(component).map(function (item) {
|
|
return item.element;
|
|
});
|
|
};
|
|
var set = function (component, element) {
|
|
var prevFocus = get(component);
|
|
component.getSystem().getByDom(element).fold(noop, function (item) {
|
|
Highlighting.highlight(component, item);
|
|
});
|
|
var newFocus = get(component);
|
|
reportFocusShifting(component, prevFocus, newFocus);
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var FocusInsideModes;
|
|
(function (FocusInsideModes) {
|
|
FocusInsideModes['OnFocusMode'] = 'onFocus';
|
|
FocusInsideModes['OnEnterOrSpaceMode'] = 'onEnterOrSpace';
|
|
FocusInsideModes['OnApiMode'] = 'onApi';
|
|
}(FocusInsideModes || (FocusInsideModes = {})));
|
|
|
|
var typical = function (infoSchema, stateInit, getKeydownRules, getKeyupRules, optFocusIn) {
|
|
var schema = function () {
|
|
return infoSchema.concat([
|
|
defaulted('focusManager', dom$2()),
|
|
defaultedOf('focusInside', 'onFocus', valueOf(function (val) {
|
|
return contains$1([
|
|
'onFocus',
|
|
'onEnterOrSpace',
|
|
'onApi'
|
|
], val) ? Result.value(val) : Result.error('Invalid value for focusInside');
|
|
})),
|
|
output('handler', me),
|
|
output('state', stateInit),
|
|
output('sendFocusIn', optFocusIn)
|
|
]);
|
|
};
|
|
var processKey = function (component, simulatedEvent, getRules, keyingConfig, keyingState) {
|
|
var rules = getRules(component, simulatedEvent, keyingConfig, keyingState);
|
|
return choose(rules, simulatedEvent.event).bind(function (rule) {
|
|
return rule(component, simulatedEvent, keyingConfig, keyingState);
|
|
});
|
|
};
|
|
var toEvents = function (keyingConfig, keyingState) {
|
|
var onFocusHandler = keyingConfig.focusInside !== FocusInsideModes.OnFocusMode ? Optional.none() : optFocusIn(keyingConfig).map(function (focusIn) {
|
|
return run(focus$4(), function (component, simulatedEvent) {
|
|
focusIn(component, keyingConfig, keyingState);
|
|
simulatedEvent.stop();
|
|
});
|
|
});
|
|
var tryGoInsideComponent = function (component, simulatedEvent) {
|
|
var isEnterOrSpace = inSet(SPACE.concat(ENTER))(simulatedEvent.event);
|
|
if (keyingConfig.focusInside === FocusInsideModes.OnEnterOrSpaceMode && isEnterOrSpace && isSource(component, simulatedEvent)) {
|
|
optFocusIn(keyingConfig).each(function (focusIn) {
|
|
focusIn(component, keyingConfig, keyingState);
|
|
simulatedEvent.stop();
|
|
});
|
|
}
|
|
};
|
|
var keyboardEvents = [
|
|
run(keydown(), function (component, simulatedEvent) {
|
|
processKey(component, simulatedEvent, getKeydownRules, keyingConfig, keyingState).fold(function () {
|
|
tryGoInsideComponent(component, simulatedEvent);
|
|
}, function (_) {
|
|
simulatedEvent.stop();
|
|
});
|
|
}),
|
|
run(keyup(), function (component, simulatedEvent) {
|
|
processKey(component, simulatedEvent, getKeyupRules, keyingConfig, keyingState).each(function (_) {
|
|
simulatedEvent.stop();
|
|
});
|
|
})
|
|
];
|
|
return derive$3(onFocusHandler.toArray().concat(keyboardEvents));
|
|
};
|
|
var me = {
|
|
schema: schema,
|
|
processKey: processKey,
|
|
toEvents: toEvents
|
|
};
|
|
return me;
|
|
};
|
|
|
|
var create$4 = function (cyclicField) {
|
|
var schema = [
|
|
option('onEscape'),
|
|
option('onEnter'),
|
|
defaulted('selector', '[data-alloy-tabstop="true"]:not(:disabled)'),
|
|
defaulted('firstTabstop', 0),
|
|
defaulted('useTabstopAt', always),
|
|
option('visibilitySelector')
|
|
].concat([cyclicField]);
|
|
var isVisible = function (tabbingConfig, element) {
|
|
var target = tabbingConfig.visibilitySelector.bind(function (sel) {
|
|
return closest$1(element, sel);
|
|
}).getOr(element);
|
|
return get$7(target) > 0;
|
|
};
|
|
var findInitial = function (component, tabbingConfig) {
|
|
var tabstops = descendants(component.element, tabbingConfig.selector);
|
|
var visibles = filter$2(tabstops, function (elem) {
|
|
return isVisible(tabbingConfig, elem);
|
|
});
|
|
return Optional.from(visibles[tabbingConfig.firstTabstop]);
|
|
};
|
|
var findCurrent = function (component, tabbingConfig) {
|
|
return tabbingConfig.focusManager.get(component).bind(function (elem) {
|
|
return closest$1(elem, tabbingConfig.selector);
|
|
});
|
|
};
|
|
var isTabstop = function (tabbingConfig, element) {
|
|
return isVisible(tabbingConfig, element) && tabbingConfig.useTabstopAt(element);
|
|
};
|
|
var focusIn = function (component, tabbingConfig, _tabbingState) {
|
|
findInitial(component, tabbingConfig).each(function (target) {
|
|
tabbingConfig.focusManager.set(component, target);
|
|
});
|
|
};
|
|
var goFromTabstop = function (component, tabstops, stopIndex, tabbingConfig, cycle) {
|
|
return cycle(tabstops, stopIndex, function (elem) {
|
|
return isTabstop(tabbingConfig, elem);
|
|
}).fold(function () {
|
|
return tabbingConfig.cyclic ? Optional.some(true) : Optional.none();
|
|
}, function (target) {
|
|
tabbingConfig.focusManager.set(component, target);
|
|
return Optional.some(true);
|
|
});
|
|
};
|
|
var go = function (component, _simulatedEvent, tabbingConfig, cycle) {
|
|
var tabstops = descendants(component.element, tabbingConfig.selector);
|
|
return findCurrent(component, tabbingConfig).bind(function (tabstop) {
|
|
var optStopIndex = findIndex$1(tabstops, curry(eq, tabstop));
|
|
return optStopIndex.bind(function (stopIndex) {
|
|
return goFromTabstop(component, tabstops, stopIndex, tabbingConfig, cycle);
|
|
});
|
|
});
|
|
};
|
|
var goBackwards = function (component, simulatedEvent, tabbingConfig) {
|
|
var navigate = tabbingConfig.cyclic ? cyclePrev : tryPrev;
|
|
return go(component, simulatedEvent, tabbingConfig, navigate);
|
|
};
|
|
var goForwards = function (component, simulatedEvent, tabbingConfig) {
|
|
var navigate = tabbingConfig.cyclic ? cycleNext : tryNext;
|
|
return go(component, simulatedEvent, tabbingConfig, navigate);
|
|
};
|
|
var execute = function (component, simulatedEvent, tabbingConfig) {
|
|
return tabbingConfig.onEnter.bind(function (f) {
|
|
return f(component, simulatedEvent);
|
|
});
|
|
};
|
|
var exit = function (component, simulatedEvent, tabbingConfig) {
|
|
return tabbingConfig.onEscape.bind(function (f) {
|
|
return f(component, simulatedEvent);
|
|
});
|
|
};
|
|
var getKeydownRules = constant$1([
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), goBackwards),
|
|
rule(inSet(TAB), goForwards),
|
|
rule(inSet(ESCAPE), exit),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(ENTER)
|
|
]), execute)
|
|
]);
|
|
var getKeyupRules = constant$1([]);
|
|
return typical(schema, NoState.init, getKeydownRules, getKeyupRules, function () {
|
|
return Optional.some(focusIn);
|
|
});
|
|
};
|
|
|
|
var AcyclicType = create$4(customField('cyclic', never));
|
|
|
|
var CyclicType = create$4(customField('cyclic', always));
|
|
|
|
var inside = function (target) {
|
|
return name$1(target) === 'input' && get$b(target, 'type') !== 'radio' || name$1(target) === 'textarea';
|
|
};
|
|
|
|
var doDefaultExecute = function (component, _simulatedEvent, focused) {
|
|
dispatch(component, focused, execute$5());
|
|
return Optional.some(true);
|
|
};
|
|
var defaultExecute = function (component, simulatedEvent, focused) {
|
|
var isComplex = inside(focused) && inSet(SPACE)(simulatedEvent.event);
|
|
return isComplex ? Optional.none() : doDefaultExecute(component, simulatedEvent, focused);
|
|
};
|
|
var stopEventForFirefox = function (_component, _simulatedEvent) {
|
|
return Optional.some(true);
|
|
};
|
|
|
|
var schema$f = [
|
|
defaulted('execute', defaultExecute),
|
|
defaulted('useSpace', false),
|
|
defaulted('useEnter', true),
|
|
defaulted('useControlEnter', false),
|
|
defaulted('useDown', false)
|
|
];
|
|
var execute$4 = function (component, simulatedEvent, executeConfig) {
|
|
return executeConfig.execute(component, simulatedEvent, component.element);
|
|
};
|
|
var getKeydownRules$5 = function (component, _simulatedEvent, executeConfig, _executeState) {
|
|
var spaceExec = executeConfig.useSpace && !inside(component.element) ? SPACE : [];
|
|
var enterExec = executeConfig.useEnter ? ENTER : [];
|
|
var downExec = executeConfig.useDown ? DOWN : [];
|
|
var execKeys = spaceExec.concat(enterExec).concat(downExec);
|
|
return [rule(inSet(execKeys), execute$4)].concat(executeConfig.useControlEnter ? [rule(and([
|
|
isControl,
|
|
inSet(ENTER)
|
|
]), execute$4)] : []);
|
|
};
|
|
var getKeyupRules$5 = function (component, _simulatedEvent, executeConfig, _executeState) {
|
|
return executeConfig.useSpace && !inside(component.element) ? [rule(inSet(SPACE), stopEventForFirefox)] : [];
|
|
};
|
|
var ExecutionType = typical(schema$f, NoState.init, getKeydownRules$5, getKeyupRules$5, function () {
|
|
return Optional.none();
|
|
});
|
|
|
|
var singleton$1 = function (doRevoke) {
|
|
var subject = Cell(Optional.none());
|
|
var revoke = function () {
|
|
return subject.get().each(doRevoke);
|
|
};
|
|
var clear = function () {
|
|
revoke();
|
|
subject.set(Optional.none());
|
|
};
|
|
var isSet = function () {
|
|
return subject.get().isSome();
|
|
};
|
|
var get = function () {
|
|
return subject.get();
|
|
};
|
|
var set = function (s) {
|
|
revoke();
|
|
subject.set(Optional.some(s));
|
|
};
|
|
return {
|
|
clear: clear,
|
|
isSet: isSet,
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var destroyable = function () {
|
|
return singleton$1(function (s) {
|
|
return s.destroy();
|
|
});
|
|
};
|
|
var api$2 = function () {
|
|
var subject = destroyable();
|
|
var run = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { run: run });
|
|
};
|
|
var value = function () {
|
|
var subject = singleton$1(noop);
|
|
var on = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { on: on });
|
|
};
|
|
|
|
var flatgrid$1 = function () {
|
|
var dimensions = value();
|
|
var setGridSize = function (numRows, numColumns) {
|
|
dimensions.set({
|
|
numRows: numRows,
|
|
numColumns: numColumns
|
|
});
|
|
};
|
|
var getNumRows = function () {
|
|
return dimensions.get().map(function (d) {
|
|
return d.numRows;
|
|
});
|
|
};
|
|
var getNumColumns = function () {
|
|
return dimensions.get().map(function (d) {
|
|
return d.numColumns;
|
|
});
|
|
};
|
|
return nu$2({
|
|
readState: function () {
|
|
return dimensions.get().map(function (d) {
|
|
return {
|
|
numRows: String(d.numRows),
|
|
numColumns: String(d.numColumns)
|
|
};
|
|
}).getOr({
|
|
numRows: '?',
|
|
numColumns: '?'
|
|
});
|
|
},
|
|
setGridSize: setGridSize,
|
|
getNumRows: getNumRows,
|
|
getNumColumns: getNumColumns
|
|
});
|
|
};
|
|
var init$5 = function (spec) {
|
|
return spec.state(spec);
|
|
};
|
|
|
|
var KeyingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
flatgrid: flatgrid$1,
|
|
init: init$5
|
|
});
|
|
|
|
var onDirection = function (isLtr, isRtl) {
|
|
return function (element) {
|
|
return getDirection(element) === 'rtl' ? isRtl : isLtr;
|
|
};
|
|
};
|
|
var getDirection = function (element) {
|
|
return get$8(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
|
|
};
|
|
|
|
var useH = function (movement) {
|
|
return function (component, simulatedEvent, config, state) {
|
|
var move = movement(component.element);
|
|
return use(move, component, simulatedEvent, config, state);
|
|
};
|
|
};
|
|
var west = function (moveLeft, moveRight) {
|
|
var movement = onDirection(moveLeft, moveRight);
|
|
return useH(movement);
|
|
};
|
|
var east = function (moveLeft, moveRight) {
|
|
var movement = onDirection(moveRight, moveLeft);
|
|
return useH(movement);
|
|
};
|
|
var useV = function (move) {
|
|
return function (component, simulatedEvent, config, state) {
|
|
return use(move, component, simulatedEvent, config, state);
|
|
};
|
|
};
|
|
var use = function (move, component, simulatedEvent, config, state) {
|
|
var outcome = config.focusManager.get(component).bind(function (focused) {
|
|
return move(component.element, focused, config, state);
|
|
});
|
|
return outcome.map(function (newFocus) {
|
|
config.focusManager.set(component, newFocus);
|
|
return true;
|
|
});
|
|
};
|
|
var north = useV;
|
|
var south = useV;
|
|
var move$1 = useV;
|
|
|
|
var isHidden = function (dom) {
|
|
return dom.offsetWidth <= 0 && dom.offsetHeight <= 0;
|
|
};
|
|
var isVisible = function (element) {
|
|
return !isHidden(element.dom);
|
|
};
|
|
|
|
var locate = function (candidates, predicate) {
|
|
return findIndex$1(candidates, predicate).map(function (index) {
|
|
return {
|
|
index: index,
|
|
candidates: candidates
|
|
};
|
|
});
|
|
};
|
|
|
|
var locateVisible = function (container, current, selector) {
|
|
var predicate = function (x) {
|
|
return eq(x, current);
|
|
};
|
|
var candidates = descendants(container, selector);
|
|
var visible = filter$2(candidates, isVisible);
|
|
return locate(visible, predicate);
|
|
};
|
|
var findIndex = function (elements, target) {
|
|
return findIndex$1(elements, function (elem) {
|
|
return eq(target, elem);
|
|
});
|
|
};
|
|
|
|
var withGrid = function (values, index, numCols, f) {
|
|
var oldRow = Math.floor(index / numCols);
|
|
var oldColumn = index % numCols;
|
|
return f(oldRow, oldColumn).bind(function (address) {
|
|
var newIndex = address.row * numCols + address.column;
|
|
return newIndex >= 0 && newIndex < values.length ? Optional.some(values[newIndex]) : Optional.none();
|
|
});
|
|
};
|
|
var cycleHorizontal$1 = function (values, index, numRows, numCols, delta) {
|
|
return withGrid(values, index, numCols, function (oldRow, oldColumn) {
|
|
var onLastRow = oldRow === numRows - 1;
|
|
var colsInRow = onLastRow ? values.length - oldRow * numCols : numCols;
|
|
var newColumn = cycleBy(oldColumn, delta, 0, colsInRow - 1);
|
|
return Optional.some({
|
|
row: oldRow,
|
|
column: newColumn
|
|
});
|
|
});
|
|
};
|
|
var cycleVertical$1 = function (values, index, numRows, numCols, delta) {
|
|
return withGrid(values, index, numCols, function (oldRow, oldColumn) {
|
|
var newRow = cycleBy(oldRow, delta, 0, numRows - 1);
|
|
var onLastRow = newRow === numRows - 1;
|
|
var colsInRow = onLastRow ? values.length - newRow * numCols : numCols;
|
|
var newCol = clamp(oldColumn, 0, colsInRow - 1);
|
|
return Optional.some({
|
|
row: newRow,
|
|
column: newCol
|
|
});
|
|
});
|
|
};
|
|
var cycleRight$1 = function (values, index, numRows, numCols) {
|
|
return cycleHorizontal$1(values, index, numRows, numCols, +1);
|
|
};
|
|
var cycleLeft$1 = function (values, index, numRows, numCols) {
|
|
return cycleHorizontal$1(values, index, numRows, numCols, -1);
|
|
};
|
|
var cycleUp$1 = function (values, index, numRows, numCols) {
|
|
return cycleVertical$1(values, index, numRows, numCols, -1);
|
|
};
|
|
var cycleDown$1 = function (values, index, numRows, numCols) {
|
|
return cycleVertical$1(values, index, numRows, numCols, +1);
|
|
};
|
|
|
|
var schema$e = [
|
|
required$1('selector'),
|
|
defaulted('execute', defaultExecute),
|
|
onKeyboardHandler('onEscape'),
|
|
defaulted('captureTab', false),
|
|
initSize()
|
|
];
|
|
var focusIn$3 = function (component, gridConfig, _gridState) {
|
|
descendant(component.element, gridConfig.selector).each(function (first) {
|
|
gridConfig.focusManager.set(component, first);
|
|
});
|
|
};
|
|
var findCurrent$1 = function (component, gridConfig) {
|
|
return gridConfig.focusManager.get(component).bind(function (elem) {
|
|
return closest$1(elem, gridConfig.selector);
|
|
});
|
|
};
|
|
var execute$3 = function (component, simulatedEvent, gridConfig, _gridState) {
|
|
return findCurrent$1(component, gridConfig).bind(function (focused) {
|
|
return gridConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var doMove$2 = function (cycle) {
|
|
return function (element, focused, gridConfig, gridState) {
|
|
return locateVisible(element, focused, gridConfig.selector).bind(function (identified) {
|
|
return cycle(identified.candidates, identified.index, gridState.getNumRows().getOr(gridConfig.initSize.numRows), gridState.getNumColumns().getOr(gridConfig.initSize.numColumns));
|
|
});
|
|
};
|
|
};
|
|
var handleTab = function (_component, _simulatedEvent, gridConfig) {
|
|
return gridConfig.captureTab ? Optional.some(true) : Optional.none();
|
|
};
|
|
var doEscape$1 = function (component, simulatedEvent, gridConfig) {
|
|
return gridConfig.onEscape(component, simulatedEvent);
|
|
};
|
|
var moveLeft$3 = doMove$2(cycleLeft$1);
|
|
var moveRight$3 = doMove$2(cycleRight$1);
|
|
var moveNorth$1 = doMove$2(cycleUp$1);
|
|
var moveSouth$1 = doMove$2(cycleDown$1);
|
|
var getKeydownRules$4 = constant$1([
|
|
rule(inSet(LEFT), west(moveLeft$3, moveRight$3)),
|
|
rule(inSet(RIGHT), east(moveLeft$3, moveRight$3)),
|
|
rule(inSet(UP), north(moveNorth$1)),
|
|
rule(inSet(DOWN), south(moveSouth$1)),
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), handleTab),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(TAB)
|
|
]), handleTab),
|
|
rule(inSet(ESCAPE), doEscape$1),
|
|
rule(inSet(SPACE.concat(ENTER)), execute$3)
|
|
]);
|
|
var getKeyupRules$4 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var FlatgridType = typical(schema$e, flatgrid$1, getKeydownRules$4, getKeyupRules$4, function () {
|
|
return Optional.some(focusIn$3);
|
|
});
|
|
|
|
var horizontal = function (container, selector, current, delta) {
|
|
var isDisabledButton = function (candidate) {
|
|
return name$1(candidate) === 'button' && get$b(candidate, 'disabled') === 'disabled';
|
|
};
|
|
var tryCycle = function (initial, index, candidates) {
|
|
var newIndex = cycleBy(index, delta, 0, candidates.length - 1);
|
|
if (newIndex === initial) {
|
|
return Optional.none();
|
|
} else {
|
|
return isDisabledButton(candidates[newIndex]) ? tryCycle(initial, newIndex, candidates) : Optional.from(candidates[newIndex]);
|
|
}
|
|
};
|
|
return locateVisible(container, current, selector).bind(function (identified) {
|
|
var index = identified.index;
|
|
var candidates = identified.candidates;
|
|
return tryCycle(index, index, candidates);
|
|
});
|
|
};
|
|
|
|
var schema$d = [
|
|
required$1('selector'),
|
|
defaulted('getInitial', Optional.none),
|
|
defaulted('execute', defaultExecute),
|
|
onKeyboardHandler('onEscape'),
|
|
defaulted('executeOnMove', false),
|
|
defaulted('allowVertical', true)
|
|
];
|
|
var findCurrent = function (component, flowConfig) {
|
|
return flowConfig.focusManager.get(component).bind(function (elem) {
|
|
return closest$1(elem, flowConfig.selector);
|
|
});
|
|
};
|
|
var execute$2 = function (component, simulatedEvent, flowConfig) {
|
|
return findCurrent(component, flowConfig).bind(function (focused) {
|
|
return flowConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var focusIn$2 = function (component, flowConfig, _state) {
|
|
flowConfig.getInitial(component).orThunk(function () {
|
|
return descendant(component.element, flowConfig.selector);
|
|
}).each(function (first) {
|
|
flowConfig.focusManager.set(component, first);
|
|
});
|
|
};
|
|
var moveLeft$2 = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, -1);
|
|
};
|
|
var moveRight$2 = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, +1);
|
|
};
|
|
var doMove$1 = function (movement) {
|
|
return function (component, simulatedEvent, flowConfig, flowState) {
|
|
return movement(component, simulatedEvent, flowConfig, flowState).bind(function () {
|
|
return flowConfig.executeOnMove ? execute$2(component, simulatedEvent, flowConfig) : Optional.some(true);
|
|
});
|
|
};
|
|
};
|
|
var doEscape = function (component, simulatedEvent, flowConfig) {
|
|
return flowConfig.onEscape(component, simulatedEvent);
|
|
};
|
|
var getKeydownRules$3 = function (_component, _se, flowConfig, _flowState) {
|
|
var westMovers = LEFT.concat(flowConfig.allowVertical ? UP : []);
|
|
var eastMovers = RIGHT.concat(flowConfig.allowVertical ? DOWN : []);
|
|
return [
|
|
rule(inSet(westMovers), doMove$1(west(moveLeft$2, moveRight$2))),
|
|
rule(inSet(eastMovers), doMove$1(east(moveLeft$2, moveRight$2))),
|
|
rule(inSet(ENTER), execute$2),
|
|
rule(inSet(SPACE), execute$2),
|
|
rule(inSet(ESCAPE), doEscape)
|
|
];
|
|
};
|
|
var getKeyupRules$3 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var FlowType = typical(schema$d, NoState.init, getKeydownRules$3, getKeyupRules$3, function () {
|
|
return Optional.some(focusIn$2);
|
|
});
|
|
|
|
var toCell = function (matrix, rowIndex, columnIndex) {
|
|
return Optional.from(matrix[rowIndex]).bind(function (row) {
|
|
return Optional.from(row[columnIndex]).map(function (cell) {
|
|
return {
|
|
rowIndex: rowIndex,
|
|
columnIndex: columnIndex,
|
|
cell: cell
|
|
};
|
|
});
|
|
});
|
|
};
|
|
var cycleHorizontal = function (matrix, rowIndex, startCol, deltaCol) {
|
|
var row = matrix[rowIndex];
|
|
var colsInRow = row.length;
|
|
var newColIndex = cycleBy(startCol, deltaCol, 0, colsInRow - 1);
|
|
return toCell(matrix, rowIndex, newColIndex);
|
|
};
|
|
var cycleVertical = function (matrix, colIndex, startRow, deltaRow) {
|
|
var nextRowIndex = cycleBy(startRow, deltaRow, 0, matrix.length - 1);
|
|
var colsInNextRow = matrix[nextRowIndex].length;
|
|
var nextColIndex = clamp(colIndex, 0, colsInNextRow - 1);
|
|
return toCell(matrix, nextRowIndex, nextColIndex);
|
|
};
|
|
var moveHorizontal = function (matrix, rowIndex, startCol, deltaCol) {
|
|
var row = matrix[rowIndex];
|
|
var colsInRow = row.length;
|
|
var newColIndex = clamp(startCol + deltaCol, 0, colsInRow - 1);
|
|
return toCell(matrix, rowIndex, newColIndex);
|
|
};
|
|
var moveVertical = function (matrix, colIndex, startRow, deltaRow) {
|
|
var nextRowIndex = clamp(startRow + deltaRow, 0, matrix.length - 1);
|
|
var colsInNextRow = matrix[nextRowIndex].length;
|
|
var nextColIndex = clamp(colIndex, 0, colsInNextRow - 1);
|
|
return toCell(matrix, nextRowIndex, nextColIndex);
|
|
};
|
|
var cycleRight = function (matrix, startRow, startCol) {
|
|
return cycleHorizontal(matrix, startRow, startCol, +1);
|
|
};
|
|
var cycleLeft = function (matrix, startRow, startCol) {
|
|
return cycleHorizontal(matrix, startRow, startCol, -1);
|
|
};
|
|
var cycleUp = function (matrix, startRow, startCol) {
|
|
return cycleVertical(matrix, startCol, startRow, -1);
|
|
};
|
|
var cycleDown = function (matrix, startRow, startCol) {
|
|
return cycleVertical(matrix, startCol, startRow, +1);
|
|
};
|
|
var moveLeft$1 = function (matrix, startRow, startCol) {
|
|
return moveHorizontal(matrix, startRow, startCol, -1);
|
|
};
|
|
var moveRight$1 = function (matrix, startRow, startCol) {
|
|
return moveHorizontal(matrix, startRow, startCol, +1);
|
|
};
|
|
var moveUp$1 = function (matrix, startRow, startCol) {
|
|
return moveVertical(matrix, startCol, startRow, -1);
|
|
};
|
|
var moveDown$1 = function (matrix, startRow, startCol) {
|
|
return moveVertical(matrix, startCol, startRow, +1);
|
|
};
|
|
|
|
var schema$c = [
|
|
requiredObjOf('selectors', [
|
|
required$1('row'),
|
|
required$1('cell')
|
|
]),
|
|
defaulted('cycles', true),
|
|
defaulted('previousSelector', Optional.none),
|
|
defaulted('execute', defaultExecute)
|
|
];
|
|
var focusIn$1 = function (component, matrixConfig, _state) {
|
|
var focused = matrixConfig.previousSelector(component).orThunk(function () {
|
|
var selectors = matrixConfig.selectors;
|
|
return descendant(component.element, selectors.cell);
|
|
});
|
|
focused.each(function (cell) {
|
|
matrixConfig.focusManager.set(component, cell);
|
|
});
|
|
};
|
|
var execute$1 = function (component, simulatedEvent, matrixConfig) {
|
|
return search(component.element).bind(function (focused) {
|
|
return matrixConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var toMatrix = function (rows, matrixConfig) {
|
|
return map$2(rows, function (row) {
|
|
return descendants(row, matrixConfig.selectors.cell);
|
|
});
|
|
};
|
|
var doMove = function (ifCycle, ifMove) {
|
|
return function (element, focused, matrixConfig) {
|
|
var move = matrixConfig.cycles ? ifCycle : ifMove;
|
|
return closest$1(focused, matrixConfig.selectors.row).bind(function (inRow) {
|
|
var cellsInRow = descendants(inRow, matrixConfig.selectors.cell);
|
|
return findIndex(cellsInRow, focused).bind(function (colIndex) {
|
|
var allRows = descendants(element, matrixConfig.selectors.row);
|
|
return findIndex(allRows, inRow).bind(function (rowIndex) {
|
|
var matrix = toMatrix(allRows, matrixConfig);
|
|
return move(matrix, rowIndex, colIndex).map(function (next) {
|
|
return next.cell;
|
|
});
|
|
});
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var moveLeft = doMove(cycleLeft, moveLeft$1);
|
|
var moveRight = doMove(cycleRight, moveRight$1);
|
|
var moveNorth = doMove(cycleUp, moveUp$1);
|
|
var moveSouth = doMove(cycleDown, moveDown$1);
|
|
var getKeydownRules$2 = constant$1([
|
|
rule(inSet(LEFT), west(moveLeft, moveRight)),
|
|
rule(inSet(RIGHT), east(moveLeft, moveRight)),
|
|
rule(inSet(UP), north(moveNorth)),
|
|
rule(inSet(DOWN), south(moveSouth)),
|
|
rule(inSet(SPACE.concat(ENTER)), execute$1)
|
|
]);
|
|
var getKeyupRules$2 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var MatrixType = typical(schema$c, NoState.init, getKeydownRules$2, getKeyupRules$2, function () {
|
|
return Optional.some(focusIn$1);
|
|
});
|
|
|
|
var schema$b = [
|
|
required$1('selector'),
|
|
defaulted('execute', defaultExecute),
|
|
defaulted('moveOnTab', false)
|
|
];
|
|
var execute = function (component, simulatedEvent, menuConfig) {
|
|
return menuConfig.focusManager.get(component).bind(function (focused) {
|
|
return menuConfig.execute(component, simulatedEvent, focused);
|
|
});
|
|
};
|
|
var focusIn = function (component, menuConfig, _state) {
|
|
descendant(component.element, menuConfig.selector).each(function (first) {
|
|
menuConfig.focusManager.set(component, first);
|
|
});
|
|
};
|
|
var moveUp = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, -1);
|
|
};
|
|
var moveDown = function (element, focused, info) {
|
|
return horizontal(element, info.selector, focused, +1);
|
|
};
|
|
var fireShiftTab = function (component, simulatedEvent, menuConfig, menuState) {
|
|
return menuConfig.moveOnTab ? move$1(moveUp)(component, simulatedEvent, menuConfig, menuState) : Optional.none();
|
|
};
|
|
var fireTab = function (component, simulatedEvent, menuConfig, menuState) {
|
|
return menuConfig.moveOnTab ? move$1(moveDown)(component, simulatedEvent, menuConfig, menuState) : Optional.none();
|
|
};
|
|
var getKeydownRules$1 = constant$1([
|
|
rule(inSet(UP), move$1(moveUp)),
|
|
rule(inSet(DOWN), move$1(moveDown)),
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), fireShiftTab),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(TAB)
|
|
]), fireTab),
|
|
rule(inSet(ENTER), execute),
|
|
rule(inSet(SPACE), execute)
|
|
]);
|
|
var getKeyupRules$1 = constant$1([rule(inSet(SPACE), stopEventForFirefox)]);
|
|
var MenuType = typical(schema$b, NoState.init, getKeydownRules$1, getKeyupRules$1, function () {
|
|
return Optional.some(focusIn);
|
|
});
|
|
|
|
var schema$a = [
|
|
onKeyboardHandler('onSpace'),
|
|
onKeyboardHandler('onEnter'),
|
|
onKeyboardHandler('onShiftEnter'),
|
|
onKeyboardHandler('onLeft'),
|
|
onKeyboardHandler('onRight'),
|
|
onKeyboardHandler('onTab'),
|
|
onKeyboardHandler('onShiftTab'),
|
|
onKeyboardHandler('onUp'),
|
|
onKeyboardHandler('onDown'),
|
|
onKeyboardHandler('onEscape'),
|
|
defaulted('stopSpaceKeyup', false),
|
|
option('focusIn')
|
|
];
|
|
var getKeydownRules = function (component, simulatedEvent, specialInfo) {
|
|
return [
|
|
rule(inSet(SPACE), specialInfo.onSpace),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(ENTER)
|
|
]), specialInfo.onEnter),
|
|
rule(and([
|
|
isShift,
|
|
inSet(ENTER)
|
|
]), specialInfo.onShiftEnter),
|
|
rule(and([
|
|
isShift,
|
|
inSet(TAB)
|
|
]), specialInfo.onShiftTab),
|
|
rule(and([
|
|
isNotShift,
|
|
inSet(TAB)
|
|
]), specialInfo.onTab),
|
|
rule(inSet(UP), specialInfo.onUp),
|
|
rule(inSet(DOWN), specialInfo.onDown),
|
|
rule(inSet(LEFT), specialInfo.onLeft),
|
|
rule(inSet(RIGHT), specialInfo.onRight),
|
|
rule(inSet(SPACE), specialInfo.onSpace),
|
|
rule(inSet(ESCAPE), specialInfo.onEscape)
|
|
];
|
|
};
|
|
var getKeyupRules = function (component, simulatedEvent, specialInfo) {
|
|
return specialInfo.stopSpaceKeyup ? [rule(inSet(SPACE), stopEventForFirefox)] : [];
|
|
};
|
|
var SpecialType = typical(schema$a, NoState.init, getKeydownRules, getKeyupRules, function (specialInfo) {
|
|
return specialInfo.focusIn;
|
|
});
|
|
|
|
var acyclic = AcyclicType.schema();
|
|
var cyclic = CyclicType.schema();
|
|
var flow = FlowType.schema();
|
|
var flatgrid = FlatgridType.schema();
|
|
var matrix = MatrixType.schema();
|
|
var execution = ExecutionType.schema();
|
|
var menu = MenuType.schema();
|
|
var special = SpecialType.schema();
|
|
|
|
var KeyboardBranches = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
acyclic: acyclic,
|
|
cyclic: cyclic,
|
|
flow: flow,
|
|
flatgrid: flatgrid,
|
|
matrix: matrix,
|
|
execution: execution,
|
|
menu: menu,
|
|
special: special
|
|
});
|
|
|
|
var isFlatgridState = function (keyState) {
|
|
return hasNonNullableKey(keyState, 'setGridSize');
|
|
};
|
|
var Keying = createModes({
|
|
branchKey: 'mode',
|
|
branches: KeyboardBranches,
|
|
name: 'keying',
|
|
active: {
|
|
events: function (keyingConfig, keyingState) {
|
|
var handler = keyingConfig.handler;
|
|
return handler.toEvents(keyingConfig, keyingState);
|
|
}
|
|
},
|
|
apis: {
|
|
focusIn: function (component, keyConfig, keyState) {
|
|
keyConfig.sendFocusIn(keyConfig).fold(function () {
|
|
component.getSystem().triggerFocus(component.element, component.element);
|
|
}, function (sendFocusIn) {
|
|
sendFocusIn(component, keyConfig, keyState);
|
|
});
|
|
},
|
|
setGridSize: function (component, keyConfig, keyState, numRows, numColumns) {
|
|
if (!isFlatgridState(keyState)) {
|
|
console.error('Layout does not support setGridSize');
|
|
} else {
|
|
keyState.setGridSize(numRows, numColumns);
|
|
}
|
|
}
|
|
},
|
|
state: KeyingState
|
|
});
|
|
|
|
var field$1 = function (name, forbidden) {
|
|
return defaultedObjOf(name, {}, map$2(forbidden, function (f) {
|
|
return forbid(f.name(), 'Cannot configure ' + f.name() + ' for ' + name);
|
|
}).concat([customField('dump', identity)]));
|
|
};
|
|
var get$6 = function (data) {
|
|
return data.dump;
|
|
};
|
|
var augment = function (data, original) {
|
|
return __assign(__assign({}, derive$2(original)), data.dump);
|
|
};
|
|
var SketchBehaviours = {
|
|
field: field$1,
|
|
augment: augment,
|
|
get: get$6
|
|
};
|
|
|
|
var _placeholder = 'placeholder';
|
|
var adt$5 = Adt.generate([
|
|
{
|
|
single: [
|
|
'required',
|
|
'valueThunk'
|
|
]
|
|
},
|
|
{
|
|
multiple: [
|
|
'required',
|
|
'valueThunks'
|
|
]
|
|
}
|
|
]);
|
|
var isSubstituted = function (spec) {
|
|
return has$2(spec, 'uiType');
|
|
};
|
|
var subPlaceholder = function (owner, detail, compSpec, placeholders) {
|
|
if (owner.exists(function (o) {
|
|
return o !== compSpec.owner;
|
|
})) {
|
|
return adt$5.single(true, constant$1(compSpec));
|
|
}
|
|
return get$c(placeholders, compSpec.name).fold(function () {
|
|
throw new Error('Unknown placeholder component: ' + compSpec.name + '\nKnown: [' + keys(placeholders) + ']\nNamespace: ' + owner.getOr('none') + '\nSpec: ' + JSON.stringify(compSpec, null, 2));
|
|
}, function (newSpec) {
|
|
return newSpec.replace();
|
|
});
|
|
};
|
|
var scan = function (owner, detail, compSpec, placeholders) {
|
|
if (isSubstituted(compSpec) && compSpec.uiType === _placeholder) {
|
|
return subPlaceholder(owner, detail, compSpec, placeholders);
|
|
} else {
|
|
return adt$5.single(false, constant$1(compSpec));
|
|
}
|
|
};
|
|
var substitute = function (owner, detail, compSpec, placeholders) {
|
|
var base = scan(owner, detail, compSpec, placeholders);
|
|
return base.fold(function (req, valueThunk) {
|
|
var value = isSubstituted(compSpec) ? valueThunk(detail, compSpec.config, compSpec.validated) : valueThunk(detail);
|
|
var childSpecs = get$c(value, 'components').getOr([]);
|
|
var substituted = bind$3(childSpecs, function (c) {
|
|
return substitute(owner, detail, c, placeholders);
|
|
});
|
|
return [__assign(__assign({}, value), { components: substituted })];
|
|
}, function (req, valuesThunk) {
|
|
if (isSubstituted(compSpec)) {
|
|
var values = valuesThunk(detail, compSpec.config, compSpec.validated);
|
|
var preprocessor = compSpec.validated.preprocess.getOr(identity);
|
|
return preprocessor(values);
|
|
} else {
|
|
return valuesThunk(detail);
|
|
}
|
|
});
|
|
};
|
|
var substituteAll = function (owner, detail, components, placeholders) {
|
|
return bind$3(components, function (c) {
|
|
return substitute(owner, detail, c, placeholders);
|
|
});
|
|
};
|
|
var oneReplace = function (label, replacements) {
|
|
var called = false;
|
|
var used = function () {
|
|
return called;
|
|
};
|
|
var replace = function () {
|
|
if (called) {
|
|
throw new Error('Trying to use the same placeholder more than once: ' + label);
|
|
}
|
|
called = true;
|
|
return replacements;
|
|
};
|
|
var required = function () {
|
|
return replacements.fold(function (req, _) {
|
|
return req;
|
|
}, function (req, _) {
|
|
return req;
|
|
});
|
|
};
|
|
return {
|
|
name: constant$1(label),
|
|
required: required,
|
|
used: used,
|
|
replace: replace
|
|
};
|
|
};
|
|
var substitutePlaces = function (owner, detail, components, placeholders) {
|
|
var ps = map$1(placeholders, function (ph, name) {
|
|
return oneReplace(name, ph);
|
|
});
|
|
var outcome = substituteAll(owner, detail, components, ps);
|
|
each(ps, function (p) {
|
|
if (p.used() === false && p.required()) {
|
|
throw new Error('Placeholder: ' + p.name() + ' was not found in components list\nNamespace: ' + owner.getOr('none') + '\nComponents: ' + JSON.stringify(detail.components, null, 2));
|
|
}
|
|
});
|
|
return outcome;
|
|
};
|
|
var single$2 = adt$5.single;
|
|
var multiple = adt$5.multiple;
|
|
var placeholder = constant$1(_placeholder);
|
|
|
|
var unique = 0;
|
|
var generate$4 = function (prefix) {
|
|
var date = new Date();
|
|
var time = date.getTime();
|
|
var random = Math.floor(Math.random() * 1000000000);
|
|
unique++;
|
|
return prefix + '_' + random + unique + String(time);
|
|
};
|
|
|
|
var adt$4 = Adt.generate([
|
|
{ required: ['data'] },
|
|
{ external: ['data'] },
|
|
{ optional: ['data'] },
|
|
{ group: ['data'] }
|
|
]);
|
|
var fFactory = defaulted('factory', { sketch: identity });
|
|
var fSchema = defaulted('schema', []);
|
|
var fName = required$1('name');
|
|
var fPname = field$2('pname', 'pname', defaultedThunk(function (typeSpec) {
|
|
return '<alloy.' + generate$4(typeSpec.name) + '>';
|
|
}), anyValue());
|
|
var fGroupSchema = customField('schema', function () {
|
|
return [option('preprocess')];
|
|
});
|
|
var fDefaults = defaulted('defaults', constant$1({}));
|
|
var fOverrides = defaulted('overrides', constant$1({}));
|
|
var requiredSpec = objOf([
|
|
fFactory,
|
|
fSchema,
|
|
fName,
|
|
fPname,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var externalSpec = objOf([
|
|
fFactory,
|
|
fSchema,
|
|
fName,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var optionalSpec = objOf([
|
|
fFactory,
|
|
fSchema,
|
|
fName,
|
|
fPname,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var groupSpec = objOf([
|
|
fFactory,
|
|
fGroupSchema,
|
|
fName,
|
|
required$1('unit'),
|
|
fPname,
|
|
fDefaults,
|
|
fOverrides
|
|
]);
|
|
var asNamedPart = function (part) {
|
|
return part.fold(Optional.some, Optional.none, Optional.some, Optional.some);
|
|
};
|
|
var name = function (part) {
|
|
var get = function (data) {
|
|
return data.name;
|
|
};
|
|
return part.fold(get, get, get, get);
|
|
};
|
|
var convert$1 = function (adtConstructor, partSchema) {
|
|
return function (spec) {
|
|
var data = asRawOrDie$1('Converting part type', partSchema, spec);
|
|
return adtConstructor(data);
|
|
};
|
|
};
|
|
var required = convert$1(adt$4.required, requiredSpec);
|
|
convert$1(adt$4.external, externalSpec);
|
|
var optional = convert$1(adt$4.optional, optionalSpec);
|
|
var group = convert$1(adt$4.group, groupSpec);
|
|
var original = constant$1('entirety');
|
|
|
|
var combine$2 = function (detail, data, partSpec, partValidated) {
|
|
return deepMerge(data.defaults(detail, partSpec, partValidated), partSpec, { uid: detail.partUids[data.name] }, data.overrides(detail, partSpec, partValidated));
|
|
};
|
|
var subs = function (owner, detail, parts) {
|
|
var internals = {};
|
|
var externals = {};
|
|
each$1(parts, function (part) {
|
|
part.fold(function (data) {
|
|
internals[data.pname] = single$2(true, function (detail, partSpec, partValidated) {
|
|
return data.factory.sketch(combine$2(detail, data, partSpec, partValidated));
|
|
});
|
|
}, function (data) {
|
|
var partSpec = detail.parts[data.name];
|
|
externals[data.name] = constant$1(data.factory.sketch(combine$2(detail, data, partSpec[original()]), partSpec));
|
|
}, function (data) {
|
|
internals[data.pname] = single$2(false, function (detail, partSpec, partValidated) {
|
|
return data.factory.sketch(combine$2(detail, data, partSpec, partValidated));
|
|
});
|
|
}, function (data) {
|
|
internals[data.pname] = multiple(true, function (detail, _partSpec, _partValidated) {
|
|
var units = detail[data.name];
|
|
return map$2(units, function (u) {
|
|
return data.factory.sketch(deepMerge(data.defaults(detail, u, _partValidated), u, data.overrides(detail, u)));
|
|
});
|
|
});
|
|
});
|
|
});
|
|
return {
|
|
internals: constant$1(internals),
|
|
externals: constant$1(externals)
|
|
};
|
|
};
|
|
|
|
var generate$3 = function (owner, parts) {
|
|
var r = {};
|
|
each$1(parts, function (part) {
|
|
asNamedPart(part).each(function (np) {
|
|
var g = doGenerateOne(owner, np.pname);
|
|
r[np.name] = function (config) {
|
|
var validated = asRawOrDie$1('Part: ' + np.name + ' in ' + owner, objOf(np.schema), config);
|
|
return __assign(__assign({}, g), {
|
|
config: config,
|
|
validated: validated
|
|
});
|
|
};
|
|
});
|
|
});
|
|
return r;
|
|
};
|
|
var doGenerateOne = function (owner, pname) {
|
|
return {
|
|
uiType: placeholder(),
|
|
owner: owner,
|
|
name: pname
|
|
};
|
|
};
|
|
var generateOne = function (owner, pname, config) {
|
|
return {
|
|
uiType: placeholder(),
|
|
owner: owner,
|
|
name: pname,
|
|
config: config,
|
|
validated: {}
|
|
};
|
|
};
|
|
var schemas = function (parts) {
|
|
return bind$3(parts, function (part) {
|
|
return part.fold(Optional.none, Optional.some, Optional.none, Optional.none).map(function (data) {
|
|
return requiredObjOf(data.name, data.schema.concat([snapshot(original())]));
|
|
}).toArray();
|
|
});
|
|
};
|
|
var names = function (parts) {
|
|
return map$2(parts, name);
|
|
};
|
|
var substitutes = function (owner, detail, parts) {
|
|
return subs(owner, detail, parts);
|
|
};
|
|
var components = function (owner, detail, internals) {
|
|
return substitutePlaces(Optional.some(owner), detail, detail.components, internals);
|
|
};
|
|
var getPart = function (component, detail, partKey) {
|
|
var uid = detail.partUids[partKey];
|
|
return component.getSystem().getByUid(uid).toOptional();
|
|
};
|
|
var getPartOrDie = function (component, detail, partKey) {
|
|
return getPart(component, detail, partKey).getOrDie('Could not find part: ' + partKey);
|
|
};
|
|
var getAllParts = function (component, detail) {
|
|
var system = component.getSystem();
|
|
return map$1(detail.partUids, function (pUid, _k) {
|
|
return constant$1(system.getByUid(pUid));
|
|
});
|
|
};
|
|
var defaultUids = function (baseUid, partTypes) {
|
|
var partNames = names(partTypes);
|
|
return wrapAll(map$2(partNames, function (pn) {
|
|
return {
|
|
key: pn,
|
|
value: baseUid + '-' + pn
|
|
};
|
|
}));
|
|
};
|
|
var defaultUidsSchema = function (partTypes) {
|
|
return field$2('partUids', 'partUids', mergeWithThunk(function (spec) {
|
|
return defaultUids(spec.uid, partTypes);
|
|
}), anyValue());
|
|
};
|
|
|
|
var premadeTag = generate$4('alloy-premade');
|
|
var premade$1 = function (comp) {
|
|
return wrap(premadeTag, comp);
|
|
};
|
|
var getPremade = function (spec) {
|
|
return get$c(spec, premadeTag);
|
|
};
|
|
var makeApi = function (f) {
|
|
return markAsSketchApi(function (component) {
|
|
var rest = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
rest[_i - 1] = arguments[_i];
|
|
}
|
|
return f.apply(void 0, __spreadArray([
|
|
component.getApis(),
|
|
component
|
|
], rest, false));
|
|
}, f);
|
|
};
|
|
|
|
var prefix$1 = constant$1('alloy-id-');
|
|
var idAttr$1 = constant$1('data-alloy-id');
|
|
|
|
var prefix = prefix$1();
|
|
var idAttr = idAttr$1();
|
|
var write = function (label, elem) {
|
|
var id = generate$4(prefix + label);
|
|
writeOnly(elem, id);
|
|
return id;
|
|
};
|
|
var writeOnly = function (elem, uid) {
|
|
Object.defineProperty(elem.dom, idAttr, {
|
|
value: uid,
|
|
writable: true
|
|
});
|
|
};
|
|
var read = function (elem) {
|
|
var id = isElement(elem) ? elem.dom[idAttr] : null;
|
|
return Optional.from(id);
|
|
};
|
|
var generate$2 = function (prefix) {
|
|
return generate$4(prefix);
|
|
};
|
|
|
|
var base = function (partSchemas, partUidsSchemas) {
|
|
var ps = partSchemas.length > 0 ? [requiredObjOf('parts', partSchemas)] : [];
|
|
return ps.concat([
|
|
required$1('uid'),
|
|
defaulted('dom', {}),
|
|
defaulted('components', []),
|
|
snapshot('originalSpec'),
|
|
defaulted('debug.sketcher', {})
|
|
]).concat(partUidsSchemas);
|
|
};
|
|
var asRawOrDie = function (label, schema, spec, partSchemas, partUidsSchemas) {
|
|
var baseS = base(partSchemas, partUidsSchemas);
|
|
return asRawOrDie$1(label + ' [SpecSchema]', objOfOnly(baseS.concat(schema)), spec);
|
|
};
|
|
|
|
var single$1 = function (owner, schema, factory, spec) {
|
|
var specWithUid = supplyUid(spec);
|
|
var detail = asRawOrDie(owner, schema, specWithUid, [], []);
|
|
return factory(detail, specWithUid);
|
|
};
|
|
var composite$1 = function (owner, schema, partTypes, factory, spec) {
|
|
var specWithUid = supplyUid(spec);
|
|
var partSchemas = schemas(partTypes);
|
|
var partUidsSchema = defaultUidsSchema(partTypes);
|
|
var detail = asRawOrDie(owner, schema, specWithUid, partSchemas, [partUidsSchema]);
|
|
var subs = substitutes(owner, detail, partTypes);
|
|
var components$1 = components(owner, detail, subs.internals());
|
|
return factory(detail, components$1, specWithUid, subs.externals());
|
|
};
|
|
var hasUid = function (spec) {
|
|
return has$2(spec, 'uid');
|
|
};
|
|
var supplyUid = function (spec) {
|
|
return hasUid(spec) ? spec : __assign(__assign({}, spec), { uid: generate$2('uid') });
|
|
};
|
|
|
|
var isSketchSpec$1 = function (spec) {
|
|
return spec.uid !== undefined;
|
|
};
|
|
var singleSchema = objOfOnly([
|
|
required$1('name'),
|
|
required$1('factory'),
|
|
required$1('configFields'),
|
|
defaulted('apis', {}),
|
|
defaulted('extraApis', {})
|
|
]);
|
|
var compositeSchema = objOfOnly([
|
|
required$1('name'),
|
|
required$1('factory'),
|
|
required$1('configFields'),
|
|
required$1('partFields'),
|
|
defaulted('apis', {}),
|
|
defaulted('extraApis', {})
|
|
]);
|
|
var single = function (rawConfig) {
|
|
var config = asRawOrDie$1('Sketcher for ' + rawConfig.name, singleSchema, rawConfig);
|
|
var sketch = function (spec) {
|
|
return single$1(config.name, config.configFields, config.factory, spec);
|
|
};
|
|
var apis = map$1(config.apis, makeApi);
|
|
var extraApis = map$1(config.extraApis, function (f, k) {
|
|
return markAsExtraApi(f, k);
|
|
});
|
|
return __assign(__assign({
|
|
name: config.name,
|
|
configFields: config.configFields,
|
|
sketch: sketch
|
|
}, apis), extraApis);
|
|
};
|
|
var composite = function (rawConfig) {
|
|
var config = asRawOrDie$1('Sketcher for ' + rawConfig.name, compositeSchema, rawConfig);
|
|
var sketch = function (spec) {
|
|
return composite$1(config.name, config.configFields, config.partFields, config.factory, spec);
|
|
};
|
|
var parts = generate$3(config.name, config.partFields);
|
|
var apis = map$1(config.apis, makeApi);
|
|
var extraApis = map$1(config.extraApis, function (f, k) {
|
|
return markAsExtraApi(f, k);
|
|
});
|
|
return __assign(__assign({
|
|
name: config.name,
|
|
partFields: config.partFields,
|
|
configFields: config.configFields,
|
|
sketch: sketch,
|
|
parts: parts
|
|
}, apis), extraApis);
|
|
};
|
|
|
|
var factory$5 = function (detail) {
|
|
var events = events$8(detail.action);
|
|
var tag = detail.dom.tag;
|
|
var lookupAttr = function (attr) {
|
|
return get$c(detail.dom, 'attributes').bind(function (attrs) {
|
|
return get$c(attrs, attr);
|
|
});
|
|
};
|
|
var getModAttributes = function () {
|
|
if (tag === 'button') {
|
|
var type = lookupAttr('type').getOr('button');
|
|
var roleAttrs = lookupAttr('role').map(function (role) {
|
|
return { role: role };
|
|
}).getOr({});
|
|
return __assign({ type: type }, roleAttrs);
|
|
} else {
|
|
var role = lookupAttr('role').getOr('button');
|
|
return { role: role };
|
|
}
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: detail.components,
|
|
events: events,
|
|
behaviours: SketchBehaviours.augment(detail.buttonBehaviours, [
|
|
Focusing.config({}),
|
|
Keying.config({
|
|
mode: 'execution',
|
|
useSpace: true,
|
|
useEnter: true
|
|
})
|
|
]),
|
|
domModification: { attributes: getModAttributes() },
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var Button = single({
|
|
name: 'Button',
|
|
factory: factory$5,
|
|
configFields: [
|
|
defaulted('uid', undefined),
|
|
required$1('dom'),
|
|
defaulted('components', []),
|
|
SketchBehaviours.field('buttonBehaviours', [
|
|
Focusing,
|
|
Keying
|
|
]),
|
|
option('action'),
|
|
option('role'),
|
|
defaulted('eventOrder', {})
|
|
]
|
|
});
|
|
|
|
var exhibit$3 = function () {
|
|
return nu$3({
|
|
styles: {
|
|
'-webkit-user-select': 'none',
|
|
'user-select': 'none',
|
|
'-ms-user-select': 'none',
|
|
'-moz-user-select': '-moz-none'
|
|
},
|
|
attributes: { unselectable: 'on' }
|
|
});
|
|
};
|
|
var events$6 = function () {
|
|
return derive$3([abort(selectstart(), always)]);
|
|
};
|
|
|
|
var ActiveUnselecting = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$6,
|
|
exhibit: exhibit$3
|
|
});
|
|
|
|
var Unselecting = create$5({
|
|
fields: [],
|
|
name: 'unselecting',
|
|
active: ActiveUnselecting
|
|
});
|
|
|
|
var getAttrs$1 = function (elem) {
|
|
var attributes = elem.dom.attributes !== undefined ? elem.dom.attributes : [];
|
|
return foldl(attributes, function (b, attr) {
|
|
var _a;
|
|
if (attr.name === 'class') {
|
|
return b;
|
|
} else {
|
|
return __assign(__assign({}, b), (_a = {}, _a[attr.name] = attr.value, _a));
|
|
}
|
|
}, {});
|
|
};
|
|
var getClasses = function (elem) {
|
|
return Array.prototype.slice.call(elem.dom.classList, 0);
|
|
};
|
|
var fromHtml = function (html) {
|
|
var elem = SugarElement.fromHtml(html);
|
|
var children$1 = children(elem);
|
|
var attrs = getAttrs$1(elem);
|
|
var classes = getClasses(elem);
|
|
var contents = children$1.length === 0 ? {} : { innerHtml: get$9(elem) };
|
|
return __assign({
|
|
tag: name$1(elem),
|
|
classes: classes,
|
|
attributes: attrs
|
|
}, contents);
|
|
};
|
|
|
|
var dom$1 = function (rawHtml) {
|
|
var html = supplant(rawHtml, { prefix: prefix$2 });
|
|
return fromHtml(html);
|
|
};
|
|
var spec = function (rawHtml) {
|
|
return { dom: dom$1(rawHtml) };
|
|
};
|
|
|
|
var forToolbarCommand = function (editor, command) {
|
|
return forToolbar(command, function () {
|
|
editor.execCommand(command);
|
|
}, {}, editor);
|
|
};
|
|
var getToggleBehaviours = function (command) {
|
|
return derive$2([
|
|
Toggling.config({
|
|
toggleClass: resolve('toolbar-button-selected'),
|
|
toggleOnExecute: false,
|
|
aria: { mode: 'pressed' }
|
|
}),
|
|
format(command, function (button, status) {
|
|
var toggle = status ? Toggling.on : Toggling.off;
|
|
toggle(button);
|
|
})
|
|
]);
|
|
};
|
|
var forToolbarStateCommand = function (editor, command) {
|
|
var extraBehaviours = getToggleBehaviours(command);
|
|
return forToolbar(command, function () {
|
|
editor.execCommand(command);
|
|
}, extraBehaviours, editor);
|
|
};
|
|
var forToolbarStateAction = function (editor, clazz, command, action) {
|
|
var extraBehaviours = getToggleBehaviours(command);
|
|
return forToolbar(clazz, action, extraBehaviours, editor);
|
|
};
|
|
var getToolbarIconButton = function (clazz, editor) {
|
|
var icons = editor.ui.registry.getAll().icons;
|
|
var optOxideIcon = Optional.from(icons[clazz]);
|
|
return optOxideIcon.fold(function () {
|
|
return dom$1('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item ${prefix}-icon-' + clazz + ' ${prefix}-icon"></span>');
|
|
}, function (icon) {
|
|
return dom$1('<span class="${prefix}-toolbar-button ${prefix}-toolbar-group-item">' + icon + '</span>');
|
|
});
|
|
};
|
|
var forToolbar = function (clazz, action, extraBehaviours, editor) {
|
|
return Button.sketch({
|
|
dom: getToolbarIconButton(clazz, editor),
|
|
action: action,
|
|
buttonBehaviours: deepMerge(derive$2([Unselecting.config({})]), extraBehaviours)
|
|
});
|
|
};
|
|
|
|
var labelPart = optional({
|
|
schema: [required$1('dom')],
|
|
name: 'label'
|
|
});
|
|
var edgePart = function (name) {
|
|
return optional({
|
|
name: '' + name + '-edge',
|
|
overrides: function (detail) {
|
|
var action = detail.model.manager.edgeActions[name];
|
|
return action.fold(function () {
|
|
return {};
|
|
}, function (a) {
|
|
return {
|
|
events: derive$3([
|
|
runActionExtra(touchstart(), function (comp, se, d) {
|
|
return a(comp, d);
|
|
}, [detail]),
|
|
runActionExtra(mousedown(), function (comp, se, d) {
|
|
return a(comp, d);
|
|
}, [detail]),
|
|
runActionExtra(mousemove(), function (comp, se, det) {
|
|
if (det.mouseIsDown.get()) {
|
|
a(comp, det);
|
|
}
|
|
}, [detail])
|
|
])
|
|
};
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var tlEdgePart = edgePart('top-left');
|
|
var tedgePart = edgePart('top');
|
|
var trEdgePart = edgePart('top-right');
|
|
var redgePart = edgePart('right');
|
|
var brEdgePart = edgePart('bottom-right');
|
|
var bedgePart = edgePart('bottom');
|
|
var blEdgePart = edgePart('bottom-left');
|
|
var ledgePart = edgePart('left');
|
|
var thumbPart = required({
|
|
name: 'thumb',
|
|
defaults: constant$1({ dom: { styles: { position: 'absolute' } } }),
|
|
overrides: function (detail) {
|
|
return {
|
|
events: derive$3([
|
|
redirectToPart(touchstart(), detail, 'spectrum'),
|
|
redirectToPart(touchmove(), detail, 'spectrum'),
|
|
redirectToPart(touchend(), detail, 'spectrum'),
|
|
redirectToPart(mousedown(), detail, 'spectrum'),
|
|
redirectToPart(mousemove(), detail, 'spectrum'),
|
|
redirectToPart(mouseup(), detail, 'spectrum')
|
|
])
|
|
};
|
|
}
|
|
});
|
|
var spectrumPart = required({
|
|
schema: [customField('mouseIsDown', function () {
|
|
return Cell(false);
|
|
})],
|
|
name: 'spectrum',
|
|
overrides: function (detail) {
|
|
var modelDetail = detail.model;
|
|
var model = modelDetail.manager;
|
|
var setValueFrom = function (component, simulatedEvent) {
|
|
return model.getValueFromEvent(simulatedEvent).map(function (value) {
|
|
return model.setValueFrom(component, detail, value);
|
|
});
|
|
};
|
|
return {
|
|
behaviours: derive$2([
|
|
Keying.config({
|
|
mode: 'special',
|
|
onLeft: function (spectrum) {
|
|
return model.onLeft(spectrum, detail);
|
|
},
|
|
onRight: function (spectrum) {
|
|
return model.onRight(spectrum, detail);
|
|
},
|
|
onUp: function (spectrum) {
|
|
return model.onUp(spectrum, detail);
|
|
},
|
|
onDown: function (spectrum) {
|
|
return model.onDown(spectrum, detail);
|
|
}
|
|
}),
|
|
Focusing.config({})
|
|
]),
|
|
events: derive$3([
|
|
run(touchstart(), setValueFrom),
|
|
run(touchmove(), setValueFrom),
|
|
run(mousedown(), setValueFrom),
|
|
run(mousemove(), function (spectrum, se) {
|
|
if (detail.mouseIsDown.get()) {
|
|
setValueFrom(spectrum, se);
|
|
}
|
|
})
|
|
])
|
|
};
|
|
}
|
|
});
|
|
var SliderParts = [
|
|
labelPart,
|
|
ledgePart,
|
|
redgePart,
|
|
tedgePart,
|
|
bedgePart,
|
|
tlEdgePart,
|
|
trEdgePart,
|
|
blEdgePart,
|
|
brEdgePart,
|
|
thumbPart,
|
|
spectrumPart
|
|
];
|
|
|
|
var onLoad$4 = function (component, repConfig, repState) {
|
|
repConfig.store.manager.onLoad(component, repConfig, repState);
|
|
};
|
|
var onUnload$2 = function (component, repConfig, repState) {
|
|
repConfig.store.manager.onUnload(component, repConfig, repState);
|
|
};
|
|
var setValue$3 = function (component, repConfig, repState, data) {
|
|
repConfig.store.manager.setValue(component, repConfig, repState, data);
|
|
};
|
|
var getValue$4 = function (component, repConfig, repState) {
|
|
return repConfig.store.manager.getValue(component, repConfig, repState);
|
|
};
|
|
var getState$1 = function (component, repConfig, repState) {
|
|
return repState;
|
|
};
|
|
|
|
var RepresentApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
onLoad: onLoad$4,
|
|
onUnload: onUnload$2,
|
|
setValue: setValue$3,
|
|
getValue: getValue$4,
|
|
getState: getState$1
|
|
});
|
|
|
|
var events$5 = function (repConfig, repState) {
|
|
var es = repConfig.resetOnDom ? [
|
|
runOnAttached(function (comp, _se) {
|
|
onLoad$4(comp, repConfig, repState);
|
|
}),
|
|
runOnDetached(function (comp, _se) {
|
|
onUnload$2(comp, repConfig, repState);
|
|
})
|
|
] : [loadEvent(repConfig, repState, onLoad$4)];
|
|
return derive$3(es);
|
|
};
|
|
|
|
var ActiveRepresenting = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$5
|
|
});
|
|
|
|
var memory = function () {
|
|
var data = Cell(null);
|
|
var readState = function () {
|
|
return {
|
|
mode: 'memory',
|
|
value: data.get()
|
|
};
|
|
};
|
|
var isNotSet = function () {
|
|
return data.get() === null;
|
|
};
|
|
var clear = function () {
|
|
data.set(null);
|
|
};
|
|
return nu$2({
|
|
set: data.set,
|
|
get: data.get,
|
|
isNotSet: isNotSet,
|
|
clear: clear,
|
|
readState: readState
|
|
});
|
|
};
|
|
var manual = function () {
|
|
var readState = noop;
|
|
return nu$2({ readState: readState });
|
|
};
|
|
var dataset = function () {
|
|
var dataByValue = Cell({});
|
|
var dataByText = Cell({});
|
|
var readState = function () {
|
|
return {
|
|
mode: 'dataset',
|
|
dataByValue: dataByValue.get(),
|
|
dataByText: dataByText.get()
|
|
};
|
|
};
|
|
var clear = function () {
|
|
dataByValue.set({});
|
|
dataByText.set({});
|
|
};
|
|
var lookup = function (itemString) {
|
|
return get$c(dataByValue.get(), itemString).orThunk(function () {
|
|
return get$c(dataByText.get(), itemString);
|
|
});
|
|
};
|
|
var update = function (items) {
|
|
var currentDataByValue = dataByValue.get();
|
|
var currentDataByText = dataByText.get();
|
|
var newDataByValue = {};
|
|
var newDataByText = {};
|
|
each$1(items, function (item) {
|
|
newDataByValue[item.value] = item;
|
|
get$c(item, 'meta').each(function (meta) {
|
|
get$c(meta, 'text').each(function (text) {
|
|
newDataByText[text] = item;
|
|
});
|
|
});
|
|
});
|
|
dataByValue.set(__assign(__assign({}, currentDataByValue), newDataByValue));
|
|
dataByText.set(__assign(__assign({}, currentDataByText), newDataByText));
|
|
};
|
|
return nu$2({
|
|
readState: readState,
|
|
lookup: lookup,
|
|
update: update,
|
|
clear: clear
|
|
});
|
|
};
|
|
var init$4 = function (spec) {
|
|
return spec.store.manager.state(spec);
|
|
};
|
|
|
|
var RepresentState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
memory: memory,
|
|
dataset: dataset,
|
|
manual: manual,
|
|
init: init$4
|
|
});
|
|
|
|
var setValue$2 = function (component, repConfig, repState, data) {
|
|
var store = repConfig.store;
|
|
repState.update([data]);
|
|
store.setValue(component, data);
|
|
repConfig.onSetValue(component, data);
|
|
};
|
|
var getValue$3 = function (component, repConfig, repState) {
|
|
var store = repConfig.store;
|
|
var key = store.getDataKey(component);
|
|
return repState.lookup(key).getOrThunk(function () {
|
|
return store.getFallbackEntry(key);
|
|
});
|
|
};
|
|
var onLoad$3 = function (component, repConfig, repState) {
|
|
var store = repConfig.store;
|
|
store.initialValue.each(function (data) {
|
|
setValue$2(component, repConfig, repState, data);
|
|
});
|
|
};
|
|
var onUnload$1 = function (component, repConfig, repState) {
|
|
repState.clear();
|
|
};
|
|
var DatasetStore = [
|
|
option('initialValue'),
|
|
required$1('getFallbackEntry'),
|
|
required$1('getDataKey'),
|
|
required$1('setValue'),
|
|
output('manager', {
|
|
setValue: setValue$2,
|
|
getValue: getValue$3,
|
|
onLoad: onLoad$3,
|
|
onUnload: onUnload$1,
|
|
state: dataset
|
|
})
|
|
];
|
|
|
|
var getValue$2 = function (component, repConfig, _repState) {
|
|
return repConfig.store.getValue(component);
|
|
};
|
|
var setValue$1 = function (component, repConfig, _repState, data) {
|
|
repConfig.store.setValue(component, data);
|
|
repConfig.onSetValue(component, data);
|
|
};
|
|
var onLoad$2 = function (component, repConfig, _repState) {
|
|
repConfig.store.initialValue.each(function (data) {
|
|
repConfig.store.setValue(component, data);
|
|
});
|
|
};
|
|
var ManualStore = [
|
|
required$1('getValue'),
|
|
defaulted('setValue', noop),
|
|
option('initialValue'),
|
|
output('manager', {
|
|
setValue: setValue$1,
|
|
getValue: getValue$2,
|
|
onLoad: onLoad$2,
|
|
onUnload: noop,
|
|
state: NoState.init
|
|
})
|
|
];
|
|
|
|
var setValue = function (component, repConfig, repState, data) {
|
|
repState.set(data);
|
|
repConfig.onSetValue(component, data);
|
|
};
|
|
var getValue$1 = function (component, repConfig, repState) {
|
|
return repState.get();
|
|
};
|
|
var onLoad$1 = function (component, repConfig, repState) {
|
|
repConfig.store.initialValue.each(function (initVal) {
|
|
if (repState.isNotSet()) {
|
|
repState.set(initVal);
|
|
}
|
|
});
|
|
};
|
|
var onUnload = function (component, repConfig, repState) {
|
|
repState.clear();
|
|
};
|
|
var MemoryStore = [
|
|
option('initialValue'),
|
|
output('manager', {
|
|
setValue: setValue,
|
|
getValue: getValue$1,
|
|
onLoad: onLoad$1,
|
|
onUnload: onUnload,
|
|
state: memory
|
|
})
|
|
];
|
|
|
|
var RepresentSchema = [
|
|
defaultedOf('store', { mode: 'memory' }, choose$1('mode', {
|
|
memory: MemoryStore,
|
|
manual: ManualStore,
|
|
dataset: DatasetStore
|
|
})),
|
|
onHandler('onSetValue'),
|
|
defaulted('resetOnDom', false)
|
|
];
|
|
|
|
var Representing = create$5({
|
|
fields: RepresentSchema,
|
|
name: 'representing',
|
|
active: ActiveRepresenting,
|
|
apis: RepresentApis,
|
|
extra: {
|
|
setValueFrom: function (component, source) {
|
|
var value = Representing.getValue(source);
|
|
Representing.setValue(component, value);
|
|
}
|
|
},
|
|
state: RepresentState
|
|
});
|
|
|
|
var api$1 = Dimension('width', function (element) {
|
|
return element.dom.offsetWidth;
|
|
});
|
|
var set$4 = function (element, h) {
|
|
return api$1.set(element, h);
|
|
};
|
|
var get$5 = function (element) {
|
|
return api$1.get(element);
|
|
};
|
|
|
|
var r$1 = function (left, top) {
|
|
var translate = function (x, y) {
|
|
return r$1(left + x, top + y);
|
|
};
|
|
return {
|
|
left: left,
|
|
top: top,
|
|
translate: translate
|
|
};
|
|
};
|
|
var SugarPosition = r$1;
|
|
|
|
var _sliderChangeEvent = 'slider.change.value';
|
|
var sliderChangeEvent = constant$1(_sliderChangeEvent);
|
|
var isTouchEvent = function (evt) {
|
|
return evt.type.indexOf('touch') !== -1;
|
|
};
|
|
var getEventSource = function (simulatedEvent) {
|
|
var evt = simulatedEvent.event.raw;
|
|
if (isTouchEvent(evt)) {
|
|
var touchEvent = evt;
|
|
return touchEvent.touches !== undefined && touchEvent.touches.length === 1 ? Optional.some(touchEvent.touches[0]).map(function (t) {
|
|
return SugarPosition(t.clientX, t.clientY);
|
|
}) : Optional.none();
|
|
} else {
|
|
var mouseEvent = evt;
|
|
return mouseEvent.clientX !== undefined ? Optional.some(mouseEvent).map(function (me) {
|
|
return SugarPosition(me.clientX, me.clientY);
|
|
}) : Optional.none();
|
|
}
|
|
};
|
|
|
|
var t = 'top', r = 'right', b = 'bottom', l = 'left';
|
|
var minX = function (detail) {
|
|
return detail.model.minX;
|
|
};
|
|
var minY = function (detail) {
|
|
return detail.model.minY;
|
|
};
|
|
var min1X = function (detail) {
|
|
return detail.model.minX - 1;
|
|
};
|
|
var min1Y = function (detail) {
|
|
return detail.model.minY - 1;
|
|
};
|
|
var maxX = function (detail) {
|
|
return detail.model.maxX;
|
|
};
|
|
var maxY = function (detail) {
|
|
return detail.model.maxY;
|
|
};
|
|
var max1X = function (detail) {
|
|
return detail.model.maxX + 1;
|
|
};
|
|
var max1Y = function (detail) {
|
|
return detail.model.maxY + 1;
|
|
};
|
|
var range$1 = function (detail, max, min) {
|
|
return max(detail) - min(detail);
|
|
};
|
|
var xRange = function (detail) {
|
|
return range$1(detail, maxX, minX);
|
|
};
|
|
var yRange = function (detail) {
|
|
return range$1(detail, maxY, minY);
|
|
};
|
|
var halfX = function (detail) {
|
|
return xRange(detail) / 2;
|
|
};
|
|
var halfY = function (detail) {
|
|
return yRange(detail) / 2;
|
|
};
|
|
var step = function (detail) {
|
|
return detail.stepSize;
|
|
};
|
|
var snap = function (detail) {
|
|
return detail.snapToGrid;
|
|
};
|
|
var snapStart = function (detail) {
|
|
return detail.snapStart;
|
|
};
|
|
var rounded = function (detail) {
|
|
return detail.rounded;
|
|
};
|
|
var hasEdge = function (detail, edgeName) {
|
|
return detail[edgeName + '-edge'] !== undefined;
|
|
};
|
|
var hasLEdge = function (detail) {
|
|
return hasEdge(detail, l);
|
|
};
|
|
var hasREdge = function (detail) {
|
|
return hasEdge(detail, r);
|
|
};
|
|
var hasTEdge = function (detail) {
|
|
return hasEdge(detail, t);
|
|
};
|
|
var hasBEdge = function (detail) {
|
|
return hasEdge(detail, b);
|
|
};
|
|
var currentValue = function (detail) {
|
|
return detail.model.value.get();
|
|
};
|
|
|
|
var xValue = function (x) {
|
|
return { x: x };
|
|
};
|
|
var yValue = function (y) {
|
|
return { y: y };
|
|
};
|
|
var xyValue = function (x, y) {
|
|
return {
|
|
x: x,
|
|
y: y
|
|
};
|
|
};
|
|
var fireSliderChange$3 = function (component, value) {
|
|
emitWith(component, sliderChangeEvent(), { value: value });
|
|
};
|
|
var setToTLEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(min1X(detail), min1Y(detail)));
|
|
};
|
|
var setToTEdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, yValue(min1Y(detail)));
|
|
};
|
|
var setToTEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(halfX(detail), min1Y(detail)));
|
|
};
|
|
var setToTREdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(max1X(detail), min1Y(detail)));
|
|
};
|
|
var setToREdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, xValue(max1X(detail)));
|
|
};
|
|
var setToREdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(max1X(detail), halfY(detail)));
|
|
};
|
|
var setToBREdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(max1X(detail), max1Y(detail)));
|
|
};
|
|
var setToBEdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, yValue(max1Y(detail)));
|
|
};
|
|
var setToBEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(halfX(detail), max1Y(detail)));
|
|
};
|
|
var setToBLEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(min1X(detail), max1Y(detail)));
|
|
};
|
|
var setToLEdge = function (edge, detail) {
|
|
fireSliderChange$3(edge, xValue(min1X(detail)));
|
|
};
|
|
var setToLEdgeXY = function (edge, detail) {
|
|
fireSliderChange$3(edge, xyValue(min1X(detail), halfY(detail)));
|
|
};
|
|
|
|
var reduceBy = function (value, min, max, step) {
|
|
if (value < min) {
|
|
return value;
|
|
} else if (value > max) {
|
|
return max;
|
|
} else if (value === min) {
|
|
return min - 1;
|
|
} else {
|
|
return Math.max(min, value - step);
|
|
}
|
|
};
|
|
var increaseBy = function (value, min, max, step) {
|
|
if (value > max) {
|
|
return value;
|
|
} else if (value < min) {
|
|
return min;
|
|
} else if (value === max) {
|
|
return max + 1;
|
|
} else {
|
|
return Math.min(max, value + step);
|
|
}
|
|
};
|
|
var capValue = function (value, min, max) {
|
|
return Math.max(min, Math.min(max, value));
|
|
};
|
|
var snapValueOf = function (value, min, max, step, snapStart) {
|
|
return snapStart.fold(function () {
|
|
var initValue = value - min;
|
|
var extraValue = Math.round(initValue / step) * step;
|
|
return capValue(min + extraValue, min - 1, max + 1);
|
|
}, function (start) {
|
|
var remainder = (value - start) % step;
|
|
var adjustment = Math.round(remainder / step);
|
|
var rawSteps = Math.floor((value - start) / step);
|
|
var maxSteps = Math.floor((max - start) / step);
|
|
var numSteps = Math.min(maxSteps, rawSteps + adjustment);
|
|
var r = start + numSteps * step;
|
|
return Math.max(start, r);
|
|
});
|
|
};
|
|
var findOffsetOf = function (value, min, max) {
|
|
return Math.min(max, Math.max(value, min)) - min;
|
|
};
|
|
var findValueOf = function (args) {
|
|
var min = args.min, max = args.max, range = args.range, value = args.value, step = args.step, snap = args.snap, snapStart = args.snapStart, rounded = args.rounded, hasMinEdge = args.hasMinEdge, hasMaxEdge = args.hasMaxEdge, minBound = args.minBound, maxBound = args.maxBound, screenRange = args.screenRange;
|
|
var capMin = hasMinEdge ? min - 1 : min;
|
|
var capMax = hasMaxEdge ? max + 1 : max;
|
|
if (value < minBound) {
|
|
return capMin;
|
|
} else if (value > maxBound) {
|
|
return capMax;
|
|
} else {
|
|
var offset = findOffsetOf(value, minBound, maxBound);
|
|
var newValue = capValue(offset / screenRange * range + min, capMin, capMax);
|
|
if (snap && newValue >= min && newValue <= max) {
|
|
return snapValueOf(newValue, min, max, step, snapStart);
|
|
} else if (rounded) {
|
|
return Math.round(newValue);
|
|
} else {
|
|
return newValue;
|
|
}
|
|
}
|
|
};
|
|
var findOffsetOfValue$2 = function (args) {
|
|
var min = args.min, max = args.max, range = args.range, value = args.value, hasMinEdge = args.hasMinEdge, hasMaxEdge = args.hasMaxEdge, maxBound = args.maxBound, maxOffset = args.maxOffset, centerMinEdge = args.centerMinEdge, centerMaxEdge = args.centerMaxEdge;
|
|
if (value < min) {
|
|
return hasMinEdge ? 0 : centerMinEdge;
|
|
} else if (value > max) {
|
|
return hasMaxEdge ? maxBound : centerMaxEdge;
|
|
} else {
|
|
return (value - min) / range * maxOffset;
|
|
}
|
|
};
|
|
|
|
var top = 'top', right = 'right', bottom = 'bottom', left = 'left', width = 'width', height = 'height';
|
|
var getBounds$1 = function (component) {
|
|
return component.element.dom.getBoundingClientRect();
|
|
};
|
|
var getBoundsProperty = function (bounds, property) {
|
|
return bounds[property];
|
|
};
|
|
var getMinXBounds = function (component) {
|
|
var bounds = getBounds$1(component);
|
|
return getBoundsProperty(bounds, left);
|
|
};
|
|
var getMaxXBounds = function (component) {
|
|
var bounds = getBounds$1(component);
|
|
return getBoundsProperty(bounds, right);
|
|
};
|
|
var getMinYBounds = function (component) {
|
|
var bounds = getBounds$1(component);
|
|
return getBoundsProperty(bounds, top);
|
|
};
|
|
var getMaxYBounds = function (component) {
|
|
var bounds = getBounds$1(component);
|
|
return getBoundsProperty(bounds, bottom);
|
|
};
|
|
var getXScreenRange = function (component) {
|
|
var bounds = getBounds$1(component);
|
|
return getBoundsProperty(bounds, width);
|
|
};
|
|
var getYScreenRange = function (component) {
|
|
var bounds = getBounds$1(component);
|
|
return getBoundsProperty(bounds, height);
|
|
};
|
|
var getCenterOffsetOf = function (componentMinEdge, componentMaxEdge, spectrumMinEdge) {
|
|
return (componentMinEdge + componentMaxEdge) / 2 - spectrumMinEdge;
|
|
};
|
|
var getXCenterOffSetOf = function (component, spectrum) {
|
|
var componentBounds = getBounds$1(component);
|
|
var spectrumBounds = getBounds$1(spectrum);
|
|
var componentMinEdge = getBoundsProperty(componentBounds, left);
|
|
var componentMaxEdge = getBoundsProperty(componentBounds, right);
|
|
var spectrumMinEdge = getBoundsProperty(spectrumBounds, left);
|
|
return getCenterOffsetOf(componentMinEdge, componentMaxEdge, spectrumMinEdge);
|
|
};
|
|
var getYCenterOffSetOf = function (component, spectrum) {
|
|
var componentBounds = getBounds$1(component);
|
|
var spectrumBounds = getBounds$1(spectrum);
|
|
var componentMinEdge = getBoundsProperty(componentBounds, top);
|
|
var componentMaxEdge = getBoundsProperty(componentBounds, bottom);
|
|
var spectrumMinEdge = getBoundsProperty(spectrumBounds, top);
|
|
return getCenterOffsetOf(componentMinEdge, componentMaxEdge, spectrumMinEdge);
|
|
};
|
|
|
|
var fireSliderChange$2 = function (spectrum, value) {
|
|
emitWith(spectrum, sliderChangeEvent(), { value: value });
|
|
};
|
|
var sliderValue$2 = function (x) {
|
|
return { x: x };
|
|
};
|
|
var findValueOfOffset$1 = function (spectrum, detail, left) {
|
|
var args = {
|
|
min: minX(detail),
|
|
max: maxX(detail),
|
|
range: xRange(detail),
|
|
value: left,
|
|
step: step(detail),
|
|
snap: snap(detail),
|
|
snapStart: snapStart(detail),
|
|
rounded: rounded(detail),
|
|
hasMinEdge: hasLEdge(detail),
|
|
hasMaxEdge: hasREdge(detail),
|
|
minBound: getMinXBounds(spectrum),
|
|
maxBound: getMaxXBounds(spectrum),
|
|
screenRange: getXScreenRange(spectrum)
|
|
};
|
|
return findValueOf(args);
|
|
};
|
|
var setValueFrom$2 = function (spectrum, detail, value) {
|
|
var xValue = findValueOfOffset$1(spectrum, detail, value);
|
|
var sliderVal = sliderValue$2(xValue);
|
|
fireSliderChange$2(spectrum, sliderVal);
|
|
return xValue;
|
|
};
|
|
var setToMin$2 = function (spectrum, detail) {
|
|
var min = minX(detail);
|
|
fireSliderChange$2(spectrum, sliderValue$2(min));
|
|
};
|
|
var setToMax$2 = function (spectrum, detail) {
|
|
var max = maxX(detail);
|
|
fireSliderChange$2(spectrum, sliderValue$2(max));
|
|
};
|
|
var moveBy$2 = function (direction, spectrum, detail) {
|
|
var f = direction > 0 ? increaseBy : reduceBy;
|
|
var xValue = f(currentValue(detail).x, minX(detail), maxX(detail), step(detail));
|
|
fireSliderChange$2(spectrum, sliderValue$2(xValue));
|
|
return Optional.some(xValue);
|
|
};
|
|
var handleMovement$2 = function (direction) {
|
|
return function (spectrum, detail) {
|
|
return moveBy$2(direction, spectrum, detail).map(always);
|
|
};
|
|
};
|
|
var getValueFromEvent$2 = function (simulatedEvent) {
|
|
var pos = getEventSource(simulatedEvent);
|
|
return pos.map(function (p) {
|
|
return p.left;
|
|
});
|
|
};
|
|
var findOffsetOfValue$1 = function (spectrum, detail, value, minEdge, maxEdge) {
|
|
var minOffset = 0;
|
|
var maxOffset = getXScreenRange(spectrum);
|
|
var centerMinEdge = minEdge.bind(function (edge) {
|
|
return Optional.some(getXCenterOffSetOf(edge, spectrum));
|
|
}).getOr(minOffset);
|
|
var centerMaxEdge = maxEdge.bind(function (edge) {
|
|
return Optional.some(getXCenterOffSetOf(edge, spectrum));
|
|
}).getOr(maxOffset);
|
|
var args = {
|
|
min: minX(detail),
|
|
max: maxX(detail),
|
|
range: xRange(detail),
|
|
value: value,
|
|
hasMinEdge: hasLEdge(detail),
|
|
hasMaxEdge: hasREdge(detail),
|
|
minBound: getMinXBounds(spectrum),
|
|
minOffset: minOffset,
|
|
maxBound: getMaxXBounds(spectrum),
|
|
maxOffset: maxOffset,
|
|
centerMinEdge: centerMinEdge,
|
|
centerMaxEdge: centerMaxEdge
|
|
};
|
|
return findOffsetOfValue$2(args);
|
|
};
|
|
var findPositionOfValue$1 = function (slider, spectrum, value, minEdge, maxEdge, detail) {
|
|
var offset = findOffsetOfValue$1(spectrum, detail, value, minEdge, maxEdge);
|
|
return getMinXBounds(spectrum) - getMinXBounds(slider) + offset;
|
|
};
|
|
var setPositionFromValue$2 = function (slider, thumb, detail, edges) {
|
|
var value = currentValue(detail);
|
|
var pos = findPositionOfValue$1(slider, edges.getSpectrum(slider), value.x, edges.getLeftEdge(slider), edges.getRightEdge(slider), detail);
|
|
var thumbRadius = get$5(thumb.element) / 2;
|
|
set$5(thumb.element, 'left', pos - thumbRadius + 'px');
|
|
};
|
|
var onLeft$2 = handleMovement$2(-1);
|
|
var onRight$2 = handleMovement$2(1);
|
|
var onUp$2 = Optional.none;
|
|
var onDown$2 = Optional.none;
|
|
var edgeActions$2 = {
|
|
'top-left': Optional.none(),
|
|
'top': Optional.none(),
|
|
'top-right': Optional.none(),
|
|
'right': Optional.some(setToREdge),
|
|
'bottom-right': Optional.none(),
|
|
'bottom': Optional.none(),
|
|
'bottom-left': Optional.none(),
|
|
'left': Optional.some(setToLEdge)
|
|
};
|
|
|
|
var HorizontalModel = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setValueFrom: setValueFrom$2,
|
|
setToMin: setToMin$2,
|
|
setToMax: setToMax$2,
|
|
findValueOfOffset: findValueOfOffset$1,
|
|
getValueFromEvent: getValueFromEvent$2,
|
|
findPositionOfValue: findPositionOfValue$1,
|
|
setPositionFromValue: setPositionFromValue$2,
|
|
onLeft: onLeft$2,
|
|
onRight: onRight$2,
|
|
onUp: onUp$2,
|
|
onDown: onDown$2,
|
|
edgeActions: edgeActions$2
|
|
});
|
|
|
|
var fireSliderChange$1 = function (spectrum, value) {
|
|
emitWith(spectrum, sliderChangeEvent(), { value: value });
|
|
};
|
|
var sliderValue$1 = function (y) {
|
|
return { y: y };
|
|
};
|
|
var findValueOfOffset = function (spectrum, detail, top) {
|
|
var args = {
|
|
min: minY(detail),
|
|
max: maxY(detail),
|
|
range: yRange(detail),
|
|
value: top,
|
|
step: step(detail),
|
|
snap: snap(detail),
|
|
snapStart: snapStart(detail),
|
|
rounded: rounded(detail),
|
|
hasMinEdge: hasTEdge(detail),
|
|
hasMaxEdge: hasBEdge(detail),
|
|
minBound: getMinYBounds(spectrum),
|
|
maxBound: getMaxYBounds(spectrum),
|
|
screenRange: getYScreenRange(spectrum)
|
|
};
|
|
return findValueOf(args);
|
|
};
|
|
var setValueFrom$1 = function (spectrum, detail, value) {
|
|
var yValue = findValueOfOffset(spectrum, detail, value);
|
|
var sliderVal = sliderValue$1(yValue);
|
|
fireSliderChange$1(spectrum, sliderVal);
|
|
return yValue;
|
|
};
|
|
var setToMin$1 = function (spectrum, detail) {
|
|
var min = minY(detail);
|
|
fireSliderChange$1(spectrum, sliderValue$1(min));
|
|
};
|
|
var setToMax$1 = function (spectrum, detail) {
|
|
var max = maxY(detail);
|
|
fireSliderChange$1(spectrum, sliderValue$1(max));
|
|
};
|
|
var moveBy$1 = function (direction, spectrum, detail) {
|
|
var f = direction > 0 ? increaseBy : reduceBy;
|
|
var yValue = f(currentValue(detail).y, minY(detail), maxY(detail), step(detail));
|
|
fireSliderChange$1(spectrum, sliderValue$1(yValue));
|
|
return Optional.some(yValue);
|
|
};
|
|
var handleMovement$1 = function (direction) {
|
|
return function (spectrum, detail) {
|
|
return moveBy$1(direction, spectrum, detail).map(always);
|
|
};
|
|
};
|
|
var getValueFromEvent$1 = function (simulatedEvent) {
|
|
var pos = getEventSource(simulatedEvent);
|
|
return pos.map(function (p) {
|
|
return p.top;
|
|
});
|
|
};
|
|
var findOffsetOfValue = function (spectrum, detail, value, minEdge, maxEdge) {
|
|
var minOffset = 0;
|
|
var maxOffset = getYScreenRange(spectrum);
|
|
var centerMinEdge = minEdge.bind(function (edge) {
|
|
return Optional.some(getYCenterOffSetOf(edge, spectrum));
|
|
}).getOr(minOffset);
|
|
var centerMaxEdge = maxEdge.bind(function (edge) {
|
|
return Optional.some(getYCenterOffSetOf(edge, spectrum));
|
|
}).getOr(maxOffset);
|
|
var args = {
|
|
min: minY(detail),
|
|
max: maxY(detail),
|
|
range: yRange(detail),
|
|
value: value,
|
|
hasMinEdge: hasTEdge(detail),
|
|
hasMaxEdge: hasBEdge(detail),
|
|
minBound: getMinYBounds(spectrum),
|
|
minOffset: minOffset,
|
|
maxBound: getMaxYBounds(spectrum),
|
|
maxOffset: maxOffset,
|
|
centerMinEdge: centerMinEdge,
|
|
centerMaxEdge: centerMaxEdge
|
|
};
|
|
return findOffsetOfValue$2(args);
|
|
};
|
|
var findPositionOfValue = function (slider, spectrum, value, minEdge, maxEdge, detail) {
|
|
var offset = findOffsetOfValue(spectrum, detail, value, minEdge, maxEdge);
|
|
return getMinYBounds(spectrum) - getMinYBounds(slider) + offset;
|
|
};
|
|
var setPositionFromValue$1 = function (slider, thumb, detail, edges) {
|
|
var value = currentValue(detail);
|
|
var pos = findPositionOfValue(slider, edges.getSpectrum(slider), value.y, edges.getTopEdge(slider), edges.getBottomEdge(slider), detail);
|
|
var thumbRadius = get$7(thumb.element) / 2;
|
|
set$5(thumb.element, 'top', pos - thumbRadius + 'px');
|
|
};
|
|
var onLeft$1 = Optional.none;
|
|
var onRight$1 = Optional.none;
|
|
var onUp$1 = handleMovement$1(-1);
|
|
var onDown$1 = handleMovement$1(1);
|
|
var edgeActions$1 = {
|
|
'top-left': Optional.none(),
|
|
'top': Optional.some(setToTEdge),
|
|
'top-right': Optional.none(),
|
|
'right': Optional.none(),
|
|
'bottom-right': Optional.none(),
|
|
'bottom': Optional.some(setToBEdge),
|
|
'bottom-left': Optional.none(),
|
|
'left': Optional.none()
|
|
};
|
|
|
|
var VerticalModel = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setValueFrom: setValueFrom$1,
|
|
setToMin: setToMin$1,
|
|
setToMax: setToMax$1,
|
|
findValueOfOffset: findValueOfOffset,
|
|
getValueFromEvent: getValueFromEvent$1,
|
|
findPositionOfValue: findPositionOfValue,
|
|
setPositionFromValue: setPositionFromValue$1,
|
|
onLeft: onLeft$1,
|
|
onRight: onRight$1,
|
|
onUp: onUp$1,
|
|
onDown: onDown$1,
|
|
edgeActions: edgeActions$1
|
|
});
|
|
|
|
var fireSliderChange = function (spectrum, value) {
|
|
emitWith(spectrum, sliderChangeEvent(), { value: value });
|
|
};
|
|
var sliderValue = function (x, y) {
|
|
return {
|
|
x: x,
|
|
y: y
|
|
};
|
|
};
|
|
var setValueFrom = function (spectrum, detail, value) {
|
|
var xValue = findValueOfOffset$1(spectrum, detail, value.left);
|
|
var yValue = findValueOfOffset(spectrum, detail, value.top);
|
|
var val = sliderValue(xValue, yValue);
|
|
fireSliderChange(spectrum, val);
|
|
return val;
|
|
};
|
|
var moveBy = function (direction, isVerticalMovement, spectrum, detail) {
|
|
var f = direction > 0 ? increaseBy : reduceBy;
|
|
var xValue = isVerticalMovement ? currentValue(detail).x : f(currentValue(detail).x, minX(detail), maxX(detail), step(detail));
|
|
var yValue = !isVerticalMovement ? currentValue(detail).y : f(currentValue(detail).y, minY(detail), maxY(detail), step(detail));
|
|
fireSliderChange(spectrum, sliderValue(xValue, yValue));
|
|
return Optional.some(xValue);
|
|
};
|
|
var handleMovement = function (direction, isVerticalMovement) {
|
|
return function (spectrum, detail) {
|
|
return moveBy(direction, isVerticalMovement, spectrum, detail).map(always);
|
|
};
|
|
};
|
|
var setToMin = function (spectrum, detail) {
|
|
var mX = minX(detail);
|
|
var mY = minY(detail);
|
|
fireSliderChange(spectrum, sliderValue(mX, mY));
|
|
};
|
|
var setToMax = function (spectrum, detail) {
|
|
var mX = maxX(detail);
|
|
var mY = maxY(detail);
|
|
fireSliderChange(spectrum, sliderValue(mX, mY));
|
|
};
|
|
var getValueFromEvent = function (simulatedEvent) {
|
|
return getEventSource(simulatedEvent);
|
|
};
|
|
var setPositionFromValue = function (slider, thumb, detail, edges) {
|
|
var value = currentValue(detail);
|
|
var xPos = findPositionOfValue$1(slider, edges.getSpectrum(slider), value.x, edges.getLeftEdge(slider), edges.getRightEdge(slider), detail);
|
|
var yPos = findPositionOfValue(slider, edges.getSpectrum(slider), value.y, edges.getTopEdge(slider), edges.getBottomEdge(slider), detail);
|
|
var thumbXRadius = get$5(thumb.element) / 2;
|
|
var thumbYRadius = get$7(thumb.element) / 2;
|
|
set$5(thumb.element, 'left', xPos - thumbXRadius + 'px');
|
|
set$5(thumb.element, 'top', yPos - thumbYRadius + 'px');
|
|
};
|
|
var onLeft = handleMovement(-1, false);
|
|
var onRight = handleMovement(1, false);
|
|
var onUp = handleMovement(-1, true);
|
|
var onDown = handleMovement(1, true);
|
|
var edgeActions = {
|
|
'top-left': Optional.some(setToTLEdgeXY),
|
|
'top': Optional.some(setToTEdgeXY),
|
|
'top-right': Optional.some(setToTREdgeXY),
|
|
'right': Optional.some(setToREdgeXY),
|
|
'bottom-right': Optional.some(setToBREdgeXY),
|
|
'bottom': Optional.some(setToBEdgeXY),
|
|
'bottom-left': Optional.some(setToBLEdgeXY),
|
|
'left': Optional.some(setToLEdgeXY)
|
|
};
|
|
|
|
var TwoDModel = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
setValueFrom: setValueFrom,
|
|
setToMin: setToMin,
|
|
setToMax: setToMax,
|
|
getValueFromEvent: getValueFromEvent,
|
|
setPositionFromValue: setPositionFromValue,
|
|
onLeft: onLeft,
|
|
onRight: onRight,
|
|
onUp: onUp,
|
|
onDown: onDown,
|
|
edgeActions: edgeActions
|
|
});
|
|
|
|
var SliderSchema = [
|
|
defaulted('stepSize', 1),
|
|
defaulted('onChange', noop),
|
|
defaulted('onChoose', noop),
|
|
defaulted('onInit', noop),
|
|
defaulted('onDragStart', noop),
|
|
defaulted('onDragEnd', noop),
|
|
defaulted('snapToGrid', false),
|
|
defaulted('rounded', true),
|
|
option('snapStart'),
|
|
requiredOf('model', choose$1('mode', {
|
|
x: [
|
|
defaulted('minX', 0),
|
|
defaulted('maxX', 100),
|
|
customField('value', function (spec) {
|
|
return Cell(spec.mode.minX);
|
|
}),
|
|
required$1('getInitialValue'),
|
|
output('manager', HorizontalModel)
|
|
],
|
|
y: [
|
|
defaulted('minY', 0),
|
|
defaulted('maxY', 100),
|
|
customField('value', function (spec) {
|
|
return Cell(spec.mode.minY);
|
|
}),
|
|
required$1('getInitialValue'),
|
|
output('manager', VerticalModel)
|
|
],
|
|
xy: [
|
|
defaulted('minX', 0),
|
|
defaulted('maxX', 100),
|
|
defaulted('minY', 0),
|
|
defaulted('maxY', 100),
|
|
customField('value', function (spec) {
|
|
return Cell({
|
|
x: spec.mode.minX,
|
|
y: spec.mode.minY
|
|
});
|
|
}),
|
|
required$1('getInitialValue'),
|
|
output('manager', TwoDModel)
|
|
]
|
|
})),
|
|
field$1('sliderBehaviours', [
|
|
Keying,
|
|
Representing
|
|
]),
|
|
customField('mouseIsDown', function () {
|
|
return Cell(false);
|
|
})
|
|
];
|
|
|
|
var mouseReleased = constant$1('mouse.released');
|
|
|
|
var sketch$9 = function (detail, components, _spec, _externals) {
|
|
var _a;
|
|
var getThumb = function (component) {
|
|
return getPartOrDie(component, detail, 'thumb');
|
|
};
|
|
var getSpectrum = function (component) {
|
|
return getPartOrDie(component, detail, 'spectrum');
|
|
};
|
|
var getLeftEdge = function (component) {
|
|
return getPart(component, detail, 'left-edge');
|
|
};
|
|
var getRightEdge = function (component) {
|
|
return getPart(component, detail, 'right-edge');
|
|
};
|
|
var getTopEdge = function (component) {
|
|
return getPart(component, detail, 'top-edge');
|
|
};
|
|
var getBottomEdge = function (component) {
|
|
return getPart(component, detail, 'bottom-edge');
|
|
};
|
|
var modelDetail = detail.model;
|
|
var model = modelDetail.manager;
|
|
var refresh = function (slider, thumb) {
|
|
model.setPositionFromValue(slider, thumb, detail, {
|
|
getLeftEdge: getLeftEdge,
|
|
getRightEdge: getRightEdge,
|
|
getTopEdge: getTopEdge,
|
|
getBottomEdge: getBottomEdge,
|
|
getSpectrum: getSpectrum
|
|
});
|
|
};
|
|
var setValue = function (slider, newValue) {
|
|
modelDetail.value.set(newValue);
|
|
var thumb = getThumb(slider);
|
|
refresh(slider, thumb);
|
|
};
|
|
var changeValue = function (slider, newValue) {
|
|
setValue(slider, newValue);
|
|
var thumb = getThumb(slider);
|
|
detail.onChange(slider, thumb, newValue);
|
|
return Optional.some(true);
|
|
};
|
|
var resetToMin = function (slider) {
|
|
model.setToMin(slider, detail);
|
|
};
|
|
var resetToMax = function (slider) {
|
|
model.setToMax(slider, detail);
|
|
};
|
|
var choose = function (slider) {
|
|
var fireOnChoose = function () {
|
|
getPart(slider, detail, 'thumb').each(function (thumb) {
|
|
var value = modelDetail.value.get();
|
|
detail.onChoose(slider, thumb, value);
|
|
});
|
|
};
|
|
var wasDown = detail.mouseIsDown.get();
|
|
detail.mouseIsDown.set(false);
|
|
if (wasDown) {
|
|
fireOnChoose();
|
|
}
|
|
};
|
|
var onDragStart = function (slider, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
detail.mouseIsDown.set(true);
|
|
detail.onDragStart(slider, getThumb(slider));
|
|
};
|
|
var onDragEnd = function (slider, simulatedEvent) {
|
|
simulatedEvent.stop();
|
|
detail.onDragEnd(slider, getThumb(slider));
|
|
choose(slider);
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.sliderBehaviours, [
|
|
Keying.config({
|
|
mode: 'special',
|
|
focusIn: function (slider) {
|
|
return getPart(slider, detail, 'spectrum').map(Keying.focusIn).map(always);
|
|
}
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (_) {
|
|
return modelDetail.value.get();
|
|
}
|
|
}
|
|
}),
|
|
Receiving.config({ channels: (_a = {}, _a[mouseReleased()] = { onReceive: choose }, _a) })
|
|
]),
|
|
events: derive$3([
|
|
run(sliderChangeEvent(), function (slider, simulatedEvent) {
|
|
changeValue(slider, simulatedEvent.event.value);
|
|
}),
|
|
runOnAttached(function (slider, _simulatedEvent) {
|
|
var getInitial = modelDetail.getInitialValue();
|
|
modelDetail.value.set(getInitial);
|
|
var thumb = getThumb(slider);
|
|
refresh(slider, thumb);
|
|
var spectrum = getSpectrum(slider);
|
|
detail.onInit(slider, thumb, spectrum, modelDetail.value.get());
|
|
}),
|
|
run(touchstart(), onDragStart),
|
|
run(touchend(), onDragEnd),
|
|
run(mousedown(), onDragStart),
|
|
run(mouseup(), onDragEnd)
|
|
]),
|
|
apis: {
|
|
resetToMin: resetToMin,
|
|
resetToMax: resetToMax,
|
|
setValue: setValue,
|
|
refresh: refresh
|
|
},
|
|
domModification: { styles: { position: 'relative' } }
|
|
};
|
|
};
|
|
|
|
var Slider = composite({
|
|
name: 'Slider',
|
|
configFields: SliderSchema,
|
|
partFields: SliderParts,
|
|
factory: sketch$9,
|
|
apis: {
|
|
setValue: function (apis, slider, value) {
|
|
apis.setValue(slider, value);
|
|
},
|
|
resetToMin: function (apis, slider) {
|
|
apis.resetToMin(slider);
|
|
},
|
|
resetToMax: function (apis, slider) {
|
|
apis.resetToMax(slider);
|
|
},
|
|
refresh: function (apis, slider) {
|
|
apis.refresh(slider);
|
|
}
|
|
}
|
|
});
|
|
|
|
var button = function (realm, clazz, makeItems, editor) {
|
|
return forToolbar(clazz, function () {
|
|
var items = makeItems();
|
|
realm.setContextToolbar([{
|
|
label: clazz + ' group',
|
|
items: items
|
|
}]);
|
|
}, {}, editor);
|
|
};
|
|
|
|
var BLACK = -1;
|
|
var makeSlider$1 = function (spec$1) {
|
|
var getColor = function (hue) {
|
|
if (hue < 0) {
|
|
return 'black';
|
|
} else if (hue > 360) {
|
|
return 'white';
|
|
} else {
|
|
return 'hsl(' + hue + ', 100%, 50%)';
|
|
}
|
|
};
|
|
var onInit = function (slider, thumb, spectrum, value) {
|
|
var color = getColor(value.x());
|
|
set$5(thumb.element, 'background-color', color);
|
|
};
|
|
var onChange = function (slider, thumb, value) {
|
|
var color = getColor(value.x());
|
|
set$5(thumb.element, 'background-color', color);
|
|
spec$1.onChange(slider, thumb, color);
|
|
};
|
|
return Slider.sketch({
|
|
dom: dom$1('<div class="${prefix}-slider ${prefix}-hue-slider-container"></div>'),
|
|
components: [
|
|
Slider.parts['left-edge'](spec('<div class="${prefix}-hue-slider-black"></div>')),
|
|
Slider.parts.spectrum({
|
|
dom: dom$1('<div class="${prefix}-slider-gradient-container"></div>'),
|
|
components: [spec('<div class="${prefix}-slider-gradient"></div>')],
|
|
behaviours: derive$2([Toggling.config({ toggleClass: resolve('thumb-active') })])
|
|
}),
|
|
Slider.parts['right-edge'](spec('<div class="${prefix}-hue-slider-white"></div>')),
|
|
Slider.parts.thumb({
|
|
dom: dom$1('<div class="${prefix}-slider-thumb"></div>'),
|
|
behaviours: derive$2([Toggling.config({ toggleClass: resolve('thumb-active') })])
|
|
})
|
|
],
|
|
onChange: onChange,
|
|
onDragStart: function (slider, thumb) {
|
|
Toggling.on(thumb);
|
|
},
|
|
onDragEnd: function (slider, thumb) {
|
|
Toggling.off(thumb);
|
|
},
|
|
onInit: onInit,
|
|
stepSize: 10,
|
|
model: {
|
|
mode: 'x',
|
|
minX: 0,
|
|
maxX: 360,
|
|
getInitialValue: function () {
|
|
return { x: spec$1.getInitialValue() };
|
|
}
|
|
},
|
|
sliderBehaviours: derive$2([orientation(Slider.refresh)])
|
|
});
|
|
};
|
|
var makeItems$1 = function (spec) {
|
|
return [makeSlider$1(spec)];
|
|
};
|
|
var sketch$8 = function (realm, editor) {
|
|
var spec = {
|
|
onChange: function (slider, thumb, color) {
|
|
editor.undoManager.transact(function () {
|
|
editor.formatter.apply('forecolor', { value: color });
|
|
editor.nodeChanged();
|
|
});
|
|
},
|
|
getInitialValue: constant$1(BLACK)
|
|
};
|
|
return button(realm, 'color-levels', function () {
|
|
return makeItems$1(spec);
|
|
}, editor);
|
|
};
|
|
|
|
var candidatesArray = [
|
|
'9px',
|
|
'10px',
|
|
'11px',
|
|
'12px',
|
|
'14px',
|
|
'16px',
|
|
'18px',
|
|
'20px',
|
|
'24px',
|
|
'32px',
|
|
'36px'
|
|
];
|
|
var defaultSize = 'medium';
|
|
var defaultIndex = 2;
|
|
var indexToSize = function (index) {
|
|
return Optional.from(candidatesArray[index]);
|
|
};
|
|
var sizeToIndex = function (size) {
|
|
return findIndex$1(candidatesArray, function (v) {
|
|
return v === size;
|
|
});
|
|
};
|
|
var getRawOrComputed = function (isRoot, rawStart) {
|
|
var optStart = isElement(rawStart) ? Optional.some(rawStart) : parent(rawStart).filter(isElement);
|
|
return optStart.map(function (start) {
|
|
var inline = closest$2(start, function (elem) {
|
|
return getRaw(elem, 'font-size').isSome();
|
|
}, isRoot).bind(function (elem) {
|
|
return getRaw(elem, 'font-size');
|
|
});
|
|
return inline.getOrThunk(function () {
|
|
return get$8(start, 'font-size');
|
|
});
|
|
}).getOr('');
|
|
};
|
|
var getSize = function (editor) {
|
|
var node = editor.selection.getStart();
|
|
var elem = SugarElement.fromDom(node);
|
|
var root = SugarElement.fromDom(editor.getBody());
|
|
var isRoot = function (e) {
|
|
return eq(root, e);
|
|
};
|
|
var elemSize = getRawOrComputed(isRoot, elem);
|
|
return find$2(candidatesArray, function (size) {
|
|
return elemSize === size;
|
|
}).getOr(defaultSize);
|
|
};
|
|
var applySize = function (editor, value) {
|
|
var currentValue = getSize(editor);
|
|
if (currentValue !== value) {
|
|
editor.execCommand('fontSize', false, value);
|
|
}
|
|
};
|
|
var get$4 = function (editor) {
|
|
var size = getSize(editor);
|
|
return sizeToIndex(size).getOr(defaultIndex);
|
|
};
|
|
var apply = function (editor, index) {
|
|
indexToSize(index).each(function (size) {
|
|
applySize(editor, size);
|
|
});
|
|
};
|
|
var candidates = constant$1(candidatesArray);
|
|
|
|
var schema$9 = objOfOnly([
|
|
required$1('getInitialValue'),
|
|
required$1('onChange'),
|
|
required$1('category'),
|
|
required$1('sizes')
|
|
]);
|
|
var sketch$7 = function (rawSpec) {
|
|
var spec$1 = asRawOrDie$1('SizeSlider', schema$9, rawSpec);
|
|
var isValidValue = function (valueIndex) {
|
|
return valueIndex >= 0 && valueIndex < spec$1.sizes.length;
|
|
};
|
|
var onChange = function (slider, thumb, valueIndex) {
|
|
var index = valueIndex.x();
|
|
if (isValidValue(index)) {
|
|
spec$1.onChange(index);
|
|
}
|
|
};
|
|
return Slider.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [
|
|
resolve('slider-' + spec$1.category + '-size-container'),
|
|
resolve('slider'),
|
|
resolve('slider-size-container')
|
|
]
|
|
},
|
|
onChange: onChange,
|
|
onDragStart: function (slider, thumb) {
|
|
Toggling.on(thumb);
|
|
},
|
|
onDragEnd: function (slider, thumb) {
|
|
Toggling.off(thumb);
|
|
},
|
|
model: {
|
|
mode: 'x',
|
|
minX: 0,
|
|
maxX: spec$1.sizes.length - 1,
|
|
getInitialValue: function () {
|
|
return { x: spec$1.getInitialValue() };
|
|
}
|
|
},
|
|
stepSize: 1,
|
|
snapToGrid: true,
|
|
sliderBehaviours: derive$2([orientation(Slider.refresh)]),
|
|
components: [
|
|
Slider.parts.spectrum({
|
|
dom: dom$1('<div class="${prefix}-slider-size-container"></div>'),
|
|
components: [spec('<div class="${prefix}-slider-size-line"></div>')]
|
|
}),
|
|
Slider.parts.thumb({
|
|
dom: dom$1('<div class="${prefix}-slider-thumb"></div>'),
|
|
behaviours: derive$2([Toggling.config({ toggleClass: resolve('thumb-active') })])
|
|
})
|
|
]
|
|
});
|
|
};
|
|
|
|
var sizes = candidates();
|
|
var makeSlider = function (spec) {
|
|
return sketch$7({
|
|
onChange: spec.onChange,
|
|
sizes: sizes,
|
|
category: 'font',
|
|
getInitialValue: spec.getInitialValue
|
|
});
|
|
};
|
|
var makeItems = function (spec$1) {
|
|
return [
|
|
spec('<span class="${prefix}-toolbar-button ${prefix}-icon-small-font ${prefix}-icon"></span>'),
|
|
makeSlider(spec$1),
|
|
spec('<span class="${prefix}-toolbar-button ${prefix}-icon-large-font ${prefix}-icon"></span>')
|
|
];
|
|
};
|
|
var sketch$6 = function (realm, editor) {
|
|
var spec = {
|
|
onChange: function (value) {
|
|
apply(editor, value);
|
|
},
|
|
getInitialValue: function () {
|
|
return get$4(editor);
|
|
}
|
|
};
|
|
return button(realm, 'font-size', function () {
|
|
return makeItems(spec);
|
|
}, editor);
|
|
};
|
|
|
|
var record = function (spec) {
|
|
var uid = isSketchSpec$1(spec) && hasNonNullableKey(spec, 'uid') ? spec.uid : generate$2('memento');
|
|
var get = function (anyInSystem) {
|
|
return anyInSystem.getSystem().getByUid(uid).getOrDie();
|
|
};
|
|
var getOpt = function (anyInSystem) {
|
|
return anyInSystem.getSystem().getByUid(uid).toOptional();
|
|
};
|
|
var asSpec = function () {
|
|
return __assign(__assign({}, spec), { uid: uid });
|
|
};
|
|
return {
|
|
get: get,
|
|
getOpt: getOpt,
|
|
asSpec: asSpec
|
|
};
|
|
};
|
|
|
|
var exports$1 = {}, module = { exports: exports$1 };
|
|
(function (define, exports, module, require) {
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EphoxContactWrapper = factory());
|
|
}(this, function () {
|
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
var promise = { exports: {} };
|
|
(function (module) {
|
|
(function (root) {
|
|
var setTimeoutFunc = setTimeout;
|
|
function noop() {
|
|
}
|
|
function bind(fn, thisArg) {
|
|
return function () {
|
|
fn.apply(thisArg, arguments);
|
|
};
|
|
}
|
|
function Promise(fn) {
|
|
if (typeof this !== 'object')
|
|
throw new TypeError('Promises must be constructed via new');
|
|
if (typeof fn !== 'function')
|
|
throw new TypeError('not a function');
|
|
this._state = 0;
|
|
this._handled = false;
|
|
this._value = undefined;
|
|
this._deferreds = [];
|
|
doResolve(fn, this);
|
|
}
|
|
function handle(self, deferred) {
|
|
while (self._state === 3) {
|
|
self = self._value;
|
|
}
|
|
if (self._state === 0) {
|
|
self._deferreds.push(deferred);
|
|
return;
|
|
}
|
|
self._handled = true;
|
|
Promise._immediateFn(function () {
|
|
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
|
|
if (cb === null) {
|
|
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
|
|
return;
|
|
}
|
|
var ret;
|
|
try {
|
|
ret = cb(self._value);
|
|
} catch (e) {
|
|
reject(deferred.promise, e);
|
|
return;
|
|
}
|
|
resolve(deferred.promise, ret);
|
|
});
|
|
}
|
|
function resolve(self, newValue) {
|
|
try {
|
|
if (newValue === self)
|
|
throw new TypeError('A promise cannot be resolved with itself.');
|
|
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
|
var then = newValue.then;
|
|
if (newValue instanceof Promise) {
|
|
self._state = 3;
|
|
self._value = newValue;
|
|
finale(self);
|
|
return;
|
|
} else if (typeof then === 'function') {
|
|
doResolve(bind(then, newValue), self);
|
|
return;
|
|
}
|
|
}
|
|
self._state = 1;
|
|
self._value = newValue;
|
|
finale(self);
|
|
} catch (e) {
|
|
reject(self, e);
|
|
}
|
|
}
|
|
function reject(self, newValue) {
|
|
self._state = 2;
|
|
self._value = newValue;
|
|
finale(self);
|
|
}
|
|
function finale(self) {
|
|
if (self._state === 2 && self._deferreds.length === 0) {
|
|
Promise._immediateFn(function () {
|
|
if (!self._handled) {
|
|
Promise._unhandledRejectionFn(self._value);
|
|
}
|
|
});
|
|
}
|
|
for (var i = 0, len = self._deferreds.length; i < len; i++) {
|
|
handle(self, self._deferreds[i]);
|
|
}
|
|
self._deferreds = null;
|
|
}
|
|
function Handler(onFulfilled, onRejected, promise) {
|
|
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
|
|
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
|
|
this.promise = promise;
|
|
}
|
|
function doResolve(fn, self) {
|
|
var done = false;
|
|
try {
|
|
fn(function (value) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
resolve(self, value);
|
|
}, function (reason) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
reject(self, reason);
|
|
});
|
|
} catch (ex) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
reject(self, ex);
|
|
}
|
|
}
|
|
Promise.prototype['catch'] = function (onRejected) {
|
|
return this.then(null, onRejected);
|
|
};
|
|
Promise.prototype.then = function (onFulfilled, onRejected) {
|
|
var prom = new this.constructor(noop);
|
|
handle(this, new Handler(onFulfilled, onRejected, prom));
|
|
return prom;
|
|
};
|
|
Promise.all = function (arr) {
|
|
var args = Array.prototype.slice.call(arr);
|
|
return new Promise(function (resolve, reject) {
|
|
if (args.length === 0)
|
|
return resolve([]);
|
|
var remaining = args.length;
|
|
function res(i, val) {
|
|
try {
|
|
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
var then = val.then;
|
|
if (typeof then === 'function') {
|
|
then.call(val, function (val) {
|
|
res(i, val);
|
|
}, reject);
|
|
return;
|
|
}
|
|
}
|
|
args[i] = val;
|
|
if (--remaining === 0) {
|
|
resolve(args);
|
|
}
|
|
} catch (ex) {
|
|
reject(ex);
|
|
}
|
|
}
|
|
for (var i = 0; i < args.length; i++) {
|
|
res(i, args[i]);
|
|
}
|
|
});
|
|
};
|
|
Promise.resolve = function (value) {
|
|
if (value && typeof value === 'object' && value.constructor === Promise) {
|
|
return value;
|
|
}
|
|
return new Promise(function (resolve) {
|
|
resolve(value);
|
|
});
|
|
};
|
|
Promise.reject = function (value) {
|
|
return new Promise(function (resolve, reject) {
|
|
reject(value);
|
|
});
|
|
};
|
|
Promise.race = function (values) {
|
|
return new Promise(function (resolve, reject) {
|
|
for (var i = 0, len = values.length; i < len; i++) {
|
|
values[i].then(resolve, reject);
|
|
}
|
|
});
|
|
};
|
|
Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {
|
|
setImmediate(fn);
|
|
} : function (fn) {
|
|
setTimeoutFunc(fn, 0);
|
|
};
|
|
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
|
|
if (typeof console !== 'undefined' && console) {
|
|
console.warn('Possible Unhandled Promise Rejection:', err);
|
|
}
|
|
};
|
|
Promise._setImmediateFn = function _setImmediateFn(fn) {
|
|
Promise._immediateFn = fn;
|
|
};
|
|
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
|
|
Promise._unhandledRejectionFn = fn;
|
|
};
|
|
if (module.exports) {
|
|
module.exports = Promise;
|
|
} else if (!root.Promise) {
|
|
root.Promise = Promise;
|
|
}
|
|
}(commonjsGlobal));
|
|
}(promise));
|
|
var promisePolyfill = promise.exports;
|
|
var Global = function () {
|
|
if (typeof window !== 'undefined') {
|
|
return window;
|
|
} else {
|
|
return Function('return this;')();
|
|
}
|
|
}();
|
|
var promisePolyfill_1 = { boltExport: Global.Promise || promisePolyfill };
|
|
return promisePolyfill_1;
|
|
}));
|
|
}(undefined, exports$1, module));
|
|
var Promise$1 = module.exports.boltExport;
|
|
|
|
var blobToDataUri = function (blob) {
|
|
return new Promise$1(function (resolve) {
|
|
var reader = new FileReader();
|
|
reader.onloadend = function () {
|
|
resolve(reader.result);
|
|
};
|
|
reader.readAsDataURL(blob);
|
|
});
|
|
};
|
|
var blobToBase64$1 = function (blob) {
|
|
return blobToDataUri(blob).then(function (dataUri) {
|
|
return dataUri.split(',')[1];
|
|
});
|
|
};
|
|
|
|
var blobToBase64 = function (blob) {
|
|
return blobToBase64$1(blob);
|
|
};
|
|
|
|
var addImage = function (editor, blob) {
|
|
blobToBase64(blob).then(function (base64) {
|
|
editor.undoManager.transact(function () {
|
|
var cache = editor.editorUpload.blobCache;
|
|
var info = cache.create(generate$4('mceu'), blob, base64);
|
|
cache.add(info);
|
|
var img = editor.dom.createHTML('img', { src: info.blobUri() });
|
|
editor.insertContent(img);
|
|
});
|
|
});
|
|
};
|
|
var extractBlob = function (simulatedEvent) {
|
|
var event = simulatedEvent.event.raw;
|
|
var files = event.target.files || event.dataTransfer.files;
|
|
return Optional.from(files[0]);
|
|
};
|
|
var sketch$5 = function (editor) {
|
|
var pickerDom = {
|
|
tag: 'input',
|
|
attributes: {
|
|
accept: 'image/*',
|
|
type: 'file',
|
|
title: ''
|
|
},
|
|
styles: {
|
|
visibility: 'hidden',
|
|
position: 'absolute'
|
|
}
|
|
};
|
|
var memPicker = record({
|
|
dom: pickerDom,
|
|
events: derive$3([
|
|
cutter(click()),
|
|
run(change(), function (picker, simulatedEvent) {
|
|
extractBlob(simulatedEvent).each(function (blob) {
|
|
addImage(editor, blob);
|
|
});
|
|
})
|
|
])
|
|
});
|
|
return Button.sketch({
|
|
dom: getToolbarIconButton('image', editor),
|
|
components: [memPicker.asSpec()],
|
|
action: function (button) {
|
|
var picker = memPicker.get(button);
|
|
picker.element.dom.click();
|
|
}
|
|
});
|
|
};
|
|
|
|
var get$3 = function (element) {
|
|
return element.dom.textContent;
|
|
};
|
|
var set$3 = function (element, value) {
|
|
element.dom.textContent = value;
|
|
};
|
|
|
|
var isNotEmpty = function (val) {
|
|
return val.length > 0;
|
|
};
|
|
var defaultToEmpty = function (str) {
|
|
return str === undefined || str === null ? '' : str;
|
|
};
|
|
var noLink = function (editor) {
|
|
var text = editor.selection.getContent({ format: 'text' });
|
|
return {
|
|
url: '',
|
|
text: text,
|
|
title: '',
|
|
target: '',
|
|
link: Optional.none()
|
|
};
|
|
};
|
|
var fromLink = function (link) {
|
|
var text = get$3(link);
|
|
var url = get$b(link, 'href');
|
|
var title = get$b(link, 'title');
|
|
var target = get$b(link, 'target');
|
|
return {
|
|
url: defaultToEmpty(url),
|
|
text: text !== url ? defaultToEmpty(text) : '',
|
|
title: defaultToEmpty(title),
|
|
target: defaultToEmpty(target),
|
|
link: Optional.some(link)
|
|
};
|
|
};
|
|
var getInfo = function (editor) {
|
|
return query(editor).fold(function () {
|
|
return noLink(editor);
|
|
}, function (link) {
|
|
return fromLink(link);
|
|
});
|
|
};
|
|
var wasSimple = function (link) {
|
|
var prevHref = get$b(link, 'href');
|
|
var prevText = get$3(link);
|
|
return prevHref === prevText;
|
|
};
|
|
var getTextToApply = function (link, url, info) {
|
|
return info.text.toOptional().filter(isNotEmpty).fold(function () {
|
|
return wasSimple(link) ? Optional.some(url) : Optional.none();
|
|
}, Optional.some);
|
|
};
|
|
var unlinkIfRequired = function (editor, info) {
|
|
var activeLink = info.link.bind(identity);
|
|
activeLink.each(function (_link) {
|
|
editor.execCommand('unlink');
|
|
});
|
|
};
|
|
var getAttrs = function (url, info) {
|
|
var attrs = {};
|
|
attrs.href = url;
|
|
info.title.toOptional().filter(isNotEmpty).each(function (title) {
|
|
attrs.title = title;
|
|
});
|
|
info.target.toOptional().filter(isNotEmpty).each(function (target) {
|
|
attrs.target = target;
|
|
});
|
|
return attrs;
|
|
};
|
|
var applyInfo = function (editor, info) {
|
|
info.url.toOptional().filter(isNotEmpty).fold(function () {
|
|
unlinkIfRequired(editor, info);
|
|
}, function (url) {
|
|
var attrs = getAttrs(url, info);
|
|
var activeLink = info.link.bind(identity);
|
|
activeLink.fold(function () {
|
|
var text = info.text.toOptional().filter(isNotEmpty).getOr(url);
|
|
editor.insertContent(editor.dom.createHTML('a', attrs, editor.dom.encode(text)));
|
|
}, function (link) {
|
|
var text = getTextToApply(link, url, info);
|
|
setAll$1(link, attrs);
|
|
text.each(function (newText) {
|
|
set$3(link, newText);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var query = function (editor) {
|
|
var start = SugarElement.fromDom(editor.selection.getStart());
|
|
return closest$1(start, 'a');
|
|
};
|
|
|
|
var platform = detect$1();
|
|
var preserve$1 = function (f, editor) {
|
|
var rng = editor.selection.getRng();
|
|
f();
|
|
editor.selection.setRng(rng);
|
|
};
|
|
var forAndroid = function (editor, f) {
|
|
var wrapper = platform.os.isAndroid() ? preserve$1 : apply$1;
|
|
wrapper(f, editor);
|
|
};
|
|
|
|
var events$4 = function (name, eventHandlers) {
|
|
var events = derive$3(eventHandlers);
|
|
return create$5({
|
|
fields: [required$1('enabled')],
|
|
name: name,
|
|
active: { events: constant$1(events) }
|
|
});
|
|
};
|
|
var config = function (name, eventHandlers) {
|
|
var me = events$4(name, eventHandlers);
|
|
return {
|
|
key: name,
|
|
value: {
|
|
config: {},
|
|
me: me,
|
|
configAsRaw: constant$1({}),
|
|
initialConfig: {},
|
|
state: NoState
|
|
}
|
|
};
|
|
};
|
|
|
|
var getCurrent = function (component, composeConfig, _composeState) {
|
|
return composeConfig.find(component);
|
|
};
|
|
|
|
var ComposeApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
getCurrent: getCurrent
|
|
});
|
|
|
|
var ComposeSchema = [required$1('find')];
|
|
|
|
var Composing = create$5({
|
|
fields: ComposeSchema,
|
|
name: 'composing',
|
|
apis: ComposeApis
|
|
});
|
|
|
|
var factory$4 = function (detail) {
|
|
var _a = detail.dom, attributes = _a.attributes, domWithoutAttributes = __rest(_a, ['attributes']);
|
|
return {
|
|
uid: detail.uid,
|
|
dom: __assign({
|
|
tag: 'div',
|
|
attributes: __assign({ role: 'presentation' }, attributes)
|
|
}, domWithoutAttributes),
|
|
components: detail.components,
|
|
behaviours: get$6(detail.containerBehaviours),
|
|
events: detail.events,
|
|
domModification: detail.domModification,
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var Container = single({
|
|
name: 'Container',
|
|
factory: factory$4,
|
|
configFields: [
|
|
defaulted('components', []),
|
|
field$1('containerBehaviours', []),
|
|
defaulted('events', {}),
|
|
defaulted('domModification', {}),
|
|
defaulted('eventOrder', {})
|
|
]
|
|
});
|
|
|
|
var factory$3 = function (detail) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
behaviours: SketchBehaviours.augment(detail.dataBehaviours, [
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.getInitialValue()
|
|
}
|
|
}),
|
|
Composing.config({ find: Optional.some })
|
|
]),
|
|
events: derive$3([runOnAttached(function (component, _simulatedEvent) {
|
|
Representing.setValue(component, detail.getInitialValue());
|
|
})])
|
|
};
|
|
};
|
|
var DataField = single({
|
|
name: 'DataField',
|
|
factory: factory$3,
|
|
configFields: [
|
|
required$1('uid'),
|
|
required$1('dom'),
|
|
required$1('getInitialValue'),
|
|
SketchBehaviours.field('dataBehaviours', [
|
|
Representing,
|
|
Composing
|
|
])
|
|
]
|
|
});
|
|
|
|
var get$2 = function (element) {
|
|
return element.dom.value;
|
|
};
|
|
var set$2 = function (element, value) {
|
|
if (value === undefined) {
|
|
throw new Error('Value.set was undefined');
|
|
}
|
|
element.dom.value = value;
|
|
};
|
|
|
|
var schema$8 = constant$1([
|
|
option('data'),
|
|
defaulted('inputAttributes', {}),
|
|
defaulted('inputStyles', {}),
|
|
defaulted('tag', 'input'),
|
|
defaulted('inputClasses', []),
|
|
onHandler('onSetValue'),
|
|
defaulted('styles', {}),
|
|
defaulted('eventOrder', {}),
|
|
field$1('inputBehaviours', [
|
|
Representing,
|
|
Focusing
|
|
]),
|
|
defaulted('selectOnFocus', true)
|
|
]);
|
|
var focusBehaviours = function (detail) {
|
|
return derive$2([Focusing.config({
|
|
onFocus: !detail.selectOnFocus ? noop : function (component) {
|
|
var input = component.element;
|
|
var value = get$2(input);
|
|
input.dom.setSelectionRange(0, value.length);
|
|
}
|
|
})]);
|
|
};
|
|
var behaviours = function (detail) {
|
|
return __assign(__assign({}, focusBehaviours(detail)), augment(detail.inputBehaviours, [Representing.config({
|
|
store: __assign(__assign({ mode: 'manual' }, detail.data.map(function (data) {
|
|
return { initialValue: data };
|
|
}).getOr({})), {
|
|
getValue: function (input) {
|
|
return get$2(input.element);
|
|
},
|
|
setValue: function (input, data) {
|
|
var current = get$2(input.element);
|
|
if (current !== data) {
|
|
set$2(input.element, data);
|
|
}
|
|
}
|
|
}),
|
|
onSetValue: detail.onSetValue
|
|
})]));
|
|
};
|
|
var dom = function (detail) {
|
|
return {
|
|
tag: detail.tag,
|
|
attributes: __assign({ type: 'text' }, detail.inputAttributes),
|
|
styles: detail.inputStyles,
|
|
classes: detail.inputClasses
|
|
};
|
|
};
|
|
|
|
var factory$2 = function (detail, _spec) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: dom(detail),
|
|
components: [],
|
|
behaviours: behaviours(detail),
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var Input = single({
|
|
name: 'Input',
|
|
configFields: schema$8(),
|
|
factory: factory$2
|
|
});
|
|
|
|
var exhibit$2 = function (base, tabConfig) {
|
|
return nu$3({
|
|
attributes: wrapAll([{
|
|
key: tabConfig.tabAttr,
|
|
value: 'true'
|
|
}])
|
|
});
|
|
};
|
|
|
|
var ActiveTabstopping = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$2
|
|
});
|
|
|
|
var TabstopSchema = [defaulted('tabAttr', 'data-alloy-tabstop')];
|
|
|
|
var Tabstopping = create$5({
|
|
fields: TabstopSchema,
|
|
name: 'tabstopping',
|
|
active: ActiveTabstopping
|
|
});
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.I18n');
|
|
|
|
var clearInputBehaviour = 'input-clearing';
|
|
var field = function (name, placeholder) {
|
|
var inputSpec = record(Input.sketch({
|
|
inputAttributes: { placeholder: global$3.translate(placeholder) },
|
|
onSetValue: function (input, _data) {
|
|
emit(input, input$1());
|
|
},
|
|
inputBehaviours: derive$2([
|
|
Composing.config({ find: Optional.some }),
|
|
Tabstopping.config({}),
|
|
Keying.config({ mode: 'execution' })
|
|
]),
|
|
selectOnFocus: false
|
|
}));
|
|
var buttonSpec = record(Button.sketch({
|
|
dom: dom$1('<button class="${prefix}-input-container-x ${prefix}-icon-cancel-circle ${prefix}-icon"></button>'),
|
|
action: function (button) {
|
|
var input = inputSpec.get(button);
|
|
Representing.setValue(input, '');
|
|
}
|
|
}));
|
|
return {
|
|
name: name,
|
|
spec: Container.sketch({
|
|
dom: dom$1('<div class="${prefix}-input-container"></div>'),
|
|
components: [
|
|
inputSpec.asSpec(),
|
|
buttonSpec.asSpec()
|
|
],
|
|
containerBehaviours: derive$2([
|
|
Toggling.config({ toggleClass: resolve('input-container-empty') }),
|
|
Composing.config({
|
|
find: function (comp) {
|
|
return Optional.some(inputSpec.get(comp));
|
|
}
|
|
}),
|
|
config(clearInputBehaviour, [run(input$1(), function (iContainer) {
|
|
var input = inputSpec.get(iContainer);
|
|
var val = Representing.getValue(input);
|
|
var f = val.length > 0 ? Toggling.off : Toggling.on;
|
|
f(iContainer);
|
|
})])
|
|
])
|
|
})
|
|
};
|
|
};
|
|
var hidden = function (name) {
|
|
return {
|
|
name: name,
|
|
spec: DataField.sketch({
|
|
dom: {
|
|
tag: 'span',
|
|
styles: { display: 'none' }
|
|
},
|
|
getInitialValue: function () {
|
|
return Optional.none();
|
|
}
|
|
})
|
|
};
|
|
};
|
|
|
|
var nativeDisabled = [
|
|
'input',
|
|
'button',
|
|
'textarea',
|
|
'select'
|
|
];
|
|
var onLoad = function (component, disableConfig, disableState) {
|
|
var f = disableConfig.disabled() ? disable : enable;
|
|
f(component, disableConfig);
|
|
};
|
|
var hasNative = function (component, config) {
|
|
return config.useNative === true && contains$1(nativeDisabled, name$1(component.element));
|
|
};
|
|
var nativeIsDisabled = function (component) {
|
|
return has$1(component.element, 'disabled');
|
|
};
|
|
var nativeDisable = function (component) {
|
|
set$8(component.element, 'disabled', 'disabled');
|
|
};
|
|
var nativeEnable = function (component) {
|
|
remove$6(component.element, 'disabled');
|
|
};
|
|
var ariaIsDisabled = function (component) {
|
|
return get$b(component.element, 'aria-disabled') === 'true';
|
|
};
|
|
var ariaDisable = function (component) {
|
|
set$8(component.element, 'aria-disabled', 'true');
|
|
};
|
|
var ariaEnable = function (component) {
|
|
set$8(component.element, 'aria-disabled', 'false');
|
|
};
|
|
var disable = function (component, disableConfig, _disableState) {
|
|
disableConfig.disableClass.each(function (disableClass) {
|
|
add$1(component.element, disableClass);
|
|
});
|
|
var f = hasNative(component, disableConfig) ? nativeDisable : ariaDisable;
|
|
f(component);
|
|
disableConfig.onDisabled(component);
|
|
};
|
|
var enable = function (component, disableConfig, _disableState) {
|
|
disableConfig.disableClass.each(function (disableClass) {
|
|
remove$3(component.element, disableClass);
|
|
});
|
|
var f = hasNative(component, disableConfig) ? nativeEnable : ariaEnable;
|
|
f(component);
|
|
disableConfig.onEnabled(component);
|
|
};
|
|
var isDisabled = function (component, disableConfig) {
|
|
return hasNative(component, disableConfig) ? nativeIsDisabled(component) : ariaIsDisabled(component);
|
|
};
|
|
var set$1 = function (component, disableConfig, disableState, disabled) {
|
|
var f = disabled ? disable : enable;
|
|
f(component, disableConfig);
|
|
};
|
|
|
|
var DisableApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
enable: enable,
|
|
disable: disable,
|
|
isDisabled: isDisabled,
|
|
onLoad: onLoad,
|
|
set: set$1
|
|
});
|
|
|
|
var exhibit$1 = function (base, disableConfig) {
|
|
return nu$3({ classes: disableConfig.disabled() ? disableConfig.disableClass.toArray() : [] });
|
|
};
|
|
var events$3 = function (disableConfig, disableState) {
|
|
return derive$3([
|
|
abort(execute$5(), function (component, _simulatedEvent) {
|
|
return isDisabled(component, disableConfig);
|
|
}),
|
|
loadEvent(disableConfig, disableState, onLoad)
|
|
]);
|
|
};
|
|
|
|
var ActiveDisable = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit$1,
|
|
events: events$3
|
|
});
|
|
|
|
var DisableSchema = [
|
|
defaultedFunction('disabled', never),
|
|
defaulted('useNative', true),
|
|
option('disableClass'),
|
|
onHandler('onDisabled'),
|
|
onHandler('onEnabled')
|
|
];
|
|
|
|
var Disabling = create$5({
|
|
fields: DisableSchema,
|
|
name: 'disabling',
|
|
active: ActiveDisable,
|
|
apis: DisableApis
|
|
});
|
|
|
|
var owner$1 = 'form';
|
|
var schema$7 = [field$1('formBehaviours', [Representing])];
|
|
var getPartName = function (name) {
|
|
return '<alloy.field.' + name + '>';
|
|
};
|
|
var sketch$4 = function (fSpec) {
|
|
var parts = function () {
|
|
var record = [];
|
|
var field = function (name, config) {
|
|
record.push(name);
|
|
return generateOne(owner$1, getPartName(name), config);
|
|
};
|
|
return {
|
|
field: field,
|
|
record: constant$1(record)
|
|
};
|
|
}();
|
|
var spec = fSpec(parts);
|
|
var partNames = parts.record();
|
|
var fieldParts = map$2(partNames, function (n) {
|
|
return required({
|
|
name: n,
|
|
pname: getPartName(n)
|
|
});
|
|
});
|
|
return composite$1(owner$1, schema$7, fieldParts, make$4, spec);
|
|
};
|
|
var toResult = function (o, e) {
|
|
return o.fold(function () {
|
|
return Result.error(e);
|
|
}, Result.value);
|
|
};
|
|
var make$4 = function (detail, components) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.formBehaviours, [Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (form) {
|
|
var resPs = getAllParts(form, detail);
|
|
return map$1(resPs, function (resPThunk, pName) {
|
|
return resPThunk().bind(function (v) {
|
|
var opt = Composing.getCurrent(v);
|
|
return toResult(opt, new Error('Cannot find a current component to extract the value from for form part \'' + pName + '\': ' + element(v.element)));
|
|
}).map(Representing.getValue);
|
|
});
|
|
},
|
|
setValue: function (form, values) {
|
|
each(values, function (newValue, key) {
|
|
getPart(form, detail, key).each(function (wrapper) {
|
|
Composing.getCurrent(wrapper).each(function (field) {
|
|
Representing.setValue(field, newValue);
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
})]),
|
|
apis: {
|
|
getField: function (form, key) {
|
|
return getPart(form, detail, key).bind(Composing.getCurrent);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var Form = {
|
|
getField: makeApi(function (apis, component, key) {
|
|
return apis.getField(component, key);
|
|
}),
|
|
sketch: sketch$4
|
|
};
|
|
|
|
var SWIPING_LEFT = 1;
|
|
var SWIPING_RIGHT = -1;
|
|
var SWIPING_NONE = 0;
|
|
var init$3 = function (xValue) {
|
|
return {
|
|
xValue: xValue,
|
|
points: []
|
|
};
|
|
};
|
|
var move = function (model, xValue) {
|
|
if (xValue === model.xValue) {
|
|
return model;
|
|
}
|
|
var currentDirection = xValue - model.xValue > 0 ? SWIPING_LEFT : SWIPING_RIGHT;
|
|
var newPoint = {
|
|
direction: currentDirection,
|
|
xValue: xValue
|
|
};
|
|
var priorPoints = function () {
|
|
if (model.points.length === 0) {
|
|
return [];
|
|
} else {
|
|
var prev = model.points[model.points.length - 1];
|
|
return prev.direction === currentDirection ? model.points.slice(0, model.points.length - 1) : model.points;
|
|
}
|
|
}();
|
|
return {
|
|
xValue: xValue,
|
|
points: priorPoints.concat([newPoint])
|
|
};
|
|
};
|
|
var complete = function (model) {
|
|
if (model.points.length === 0) {
|
|
return SWIPING_NONE;
|
|
} else {
|
|
var firstDirection = model.points[0].direction;
|
|
var lastDirection = model.points[model.points.length - 1].direction;
|
|
return firstDirection === SWIPING_RIGHT && lastDirection === SWIPING_RIGHT ? SWIPING_RIGHT : firstDirection === SWIPING_LEFT && lastDirection === SWIPING_LEFT ? SWIPING_LEFT : SWIPING_NONE;
|
|
}
|
|
};
|
|
|
|
var sketch$3 = function (rawSpec) {
|
|
var navigateEvent = 'navigateEvent';
|
|
var wrapperAdhocEvents = 'serializer-wrapper-events';
|
|
var formAdhocEvents = 'form-events';
|
|
var schema = objOf([
|
|
required$1('fields'),
|
|
defaulted('maxFieldIndex', rawSpec.fields.length - 1),
|
|
required$1('onExecute'),
|
|
required$1('getInitialValue'),
|
|
customField('state', function () {
|
|
return {
|
|
dialogSwipeState: value(),
|
|
currentScreen: Cell(0)
|
|
};
|
|
})
|
|
]);
|
|
var spec$1 = asRawOrDie$1('SerialisedDialog', schema, rawSpec);
|
|
var navigationButton = function (direction, directionName, enabled) {
|
|
return Button.sketch({
|
|
dom: dom$1('<span class="${prefix}-icon-' + directionName + ' ${prefix}-icon"></span>'),
|
|
action: function (button) {
|
|
emitWith(button, navigateEvent, { direction: direction });
|
|
},
|
|
buttonBehaviours: derive$2([Disabling.config({
|
|
disableClass: resolve('toolbar-navigation-disabled'),
|
|
disabled: function () {
|
|
return !enabled;
|
|
}
|
|
})])
|
|
});
|
|
};
|
|
var reposition = function (dialog, message) {
|
|
descendant(dialog.element, '.' + resolve('serialised-dialog-chain')).each(function (parent) {
|
|
set$5(parent, 'left', -spec$1.state.currentScreen.get() * message.width + 'px');
|
|
});
|
|
};
|
|
var navigate = function (dialog, direction) {
|
|
var screens = descendants(dialog.element, '.' + resolve('serialised-dialog-screen'));
|
|
descendant(dialog.element, '.' + resolve('serialised-dialog-chain')).each(function (parent) {
|
|
if (spec$1.state.currentScreen.get() + direction >= 0 && spec$1.state.currentScreen.get() + direction < screens.length) {
|
|
getRaw(parent, 'left').each(function (left) {
|
|
var currentLeft = parseInt(left, 10);
|
|
var w = get$5(screens[0]);
|
|
set$5(parent, 'left', currentLeft - direction * w + 'px');
|
|
});
|
|
spec$1.state.currentScreen.set(spec$1.state.currentScreen.get() + direction);
|
|
}
|
|
});
|
|
};
|
|
var focusInput = function (dialog) {
|
|
var inputs = descendants(dialog.element, 'input');
|
|
var optInput = Optional.from(inputs[spec$1.state.currentScreen.get()]);
|
|
optInput.each(function (input) {
|
|
dialog.getSystem().getByDom(input).each(function (inputComp) {
|
|
dispatchFocus(dialog, inputComp.element);
|
|
});
|
|
});
|
|
var dotitems = memDots.get(dialog);
|
|
Highlighting.highlightAt(dotitems, spec$1.state.currentScreen.get());
|
|
};
|
|
var resetState = function () {
|
|
spec$1.state.currentScreen.set(0);
|
|
spec$1.state.dialogSwipeState.clear();
|
|
};
|
|
var memForm = record(Form.sketch(function (parts) {
|
|
return {
|
|
dom: dom$1('<div class="${prefix}-serialised-dialog"></div>'),
|
|
components: [Container.sketch({
|
|
dom: dom$1('<div class="${prefix}-serialised-dialog-chain" style="left: 0px; position: absolute;"></div>'),
|
|
components: map$2(spec$1.fields, function (field, i) {
|
|
return i <= spec$1.maxFieldIndex ? Container.sketch({
|
|
dom: dom$1('<div class="${prefix}-serialised-dialog-screen"></div>'),
|
|
components: [
|
|
navigationButton(-1, 'previous', i > 0),
|
|
parts.field(field.name, field.spec),
|
|
navigationButton(+1, 'next', i < spec$1.maxFieldIndex)
|
|
]
|
|
}) : parts.field(field.name, field.spec);
|
|
})
|
|
})],
|
|
formBehaviours: derive$2([
|
|
orientation(function (dialog, message) {
|
|
reposition(dialog, message);
|
|
}),
|
|
Keying.config({
|
|
mode: 'special',
|
|
focusIn: function (dialog, _specialInfo) {
|
|
focusInput(dialog);
|
|
},
|
|
onTab: function (dialog, _specialInfo) {
|
|
navigate(dialog, +1);
|
|
return Optional.some(true);
|
|
},
|
|
onShiftTab: function (dialog, _specialInfo) {
|
|
navigate(dialog, -1);
|
|
return Optional.some(true);
|
|
}
|
|
}),
|
|
config(formAdhocEvents, [
|
|
runOnAttached(function (dialog, _simulatedEvent) {
|
|
resetState();
|
|
var dotitems = memDots.get(dialog);
|
|
Highlighting.highlightFirst(dotitems);
|
|
spec$1.getInitialValue(dialog).each(function (v) {
|
|
Representing.setValue(dialog, v);
|
|
});
|
|
}),
|
|
runOnExecute(spec$1.onExecute),
|
|
run(transitionend(), function (dialog, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
if (event.raw.propertyName === 'left') {
|
|
focusInput(dialog);
|
|
}
|
|
}),
|
|
run(navigateEvent, function (dialog, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
var direction = event.direction;
|
|
navigate(dialog, direction);
|
|
})
|
|
])
|
|
])
|
|
};
|
|
}));
|
|
var memDots = record({
|
|
dom: dom$1('<div class="${prefix}-dot-container"></div>'),
|
|
behaviours: derive$2([Highlighting.config({
|
|
highlightClass: resolve('dot-active'),
|
|
itemClass: resolve('dot-item')
|
|
})]),
|
|
components: bind$3(spec$1.fields, function (_f, i) {
|
|
return i <= spec$1.maxFieldIndex ? [spec('<div class="${prefix}-dot-item ${prefix}-icon-full-dot ${prefix}-icon"></div>')] : [];
|
|
})
|
|
});
|
|
return {
|
|
dom: dom$1('<div class="${prefix}-serializer-wrapper"></div>'),
|
|
components: [
|
|
memForm.asSpec(),
|
|
memDots.asSpec()
|
|
],
|
|
behaviours: derive$2([
|
|
Keying.config({
|
|
mode: 'special',
|
|
focusIn: function (wrapper) {
|
|
var form = memForm.get(wrapper);
|
|
Keying.focusIn(form);
|
|
}
|
|
}),
|
|
config(wrapperAdhocEvents, [
|
|
run(touchstart(), function (_wrapper, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
spec$1.state.dialogSwipeState.set(init$3(event.raw.touches[0].clientX));
|
|
}),
|
|
run(touchmove(), function (_wrapper, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
spec$1.state.dialogSwipeState.on(function (state) {
|
|
simulatedEvent.event.prevent();
|
|
spec$1.state.dialogSwipeState.set(move(state, event.raw.touches[0].clientX));
|
|
});
|
|
}),
|
|
run(touchend(), function (wrapper, _simulatedEvent) {
|
|
spec$1.state.dialogSwipeState.on(function (state) {
|
|
var dialog = memForm.get(wrapper);
|
|
var direction = -1 * complete(state);
|
|
navigate(dialog, direction);
|
|
});
|
|
})
|
|
])
|
|
])
|
|
};
|
|
};
|
|
|
|
var getGroups = cached(function (realm, editor) {
|
|
return [{
|
|
label: 'the link group',
|
|
items: [sketch$3({
|
|
fields: [
|
|
field('url', 'Type or paste URL'),
|
|
field('text', 'Link text'),
|
|
field('title', 'Link title'),
|
|
field('target', 'Link target'),
|
|
hidden('link')
|
|
],
|
|
maxFieldIndex: [
|
|
'url',
|
|
'text',
|
|
'title',
|
|
'target'
|
|
].length - 1,
|
|
getInitialValue: function () {
|
|
return Optional.some(getInfo(editor));
|
|
},
|
|
onExecute: function (dialog, _simulatedEvent) {
|
|
var info = Representing.getValue(dialog);
|
|
applyInfo(editor, info);
|
|
realm.restoreToolbar();
|
|
editor.focus();
|
|
}
|
|
})]
|
|
}];
|
|
});
|
|
var sketch$2 = function (realm, editor) {
|
|
return forToolbarStateAction(editor, 'link', 'link', function () {
|
|
var groups = getGroups(realm, editor);
|
|
realm.setContextToolbar(groups);
|
|
forAndroid(editor, function () {
|
|
realm.focusToolbar();
|
|
});
|
|
query(editor).each(function (link) {
|
|
editor.selection.select(link.dom);
|
|
});
|
|
});
|
|
};
|
|
|
|
var isRecursive = function (component, originator, target) {
|
|
return eq(originator, component.element) && !eq(originator, target);
|
|
};
|
|
var events$2 = derive$3([can(focus$4(), function (component, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
var originator = event.originator;
|
|
var target = event.target;
|
|
if (isRecursive(component, originator, target)) {
|
|
console.warn(focus$4() + ' did not get interpreted by the desired target. ' + '\nOriginator: ' + element(originator) + '\nTarget: ' + element(target) + '\nCheck the ' + focus$4() + ' event handlers');
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
})]);
|
|
|
|
var DefaultEvents = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$2
|
|
});
|
|
|
|
var make$3 = identity;
|
|
|
|
var NoContextApi = function (getComp) {
|
|
var getMessage = function (event) {
|
|
return 'The component must be in a context to execute: ' + event + (getComp ? '\n' + element(getComp().element) + ' is not in context.' : '');
|
|
};
|
|
var fail = function (event) {
|
|
return function () {
|
|
throw new Error(getMessage(event));
|
|
};
|
|
};
|
|
var warn = function (event) {
|
|
return function () {
|
|
console.warn(getMessage(event));
|
|
};
|
|
};
|
|
return {
|
|
debugInfo: constant$1('fake'),
|
|
triggerEvent: warn('triggerEvent'),
|
|
triggerFocus: warn('triggerFocus'),
|
|
triggerEscape: warn('triggerEscape'),
|
|
broadcast: warn('broadcast'),
|
|
broadcastOn: warn('broadcastOn'),
|
|
broadcastEvent: warn('broadcastEvent'),
|
|
build: fail('build'),
|
|
addToWorld: fail('addToWorld'),
|
|
removeFromWorld: fail('removeFromWorld'),
|
|
addToGui: fail('addToGui'),
|
|
removeFromGui: fail('removeFromGui'),
|
|
getByUid: fail('getByUid'),
|
|
getByDom: fail('getByDom'),
|
|
isConnected: never
|
|
};
|
|
};
|
|
var singleton = NoContextApi();
|
|
|
|
var generateFrom$1 = function (spec, all) {
|
|
var schema = map$2(all, function (a) {
|
|
return optionObjOf(a.name(), [
|
|
required$1('config'),
|
|
defaulted('state', NoState)
|
|
]);
|
|
});
|
|
var validated = asRaw('component.behaviours', objOf(schema), spec.behaviours).fold(function (errInfo) {
|
|
throw new Error(formatError(errInfo) + '\nComplete spec:\n' + JSON.stringify(spec, null, 2));
|
|
}, identity);
|
|
return {
|
|
list: all,
|
|
data: map$1(validated, function (optBlobThunk) {
|
|
var output = optBlobThunk.map(function (blob) {
|
|
return {
|
|
config: blob.config,
|
|
state: blob.state.init(blob.config)
|
|
};
|
|
});
|
|
return constant$1(output);
|
|
})
|
|
};
|
|
};
|
|
var getBehaviours$1 = function (bData) {
|
|
return bData.list;
|
|
};
|
|
var getData = function (bData) {
|
|
return bData.data;
|
|
};
|
|
|
|
var byInnerKey = function (data, tuple) {
|
|
var r = {};
|
|
each(data, function (detail, key) {
|
|
each(detail, function (value, indexKey) {
|
|
var chain = get$c(r, indexKey).getOr([]);
|
|
r[indexKey] = chain.concat([tuple(key, value)]);
|
|
});
|
|
});
|
|
return r;
|
|
};
|
|
|
|
var combine$1 = function (info, baseMod, behaviours, base) {
|
|
var modsByBehaviour = __assign({}, baseMod);
|
|
each$1(behaviours, function (behaviour) {
|
|
modsByBehaviour[behaviour.name()] = behaviour.exhibit(info, base);
|
|
});
|
|
var byAspect = byInnerKey(modsByBehaviour, function (name, modification) {
|
|
return {
|
|
name: name,
|
|
modification: modification
|
|
};
|
|
});
|
|
var combineObjects = function (objects) {
|
|
return foldr(objects, function (b, a) {
|
|
return __assign(__assign({}, a.modification), b);
|
|
}, {});
|
|
};
|
|
var combinedClasses = foldr(byAspect.classes, function (b, a) {
|
|
return a.modification.concat(b);
|
|
}, []);
|
|
var combinedAttributes = combineObjects(byAspect.attributes);
|
|
var combinedStyles = combineObjects(byAspect.styles);
|
|
return nu$3({
|
|
classes: combinedClasses,
|
|
attributes: combinedAttributes,
|
|
styles: combinedStyles
|
|
});
|
|
};
|
|
|
|
var sortKeys = function (label, keyName, array, order) {
|
|
try {
|
|
var sorted = sort(array, function (a, b) {
|
|
var aKey = a[keyName];
|
|
var bKey = b[keyName];
|
|
var aIndex = order.indexOf(aKey);
|
|
var bIndex = order.indexOf(bKey);
|
|
if (aIndex === -1) {
|
|
throw new Error('The ordering for ' + label + ' does not have an entry for ' + aKey + '.\nOrder specified: ' + JSON.stringify(order, null, 2));
|
|
}
|
|
if (bIndex === -1) {
|
|
throw new Error('The ordering for ' + label + ' does not have an entry for ' + bKey + '.\nOrder specified: ' + JSON.stringify(order, null, 2));
|
|
}
|
|
if (aIndex < bIndex) {
|
|
return -1;
|
|
} else if (bIndex < aIndex) {
|
|
return 1;
|
|
} else {
|
|
return 0;
|
|
}
|
|
});
|
|
return Result.value(sorted);
|
|
} catch (err) {
|
|
return Result.error([err]);
|
|
}
|
|
};
|
|
|
|
var uncurried = function (handler, purpose) {
|
|
return {
|
|
handler: handler,
|
|
purpose: purpose
|
|
};
|
|
};
|
|
var curried = function (handler, purpose) {
|
|
return {
|
|
cHandler: handler,
|
|
purpose: purpose
|
|
};
|
|
};
|
|
var curryArgs = function (descHandler, extraArgs) {
|
|
return curried(curry.apply(undefined, [descHandler.handler].concat(extraArgs)), descHandler.purpose);
|
|
};
|
|
var getCurried = function (descHandler) {
|
|
return descHandler.cHandler;
|
|
};
|
|
|
|
var behaviourTuple = function (name, handler) {
|
|
return {
|
|
name: name,
|
|
handler: handler
|
|
};
|
|
};
|
|
var nameToHandlers = function (behaviours, info) {
|
|
var r = {};
|
|
each$1(behaviours, function (behaviour) {
|
|
r[behaviour.name()] = behaviour.handlers(info);
|
|
});
|
|
return r;
|
|
};
|
|
var groupByEvents = function (info, behaviours, base) {
|
|
var behaviourEvents = __assign(__assign({}, base), nameToHandlers(behaviours, info));
|
|
return byInnerKey(behaviourEvents, behaviourTuple);
|
|
};
|
|
var combine = function (info, eventOrder, behaviours, base) {
|
|
var byEventName = groupByEvents(info, behaviours, base);
|
|
return combineGroups(byEventName, eventOrder);
|
|
};
|
|
var assemble = function (rawHandler) {
|
|
var handler = read$1(rawHandler);
|
|
return function (component, simulatedEvent) {
|
|
var rest = [];
|
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
rest[_i - 2] = arguments[_i];
|
|
}
|
|
var args = [
|
|
component,
|
|
simulatedEvent
|
|
].concat(rest);
|
|
if (handler.abort.apply(undefined, args)) {
|
|
simulatedEvent.stop();
|
|
} else if (handler.can.apply(undefined, args)) {
|
|
handler.run.apply(undefined, args);
|
|
}
|
|
};
|
|
};
|
|
var missingOrderError = function (eventName, tuples) {
|
|
return Result.error(['The event (' + eventName + ') has more than one behaviour that listens to it.\nWhen this occurs, you must ' + 'specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that ' + 'can trigger it are: ' + JSON.stringify(map$2(tuples, function (c) {
|
|
return c.name;
|
|
}), null, 2)]);
|
|
};
|
|
var fuse = function (tuples, eventOrder, eventName) {
|
|
var order = eventOrder[eventName];
|
|
if (!order) {
|
|
return missingOrderError(eventName, tuples);
|
|
} else {
|
|
return sortKeys('Event: ' + eventName, 'name', tuples, order).map(function (sortedTuples) {
|
|
var handlers = map$2(sortedTuples, function (tuple) {
|
|
return tuple.handler;
|
|
});
|
|
return fuse$1(handlers);
|
|
});
|
|
}
|
|
};
|
|
var combineGroups = function (byEventName, eventOrder) {
|
|
var r = mapToArray(byEventName, function (tuples, eventName) {
|
|
var combined = tuples.length === 1 ? Result.value(tuples[0].handler) : fuse(tuples, eventOrder, eventName);
|
|
return combined.map(function (handler) {
|
|
var assembled = assemble(handler);
|
|
var purpose = tuples.length > 1 ? filter$2(eventOrder[eventName], function (o) {
|
|
return exists(tuples, function (t) {
|
|
return t.name === o;
|
|
});
|
|
}).join(' > ') : tuples[0].name;
|
|
return wrap(eventName, uncurried(assembled, purpose));
|
|
});
|
|
});
|
|
return consolidate(r, {});
|
|
};
|
|
|
|
var _a;
|
|
var baseBehaviour = 'alloy.base.behaviour';
|
|
var schema$6 = objOf([
|
|
field$2('dom', 'dom', required$2(), objOf([
|
|
required$1('tag'),
|
|
defaulted('styles', {}),
|
|
defaulted('classes', []),
|
|
defaulted('attributes', {}),
|
|
option('value'),
|
|
option('innerHtml')
|
|
])),
|
|
required$1('components'),
|
|
required$1('uid'),
|
|
defaulted('events', {}),
|
|
defaulted('apis', {}),
|
|
field$2('eventOrder', 'eventOrder', mergeWith((_a = {}, _a[execute$5()] = [
|
|
'disabling',
|
|
baseBehaviour,
|
|
'toggling',
|
|
'typeaheadevents'
|
|
], _a[focus$4()] = [
|
|
baseBehaviour,
|
|
'focusing',
|
|
'keying'
|
|
], _a[systemInit()] = [
|
|
baseBehaviour,
|
|
'disabling',
|
|
'toggling',
|
|
'representing'
|
|
], _a[input$1()] = [
|
|
baseBehaviour,
|
|
'representing',
|
|
'streaming',
|
|
'invalidating'
|
|
], _a[detachedFromDom()] = [
|
|
baseBehaviour,
|
|
'representing',
|
|
'item-events',
|
|
'tooltipping'
|
|
], _a[mousedown()] = [
|
|
'focusing',
|
|
baseBehaviour,
|
|
'item-type-events'
|
|
], _a[touchstart()] = [
|
|
'focusing',
|
|
baseBehaviour,
|
|
'item-type-events'
|
|
], _a[mouseover()] = [
|
|
'item-type-events',
|
|
'tooltipping'
|
|
], _a[receive$1()] = [
|
|
'receiving',
|
|
'reflecting',
|
|
'tooltipping'
|
|
], _a)), anyValue()),
|
|
option('domModification')
|
|
]);
|
|
var toInfo = function (spec) {
|
|
return asRaw('custom.definition', schema$6, spec);
|
|
};
|
|
var toDefinition = function (detail) {
|
|
return __assign(__assign({}, detail.dom), {
|
|
uid: detail.uid,
|
|
domChildren: map$2(detail.components, function (comp) {
|
|
return comp.element;
|
|
})
|
|
});
|
|
};
|
|
var toModification = function (detail) {
|
|
return detail.domModification.fold(function () {
|
|
return nu$3({});
|
|
}, nu$3);
|
|
};
|
|
var toEvents = function (info) {
|
|
return info.events;
|
|
};
|
|
|
|
var add = function (element, classes) {
|
|
each$1(classes, function (x) {
|
|
add$1(element, x);
|
|
});
|
|
};
|
|
var remove$1 = function (element, classes) {
|
|
each$1(classes, function (x) {
|
|
remove$3(element, x);
|
|
});
|
|
};
|
|
|
|
var renderToDom = function (definition) {
|
|
var subject = SugarElement.fromTag(definition.tag);
|
|
setAll$1(subject, definition.attributes);
|
|
add(subject, definition.classes);
|
|
setAll(subject, definition.styles);
|
|
definition.innerHtml.each(function (html) {
|
|
return set$7(subject, html);
|
|
});
|
|
var children = definition.domChildren;
|
|
append$1(subject, children);
|
|
definition.value.each(function (value) {
|
|
set$2(subject, value);
|
|
});
|
|
if (!definition.uid) {
|
|
debugger;
|
|
}
|
|
writeOnly(subject, definition.uid);
|
|
return subject;
|
|
};
|
|
|
|
var getBehaviours = function (spec) {
|
|
var behaviours = get$c(spec, 'behaviours').getOr({});
|
|
return bind$3(keys(behaviours), function (name) {
|
|
var behaviour = behaviours[name];
|
|
return isNonNullable(behaviour) ? [behaviour.me] : [];
|
|
});
|
|
};
|
|
var generateFrom = function (spec, all) {
|
|
return generateFrom$1(spec, all);
|
|
};
|
|
var generate$1 = function (spec) {
|
|
var all = getBehaviours(spec);
|
|
return generateFrom(spec, all);
|
|
};
|
|
|
|
var getDomDefinition = function (info, bList, bData) {
|
|
var definition = toDefinition(info);
|
|
var infoModification = toModification(info);
|
|
var baseModification = { 'alloy.base.modification': infoModification };
|
|
var modification = bList.length > 0 ? combine$1(bData, baseModification, bList, definition) : infoModification;
|
|
return merge(definition, modification);
|
|
};
|
|
var getEvents = function (info, bList, bData) {
|
|
var baseEvents = { 'alloy.base.behaviour': toEvents(info) };
|
|
return combine(bData, info.eventOrder, bList, baseEvents).getOrDie();
|
|
};
|
|
var build$2 = function (spec) {
|
|
var getMe = function () {
|
|
return me;
|
|
};
|
|
var systemApi = Cell(singleton);
|
|
var info = getOrDie(toInfo(spec));
|
|
var bBlob = generate$1(spec);
|
|
var bList = getBehaviours$1(bBlob);
|
|
var bData = getData(bBlob);
|
|
var modDefinition = getDomDefinition(info, bList, bData);
|
|
var item = renderToDom(modDefinition);
|
|
var events = getEvents(info, bList, bData);
|
|
var subcomponents = Cell(info.components);
|
|
var connect = function (newApi) {
|
|
systemApi.set(newApi);
|
|
};
|
|
var disconnect = function () {
|
|
systemApi.set(NoContextApi(getMe));
|
|
};
|
|
var syncComponents = function () {
|
|
var children$1 = children(item);
|
|
var subs = bind$3(children$1, function (child) {
|
|
return systemApi.get().getByDom(child).fold(function () {
|
|
return [];
|
|
}, pure$2);
|
|
});
|
|
subcomponents.set(subs);
|
|
};
|
|
var config = function (behaviour) {
|
|
var b = bData;
|
|
var f = isFunction(b[behaviour.name()]) ? b[behaviour.name()] : function () {
|
|
throw new Error('Could not find ' + behaviour.name() + ' in ' + JSON.stringify(spec, null, 2));
|
|
};
|
|
return f();
|
|
};
|
|
var hasConfigured = function (behaviour) {
|
|
return isFunction(bData[behaviour.name()]);
|
|
};
|
|
var getApis = function () {
|
|
return info.apis;
|
|
};
|
|
var readState = function (behaviourName) {
|
|
return bData[behaviourName]().map(function (b) {
|
|
return b.state.readState();
|
|
}).getOr('not enabled');
|
|
};
|
|
var me = {
|
|
uid: spec.uid,
|
|
getSystem: systemApi.get,
|
|
config: config,
|
|
hasConfigured: hasConfigured,
|
|
spec: spec,
|
|
readState: readState,
|
|
getApis: getApis,
|
|
connect: connect,
|
|
disconnect: disconnect,
|
|
element: item,
|
|
syncComponents: syncComponents,
|
|
components: subcomponents.get,
|
|
events: events
|
|
};
|
|
return me;
|
|
};
|
|
|
|
var buildSubcomponents = function (spec) {
|
|
var components = get$c(spec, 'components').getOr([]);
|
|
return map$2(components, build$1);
|
|
};
|
|
var buildFromSpec = function (userSpec) {
|
|
var _a = make$3(userSpec), specEvents = _a.events, spec = __rest(_a, ['events']);
|
|
var components = buildSubcomponents(spec);
|
|
var completeSpec = __assign(__assign({}, spec), {
|
|
events: __assign(__assign({}, DefaultEvents), specEvents),
|
|
components: components
|
|
});
|
|
return Result.value(build$2(completeSpec));
|
|
};
|
|
var text = function (textContent) {
|
|
var element = SugarElement.fromText(textContent);
|
|
return external({ element: element });
|
|
};
|
|
var external = function (spec) {
|
|
var extSpec = asRawOrDie$1('external.component', objOfOnly([
|
|
required$1('element'),
|
|
option('uid')
|
|
]), spec);
|
|
var systemApi = Cell(NoContextApi());
|
|
var connect = function (newApi) {
|
|
systemApi.set(newApi);
|
|
};
|
|
var disconnect = function () {
|
|
systemApi.set(NoContextApi(function () {
|
|
return me;
|
|
}));
|
|
};
|
|
var uid = extSpec.uid.getOrThunk(function () {
|
|
return generate$2('external');
|
|
});
|
|
writeOnly(extSpec.element, uid);
|
|
var me = {
|
|
uid: uid,
|
|
getSystem: systemApi.get,
|
|
config: Optional.none,
|
|
hasConfigured: never,
|
|
connect: connect,
|
|
disconnect: disconnect,
|
|
getApis: function () {
|
|
return {};
|
|
},
|
|
element: extSpec.element,
|
|
spec: spec,
|
|
readState: constant$1('No state'),
|
|
syncComponents: noop,
|
|
components: constant$1([]),
|
|
events: {}
|
|
};
|
|
return premade$1(me);
|
|
};
|
|
var uids = generate$2;
|
|
var isSketchSpec = function (spec) {
|
|
return has$2(spec, 'uid');
|
|
};
|
|
var build$1 = function (spec) {
|
|
return getPremade(spec).getOrThunk(function () {
|
|
var userSpecWithUid = isSketchSpec(spec) ? spec : __assign({ uid: uids('') }, spec);
|
|
return buildFromSpec(userSpecWithUid).getOrDie();
|
|
});
|
|
};
|
|
var premade = premade$1;
|
|
|
|
var hoverEvent = 'alloy.item-hover';
|
|
var focusEvent = 'alloy.item-focus';
|
|
var onHover = function (item) {
|
|
if (search(item.element).isNone() || Focusing.isFocused(item)) {
|
|
if (!Focusing.isFocused(item)) {
|
|
Focusing.focus(item);
|
|
}
|
|
emitWith(item, hoverEvent, { item: item });
|
|
}
|
|
};
|
|
var onFocus = function (item) {
|
|
emitWith(item, focusEvent, { item: item });
|
|
};
|
|
var hover = constant$1(hoverEvent);
|
|
var focus$1 = constant$1(focusEvent);
|
|
|
|
var builder$2 = function (detail) {
|
|
return {
|
|
dom: detail.dom,
|
|
domModification: __assign(__assign({}, detail.domModification), { attributes: __assign(__assign(__assign({ 'role': detail.toggling.isSome() ? 'menuitemcheckbox' : 'menuitem' }, detail.domModification.attributes), { 'aria-haspopup': detail.hasSubmenu }), detail.hasSubmenu ? { 'aria-expanded': false } : {}) }),
|
|
behaviours: SketchBehaviours.augment(detail.itemBehaviours, [
|
|
detail.toggling.fold(Toggling.revoke, function (tConfig) {
|
|
return Toggling.config(__assign({ aria: { mode: 'checked' } }, tConfig));
|
|
}),
|
|
Focusing.config({
|
|
ignore: detail.ignoreFocus,
|
|
stopMousedown: detail.ignoreFocus,
|
|
onFocus: function (component) {
|
|
onFocus(component);
|
|
}
|
|
}),
|
|
Keying.config({ mode: 'execution' }),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.data
|
|
}
|
|
}),
|
|
config('item-type-events', __spreadArray(__spreadArray([], pointerEvents(), true), [
|
|
run(mouseover(), onHover),
|
|
run(focusItem(), Focusing.focus)
|
|
], false))
|
|
]),
|
|
components: detail.components,
|
|
eventOrder: detail.eventOrder
|
|
};
|
|
};
|
|
var schema$5 = [
|
|
required$1('data'),
|
|
required$1('components'),
|
|
required$1('dom'),
|
|
defaulted('hasSubmenu', false),
|
|
option('toggling'),
|
|
SketchBehaviours.field('itemBehaviours', [
|
|
Toggling,
|
|
Focusing,
|
|
Keying,
|
|
Representing
|
|
]),
|
|
defaulted('ignoreFocus', false),
|
|
defaulted('domModification', {}),
|
|
output('builder', builder$2),
|
|
defaulted('eventOrder', {})
|
|
];
|
|
|
|
var builder$1 = function (detail) {
|
|
return {
|
|
dom: detail.dom,
|
|
components: detail.components,
|
|
events: derive$3([stopper(focusItem())])
|
|
};
|
|
};
|
|
var schema$4 = [
|
|
required$1('dom'),
|
|
required$1('components'),
|
|
output('builder', builder$1)
|
|
];
|
|
|
|
var owner = constant$1('item-widget');
|
|
var parts$3 = constant$1([required({
|
|
name: 'widget',
|
|
overrides: function (detail) {
|
|
return {
|
|
behaviours: derive$2([Representing.config({
|
|
store: {
|
|
mode: 'manual',
|
|
getValue: function (_component) {
|
|
return detail.data;
|
|
},
|
|
setValue: noop
|
|
}
|
|
})])
|
|
};
|
|
}
|
|
})]);
|
|
|
|
var builder = function (detail) {
|
|
var subs = substitutes(owner(), detail, parts$3());
|
|
var components$1 = components(owner(), detail, subs.internals());
|
|
var focusWidget = function (component) {
|
|
return getPart(component, detail, 'widget').map(function (widget) {
|
|
Keying.focusIn(widget);
|
|
return widget;
|
|
});
|
|
};
|
|
var onHorizontalArrow = function (component, simulatedEvent) {
|
|
return inside(simulatedEvent.event.target) ? Optional.none() : function () {
|
|
if (detail.autofocus) {
|
|
simulatedEvent.setSource(component.element);
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}();
|
|
};
|
|
return {
|
|
dom: detail.dom,
|
|
components: components$1,
|
|
domModification: detail.domModification,
|
|
events: derive$3([
|
|
runOnExecute(function (component, simulatedEvent) {
|
|
focusWidget(component).each(function (_widget) {
|
|
simulatedEvent.stop();
|
|
});
|
|
}),
|
|
run(mouseover(), onHover),
|
|
run(focusItem(), function (component, _simulatedEvent) {
|
|
if (detail.autofocus) {
|
|
focusWidget(component);
|
|
} else {
|
|
Focusing.focus(component);
|
|
}
|
|
})
|
|
]),
|
|
behaviours: SketchBehaviours.augment(detail.widgetBehaviours, [
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.data
|
|
}
|
|
}),
|
|
Focusing.config({
|
|
ignore: detail.ignoreFocus,
|
|
onFocus: function (component) {
|
|
onFocus(component);
|
|
}
|
|
}),
|
|
Keying.config({
|
|
mode: 'special',
|
|
focusIn: detail.autofocus ? function (component) {
|
|
focusWidget(component);
|
|
} : revoke(),
|
|
onLeft: onHorizontalArrow,
|
|
onRight: onHorizontalArrow,
|
|
onEscape: function (component, simulatedEvent) {
|
|
if (!Focusing.isFocused(component) && !detail.autofocus) {
|
|
Focusing.focus(component);
|
|
return Optional.some(true);
|
|
} else if (detail.autofocus) {
|
|
simulatedEvent.setSource(component.element);
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
})
|
|
])
|
|
};
|
|
};
|
|
var schema$3 = [
|
|
required$1('uid'),
|
|
required$1('data'),
|
|
required$1('components'),
|
|
required$1('dom'),
|
|
defaulted('autofocus', false),
|
|
defaulted('ignoreFocus', false),
|
|
SketchBehaviours.field('widgetBehaviours', [
|
|
Representing,
|
|
Focusing,
|
|
Keying
|
|
]),
|
|
defaulted('domModification', {}),
|
|
defaultUidsSchema(parts$3()),
|
|
output('builder', builder)
|
|
];
|
|
|
|
var itemSchema = choose$1('type', {
|
|
widget: schema$3,
|
|
item: schema$5,
|
|
separator: schema$4
|
|
});
|
|
var configureGrid = function (detail, movementInfo) {
|
|
return {
|
|
mode: 'flatgrid',
|
|
selector: '.' + detail.markers.item,
|
|
initSize: {
|
|
numColumns: movementInfo.initSize.numColumns,
|
|
numRows: movementInfo.initSize.numRows
|
|
},
|
|
focusManager: detail.focusManager
|
|
};
|
|
};
|
|
var configureMatrix = function (detail, movementInfo) {
|
|
return {
|
|
mode: 'matrix',
|
|
selectors: {
|
|
row: movementInfo.rowSelector,
|
|
cell: '.' + detail.markers.item
|
|
},
|
|
focusManager: detail.focusManager
|
|
};
|
|
};
|
|
var configureMenu = function (detail, movementInfo) {
|
|
return {
|
|
mode: 'menu',
|
|
selector: '.' + detail.markers.item,
|
|
moveOnTab: movementInfo.moveOnTab,
|
|
focusManager: detail.focusManager
|
|
};
|
|
};
|
|
var parts$2 = constant$1([group({
|
|
factory: {
|
|
sketch: function (spec) {
|
|
var itemInfo = asRawOrDie$1('menu.spec item', itemSchema, spec);
|
|
return itemInfo.builder(itemInfo);
|
|
}
|
|
},
|
|
name: 'items',
|
|
unit: 'item',
|
|
defaults: function (detail, u) {
|
|
return has$2(u, 'uid') ? u : __assign(__assign({}, u), { uid: generate$2('item') });
|
|
},
|
|
overrides: function (detail, u) {
|
|
return {
|
|
type: u.type,
|
|
ignoreFocus: detail.fakeFocus,
|
|
domModification: { classes: [detail.markers.item] }
|
|
};
|
|
}
|
|
})]);
|
|
var schema$2 = constant$1([
|
|
required$1('value'),
|
|
required$1('items'),
|
|
required$1('dom'),
|
|
required$1('components'),
|
|
defaulted('eventOrder', {}),
|
|
field$1('menuBehaviours', [
|
|
Highlighting,
|
|
Representing,
|
|
Composing,
|
|
Keying
|
|
]),
|
|
defaultedOf('movement', {
|
|
mode: 'menu',
|
|
moveOnTab: true
|
|
}, choose$1('mode', {
|
|
grid: [
|
|
initSize(),
|
|
output('config', configureGrid)
|
|
],
|
|
matrix: [
|
|
output('config', configureMatrix),
|
|
required$1('rowSelector')
|
|
],
|
|
menu: [
|
|
defaulted('moveOnTab', true),
|
|
output('config', configureMenu)
|
|
]
|
|
})),
|
|
itemMarkers(),
|
|
defaulted('fakeFocus', false),
|
|
defaulted('focusManager', dom$2()),
|
|
onHandler('onHighlight')
|
|
]);
|
|
|
|
var focus = constant$1('alloy.menu-focus');
|
|
|
|
var make$2 = function (detail, components, _spec, _externals) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
markers: detail.markers,
|
|
behaviours: augment(detail.menuBehaviours, [
|
|
Highlighting.config({
|
|
highlightClass: detail.markers.selectedItem,
|
|
itemClass: detail.markers.item,
|
|
onHighlight: detail.onHighlight
|
|
}),
|
|
Representing.config({
|
|
store: {
|
|
mode: 'memory',
|
|
initialValue: detail.value
|
|
}
|
|
}),
|
|
Composing.config({ find: Optional.some }),
|
|
Keying.config(detail.movement.config(detail, detail.movement))
|
|
]),
|
|
events: derive$3([
|
|
run(focus$1(), function (menu, simulatedEvent) {
|
|
var event = simulatedEvent.event;
|
|
menu.getSystem().getByDom(event.target).each(function (item) {
|
|
Highlighting.highlight(menu, item);
|
|
simulatedEvent.stop();
|
|
emitWith(menu, focus(), {
|
|
menu: menu,
|
|
item: item
|
|
});
|
|
});
|
|
}),
|
|
run(hover(), function (menu, simulatedEvent) {
|
|
var item = simulatedEvent.event.item;
|
|
Highlighting.highlight(menu, item);
|
|
})
|
|
]),
|
|
components: components,
|
|
eventOrder: detail.eventOrder,
|
|
domModification: { attributes: { role: 'menu' } }
|
|
};
|
|
};
|
|
|
|
var Menu = composite({
|
|
name: 'Menu',
|
|
configFields: schema$2(),
|
|
partFields: parts$2(),
|
|
factory: make$2
|
|
});
|
|
|
|
var preserve = function (f, container) {
|
|
var dos = getRootNode(container);
|
|
var refocus = active(dos).bind(function (focused) {
|
|
var hasFocus = function (elem) {
|
|
return eq(focused, elem);
|
|
};
|
|
return hasFocus(container) ? Optional.some(container) : descendant$1(container, hasFocus);
|
|
});
|
|
var result = f(container);
|
|
refocus.each(function (oldFocus) {
|
|
active(dos).filter(function (newFocus) {
|
|
return eq(newFocus, oldFocus);
|
|
}).fold(function () {
|
|
focus$3(oldFocus);
|
|
}, noop);
|
|
});
|
|
return result;
|
|
};
|
|
|
|
var set = function (component, replaceConfig, replaceState, data) {
|
|
preserve(function () {
|
|
var newChildren = map$2(data, component.getSystem().build);
|
|
replaceChildren(component, newChildren);
|
|
}, component.element);
|
|
};
|
|
var insert = function (component, replaceConfig, insertion, childSpec) {
|
|
var child = component.getSystem().build(childSpec);
|
|
attachWith(component, child, insertion);
|
|
};
|
|
var append = function (component, replaceConfig, replaceState, appendee) {
|
|
insert(component, replaceConfig, append$2, appendee);
|
|
};
|
|
var prepend = function (component, replaceConfig, replaceState, prependee) {
|
|
insert(component, replaceConfig, prepend$1, prependee);
|
|
};
|
|
var remove = function (component, replaceConfig, replaceState, removee) {
|
|
var children = contents(component);
|
|
var foundChild = find$2(children, function (child) {
|
|
return eq(removee.element, child.element);
|
|
});
|
|
foundChild.each(detach);
|
|
};
|
|
var contents = function (component, _replaceConfig) {
|
|
return component.components();
|
|
};
|
|
var replaceAt = function (component, replaceConfig, replaceState, replaceeIndex, replacer) {
|
|
var children = contents(component);
|
|
return Optional.from(children[replaceeIndex]).map(function (replacee) {
|
|
remove(component, replaceConfig, replaceState, replacee);
|
|
replacer.each(function (r) {
|
|
insert(component, replaceConfig, function (p, c) {
|
|
appendAt(p, c, replaceeIndex);
|
|
}, r);
|
|
});
|
|
return replacee;
|
|
});
|
|
};
|
|
var replaceBy = function (component, replaceConfig, replaceState, replaceePred, replacer) {
|
|
var children = contents(component);
|
|
return findIndex$1(children, replaceePred).bind(function (replaceeIndex) {
|
|
return replaceAt(component, replaceConfig, replaceState, replaceeIndex, replacer);
|
|
});
|
|
};
|
|
|
|
var ReplaceApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
append: append,
|
|
prepend: prepend,
|
|
remove: remove,
|
|
replaceAt: replaceAt,
|
|
replaceBy: replaceBy,
|
|
set: set,
|
|
contents: contents
|
|
});
|
|
|
|
var Replacing = create$5({
|
|
fields: [],
|
|
name: 'replacing',
|
|
apis: ReplaceApis
|
|
});
|
|
|
|
var transpose = function (obj) {
|
|
return tupleMap(obj, function (v, k) {
|
|
return {
|
|
k: v,
|
|
v: k
|
|
};
|
|
});
|
|
};
|
|
var trace = function (items, byItem, byMenu, finish) {
|
|
return get$c(byMenu, finish).bind(function (triggerItem) {
|
|
return get$c(items, triggerItem).bind(function (triggerMenu) {
|
|
var rest = trace(items, byItem, byMenu, triggerMenu);
|
|
return Optional.some([triggerMenu].concat(rest));
|
|
});
|
|
}).getOr([]);
|
|
};
|
|
var generate = function (menus, expansions) {
|
|
var items = {};
|
|
each(menus, function (menuItems, menu) {
|
|
each$1(menuItems, function (item) {
|
|
items[item] = menu;
|
|
});
|
|
});
|
|
var byItem = expansions;
|
|
var byMenu = transpose(expansions);
|
|
var menuPaths = map$1(byMenu, function (_triggerItem, submenu) {
|
|
return [submenu].concat(trace(items, byItem, byMenu, submenu));
|
|
});
|
|
return map$1(items, function (menu) {
|
|
return get$c(menuPaths, menu).getOr([menu]);
|
|
});
|
|
};
|
|
|
|
var init$2 = function () {
|
|
var expansions = Cell({});
|
|
var menus = Cell({});
|
|
var paths = Cell({});
|
|
var primary = value();
|
|
var directory = Cell({});
|
|
var clear = function () {
|
|
expansions.set({});
|
|
menus.set({});
|
|
paths.set({});
|
|
primary.clear();
|
|
};
|
|
var isClear = function () {
|
|
return primary.get().isNone();
|
|
};
|
|
var setMenuBuilt = function (menuName, built) {
|
|
var _a;
|
|
menus.set(__assign(__assign({}, menus.get()), (_a = {}, _a[menuName] = {
|
|
type: 'prepared',
|
|
menu: built
|
|
}, _a)));
|
|
};
|
|
var setContents = function (sPrimary, sMenus, sExpansions, dir) {
|
|
primary.set(sPrimary);
|
|
expansions.set(sExpansions);
|
|
menus.set(sMenus);
|
|
directory.set(dir);
|
|
var sPaths = generate(dir, sExpansions);
|
|
paths.set(sPaths);
|
|
};
|
|
var getTriggeringItem = function (menuValue) {
|
|
return find(expansions.get(), function (v, _k) {
|
|
return v === menuValue;
|
|
});
|
|
};
|
|
var getTriggerData = function (menuValue, getItemByValue, path) {
|
|
return getPreparedMenu(menuValue).bind(function (menu) {
|
|
return getTriggeringItem(menuValue).bind(function (triggeringItemValue) {
|
|
return getItemByValue(triggeringItemValue).map(function (triggeredItem) {
|
|
return {
|
|
triggeredMenu: menu,
|
|
triggeringItem: triggeredItem,
|
|
triggeringPath: path
|
|
};
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var getTriggeringPath = function (itemValue, getItemByValue) {
|
|
var extraPath = filter$2(lookupItem(itemValue).toArray(), function (menuValue) {
|
|
return getPreparedMenu(menuValue).isSome();
|
|
});
|
|
return get$c(paths.get(), itemValue).bind(function (path) {
|
|
var revPath = reverse(extraPath.concat(path));
|
|
var triggers = bind$3(revPath, function (menuValue, menuIndex) {
|
|
return getTriggerData(menuValue, getItemByValue, revPath.slice(0, menuIndex + 1)).fold(function () {
|
|
return is(primary.get(), menuValue) ? [] : [Optional.none()];
|
|
}, function (data) {
|
|
return [Optional.some(data)];
|
|
});
|
|
});
|
|
return sequence(triggers);
|
|
});
|
|
};
|
|
var expand = function (itemValue) {
|
|
return get$c(expansions.get(), itemValue).map(function (menu) {
|
|
var current = get$c(paths.get(), itemValue).getOr([]);
|
|
return [menu].concat(current);
|
|
});
|
|
};
|
|
var collapse = function (itemValue) {
|
|
return get$c(paths.get(), itemValue).bind(function (path) {
|
|
return path.length > 1 ? Optional.some(path.slice(1)) : Optional.none();
|
|
});
|
|
};
|
|
var refresh = function (itemValue) {
|
|
return get$c(paths.get(), itemValue);
|
|
};
|
|
var getPreparedMenu = function (menuValue) {
|
|
return lookupMenu(menuValue).bind(extractPreparedMenu);
|
|
};
|
|
var lookupMenu = function (menuValue) {
|
|
return get$c(menus.get(), menuValue);
|
|
};
|
|
var lookupItem = function (itemValue) {
|
|
return get$c(expansions.get(), itemValue);
|
|
};
|
|
var otherMenus = function (path) {
|
|
var menuValues = directory.get();
|
|
return difference(keys(menuValues), path);
|
|
};
|
|
var getPrimary = function () {
|
|
return primary.get().bind(getPreparedMenu);
|
|
};
|
|
var getMenus = function () {
|
|
return menus.get();
|
|
};
|
|
return {
|
|
setMenuBuilt: setMenuBuilt,
|
|
setContents: setContents,
|
|
expand: expand,
|
|
refresh: refresh,
|
|
collapse: collapse,
|
|
lookupMenu: lookupMenu,
|
|
lookupItem: lookupItem,
|
|
otherMenus: otherMenus,
|
|
getPrimary: getPrimary,
|
|
getMenus: getMenus,
|
|
clear: clear,
|
|
isClear: isClear,
|
|
getTriggeringPath: getTriggeringPath
|
|
};
|
|
};
|
|
var extractPreparedMenu = function (prep) {
|
|
return prep.type === 'prepared' ? Optional.some(prep.menu) : Optional.none();
|
|
};
|
|
var LayeredState = {
|
|
init: init$2,
|
|
extractPreparedMenu: extractPreparedMenu
|
|
};
|
|
|
|
var make$1 = function (detail, _rawUiSpec) {
|
|
var submenuParentItems = value();
|
|
var buildMenus = function (container, primaryName, menus) {
|
|
return map$1(menus, function (spec, name) {
|
|
var makeSketch = function () {
|
|
return Menu.sketch(__assign(__assign({}, spec), {
|
|
value: name,
|
|
markers: detail.markers,
|
|
fakeFocus: detail.fakeFocus,
|
|
onHighlight: detail.onHighlight,
|
|
focusManager: detail.fakeFocus ? highlights() : dom$2()
|
|
}));
|
|
};
|
|
return name === primaryName ? {
|
|
type: 'prepared',
|
|
menu: container.getSystem().build(makeSketch())
|
|
} : {
|
|
type: 'notbuilt',
|
|
nbMenu: makeSketch
|
|
};
|
|
});
|
|
};
|
|
var layeredState = LayeredState.init();
|
|
var setup = function (container) {
|
|
var componentMap = buildMenus(container, detail.data.primary, detail.data.menus);
|
|
var directory = toDirectory();
|
|
layeredState.setContents(detail.data.primary, componentMap, detail.data.expansions, directory);
|
|
return layeredState.getPrimary();
|
|
};
|
|
var getItemValue = function (item) {
|
|
return Representing.getValue(item).value;
|
|
};
|
|
var getItemByValue = function (_container, menus, itemValue) {
|
|
return findMap(menus, function (menu) {
|
|
if (!menu.getSystem().isConnected()) {
|
|
return Optional.none();
|
|
}
|
|
var candidates = Highlighting.getCandidates(menu);
|
|
return find$2(candidates, function (c) {
|
|
return getItemValue(c) === itemValue;
|
|
});
|
|
});
|
|
};
|
|
var toDirectory = function (_container) {
|
|
return map$1(detail.data.menus, function (data, _menuName) {
|
|
return bind$3(data.items, function (item) {
|
|
return item.type === 'separator' ? [] : [item.data.value];
|
|
});
|
|
});
|
|
};
|
|
var setActiveMenu = function (container, menu) {
|
|
Highlighting.highlight(container, menu);
|
|
Highlighting.getHighlighted(menu).orThunk(function () {
|
|
return Highlighting.getFirst(menu);
|
|
}).each(function (item) {
|
|
dispatch(container, item.element, focusItem());
|
|
});
|
|
};
|
|
var getMenus = function (state, menuValues) {
|
|
return cat(map$2(menuValues, function (mv) {
|
|
return state.lookupMenu(mv).bind(function (prep) {
|
|
return prep.type === 'prepared' ? Optional.some(prep.menu) : Optional.none();
|
|
});
|
|
}));
|
|
};
|
|
var closeOthers = function (container, state, path) {
|
|
var others = getMenus(state, state.otherMenus(path));
|
|
each$1(others, function (o) {
|
|
remove$1(o.element, [detail.markers.backgroundMenu]);
|
|
if (!detail.stayInDom) {
|
|
Replacing.remove(container, o);
|
|
}
|
|
});
|
|
};
|
|
var getSubmenuParents = function (container) {
|
|
return submenuParentItems.get().getOrThunk(function () {
|
|
var r = {};
|
|
var items = descendants(container.element, '.' + detail.markers.item);
|
|
var parentItems = filter$2(items, function (i) {
|
|
return get$b(i, 'aria-haspopup') === 'true';
|
|
});
|
|
each$1(parentItems, function (i) {
|
|
container.getSystem().getByDom(i).each(function (itemComp) {
|
|
var key = getItemValue(itemComp);
|
|
r[key] = itemComp;
|
|
});
|
|
});
|
|
submenuParentItems.set(r);
|
|
return r;
|
|
});
|
|
};
|
|
var updateAriaExpansions = function (container, path) {
|
|
var parentItems = getSubmenuParents(container);
|
|
each(parentItems, function (v, k) {
|
|
var expanded = contains$1(path, k);
|
|
set$8(v.element, 'aria-expanded', expanded);
|
|
});
|
|
};
|
|
var updateMenuPath = function (container, state, path) {
|
|
return Optional.from(path[0]).bind(function (latestMenuName) {
|
|
return state.lookupMenu(latestMenuName).bind(function (menuPrep) {
|
|
if (menuPrep.type === 'notbuilt') {
|
|
return Optional.none();
|
|
} else {
|
|
var activeMenu = menuPrep.menu;
|
|
var rest = getMenus(state, path.slice(1));
|
|
each$1(rest, function (r) {
|
|
add$1(r.element, detail.markers.backgroundMenu);
|
|
});
|
|
if (!inBody(activeMenu.element)) {
|
|
Replacing.append(container, premade(activeMenu));
|
|
}
|
|
remove$1(activeMenu.element, [detail.markers.backgroundMenu]);
|
|
setActiveMenu(container, activeMenu);
|
|
closeOthers(container, state, path);
|
|
return Optional.some(activeMenu);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var ExpandHighlightDecision;
|
|
(function (ExpandHighlightDecision) {
|
|
ExpandHighlightDecision[ExpandHighlightDecision['HighlightSubmenu'] = 0] = 'HighlightSubmenu';
|
|
ExpandHighlightDecision[ExpandHighlightDecision['HighlightParent'] = 1] = 'HighlightParent';
|
|
}(ExpandHighlightDecision || (ExpandHighlightDecision = {})));
|
|
var buildIfRequired = function (container, menuName, menuPrep) {
|
|
if (menuPrep.type === 'notbuilt') {
|
|
var menu = container.getSystem().build(menuPrep.nbMenu());
|
|
layeredState.setMenuBuilt(menuName, menu);
|
|
return menu;
|
|
} else {
|
|
return menuPrep.menu;
|
|
}
|
|
};
|
|
var expandRight = function (container, item, decision) {
|
|
if (decision === void 0) {
|
|
decision = ExpandHighlightDecision.HighlightSubmenu;
|
|
}
|
|
if (item.hasConfigured(Disabling) && Disabling.isDisabled(item)) {
|
|
return Optional.some(item);
|
|
} else {
|
|
var value = getItemValue(item);
|
|
return layeredState.expand(value).bind(function (path) {
|
|
updateAriaExpansions(container, path);
|
|
return Optional.from(path[0]).bind(function (menuName) {
|
|
return layeredState.lookupMenu(menuName).bind(function (activeMenuPrep) {
|
|
var activeMenu = buildIfRequired(container, menuName, activeMenuPrep);
|
|
if (!inBody(activeMenu.element)) {
|
|
Replacing.append(container, premade(activeMenu));
|
|
}
|
|
detail.onOpenSubmenu(container, item, activeMenu, reverse(path));
|
|
if (decision === ExpandHighlightDecision.HighlightSubmenu) {
|
|
Highlighting.highlightFirst(activeMenu);
|
|
return updateMenuPath(container, layeredState, path);
|
|
} else {
|
|
Highlighting.dehighlightAll(activeMenu);
|
|
return Optional.some(item);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var collapseLeft = function (container, item) {
|
|
var value = getItemValue(item);
|
|
return layeredState.collapse(value).bind(function (path) {
|
|
updateAriaExpansions(container, path);
|
|
return updateMenuPath(container, layeredState, path).map(function (activeMenu) {
|
|
detail.onCollapseMenu(container, item, activeMenu);
|
|
return activeMenu;
|
|
});
|
|
});
|
|
};
|
|
var updateView = function (container, item) {
|
|
var value = getItemValue(item);
|
|
return layeredState.refresh(value).bind(function (path) {
|
|
updateAriaExpansions(container, path);
|
|
return updateMenuPath(container, layeredState, path);
|
|
});
|
|
};
|
|
var onRight = function (container, item) {
|
|
return inside(item.element) ? Optional.none() : expandRight(container, item, ExpandHighlightDecision.HighlightSubmenu);
|
|
};
|
|
var onLeft = function (container, item) {
|
|
return inside(item.element) ? Optional.none() : collapseLeft(container, item);
|
|
};
|
|
var onEscape = function (container, item) {
|
|
return collapseLeft(container, item).orThunk(function () {
|
|
return detail.onEscape(container, item).map(function () {
|
|
return container;
|
|
});
|
|
});
|
|
};
|
|
var keyOnItem = function (f) {
|
|
return function (container, simulatedEvent) {
|
|
return closest$1(simulatedEvent.getSource(), '.' + detail.markers.item).bind(function (target) {
|
|
return container.getSystem().getByDom(target).toOptional().bind(function (item) {
|
|
return f(container, item).map(always);
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var events = derive$3([
|
|
run(focus(), function (sandbox, simulatedEvent) {
|
|
var item = simulatedEvent.event.item;
|
|
layeredState.lookupItem(getItemValue(item)).each(function () {
|
|
var menu = simulatedEvent.event.menu;
|
|
Highlighting.highlight(sandbox, menu);
|
|
var value = getItemValue(simulatedEvent.event.item);
|
|
layeredState.refresh(value).each(function (path) {
|
|
return closeOthers(sandbox, layeredState, path);
|
|
});
|
|
});
|
|
}),
|
|
runOnExecute(function (component, simulatedEvent) {
|
|
var target = simulatedEvent.event.target;
|
|
component.getSystem().getByDom(target).each(function (item) {
|
|
var itemValue = getItemValue(item);
|
|
if (itemValue.indexOf('collapse-item') === 0) {
|
|
collapseLeft(component, item);
|
|
}
|
|
expandRight(component, item, ExpandHighlightDecision.HighlightSubmenu).fold(function () {
|
|
detail.onExecute(component, item);
|
|
}, noop);
|
|
});
|
|
}),
|
|
runOnAttached(function (container, _simulatedEvent) {
|
|
setup(container).each(function (primary) {
|
|
Replacing.append(container, premade(primary));
|
|
detail.onOpenMenu(container, primary);
|
|
if (detail.highlightImmediately) {
|
|
setActiveMenu(container, primary);
|
|
}
|
|
});
|
|
})
|
|
].concat(detail.navigateOnHover ? [run(hover(), function (sandbox, simulatedEvent) {
|
|
var item = simulatedEvent.event.item;
|
|
updateView(sandbox, item);
|
|
expandRight(sandbox, item, ExpandHighlightDecision.HighlightParent);
|
|
detail.onHover(sandbox, item);
|
|
})] : []));
|
|
var getActiveItem = function (container) {
|
|
return Highlighting.getHighlighted(container).bind(Highlighting.getHighlighted);
|
|
};
|
|
var collapseMenuApi = function (container) {
|
|
getActiveItem(container).each(function (currentItem) {
|
|
collapseLeft(container, currentItem);
|
|
});
|
|
};
|
|
var highlightPrimary = function (container) {
|
|
layeredState.getPrimary().each(function (primary) {
|
|
setActiveMenu(container, primary);
|
|
});
|
|
};
|
|
var extractMenuFromContainer = function (container) {
|
|
return Optional.from(container.components()[0]).filter(function (comp) {
|
|
return get$b(comp.element, 'role') === 'menu';
|
|
});
|
|
};
|
|
var repositionMenus = function (container) {
|
|
var maybeActivePrimary = layeredState.getPrimary().bind(function (primary) {
|
|
return getActiveItem(container).bind(function (currentItem) {
|
|
var itemValue = getItemValue(currentItem);
|
|
var allMenus = values(layeredState.getMenus());
|
|
var preparedMenus = cat(map$2(allMenus, LayeredState.extractPreparedMenu));
|
|
return layeredState.getTriggeringPath(itemValue, function (v) {
|
|
return getItemByValue(container, preparedMenus, v);
|
|
});
|
|
}).map(function (triggeringPath) {
|
|
return {
|
|
primary: primary,
|
|
triggeringPath: triggeringPath
|
|
};
|
|
});
|
|
});
|
|
maybeActivePrimary.fold(function () {
|
|
extractMenuFromContainer(container).each(function (primaryMenu) {
|
|
detail.onRepositionMenu(container, primaryMenu, []);
|
|
});
|
|
}, function (_a) {
|
|
var primary = _a.primary, triggeringPath = _a.triggeringPath;
|
|
detail.onRepositionMenu(container, primary, triggeringPath);
|
|
});
|
|
};
|
|
var apis = {
|
|
collapseMenu: collapseMenuApi,
|
|
highlightPrimary: highlightPrimary,
|
|
repositionMenus: repositionMenus
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
markers: detail.markers,
|
|
behaviours: augment(detail.tmenuBehaviours, [
|
|
Keying.config({
|
|
mode: 'special',
|
|
onRight: keyOnItem(onRight),
|
|
onLeft: keyOnItem(onLeft),
|
|
onEscape: keyOnItem(onEscape),
|
|
focusIn: function (container, _keyInfo) {
|
|
layeredState.getPrimary().each(function (primary) {
|
|
dispatch(container, primary.element, focusItem());
|
|
});
|
|
}
|
|
}),
|
|
Highlighting.config({
|
|
highlightClass: detail.markers.selectedMenu,
|
|
itemClass: detail.markers.menu
|
|
}),
|
|
Composing.config({
|
|
find: function (container) {
|
|
return Highlighting.getHighlighted(container);
|
|
}
|
|
}),
|
|
Replacing.config({})
|
|
]),
|
|
eventOrder: detail.eventOrder,
|
|
apis: apis,
|
|
events: events
|
|
};
|
|
};
|
|
var collapseItem$1 = constant$1('collapse-item');
|
|
|
|
var tieredData = function (primary, menus, expansions) {
|
|
return {
|
|
primary: primary,
|
|
menus: menus,
|
|
expansions: expansions
|
|
};
|
|
};
|
|
var singleData = function (name, menu) {
|
|
return {
|
|
primary: name,
|
|
menus: wrap(name, menu),
|
|
expansions: {}
|
|
};
|
|
};
|
|
var collapseItem = function (text) {
|
|
return {
|
|
value: generate$4(collapseItem$1()),
|
|
meta: { text: text }
|
|
};
|
|
};
|
|
var tieredMenu = single({
|
|
name: 'TieredMenu',
|
|
configFields: [
|
|
onStrictKeyboardHandler('onExecute'),
|
|
onStrictKeyboardHandler('onEscape'),
|
|
onStrictHandler('onOpenMenu'),
|
|
onStrictHandler('onOpenSubmenu'),
|
|
onHandler('onRepositionMenu'),
|
|
onHandler('onCollapseMenu'),
|
|
defaulted('highlightImmediately', true),
|
|
requiredObjOf('data', [
|
|
required$1('primary'),
|
|
required$1('menus'),
|
|
required$1('expansions')
|
|
]),
|
|
defaulted('fakeFocus', false),
|
|
onHandler('onHighlight'),
|
|
onHandler('onHover'),
|
|
tieredMenuMarkers(),
|
|
required$1('dom'),
|
|
defaulted('navigateOnHover', true),
|
|
defaulted('stayInDom', false),
|
|
field$1('tmenuBehaviours', [
|
|
Keying,
|
|
Highlighting,
|
|
Composing,
|
|
Replacing
|
|
]),
|
|
defaulted('eventOrder', {})
|
|
],
|
|
apis: {
|
|
collapseMenu: function (apis, tmenu) {
|
|
apis.collapseMenu(tmenu);
|
|
},
|
|
highlightPrimary: function (apis, tmenu) {
|
|
apis.highlightPrimary(tmenu);
|
|
},
|
|
repositionMenus: function (apis, tmenu) {
|
|
apis.repositionMenus(tmenu);
|
|
}
|
|
},
|
|
factory: make$1,
|
|
extraApis: {
|
|
tieredData: tieredData,
|
|
singleData: singleData,
|
|
collapseItem: collapseItem
|
|
}
|
|
});
|
|
|
|
var findRoute = function (component, transConfig, transState, route) {
|
|
return get$c(transConfig.routes, route.start).bind(function (sConfig) {
|
|
return get$c(sConfig, route.destination);
|
|
});
|
|
};
|
|
var getTransition = function (comp, transConfig, transState) {
|
|
var route = getCurrentRoute(comp, transConfig);
|
|
return route.bind(function (r) {
|
|
return getTransitionOf(comp, transConfig, transState, r);
|
|
});
|
|
};
|
|
var getTransitionOf = function (comp, transConfig, transState, route) {
|
|
return findRoute(comp, transConfig, transState, route).bind(function (r) {
|
|
return r.transition.map(function (t) {
|
|
return {
|
|
transition: t,
|
|
route: r
|
|
};
|
|
});
|
|
});
|
|
};
|
|
var disableTransition = function (comp, transConfig, transState) {
|
|
getTransition(comp, transConfig, transState).each(function (routeTransition) {
|
|
var t = routeTransition.transition;
|
|
remove$3(comp.element, t.transitionClass);
|
|
remove$6(comp.element, transConfig.destinationAttr);
|
|
});
|
|
};
|
|
var getNewRoute = function (comp, transConfig, transState, destination) {
|
|
return {
|
|
start: get$b(comp.element, transConfig.stateAttr),
|
|
destination: destination
|
|
};
|
|
};
|
|
var getCurrentRoute = function (comp, transConfig, _transState) {
|
|
var el = comp.element;
|
|
return getOpt(el, transConfig.destinationAttr).map(function (destination) {
|
|
return {
|
|
start: get$b(comp.element, transConfig.stateAttr),
|
|
destination: destination
|
|
};
|
|
});
|
|
};
|
|
var jumpTo = function (comp, transConfig, transState, destination) {
|
|
disableTransition(comp, transConfig, transState);
|
|
if (has$1(comp.element, transConfig.stateAttr) && get$b(comp.element, transConfig.stateAttr) !== destination) {
|
|
transConfig.onFinish(comp, destination);
|
|
}
|
|
set$8(comp.element, transConfig.stateAttr, destination);
|
|
};
|
|
var fasttrack = function (comp, transConfig, _transState, _destination) {
|
|
if (has$1(comp.element, transConfig.destinationAttr)) {
|
|
getOpt(comp.element, transConfig.destinationAttr).each(function (destination) {
|
|
set$8(comp.element, transConfig.stateAttr, destination);
|
|
});
|
|
remove$6(comp.element, transConfig.destinationAttr);
|
|
}
|
|
};
|
|
var progressTo = function (comp, transConfig, transState, destination) {
|
|
fasttrack(comp, transConfig);
|
|
var route = getNewRoute(comp, transConfig, transState, destination);
|
|
getTransitionOf(comp, transConfig, transState, route).fold(function () {
|
|
jumpTo(comp, transConfig, transState, destination);
|
|
}, function (routeTransition) {
|
|
disableTransition(comp, transConfig, transState);
|
|
var t = routeTransition.transition;
|
|
add$1(comp.element, t.transitionClass);
|
|
set$8(comp.element, transConfig.destinationAttr, destination);
|
|
});
|
|
};
|
|
var getState = function (comp, transConfig, _transState) {
|
|
return getOpt(comp.element, transConfig.stateAttr);
|
|
};
|
|
|
|
var TransitionApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
findRoute: findRoute,
|
|
disableTransition: disableTransition,
|
|
getCurrentRoute: getCurrentRoute,
|
|
jumpTo: jumpTo,
|
|
progressTo: progressTo,
|
|
getState: getState
|
|
});
|
|
|
|
var events$1 = function (transConfig, transState) {
|
|
return derive$3([
|
|
run(transitionend(), function (component, simulatedEvent) {
|
|
var raw = simulatedEvent.event.raw;
|
|
getCurrentRoute(component, transConfig).each(function (route) {
|
|
findRoute(component, transConfig, transState, route).each(function (rInfo) {
|
|
rInfo.transition.each(function (rTransition) {
|
|
if (raw.propertyName === rTransition.property) {
|
|
jumpTo(component, transConfig, transState, route.destination);
|
|
transConfig.onTransition(component, route);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}),
|
|
runOnAttached(function (comp, _se) {
|
|
jumpTo(comp, transConfig, transState, transConfig.initialState);
|
|
})
|
|
]);
|
|
};
|
|
|
|
var ActiveTransitioning = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
events: events$1
|
|
});
|
|
|
|
var TransitionSchema = [
|
|
defaulted('destinationAttr', 'data-transitioning-destination'),
|
|
defaulted('stateAttr', 'data-transitioning-state'),
|
|
required$1('initialState'),
|
|
onHandler('onTransition'),
|
|
onHandler('onFinish'),
|
|
requiredOf('routes', setOf(Result.value, setOf(Result.value, objOfOnly([optionObjOfOnly('transition', [
|
|
required$1('property'),
|
|
required$1('transitionClass')
|
|
])]))))
|
|
];
|
|
|
|
var createRoutes = function (routes) {
|
|
var r = {};
|
|
each(routes, function (v, k) {
|
|
var waypoints = k.split('<->');
|
|
r[waypoints[0]] = wrap(waypoints[1], v);
|
|
r[waypoints[1]] = wrap(waypoints[0], v);
|
|
});
|
|
return r;
|
|
};
|
|
var createBistate = function (first, second, transitions) {
|
|
return wrapAll([
|
|
{
|
|
key: first,
|
|
value: wrap(second, transitions)
|
|
},
|
|
{
|
|
key: second,
|
|
value: wrap(first, transitions)
|
|
}
|
|
]);
|
|
};
|
|
var createTristate = function (first, second, third, transitions) {
|
|
return wrapAll([
|
|
{
|
|
key: first,
|
|
value: wrapAll([
|
|
{
|
|
key: second,
|
|
value: transitions
|
|
},
|
|
{
|
|
key: third,
|
|
value: transitions
|
|
}
|
|
])
|
|
},
|
|
{
|
|
key: second,
|
|
value: wrapAll([
|
|
{
|
|
key: first,
|
|
value: transitions
|
|
},
|
|
{
|
|
key: third,
|
|
value: transitions
|
|
}
|
|
])
|
|
},
|
|
{
|
|
key: third,
|
|
value: wrapAll([
|
|
{
|
|
key: first,
|
|
value: transitions
|
|
},
|
|
{
|
|
key: second,
|
|
value: transitions
|
|
}
|
|
])
|
|
}
|
|
]);
|
|
};
|
|
var Transitioning = create$5({
|
|
fields: TransitionSchema,
|
|
name: 'transitioning',
|
|
active: ActiveTransitioning,
|
|
apis: TransitionApis,
|
|
extra: {
|
|
createRoutes: createRoutes,
|
|
createBistate: createBistate,
|
|
createTristate: createTristate
|
|
}
|
|
});
|
|
|
|
var scrollableStyle = resolve('scrollable');
|
|
var register$2 = function (element) {
|
|
add$1(element, scrollableStyle);
|
|
};
|
|
var deregister = function (element) {
|
|
remove$3(element, scrollableStyle);
|
|
};
|
|
var scrollable = scrollableStyle;
|
|
|
|
var getValue = function (item) {
|
|
return get$c(item, 'format').getOr(item.title);
|
|
};
|
|
var convert = function (formats, memMenuThunk) {
|
|
var mainMenu = makeMenu('Styles', [].concat(map$2(formats.items, function (k) {
|
|
return makeItem(getValue(k), k.title, k.isSelected(), k.getPreview(), hasNonNullableKey(formats.expansions, getValue(k)));
|
|
})), memMenuThunk, false);
|
|
var submenus = map$1(formats.menus, function (menuItems, menuName) {
|
|
var items = map$2(menuItems, function (item) {
|
|
return makeItem(getValue(item), item.title, item.isSelected !== undefined ? item.isSelected() : false, item.getPreview !== undefined ? item.getPreview() : '', hasNonNullableKey(formats.expansions, getValue(item)));
|
|
});
|
|
return makeMenu(menuName, items, memMenuThunk, true);
|
|
});
|
|
var menus = deepMerge(submenus, wrap('styles', mainMenu));
|
|
var tmenu = tieredMenu.tieredData('styles', menus, formats.expansions);
|
|
return { tmenu: tmenu };
|
|
};
|
|
var makeItem = function (value, text, selected, preview, isMenu) {
|
|
return {
|
|
data: {
|
|
value: value,
|
|
text: text
|
|
},
|
|
type: 'item',
|
|
dom: {
|
|
tag: 'div',
|
|
classes: isMenu ? [resolve('styles-item-is-menu')] : []
|
|
},
|
|
toggling: {
|
|
toggleOnExecute: false,
|
|
toggleClass: resolve('format-matches'),
|
|
selected: selected
|
|
},
|
|
itemBehaviours: derive$2(isMenu ? [] : [format(value, function (comp, status) {
|
|
var toggle = status ? Toggling.on : Toggling.off;
|
|
toggle(comp);
|
|
})]),
|
|
components: [{
|
|
dom: {
|
|
tag: 'div',
|
|
attributes: { style: preview },
|
|
innerHtml: text
|
|
}
|
|
}]
|
|
};
|
|
};
|
|
var makeMenu = function (value, items, memMenuThunk, collapsable) {
|
|
return {
|
|
value: value,
|
|
dom: { tag: 'div' },
|
|
components: [
|
|
Button.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [resolve('styles-collapser')]
|
|
},
|
|
components: collapsable ? [
|
|
{
|
|
dom: {
|
|
tag: 'span',
|
|
classes: [resolve('styles-collapse-icon')]
|
|
}
|
|
},
|
|
text(value)
|
|
] : [text(value)],
|
|
action: function (item) {
|
|
if (collapsable) {
|
|
var comp = memMenuThunk().get(item);
|
|
tieredMenu.collapseMenu(comp);
|
|
}
|
|
}
|
|
}),
|
|
{
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [resolve('styles-menu-items-container')]
|
|
},
|
|
components: [Menu.parts.items({})],
|
|
behaviours: derive$2([config('adhoc-scrollable-menu', [
|
|
runOnAttached(function (component, _simulatedEvent) {
|
|
set$5(component.element, 'overflow-y', 'auto');
|
|
set$5(component.element, '-webkit-overflow-scrolling', 'touch');
|
|
register$2(component.element);
|
|
}),
|
|
runOnDetached(function (component) {
|
|
remove$2(component.element, 'overflow-y');
|
|
remove$2(component.element, '-webkit-overflow-scrolling');
|
|
deregister(component.element);
|
|
})
|
|
])])
|
|
}
|
|
],
|
|
items: items,
|
|
menuBehaviours: derive$2([Transitioning.config({
|
|
initialState: 'after',
|
|
routes: Transitioning.createTristate('before', 'current', 'after', {
|
|
transition: {
|
|
property: 'transform',
|
|
transitionClass: 'transitioning'
|
|
}
|
|
})
|
|
})])
|
|
};
|
|
};
|
|
var sketch$1 = function (settings) {
|
|
var dataset = convert(settings.formats, function () {
|
|
return memMenu;
|
|
});
|
|
var memMenu = record(tieredMenu.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [resolve('styles-menu')]
|
|
},
|
|
components: [],
|
|
fakeFocus: true,
|
|
stayInDom: true,
|
|
onExecute: function (_tmenu, item) {
|
|
var v = Representing.getValue(item);
|
|
settings.handle(item, v.value);
|
|
return Optional.none();
|
|
},
|
|
onEscape: function () {
|
|
return Optional.none();
|
|
},
|
|
onOpenMenu: function (container, menu) {
|
|
var w = get$5(container.element);
|
|
set$4(menu.element, w);
|
|
Transitioning.jumpTo(menu, 'current');
|
|
},
|
|
onOpenSubmenu: function (container, item, submenu) {
|
|
var w = get$5(container.element);
|
|
var menu = ancestor(item.element, '[role="menu"]').getOrDie('hacky');
|
|
var menuComp = container.getSystem().getByDom(menu).getOrDie();
|
|
set$4(submenu.element, w);
|
|
Transitioning.progressTo(menuComp, 'before');
|
|
Transitioning.jumpTo(submenu, 'after');
|
|
Transitioning.progressTo(submenu, 'current');
|
|
},
|
|
onCollapseMenu: function (container, item, menu) {
|
|
var submenu = ancestor(item.element, '[role="menu"]').getOrDie('hacky');
|
|
var submenuComp = container.getSystem().getByDom(submenu).getOrDie();
|
|
Transitioning.progressTo(submenuComp, 'after');
|
|
Transitioning.progressTo(menu, 'current');
|
|
},
|
|
navigateOnHover: false,
|
|
highlightImmediately: true,
|
|
data: dataset.tmenu,
|
|
markers: {
|
|
backgroundMenu: resolve('styles-background-menu'),
|
|
menu: resolve('styles-menu'),
|
|
selectedMenu: resolve('styles-selected-menu'),
|
|
item: resolve('styles-item'),
|
|
selectedItem: resolve('styles-selected-item')
|
|
}
|
|
}));
|
|
return memMenu.asSpec();
|
|
};
|
|
|
|
var getFromExpandingItem = function (item) {
|
|
var newItem = deepMerge(exclude(item, ['items']), { menu: true });
|
|
var rest = expand(item.items);
|
|
var newMenus = deepMerge(rest.menus, wrap(item.title, rest.items));
|
|
var newExpansions = deepMerge(rest.expansions, wrap(item.title, item.title));
|
|
return {
|
|
item: newItem,
|
|
menus: newMenus,
|
|
expansions: newExpansions
|
|
};
|
|
};
|
|
var getFromItem = function (item) {
|
|
return hasNonNullableKey(item, 'items') ? getFromExpandingItem(item) : {
|
|
item: item,
|
|
menus: {},
|
|
expansions: {}
|
|
};
|
|
};
|
|
var expand = function (items) {
|
|
return foldr(items, function (acc, item) {
|
|
var newData = getFromItem(item);
|
|
return {
|
|
menus: deepMerge(acc.menus, newData.menus),
|
|
items: [newData.item].concat(acc.items),
|
|
expansions: deepMerge(acc.expansions, newData.expansions)
|
|
};
|
|
}, {
|
|
menus: {},
|
|
expansions: {},
|
|
items: []
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
var isSelectedFor = function (format) {
|
|
return function () {
|
|
return editor.formatter.match(format);
|
|
};
|
|
};
|
|
var getPreview = function (format) {
|
|
return function () {
|
|
return editor.formatter.getCssText(format);
|
|
};
|
|
};
|
|
var enrichSupported = function (item) {
|
|
return deepMerge(item, {
|
|
isSelected: isSelectedFor(item.format),
|
|
getPreview: getPreview(item.format)
|
|
});
|
|
};
|
|
var enrichMenu = function (item) {
|
|
return deepMerge(item, {
|
|
isSelected: never,
|
|
getPreview: constant$1('')
|
|
});
|
|
};
|
|
var enrichCustom = function (item) {
|
|
var formatName = generate$4(item.title);
|
|
var newItem = deepMerge(item, {
|
|
format: formatName,
|
|
isSelected: isSelectedFor(formatName),
|
|
getPreview: getPreview(formatName)
|
|
});
|
|
editor.formatter.register(formatName, newItem);
|
|
return newItem;
|
|
};
|
|
var doEnrich = function (items) {
|
|
return map$2(items, function (item) {
|
|
if (hasNonNullableKey(item, 'items')) {
|
|
var newItems = doEnrich(item.items);
|
|
return deepMerge(enrichMenu(item), { items: newItems });
|
|
} else if (hasNonNullableKey(item, 'format')) {
|
|
return enrichSupported(item);
|
|
} else {
|
|
return enrichCustom(item);
|
|
}
|
|
});
|
|
};
|
|
return doEnrich(getStyleFormats(editor));
|
|
};
|
|
var prune = function (editor, formats) {
|
|
var doPrune = function (items) {
|
|
return bind$3(items, function (item) {
|
|
if (item.items !== undefined) {
|
|
var newItems = doPrune(item.items);
|
|
return newItems.length > 0 ? [item] : [];
|
|
} else {
|
|
var keep = hasNonNullableKey(item, 'format') ? editor.formatter.canApply(item.format) : true;
|
|
return keep ? [item] : [];
|
|
}
|
|
});
|
|
};
|
|
var prunedItems = doPrune(formats);
|
|
return expand(prunedItems);
|
|
};
|
|
var ui = function (editor, formats, onDone) {
|
|
var pruned = prune(editor, formats);
|
|
return sketch$1({
|
|
formats: pruned,
|
|
handle: function (item, value) {
|
|
editor.undoManager.transact(function () {
|
|
if (Toggling.isOn(item)) {
|
|
editor.formatter.remove(value);
|
|
} else {
|
|
editor.formatter.apply(value);
|
|
}
|
|
});
|
|
onDone();
|
|
}
|
|
});
|
|
};
|
|
|
|
var extract = function (rawToolbar) {
|
|
var toolbar = rawToolbar.replace(/\|/g, ' ').trim();
|
|
return toolbar.length > 0 ? toolbar.split(/\s+/) : [];
|
|
};
|
|
var identifyFromArray = function (toolbar) {
|
|
return bind$3(toolbar, function (item) {
|
|
return isArray(item) ? identifyFromArray(item) : extract(item);
|
|
});
|
|
};
|
|
var identify = function (editor) {
|
|
var toolbar = getToolbar(editor);
|
|
return isArray(toolbar) ? identifyFromArray(toolbar) : extract(toolbar);
|
|
};
|
|
var setup$3 = function (realm, editor) {
|
|
var commandSketch = function (name) {
|
|
return function () {
|
|
return forToolbarCommand(editor, name);
|
|
};
|
|
};
|
|
var stateCommandSketch = function (name) {
|
|
return function () {
|
|
return forToolbarStateCommand(editor, name);
|
|
};
|
|
};
|
|
var actionSketch = function (name, query, action) {
|
|
return function () {
|
|
return forToolbarStateAction(editor, name, query, action);
|
|
};
|
|
};
|
|
var undo = commandSketch('undo');
|
|
var redo = commandSketch('redo');
|
|
var bold = stateCommandSketch('bold');
|
|
var italic = stateCommandSketch('italic');
|
|
var underline = stateCommandSketch('underline');
|
|
var removeformat = commandSketch('removeformat');
|
|
var link = function () {
|
|
return sketch$2(realm, editor);
|
|
};
|
|
var unlink = actionSketch('unlink', 'link', function () {
|
|
editor.execCommand('unlink', null, false);
|
|
});
|
|
var image = function () {
|
|
return sketch$5(editor);
|
|
};
|
|
var bullist = actionSketch('unordered-list', 'ul', function () {
|
|
editor.execCommand('InsertUnorderedList', null, false);
|
|
});
|
|
var numlist = actionSketch('ordered-list', 'ol', function () {
|
|
editor.execCommand('InsertOrderedList', null, false);
|
|
});
|
|
var fontsizeselect = function () {
|
|
return sketch$6(realm, editor);
|
|
};
|
|
var forecolor = function () {
|
|
return sketch$8(realm, editor);
|
|
};
|
|
var styleFormats = register$1(editor);
|
|
var styleFormatsMenu = function () {
|
|
return ui(editor, styleFormats, function () {
|
|
editor.fire('scrollIntoView');
|
|
});
|
|
};
|
|
var styleselect = function () {
|
|
return forToolbar('style-formats', function (button) {
|
|
editor.fire('toReading');
|
|
realm.dropup.appear(styleFormatsMenu, Toggling.on, button);
|
|
}, derive$2([
|
|
Toggling.config({
|
|
toggleClass: resolve('toolbar-button-selected'),
|
|
toggleOnExecute: false,
|
|
aria: { mode: 'pressed' }
|
|
}),
|
|
Receiving.config({
|
|
channels: wrapAll([
|
|
receive(orientationChanged, Toggling.off),
|
|
receive(dropupDismissed, Toggling.off)
|
|
])
|
|
})
|
|
]), editor);
|
|
};
|
|
var feature = function (prereq, sketch) {
|
|
return {
|
|
isSupported: function () {
|
|
var buttons = editor.ui.registry.getAll().buttons;
|
|
return prereq.forall(function (p) {
|
|
return hasNonNullableKey(buttons, p);
|
|
});
|
|
},
|
|
sketch: sketch
|
|
};
|
|
};
|
|
return {
|
|
undo: feature(Optional.none(), undo),
|
|
redo: feature(Optional.none(), redo),
|
|
bold: feature(Optional.none(), bold),
|
|
italic: feature(Optional.none(), italic),
|
|
underline: feature(Optional.none(), underline),
|
|
removeformat: feature(Optional.none(), removeformat),
|
|
link: feature(Optional.none(), link),
|
|
unlink: feature(Optional.none(), unlink),
|
|
image: feature(Optional.none(), image),
|
|
bullist: feature(Optional.some('bullist'), bullist),
|
|
numlist: feature(Optional.some('numlist'), numlist),
|
|
fontsizeselect: feature(Optional.none(), fontsizeselect),
|
|
forecolor: feature(Optional.none(), forecolor),
|
|
styleselect: feature(Optional.none(), styleselect)
|
|
};
|
|
};
|
|
var detect = function (editor, features) {
|
|
var itemNames = identify(editor);
|
|
var present = {};
|
|
return bind$3(itemNames, function (iName) {
|
|
var r = !hasNonNullableKey(present, iName) && hasNonNullableKey(features, iName) && features[iName].isSupported() ? [features[iName].sketch()] : [];
|
|
present[iName] = true;
|
|
return r;
|
|
});
|
|
};
|
|
|
|
var mkEvent = function (target, x, y, stop, prevent, kill, raw) {
|
|
return {
|
|
target: target,
|
|
x: x,
|
|
y: y,
|
|
stop: stop,
|
|
prevent: prevent,
|
|
kill: kill,
|
|
raw: raw
|
|
};
|
|
};
|
|
var fromRawEvent = function (rawEvent) {
|
|
var target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target));
|
|
var stop = function () {
|
|
return rawEvent.stopPropagation();
|
|
};
|
|
var prevent = function () {
|
|
return rawEvent.preventDefault();
|
|
};
|
|
var kill = compose(prevent, stop);
|
|
return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent);
|
|
};
|
|
var handle = function (filter, handler) {
|
|
return function (rawEvent) {
|
|
if (filter(rawEvent)) {
|
|
handler(fromRawEvent(rawEvent));
|
|
}
|
|
};
|
|
};
|
|
var binder = function (element, event, filter, handler, useCapture) {
|
|
var wrapped = handle(filter, handler);
|
|
element.dom.addEventListener(event, wrapped, useCapture);
|
|
return { unbind: curry(unbind, element, event, wrapped, useCapture) };
|
|
};
|
|
var bind$1 = function (element, event, filter, handler) {
|
|
return binder(element, event, filter, handler, false);
|
|
};
|
|
var capture$1 = function (element, event, filter, handler) {
|
|
return binder(element, event, filter, handler, true);
|
|
};
|
|
var unbind = function (element, event, handler, useCapture) {
|
|
element.dom.removeEventListener(event, handler, useCapture);
|
|
};
|
|
|
|
var filter = always;
|
|
var bind = function (element, event, handler) {
|
|
return bind$1(element, event, filter, handler);
|
|
};
|
|
var capture = function (element, event, handler) {
|
|
return capture$1(element, event, filter, handler);
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var INTERVAL = 50;
|
|
var INSURANCE = 1000 / INTERVAL;
|
|
var get$1 = function (outerWindow) {
|
|
var isPortrait = outerWindow.matchMedia('(orientation: portrait)').matches;
|
|
return { isPortrait: constant$1(isPortrait) };
|
|
};
|
|
var getActualWidth = function (outerWindow) {
|
|
var isIos = detect$1().os.isiOS();
|
|
var isPortrait = get$1(outerWindow).isPortrait();
|
|
return isIos && !isPortrait ? outerWindow.screen.height : outerWindow.screen.width;
|
|
};
|
|
var onChange = function (outerWindow, listeners) {
|
|
var win = SugarElement.fromDom(outerWindow);
|
|
var poller = null;
|
|
var change = function () {
|
|
global$2.clearInterval(poller);
|
|
var orientation = get$1(outerWindow);
|
|
listeners.onChange(orientation);
|
|
onAdjustment(function () {
|
|
listeners.onReady(orientation);
|
|
});
|
|
};
|
|
var orientationHandle = bind(win, 'orientationchange', change);
|
|
var onAdjustment = function (f) {
|
|
global$2.clearInterval(poller);
|
|
var flag = outerWindow.innerHeight;
|
|
var insurance = 0;
|
|
poller = global$2.setInterval(function () {
|
|
if (flag !== outerWindow.innerHeight) {
|
|
global$2.clearInterval(poller);
|
|
f(Optional.some(outerWindow.innerHeight));
|
|
} else if (insurance > INSURANCE) {
|
|
global$2.clearInterval(poller);
|
|
f(Optional.none());
|
|
}
|
|
insurance++;
|
|
}, INTERVAL);
|
|
};
|
|
var destroy = function () {
|
|
orientationHandle.unbind();
|
|
};
|
|
return {
|
|
onAdjustment: onAdjustment,
|
|
destroy: destroy
|
|
};
|
|
};
|
|
|
|
var setStart = function (rng, situ) {
|
|
situ.fold(function (e) {
|
|
rng.setStartBefore(e.dom);
|
|
}, function (e, o) {
|
|
rng.setStart(e.dom, o);
|
|
}, function (e) {
|
|
rng.setStartAfter(e.dom);
|
|
});
|
|
};
|
|
var setFinish = function (rng, situ) {
|
|
situ.fold(function (e) {
|
|
rng.setEndBefore(e.dom);
|
|
}, function (e, o) {
|
|
rng.setEnd(e.dom, o);
|
|
}, function (e) {
|
|
rng.setEndAfter(e.dom);
|
|
});
|
|
};
|
|
var relativeToNative = function (win, startSitu, finishSitu) {
|
|
var range = win.document.createRange();
|
|
setStart(range, startSitu);
|
|
setFinish(range, finishSitu);
|
|
return range;
|
|
};
|
|
var exactToNative = function (win, start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
};
|
|
var toRect$1 = function (rect) {
|
|
return {
|
|
left: rect.left,
|
|
top: rect.top,
|
|
right: rect.right,
|
|
bottom: rect.bottom,
|
|
width: rect.width,
|
|
height: rect.height
|
|
};
|
|
};
|
|
var getFirstRect$1 = function (rng) {
|
|
var rects = rng.getClientRects();
|
|
var rect = rects.length > 0 ? rects[0] : rng.getBoundingClientRect();
|
|
return rect.width > 0 || rect.height > 0 ? Optional.some(rect).map(toRect$1) : Optional.none();
|
|
};
|
|
|
|
var adt$3 = Adt.generate([
|
|
{
|
|
ltr: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
},
|
|
{
|
|
rtl: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
}
|
|
]);
|
|
var fromRange = function (win, type, range) {
|
|
return type(SugarElement.fromDom(range.startContainer), range.startOffset, SugarElement.fromDom(range.endContainer), range.endOffset);
|
|
};
|
|
var getRanges = function (win, selection) {
|
|
return selection.match({
|
|
domRange: function (rng) {
|
|
return {
|
|
ltr: constant$1(rng),
|
|
rtl: Optional.none
|
|
};
|
|
},
|
|
relative: function (startSitu, finishSitu) {
|
|
return {
|
|
ltr: cached(function () {
|
|
return relativeToNative(win, startSitu, finishSitu);
|
|
}),
|
|
rtl: cached(function () {
|
|
return Optional.some(relativeToNative(win, finishSitu, startSitu));
|
|
})
|
|
};
|
|
},
|
|
exact: function (start, soffset, finish, foffset) {
|
|
return {
|
|
ltr: cached(function () {
|
|
return exactToNative(win, start, soffset, finish, foffset);
|
|
}),
|
|
rtl: cached(function () {
|
|
return Optional.some(exactToNative(win, finish, foffset, start, soffset));
|
|
})
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var doDiagnose = function (win, ranges) {
|
|
var rng = ranges.ltr();
|
|
if (rng.collapsed) {
|
|
var reversed = ranges.rtl().filter(function (rev) {
|
|
return rev.collapsed === false;
|
|
});
|
|
return reversed.map(function (rev) {
|
|
return adt$3.rtl(SugarElement.fromDom(rev.endContainer), rev.endOffset, SugarElement.fromDom(rev.startContainer), rev.startOffset);
|
|
}).getOrThunk(function () {
|
|
return fromRange(win, adt$3.ltr, rng);
|
|
});
|
|
} else {
|
|
return fromRange(win, adt$3.ltr, rng);
|
|
}
|
|
};
|
|
var diagnose = function (win, selection) {
|
|
var ranges = getRanges(win, selection);
|
|
return doDiagnose(win, ranges);
|
|
};
|
|
var asLtrRange = function (win, selection) {
|
|
var diagnosis = diagnose(win, selection);
|
|
return diagnosis.match({
|
|
ltr: function (start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
},
|
|
rtl: function (start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(finish.dom, foffset);
|
|
rng.setEnd(start.dom, soffset);
|
|
return rng;
|
|
}
|
|
});
|
|
};
|
|
adt$3.ltr;
|
|
adt$3.rtl;
|
|
|
|
var create$3 = function (start, soffset, finish, foffset) {
|
|
return {
|
|
start: start,
|
|
soffset: soffset,
|
|
finish: finish,
|
|
foffset: foffset
|
|
};
|
|
};
|
|
var SimRange = { create: create$3 };
|
|
|
|
var NodeValue = function (is, name) {
|
|
var get = function (element) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
return getOption(element).getOr('');
|
|
};
|
|
var getOption = function (element) {
|
|
return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
|
|
};
|
|
var set = function (element, value) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
element.dom.nodeValue = value;
|
|
};
|
|
return {
|
|
get: get,
|
|
getOption: getOption,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var api = NodeValue(isText, 'text');
|
|
var getOption = function (element) {
|
|
return api.getOption(element);
|
|
};
|
|
|
|
var getEnd = function (element) {
|
|
return name$1(element) === 'img' ? 1 : getOption(element).fold(function () {
|
|
return children(element).length;
|
|
}, function (v) {
|
|
return v.length;
|
|
});
|
|
};
|
|
|
|
var adt$2 = Adt.generate([
|
|
{ before: ['element'] },
|
|
{
|
|
on: [
|
|
'element',
|
|
'offset'
|
|
]
|
|
},
|
|
{ after: ['element'] }
|
|
]);
|
|
var cata = function (subject, onBefore, onOn, onAfter) {
|
|
return subject.fold(onBefore, onOn, onAfter);
|
|
};
|
|
var getStart$1 = function (situ) {
|
|
return situ.fold(identity, identity, identity);
|
|
};
|
|
var before = adt$2.before;
|
|
var on = adt$2.on;
|
|
var after$1 = adt$2.after;
|
|
var Situ = {
|
|
before: before,
|
|
on: on,
|
|
after: after$1,
|
|
cata: cata,
|
|
getStart: getStart$1
|
|
};
|
|
|
|
var adt$1 = Adt.generate([
|
|
{ domRange: ['rng'] },
|
|
{
|
|
relative: [
|
|
'startSitu',
|
|
'finishSitu'
|
|
]
|
|
},
|
|
{
|
|
exact: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
}
|
|
]);
|
|
var exactFromRange = function (simRange) {
|
|
return adt$1.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset);
|
|
};
|
|
var getStart = function (selection) {
|
|
return selection.match({
|
|
domRange: function (rng) {
|
|
return SugarElement.fromDom(rng.startContainer);
|
|
},
|
|
relative: function (startSitu, _finishSitu) {
|
|
return Situ.getStart(startSitu);
|
|
},
|
|
exact: function (start, _soffset, _finish, _foffset) {
|
|
return start;
|
|
}
|
|
});
|
|
};
|
|
var domRange = adt$1.domRange;
|
|
var relative = adt$1.relative;
|
|
var exact = adt$1.exact;
|
|
var getWin$1 = function (selection) {
|
|
var start = getStart(selection);
|
|
return defaultView(start);
|
|
};
|
|
var range = SimRange.create;
|
|
var SimSelection = {
|
|
domRange: domRange,
|
|
relative: relative,
|
|
exact: exact,
|
|
exactFromRange: exactFromRange,
|
|
getWin: getWin$1,
|
|
range: range
|
|
};
|
|
|
|
var beforeSpecial = function (element, offset) {
|
|
var name = name$1(element);
|
|
if ('input' === name) {
|
|
return Situ.after(element);
|
|
} else if (!contains$1([
|
|
'br',
|
|
'img'
|
|
], name)) {
|
|
return Situ.on(element, offset);
|
|
} else {
|
|
return offset === 0 ? Situ.before(element) : Situ.after(element);
|
|
}
|
|
};
|
|
var preprocessExact = function (start, soffset, finish, foffset) {
|
|
var startSitu = beforeSpecial(start, soffset);
|
|
var finishSitu = beforeSpecial(finish, foffset);
|
|
return SimSelection.relative(startSitu, finishSitu);
|
|
};
|
|
|
|
var makeRange = function (start, soffset, finish, foffset) {
|
|
var doc = owner$2(start);
|
|
var rng = doc.dom.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
};
|
|
var after = function (start, soffset, finish, foffset) {
|
|
var r = makeRange(start, soffset, finish, foffset);
|
|
var same = eq(start, finish) && soffset === foffset;
|
|
return r.collapsed && !same;
|
|
};
|
|
|
|
var getNativeSelection = function (win) {
|
|
return Optional.from(win.getSelection());
|
|
};
|
|
var doSetNativeRange = function (win, rng) {
|
|
getNativeSelection(win).each(function (selection) {
|
|
selection.removeAllRanges();
|
|
selection.addRange(rng);
|
|
});
|
|
};
|
|
var doSetRange = function (win, start, soffset, finish, foffset) {
|
|
var rng = exactToNative(win, start, soffset, finish, foffset);
|
|
doSetNativeRange(win, rng);
|
|
};
|
|
var setLegacyRtlRange = function (win, selection, start, soffset, finish, foffset) {
|
|
selection.collapse(start.dom, soffset);
|
|
selection.extend(finish.dom, foffset);
|
|
};
|
|
var setRangeFromRelative = function (win, relative) {
|
|
return diagnose(win, relative).match({
|
|
ltr: function (start, soffset, finish, foffset) {
|
|
doSetRange(win, start, soffset, finish, foffset);
|
|
},
|
|
rtl: function (start, soffset, finish, foffset) {
|
|
getNativeSelection(win).each(function (selection) {
|
|
if (selection.setBaseAndExtent) {
|
|
selection.setBaseAndExtent(start.dom, soffset, finish.dom, foffset);
|
|
} else if (selection.extend) {
|
|
try {
|
|
setLegacyRtlRange(win, selection, start, soffset, finish, foffset);
|
|
} catch (e) {
|
|
doSetRange(win, finish, foffset, start, soffset);
|
|
}
|
|
} else {
|
|
doSetRange(win, finish, foffset, start, soffset);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var setExact = function (win, start, soffset, finish, foffset) {
|
|
var relative = preprocessExact(start, soffset, finish, foffset);
|
|
setRangeFromRelative(win, relative);
|
|
};
|
|
var readRange = function (selection) {
|
|
if (selection.rangeCount > 0) {
|
|
var firstRng = selection.getRangeAt(0);
|
|
var lastRng = selection.getRangeAt(selection.rangeCount - 1);
|
|
return Optional.some(SimRange.create(SugarElement.fromDom(firstRng.startContainer), firstRng.startOffset, SugarElement.fromDom(lastRng.endContainer), lastRng.endOffset));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var doGetExact = function (selection) {
|
|
if (selection.anchorNode === null || selection.focusNode === null) {
|
|
return readRange(selection);
|
|
} else {
|
|
var anchor = SugarElement.fromDom(selection.anchorNode);
|
|
var focus_1 = SugarElement.fromDom(selection.focusNode);
|
|
return after(anchor, selection.anchorOffset, focus_1, selection.focusOffset) ? Optional.some(SimRange.create(anchor, selection.anchorOffset, focus_1, selection.focusOffset)) : readRange(selection);
|
|
}
|
|
};
|
|
var getExact = function (win) {
|
|
return getNativeSelection(win).filter(function (sel) {
|
|
return sel.rangeCount > 0;
|
|
}).bind(doGetExact);
|
|
};
|
|
var get = function (win) {
|
|
return getExact(win).map(function (range) {
|
|
return SimSelection.exact(range.start, range.soffset, range.finish, range.foffset);
|
|
});
|
|
};
|
|
var getFirstRect = function (win, selection) {
|
|
var rng = asLtrRange(win, selection);
|
|
return getFirstRect$1(rng);
|
|
};
|
|
var clear = function (win) {
|
|
getNativeSelection(win).each(function (selection) {
|
|
return selection.removeAllRanges();
|
|
});
|
|
};
|
|
|
|
var getBodyFromFrame = function (frame) {
|
|
return Optional.some(SugarElement.fromDom(frame.dom.contentWindow.document.body));
|
|
};
|
|
var getDocFromFrame = function (frame) {
|
|
return Optional.some(SugarElement.fromDom(frame.dom.contentWindow.document));
|
|
};
|
|
var getWinFromFrame = function (frame) {
|
|
return Optional.from(frame.dom.contentWindow);
|
|
};
|
|
var getSelectionFromFrame = function (frame) {
|
|
var optWin = getWinFromFrame(frame);
|
|
return optWin.bind(getExact);
|
|
};
|
|
var getFrame = function (editor) {
|
|
return editor.getFrame();
|
|
};
|
|
var getOrDerive = function (name, f) {
|
|
return function (editor) {
|
|
var g = editor[name].getOrThunk(function () {
|
|
var frame = getFrame(editor);
|
|
return function () {
|
|
return f(frame);
|
|
};
|
|
});
|
|
return g();
|
|
};
|
|
};
|
|
var getOrListen = function (editor, doc, name, type) {
|
|
return editor[name].getOrThunk(function () {
|
|
return function (handler) {
|
|
return bind(doc, type, handler);
|
|
};
|
|
});
|
|
};
|
|
var getActiveApi = function (editor) {
|
|
var frame = getFrame(editor);
|
|
var tryFallbackBox = function (win) {
|
|
var isCollapsed = function (sel) {
|
|
return eq(sel.start, sel.finish) && sel.soffset === sel.foffset;
|
|
};
|
|
var toStartRect = function (sel) {
|
|
var rect = sel.start.dom.getBoundingClientRect();
|
|
return rect.width > 0 || rect.height > 0 ? Optional.some(rect) : Optional.none();
|
|
};
|
|
return getExact(win).filter(isCollapsed).bind(toStartRect);
|
|
};
|
|
return getBodyFromFrame(frame).bind(function (body) {
|
|
return getDocFromFrame(frame).bind(function (doc) {
|
|
return getWinFromFrame(frame).map(function (win) {
|
|
var html = SugarElement.fromDom(doc.dom.documentElement);
|
|
var getCursorBox = editor.getCursorBox.getOrThunk(function () {
|
|
return function () {
|
|
return get(win).bind(function (sel) {
|
|
return getFirstRect(win, sel).orThunk(function () {
|
|
return tryFallbackBox(win);
|
|
});
|
|
});
|
|
};
|
|
});
|
|
var setSelection = editor.setSelection.getOrThunk(function () {
|
|
return function (start, soffset, finish, foffset) {
|
|
setExact(win, start, soffset, finish, foffset);
|
|
};
|
|
});
|
|
var clearSelection = editor.clearSelection.getOrThunk(function () {
|
|
return function () {
|
|
clear(win);
|
|
};
|
|
});
|
|
return {
|
|
body: body,
|
|
doc: doc,
|
|
win: win,
|
|
html: html,
|
|
getSelection: curry(getSelectionFromFrame, frame),
|
|
setSelection: setSelection,
|
|
clearSelection: clearSelection,
|
|
frame: frame,
|
|
onKeyup: getOrListen(editor, doc, 'onKeyup', 'keyup'),
|
|
onNodeChanged: getOrListen(editor, doc, 'onNodeChanged', 'SelectionChange'),
|
|
onDomChanged: editor.onDomChanged,
|
|
onScrollToCursor: editor.onScrollToCursor,
|
|
onScrollToElement: editor.onScrollToElement,
|
|
onToReading: editor.onToReading,
|
|
onToEditing: editor.onToEditing,
|
|
onToolbarScrollStart: editor.onToolbarScrollStart,
|
|
onTouchContent: editor.onTouchContent,
|
|
onTapContent: editor.onTapContent,
|
|
onTouchToolstrip: editor.onTouchToolstrip,
|
|
getCursorBox: getCursorBox
|
|
};
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var getWin = getOrDerive('getWin', getWinFromFrame);
|
|
|
|
var tag = function () {
|
|
var head = first$1('head').getOrDie();
|
|
var nu = function () {
|
|
var meta = SugarElement.fromTag('meta');
|
|
set$8(meta, 'name', 'viewport');
|
|
append$2(head, meta);
|
|
return meta;
|
|
};
|
|
var element = first$1('meta[name="viewport"]').getOrThunk(nu);
|
|
var backup = get$b(element, 'content');
|
|
var maximize = function () {
|
|
set$8(element, 'content', 'width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0');
|
|
};
|
|
var restore = function () {
|
|
if (backup !== undefined && backup !== null && backup.length > 0) {
|
|
set$8(element, 'content', backup);
|
|
} else {
|
|
set$8(element, 'content', 'user-scalable=yes');
|
|
}
|
|
};
|
|
return {
|
|
maximize: maximize,
|
|
restore: restore
|
|
};
|
|
};
|
|
|
|
var attr = 'data-ephox-mobile-fullscreen-style';
|
|
var siblingStyles = 'display:none!important;';
|
|
var ancestorPosition = 'position:absolute!important;';
|
|
var ancestorStyles = 'top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;';
|
|
var bgFallback = 'background-color:rgb(255,255,255)!important;';
|
|
var isAndroid = detect$1().os.isAndroid();
|
|
var matchColor = function (editorBody) {
|
|
var color = get$8(editorBody, 'background-color');
|
|
return color !== undefined && color !== '' ? 'background-color:' + color + '!important' : bgFallback;
|
|
};
|
|
var clobberStyles = function (container, editorBody) {
|
|
var gatherSiblings = function (element) {
|
|
return siblings(element, '*');
|
|
};
|
|
var clobber = function (clobberStyle) {
|
|
return function (element) {
|
|
var styles = get$b(element, 'style');
|
|
var backup = styles === undefined ? 'no-styles' : styles.trim();
|
|
if (backup === clobberStyle) {
|
|
return;
|
|
} else {
|
|
set$8(element, attr, backup);
|
|
set$8(element, 'style', clobberStyle);
|
|
}
|
|
};
|
|
};
|
|
var ancestors$1 = ancestors(container, '*');
|
|
var siblings$1 = bind$3(ancestors$1, gatherSiblings);
|
|
var bgColor = matchColor(editorBody);
|
|
each$1(siblings$1, clobber(siblingStyles));
|
|
each$1(ancestors$1, clobber(ancestorPosition + ancestorStyles + bgColor));
|
|
var containerStyles = isAndroid === true ? '' : ancestorPosition;
|
|
clobber(containerStyles + ancestorStyles + bgColor)(container);
|
|
};
|
|
var restoreStyles = function () {
|
|
var clobberedEls = all('[' + attr + ']');
|
|
each$1(clobberedEls, function (element) {
|
|
var restore = get$b(element, attr);
|
|
if (restore !== 'no-styles') {
|
|
set$8(element, 'style', restore);
|
|
} else {
|
|
remove$6(element, 'style');
|
|
}
|
|
remove$6(element, attr);
|
|
});
|
|
};
|
|
|
|
var DelayedFunction = function (fun, delay) {
|
|
var ref = null;
|
|
var schedule = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
ref = setTimeout(function () {
|
|
fun.apply(null, args);
|
|
ref = null;
|
|
}, delay);
|
|
};
|
|
var cancel = function () {
|
|
if (ref !== null) {
|
|
clearTimeout(ref);
|
|
ref = null;
|
|
}
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
schedule: schedule
|
|
};
|
|
};
|
|
|
|
var SIGNIFICANT_MOVE = 5;
|
|
var LONGPRESS_DELAY = 400;
|
|
var getTouch = function (event) {
|
|
var raw = event.raw;
|
|
if (raw.touches === undefined || raw.touches.length !== 1) {
|
|
return Optional.none();
|
|
}
|
|
return Optional.some(raw.touches[0]);
|
|
};
|
|
var isFarEnough = function (touch, data) {
|
|
var distX = Math.abs(touch.clientX - data.x);
|
|
var distY = Math.abs(touch.clientY - data.y);
|
|
return distX > SIGNIFICANT_MOVE || distY > SIGNIFICANT_MOVE;
|
|
};
|
|
var monitor$1 = function (settings) {
|
|
var startData = value();
|
|
var longpressFired = Cell(false);
|
|
var longpress$1 = DelayedFunction(function (event) {
|
|
settings.triggerEvent(longpress(), event);
|
|
longpressFired.set(true);
|
|
}, LONGPRESS_DELAY);
|
|
var handleTouchstart = function (event) {
|
|
getTouch(event).each(function (touch) {
|
|
longpress$1.cancel();
|
|
var data = {
|
|
x: touch.clientX,
|
|
y: touch.clientY,
|
|
target: event.target
|
|
};
|
|
longpress$1.schedule(event);
|
|
longpressFired.set(false);
|
|
startData.set(data);
|
|
});
|
|
return Optional.none();
|
|
};
|
|
var handleTouchmove = function (event) {
|
|
longpress$1.cancel();
|
|
getTouch(event).each(function (touch) {
|
|
startData.on(function (data) {
|
|
if (isFarEnough(touch, data)) {
|
|
startData.clear();
|
|
}
|
|
});
|
|
});
|
|
return Optional.none();
|
|
};
|
|
var handleTouchend = function (event) {
|
|
longpress$1.cancel();
|
|
var isSame = function (data) {
|
|
return eq(data.target, event.target);
|
|
};
|
|
return startData.get().filter(isSame).map(function (_data) {
|
|
if (longpressFired.get()) {
|
|
event.prevent();
|
|
return false;
|
|
} else {
|
|
return settings.triggerEvent(tap(), event);
|
|
}
|
|
});
|
|
};
|
|
var handlers = wrapAll([
|
|
{
|
|
key: touchstart(),
|
|
value: handleTouchstart
|
|
},
|
|
{
|
|
key: touchmove(),
|
|
value: handleTouchmove
|
|
},
|
|
{
|
|
key: touchend(),
|
|
value: handleTouchend
|
|
}
|
|
]);
|
|
var fireIfReady = function (event, type) {
|
|
return get$c(handlers, type).bind(function (handler) {
|
|
return handler(event);
|
|
});
|
|
};
|
|
return { fireIfReady: fireIfReady };
|
|
};
|
|
|
|
var monitor = function (editorApi) {
|
|
var tapEvent = monitor$1({
|
|
triggerEvent: function (type, evt) {
|
|
editorApi.onTapContent(evt);
|
|
}
|
|
});
|
|
var onTouchend = function () {
|
|
return bind(editorApi.body, 'touchend', function (evt) {
|
|
tapEvent.fireIfReady(evt, 'touchend');
|
|
});
|
|
};
|
|
var onTouchmove = function () {
|
|
return bind(editorApi.body, 'touchmove', function (evt) {
|
|
tapEvent.fireIfReady(evt, 'touchmove');
|
|
});
|
|
};
|
|
var fireTouchstart = function (evt) {
|
|
tapEvent.fireIfReady(evt, 'touchstart');
|
|
};
|
|
return {
|
|
fireTouchstart: fireTouchstart,
|
|
onTouchend: onTouchend,
|
|
onTouchmove: onTouchmove
|
|
};
|
|
};
|
|
|
|
var isAndroid6 = detect$1().os.version.major >= 6;
|
|
var initEvents$1 = function (editorApi, toolstrip, alloy) {
|
|
var tapping = monitor(editorApi);
|
|
var outerDoc = owner$2(toolstrip);
|
|
var isRanged = function (sel) {
|
|
return !eq(sel.start, sel.finish) || sel.soffset !== sel.foffset;
|
|
};
|
|
var hasRangeInUi = function () {
|
|
return active(outerDoc).filter(function (input) {
|
|
return name$1(input) === 'input';
|
|
}).exists(function (input) {
|
|
return input.dom.selectionStart !== input.dom.selectionEnd;
|
|
});
|
|
};
|
|
var updateMargin = function () {
|
|
var rangeInContent = editorApi.doc.dom.hasFocus() && editorApi.getSelection().exists(isRanged);
|
|
alloy.getByDom(toolstrip).each((rangeInContent || hasRangeInUi()) === true ? Toggling.on : Toggling.off);
|
|
};
|
|
var listeners = [
|
|
bind(editorApi.body, 'touchstart', function (evt) {
|
|
editorApi.onTouchContent();
|
|
tapping.fireTouchstart(evt);
|
|
}),
|
|
tapping.onTouchmove(),
|
|
tapping.onTouchend(),
|
|
bind(toolstrip, 'touchstart', function (_evt) {
|
|
editorApi.onTouchToolstrip();
|
|
}),
|
|
editorApi.onToReading(function () {
|
|
blur$1(editorApi.body);
|
|
}),
|
|
editorApi.onToEditing(noop),
|
|
editorApi.onScrollToCursor(function (tinyEvent) {
|
|
tinyEvent.preventDefault();
|
|
editorApi.getCursorBox().each(function (bounds) {
|
|
var cWin = editorApi.win;
|
|
var isOutside = bounds.top > cWin.innerHeight || bounds.bottom > cWin.innerHeight;
|
|
var cScrollBy = isOutside ? bounds.bottom - cWin.innerHeight + 50 : 0;
|
|
if (cScrollBy !== 0) {
|
|
cWin.scrollTo(cWin.pageXOffset, cWin.pageYOffset + cScrollBy);
|
|
}
|
|
});
|
|
})
|
|
].concat(isAndroid6 === true ? [] : [
|
|
bind(SugarElement.fromDom(editorApi.win), 'blur', function () {
|
|
alloy.getByDom(toolstrip).each(Toggling.off);
|
|
}),
|
|
bind(outerDoc, 'select', updateMargin),
|
|
bind(editorApi.doc, 'selectionchange', updateMargin)
|
|
]);
|
|
var destroy = function () {
|
|
each$1(listeners, function (l) {
|
|
l.unbind();
|
|
});
|
|
};
|
|
return { destroy: destroy };
|
|
};
|
|
|
|
var safeParse = function (element, attribute) {
|
|
var parsed = parseInt(get$b(element, attribute), 10);
|
|
return isNaN(parsed) ? 0 : parsed;
|
|
};
|
|
|
|
var COLLAPSED_WIDTH = 2;
|
|
var collapsedRect = function (rect) {
|
|
return __assign(__assign({}, rect), { width: COLLAPSED_WIDTH });
|
|
};
|
|
var toRect = function (rawRect) {
|
|
return {
|
|
left: rawRect.left,
|
|
top: rawRect.top,
|
|
right: rawRect.right,
|
|
bottom: rawRect.bottom,
|
|
width: rawRect.width,
|
|
height: rawRect.height
|
|
};
|
|
};
|
|
var getRectsFromRange = function (range) {
|
|
if (!range.collapsed) {
|
|
return map$2(range.getClientRects(), toRect);
|
|
} else {
|
|
var start_1 = SugarElement.fromDom(range.startContainer);
|
|
return parent(start_1).bind(function (parent) {
|
|
var selection = SimSelection.exact(start_1, range.startOffset, parent, getEnd(parent));
|
|
var optRect = getFirstRect(range.startContainer.ownerDocument.defaultView, selection);
|
|
return optRect.map(collapsedRect).map(pure$2);
|
|
}).getOr([]);
|
|
}
|
|
};
|
|
var getRectangles = function (cWin) {
|
|
var sel = cWin.getSelection();
|
|
return sel !== undefined && sel.rangeCount > 0 ? getRectsFromRange(sel.getRangeAt(0)) : [];
|
|
};
|
|
|
|
var autocompleteHack = function () {
|
|
return function (f) {
|
|
global$2.setTimeout(function () {
|
|
f();
|
|
}, 0);
|
|
};
|
|
};
|
|
var resume$1 = function (cWin) {
|
|
cWin.focus();
|
|
var iBody = SugarElement.fromDom(cWin.document.body);
|
|
var inInput = active().exists(function (elem) {
|
|
return contains$1([
|
|
'input',
|
|
'textarea'
|
|
], name$1(elem));
|
|
});
|
|
var transaction = inInput ? autocompleteHack() : apply$1;
|
|
transaction(function () {
|
|
active().each(blur$1);
|
|
focus$3(iBody);
|
|
});
|
|
};
|
|
|
|
var EXTRA_SPACING = 50;
|
|
var data = 'data-' + resolve('last-outer-height');
|
|
var setLastHeight = function (cBody, value) {
|
|
set$8(cBody, data, value);
|
|
};
|
|
var getLastHeight = function (cBody) {
|
|
return safeParse(cBody, data);
|
|
};
|
|
var getBoundsFrom = function (rect) {
|
|
return {
|
|
top: rect.top,
|
|
bottom: rect.top + rect.height
|
|
};
|
|
};
|
|
var getBounds = function (cWin) {
|
|
var rects = getRectangles(cWin);
|
|
return rects.length > 0 ? Optional.some(rects[0]).map(getBoundsFrom) : Optional.none();
|
|
};
|
|
var findDelta = function (outerWindow, cBody) {
|
|
var last = getLastHeight(cBody);
|
|
var current = outerWindow.innerHeight;
|
|
return last > current ? Optional.some(last - current) : Optional.none();
|
|
};
|
|
var calculate = function (cWin, bounds, delta) {
|
|
var isOutside = bounds.top > cWin.innerHeight || bounds.bottom > cWin.innerHeight;
|
|
return isOutside ? Math.min(delta, bounds.bottom - cWin.innerHeight + EXTRA_SPACING) : 0;
|
|
};
|
|
var setup$2 = function (outerWindow, cWin) {
|
|
var cBody = SugarElement.fromDom(cWin.document.body);
|
|
var toEditing = function () {
|
|
resume$1(cWin);
|
|
};
|
|
var onResize = bind(SugarElement.fromDom(outerWindow), 'resize', function () {
|
|
findDelta(outerWindow, cBody).each(function (delta) {
|
|
getBounds(cWin).each(function (bounds) {
|
|
var cScrollBy = calculate(cWin, bounds, delta);
|
|
if (cScrollBy !== 0) {
|
|
cWin.scrollTo(cWin.pageXOffset, cWin.pageYOffset + cScrollBy);
|
|
}
|
|
});
|
|
});
|
|
setLastHeight(cBody, outerWindow.innerHeight);
|
|
});
|
|
setLastHeight(cBody, outerWindow.innerHeight);
|
|
var destroy = function () {
|
|
onResize.unbind();
|
|
};
|
|
return {
|
|
toEditing: toEditing,
|
|
destroy: destroy
|
|
};
|
|
};
|
|
|
|
var create$2 = function (platform, mask) {
|
|
var meta = tag();
|
|
var androidApi = api$2();
|
|
var androidEvents = api$2();
|
|
var enter = function () {
|
|
mask.hide();
|
|
add$1(platform.container, resolve('fullscreen-maximized'));
|
|
add$1(platform.container, resolve('android-maximized'));
|
|
meta.maximize();
|
|
add$1(platform.body, resolve('android-scroll-reload'));
|
|
androidApi.set(setup$2(platform.win, getWin(platform.editor).getOrDie('no')));
|
|
getActiveApi(platform.editor).each(function (editorApi) {
|
|
clobberStyles(platform.container, editorApi.body);
|
|
androidEvents.set(initEvents$1(editorApi, platform.toolstrip, platform.alloy));
|
|
});
|
|
};
|
|
var exit = function () {
|
|
meta.restore();
|
|
mask.show();
|
|
remove$3(platform.container, resolve('fullscreen-maximized'));
|
|
remove$3(platform.container, resolve('android-maximized'));
|
|
restoreStyles();
|
|
remove$3(platform.body, resolve('android-scroll-reload'));
|
|
androidEvents.clear();
|
|
androidApi.clear();
|
|
};
|
|
return {
|
|
enter: enter,
|
|
exit: exit
|
|
};
|
|
};
|
|
|
|
var first = function (fn, rate) {
|
|
var timer = null;
|
|
var cancel = function () {
|
|
if (!isNull(timer)) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
};
|
|
var throttle = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (isNull(timer)) {
|
|
timer = setTimeout(function () {
|
|
timer = null;
|
|
fn.apply(null, args);
|
|
}, rate);
|
|
}
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
throttle: throttle
|
|
};
|
|
};
|
|
var last = function (fn, rate) {
|
|
var timer = null;
|
|
var cancel = function () {
|
|
if (!isNull(timer)) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
};
|
|
var throttle = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
cancel();
|
|
timer = setTimeout(function () {
|
|
timer = null;
|
|
fn.apply(null, args);
|
|
}, rate);
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
throttle: throttle
|
|
};
|
|
};
|
|
|
|
var sketch = function (onView, _translate) {
|
|
var memIcon = record(Container.sketch({
|
|
dom: dom$1('<div aria-hidden="true" class="${prefix}-mask-tap-icon"></div>'),
|
|
containerBehaviours: derive$2([Toggling.config({
|
|
toggleClass: resolve('mask-tap-icon-selected'),
|
|
toggleOnExecute: false
|
|
})])
|
|
}));
|
|
var onViewThrottle = first(onView, 200);
|
|
return Container.sketch({
|
|
dom: dom$1('<div class="${prefix}-disabled-mask"></div>'),
|
|
components: [Container.sketch({
|
|
dom: dom$1('<div class="${prefix}-content-container"></div>'),
|
|
components: [Button.sketch({
|
|
dom: dom$1('<div class="${prefix}-content-tap-section"></div>'),
|
|
components: [memIcon.asSpec()],
|
|
action: function (_button) {
|
|
onViewThrottle.throttle();
|
|
},
|
|
buttonBehaviours: derive$2([Toggling.config({ toggleClass: resolve('mask-tap-icon-selected') })])
|
|
})]
|
|
})]
|
|
});
|
|
};
|
|
|
|
var unbindNoop = constant$1({ unbind: noop });
|
|
var MobileSchema = objOf([
|
|
requiredObjOf('editor', [
|
|
required$1('getFrame'),
|
|
option('getBody'),
|
|
option('getDoc'),
|
|
option('getWin'),
|
|
option('getSelection'),
|
|
option('setSelection'),
|
|
option('clearSelection'),
|
|
option('cursorSaver'),
|
|
option('onKeyup'),
|
|
option('onNodeChanged'),
|
|
option('getCursorBox'),
|
|
required$1('onDomChanged'),
|
|
defaulted('onTouchContent', noop),
|
|
defaulted('onTapContent', noop),
|
|
defaulted('onTouchToolstrip', noop),
|
|
defaulted('onScrollToCursor', unbindNoop),
|
|
defaulted('onScrollToElement', unbindNoop),
|
|
defaulted('onToEditing', unbindNoop),
|
|
defaulted('onToReading', unbindNoop),
|
|
defaulted('onToolbarScrollStart', identity)
|
|
]),
|
|
required$1('socket'),
|
|
required$1('toolstrip'),
|
|
required$1('dropup'),
|
|
required$1('toolbar'),
|
|
required$1('container'),
|
|
required$1('alloy'),
|
|
customField('win', function (spec) {
|
|
return owner$2(spec.socket).dom.defaultView;
|
|
}),
|
|
customField('body', function (spec) {
|
|
return SugarElement.fromDom(spec.socket.dom.ownerDocument.body);
|
|
}),
|
|
defaulted('translate', identity),
|
|
defaulted('setReadOnly', noop),
|
|
defaulted('readOnlyOnInit', always)
|
|
]);
|
|
|
|
var produce$1 = function (raw) {
|
|
var mobile = asRawOrDie$1('Getting AndroidWebapp schema', MobileSchema, raw);
|
|
set$5(mobile.toolstrip, 'width', '100%');
|
|
var onTap = function () {
|
|
mobile.setReadOnly(mobile.readOnlyOnInit());
|
|
mode.enter();
|
|
};
|
|
var mask = build$1(sketch(onTap, mobile.translate));
|
|
mobile.alloy.add(mask);
|
|
var maskApi = {
|
|
show: function () {
|
|
mobile.alloy.add(mask);
|
|
},
|
|
hide: function () {
|
|
mobile.alloy.remove(mask);
|
|
}
|
|
};
|
|
append$2(mobile.container, mask.element);
|
|
var mode = create$2(mobile, maskApi);
|
|
return {
|
|
setReadOnly: mobile.setReadOnly,
|
|
refreshStructure: noop,
|
|
enter: mode.enter,
|
|
exit: mode.exit,
|
|
destroy: noop
|
|
};
|
|
};
|
|
|
|
var schema$1 = constant$1([
|
|
required$1('dom'),
|
|
defaulted('shell', true),
|
|
field$1('toolbarBehaviours', [Replacing])
|
|
]);
|
|
var enhanceGroups = function () {
|
|
return { behaviours: derive$2([Replacing.config({})]) };
|
|
};
|
|
var parts$1 = constant$1([optional({
|
|
name: 'groups',
|
|
overrides: enhanceGroups
|
|
})]);
|
|
|
|
var factory$1 = function (detail, components, _spec, _externals) {
|
|
var setGroups = function (toolbar, groups) {
|
|
getGroupContainer(toolbar).fold(function () {
|
|
console.error('Toolbar was defined to not be a shell, but no groups container was specified in components');
|
|
throw new Error('Toolbar was defined to not be a shell, but no groups container was specified in components');
|
|
}, function (container) {
|
|
Replacing.set(container, groups);
|
|
});
|
|
};
|
|
var getGroupContainer = function (component) {
|
|
return detail.shell ? Optional.some(component) : getPart(component, detail, 'groups');
|
|
};
|
|
var extra = detail.shell ? {
|
|
behaviours: [Replacing.config({})],
|
|
components: []
|
|
} : {
|
|
behaviours: [],
|
|
components: components
|
|
};
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: extra.components,
|
|
behaviours: augment(detail.toolbarBehaviours, extra.behaviours),
|
|
apis: { setGroups: setGroups },
|
|
domModification: { attributes: { role: 'group' } }
|
|
};
|
|
};
|
|
var Toolbar = composite({
|
|
name: 'Toolbar',
|
|
configFields: schema$1(),
|
|
partFields: parts$1(),
|
|
factory: factory$1,
|
|
apis: {
|
|
setGroups: function (apis, toolbar, groups) {
|
|
apis.setGroups(toolbar, groups);
|
|
}
|
|
}
|
|
});
|
|
|
|
var schema = constant$1([
|
|
required$1('items'),
|
|
markers(['itemSelector']),
|
|
field$1('tgroupBehaviours', [Keying])
|
|
]);
|
|
var parts = constant$1([group({
|
|
name: 'items',
|
|
unit: 'item'
|
|
})]);
|
|
|
|
var factory = function (detail, components, _spec, _externals) {
|
|
return {
|
|
uid: detail.uid,
|
|
dom: detail.dom,
|
|
components: components,
|
|
behaviours: augment(detail.tgroupBehaviours, [Keying.config({
|
|
mode: 'flow',
|
|
selector: detail.markers.itemSelector
|
|
})]),
|
|
domModification: { attributes: { role: 'toolbar' } }
|
|
};
|
|
};
|
|
var ToolbarGroup = composite({
|
|
name: 'ToolbarGroup',
|
|
configFields: schema(),
|
|
partFields: parts(),
|
|
factory: factory
|
|
});
|
|
|
|
var dataHorizontal = 'data-' + resolve('horizontal-scroll');
|
|
var canScrollVertically = function (container) {
|
|
container.dom.scrollTop = 1;
|
|
var result = container.dom.scrollTop !== 0;
|
|
container.dom.scrollTop = 0;
|
|
return result;
|
|
};
|
|
var canScrollHorizontally = function (container) {
|
|
container.dom.scrollLeft = 1;
|
|
var result = container.dom.scrollLeft !== 0;
|
|
container.dom.scrollLeft = 0;
|
|
return result;
|
|
};
|
|
var hasVerticalScroll = function (container) {
|
|
return container.dom.scrollTop > 0 || canScrollVertically(container);
|
|
};
|
|
var hasHorizontalScroll = function (container) {
|
|
return container.dom.scrollLeft > 0 || canScrollHorizontally(container);
|
|
};
|
|
var markAsHorizontal = function (container) {
|
|
set$8(container, dataHorizontal, 'true');
|
|
};
|
|
var hasScroll = function (container) {
|
|
return get$b(container, dataHorizontal) === 'true' ? hasHorizontalScroll(container) : hasVerticalScroll(container);
|
|
};
|
|
var exclusive = function (scope, selector) {
|
|
return bind(scope, 'touchmove', function (event) {
|
|
closest$1(event.target, selector).filter(hasScroll).fold(function () {
|
|
event.prevent();
|
|
}, noop);
|
|
});
|
|
};
|
|
|
|
var ScrollingToolbar = function () {
|
|
var makeGroup = function (gSpec) {
|
|
var scrollClass = gSpec.scrollable === true ? '${prefix}-toolbar-scrollable-group' : '';
|
|
return {
|
|
dom: dom$1('<div aria-label="' + gSpec.label + '" class="${prefix}-toolbar-group ' + scrollClass + '"></div>'),
|
|
tgroupBehaviours: derive$2([config('adhoc-scrollable-toolbar', gSpec.scrollable === true ? [runOnInit(function (component, _simulatedEvent) {
|
|
set$5(component.element, 'overflow-x', 'auto');
|
|
markAsHorizontal(component.element);
|
|
register$2(component.element);
|
|
})] : [])]),
|
|
components: [Container.sketch({ components: [ToolbarGroup.parts.items({})] })],
|
|
markers: { itemSelector: '.' + resolve('toolbar-group-item') },
|
|
items: gSpec.items
|
|
};
|
|
};
|
|
var toolbar = build$1(Toolbar.sketch({
|
|
dom: dom$1('<div class="${prefix}-toolbar"></div>'),
|
|
components: [Toolbar.parts.groups({})],
|
|
toolbarBehaviours: derive$2([
|
|
Toggling.config({
|
|
toggleClass: resolve('context-toolbar'),
|
|
toggleOnExecute: false,
|
|
aria: { mode: 'none' }
|
|
}),
|
|
Keying.config({ mode: 'cyclic' })
|
|
]),
|
|
shell: true
|
|
}));
|
|
var wrapper = build$1(Container.sketch({
|
|
dom: { classes: [resolve('toolstrip')] },
|
|
components: [premade(toolbar)],
|
|
containerBehaviours: derive$2([Toggling.config({
|
|
toggleClass: resolve('android-selection-context-toolbar'),
|
|
toggleOnExecute: false
|
|
})])
|
|
}));
|
|
var resetGroups = function () {
|
|
Toolbar.setGroups(toolbar, initGroups.get());
|
|
Toggling.off(toolbar);
|
|
};
|
|
var initGroups = Cell([]);
|
|
var setGroups = function (gs) {
|
|
initGroups.set(gs);
|
|
resetGroups();
|
|
};
|
|
var createGroups = function (gs) {
|
|
return map$2(gs, compose(ToolbarGroup.sketch, makeGroup));
|
|
};
|
|
var refresh = function () {
|
|
};
|
|
var setContextToolbar = function (gs) {
|
|
Toggling.on(toolbar);
|
|
Toolbar.setGroups(toolbar, gs);
|
|
};
|
|
var restoreToolbar = function () {
|
|
if (Toggling.isOn(toolbar)) {
|
|
resetGroups();
|
|
}
|
|
};
|
|
var focus = function () {
|
|
Keying.focusIn(toolbar);
|
|
};
|
|
return {
|
|
wrapper: wrapper,
|
|
toolbar: toolbar,
|
|
createGroups: createGroups,
|
|
setGroups: setGroups,
|
|
setContextToolbar: setContextToolbar,
|
|
restoreToolbar: restoreToolbar,
|
|
refresh: refresh,
|
|
focus: focus
|
|
};
|
|
};
|
|
|
|
var makeEditSwitch = function (webapp) {
|
|
return build$1(Button.sketch({
|
|
dom: dom$1('<div class="${prefix}-mask-edit-icon ${prefix}-icon"></div>'),
|
|
action: function () {
|
|
webapp.run(function (w) {
|
|
w.setReadOnly(false);
|
|
});
|
|
}
|
|
}));
|
|
};
|
|
var makeSocket = function () {
|
|
return build$1(Container.sketch({
|
|
dom: dom$1('<div class="${prefix}-editor-socket"></div>'),
|
|
components: [],
|
|
containerBehaviours: derive$2([Replacing.config({})])
|
|
}));
|
|
};
|
|
var showEdit = function (socket, switchToEdit) {
|
|
Replacing.append(socket, premade(switchToEdit));
|
|
};
|
|
var hideEdit = function (socket, switchToEdit) {
|
|
Replacing.remove(socket, switchToEdit);
|
|
};
|
|
var updateMode = function (socket, switchToEdit, readOnly, root) {
|
|
var swap = readOnly === true ? Swapping.toAlpha : Swapping.toOmega;
|
|
swap(root);
|
|
var f = readOnly ? showEdit : hideEdit;
|
|
f(socket, switchToEdit);
|
|
};
|
|
|
|
var getAnimationRoot = function (component, slideConfig) {
|
|
return slideConfig.getAnimationRoot.fold(function () {
|
|
return component.element;
|
|
}, function (get) {
|
|
return get(component);
|
|
});
|
|
};
|
|
|
|
var getDimensionProperty = function (slideConfig) {
|
|
return slideConfig.dimension.property;
|
|
};
|
|
var getDimension = function (slideConfig, elem) {
|
|
return slideConfig.dimension.getDimension(elem);
|
|
};
|
|
var disableTransitions = function (component, slideConfig) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
remove$1(root, [
|
|
slideConfig.shrinkingClass,
|
|
slideConfig.growingClass
|
|
]);
|
|
};
|
|
var setShrunk = function (component, slideConfig) {
|
|
remove$3(component.element, slideConfig.openClass);
|
|
add$1(component.element, slideConfig.closedClass);
|
|
set$5(component.element, getDimensionProperty(slideConfig), '0px');
|
|
reflow(component.element);
|
|
};
|
|
var setGrown = function (component, slideConfig) {
|
|
remove$3(component.element, slideConfig.closedClass);
|
|
add$1(component.element, slideConfig.openClass);
|
|
remove$2(component.element, getDimensionProperty(slideConfig));
|
|
};
|
|
var doImmediateShrink = function (component, slideConfig, slideState, _calculatedSize) {
|
|
slideState.setCollapsed();
|
|
set$5(component.element, getDimensionProperty(slideConfig), getDimension(slideConfig, component.element));
|
|
reflow(component.element);
|
|
disableTransitions(component, slideConfig);
|
|
setShrunk(component, slideConfig);
|
|
slideConfig.onStartShrink(component);
|
|
slideConfig.onShrunk(component);
|
|
};
|
|
var doStartShrink = function (component, slideConfig, slideState, calculatedSize) {
|
|
var size = calculatedSize.getOrThunk(function () {
|
|
return getDimension(slideConfig, component.element);
|
|
});
|
|
slideState.setCollapsed();
|
|
set$5(component.element, getDimensionProperty(slideConfig), size);
|
|
reflow(component.element);
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
remove$3(root, slideConfig.growingClass);
|
|
add$1(root, slideConfig.shrinkingClass);
|
|
setShrunk(component, slideConfig);
|
|
slideConfig.onStartShrink(component);
|
|
};
|
|
var doStartSmartShrink = function (component, slideConfig, slideState) {
|
|
var size = getDimension(slideConfig, component.element);
|
|
var shrinker = size === '0px' ? doImmediateShrink : doStartShrink;
|
|
shrinker(component, slideConfig, slideState, Optional.some(size));
|
|
};
|
|
var doStartGrow = function (component, slideConfig, slideState) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
var wasShrinking = has(root, slideConfig.shrinkingClass);
|
|
var beforeSize = getDimension(slideConfig, component.element);
|
|
setGrown(component, slideConfig);
|
|
var fullSize = getDimension(slideConfig, component.element);
|
|
var startPartialGrow = function () {
|
|
set$5(component.element, getDimensionProperty(slideConfig), beforeSize);
|
|
reflow(component.element);
|
|
};
|
|
var startCompleteGrow = function () {
|
|
setShrunk(component, slideConfig);
|
|
};
|
|
var setStartSize = wasShrinking ? startPartialGrow : startCompleteGrow;
|
|
setStartSize();
|
|
remove$3(root, slideConfig.shrinkingClass);
|
|
add$1(root, slideConfig.growingClass);
|
|
setGrown(component, slideConfig);
|
|
set$5(component.element, getDimensionProperty(slideConfig), fullSize);
|
|
slideState.setExpanded();
|
|
slideConfig.onStartGrow(component);
|
|
};
|
|
var refresh$1 = function (component, slideConfig, slideState) {
|
|
if (slideState.isExpanded()) {
|
|
remove$2(component.element, getDimensionProperty(slideConfig));
|
|
var fullSize = getDimension(slideConfig, component.element);
|
|
set$5(component.element, getDimensionProperty(slideConfig), fullSize);
|
|
}
|
|
};
|
|
var grow = function (component, slideConfig, slideState) {
|
|
if (!slideState.isExpanded()) {
|
|
doStartGrow(component, slideConfig, slideState);
|
|
}
|
|
};
|
|
var shrink = function (component, slideConfig, slideState) {
|
|
if (slideState.isExpanded()) {
|
|
doStartSmartShrink(component, slideConfig, slideState);
|
|
}
|
|
};
|
|
var immediateShrink = function (component, slideConfig, slideState) {
|
|
if (slideState.isExpanded()) {
|
|
doImmediateShrink(component, slideConfig, slideState);
|
|
}
|
|
};
|
|
var hasGrown = function (component, slideConfig, slideState) {
|
|
return slideState.isExpanded();
|
|
};
|
|
var hasShrunk = function (component, slideConfig, slideState) {
|
|
return slideState.isCollapsed();
|
|
};
|
|
var isGrowing = function (component, slideConfig, _slideState) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
return has(root, slideConfig.growingClass) === true;
|
|
};
|
|
var isShrinking = function (component, slideConfig, _slideState) {
|
|
var root = getAnimationRoot(component, slideConfig);
|
|
return has(root, slideConfig.shrinkingClass) === true;
|
|
};
|
|
var isTransitioning = function (component, slideConfig, slideState) {
|
|
return isGrowing(component, slideConfig) || isShrinking(component, slideConfig);
|
|
};
|
|
var toggleGrow = function (component, slideConfig, slideState) {
|
|
var f = slideState.isExpanded() ? doStartSmartShrink : doStartGrow;
|
|
f(component, slideConfig, slideState);
|
|
};
|
|
|
|
var SlidingApis = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
refresh: refresh$1,
|
|
grow: grow,
|
|
shrink: shrink,
|
|
immediateShrink: immediateShrink,
|
|
hasGrown: hasGrown,
|
|
hasShrunk: hasShrunk,
|
|
isGrowing: isGrowing,
|
|
isShrinking: isShrinking,
|
|
isTransitioning: isTransitioning,
|
|
toggleGrow: toggleGrow,
|
|
disableTransitions: disableTransitions
|
|
});
|
|
|
|
var exhibit = function (base, slideConfig, _slideState) {
|
|
var expanded = slideConfig.expanded;
|
|
return expanded ? nu$3({
|
|
classes: [slideConfig.openClass],
|
|
styles: {}
|
|
}) : nu$3({
|
|
classes: [slideConfig.closedClass],
|
|
styles: wrap(slideConfig.dimension.property, '0px')
|
|
});
|
|
};
|
|
var events = function (slideConfig, slideState) {
|
|
return derive$3([runOnSource(transitionend(), function (component, simulatedEvent) {
|
|
var raw = simulatedEvent.event.raw;
|
|
if (raw.propertyName === slideConfig.dimension.property) {
|
|
disableTransitions(component, slideConfig);
|
|
if (slideState.isExpanded()) {
|
|
remove$2(component.element, slideConfig.dimension.property);
|
|
}
|
|
var notify = slideState.isExpanded() ? slideConfig.onGrown : slideConfig.onShrunk;
|
|
notify(component);
|
|
}
|
|
})]);
|
|
};
|
|
|
|
var ActiveSliding = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
exhibit: exhibit,
|
|
events: events
|
|
});
|
|
|
|
var SlidingSchema = [
|
|
required$1('closedClass'),
|
|
required$1('openClass'),
|
|
required$1('shrinkingClass'),
|
|
required$1('growingClass'),
|
|
option('getAnimationRoot'),
|
|
onHandler('onShrunk'),
|
|
onHandler('onStartShrink'),
|
|
onHandler('onGrown'),
|
|
onHandler('onStartGrow'),
|
|
defaulted('expanded', false),
|
|
requiredOf('dimension', choose$1('property', {
|
|
width: [
|
|
output('property', 'width'),
|
|
output('getDimension', function (elem) {
|
|
return get$5(elem) + 'px';
|
|
})
|
|
],
|
|
height: [
|
|
output('property', 'height'),
|
|
output('getDimension', function (elem) {
|
|
return get$7(elem) + 'px';
|
|
})
|
|
]
|
|
}))
|
|
];
|
|
|
|
var init$1 = function (spec) {
|
|
var state = Cell(spec.expanded);
|
|
var readState = function () {
|
|
return 'expanded: ' + state.get();
|
|
};
|
|
return nu$2({
|
|
isExpanded: function () {
|
|
return state.get() === true;
|
|
},
|
|
isCollapsed: function () {
|
|
return state.get() === false;
|
|
},
|
|
setCollapsed: curry(state.set, false),
|
|
setExpanded: curry(state.set, true),
|
|
readState: readState
|
|
});
|
|
};
|
|
|
|
var SlidingState = /*#__PURE__*/Object.freeze({
|
|
__proto__: null,
|
|
init: init$1
|
|
});
|
|
|
|
var Sliding = create$5({
|
|
fields: SlidingSchema,
|
|
name: 'sliding',
|
|
active: ActiveSliding,
|
|
apis: SlidingApis,
|
|
state: SlidingState
|
|
});
|
|
|
|
var build = function (refresh, scrollIntoView) {
|
|
var dropup = build$1(Container.sketch({
|
|
dom: {
|
|
tag: 'div',
|
|
classes: [resolve('dropup')]
|
|
},
|
|
components: [],
|
|
containerBehaviours: derive$2([
|
|
Replacing.config({}),
|
|
Sliding.config({
|
|
closedClass: resolve('dropup-closed'),
|
|
openClass: resolve('dropup-open'),
|
|
shrinkingClass: resolve('dropup-shrinking'),
|
|
growingClass: resolve('dropup-growing'),
|
|
dimension: { property: 'height' },
|
|
onShrunk: function (component) {
|
|
refresh();
|
|
scrollIntoView();
|
|
Replacing.set(component, []);
|
|
},
|
|
onGrown: function (_component) {
|
|
refresh();
|
|
scrollIntoView();
|
|
}
|
|
}),
|
|
orientation(function (_component, _data) {
|
|
disappear(noop);
|
|
})
|
|
])
|
|
}));
|
|
var appear = function (menu, update, component) {
|
|
if (Sliding.hasShrunk(dropup) === true && Sliding.isTransitioning(dropup) === false) {
|
|
window.requestAnimationFrame(function () {
|
|
update(component);
|
|
Replacing.set(dropup, [menu()]);
|
|
Sliding.grow(dropup);
|
|
});
|
|
}
|
|
};
|
|
var disappear = function (onReadyToShrink) {
|
|
window.requestAnimationFrame(function () {
|
|
onReadyToShrink();
|
|
Sliding.shrink(dropup);
|
|
});
|
|
};
|
|
return {
|
|
appear: appear,
|
|
disappear: disappear,
|
|
component: dropup,
|
|
element: dropup.element
|
|
};
|
|
};
|
|
|
|
var closest = function (scope, selector, isRoot) {
|
|
return closest$1(scope, selector, isRoot).isSome();
|
|
};
|
|
|
|
var isDangerous = function (event) {
|
|
var keyEv = event.raw;
|
|
return keyEv.which === BACKSPACE[0] && !contains$1([
|
|
'input',
|
|
'textarea'
|
|
], name$1(event.target)) && !closest(event.target, '[contenteditable="true"]');
|
|
};
|
|
var isFirefox = function () {
|
|
return detect$1().browser.isFirefox();
|
|
};
|
|
var bindFocus = function (container, handler) {
|
|
if (isFirefox()) {
|
|
return capture(container, 'focus', handler);
|
|
} else {
|
|
return bind(container, 'focusin', handler);
|
|
}
|
|
};
|
|
var bindBlur = function (container, handler) {
|
|
if (isFirefox()) {
|
|
return capture(container, 'blur', handler);
|
|
} else {
|
|
return bind(container, 'focusout', handler);
|
|
}
|
|
};
|
|
var setup$1 = function (container, rawSettings) {
|
|
var settings = __assign({ stopBackspace: true }, rawSettings);
|
|
var pointerEvents = [
|
|
'touchstart',
|
|
'touchmove',
|
|
'touchend',
|
|
'touchcancel',
|
|
'gesturestart',
|
|
'mousedown',
|
|
'mouseup',
|
|
'mouseover',
|
|
'mousemove',
|
|
'mouseout',
|
|
'click'
|
|
];
|
|
var tapEvent = monitor$1(settings);
|
|
var simpleEvents = map$2(pointerEvents.concat([
|
|
'selectstart',
|
|
'input',
|
|
'contextmenu',
|
|
'change',
|
|
'transitionend',
|
|
'transitioncancel',
|
|
'drag',
|
|
'dragstart',
|
|
'dragend',
|
|
'dragenter',
|
|
'dragleave',
|
|
'dragover',
|
|
'drop',
|
|
'keyup'
|
|
]), function (type) {
|
|
return bind(container, type, function (event) {
|
|
tapEvent.fireIfReady(event, type).each(function (tapStopped) {
|
|
if (tapStopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
var stopped = settings.triggerEvent(type, event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
});
|
|
var pasteTimeout = value();
|
|
var onPaste = bind(container, 'paste', function (event) {
|
|
tapEvent.fireIfReady(event, 'paste').each(function (tapStopped) {
|
|
if (tapStopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
var stopped = settings.triggerEvent('paste', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
pasteTimeout.set(setTimeout(function () {
|
|
settings.triggerEvent(postPaste(), event);
|
|
}, 0));
|
|
});
|
|
var onKeydown = bind(container, 'keydown', function (event) {
|
|
var stopped = settings.triggerEvent('keydown', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
} else if (settings.stopBackspace && isDangerous(event)) {
|
|
event.prevent();
|
|
}
|
|
});
|
|
var onFocusIn = bindFocus(container, function (event) {
|
|
var stopped = settings.triggerEvent('focusin', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
});
|
|
var focusoutTimeout = value();
|
|
var onFocusOut = bindBlur(container, function (event) {
|
|
var stopped = settings.triggerEvent('focusout', event);
|
|
if (stopped) {
|
|
event.kill();
|
|
}
|
|
focusoutTimeout.set(setTimeout(function () {
|
|
settings.triggerEvent(postBlur(), event);
|
|
}, 0));
|
|
});
|
|
var unbind = function () {
|
|
each$1(simpleEvents, function (e) {
|
|
e.unbind();
|
|
});
|
|
onKeydown.unbind();
|
|
onFocusIn.unbind();
|
|
onFocusOut.unbind();
|
|
onPaste.unbind();
|
|
pasteTimeout.on(clearTimeout);
|
|
focusoutTimeout.on(clearTimeout);
|
|
};
|
|
return { unbind: unbind };
|
|
};
|
|
|
|
var derive$1 = function (rawEvent, rawTarget) {
|
|
var source = get$c(rawEvent, 'target').getOr(rawTarget);
|
|
return Cell(source);
|
|
};
|
|
|
|
var fromSource = function (event, source) {
|
|
var stopper = Cell(false);
|
|
var cutter = Cell(false);
|
|
var stop = function () {
|
|
stopper.set(true);
|
|
};
|
|
var cut = function () {
|
|
cutter.set(true);
|
|
};
|
|
return {
|
|
stop: stop,
|
|
cut: cut,
|
|
isStopped: stopper.get,
|
|
isCut: cutter.get,
|
|
event: event,
|
|
setSource: source.set,
|
|
getSource: source.get
|
|
};
|
|
};
|
|
var fromExternal = function (event) {
|
|
var stopper = Cell(false);
|
|
var stop = function () {
|
|
stopper.set(true);
|
|
};
|
|
return {
|
|
stop: stop,
|
|
cut: noop,
|
|
isStopped: stopper.get,
|
|
isCut: never,
|
|
event: event,
|
|
setSource: die('Cannot set source of a broadcasted event'),
|
|
getSource: die('Cannot get source of a broadcasted event')
|
|
};
|
|
};
|
|
|
|
var adt = Adt.generate([
|
|
{ stopped: [] },
|
|
{ resume: ['element'] },
|
|
{ complete: [] }
|
|
]);
|
|
var doTriggerHandler = function (lookup, eventType, rawEvent, target, source, logger) {
|
|
var handler = lookup(eventType, target);
|
|
var simulatedEvent = fromSource(rawEvent, source);
|
|
return handler.fold(function () {
|
|
logger.logEventNoHandlers(eventType, target);
|
|
return adt.complete();
|
|
}, function (handlerInfo) {
|
|
var descHandler = handlerInfo.descHandler;
|
|
var eventHandler = getCurried(descHandler);
|
|
eventHandler(simulatedEvent);
|
|
if (simulatedEvent.isStopped()) {
|
|
logger.logEventStopped(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt.stopped();
|
|
} else if (simulatedEvent.isCut()) {
|
|
logger.logEventCut(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt.complete();
|
|
} else {
|
|
return parent(handlerInfo.element).fold(function () {
|
|
logger.logNoParent(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt.complete();
|
|
}, function (parent) {
|
|
logger.logEventResponse(eventType, handlerInfo.element, descHandler.purpose);
|
|
return adt.resume(parent);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var doTriggerOnUntilStopped = function (lookup, eventType, rawEvent, rawTarget, source, logger) {
|
|
return doTriggerHandler(lookup, eventType, rawEvent, rawTarget, source, logger).fold(always, function (parent) {
|
|
return doTriggerOnUntilStopped(lookup, eventType, rawEvent, parent, source, logger);
|
|
}, never);
|
|
};
|
|
var triggerHandler = function (lookup, eventType, rawEvent, target, logger) {
|
|
var source = derive$1(rawEvent, target);
|
|
return doTriggerHandler(lookup, eventType, rawEvent, target, source, logger);
|
|
};
|
|
var broadcast = function (listeners, rawEvent, _logger) {
|
|
var simulatedEvent = fromExternal(rawEvent);
|
|
each$1(listeners, function (listener) {
|
|
var descHandler = listener.descHandler;
|
|
var handler = getCurried(descHandler);
|
|
handler(simulatedEvent);
|
|
});
|
|
return simulatedEvent.isStopped();
|
|
};
|
|
var triggerUntilStopped = function (lookup, eventType, rawEvent, logger) {
|
|
return triggerOnUntilStopped(lookup, eventType, rawEvent, rawEvent.target, logger);
|
|
};
|
|
var triggerOnUntilStopped = function (lookup, eventType, rawEvent, rawTarget, logger) {
|
|
var source = derive$1(rawEvent, rawTarget);
|
|
return doTriggerOnUntilStopped(lookup, eventType, rawEvent, rawTarget, source, logger);
|
|
};
|
|
|
|
var eventHandler = function (element, descHandler) {
|
|
return {
|
|
element: element,
|
|
descHandler: descHandler
|
|
};
|
|
};
|
|
var broadcastHandler = function (id, handler) {
|
|
return {
|
|
id: id,
|
|
descHandler: handler
|
|
};
|
|
};
|
|
var EventRegistry = function () {
|
|
var registry = {};
|
|
var registerId = function (extraArgs, id, events) {
|
|
each(events, function (v, k) {
|
|
var handlers = registry[k] !== undefined ? registry[k] : {};
|
|
handlers[id] = curryArgs(v, extraArgs);
|
|
registry[k] = handlers;
|
|
});
|
|
};
|
|
var findHandler = function (handlers, elem) {
|
|
return read(elem).bind(function (id) {
|
|
return get$c(handlers, id);
|
|
}).map(function (descHandler) {
|
|
return eventHandler(elem, descHandler);
|
|
});
|
|
};
|
|
var filterByType = function (type) {
|
|
return get$c(registry, type).map(function (handlers) {
|
|
return mapToArray(handlers, function (f, id) {
|
|
return broadcastHandler(id, f);
|
|
});
|
|
}).getOr([]);
|
|
};
|
|
var find = function (isAboveRoot, type, target) {
|
|
return get$c(registry, type).bind(function (handlers) {
|
|
return closest$3(target, function (elem) {
|
|
return findHandler(handlers, elem);
|
|
}, isAboveRoot);
|
|
});
|
|
};
|
|
var unregisterId = function (id) {
|
|
each(registry, function (handlersById, _eventName) {
|
|
if (has$2(handlersById, id)) {
|
|
delete handlersById[id];
|
|
}
|
|
});
|
|
};
|
|
return {
|
|
registerId: registerId,
|
|
unregisterId: unregisterId,
|
|
filterByType: filterByType,
|
|
find: find
|
|
};
|
|
};
|
|
|
|
var Registry = function () {
|
|
var events = EventRegistry();
|
|
var components = {};
|
|
var readOrTag = function (component) {
|
|
var elem = component.element;
|
|
return read(elem).getOrThunk(function () {
|
|
return write('uid-', component.element);
|
|
});
|
|
};
|
|
var failOnDuplicate = function (component, tagId) {
|
|
var conflict = components[tagId];
|
|
if (conflict === component) {
|
|
unregister(component);
|
|
} else {
|
|
throw new Error('The tagId "' + tagId + '" is already used by: ' + element(conflict.element) + '\nCannot use it for: ' + element(component.element) + '\n' + 'The conflicting element is' + (inBody(conflict.element) ? ' ' : ' not ') + 'already in the DOM');
|
|
}
|
|
};
|
|
var register = function (component) {
|
|
var tagId = readOrTag(component);
|
|
if (hasNonNullableKey(components, tagId)) {
|
|
failOnDuplicate(component, tagId);
|
|
}
|
|
var extraArgs = [component];
|
|
events.registerId(extraArgs, tagId, component.events);
|
|
components[tagId] = component;
|
|
};
|
|
var unregister = function (component) {
|
|
read(component.element).each(function (tagId) {
|
|
delete components[tagId];
|
|
events.unregisterId(tagId);
|
|
});
|
|
};
|
|
var filter = function (type) {
|
|
return events.filterByType(type);
|
|
};
|
|
var find = function (isAboveRoot, type, target) {
|
|
return events.find(isAboveRoot, type, target);
|
|
};
|
|
var getById = function (id) {
|
|
return get$c(components, id);
|
|
};
|
|
return {
|
|
find: find,
|
|
filter: filter,
|
|
register: register,
|
|
unregister: unregister,
|
|
getById: getById
|
|
};
|
|
};
|
|
|
|
var takeover$1 = function (root) {
|
|
var isAboveRoot = function (el) {
|
|
return parent(root.element).fold(always, function (parent) {
|
|
return eq(el, parent);
|
|
});
|
|
};
|
|
var registry = Registry();
|
|
var lookup = function (eventName, target) {
|
|
return registry.find(isAboveRoot, eventName, target);
|
|
};
|
|
var domEvents = setup$1(root.element, {
|
|
triggerEvent: function (eventName, event) {
|
|
return monitorEvent(eventName, event.target, function (logger) {
|
|
return triggerUntilStopped(lookup, eventName, event, logger);
|
|
});
|
|
}
|
|
});
|
|
var systemApi = {
|
|
debugInfo: constant$1('real'),
|
|
triggerEvent: function (eventName, target, data) {
|
|
monitorEvent(eventName, target, function (logger) {
|
|
return triggerOnUntilStopped(lookup, eventName, data, target, logger);
|
|
});
|
|
},
|
|
triggerFocus: function (target, originator) {
|
|
read(target).fold(function () {
|
|
focus$3(target);
|
|
}, function (_alloyId) {
|
|
monitorEvent(focus$4(), target, function (logger) {
|
|
triggerHandler(lookup, focus$4(), {
|
|
originator: originator,
|
|
kill: noop,
|
|
prevent: noop,
|
|
target: target
|
|
}, target, logger);
|
|
return false;
|
|
});
|
|
});
|
|
},
|
|
triggerEscape: function (comp, simulatedEvent) {
|
|
systemApi.triggerEvent('keydown', comp.element, simulatedEvent.event);
|
|
},
|
|
getByUid: function (uid) {
|
|
return getByUid(uid);
|
|
},
|
|
getByDom: function (elem) {
|
|
return getByDom(elem);
|
|
},
|
|
build: build$1,
|
|
addToGui: function (c) {
|
|
add(c);
|
|
},
|
|
removeFromGui: function (c) {
|
|
remove(c);
|
|
},
|
|
addToWorld: function (c) {
|
|
addToWorld(c);
|
|
},
|
|
removeFromWorld: function (c) {
|
|
removeFromWorld(c);
|
|
},
|
|
broadcast: function (message) {
|
|
broadcast$1(message);
|
|
},
|
|
broadcastOn: function (channels, message) {
|
|
broadcastOn(channels, message);
|
|
},
|
|
broadcastEvent: function (eventName, event) {
|
|
broadcastEvent(eventName, event);
|
|
},
|
|
isConnected: always
|
|
};
|
|
var addToWorld = function (component) {
|
|
component.connect(systemApi);
|
|
if (!isText(component.element)) {
|
|
registry.register(component);
|
|
each$1(component.components(), addToWorld);
|
|
systemApi.triggerEvent(systemInit(), component.element, { target: component.element });
|
|
}
|
|
};
|
|
var removeFromWorld = function (component) {
|
|
if (!isText(component.element)) {
|
|
each$1(component.components(), removeFromWorld);
|
|
registry.unregister(component);
|
|
}
|
|
component.disconnect();
|
|
};
|
|
var add = function (component) {
|
|
attach(root, component);
|
|
};
|
|
var remove = function (component) {
|
|
detach(component);
|
|
};
|
|
var destroy = function () {
|
|
domEvents.unbind();
|
|
remove$7(root.element);
|
|
};
|
|
var broadcastData = function (data) {
|
|
var receivers = registry.filter(receive$1());
|
|
each$1(receivers, function (receiver) {
|
|
var descHandler = receiver.descHandler;
|
|
var handler = getCurried(descHandler);
|
|
handler(data);
|
|
});
|
|
};
|
|
var broadcast$1 = function (message) {
|
|
broadcastData({
|
|
universal: true,
|
|
data: message
|
|
});
|
|
};
|
|
var broadcastOn = function (channels, message) {
|
|
broadcastData({
|
|
universal: false,
|
|
channels: channels,
|
|
data: message
|
|
});
|
|
};
|
|
var broadcastEvent = function (eventName, event) {
|
|
var listeners = registry.filter(eventName);
|
|
return broadcast(listeners, event);
|
|
};
|
|
var getByUid = function (uid) {
|
|
return registry.getById(uid).fold(function () {
|
|
return Result.error(new Error('Could not find component with uid: "' + uid + '" in system.'));
|
|
}, Result.value);
|
|
};
|
|
var getByDom = function (elem) {
|
|
var uid = read(elem).getOr('not found');
|
|
return getByUid(uid);
|
|
};
|
|
addToWorld(root);
|
|
return {
|
|
root: root,
|
|
element: root.element,
|
|
destroy: destroy,
|
|
add: add,
|
|
remove: remove,
|
|
getByUid: getByUid,
|
|
getByDom: getByDom,
|
|
addToWorld: addToWorld,
|
|
removeFromWorld: removeFromWorld,
|
|
broadcast: broadcast$1,
|
|
broadcastOn: broadcastOn,
|
|
broadcastEvent: broadcastEvent
|
|
};
|
|
};
|
|
|
|
var READ_ONLY_MODE_CLASS = resolve('readonly-mode');
|
|
var EDIT_MODE_CLASS = resolve('edit-mode');
|
|
function OuterContainer (spec) {
|
|
var root = build$1(Container.sketch({
|
|
dom: { classes: [resolve('outer-container')].concat(spec.classes) },
|
|
containerBehaviours: derive$2([Swapping.config({
|
|
alpha: READ_ONLY_MODE_CLASS,
|
|
omega: EDIT_MODE_CLASS
|
|
})])
|
|
}));
|
|
return takeover$1(root);
|
|
}
|
|
|
|
function AndroidRealm (scrollIntoView) {
|
|
var alloy = OuterContainer({ classes: [resolve('android-container')] });
|
|
var toolbar = ScrollingToolbar();
|
|
var webapp = api$2();
|
|
var switchToEdit = makeEditSwitch(webapp);
|
|
var socket = makeSocket();
|
|
var dropup = build(noop, scrollIntoView);
|
|
alloy.add(toolbar.wrapper);
|
|
alloy.add(socket);
|
|
alloy.add(dropup.component);
|
|
var setToolbarGroups = function (rawGroups) {
|
|
var groups = toolbar.createGroups(rawGroups);
|
|
toolbar.setGroups(groups);
|
|
};
|
|
var setContextToolbar = function (rawGroups) {
|
|
var groups = toolbar.createGroups(rawGroups);
|
|
toolbar.setContextToolbar(groups);
|
|
};
|
|
var focusToolbar = function () {
|
|
toolbar.focus();
|
|
};
|
|
var restoreToolbar = function () {
|
|
toolbar.restoreToolbar();
|
|
};
|
|
var init = function (spec) {
|
|
webapp.set(produce$1(spec));
|
|
};
|
|
var exit = function () {
|
|
webapp.run(function (w) {
|
|
w.exit();
|
|
Replacing.remove(socket, switchToEdit);
|
|
});
|
|
};
|
|
var updateMode$1 = function (readOnly) {
|
|
updateMode(socket, switchToEdit, readOnly, alloy.root);
|
|
};
|
|
return {
|
|
system: alloy,
|
|
element: alloy.element,
|
|
init: init,
|
|
exit: exit,
|
|
setToolbarGroups: setToolbarGroups,
|
|
setContextToolbar: setContextToolbar,
|
|
focusToolbar: focusToolbar,
|
|
restoreToolbar: restoreToolbar,
|
|
updateMode: updateMode$1,
|
|
socket: socket,
|
|
dropup: dropup
|
|
};
|
|
}
|
|
|
|
var input = function (parent, operation) {
|
|
var input = SugarElement.fromTag('input');
|
|
setAll(input, {
|
|
opacity: '0',
|
|
position: 'absolute',
|
|
top: '-1000px',
|
|
left: '-1000px'
|
|
});
|
|
append$2(parent, input);
|
|
focus$3(input);
|
|
operation(input);
|
|
remove$7(input);
|
|
};
|
|
|
|
var refresh = function (winScope) {
|
|
var sel = winScope.getSelection();
|
|
if (sel.rangeCount > 0) {
|
|
var br = sel.getRangeAt(0);
|
|
var r = winScope.document.createRange();
|
|
r.setStart(br.startContainer, br.startOffset);
|
|
r.setEnd(br.endContainer, br.endOffset);
|
|
sel.removeAllRanges();
|
|
sel.addRange(r);
|
|
}
|
|
};
|
|
|
|
var resume = function (cWin, frame) {
|
|
active().each(function (active) {
|
|
if (!eq(active, frame)) {
|
|
blur$1(active);
|
|
}
|
|
});
|
|
cWin.focus();
|
|
focus$3(SugarElement.fromDom(cWin.document.body));
|
|
refresh(cWin);
|
|
};
|
|
|
|
var stubborn = function (outerBody, cWin, page, frame) {
|
|
var toEditing = function () {
|
|
resume(cWin, frame);
|
|
};
|
|
var toReading = function () {
|
|
input(outerBody, blur$1);
|
|
};
|
|
var captureInput = bind(page, 'keydown', function (evt) {
|
|
if (!contains$1([
|
|
'input',
|
|
'textarea'
|
|
], name$1(evt.target))) {
|
|
toEditing();
|
|
}
|
|
});
|
|
var onToolbarTouch = noop;
|
|
var destroy = function () {
|
|
captureInput.unbind();
|
|
};
|
|
return {
|
|
toReading: toReading,
|
|
toEditing: toEditing,
|
|
onToolbarTouch: onToolbarTouch,
|
|
destroy: destroy
|
|
};
|
|
};
|
|
|
|
var initEvents = function (editorApi, iosApi, toolstrip, socket, _dropup) {
|
|
var saveSelectionFirst = function () {
|
|
iosApi.run(function (api) {
|
|
api.highlightSelection();
|
|
});
|
|
};
|
|
var refreshIosSelection = function () {
|
|
iosApi.run(function (api) {
|
|
api.refreshSelection();
|
|
});
|
|
};
|
|
var scrollToY = function (yTop, height) {
|
|
var y = yTop - socket.dom.scrollTop;
|
|
iosApi.run(function (api) {
|
|
api.scrollIntoView(y, y + height);
|
|
});
|
|
};
|
|
var scrollToElement = function (_target) {
|
|
scrollToY(iosApi, socket);
|
|
};
|
|
var scrollToCursor = function () {
|
|
editorApi.getCursorBox().each(function (box) {
|
|
scrollToY(box.top, box.height);
|
|
});
|
|
};
|
|
var clearSelection = function () {
|
|
iosApi.run(function (api) {
|
|
api.clearSelection();
|
|
});
|
|
};
|
|
var clearAndRefresh = function () {
|
|
clearSelection();
|
|
refreshThrottle.throttle();
|
|
};
|
|
var refreshView = function () {
|
|
scrollToCursor();
|
|
iosApi.run(function (api) {
|
|
api.syncHeight();
|
|
});
|
|
};
|
|
var reposition = function () {
|
|
var toolbarHeight = get$7(toolstrip);
|
|
iosApi.run(function (api) {
|
|
api.setViewportOffset(toolbarHeight);
|
|
});
|
|
refreshIosSelection();
|
|
refreshView();
|
|
};
|
|
var toEditing = function () {
|
|
iosApi.run(function (api) {
|
|
api.toEditing();
|
|
});
|
|
};
|
|
var toReading = function () {
|
|
iosApi.run(function (api) {
|
|
api.toReading();
|
|
});
|
|
};
|
|
var onToolbarTouch = function (event) {
|
|
iosApi.run(function (api) {
|
|
api.onToolbarTouch(event);
|
|
});
|
|
};
|
|
var tapping = monitor(editorApi);
|
|
var refreshThrottle = last(refreshView, 300);
|
|
var listeners = [
|
|
editorApi.onKeyup(clearAndRefresh),
|
|
editorApi.onNodeChanged(refreshIosSelection),
|
|
editorApi.onDomChanged(refreshThrottle.throttle),
|
|
editorApi.onDomChanged(refreshIosSelection),
|
|
editorApi.onScrollToCursor(function (tinyEvent) {
|
|
tinyEvent.preventDefault();
|
|
refreshThrottle.throttle();
|
|
}),
|
|
editorApi.onScrollToElement(function (event) {
|
|
scrollToElement(event.element);
|
|
}),
|
|
editorApi.onToEditing(toEditing),
|
|
editorApi.onToReading(toReading),
|
|
bind(editorApi.doc, 'touchend', function (touchEvent) {
|
|
if (eq(editorApi.html, touchEvent.target) || eq(editorApi.body, touchEvent.target)) ;
|
|
}),
|
|
bind(toolstrip, 'transitionend', function (transitionEvent) {
|
|
if (transitionEvent.raw.propertyName === 'height') {
|
|
reposition();
|
|
}
|
|
}),
|
|
capture(toolstrip, 'touchstart', function (touchEvent) {
|
|
saveSelectionFirst();
|
|
onToolbarTouch(touchEvent);
|
|
editorApi.onTouchToolstrip();
|
|
}),
|
|
bind(editorApi.body, 'touchstart', function (evt) {
|
|
clearSelection();
|
|
editorApi.onTouchContent();
|
|
tapping.fireTouchstart(evt);
|
|
}),
|
|
tapping.onTouchmove(),
|
|
tapping.onTouchend(),
|
|
bind(editorApi.body, 'click', function (event) {
|
|
event.kill();
|
|
}),
|
|
bind(toolstrip, 'touchmove', function () {
|
|
editorApi.onToolbarScrollStart();
|
|
})
|
|
];
|
|
var destroy = function () {
|
|
each$1(listeners, function (l) {
|
|
l.unbind();
|
|
});
|
|
};
|
|
return { destroy: destroy };
|
|
};
|
|
|
|
function FakeSelection (win, frame) {
|
|
var doc = win.document;
|
|
var container = SugarElement.fromTag('div');
|
|
add$1(container, resolve('unfocused-selections'));
|
|
append$2(SugarElement.fromDom(doc.documentElement), container);
|
|
var onTouch = bind(container, 'touchstart', function (event) {
|
|
event.prevent();
|
|
resume(win, frame);
|
|
clear();
|
|
});
|
|
var make = function (rectangle) {
|
|
var span = SugarElement.fromTag('span');
|
|
add(span, [
|
|
resolve('layer-editor'),
|
|
resolve('unfocused-selection')
|
|
]);
|
|
setAll(span, {
|
|
left: rectangle.left + 'px',
|
|
top: rectangle.top + 'px',
|
|
width: rectangle.width + 'px',
|
|
height: rectangle.height + 'px'
|
|
});
|
|
return span;
|
|
};
|
|
var update = function () {
|
|
clear();
|
|
var rectangles = getRectangles(win);
|
|
var spans = map$2(rectangles, make);
|
|
append$1(container, spans);
|
|
};
|
|
var clear = function () {
|
|
empty(container);
|
|
};
|
|
var destroy = function () {
|
|
onTouch.unbind();
|
|
remove$7(container);
|
|
};
|
|
var isActive = function () {
|
|
return children(container).length > 0;
|
|
};
|
|
return {
|
|
update: update,
|
|
isActive: isActive,
|
|
destroy: destroy,
|
|
clear: clear
|
|
};
|
|
}
|
|
|
|
var nu$1 = function (baseFn) {
|
|
var data = Optional.none();
|
|
var callbacks = [];
|
|
var map = function (f) {
|
|
return nu$1(function (nCallback) {
|
|
get(function (data) {
|
|
nCallback(f(data));
|
|
});
|
|
});
|
|
};
|
|
var get = function (nCallback) {
|
|
if (isReady()) {
|
|
call(nCallback);
|
|
} else {
|
|
callbacks.push(nCallback);
|
|
}
|
|
};
|
|
var set = function (x) {
|
|
if (!isReady()) {
|
|
data = Optional.some(x);
|
|
run(callbacks);
|
|
callbacks = [];
|
|
}
|
|
};
|
|
var isReady = function () {
|
|
return data.isSome();
|
|
};
|
|
var run = function (cbs) {
|
|
each$1(cbs, call);
|
|
};
|
|
var call = function (cb) {
|
|
data.each(function (x) {
|
|
setTimeout(function () {
|
|
cb(x);
|
|
}, 0);
|
|
});
|
|
};
|
|
baseFn(set);
|
|
return {
|
|
get: get,
|
|
map: map,
|
|
isReady: isReady
|
|
};
|
|
};
|
|
var pure$1 = function (a) {
|
|
return nu$1(function (callback) {
|
|
callback(a);
|
|
});
|
|
};
|
|
var LazyValue = {
|
|
nu: nu$1,
|
|
pure: pure$1
|
|
};
|
|
|
|
var errorReporter = function (err) {
|
|
setTimeout(function () {
|
|
throw err;
|
|
}, 0);
|
|
};
|
|
var make = function (run) {
|
|
var get = function (callback) {
|
|
run().then(callback, errorReporter);
|
|
};
|
|
var map = function (fab) {
|
|
return make(function () {
|
|
return run().then(fab);
|
|
});
|
|
};
|
|
var bind = function (aFutureB) {
|
|
return make(function () {
|
|
return run().then(function (v) {
|
|
return aFutureB(v).toPromise();
|
|
});
|
|
});
|
|
};
|
|
var anonBind = function (futureB) {
|
|
return make(function () {
|
|
return run().then(function () {
|
|
return futureB.toPromise();
|
|
});
|
|
});
|
|
};
|
|
var toLazy = function () {
|
|
return LazyValue.nu(get);
|
|
};
|
|
var toCached = function () {
|
|
var cache = null;
|
|
return make(function () {
|
|
if (cache === null) {
|
|
cache = run();
|
|
}
|
|
return cache;
|
|
});
|
|
};
|
|
var toPromise = run;
|
|
return {
|
|
map: map,
|
|
bind: bind,
|
|
anonBind: anonBind,
|
|
toLazy: toLazy,
|
|
toCached: toCached,
|
|
toPromise: toPromise,
|
|
get: get
|
|
};
|
|
};
|
|
var nu = function (baseFn) {
|
|
return make(function () {
|
|
return new Promise$1(baseFn);
|
|
});
|
|
};
|
|
var pure = function (a) {
|
|
return make(function () {
|
|
return Promise$1.resolve(a);
|
|
});
|
|
};
|
|
var Future = {
|
|
nu: nu,
|
|
pure: pure
|
|
};
|
|
|
|
var adjust = function (value, destination, amount) {
|
|
if (Math.abs(value - destination) <= amount) {
|
|
return Optional.none();
|
|
} else if (value < destination) {
|
|
return Optional.some(value + amount);
|
|
} else {
|
|
return Optional.some(value - amount);
|
|
}
|
|
};
|
|
var create$1 = function () {
|
|
var interval = null;
|
|
var animate = function (getCurrent, destination, amount, increment, doFinish, rate) {
|
|
var finished = false;
|
|
var finish = function (v) {
|
|
finished = true;
|
|
doFinish(v);
|
|
};
|
|
global$2.clearInterval(interval);
|
|
var abort = function (v) {
|
|
global$2.clearInterval(interval);
|
|
finish(v);
|
|
};
|
|
interval = global$2.setInterval(function () {
|
|
var value = getCurrent();
|
|
adjust(value, destination, amount).fold(function () {
|
|
global$2.clearInterval(interval);
|
|
finish(destination);
|
|
}, function (s) {
|
|
increment(s, abort);
|
|
if (!finished) {
|
|
var newValue = getCurrent();
|
|
if (newValue !== s || Math.abs(newValue - destination) > Math.abs(value - destination)) {
|
|
global$2.clearInterval(interval);
|
|
finish(destination);
|
|
}
|
|
}
|
|
});
|
|
}, rate);
|
|
};
|
|
return { animate: animate };
|
|
};
|
|
|
|
var findDevice = function (deviceWidth, deviceHeight) {
|
|
var devices = [
|
|
{
|
|
width: 320,
|
|
height: 480,
|
|
keyboard: {
|
|
portrait: 300,
|
|
landscape: 240
|
|
}
|
|
},
|
|
{
|
|
width: 320,
|
|
height: 568,
|
|
keyboard: {
|
|
portrait: 300,
|
|
landscape: 240
|
|
}
|
|
},
|
|
{
|
|
width: 375,
|
|
height: 667,
|
|
keyboard: {
|
|
portrait: 305,
|
|
landscape: 240
|
|
}
|
|
},
|
|
{
|
|
width: 414,
|
|
height: 736,
|
|
keyboard: {
|
|
portrait: 320,
|
|
landscape: 240
|
|
}
|
|
},
|
|
{
|
|
width: 768,
|
|
height: 1024,
|
|
keyboard: {
|
|
portrait: 320,
|
|
landscape: 400
|
|
}
|
|
},
|
|
{
|
|
width: 1024,
|
|
height: 1366,
|
|
keyboard: {
|
|
portrait: 380,
|
|
landscape: 460
|
|
}
|
|
}
|
|
];
|
|
return findMap(devices, function (device) {
|
|
return someIf(deviceWidth <= device.width && deviceHeight <= device.height, device.keyboard);
|
|
}).getOr({
|
|
portrait: deviceHeight / 5,
|
|
landscape: deviceWidth / 4
|
|
});
|
|
};
|
|
|
|
var softKeyboardLimits = function (outerWindow) {
|
|
return findDevice(outerWindow.screen.width, outerWindow.screen.height);
|
|
};
|
|
var accountableKeyboardHeight = function (outerWindow) {
|
|
var portrait = get$1(outerWindow).isPortrait();
|
|
var limits = softKeyboardLimits(outerWindow);
|
|
var keyboard = portrait ? limits.portrait : limits.landscape;
|
|
var visualScreenHeight = portrait ? outerWindow.screen.height : outerWindow.screen.width;
|
|
return visualScreenHeight - outerWindow.innerHeight > keyboard ? 0 : keyboard;
|
|
};
|
|
var getGreenzone = function (socket, dropup) {
|
|
var outerWindow = owner$2(socket).dom.defaultView;
|
|
var viewportHeight = get$7(socket) + get$7(dropup);
|
|
var acc = accountableKeyboardHeight(outerWindow);
|
|
return viewportHeight - acc;
|
|
};
|
|
var updatePadding = function (contentBody, socket, dropup) {
|
|
var greenzoneHeight = getGreenzone(socket, dropup);
|
|
var deltaHeight = get$7(socket) + get$7(dropup) - greenzoneHeight;
|
|
set$5(contentBody, 'padding-bottom', deltaHeight + 'px');
|
|
};
|
|
|
|
var fixture = Adt.generate([
|
|
{
|
|
fixed: [
|
|
'element',
|
|
'property',
|
|
'offsetY'
|
|
]
|
|
},
|
|
{
|
|
scroller: [
|
|
'element',
|
|
'offsetY'
|
|
]
|
|
}
|
|
]);
|
|
var yFixedData = 'data-' + resolve('position-y-fixed');
|
|
var yFixedProperty = 'data-' + resolve('y-property');
|
|
var yScrollingData = 'data-' + resolve('scrolling');
|
|
var windowSizeData = 'data-' + resolve('last-window-height');
|
|
var getYFixedData = function (element) {
|
|
return safeParse(element, yFixedData);
|
|
};
|
|
var getYFixedProperty = function (element) {
|
|
return get$b(element, yFixedProperty);
|
|
};
|
|
var getLastWindowSize = function (element) {
|
|
return safeParse(element, windowSizeData);
|
|
};
|
|
var classifyFixed = function (element, offsetY) {
|
|
var prop = getYFixedProperty(element);
|
|
return fixture.fixed(element, prop, offsetY);
|
|
};
|
|
var classifyScrolling = function (element, offsetY) {
|
|
return fixture.scroller(element, offsetY);
|
|
};
|
|
var classify = function (element) {
|
|
var offsetY = getYFixedData(element);
|
|
var classifier = get$b(element, yScrollingData) === 'true' ? classifyScrolling : classifyFixed;
|
|
return classifier(element, offsetY);
|
|
};
|
|
var findFixtures = function (container) {
|
|
var candidates = descendants(container, '[' + yFixedData + ']');
|
|
return map$2(candidates, classify);
|
|
};
|
|
var takeoverToolbar = function (toolbar) {
|
|
var oldToolbarStyle = get$b(toolbar, 'style');
|
|
setAll(toolbar, {
|
|
position: 'absolute',
|
|
top: '0px'
|
|
});
|
|
set$8(toolbar, yFixedData, '0px');
|
|
set$8(toolbar, yFixedProperty, 'top');
|
|
var restore = function () {
|
|
set$8(toolbar, 'style', oldToolbarStyle || '');
|
|
remove$6(toolbar, yFixedData);
|
|
remove$6(toolbar, yFixedProperty);
|
|
};
|
|
return { restore: restore };
|
|
};
|
|
var takeoverViewport = function (toolbarHeight, height, viewport) {
|
|
var oldViewportStyle = get$b(viewport, 'style');
|
|
register$2(viewport);
|
|
setAll(viewport, {
|
|
position: 'absolute',
|
|
height: height + 'px',
|
|
width: '100%',
|
|
top: toolbarHeight + 'px'
|
|
});
|
|
set$8(viewport, yFixedData, toolbarHeight + 'px');
|
|
set$8(viewport, yScrollingData, 'true');
|
|
set$8(viewport, yFixedProperty, 'top');
|
|
var restore = function () {
|
|
deregister(viewport);
|
|
set$8(viewport, 'style', oldViewportStyle || '');
|
|
remove$6(viewport, yFixedData);
|
|
remove$6(viewport, yScrollingData);
|
|
remove$6(viewport, yFixedProperty);
|
|
};
|
|
return { restore: restore };
|
|
};
|
|
var takeoverDropup = function (dropup) {
|
|
var oldDropupStyle = get$b(dropup, 'style');
|
|
setAll(dropup, {
|
|
position: 'absolute',
|
|
bottom: '0px'
|
|
});
|
|
set$8(dropup, yFixedData, '0px');
|
|
set$8(dropup, yFixedProperty, 'bottom');
|
|
var restore = function () {
|
|
set$8(dropup, 'style', oldDropupStyle || '');
|
|
remove$6(dropup, yFixedData);
|
|
remove$6(dropup, yFixedProperty);
|
|
};
|
|
return { restore: restore };
|
|
};
|
|
var deriveViewportHeight = function (viewport, toolbarHeight, dropupHeight) {
|
|
var outerWindow = owner$2(viewport).dom.defaultView;
|
|
var winH = outerWindow.innerHeight;
|
|
set$8(viewport, windowSizeData, winH + 'px');
|
|
return winH - toolbarHeight - dropupHeight;
|
|
};
|
|
var takeover = function (viewport, contentBody, toolbar, dropup) {
|
|
var outerWindow = owner$2(viewport).dom.defaultView;
|
|
var toolbarSetup = takeoverToolbar(toolbar);
|
|
var toolbarHeight = get$7(toolbar);
|
|
var dropupHeight = get$7(dropup);
|
|
var viewportHeight = deriveViewportHeight(viewport, toolbarHeight, dropupHeight);
|
|
var viewportSetup = takeoverViewport(toolbarHeight, viewportHeight, viewport);
|
|
var dropupSetup = takeoverDropup(dropup);
|
|
var isActive = true;
|
|
var restore = function () {
|
|
isActive = false;
|
|
toolbarSetup.restore();
|
|
viewportSetup.restore();
|
|
dropupSetup.restore();
|
|
};
|
|
var isExpanding = function () {
|
|
var currentWinHeight = outerWindow.innerHeight;
|
|
var lastWinHeight = getLastWindowSize(viewport);
|
|
return currentWinHeight > lastWinHeight;
|
|
};
|
|
var refresh = function () {
|
|
if (isActive) {
|
|
var newToolbarHeight = get$7(toolbar);
|
|
var dropupHeight_1 = get$7(dropup);
|
|
var newHeight = deriveViewportHeight(viewport, newToolbarHeight, dropupHeight_1);
|
|
set$8(viewport, yFixedData, newToolbarHeight + 'px');
|
|
set$5(viewport, 'height', newHeight + 'px');
|
|
updatePadding(contentBody, viewport, dropup);
|
|
}
|
|
};
|
|
var setViewportOffset = function (newYOffset) {
|
|
var offsetPx = newYOffset + 'px';
|
|
set$8(viewport, yFixedData, offsetPx);
|
|
refresh();
|
|
};
|
|
updatePadding(contentBody, viewport, dropup);
|
|
return {
|
|
setViewportOffset: setViewportOffset,
|
|
isExpanding: isExpanding,
|
|
isShrinking: not(isExpanding),
|
|
refresh: refresh,
|
|
restore: restore
|
|
};
|
|
};
|
|
|
|
var animator = create$1();
|
|
var ANIMATION_STEP = 15;
|
|
var NUM_TOP_ANIMATION_FRAMES = 10;
|
|
var ANIMATION_RATE = 10;
|
|
var lastScroll = 'data-' + resolve('last-scroll-top');
|
|
var getTop = function (element) {
|
|
var raw = getRaw(element, 'top').getOr('0');
|
|
return parseInt(raw, 10);
|
|
};
|
|
var getScrollTop = function (element) {
|
|
return parseInt(element.dom.scrollTop, 10);
|
|
};
|
|
var moveScrollAndTop = function (element, destination, finalTop) {
|
|
return Future.nu(function (callback) {
|
|
var getCurrent = curry(getScrollTop, element);
|
|
var update = function (newScroll) {
|
|
element.dom.scrollTop = newScroll;
|
|
set$5(element, 'top', getTop(element) + ANIMATION_STEP + 'px');
|
|
};
|
|
var finish = function () {
|
|
element.dom.scrollTop = destination;
|
|
set$5(element, 'top', finalTop + 'px');
|
|
callback(destination);
|
|
};
|
|
animator.animate(getCurrent, destination, ANIMATION_STEP, update, finish, ANIMATION_RATE);
|
|
});
|
|
};
|
|
var moveOnlyScroll = function (element, destination) {
|
|
return Future.nu(function (callback) {
|
|
var getCurrent = curry(getScrollTop, element);
|
|
set$8(element, lastScroll, getCurrent());
|
|
var update = function (newScroll, abort) {
|
|
var previous = safeParse(element, lastScroll);
|
|
if (previous !== element.dom.scrollTop) {
|
|
abort(element.dom.scrollTop);
|
|
} else {
|
|
element.dom.scrollTop = newScroll;
|
|
set$8(element, lastScroll, newScroll);
|
|
}
|
|
};
|
|
var finish = function () {
|
|
element.dom.scrollTop = destination;
|
|
set$8(element, lastScroll, destination);
|
|
callback(destination);
|
|
};
|
|
var distance = Math.abs(destination - getCurrent());
|
|
var step = Math.ceil(distance / NUM_TOP_ANIMATION_FRAMES);
|
|
animator.animate(getCurrent, destination, step, update, finish, ANIMATION_RATE);
|
|
});
|
|
};
|
|
var moveOnlyTop = function (element, destination) {
|
|
return Future.nu(function (callback) {
|
|
var getCurrent = curry(getTop, element);
|
|
var update = function (newTop) {
|
|
set$5(element, 'top', newTop + 'px');
|
|
};
|
|
var finish = function () {
|
|
update(destination);
|
|
callback(destination);
|
|
};
|
|
var distance = Math.abs(destination - getCurrent());
|
|
var step = Math.ceil(distance / NUM_TOP_ANIMATION_FRAMES);
|
|
animator.animate(getCurrent, destination, step, update, finish, ANIMATION_RATE);
|
|
});
|
|
};
|
|
var updateTop = function (element, amount) {
|
|
var newTop = amount + getYFixedData(element) + 'px';
|
|
set$5(element, 'top', newTop);
|
|
};
|
|
var moveWindowScroll = function (toolbar, viewport, destY) {
|
|
var outerWindow = owner$2(toolbar).dom.defaultView;
|
|
return Future.nu(function (callback) {
|
|
updateTop(toolbar, destY);
|
|
updateTop(viewport, destY);
|
|
outerWindow.scrollTo(0, destY);
|
|
callback(destY);
|
|
});
|
|
};
|
|
|
|
function BackgroundActivity (doAction) {
|
|
var action = Cell(LazyValue.pure({}));
|
|
var start = function (value) {
|
|
var future = LazyValue.nu(function (callback) {
|
|
return doAction(value).get(callback);
|
|
});
|
|
action.set(future);
|
|
};
|
|
var idle = function (g) {
|
|
action.get().get(function () {
|
|
g();
|
|
});
|
|
};
|
|
return {
|
|
start: start,
|
|
idle: idle
|
|
};
|
|
}
|
|
|
|
var scrollIntoView = function (cWin, socket, dropup, top, bottom) {
|
|
var greenzone = getGreenzone(socket, dropup);
|
|
var refreshCursor = curry(refresh, cWin);
|
|
if (top > greenzone || bottom > greenzone) {
|
|
moveOnlyScroll(socket, socket.dom.scrollTop - greenzone + bottom).get(refreshCursor);
|
|
} else if (top < 0) {
|
|
moveOnlyScroll(socket, socket.dom.scrollTop + top).get(refreshCursor);
|
|
} else ;
|
|
};
|
|
|
|
var par$1 = function (asyncValues, nu) {
|
|
return nu(function (callback) {
|
|
var r = [];
|
|
var count = 0;
|
|
var cb = function (i) {
|
|
return function (value) {
|
|
r[i] = value;
|
|
count++;
|
|
if (count >= asyncValues.length) {
|
|
callback(r);
|
|
}
|
|
};
|
|
};
|
|
if (asyncValues.length === 0) {
|
|
callback([]);
|
|
} else {
|
|
each$1(asyncValues, function (asyncValue, i) {
|
|
asyncValue.get(cb(i));
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
var par = function (futures) {
|
|
return par$1(futures, Future.nu);
|
|
};
|
|
|
|
var updateFixed = function (element, property, winY, offsetY) {
|
|
var destination = winY + offsetY;
|
|
set$5(element, property, destination + 'px');
|
|
return Future.pure(offsetY);
|
|
};
|
|
var updateScrollingFixed = function (element, winY, offsetY) {
|
|
var destTop = winY + offsetY;
|
|
var oldProp = getRaw(element, 'top').getOr(offsetY);
|
|
var delta = destTop - parseInt(oldProp, 10);
|
|
var destScroll = element.dom.scrollTop + delta;
|
|
return moveScrollAndTop(element, destScroll, destTop);
|
|
};
|
|
var updateFixture = function (fixture, winY) {
|
|
return fixture.fold(function (element, property, offsetY) {
|
|
return updateFixed(element, property, winY, offsetY);
|
|
}, function (element, offsetY) {
|
|
return updateScrollingFixed(element, winY, offsetY);
|
|
});
|
|
};
|
|
var updatePositions = function (container, winY) {
|
|
var fixtures = findFixtures(container);
|
|
var updates = map$2(fixtures, function (fixture) {
|
|
return updateFixture(fixture, winY);
|
|
});
|
|
return par(updates);
|
|
};
|
|
|
|
var VIEW_MARGIN = 5;
|
|
var register = function (toolstrip, socket, container, outerWindow, structure, cWin) {
|
|
var scroller = BackgroundActivity(function (y) {
|
|
return moveWindowScroll(toolstrip, socket, y);
|
|
});
|
|
var scrollBounds = function () {
|
|
var rects = getRectangles(cWin);
|
|
return Optional.from(rects[0]).bind(function (rect) {
|
|
var viewTop = rect.top - socket.dom.scrollTop;
|
|
var outside = viewTop > outerWindow.innerHeight + VIEW_MARGIN || viewTop < -VIEW_MARGIN;
|
|
return outside ? Optional.some({
|
|
top: viewTop,
|
|
bottom: viewTop + rect.height
|
|
}) : Optional.none();
|
|
});
|
|
};
|
|
var scrollThrottle = last(function () {
|
|
scroller.idle(function () {
|
|
updatePositions(container, outerWindow.pageYOffset).get(function () {
|
|
var extraScroll = scrollBounds();
|
|
extraScroll.each(function (extra) {
|
|
socket.dom.scrollTop = socket.dom.scrollTop + extra.top;
|
|
});
|
|
scroller.start(0);
|
|
structure.refresh();
|
|
});
|
|
});
|
|
}, 1000);
|
|
var onScroll = bind(SugarElement.fromDom(outerWindow), 'scroll', function () {
|
|
if (outerWindow.pageYOffset < 0) {
|
|
return;
|
|
}
|
|
scrollThrottle.throttle();
|
|
});
|
|
updatePositions(container, outerWindow.pageYOffset).get(identity);
|
|
return { unbind: onScroll.unbind };
|
|
};
|
|
var setup = function (bag) {
|
|
var cWin = bag.cWin;
|
|
var ceBody = bag.ceBody;
|
|
var socket = bag.socket;
|
|
var toolstrip = bag.toolstrip;
|
|
var contentElement = bag.contentElement;
|
|
var keyboardType = bag.keyboardType;
|
|
var outerWindow = bag.outerWindow;
|
|
var dropup = bag.dropup;
|
|
var outerBody = bag.outerBody;
|
|
var structure = takeover(socket, ceBody, toolstrip, dropup);
|
|
var keyboardModel = keyboardType(outerBody, cWin, body(), contentElement);
|
|
var toEditing = function () {
|
|
keyboardModel.toEditing();
|
|
clearSelection();
|
|
};
|
|
var toReading = function () {
|
|
keyboardModel.toReading();
|
|
};
|
|
var onToolbarTouch = function (_event) {
|
|
keyboardModel.onToolbarTouch();
|
|
};
|
|
var onOrientation = onChange(outerWindow, {
|
|
onChange: noop,
|
|
onReady: structure.refresh
|
|
});
|
|
onOrientation.onAdjustment(function () {
|
|
structure.refresh();
|
|
});
|
|
var onResize = bind(SugarElement.fromDom(outerWindow), 'resize', function () {
|
|
if (structure.isExpanding()) {
|
|
structure.refresh();
|
|
}
|
|
});
|
|
var onScroll = register(toolstrip, socket, outerBody, outerWindow, structure, cWin);
|
|
var unfocusedSelection = FakeSelection(cWin, contentElement);
|
|
var refreshSelection = function () {
|
|
if (unfocusedSelection.isActive()) {
|
|
unfocusedSelection.update();
|
|
}
|
|
};
|
|
var highlightSelection = function () {
|
|
unfocusedSelection.update();
|
|
};
|
|
var clearSelection = function () {
|
|
unfocusedSelection.clear();
|
|
};
|
|
var scrollIntoView$1 = function (top, bottom) {
|
|
scrollIntoView(cWin, socket, dropup, top, bottom);
|
|
};
|
|
var syncHeight = function () {
|
|
set$5(contentElement, 'height', contentElement.dom.contentWindow.document.body.scrollHeight + 'px');
|
|
};
|
|
var setViewportOffset = function (newYOffset) {
|
|
structure.setViewportOffset(newYOffset);
|
|
moveOnlyTop(socket, newYOffset).get(identity);
|
|
};
|
|
var destroy = function () {
|
|
structure.restore();
|
|
onOrientation.destroy();
|
|
onScroll.unbind();
|
|
onResize.unbind();
|
|
keyboardModel.destroy();
|
|
unfocusedSelection.destroy();
|
|
input(body(), blur$1);
|
|
};
|
|
return {
|
|
toEditing: toEditing,
|
|
toReading: toReading,
|
|
onToolbarTouch: onToolbarTouch,
|
|
refreshSelection: refreshSelection,
|
|
clearSelection: clearSelection,
|
|
highlightSelection: highlightSelection,
|
|
scrollIntoView: scrollIntoView$1,
|
|
updateToolbarPadding: noop,
|
|
setViewportOffset: setViewportOffset,
|
|
syncHeight: syncHeight,
|
|
refreshStructure: structure.refresh,
|
|
destroy: destroy
|
|
};
|
|
};
|
|
|
|
var create = function (platform, mask) {
|
|
var meta = tag();
|
|
var priorState = value();
|
|
var scrollEvents = value();
|
|
var iosApi = api$2();
|
|
var iosEvents = api$2();
|
|
var enter = function () {
|
|
mask.hide();
|
|
var doc = SugarElement.fromDom(document);
|
|
getActiveApi(platform.editor).each(function (editorApi) {
|
|
priorState.set({
|
|
socketHeight: getRaw(platform.socket, 'height'),
|
|
iframeHeight: getRaw(editorApi.frame, 'height'),
|
|
outerScroll: document.body.scrollTop
|
|
});
|
|
scrollEvents.set({ exclusives: exclusive(doc, '.' + scrollable) });
|
|
add$1(platform.container, resolve('fullscreen-maximized'));
|
|
clobberStyles(platform.container, editorApi.body);
|
|
meta.maximize();
|
|
set$5(platform.socket, 'overflow', 'scroll');
|
|
set$5(platform.socket, '-webkit-overflow-scrolling', 'touch');
|
|
focus$3(editorApi.body);
|
|
iosApi.set(setup({
|
|
cWin: editorApi.win,
|
|
ceBody: editorApi.body,
|
|
socket: platform.socket,
|
|
toolstrip: platform.toolstrip,
|
|
dropup: platform.dropup.element,
|
|
contentElement: editorApi.frame,
|
|
outerBody: platform.body,
|
|
outerWindow: platform.win,
|
|
keyboardType: stubborn
|
|
}));
|
|
iosApi.run(function (api) {
|
|
api.syncHeight();
|
|
});
|
|
iosEvents.set(initEvents(editorApi, iosApi, platform.toolstrip, platform.socket, platform.dropup));
|
|
});
|
|
};
|
|
var exit = function () {
|
|
meta.restore();
|
|
iosEvents.clear();
|
|
iosApi.clear();
|
|
mask.show();
|
|
priorState.on(function (s) {
|
|
s.socketHeight.each(function (h) {
|
|
set$5(platform.socket, 'height', h);
|
|
});
|
|
s.iframeHeight.each(function (h) {
|
|
set$5(platform.editor.getFrame(), 'height', h);
|
|
});
|
|
document.body.scrollTop = s.scrollTop;
|
|
});
|
|
priorState.clear();
|
|
scrollEvents.on(function (s) {
|
|
s.exclusives.unbind();
|
|
});
|
|
scrollEvents.clear();
|
|
remove$3(platform.container, resolve('fullscreen-maximized'));
|
|
restoreStyles();
|
|
deregister(platform.toolbar);
|
|
remove$2(platform.socket, 'overflow');
|
|
remove$2(platform.socket, '-webkit-overflow-scrolling');
|
|
blur$1(platform.editor.getFrame());
|
|
getActiveApi(platform.editor).each(function (editorApi) {
|
|
editorApi.clearSelection();
|
|
});
|
|
};
|
|
var refreshStructure = function () {
|
|
iosApi.run(function (api) {
|
|
api.refreshStructure();
|
|
});
|
|
};
|
|
return {
|
|
enter: enter,
|
|
refreshStructure: refreshStructure,
|
|
exit: exit
|
|
};
|
|
};
|
|
|
|
var produce = function (raw) {
|
|
var mobile = asRawOrDie$1('Getting IosWebapp schema', MobileSchema, raw);
|
|
set$5(mobile.toolstrip, 'width', '100%');
|
|
set$5(mobile.container, 'position', 'relative');
|
|
var onView = function () {
|
|
mobile.setReadOnly(mobile.readOnlyOnInit());
|
|
mode.enter();
|
|
};
|
|
var mask = build$1(sketch(onView, mobile.translate));
|
|
mobile.alloy.add(mask);
|
|
var maskApi = {
|
|
show: function () {
|
|
mobile.alloy.add(mask);
|
|
},
|
|
hide: function () {
|
|
mobile.alloy.remove(mask);
|
|
}
|
|
};
|
|
var mode = create(mobile, maskApi);
|
|
return {
|
|
setReadOnly: mobile.setReadOnly,
|
|
refreshStructure: mode.refreshStructure,
|
|
enter: mode.enter,
|
|
exit: mode.exit,
|
|
destroy: noop
|
|
};
|
|
};
|
|
|
|
function IosRealm (scrollIntoView) {
|
|
var alloy = OuterContainer({ classes: [resolve('ios-container')] });
|
|
var toolbar = ScrollingToolbar();
|
|
var webapp = api$2();
|
|
var switchToEdit = makeEditSwitch(webapp);
|
|
var socket = makeSocket();
|
|
var dropup = build(function () {
|
|
webapp.run(function (w) {
|
|
w.refreshStructure();
|
|
});
|
|
}, scrollIntoView);
|
|
alloy.add(toolbar.wrapper);
|
|
alloy.add(socket);
|
|
alloy.add(dropup.component);
|
|
var setToolbarGroups = function (rawGroups) {
|
|
var groups = toolbar.createGroups(rawGroups);
|
|
toolbar.setGroups(groups);
|
|
};
|
|
var setContextToolbar = function (rawGroups) {
|
|
var groups = toolbar.createGroups(rawGroups);
|
|
toolbar.setContextToolbar(groups);
|
|
};
|
|
var focusToolbar = function () {
|
|
toolbar.focus();
|
|
};
|
|
var restoreToolbar = function () {
|
|
toolbar.restoreToolbar();
|
|
};
|
|
var init = function (spec) {
|
|
webapp.set(produce(spec));
|
|
};
|
|
var exit = function () {
|
|
webapp.run(function (w) {
|
|
Replacing.remove(socket, switchToEdit);
|
|
w.exit();
|
|
});
|
|
};
|
|
var updateMode$1 = function (readOnly) {
|
|
updateMode(socket, switchToEdit, readOnly, alloy.root);
|
|
};
|
|
return {
|
|
system: alloy,
|
|
element: alloy.element,
|
|
init: init,
|
|
exit: exit,
|
|
setToolbarGroups: setToolbarGroups,
|
|
setContextToolbar: setContextToolbar,
|
|
focusToolbar: focusToolbar,
|
|
restoreToolbar: restoreToolbar,
|
|
updateMode: updateMode$1,
|
|
socket: socket,
|
|
dropup: dropup
|
|
};
|
|
}
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
|
|
|
var derive = function (editor) {
|
|
var base = Optional.from(getSkinUrl(editor)).getOrThunk(function () {
|
|
return global$1.baseURL + '/skins/ui/oxide';
|
|
});
|
|
return {
|
|
content: base + '/content.mobile.min.css',
|
|
ui: base + '/skin.mobile.min.css'
|
|
};
|
|
};
|
|
|
|
var fireChange = function (realm, command, state) {
|
|
realm.system.broadcastOn([formatChanged], {
|
|
command: command,
|
|
state: state
|
|
});
|
|
};
|
|
var init = function (realm, editor) {
|
|
var allFormats = keys(editor.formatter.get());
|
|
each$1(allFormats, function (command) {
|
|
editor.formatter.formatChanged(command, function (state) {
|
|
fireChange(realm, command, state);
|
|
});
|
|
});
|
|
each$1([
|
|
'ul',
|
|
'ol'
|
|
], function (command) {
|
|
editor.selection.selectorChanged(command, function (state, _data) {
|
|
fireChange(realm, command, state);
|
|
});
|
|
});
|
|
};
|
|
|
|
var fireSkinLoaded = function (editor) {
|
|
return function () {
|
|
var done = function () {
|
|
editor._skinLoaded = true;
|
|
editor.fire('SkinLoaded');
|
|
};
|
|
if (editor.initialized) {
|
|
done();
|
|
} else {
|
|
editor.on('init', done);
|
|
}
|
|
};
|
|
};
|
|
|
|
var READING = 'toReading';
|
|
var EDITING = 'toEditing';
|
|
var renderMobileTheme = function (editor) {
|
|
var renderUI = function () {
|
|
var targetNode = editor.getElement();
|
|
var cssUrls = derive(editor);
|
|
if (isSkinDisabled(editor) === false) {
|
|
var styleSheetLoader_1 = global$5.DOM.styleSheetLoader;
|
|
editor.contentCSS.push(cssUrls.content);
|
|
styleSheetLoader_1.load(cssUrls.ui, fireSkinLoaded(editor));
|
|
editor.on('remove', function () {
|
|
return styleSheetLoader_1.unload(cssUrls.ui);
|
|
});
|
|
} else {
|
|
fireSkinLoaded(editor)();
|
|
}
|
|
var doScrollIntoView = function () {
|
|
editor.fire('ScrollIntoView');
|
|
};
|
|
var realm = detect$1().os.isAndroid() ? AndroidRealm(doScrollIntoView) : IosRealm(doScrollIntoView);
|
|
var original = SugarElement.fromDom(targetNode);
|
|
attachSystemAfter(original, realm.system);
|
|
var findFocusIn = function (elem) {
|
|
return search(elem).bind(function (focused) {
|
|
return realm.system.getByDom(focused).toOptional();
|
|
});
|
|
};
|
|
var outerWindow = targetNode.ownerDocument.defaultView;
|
|
var orientation = onChange(outerWindow, {
|
|
onChange: function () {
|
|
var alloy = realm.system;
|
|
alloy.broadcastOn([orientationChanged], { width: getActualWidth(outerWindow) });
|
|
},
|
|
onReady: noop
|
|
});
|
|
var setReadOnly = function (dynamicGroup, readOnlyGroups, mainGroups, ro) {
|
|
if (ro === false) {
|
|
editor.selection.collapse();
|
|
}
|
|
var toolbars = configureToolbar(dynamicGroup, readOnlyGroups, mainGroups);
|
|
realm.setToolbarGroups(ro === true ? toolbars.readOnly : toolbars.main);
|
|
editor.setMode(ro === true ? 'readonly' : 'design');
|
|
editor.fire(ro === true ? READING : EDITING);
|
|
realm.updateMode(ro);
|
|
};
|
|
var configureToolbar = function (dynamicGroup, readOnlyGroups, mainGroups) {
|
|
var dynamic = dynamicGroup.get();
|
|
var toolbars = {
|
|
readOnly: dynamic.backToMask.concat(readOnlyGroups.get()),
|
|
main: dynamic.backToMask.concat(mainGroups.get())
|
|
};
|
|
return toolbars;
|
|
};
|
|
var bindHandler = function (label, handler) {
|
|
editor.on(label, handler);
|
|
return {
|
|
unbind: function () {
|
|
editor.off(label);
|
|
}
|
|
};
|
|
};
|
|
editor.on('init', function () {
|
|
realm.init({
|
|
editor: {
|
|
getFrame: function () {
|
|
return SugarElement.fromDom(editor.contentAreaContainer.querySelector('iframe'));
|
|
},
|
|
onDomChanged: function () {
|
|
return { unbind: noop };
|
|
},
|
|
onToReading: function (handler) {
|
|
return bindHandler(READING, handler);
|
|
},
|
|
onToEditing: function (handler) {
|
|
return bindHandler(EDITING, handler);
|
|
},
|
|
onScrollToCursor: function (handler) {
|
|
editor.on('ScrollIntoView', function (tinyEvent) {
|
|
handler(tinyEvent);
|
|
});
|
|
var unbind = function () {
|
|
editor.off('ScrollIntoView');
|
|
orientation.destroy();
|
|
};
|
|
return { unbind: unbind };
|
|
},
|
|
onTouchToolstrip: function () {
|
|
hideDropup();
|
|
},
|
|
onTouchContent: function () {
|
|
var toolbar = SugarElement.fromDom(editor.editorContainer.querySelector('.' + resolve('toolbar')));
|
|
findFocusIn(toolbar).each(emitExecute);
|
|
realm.restoreToolbar();
|
|
hideDropup();
|
|
},
|
|
onTapContent: function (evt) {
|
|
var target = evt.target;
|
|
if (name$1(target) === 'img') {
|
|
editor.selection.select(target.dom);
|
|
evt.kill();
|
|
} else if (name$1(target) === 'a') {
|
|
var component = realm.system.getByDom(SugarElement.fromDom(editor.editorContainer));
|
|
component.each(function (container) {
|
|
if (Swapping.isAlpha(container)) {
|
|
openLink(target.dom);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
},
|
|
container: SugarElement.fromDom(editor.editorContainer),
|
|
socket: SugarElement.fromDom(editor.contentAreaContainer),
|
|
toolstrip: SugarElement.fromDom(editor.editorContainer.querySelector('.' + resolve('toolstrip'))),
|
|
toolbar: SugarElement.fromDom(editor.editorContainer.querySelector('.' + resolve('toolbar'))),
|
|
dropup: realm.dropup,
|
|
alloy: realm.system,
|
|
translate: noop,
|
|
setReadOnly: function (ro) {
|
|
setReadOnly(dynamicGroup, readOnlyGroups, mainGroups, ro);
|
|
},
|
|
readOnlyOnInit: function () {
|
|
return readOnlyOnInit();
|
|
}
|
|
});
|
|
var hideDropup = function () {
|
|
realm.dropup.disappear(function () {
|
|
realm.system.broadcastOn([dropupDismissed], {});
|
|
});
|
|
};
|
|
var backToMaskGroup = {
|
|
label: 'The first group',
|
|
scrollable: false,
|
|
items: [forToolbar('back', function () {
|
|
editor.selection.collapse();
|
|
realm.exit();
|
|
}, {}, editor)]
|
|
};
|
|
var backToReadOnlyGroup = {
|
|
label: 'Back to read only',
|
|
scrollable: false,
|
|
items: [forToolbar('readonly-back', function () {
|
|
setReadOnly(dynamicGroup, readOnlyGroups, mainGroups, true);
|
|
}, {}, editor)]
|
|
};
|
|
var readOnlyGroup = {
|
|
label: 'The read only mode group',
|
|
scrollable: true,
|
|
items: []
|
|
};
|
|
var features = setup$3(realm, editor);
|
|
var items = detect(editor, features);
|
|
var actionGroup = {
|
|
label: 'the action group',
|
|
scrollable: true,
|
|
items: items
|
|
};
|
|
var extraGroup = {
|
|
label: 'The extra group',
|
|
scrollable: false,
|
|
items: []
|
|
};
|
|
var mainGroups = Cell([
|
|
actionGroup,
|
|
extraGroup
|
|
]);
|
|
var readOnlyGroups = Cell([
|
|
readOnlyGroup,
|
|
extraGroup
|
|
]);
|
|
var dynamicGroup = Cell({
|
|
backToMask: [backToMaskGroup],
|
|
backToReadOnly: [backToReadOnlyGroup]
|
|
});
|
|
init(realm, editor);
|
|
});
|
|
editor.on('remove', function () {
|
|
realm.exit();
|
|
});
|
|
editor.on('detach', function () {
|
|
detachSystem(realm.system);
|
|
realm.system.destroy();
|
|
});
|
|
return {
|
|
iframeContainer: realm.socket.element.dom,
|
|
editorContainer: realm.element.dom
|
|
};
|
|
};
|
|
return {
|
|
getNotificationManagerImpl: function () {
|
|
return {
|
|
open: constant$1({
|
|
progressBar: { value: noop },
|
|
close: noop,
|
|
text: noop,
|
|
getEl: constant$1(null),
|
|
moveTo: noop,
|
|
moveRel: noop,
|
|
settings: {}
|
|
}),
|
|
close: noop,
|
|
reposition: noop,
|
|
getArgs: constant$1({})
|
|
};
|
|
},
|
|
renderUI: renderUI
|
|
};
|
|
};
|
|
function Theme () {
|
|
global$4.add('mobile', renderMobileTheme);
|
|
}
|
|
|
|
Theme();
|
|
|
|
}());
|
|
|
|
tinymce.IconManager.add('default', {
|
|
icons: {
|
|
'accessibility-check': '<svg width="24" height="24"><path d="M12 2a2 2 0 012 2 2 2 0 01-2 2 2 2 0 01-2-2c0-1.1.9-2 2-2zm8 7h-5v12c0 .6-.4 1-1 1a1 1 0 01-1-1v-5c0-.6-.4-1-1-1a1 1 0 00-1 1v5c0 .6-.4 1-1 1a1 1 0 01-1-1V9H4a1 1 0 110-2h16c.6 0 1 .4 1 1s-.4 1-1 1z" fill-rule="nonzero"/></svg>',
|
|
'action-next': '<svg width="24" height="24"><path fill-rule="nonzero" d="M5.7 7.3a1 1 0 00-1.4 1.4l7.7 7.7 7.7-7.7a1 1 0 10-1.4-1.4L12 13.6 5.7 7.3z"/></svg>',
|
|
'action-prev': '<svg width="24" height="24"><path fill-rule="nonzero" d="M18.3 15.7a1 1 0 001.4-1.4L12 6.6l-7.7 7.7a1 1 0 001.4 1.4L12 9.4l6.3 6.3z"/></svg>',
|
|
'align-center': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 110-2zm3 4h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 110-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 010-2zm-3-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2z" fill-rule="evenodd"/></svg>',
|
|
'align-justify': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 110-2zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 110-2zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2zm0 4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2z" fill-rule="evenodd"/></svg>',
|
|
'align-left': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 110-2zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 110-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2z" fill-rule="evenodd"/></svg>',
|
|
'align-none': '<svg width="24" height="24"><path d="M14.2 5L13 7H5a1 1 0 110-2h9.2zm4 0h.8a1 1 0 010 2h-2l1.2-2zm-6.4 4l-1.2 2H5a1 1 0 010-2h6.8zm4 0H19a1 1 0 010 2h-4.4l1.2-2zm-6.4 4l-1.2 2H5a1 1 0 010-2h4.4zm4 0H19a1 1 0 010 2h-6.8l1.2-2zM7 17l-1.2 2H5a1 1 0 010-2h2zm4 0h8a1 1 0 010 2H9.8l1.2-2zm5.2-13.5l1.3.7-9.7 16.3-1.3-.7 9.7-16.3z" fill-rule="evenodd"/></svg>',
|
|
'align-right': '<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 110-2zm6 4h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm-6-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2z" fill-rule="evenodd"/></svg>',
|
|
'arrow-left': '<svg width="24" height="24"><path d="M5.6 13l12 6a1 1 0 001.4-1V6a1 1 0 00-1.4-.9l-12 6a1 1 0 000 1.8z" fill-rule="evenodd"/></svg>',
|
|
'arrow-right': '<svg width="24" height="24"><path d="M18.5 13l-12 6A1 1 0 015 18V6a1 1 0 011.4-.9l12 6a1 1 0 010 1.8z" fill-rule="evenodd"/></svg>',
|
|
'bold': '<svg width="24" height="24"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 01-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4z" fill-rule="evenodd"/></svg>',
|
|
'bookmark': '<svg width="24" height="24"><path d="M6 4v17l6-4 6 4V4c0-.6-.4-1-1-1H7a1 1 0 00-1 1z" fill-rule="nonzero"/></svg>',
|
|
'border-style': '<svg width="24" height="24"><g fill-rule="evenodd"><rect width="18" height="2" x="3" y="6" rx="1"/><rect width="2.8" height="2" x="3" y="16" rx="1"/><rect width="2.8" height="2" x="6.8" y="16" rx="1"/><rect width="2.8" height="2" x="10.6" y="16" rx="1"/><rect width="2.8" height="2" x="14.4" y="16" rx="1"/><rect width="2.8" height="2" x="18.2" y="16" rx="1"/><rect width="8" height="2" x="3" y="11" rx="1"/><rect width="8" height="2" x="13" y="11" rx="1"/></g></svg>',
|
|
'border-width': '<svg width="24" height="24"><g fill-rule="evenodd"><rect width="18" height="5" x="3" y="5" rx="1"/><rect width="18" height="3.5" x="3" y="11.5" rx="1"/><rect width="18" height="2" x="3" y="17" rx="1"/></g></svg>',
|
|
'brightness': '<svg width="24" height="24"><path d="M12 17c.3 0 .5.1.7.3.2.2.3.4.3.7v1c0 .3-.1.5-.3.7a1 1 0 01-.7.3 1 1 0 01-.7-.3 1 1 0 01-.3-.7v-1c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3zm0-10a1 1 0 01-.7-.3A1 1 0 0111 6V5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3.3 0 .5.1.7.3.2.2.3.4.3.7v1c0 .3-.1.5-.3.7a1 1 0 01-.7.3zm7 4c.3 0 .5.1.7.3.2.2.3.4.3.7 0 .3-.1.5-.3.7a1 1 0 01-.7.3h-1a1 1 0 01-.7-.3 1 1 0 01-.3-.7c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h1zM7 12c0 .3-.1.5-.3.7a1 1 0 01-.7.3H5a1 1 0 01-.7-.3A1 1 0 014 12c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h1c.3 0 .5.1.7.3.2.2.3.4.3.7zm10 3.5l.7.8c.2.1.3.4.3.6 0 .3-.1.6-.3.8a1 1 0 01-.8.3 1 1 0 01-.6-.3l-.8-.7a1 1 0 01-.3-.8c0-.2.1-.5.3-.7a1 1 0 011.4 0zm-10-7l-.7-.8a1 1 0 01-.3-.6c0-.3.1-.6.3-.8.2-.2.5-.3.8-.3.2 0 .5.1.7.3l.7.7c.2.2.3.5.3.8 0 .2-.1.5-.3.7a1 1 0 01-.7.3 1 1 0 01-.8-.3zm10 0a1 1 0 01-.8.3 1 1 0 01-.7-.3 1 1 0 01-.3-.7c0-.3.1-.6.3-.8l.8-.7c.1-.2.4-.3.6-.3.3 0 .6.1.8.3.2.2.3.5.3.8 0 .2-.1.5-.3.7l-.7.7zm-10 7c.2-.2.5-.3.8-.3.2 0 .5.1.7.3a1 1 0 010 1.4l-.8.8a1 1 0 01-.6.3 1 1 0 01-.8-.3 1 1 0 01-.3-.8c0-.2.1-.5.3-.6l.7-.8zM12 8a4 4 0 013.7 2.4 4 4 0 010 3.2A4 4 0 0112 16a4 4 0 01-3.7-2.4 4 4 0 010-3.2A4 4 0 0112 8zm0 6.5c.7 0 1.3-.2 1.8-.7.5-.5.7-1.1.7-1.8s-.2-1.3-.7-1.8c-.5-.5-1.1-.7-1.8-.7s-1.3.2-1.8.7c-.5.5-.7 1.1-.7 1.8s.2 1.3.7 1.8c.5.5 1.1.7 1.8.7z" fill-rule="evenodd"/></svg>',
|
|
'browse': '<svg width="24" height="24"><path d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2h-4v-2h4V8H5v10h4v2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm-8 9.4l-2.3 2.3a1 1 0 11-1.4-1.4l4-4a1 1 0 011.4 0l4 4a1 1 0 01-1.4 1.4L13 13.4V20a1 1 0 01-2 0v-6.6z" fill-rule="nonzero"/></svg>',
|
|
'cancel': '<svg width="24" height="24"><path d="M12 4.6a7.4 7.4 0 110 14.8 7.4 7.4 0 010-14.8zM12 3a9 9 0 100 18 9 9 0 000-18zm0 8L14.8 8l1 1.1-2.7 2.8 2.7 2.7-1.1 1.1-2.7-2.7-2.7 2.7-1-1.1 2.6-2.7-2.7-2.7 1-1.1 2.8 2.7z" fill-rule="nonzero"/></svg>',
|
|
'cell-background-color': '<svg width="24" height="24"><path d="M15.7 2l1.6 1.6-2.7 2.6 5.9 5.8c.7.7.7 1.7 0 2.4l-6.3 6.1a1.7 1.7 0 01-2.4 0l-6.3-6.1c-.7-.7-.7-1.7 0-2.4L15.7 2zM18 12l-4.5-4L9 12h9zM4 16s2 2.4 2 3.8C6 21 5.1 22 4 22s-2-1-2-2.2C2 18.4 4 16 4 16z"/></svg>',
|
|
'cell-border-color': '<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M5 13v5h2v2H5a2 2 0 01-2-2v-5h2zm8-7V4h6a2 2 0 012 2h-8z" opacity=".2"/><path fill-rule="nonzero" d="M13 4v2H5v7H3V6c0-1.1.9-2 2-2h8zm-2.6 14.1l.1-.1.1.1.2.3.2.2.2.2c.4.6.8 1.2.8 1.7 0 .8-.7 1.5-1.5 1.5S9 21.3 9 20.5c0-.5.4-1.1.8-1.7l.2-.2.2-.2.2-.3z"/><path d="M13 11l-2 2H5v-2h6V6h2z"/><path fill-rule="nonzero" d="M18.4 8l1 1-1.8 1.9 4 4c.5.4.5 1.1 0 1.6l-4.3 4.2a1.2 1.2 0 01-1.6 0l-4.4-4.2c-.4-.5-.4-1.2 0-1.7l7-6.8zm1.6 7l-3-3-3 3h6z"/></g></svg>',
|
|
'change-case': '<svg width="24" height="24"><path d="M18.4 18.2v-.6c-.5.8-1.3 1.2-2.4 1.2-2.2 0-3.3-1.6-3.3-4.8 0-3.1 1-4.7 3.3-4.7 1.1 0 1.8.3 2.4 1.1v-.6c0-.5.4-.8.8-.8s.8.3.8.8v8.4c0 .5-.4.8-.8.8a.8.8 0 01-.8-.8zm-2-7.4c-1.3 0-1.8.9-1.8 3.2 0 2.4.5 3.3 1.7 3.3 1.3 0 1.8-.9 1.8-3.2 0-2.4-.5-3.3-1.7-3.3zM10 15.7H5.5l-.8 2.6a1 1 0 01-1 .7h-.2a.7.7 0 01-.7-1l4-12a1 1 0 012 0l4 12a.7.7 0 01-.8 1h-.2a1 1 0 01-1-.7l-.8-2.6zm-.3-1.5l-2-6.5-1.9 6.5h3.9z" fill-rule="evenodd"/></svg>',
|
|
'character-count': '<svg width="24" height="24"><path d="M4 11.5h16v1H4v-1zm4.8-6.8V10H7.7V5.8h-1v-1h2zM11 8.3V9h2v1h-3V7.7l2-1v-.9h-2v-1h3v2.4l-2 1zm6.3-3.4V10h-3.1V9h2.1V8h-2.1V6.8h2.1v-1h-2.1v-1h3.1zM5.8 16.4c0-.5.2-.8.5-1 .2-.2.6-.3 1.2-.3l.8.1c.2 0 .4.2.5.3l.4.4v2.8l.2.3H8.2v-.1-.2l-.6.3H7c-.4 0-.7 0-1-.2a1 1 0 01-.3-.9c0-.3 0-.6.3-.8.3-.2.7-.4 1.2-.4l.6-.2h.3v-.2l-.1-.2a.8.8 0 00-.5-.1 1 1 0 00-.4 0l-.3.4h-1zm2.3.8h-.2l-.2.1-.4.1a1 1 0 00-.4.2l-.2.2.1.3.5.1h.4l.4-.4v-.6zm2-3.4h1.2v1.7l.5-.3h.5c.5 0 .9.1 1.2.5.3.4.5.8.5 1.4 0 .6-.2 1.1-.5 1.5-.3.4-.7.6-1.3.6l-.6-.1-.4-.4v.4h-1.1v-5.4zm1.1 3.3c0 .3 0 .6.2.8a.7.7 0 001.2 0l.2-.8c0-.4 0-.6-.2-.8a.7.7 0 00-.6-.3l-.6.3-.2.8zm6.1-.5c0-.2 0-.3-.2-.4a.8.8 0 00-.5-.2c-.3 0-.5.1-.6.3l-.2.9c0 .3 0 .6.2.8.1.2.3.3.6.3.2 0 .4 0 .5-.2l.2-.4h1.1c0 .5-.3.8-.6 1.1a2 2 0 01-1.3.4c-.5 0-1-.2-1.3-.6a2 2 0 01-.5-1.4c0-.6.1-1.1.5-1.5.3-.4.8-.5 1.4-.5.5 0 1 0 1.2.3.4.3.5.7.5 1.2h-1v-.1z" fill-rule="evenodd"/></svg>',
|
|
'checklist-rtl': '<svg width="24" height="24"><path d="M5 17h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 010-2zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 110-2zm14.2 11c.2-.4.6-.5.9-.3.3.2.4.6.2 1L18 20c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 010-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L18 14c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 010-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L18 8c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 010-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8z" fill-rule="evenodd"/></svg>',
|
|
'checklist': '<svg width="24" height="24"><path d="M11 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm0-6h8a1 1 0 010 2h-8a1 1 0 010-2zM7.2 16c.2-.4.6-.5.9-.3.3.2.4.6.2 1L6 20c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 010-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L6 14c-.2.3-.7.4-1 0l-1.3-1.3a.7.7 0 010-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8zm0-6c.2-.4.6-.5.9-.3.3.2.4.6.2 1L6 8c-.2.3-.7.4-1 0L3.8 6.9a.7.7 0 010-1c.3-.2.7-.2 1 0l.7.9 1.7-2.8z" fill-rule="evenodd"/></svg>',
|
|
'checkmark': '<svg width="24" height="24"><path d="M18.2 5.4a1 1 0 011.6 1.2l-8 12a1 1 0 01-1.5.1l-5-5a1 1 0 111.4-1.4l4.1 4.1 7.4-11z" fill-rule="nonzero"/></svg>',
|
|
'chevron-down': '<svg width="10" height="10"><path d="M8.7 2.2c.3-.3.8-.3 1 0 .4.4.4.9 0 1.2L5.7 7.8c-.3.3-.9.3-1.2 0L.2 3.4a.8.8 0 010-1.2c.3-.3.8-.3 1.1 0L5 6l3.7-3.8z" fill-rule="nonzero"/></svg>',
|
|
'chevron-left': '<svg width="10" height="10"><path d="M7.8 1.3L4 5l3.8 3.7c.3.3.3.8 0 1-.4.4-.9.4-1.2 0L2.2 5.7a.8.8 0 010-1.2L6.6.2C7 0 7.4 0 7.8.2c.3.3.3.8 0 1.1z" fill-rule="nonzero"/></svg>',
|
|
'chevron-right': '<svg width="10" height="10"><path d="M2.2 1.3a.8.8 0 010-1c.4-.4.9-.4 1.2 0l4.4 4.1c.3.4.3.9 0 1.2L3.4 9.8c-.3.3-.8.3-1.2 0a.8.8 0 010-1.1L6 5 2.2 1.3z" fill-rule="nonzero"/></svg>',
|
|
'chevron-up': '<svg width="10" height="10"><path d="M8.7 7.8L5 4 1.3 7.8c-.3.3-.8.3-1 0a.8.8 0 010-1.2l4.1-4.4c.3-.3.9-.3 1.2 0l4.2 4.4c.3.3.3.9 0 1.2-.3.3-.8.3-1.1 0z" fill-rule="nonzero"/></svg>',
|
|
'close': '<svg width="24" height="24"><path d="M17.3 8.2L13.4 12l3.9 3.8a1 1 0 01-1.5 1.5L12 13.4l-3.8 3.9a1 1 0 01-1.5-1.5l3.9-3.8-3.9-3.8a1 1 0 011.5-1.5l3.8 3.9 3.8-3.9a1 1 0 011.5 1.5z" fill-rule="evenodd"/></svg>',
|
|
'code-sample': '<svg width="24" height="26"><path d="M7.1 11a2.8 2.8 0 01-.8 2 2.8 2.8 0 01.8 2v1.7c0 .3.1.6.4.8.2.3.5.4.8.4.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.7 0-1.4-.3-2-.8-.5-.6-.8-1.3-.8-2V15c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 01-.4-.4v-.8c0-.2.2-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V9.3c0-.7.3-1.4.8-2 .6-.5 1.3-.8 2-.8.3 0 .4.2.4.4v.8c0 .2-.1.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8V11zm9.8 0V9.3c0-.3-.1-.6-.4-.8-.2-.3-.5-.4-.8-.4a.4.4 0 01-.4-.4V7c0-.2.1-.4.4-.4.7 0 1.4.3 2 .8.5.6.8 1.3.8 2V11c0 .3.1.6.4.8.2.3.5.4.8.4.2 0 .4.2.4.4v.8c0 .2-.2.4-.4.4-.3 0-.6.1-.8.4-.3.2-.4.5-.4.8v1.7c0 .7-.3 1.4-.8 2-.6.5-1.3.8-2 .8a.4.4 0 01-.4-.4v-.8c0-.2.1-.4.4-.4.3 0 .6-.1.8-.4.3-.2.4-.5.4-.8V15a2.8 2.8 0 01.8-2 2.8 2.8 0 01-.8-2zm-3.3-.4c0 .4-.1.8-.5 1.1-.3.3-.7.5-1.1.5-.4 0-.8-.2-1.1-.5-.4-.3-.5-.7-.5-1.1 0-.5.1-.9.5-1.2.3-.3.7-.4 1.1-.4.4 0 .8.1 1.1.4.4.3.5.7.5 1.2zM12 13c.4 0 .8.1 1.1.5.4.3.5.7.5 1.1 0 1-.1 1.6-.5 2a3 3 0 01-1.1 1c-.4.3-.8.4-1.1.4a.5.5 0 01-.5-.5V17a3 3 0 001-.2l.6-.6c-.6 0-1-.2-1.3-.5-.2-.3-.3-.7-.3-1 0-.5.1-1 .5-1.2.3-.4.7-.5 1.1-.5z" fill-rule="evenodd"/></svg>',
|
|
'color-levels': '<svg width="24" height="24"><path d="M17.5 11.4A9 9 0 0118 14c0 .5 0 1-.2 1.4 0 .4-.3.9-.5 1.3a6.2 6.2 0 01-3.7 3 5.7 5.7 0 01-3.2 0A5.9 5.9 0 017.6 18a6.2 6.2 0 01-1.4-2.6 6.7 6.7 0 010-2.8c0-.4.1-.9.3-1.3a13.6 13.6 0 012.3-4A20 20 0 0112 4a26.4 26.4 0 013.2 3.4 18.2 18.2 0 012.3 4zm-2 4.5c.4-.7.5-1.4.5-2a7.3 7.3 0 00-1-3.2c.2.6.2 1.2.2 1.9a4.5 4.5 0 01-1.3 3 5.3 5.3 0 01-2.3 1.5 4.9 4.9 0 01-2 .1 4.3 4.3 0 002.4.8 4 4 0 002-.6 4 4 0 001.5-1.5z" fill-rule="evenodd"/></svg>',
|
|
'color-picker': '<svg width="24" height="24"><path d="M12 3a9 9 0 000 18 1.5 1.5 0 001.1-2.5c-.2-.3-.4-.6-.4-1 0-.8.7-1.5 1.5-1.5H16a5 5 0 005-5c0-4.4-4-8-9-8zm-5.5 9a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm3-4a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm5 0a1.5 1.5 0 110-3 1.5 1.5 0 010 3zm3 4a1.5 1.5 0 110-3 1.5 1.5 0 010 3z" fill-rule="nonzero"/></svg>',
|
|
'color-swatch-remove-color': '<svg width="24" height="24"><path stroke="#000" stroke-width="2" d="M21 3L3 21" fill-rule="evenodd"/></svg>',
|
|
'color-swatch': '<svg width="24" height="24"><rect x="3" y="3" width="18" height="18" rx="1" fill-rule="evenodd"/></svg>',
|
|
'comment-add': '<svg width="24" height="24"><g fill-rule="nonzero"><path d="M9 19l3-2h7c.6 0 1-.4 1-1V6c0-.6-.4-1-1-1H5a1 1 0 00-1 1v10c0 .6.4 1 1 1h4v2zm-2 4v-4H5a3 3 0 01-3-3V6a3 3 0 013-3h14a3 3 0 013 3v10a3 3 0 01-3 3h-6.4L7 23z"/><path d="M13 10h2a1 1 0 010 2h-2v2a1 1 0 01-2 0v-2H9a1 1 0 010-2h2V8a1 1 0 012 0v2z"/></g></svg>',
|
|
'comment': '<svg width="24" height="24"><path fill-rule="nonzero" d="M9 19l3-2h7c.6 0 1-.4 1-1V6c0-.6-.4-1-1-1H5a1 1 0 00-1 1v10c0 .6.4 1 1 1h4v2zm-2 4v-4H5a3 3 0 01-3-3V6a3 3 0 013-3h14a3 3 0 013 3v10a3 3 0 01-3 3h-6.4L7 23z"/></svg>',
|
|
'contrast': '<svg width="24" height="24"><path d="M12 4a7.8 7.8 0 015.7 2.3A8 8 0 1112 4zm-6 8a6 6 0 006 6V6a6 6 0 00-6 6z" fill-rule="evenodd"/></svg>',
|
|
'copy': '<svg width="24" height="24"><path d="M16 3H6a2 2 0 00-2 2v11h2V5h10V3zm1 4a2 2 0 012 2v10a2 2 0 01-2 2h-7a2 2 0 01-2-2V9c0-1.2.9-2 2-2h7zm0 12V9h-7v10h7z" fill-rule="nonzero"/></svg>',
|
|
'crop': '<svg width="24" height="24"><path d="M17 8v7h2c.6 0 1 .4 1 1s-.4 1-1 1h-2v2c0 .6-.4 1-1 1a1 1 0 01-1-1v-2H7V9H5a1 1 0 110-2h2V5c0-.6.4-1 1-1s1 .4 1 1v2h7l3-3 1 1-3 3zM9 9v5l5-5H9zm1 6h5v-5l-5 5z" fill-rule="evenodd"/></svg>',
|
|
'cut-column': '<svg width="24" height="24"><path fill-rule="evenodd" d="M7.2 4.5c.9 0 1.6.4 2.2 1A3.7 3.7 0 0110.5 8v.5l1 1 4-4 1-.5a3.3 3.3 0 012 0c.4 0 .7.3 1 .5L17 8h4v13h-6V10l-1.5 1.5.5.5v4l-2.5-2.5-1 1v.5c0 .4 0 .8-.3 1.2-.2.5-.4.9-.8 1.2-.6.7-1.3 1-2.2 1-.8.2-1.5 0-2-.6l-.5-.8-.2-1c0-.4 0-.8.3-1.2A3.9 3.9 0 017 12.7c.5-.2 1-.3 1.5-.2l1-1-1-1c-.5 0-1 0-1.5-.2-.5-.1-1-.4-1.4-.9-.4-.3-.6-.7-.8-1.2L4.5 7c0-.4 0-.7.2-1 0-.3.3-.6.5-.8.5-.5 1.2-.8 2-.7zm12.3 5h-3v10h3v-10zM8 13.8h-.3l-.4.2a2.8 2.8 0 00-.7.4v.1a2.8 2.8 0 00-.6.8l-.1.4v.7l.2.5.5.2h.7a2.6 2.6 0 00.8-.3 2.4 2.4 0 00.7-.7 2.5 2.5 0 00.3-.8 1.5 1.5 0 000-.8 1 1 0 00-.2-.4 1 1 0 00-.5-.2H8zm3.5-3.7c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zM7 5.8h-.4a1 1 0 00-.5.3 1 1 0 00-.2.5v.7a2.5 2.5 0 00.3.8l.2.3h.1l.4.4.4.2.4.1h.7L9 9l.2-.4a1.6 1.6 0 000-.8 2.6 2.6 0 00-.3-.8A2.5 2.5 0 007.7 6l-.4-.1H7z"/></svg>',
|
|
'cut-row': '<svg width="24" height="24"><path fill-rule="evenodd" d="M22 3v5H9l3 3 2-2h4l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8.7.6 1 1.3 1 2.2.2.8 0 1.5-.6 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 01-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2 0-.9.4-1.6 1-2.2A3.7 3.7 0 018.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 010-2c0-.4.3-.7.5-1l2 2V3h14zM8.5 15.3h-.3a2.6 2.6 0 00-.8.4 2.5 2.5 0 00-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 00.8-.3L9 18V18l.4-.4.2-.4.1-.4v-.3-.4a1 1 0 00-.2-.5 1 1 0 00-.4-.2h-.5zm7 0H15a1 1 0 00-.4.3 1 1 0 00-.2.5 1.5 1.5 0 000 .7v.4a2.8 2.8 0 00.5.7h.1a2.8 2.8 0 00.8.6l.4.1h.7l.5-.2.2-.5v-.4-.3a2.6 2.6 0 00-.3-.8 2.4 2.4 0 00-.7-.7 2.5 2.5 0 00-.8-.3h-.3zM12 11.6c-.4 0-.7.1-1 .4-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4s.7-.1 1-.4c.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4zm8.5-7.1h-11v2h11v-2z"/></svg>',
|
|
'cut': '<svg width="24" height="24"><path d="M18 15c.6.7 1 1.4 1 2.3 0 .8-.2 1.5-.7 2l-.8.5-1 .2c-.4 0-.8 0-1.2-.3a3.9 3.9 0 01-2.1-2.2c-.2-.5-.3-1-.2-1.5l-1-1-1 1c0 .5 0 1-.2 1.5-.1.5-.4 1-.9 1.4-.3.4-.7.6-1.2.8l-1.2.3c-.4 0-.7 0-1-.2-.3 0-.6-.3-.8-.5-.5-.5-.8-1.2-.7-2 0-.9.4-1.6 1-2.2A3.7 3.7 0 018.6 14H9l1-1-4-4-.5-1a3.3 3.3 0 010-2c0-.4.3-.7.5-1l6 6 6-6 .5 1a3.3 3.3 0 010 2c0 .4-.3.7-.5 1l-4 4 1 1h.5c.4 0 .8 0 1.2.3.5.2.9.4 1.2.8zm-8.5 2.2l.1-.4v-.3-.4a1 1 0 00-.2-.5 1 1 0 00-.4-.2 1.6 1.6 0 00-.8 0 2.6 2.6 0 00-.8.3 2.5 2.5 0 00-.9 1.1l-.1.4v.7l.2.5.5.2h.7a2.5 2.5 0 00.8-.3 2.8 2.8 0 001-1zm2.5-2.8c.4 0 .7-.1 1-.4.3-.3.4-.6.4-1s-.1-.7-.4-1c-.3-.3-.6-.4-1-.4s-.7.1-1 .4c-.3.3-.4.6-.4 1s.1.7.4 1c.3.3.6.4 1 .4zm5.4 4l.2-.5v-.4-.3a2.6 2.6 0 00-.3-.8 2.4 2.4 0 00-.7-.7 2.5 2.5 0 00-.8-.3 1.5 1.5 0 00-.8 0 1 1 0 00-.4.2 1 1 0 00-.2.5 1.5 1.5 0 000 .7v.4l.3.4.3.4a2.8 2.8 0 00.8.5l.4.1h.7l.5-.2z" fill-rule="evenodd"/></svg>',
|
|
'document-properties': '<svg width="24" height="24"><path d="M14.4 3H7a2 2 0 00-2 2v14c0 1.1.9 2 2 2h10a2 2 0 002-2V7.6L14.4 3zM17 19H7V5h6v4h4v10z" fill-rule="nonzero"/></svg>',
|
|
'drag': '<svg width="24" height="24"><path d="M13 5h2v2h-2V5zm0 4h2v2h-2V9zM9 9h2v2H9V9zm4 4h2v2h-2v-2zm-4 0h2v2H9v-2zm0 4h2v2H9v-2zm4 0h2v2h-2v-2zM9 5h2v2H9V5z" fill-rule="evenodd"/></svg>',
|
|
'duplicate-column': '<svg width="24" height="24"><path d="M17 6v16h-7V6h7zm-2 2h-3v12h3V8zm-2-6v2H8v15H6V2h7z"/></svg>',
|
|
'duplicate-row': '<svg width="24" height="24"><path d="M22 11v7H6v-7h16zm-2 2H8v3h12v-3zm-1-6v2H4v5H2V7h17z"/></svg>',
|
|
'duplicate': '<svg width="24" height="24"><g fill-rule="nonzero"><path d="M16 3v2H6v11H4V5c0-1.1.9-2 2-2h10zm3 8h-2V9h-7v10h9a2 2 0 01-2 2h-7a2 2 0 01-2-2V9c0-1.2.9-2 2-2h7a2 2 0 012 2v2z"/><path d="M17 14h1a1 1 0 010 2h-1v1a1 1 0 01-2 0v-1h-1a1 1 0 010-2h1v-1a1 1 0 012 0v1z"/></g></svg>',
|
|
'edit-block': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19.8 8.8l-9.4 9.4c-.2.2-.5.4-.9.4l-5.4 1.2 1.2-5.4.5-.8 9.4-9.4c.7-.7 1.8-.7 2.5 0l2.1 2.1c.7.7.7 1.8 0 2.5zm-2-.2l1-.9v-.3l-2.2-2.2a.3.3 0 00-.3 0l-1 1L18 8.5zm-1 1l-2.5-2.4-6 6 2.5 2.5 6-6zm-7 7.1l-2.6-2.4-.3.3-.1.2-.7 3 3.1-.6h.1l.4-.5z"/></svg>',
|
|
'edit-image': '<svg width="24" height="24"><path d="M18 16h2V7a2 2 0 00-2-2H7v2h11v9zM6 17h15a1 1 0 010 2h-1v1a1 1 0 01-2 0v-1H6a2 2 0 01-2-2V7H3a1 1 0 110-2h1V4a1 1 0 112 0v13zm3-5.3l1.3 2 3-4.7 3.7 6H7l2-3.3z" fill-rule="nonzero"/></svg>',
|
|
'embed-page': '<svg width="24" height="24"><path d="M19 6V5H5v14h2A13 13 0 0119 6zm0 1.4c-.8.8-1.6 2.4-2.2 4.6H19V7.4zm0 5.6h-2.4c-.4 1.8-.6 3.8-.6 6h3v-6zm-4 6c0-2.2.2-4.2.6-6H13c-.7 1.8-1.1 3.8-1.1 6h3zm-4 0c0-2.2.4-4.2 1-6H9.6A12 12 0 008 19h3zM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 01-1-1V4c0-.6.4-1 1-1zm11.8 9c.4-1.9 1-3.4 1.8-4.5a9.2 9.2 0 00-4 4.5h2.2zm-3.4 0a12 12 0 012.8-4 12 12 0 00-5 4h2.2z" fill-rule="nonzero"/></svg>',
|
|
'embed': '<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 01-1-1V4c0-.6.4-1 1-1zm1 2v14h14V5H5zm4.8 2.6l5.6 4a.5.5 0 010 .8l-5.6 4A.5.5 0 019 16V8a.5.5 0 01.8-.4z" fill-rule="nonzero"/></svg>',
|
|
'emoji': '<svg width="24" height="24"><path d="M9 11c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 00-1 1c0 .6.4 1 1 1zm6 0c.6 0 1-.4 1-1s-.4-1-1-1a1 1 0 00-1 1c0 .6.4 1 1 1zm-3 5.5c2.1 0 4-1.5 4.4-3.5H7.6c.5 2 2.3 3.5 4.4 3.5zM12 4a8 8 0 100 16 8 8 0 000-16zm0 14.5a6.5 6.5 0 110-13 6.5 6.5 0 010 13z" fill-rule="nonzero"/></svg>',
|
|
'export': '<svg width="24" height="24"><g fill-rule="nonzero"><path d="M14.4 3L18 7v1h-5V5H7v14h9a1 1 0 012 0c0 1-.8 2-1.9 2H7c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2h7.5z"/><path d="M18.1 12c.5 0 .9.4.9 1 0 .5-.3 1-.8 1h-7.3c-.5 0-.9-.4-.9-1 0-.5.3-1 .8-1h7.3z"/><path d="M16.4 9.2a1 1 0 011.4.2l2.4 3.6-2.4 3.6a1 1 0 01-1.7-1v-.2l1.7-2.4-1.6-2.4a1 1 0 01.2-1.4z"/></g></svg>',
|
|
'fill': '<svg width="24" height="26"><path d="M16.6 12l-9-9-1.4 1.4 2.4 2.4-5.2 5.1c-.5.6-.5 1.6 0 2.2L9 19.6a1.5 1.5 0 002.2 0l5.5-5.5c.5-.6.5-1.6 0-2.2zM5.2 13L10 8.2l4.8 4.8H5.2zM19 14.5s-2 2.2-2 3.5c0 1.1.9 2 2 2a2 2 0 002-2c0-1.3-2-3.5-2-3.5z" fill-rule="nonzero"/></svg>',
|
|
'flip-horizontally': '<svg width="24" height="24"><path d="M14 19h2v-2h-2v2zm4-8h2V9h-2v2zM4 7v10c0 1.1.9 2 2 2h3v-2H6V7h3V5H6a2 2 0 00-2 2zm14-2v2h2a2 2 0 00-2-2zm-7 16h2V3h-2v18zm7-6h2v-2h-2v2zm-4-8h2V5h-2v2zm4 12a2 2 0 002-2h-2v2z" fill-rule="nonzero"/></svg>',
|
|
'flip-vertically': '<svg width="24" height="24"><path d="M5 14v2h2v-2H5zm8 4v2h2v-2h-2zm4-14H7a2 2 0 00-2 2v3h2V6h10v3h2V6a2 2 0 00-2-2zm2 14h-2v2a2 2 0 002-2zM3 11v2h18v-2H3zm6 7v2h2v-2H9zm8-4v2h2v-2h-2zM5 18c0 1.1.9 2 2 2v-2H5z" fill-rule="nonzero"/></svg>',
|
|
'format-painter': '<svg width="24" height="24"><path d="M18 5V4c0-.5-.4-1-1-1H5a1 1 0 00-1 1v4c0 .6.5 1 1 1h12c.6 0 1-.4 1-1V7h1v4H9v9c0 .6.4 1 1 1h2c.6 0 1-.4 1-1v-7h8V5h-3z" fill-rule="nonzero"/></svg>',
|
|
'format': '<svg width="24" height="24"><path fill-rule="evenodd" d="M17 5a1 1 0 010 2h-4v11a1 1 0 01-2 0V7H7a1 1 0 110-2h10z"/></svg>',
|
|
'fullscreen': '<svg width="24" height="24"><path d="M15.3 10l-1.2-1.3 2.9-3h-2.3a.9.9 0 110-1.7H19c.5 0 .9.4.9.9v4.4a.9.9 0 11-1.8 0V7l-2.9 3zm0 4l3 3v-2.3a.9.9 0 111.7 0V19c0 .5-.4.9-.9.9h-4.4a.9.9 0 110-1.8H17l-3-2.9 1.3-1.2zM10 15.4l-2.9 3h2.3a.9.9 0 110 1.7H5a.9.9 0 01-.9-.9v-4.4a.9.9 0 111.8 0V17l2.9-3 1.2 1.3zM8.7 10L5.7 7v2.3a.9.9 0 01-1.7 0V5c0-.5.4-.9.9-.9h4.4a.9.9 0 010 1.8H7l3 2.9-1.3 1.2z" fill-rule="nonzero"/></svg>',
|
|
'gallery': '<svg width="24" height="24"><path fill-rule="nonzero" d="M5 15.7l2.3-2.2c.3-.3.7-.3 1 0L11 16l5.1-5c.3-.4.8-.4 1 0l2 1.9V8H5v7.7zM5 18V19h3l1.8-1.9-2-2L5 17.9zm14-3l-2.5-2.4-6.4 6.5H19v-4zM4 6h16c.6 0 1 .4 1 1v13c0 .6-.4 1-1 1H4a1 1 0 01-1-1V7c0-.6.4-1 1-1zm6 7a2 2 0 110-4 2 2 0 010 4zM4.5 4h15a.5.5 0 110 1h-15a.5.5 0 010-1zm2-2h11a.5.5 0 110 1h-11a.5.5 0 010-1z"/></svg>',
|
|
'gamma': '<svg width="24" height="24"><path d="M4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 01-1-1V4c0-.6.4-1 1-1zm1 2v14h14V5H5zm6.5 11.8V14L9.2 8.7a5.1 5.1 0 00-.4-.8l-.1-.2H8 8v-1l.3-.1.3-.1h.7a1 1 0 01.6.5l.1.3a8.5 8.5 0 01.3.6l1.9 4.6 2-5.2a1 1 0 011-.6.5.5 0 01.5.6L13 14v2.8a.7.7 0 01-1.4 0z" fill-rule="nonzero"/></svg>',
|
|
'help': '<svg width="24" height="24"><g fill-rule="evenodd"><path d="M12 5.5a6.5 6.5 0 00-6 9 6.3 6.3 0 001.4 2l1 1a6.3 6.3 0 003.6 1 6.5 6.5 0 006-9 6.3 6.3 0 00-1.4-2l-1-1a6.3 6.3 0 00-3.6-1zM12 4a7.8 7.8 0 015.7 2.3A8 8 0 1112 4z"/><path d="M9.6 9.7a.7.7 0 01-.7-.8c0-1.1 1.5-1.8 3.2-1.8 1.8 0 3.2.8 3.2 2.4 0 1.4-.4 2.1-1.5 2.8-.2 0-.3.1-.3.2a2 2 0 00-.8.8.8.8 0 01-1.4-.6c.3-.7.8-1 1.3-1.5l.4-.2c.7-.4.8-.6.8-1.5 0-.5-.6-.9-1.7-.9-.5 0-1 .1-1.4.3-.2 0-.3.1-.3.2v-.2c0 .4-.4.8-.8.8z" fill-rule="nonzero"/><circle cx="12" cy="16" r="1"/></g></svg>',
|
|
'highlight-bg-color': '<svg width="24" height="24"><g fill-rule="evenodd"><path id="tox-icon-highlight-bg-color__color" d="M3 18h18v3H3z"/><path fill-rule="nonzero" d="M7.7 16.7H3l3.3-3.3-.7-.8L10.2 8l4 4.1-4 4.2c-.2.2-.6.2-.8 0l-.6-.7-1.1 1.1zm5-7.5L11 7.4l3-2.9a2 2 0 012.6 0L18 6c.7.7.7 2 0 2.7l-2.9 2.9-1.8-1.8-.5-.6"/></g></svg>',
|
|
'home': '<svg width="24" height="24"><path fill-rule="nonzero" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>',
|
|
'horizontal-rule': '<svg width="24" height="24"><path d="M4 11h16v2H4z" fill-rule="evenodd"/></svg>',
|
|
'image-options': '<svg width="24" height="24"><path d="M6 10a2 2 0 00-2 2c0 1.1.9 2 2 2a2 2 0 002-2 2 2 0 00-2-2zm12 0a2 2 0 00-2 2c0 1.1.9 2 2 2a2 2 0 002-2 2 2 0 00-2-2zm-6 0a2 2 0 00-2 2c0 1.1.9 2 2 2a2 2 0 002-2 2 2 0 00-2-2z" fill-rule="nonzero"/></svg>',
|
|
'image': '<svg width="24" height="24"><path d="M5 15.7l3.3-3.2c.3-.3.7-.3 1 0L12 15l4.1-4c.3-.4.8-.4 1 0l2 1.9V5H5v10.7zM5 18V19h3l2.8-2.9-2-2L5 17.9zm14-3l-2.5-2.4-6.4 6.5H19v-4zM4 3h16c.6 0 1 .4 1 1v16c0 .6-.4 1-1 1H4a1 1 0 01-1-1V4c0-.6.4-1 1-1zm6 8a2 2 0 100-4 2 2 0 000 4z" fill-rule="nonzero"/></svg>',
|
|
'indent': '<svg width="24" height="24"><path d="M7 5h12c.6 0 1 .4 1 1s-.4 1-1 1H7a1 1 0 110-2zm5 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 010-2zm0 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 010-2zm-5 4h12a1 1 0 010 2H7a1 1 0 010-2zm-2.6-3.8L6.2 12l-1.8-1.2a1 1 0 011.2-1.6l3 2a1 1 0 010 1.6l-3 2a1 1 0 11-1.2-1.6z" fill-rule="evenodd"/></svg>',
|
|
'info': '<svg width="24" height="24"><path d="M12 4a7.8 7.8 0 015.7 2.3A8 8 0 1112 4zm-1 3v2h2V7h-2zm3 10v-1h-1v-5h-3v1h1v4h-1v1h4z" fill-rule="evenodd"/></svg>',
|
|
'insert-character': '<svg width="24" height="24"><path d="M15 18h4l1-2v4h-6v-3.3l1.4-1a6 6 0 001.8-2.9 6.3 6.3 0 00-.1-4.1 5.8 5.8 0 00-3-3.2c-.6-.3-1.3-.5-2.1-.5a5.1 5.1 0 00-3.9 1.8 6.3 6.3 0 00-1.3 6 6.2 6.2 0 001.8 3l1.4.9V20H4v-4l1 2h4v-.5l-2-1L5.4 15A6.5 6.5 0 014 11c0-1 .2-1.9.6-2.7A7 7 0 016.3 6C7.1 5.4 8 5 9 4.5c1-.3 2-.5 3.1-.5a8.8 8.8 0 015.7 2 7 7 0 011.7 2.3 6 6 0 01.2 4.8c-.2.7-.6 1.3-1 1.9a7.6 7.6 0 01-3.6 2.5v.5z" fill-rule="evenodd"/></svg>',
|
|
'insert-time': '<svg width="24" height="24"><g fill-rule="nonzero"><path d="M12 19a7 7 0 100-14 7 7 0 000 14zm0 2a9 9 0 110-18 9 9 0 010 18z"/><path d="M16 12h-3V7c0-.6-.4-1-1-1a1 1 0 00-1 1v7h5c.6 0 1-.4 1-1s-.4-1-1-1z"/></g></svg>',
|
|
'invert': '<svg width="24" height="24"><path d="M18 19.3L16.5 18a5.8 5.8 0 01-3.1 1.9 6.1 6.1 0 01-5.5-1.6A5.8 5.8 0 016 14v-.3l.1-1.2A13.9 13.9 0 017.7 9l-3-3 .7-.8 2.8 2.9 9 8.9 1.5 1.6-.7.6zm0-5.5v.3l-.1 1.1-.4 1-1.2-1.2a4.3 4.3 0 00.2-1v-.2c0-.4 0-.8-.2-1.3l-.5-1.4a14.8 14.8 0 00-3-4.2L12 6a26.1 26.1 0 00-2.2 2.5l-1-1a20.9 20.9 0 012.9-3.3L12 4l1 .8a22.2 22.2 0 014 5.4c.6 1.2 1 2.4 1 3.6z" fill-rule="evenodd"/></svg>',
|
|
'italic': '<svg width="24" height="24"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8z" fill-rule="evenodd"/></svg>',
|
|
'language': '<svg width="24" height="24"><path d="M12 3a9 9 0 110 18 9 9 0 010-18zm4.3 13.3c-.5 1-1.2 2-2 2.9a7.5 7.5 0 003.2-2.1l-.2-.2a6 6 0 00-1-.6zm-8.6 0c-.5.2-.9.5-1.2.8.9 1 2 1.7 3.2 2a10 10 0 01-2-2.8zm3.6-.8c-.8 0-1.6.1-2.2.3.5 1 1.2 1.9 2.1 2.7zm1.5 0v3c.9-.8 1.6-1.7 2.1-2.7-.6-.2-1.4-.3-2.1-.3zm-6-2.7H4.5c.2 1 .5 2.1 1 3h.3l1.3-1a10 10 0 01-.3-2zm12.7 0h-2.3c0 .7-.1 1.4-.3 2l1.6 1.1c.5-1 .9-2 1-3.1zm-3.8 0h-3V14c1 0 2 .1 2.7.4.2-.5.3-1 .3-1.6zm-4.4 0h-3l.3 1.6c.8-.3 1.7-.4 2.7-.4v-1.3zm-5.5-5c-.7 1-1.1 2.2-1.3 3.5h2.3c0-1 .2-1.8.5-2.6l-1.5-1zm2.9 1.4v.1c-.2.6-.4 1.3-.4 2h3V9.4c-1 0-1.8-.1-2.6-.3zm6.6 0h-.1l-2.4.3v1.8h3l-.5-2.1zm3-1.4l-.3.1-1.3.8c.3.8.5 1.6.5 2.6h2.3a7.5 7.5 0 00-1.3-3.5zm-9 0l2 .2V5.5a9 9 0 00-2 2.2zm3.5-2.3V8c.6 0 1.3 0 1.9-.2a9 9 0 00-2-2.3zm-3-.7h-.1c-1.1.4-2.1 1-3 1.8l1.2.7a10 10 0 011.9-2.5zm4.4 0l.1.1a10 10 0 011.8 2.4l1.1-.7a7.5 7.5 0 00-3-1.8z"/></svg>',
|
|
'line-height': '<svg width="24" height="24"><path d="M21 5a1 1 0 01.1 2H13a1 1 0 01-.1-2H21zm0 4a1 1 0 01.1 2H13a1 1 0 01-.1-2H21zm0 4a1 1 0 01.1 2H13a1 1 0 01-.1-2H21zm0 4a1 1 0 01.1 2H13a1 1 0 01-.1-2H21zM7 3.6l3.7 3.7a1 1 0 01-1.3 1.5h-.1L8 7.3v9.2l1.3-1.3a1 1 0 011.3 0h.1c.4.4.4 1 0 1.3v.1L7 20.4l-3.7-3.7a1 1 0 011.3-1.5h.1L6 16.7V7.4L4.7 8.7a1 1 0 01-1.3 0h-.1a1 1 0 010-1.3v-.1L7 3.6z"/></svg>',
|
|
'line': '<svg width="24" height="24"><path d="M15 9l-8 8H4v-3l8-8 3 3zm1-1l-3-3 1-1h1c-.2 0 0 0 0 0l2 2s0 .2 0 0v1l-1 1zM4 18h16v2H4v-2z" fill-rule="evenodd"/></svg>',
|
|
'link': '<svg width="24" height="24"><path d="M6.2 12.3a1 1 0 011.4 1.4l-2.1 2a2 2 0 102.7 2.8l4.8-4.8a1 1 0 000-1.4 1 1 0 111.4-1.3 2.9 2.9 0 010 4L9.6 20a3.9 3.9 0 01-5.5-5.5l2-2zm11.6-.6a1 1 0 01-1.4-1.4l2-2a2 2 0 10-2.6-2.8L11 10.3a1 1 0 000 1.4A1 1 0 119.6 13a2.9 2.9 0 010-4L14.4 4a3.9 3.9 0 015.5 5.5l-2 2z" fill-rule="nonzero"/></svg>',
|
|
'list-bull-circle': '<svg width="48" height="48"><g fill-rule="evenodd"><path d="M11 16a2 2 0 100-4 2 2 0 000 4zm0 1a3 3 0 110-6 3 3 0 010 6zM11 26a2 2 0 100-4 2 2 0 000 4zm0 1a3 3 0 110-6 3 3 0 010 6zM11 36a2 2 0 100-4 2 2 0 000 4zm0 1a3 3 0 110-6 3 3 0 010 6z" fill-rule="nonzero"/><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/></g></svg>',
|
|
'list-bull-default': '<svg width="48" height="48"><g fill-rule="evenodd"><circle cx="11" cy="14" r="3"/><circle cx="11" cy="24" r="3"/><circle cx="11" cy="34" r="3"/><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/></g></svg>',
|
|
'list-bull-square': '<svg width="48" height="48"><g fill-rule="evenodd"><path d="M8 11h6v6H8zM8 21h6v6H8zM8 31h6v6H8z"/><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/></g></svg>',
|
|
'list-num-default-rtl': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M37.4 17v-4.8l-1.6 1v-1.1l1.6-1h1.2V17zM33.3 17.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm1.7 5.7c0-1.2 1-2 2.2-2 1.3 0 2.1.8 2.1 1.8 0 .7-.3 1.2-1.3 2.2l-1.2 1v.2h2.6v1h-4.3v-.9l2-1.9c.8-.8 1-1.1 1-1.5 0-.5-.4-.8-1-.8-.5 0-.9.3-.9.9H35zm-1.7 4.3c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm3.2 7.3v-1h.7c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7s-1 .3-1 .8H35c0-1.1 1-1.8 2.2-1.8 1.2 0 2.1.6 2.1 1.6 0 .7-.4 1.2-1 1.3v.1c.7.1 1.3.7 1.3 1.4 0 1-1 1.9-2.4 1.9-1.3 0-2.2-.8-2.3-2h1.2c0 .6.5 1 1.1 1 .6 0 1-.4 1-1 0-.5-.3-.8-1-.8h-.7zm-3.3 2.7c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7z"/></g></svg>',
|
|
'list-num-default': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M10 17v-4.8l-1.5 1v-1.1l1.6-1h1.2V17h-1.2zm3.6.1c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7zm-5 5.7c0-1.2.8-2 2.1-2s2.1.8 2.1 1.8c0 .7-.3 1.2-1.4 2.2l-1.1 1v.2h2.6v1H8.6v-.9l2-1.9c.8-.8 1-1.1 1-1.5 0-.5-.4-.8-1-.8-.5 0-.9.3-.9.9H8.5zm6.3 4.3c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zM10 34.4v-1h.7c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7s-1 .3-1 .8H8.6c0-1.1 1-1.8 2.2-1.8 1.3 0 2.1.6 2.1 1.6 0 .7-.4 1.2-1 1.3v.1c.8.1 1.3.7 1.3 1.4 0 1-1 1.9-2.4 1.9-1.3 0-2.2-.8-2.3-2h1.2c0 .6.5 1 1.1 1 .7 0 1-.4 1-1 0-.5-.3-.8-1-.8h-.7zm4.7 2.7c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7z"/></g></svg>',
|
|
'list-num-lower-alpha-rtl': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M36.5 16c-.9 0-1.5-.5-1.5-1.3s.6-1.3 1.8-1.4h1v-.4c0-.4-.2-.6-.7-.6-.4 0-.7.1-.8.4h-1.1c0-.8.8-1.4 2-1.4S39 12 39 13V16h-1.2v-.6c-.3.4-.8.7-1.4.7zm.4-.8c.6 0 1-.4 1-.9V14h-1c-.5.1-.7.3-.7.6 0 .4.3.6.7.6zM33.1 16.1c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7zM37.7 26c-.7 0-1.2-.2-1.5-.7v.7H35v-6.3h1.2v2.5c.3-.5.8-.9 1.5-.9 1.1 0 1.8 1 1.8 2.4 0 1.5-.7 2.4-1.8 2.4zm-.5-3.6c-.6 0-1 .5-1 1.3s.4 1.4 1 1.4c.7 0 1-.6 1-1.4 0-.8-.3-1.3-1-1.3zM33.2 26.1c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7zm6 7h-1c-.1-.5-.4-.8-1-.8s-1 .5-1 1.4c0 1 .4 1.4 1 1.4.5 0 .9-.2 1-.7h1c0 1-.8 1.7-2 1.7-1.4 0-2.2-.9-2.2-2.4s.8-2.4 2.2-2.4c1.2 0 2 .7 2 1.7zm-6.1 3c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7z"/></g></svg>',
|
|
'list-num-lower-alpha': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M10.3 15.2c.5 0 1-.4 1-.9V14h-1c-.5.1-.8.3-.8.6 0 .4.3.6.8.6zm-.4.9c-1 0-1.5-.6-1.5-1.4 0-.8.6-1.3 1.7-1.4h1.1v-.4c0-.4-.2-.6-.7-.6-.5 0-.8.1-.9.4h-1c0-.8.8-1.4 2-1.4 1.1 0 1.8.6 1.8 1.6V16h-1.1v-.6h-.1c-.2.4-.7.7-1.3.7zm4.6 0c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm-3.2 10c-.6 0-1.2-.3-1.4-.8v.7H8.5v-6.3H10v2.5c.3-.5.8-.9 1.4-.9 1.2 0 1.9 1 1.9 2.4 0 1.5-.7 2.4-1.9 2.4zm-.4-3.7c-.7 0-1 .5-1 1.3s.3 1.4 1 1.4c.6 0 1-.6 1-1.4 0-.8-.4-1.3-1-1.3zm4 3.7c-.5 0-.7-.3-.7-.7 0-.4.2-.7.7-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm-2.2 7h-1.2c0-.5-.4-.8-.9-.8-.6 0-1 .5-1 1.4 0 1 .4 1.4 1 1.4.5 0 .8-.2 1-.7h1c0 1-.8 1.7-2 1.7-1.4 0-2.2-.9-2.2-2.4s.8-2.4 2.2-2.4c1.2 0 2 .7 2 1.7zm1.8 3c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7z"/></g></svg>',
|
|
'list-num-lower-greek-rtl': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M37.4 16c-1.2 0-2-.8-2-2.3 0-1.5.8-2.4 2-2.4.6 0 1 .4 1.3 1v-.9H40v3.2c0 .4.1.5.4.5h.2v.9h-.6c-.6 0-1-.2-1-.7h-.2c-.2.4-.7.8-1.3.8zm.3-1c.6 0 1-.5 1-1.3s-.4-1.3-1-1.3-1 .5-1 1.3.4 1.4 1 1.4zM33.3 16.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zM36 21.9c0-1.5.8-2.3 2.1-2.3 1.2 0 2 .6 2 1.6 0 .6-.3 1-.9 1.3.9.3 1.3.8 1.3 1.7 0 1.2-.7 1.9-1.8 1.9-.6 0-1.1-.3-1.4-.8v2.2H36V22zm1.8 1.2v-1h.3c.5 0 .9-.2.9-.7 0-.5-.3-.8-.9-.8-.5 0-.8.3-.8 1v2.2c0 .8.4 1.3 1 1.3s1-.4 1-1-.4-1-1.2-1h-.3zM33.3 26.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zM37.1 34.6L34.8 30h1.4l1.7 3.5 1.7-3.5h1.1l-2.2 4.6v.1c.5.8.7 1.4.7 1.8 0 .4-.2.8-.4 1-.2.2-.6.3-1 .3-.9 0-1.3-.4-1.3-1.2 0-.5.2-1 .5-1.7l.1-.2zm.7 1a2 2 0 00-.4.9c0 .3.1.4.4.4.3 0 .4-.1.4-.4 0-.2-.1-.6-.4-1zM33.3 36.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7z"/></g></svg>',
|
|
'list-num-lower-greek': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M10.5 15c.7 0 1-.5 1-1.3s-.3-1.3-1-1.3c-.5 0-.9.5-.9 1.3s.4 1.4 1 1.4zm-.3 1c-1.1 0-1.8-.8-1.8-2.3 0-1.5.7-2.4 1.8-2.4.7 0 1.1.4 1.3 1h.1v-.9h1.2v3.2c0 .4.1.5.4.5h.2v.9h-.6c-.6 0-1-.2-1.1-.7h-.1c-.2.4-.7.8-1.4.8zm5 .1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.7-.7.5 0 .8.3.8.7 0 .4-.3.7-.8.7zm-4.9 7v-1h.3c.6 0 1-.2 1-.7 0-.5-.4-.8-1-.8-.5 0-.8.3-.8 1v2.2c0 .8.4 1.3 1.1 1.3.6 0 1-.4 1-1s-.5-1-1.3-1h-.3zM8.6 22c0-1.5.7-2.3 2-2.3 1.2 0 2 .6 2 1.6 0 .6-.3 1-.8 1.3.8.3 1.3.8 1.3 1.7 0 1.2-.8 1.9-1.9 1.9-.6 0-1.1-.3-1.3-.8v2.2H8.5V22zm6.2 4.2c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7zm-4.5 8.5L8 30h1.4l1.7 3.5 1.7-3.5h1.1l-2.2 4.6v.1c.5.8.7 1.4.7 1.8 0 .4-.1.8-.4 1-.2.2-.6.3-1 .3-.9 0-1.3-.4-1.3-1.2 0-.5.2-1 .5-1.7l.1-.2zm.7 1a2 2 0 00-.4.9c0 .3.1.4.4.4.3 0 .4-.1.4-.4 0-.2-.1-.6-.4-1zm4.5.5c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7z"/></g></svg>',
|
|
'list-num-lower-roman-rtl': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M32.9 16v-1.2h-1.3V16H33zm0 10v-1.2h-1.3V26H33zm0 10v-1.2h-1.3V36H33z"/><path fill-rule="nonzero" d="M36 21h-1.5v5H36zM36 31h-1.5v5H36zM39 21h-1.5v5H39zM39 31h-1.5v5H39zM42 31h-1.5v5H42zM36 11h-1.5v5H36zM36 19h-1.5v1H36zM36 29h-1.5v1H36zM39 19h-1.5v1H39zM39 29h-1.5v1H39zM42 29h-1.5v1H42zM36 9h-1.5v1H36z"/></g></svg>',
|
|
'list-num-lower-roman': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M15.1 16v-1.2h1.3V16H15zm0 10v-1.2h1.3V26H15zm0 10v-1.2h1.3V36H15z"/><path fill-rule="nonzero" d="M12 21h1.5v5H12zM12 31h1.5v5H12zM9 21h1.5v5H9zM9 31h1.5v5H9zM6 31h1.5v5H6zM12 11h1.5v5H12zM12 19h1.5v1H12zM12 29h1.5v1H12zM9 19h1.5v1H9zM9 29h1.5v1H9zM6 29h1.5v1H6zM12 9h1.5v1H12z"/></g></svg>',
|
|
'list-num-upper-alpha-rtl': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M39.3 17l-.5-1.4h-2l-.5 1.4H35l2-6h1.6l2 6h-1.3zm-1.6-4.7l-.7 2.3h1.6l-.8-2.3zM33.4 17c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7zm4.7 9.9h-2.7v-6H38c1.2 0 1.9.6 1.9 1.5 0 .6-.5 1.2-1 1.3.7.1 1.3.7 1.3 1.5 0 1-.8 1.7-2 1.7zm-1.4-5v1.5h1c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7h-1zm0 4h1.1c.7 0 1.1-.3 1.1-.8 0-.6-.4-.9-1.1-.9h-1.1V26zM33 27.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm4.9 10c-1.8 0-2.8-1.1-2.8-3.1s1-3.1 2.8-3.1c1.4 0 2.5.9 2.6 2.2h-1.3c0-.7-.6-1.1-1.3-1.1-1 0-1.6.7-1.6 2s.6 2 1.6 2c.7 0 1.2-.4 1.4-1h1.2c-.1 1.3-1.2 2.2-2.6 2.2zm-4.5 0c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7z"/></g></svg>',
|
|
'list-num-upper-alpha': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M12.6 17l-.5-1.4h-2L9.5 17H8.3l2-6H12l2 6h-1.3zM11 12.3l-.7 2.3h1.6l-.8-2.3zm4.7 4.8c-.4 0-.7-.3-.7-.7 0-.4.3-.7.7-.7.5 0 .7.3.7.7 0 .4-.2.7-.7.7zM11.4 27H8.7v-6h2.6c1.2 0 1.9.6 1.9 1.5 0 .6-.5 1.2-1 1.3.7.1 1.3.7 1.3 1.5 0 1-.8 1.7-2 1.7zM10 22v1.5h1c.6 0 1-.3 1-.8 0-.4-.4-.7-1-.7h-1zm0 4H11c.7 0 1.1-.3 1.1-.8 0-.6-.4-.9-1.1-.9H10V26zm5.4 1.1c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7zm-4.1 10c-1.8 0-2.8-1.1-2.8-3.1s1-3.1 2.8-3.1c1.4 0 2.5.9 2.6 2.2h-1.3c0-.7-.6-1.1-1.3-1.1-1 0-1.6.7-1.6 2s.6 2 1.6 2c.7 0 1.2-.4 1.4-1h1.2c-.1 1.3-1.2 2.2-2.6 2.2zm4.5 0c-.5 0-.8-.3-.8-.7 0-.4.3-.7.8-.7.4 0 .7.3.7.7 0 .4-.3.7-.7.7z"/></g></svg>',
|
|
'list-num-upper-roman-rtl': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M8 12h22v4H8zM8 22h22v4H8zM8 32h22v4H8z"/><path d="M31.6 17v-1.2H33V17h-1.3zm0 10v-1.2H33V27h-1.3zm0 10v-1.2H33V37h-1.3z"/><path fill-rule="nonzero" d="M34.5 20H36v7h-1.5zM34.5 30H36v7h-1.5zM37.5 20H39v7h-1.5zM37.5 30H39v7h-1.5zM40.5 30H42v7h-1.5zM34.5 10H36v7h-1.5z"/></g></svg>',
|
|
'list-num-upper-roman': '<svg width="48" height="48"><g fill-rule="evenodd"><path opacity=".2" d="M18 12h22v4H18zM18 22h22v4H18zM18 32h22v4H18z"/><path d="M15.1 17v-1.2h1.3V17H15zm0 10v-1.2h1.3V27H15zm0 10v-1.2h1.3V37H15z"/><path fill-rule="nonzero" d="M12 20h1.5v7H12zM12 30h1.5v7H12zM9 20h1.5v7H9zM9 30h1.5v7H9zM6 30h1.5v7H6zM12 10h1.5v7H12z"/></g></svg>',
|
|
'lock': '<svg width="24" height="24"><path d="M16.3 11c.2 0 .3 0 .5.2l.2.6v7.4c0 .3 0 .4-.2.6l-.6.2H7.8c-.3 0-.4 0-.6-.2a.7.7 0 01-.2-.6v-7.4c0-.3 0-.4.2-.6l.5-.2H8V8c0-.8.3-1.5.9-2.1.6-.6 1.3-.9 2.1-.9h2c.8 0 1.5.3 2.1.9.6.6.9 1.3.9 2.1v3h.3zM10 8v3h4V8a1 1 0 00-.3-.7A1 1 0 0013 7h-2a1 1 0 00-.7.3 1 1 0 00-.3.7z" fill-rule="evenodd"/></svg>',
|
|
'ltr': '<svg width="24" height="24"><path d="M11 5h7a1 1 0 010 2h-1v11a1 1 0 01-2 0V7h-2v11a1 1 0 01-2 0v-6c-.5 0-1 0-1.4-.3A3.4 3.4 0 017.8 10a3.3 3.3 0 010-2.8 3.4 3.4 0 011.8-1.8L11 5zM4.4 16.2L6.2 15l-1.8-1.2a1 1 0 011.2-1.6l3 2a1 1 0 010 1.6l-3 2a1 1 0 11-1.2-1.6z" fill-rule="evenodd"/></svg>',
|
|
'more-drawer': '<svg width="24" height="24"><path d="M6 10a2 2 0 00-2 2c0 1.1.9 2 2 2a2 2 0 002-2 2 2 0 00-2-2zm12 0a2 2 0 00-2 2c0 1.1.9 2 2 2a2 2 0 002-2 2 2 0 00-2-2zm-6 0a2 2 0 00-2 2c0 1.1.9 2 2 2a2 2 0 002-2 2 2 0 00-2-2z" fill-rule="nonzero"/></svg>',
|
|
'new-document': '<svg width="24" height="24"><path d="M14.4 3H7a2 2 0 00-2 2v14c0 1.1.9 2 2 2h10a2 2 0 002-2V7.6L14.4 3zM17 19H7V5h6v4h4v10z" fill-rule="nonzero"/></svg>',
|
|
'new-tab': '<svg width="24" height="24"><path d="M15 13l2-2v8H5V7h8l-2 2H7v8h8v-4zm4-8v5.5l-2-2-5.6 5.5H10v-1.4L15.5 7l-2-2H19z" fill-rule="evenodd"/></svg>',
|
|
'non-breaking': '<svg width="24" height="24"><path d="M11 11H8a1 1 0 110-2h3V6c0-.6.4-1 1-1s1 .4 1 1v3h3c.6 0 1 .4 1 1s-.4 1-1 1h-3v3c0 .6-.4 1-1 1a1 1 0 01-1-1v-3zm10 4v5H3v-5c0-.6.4-1 1-1s1 .4 1 1v3h14v-3c0-.6.4-1 1-1s1 .4 1 1z" fill-rule="evenodd"/></svg>',
|
|
'notice': '<svg width="24" height="24"><path d="M17.8 9.8L15.4 4 20 8.5v7L15.5 20h-7L4 15.5v-7L8.5 4h7l2.3 5.8zm0 0l2.2 5.7-2.3-5.8zM13 17v-2h-2v2h2zm0-4V7h-2v6h2z" fill-rule="evenodd"/></svg>',
|
|
'ordered-list-rtl': '<svg width="24" height="24"><path d="M6 17h8a1 1 0 010 2H6a1 1 0 010-2zm0-6h8a1 1 0 010 2H6a1 1 0 010-2zm0-6h8a1 1 0 010 2H6a1 1 0 110-2zm13-1v3.5a.5.5 0 11-1 0V5h-.5a.5.5 0 110-1H19zm-1 8.8l.2.2h1.3a.5.5 0 110 1h-1.6a1 1 0 01-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 00-.2-.2h-1.3a.5.5 0 01-.5-.5c0-.3.2-.5.5-.5h1.6c.5 0 .9.4.9 1v.1c0 .4-.3.8-.6 1l-1.2.4-.2.3zm2 4.2v2c0 .6-.4 1-1 1h-1.5a.5.5 0 010-1h1.2a.3.3 0 100-.6h-1.3a.4.4 0 110-.8h1.3a.3.3 0 000-.6h-1.2a.5.5 0 110-1H19c.6 0 1 .4 1 1z" fill-rule="evenodd"/></svg>',
|
|
'ordered-list': '<svg width="24" height="24"><path d="M10 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 110-2zM6 4v3.5c0 .3-.2.5-.5.5a.5.5 0 01-.5-.5V5h-.5a.5.5 0 010-1H6zm-1 8.8l.2.2h1.3c.3 0 .5.2.5.5s-.2.5-.5.5H4.9a1 1 0 01-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 00-.2-.2H4.5a.5.5 0 01-.5-.5c0-.3.2-.5.5-.5h1.6c.5 0 .9.4.9 1v.1c0 .4-.3.8-.6 1l-1.2.4-.2.3zM7 17v2c0 .6-.4 1-1 1H4.5a.5.5 0 010-1h1.2c.2 0 .3-.1.3-.3 0-.2-.1-.3-.3-.3H4.4a.4.4 0 110-.8h1.3c.2 0 .3-.1.3-.3 0-.2-.1-.3-.3-.3H4.5a.5.5 0 110-1H6c.6 0 1 .4 1 1z" fill-rule="evenodd"/></svg>',
|
|
'orientation': '<svg width="24" height="24"><path d="M7.3 6.4L1 13l6.4 6.5 6.5-6.5-6.5-6.5zM3.7 13l3.6-3.7L11 13l-3.7 3.7-3.6-3.7zM12 6l2.8 2.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0L9.2 5.7a.8.8 0 010-1.2L13.6.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L12 4h1a9 9 0 11-4.3 16.9l1.5-1.5A7 7 0 1013 6h-1z" fill-rule="nonzero"/></svg>',
|
|
'outdent': '<svg width="24" height="24"><path d="M7 5h12c.6 0 1 .4 1 1s-.4 1-1 1H7a1 1 0 110-2zm5 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 010-2zm0 4h7c.6 0 1 .4 1 1s-.4 1-1 1h-7a1 1 0 010-2zm-5 4h12a1 1 0 010 2H7a1 1 0 010-2zm1.6-3.8a1 1 0 01-1.2 1.6l-3-2a1 1 0 010-1.6l3-2a1 1 0 011.2 1.6L6.8 12l1.8 1.2z" fill-rule="evenodd"/></svg>',
|
|
'page-break': '<svg width="24" height="24"><g fill-rule="evenodd"><path d="M5 11c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 010-2zm3 0h1c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 010-2zm4 0c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 010-2zm3 0h1c.6 0 1 .4 1 1s-.4 1-1 1h-1a1 1 0 010-2zm4 0c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 010-2zM7 3v5h10V3c0-.6.4-1 1-1s1 .4 1 1v7H5V3c0-.6.4-1 1-1s1 .4 1 1zM6 22a1 1 0 01-1-1v-7h14v7c0 .6-.4 1-1 1a1 1 0 01-1-1v-5H7v5c0 .6-.4 1-1 1z"/></g></svg>',
|
|
'paragraph': '<svg width="24" height="24"><path fill-rule="evenodd" d="M10 5h7a1 1 0 010 2h-1v11a1 1 0 01-2 0V7h-2v11a1 1 0 01-2 0v-6c-.5 0-1 0-1.4-.3A3.4 3.4 0 016.8 10a3.3 3.3 0 010-2.8 3.4 3.4 0 011.8-1.8L10 5z"/></svg>',
|
|
'paste-column-after': '<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 012.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 01-1-1V5H6v13h7v2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2H9.2A3 3 0 0112 1zm8 7v12h-6V8h6zm-1.5 1.5h-3v9h3v-9zM12 3a1 1 0 100 2 1 1 0 000-2z"/></svg>',
|
|
'paste-column-before': '<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 012.8 2H18c1 0 2 .8 2 1.9V18c0 1-.8 2-1.9 2H11v-2h7V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 01-1-1V5H6v2H4V5c0-1 .8-2 1.9-2H9.2A3 3 0 0112 1zm-2 7v12H4V8h6zM8.5 9.5h-3v9h3v-9zM12 3a1 1 0 100 2 1 1 0 000-2z"/></svg>',
|
|
'paste-row-after': '<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 012.8 2H18c1 0 2 .8 2 1.9V11h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 01-1-1V5H6v13h14c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2H9.2A3 3 0 0112 1zm10 11v5H8v-5h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 100 2 1 1 0 000-2z"/></svg>',
|
|
'paste-row-before': '<svg width="24" height="24"><path fill-rule="evenodd" d="M12 1a3 3 0 012.8 2H18c1 0 2 .8 2 1.9V7h-2V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 01-1-1V5H6v13h12v-4h2v4c0 1-.8 2-1.9 2H6c-1 0-2-.8-2-1.9V5c0-1 .8-2 1.9-2H9.2A3 3 0 0112 1zm10 7v5H8V8h14zm-1.5 1.5h-11v2h11v-2zM12 3a1 1 0 100 2 1 1 0 000-2z"/></svg>',
|
|
'paste-text': '<svg width="24" height="24"><path d="M18 9V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 01-1-1V5H6v13h3V9h9zM9 20H6a2 2 0 01-2-2V5c0-1.1.9-2 2-2h3.2A3 3 0 0112 1a3 3 0 012.8 2H18a2 2 0 012 2v4h1v12H9v-1zm1.5-9.5v9h9v-9h-9zM12 3a1 1 0 00-1 1c0 .5.4 1 1 1s1-.5 1-1-.4-1-1-1zm0 9h6v2h-.5l-.5-1h-1v4h.8v1h-3.6v-1h.8v-4h-1l-.5 1H12v-2z" fill-rule="nonzero"/></svg>',
|
|
'paste': '<svg width="24" height="24"><path d="M18 9V5h-2v1c0 .6-.4 1-1 1H9a1 1 0 01-1-1V5H6v13h3V9h9zM9 20H6a2 2 0 01-2-2V5c0-1.1.9-2 2-2h3.2A3 3 0 0112 1a3 3 0 012.8 2H18a2 2 0 012 2v4h1v12H9v-1zm1.5-9.5v9h9v-9h-9zM12 3a1 1 0 00-1 1c0 .5.4 1 1 1s1-.5 1-1-.4-1-1-1z" fill-rule="nonzero"/></svg>',
|
|
'permanent-pen': '<svg width="24" height="24"><path d="M10.5 17.5L8 20H3v-3l3.5-3.5a2 2 0 010-3L14 3l1 1-7.3 7.3a1 1 0 000 1.4l3.6 3.6c.4.4 1 .4 1.4 0L20 9l1 1-7.6 7.6a2 2 0 01-2.8 0l-.1-.1z" fill-rule="nonzero"/></svg>',
|
|
'plus': '<svg width="24" height="24"><path d="M12 4c.5 0 1 .4 1 .9V11h6a1 1 0 01.1 2H13v6a1 1 0 01-2 .1V13H5a1 1 0 01-.1-2H11V5c0-.6.4-1 1-1z"/></svg>',
|
|
'preferences': '<svg width="24" height="24"><path d="M20.1 13.5l-1.9.2a5.8 5.8 0 01-.6 1.5l1.2 1.5c.4.4.3 1 0 1.4l-.7.7a1 1 0 01-1.4 0l-1.5-1.2a6.2 6.2 0 01-1.5.6l-.2 1.9c0 .5-.5.9-1 .9h-1a1 1 0 01-1-.9l-.2-1.9a5.8 5.8 0 01-1.5-.6l-1.5 1.2a1 1 0 01-1.4 0l-.7-.7a1 1 0 010-1.4l1.2-1.5a6.2 6.2 0 01-.6-1.5l-1.9-.2a1 1 0 01-.9-1v-1c0-.5.4-1 .9-1l1.9-.2a5.8 5.8 0 01.6-1.5L5.2 7.3a1 1 0 010-1.4l.7-.7a1 1 0 011.4 0l1.5 1.2a6.2 6.2 0 011.5-.6l.2-1.9c0-.5.5-.9 1-.9h1c.5 0 1 .4 1 .9l.2 1.9a5.8 5.8 0 011.5.6l1.5-1.2a1 1 0 011.4 0l.7.7c.3.4.4 1 0 1.4l-1.2 1.5a6.2 6.2 0 01.6 1.5l1.9.2c.5 0 .9.5.9 1v1c0 .5-.4 1-.9 1zM12 15a3 3 0 100-6 3 3 0 000 6z" fill-rule="evenodd"/></svg>',
|
|
'preview': '<svg width="24" height="24"><path d="M3.5 12.5c.5.8 1.1 1.6 1.8 2.3 2 2 4.2 3.2 6.7 3.2s4.7-1.2 6.7-3.2a16.2 16.2 0 002.1-2.8 15.7 15.7 0 00-2.1-2.8c-2-2-4.2-3.2-6.7-3.2a9.3 9.3 0 00-6.7 3.2A16.2 16.2 0 003.2 12c0 .2.2.3.3.5zm-2.4-1l.7-1.2L4 7.8C6.2 5.4 8.9 4 12 4c3 0 5.8 1.4 8.1 3.8a18.2 18.2 0 012.8 3.7v1l-.7 1.2-2.1 2.5c-2.3 2.4-5 3.8-8.1 3.8-3 0-5.8-1.4-8.1-3.8a18.2 18.2 0 01-2.8-3.7 1 1 0 010-1zm12-3.3a2 2 0 102.7 2.6 4 4 0 11-2.6-2.6z" fill-rule="nonzero"/></svg>',
|
|
'print': '<svg width="24" height="24"><path d="M18 8H6a3 3 0 00-3 3v6h2v3h14v-3h2v-6a3 3 0 00-3-3zm-1 10H7v-4h10v4zm.5-5c-.8 0-1.5-.7-1.5-1.5s.7-1.5 1.5-1.5 1.5.7 1.5 1.5-.7 1.5-1.5 1.5zm.5-8H6v2h12V5z" fill-rule="nonzero"/></svg>',
|
|
'quote': '<svg width="24" height="24"><path d="M7.5 17h.9c.4 0 .7-.2.9-.6L11 13V8c0-.6-.4-1-1-1H6a1 1 0 00-1 1v4c0 .6.4 1 1 1h2l-1.3 2.7a1 1 0 00.8 1.3zm8 0h.9c.4 0 .7-.2.9-.6L19 13V8c0-.6-.4-1-1-1h-4a1 1 0 00-1 1v4c0 .6.4 1 1 1h2l-1.3 2.7a1 1 0 00.8 1.3z" fill-rule="nonzero"/></svg>',
|
|
'redo': '<svg width="24" height="24"><path d="M17.6 10H12c-2.8 0-4.4 1.4-4.9 3.5-.4 2 .3 4 1.4 4.6a1 1 0 11-1 1.8c-2-1.2-2.9-4.1-2.3-6.8.6-3 3-5.1 6.8-5.1h5.6l-3.3-3.3a1 1 0 111.4-1.4l5 5a1 1 0 010 1.4l-5 5a1 1 0 01-1.4-1.4l3.3-3.3z" fill-rule="nonzero"/></svg>',
|
|
'reload': '<svg width="24" height="24"><g fill-rule="nonzero"><path d="M5 22.1l-1.2-4.7v-.2a1 1 0 011-1l5 .4a1 1 0 11-.2 2l-2.2-.2a7.8 7.8 0 008.4.2 7.5 7.5 0 003.5-6.4 1 1 0 112 0 9.5 9.5 0 01-4.5 8 9.9 9.9 0 01-10.2 0l.4 1.4a1 1 0 11-2 .5zM13.6 7.4c0-.5.5-1 1-.9l2.8.2a8 8 0 00-9.5-1 7.5 7.5 0 00-3.6 7 1 1 0 01-2 0 9.5 9.5 0 014.5-8.6 10 10 0 0110.9.3l-.3-1a1 1 0 012-.5l1.1 4.8a1 1 0 01-1 1.2l-5-.4a1 1 0 01-.9-1z"/></g></svg>',
|
|
'remove-formatting': '<svg width="24" height="24"><path d="M13.2 6a1 1 0 010 .2l-2.6 10a1 1 0 01-1 .8h-.2a.8.8 0 01-.8-1l2.6-10H8a1 1 0 110-2h9a1 1 0 010 2h-3.8zM5 18h7a1 1 0 010 2H5a1 1 0 010-2zm13 1.5L16.5 18 15 19.5a.7.7 0 01-1-1l1.5-1.5-1.5-1.5a.7.7 0 011-1l1.5 1.5 1.5-1.5a.7.7 0 011 1L17.5 17l1.5 1.5a.7.7 0 01-1 1z" fill-rule="evenodd"/></svg>',
|
|
'remove': '<svg width="24" height="24"><path d="M16 7h3a1 1 0 010 2h-1v9a3 3 0 01-3 3H9a3 3 0 01-3-3V9H5a1 1 0 110-2h3V6a3 3 0 013-3h2a3 3 0 013 3v1zm-2 0V6c0-.6-.4-1-1-1h-2a1 1 0 00-1 1v1h4zm2 2H8v9c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V9zm-7 3a1 1 0 012 0v4a1 1 0 01-2 0v-4zm4 0a1 1 0 012 0v4a1 1 0 01-2 0v-4z" fill-rule="nonzero"/></svg>',
|
|
'resize-handle': '<svg width="10" height="10"><g fill-rule="nonzero"><path d="M8.1 1.1A.5.5 0 119 2l-7 7A.5.5 0 111 8l7-7zM8.1 5.1A.5.5 0 119 6l-3 3A.5.5 0 115 8l3-3z"/></g></svg>',
|
|
'resize': '<svg width="24" height="24"><path d="M4 5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h6c.3 0 .5.1.7.3.2.2.3.4.3.7 0 .3-.1.5-.3.7a1 1 0 01-.7.3H7.4L18 16.6V13c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3.3 0 .5.1.7.3.2.2.3.4.3.7v6c0 .3-.1.5-.3.7a1 1 0 01-.7.3h-6a1 1 0 01-.7-.3 1 1 0 01-.3-.7c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h3.6L6 7.4V11c0 .3-.1.5-.3.7a1 1 0 01-.7.3 1 1 0 01-.7-.3A1 1 0 014 11V5z" fill-rule="evenodd"/></svg>',
|
|
'restore-draft': '<svg width="24" height="24"><g fill-rule="evenodd"><path d="M17 13c0 .6-.4 1-1 1h-4V8c0-.6.4-1 1-1s1 .4 1 1v4h2c.6 0 1 .4 1 1z"/><path d="M4.7 10H9a1 1 0 010 2H3a1 1 0 01-1-1V5a1 1 0 112 0v3l2.5-2.4a9.2 9.2 0 0110.8-1.5A9 9 0 0113.4 21c-2.4.1-4.7-.7-6.5-2.2a1 1 0 111.3-1.5 7.2 7.2 0 0011.6-3.7 7 7 0 00-3.5-7.7A7.2 7.2 0 008 7L4.7 10z" fill-rule="nonzero"/></g></svg>',
|
|
'rotate-left': '<svg width="24" height="24"><path d="M4.7 10H9a1 1 0 010 2H3a1 1 0 01-1-1V5a1 1 0 112 0v3l2.5-2.4a9.2 9.2 0 0110.8-1.5A9 9 0 0113.4 21c-2.4.1-4.7-.7-6.5-2.2a1 1 0 111.3-1.5 7.2 7.2 0 0011.6-3.7 7 7 0 00-3.5-7.7A7.2 7.2 0 008 7L4.7 10z" fill-rule="nonzero"/></svg>',
|
|
'rotate-right': '<svg width="24" height="24"><path d="M20 8V5a1 1 0 012 0v6c0 .6-.4 1-1 1h-6a1 1 0 010-2h4.3L16 7A7.2 7.2 0 007.7 6a7 7 0 003 13.1c1.9.1 3.7-.5 5-1.7a1 1 0 011.4 1.5A9.2 9.2 0 012.2 14c-.9-3.9 1-8 4.5-9.9 3.5-1.9 8-1.3 10.8 1.5L20 8z" fill-rule="nonzero"/></svg>',
|
|
'rtl': '<svg width="24" height="24"><path d="M8 5h8v2h-2v12h-2V7h-2v12H8v-7c-.5 0-1 0-1.4-.3A3.4 3.4 0 014.8 10a3.3 3.3 0 010-2.8 3.4 3.4 0 011.8-1.8L8 5zm12 11.2a1 1 0 11-1 1.6l-3-2a1 1 0 010-1.6l3-2a1 1 0 111 1.6L18.4 15l1.8 1.2z" fill-rule="evenodd"/></svg>',
|
|
'save': '<svg width="24" height="24"><path d="M5 16h14a2 2 0 012 2v2a2 2 0 01-2 2H5a2 2 0 01-2-2v-2c0-1.1.9-2 2-2zm0 2v2h14v-2H5zm10 0h2v2h-2v-2zm-4-6.4L8.7 9.3a1 1 0 10-1.4 1.4l4 4c.4.4 1 .4 1.4 0l4-4a1 1 0 10-1.4-1.4L13 11.6V4a1 1 0 00-2 0v7.6z" fill-rule="nonzero"/></svg>',
|
|
'search': '<svg width="24" height="24"><path d="M16 17.3a8 8 0 111.4-1.4l4.3 4.4a1 1 0 01-1.4 1.4l-4.4-4.3zm-5-.3a6 6 0 100-12 6 6 0 000 12z" fill-rule="nonzero"/></svg>',
|
|
'select-all': '<svg width="24" height="24"><path d="M3 5h2V3a2 2 0 00-2 2zm0 8h2v-2H3v2zm4 8h2v-2H7v2zM3 9h2V7H3v2zm10-6h-2v2h2V3zm6 0v2h2a2 2 0 00-2-2zM5 21v-2H3c0 1.1.9 2 2 2zm-2-4h2v-2H3v2zM9 3H7v2h2V3zm2 18h2v-2h-2v2zm8-8h2v-2h-2v2zm0 8a2 2 0 002-2h-2v2zm0-12h2V7h-2v2zm0 8h2v-2h-2v2zm-4 4h2v-2h-2v2zm0-16h2V3h-2v2zM7 17h10V7H7v10zm2-8h6v6H9V9z" fill-rule="nonzero"/></svg>',
|
|
'selected': '<svg width="24" height="24"><path fill-rule="nonzero" d="M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6c0-1.1.9-2 2-2zm3.6 10.9L7 12.3a.7.7 0 00-1 1L9.6 17 18 8.6a.7.7 0 000-1 .7.7 0 00-1 0l-7.4 7.3z"/></svg>',
|
|
'settings': '<svg width="24" height="24"><path d="M11 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8v.3c0 .2 0 .3-.2.5l-.6.2H7.8c-.3 0-.4 0-.6-.2a.7.7 0 01-.2-.6V8H5a1 1 0 110-2h2v-.3c0-.2 0-.3.2-.5l.5-.2h2.5c.3 0 .4 0 .6.2l.2.5V6zM8 8h2V6H8v2zm9 2.8v.2h2c.6 0 1 .4 1 1s-.4 1-1 1h-2v.3c0 .2 0 .3-.2.5l-.6.2h-2.4c-.3 0-.4 0-.6-.2a.7.7 0 01-.2-.6V13H5a1 1 0 010-2h8v-.3c0-.2 0-.3.2-.5l.6-.2h2.4c.3 0 .4 0 .6.2l.2.6zM14 13h2v-2h-2v2zm-3 2.8v.2h8c.6 0 1 .4 1 1s-.4 1-1 1h-8v.3c0 .2 0 .3-.2.5l-.6.2H7.8c-.3 0-.4 0-.6-.2a.7.7 0 01-.2-.6V18H5a1 1 0 010-2h2v-.3c0-.2 0-.3.2-.5l.5-.2h2.5c.3 0 .4 0 .6.2l.2.6zM8 18h2v-2H8v2z" fill-rule="evenodd"/></svg>',
|
|
'sharpen': '<svg width="24" height="24"><path d="M16 6l4 4-8 9-8-9 4-4h8zm-4 10.2l5.5-6.2-.1-.1H12v-.3h5.1l-.2-.2H12V9h4.6l-.2-.2H12v-.3h4.1l-.2-.2H12V8h3.6l-.2-.2H8.7L6.5 10l.1.1H12v.3H6.9l.2.2H12v.3H7.3l.2.2H12v.3H7.7l.3.2h4v.3H8.2l.2.2H12v.3H8.6l.3.2H12v.3H9l.3.2H12v.3H9.5l.2.2H12v.3h-2l.2.2H12v.3h-1.6l.2.2H12v.3h-1.1l.2.2h.9v.3h-.7l.2.2h.5v.3h-.3l.3.2z" fill-rule="evenodd"/></svg>',
|
|
'sourcecode': '<svg width="24" height="24"><g fill-rule="nonzero"><path d="M9.8 15.7c.3.3.3.8 0 1-.3.4-.9.4-1.2 0l-4.4-4.1a.8.8 0 010-1.2l4.4-4.2c.3-.3.9-.3 1.2 0 .3.3.3.8 0 1.1L6 12l3.8 3.7zM14.2 15.7c-.3.3-.3.8 0 1 .4.4.9.4 1.2 0l4.4-4.1c.3-.3.3-.9 0-1.2l-4.4-4.2a.8.8 0 00-1.2 0c-.3.3-.3.8 0 1.1L18 12l-3.8 3.7z"/></g></svg>',
|
|
'spell-check': '<svg width="24" height="24"><path d="M6 8v3H5V5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h2c.3 0 .5.1.7.3.2.2.3.4.3.7v6H8V8H6zm0-3v2h2V5H6zm13 0h-3v5h3v1h-3a1 1 0 01-.7-.3 1 1 0 01-.3-.7V5c0-.3.1-.5.3-.7.2-.2.4-.3.7-.3h3v1zm-5 1.5l-.1.7c-.1.2-.3.3-.6.3.3 0 .5.1.6.3l.1.7V10c0 .3-.1.5-.3.7a1 1 0 01-.7.3h-3V4h3c.3 0 .5.1.7.3.2.2.3.4.3.7v1.5zM13 10V8h-2v2h2zm0-3V5h-2v2h2zm3 5l1 1-6.5 7L7 15.5l1.3-1 2.2 2.2L16 12z" fill-rule="evenodd"/></svg>',
|
|
'strike-through': '<svg width="24" height="24"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 017 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1z"/><path d="M5 11h14a1 1 0 010 2H5a1 1 0 010-2z" fill-rule="nonzero"/></g></svg>',
|
|
'subscript': '<svg width="24" height="24"><path d="M10.4 10l4.6 4.6-1.4 1.4L9 11.4 4.4 16 3 14.6 7.6 10 3 5.4 4.4 4 9 8.6 13.6 4 15 5.4 10.4 10zM21 19h-5v-1l1-.8 1.7-1.6c.3-.4.5-.8.5-1.2 0-.3 0-.6-.2-.7-.2-.2-.5-.3-.9-.3a2 2 0 00-.8.2l-.7.3-.4-1.1 1-.6 1.2-.2c.8 0 1.4.3 1.8.7.4.4.6.9.6 1.5s-.2 1.1-.5 1.6a8 8 0 01-1.3 1.3l-.6.6h2.6V19z" fill-rule="nonzero"/></svg>',
|
|
'superscript': '<svg width="24" height="24"><path d="M15 9.4L10.4 14l4.6 4.6-1.4 1.4L9 15.4 4.4 20 3 18.6 7.6 14 3 9.4 4.4 8 9 12.6 13.6 8 15 9.4zm5.9 1.6h-5v-1l1-.8 1.7-1.6c.3-.5.5-.9.5-1.3 0-.3 0-.5-.2-.7-.2-.2-.5-.3-.9-.3l-.8.2-.7.4-.4-1.2c.2-.2.5-.4 1-.5.3-.2.8-.2 1.2-.2.8 0 1.4.2 1.8.6.4.4.6 1 .6 1.6 0 .5-.2 1-.5 1.5l-1.3 1.4-.6.5h2.6V11z" fill-rule="nonzero"/></svg>',
|
|
'table-caption': '<svg width="24" height="24"><g fill-rule="nonzero"><rect width="12" height="2" x="3" y="4" rx="1"/><path d="M19 8a2 2 0 012 2v8a2 2 0 01-2 2H5a2 2 0 01-2-2v-8c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-5h-6v3h6v-3zM5 13h6v-3H5v3z"/></g></svg>',
|
|
'table-cell-classes': '<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M13 4v9H3V6c0-1.1.9-2 2-2h8zm-2 2H5v5h6V6z"/><path fill-rule="nonzero" d="M13 4h6a2 2 0 012 2v7h-8v-2h6V6h-6V4z" opacity=".2"/><path d="M18 20l-2.6 1.6.7-3-2.4-2 3.1-.2 1.2-2.9 1.2 2.9 3 .2-2.3 2 .7 3z"/><path fill-rule="nonzero" d="M3 13v5c0 1.1.9 2 2 2h8v-7h-2v5H5v-5H3z" opacity=".2"/></g></svg>',
|
|
'table-cell-properties': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm-8 9H5v5h6v-5zm8 0h-6v5h6v-5zm-8-7H5v5h6V6z"/></svg>',
|
|
'table-cell-select-all': '<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v12h14V6z"/><path d="M13 6v5h6v2h-6v5h-2v-5H5v-2h6V6h2z" opacity=".2"/></g></svg>',
|
|
'table-cell-select-inner': '<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v12h14V6z" opacity=".2"/><path d="M13 6v5h6v2h-6v5h-2v-5H5v-2h6V6h2z"/></g></svg>',
|
|
'table-classes': '<svg width="24" height="24"><g fill-rule="evenodd"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v7h-8v7H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm-8 9H5v5h6v-5zm8-7h-6v5h6V6zm-8 0H5v5h6V6z"/><path d="M18 20l-2.6 1.6.7-3-2.4-2 3.1-.2 1.2-2.9 1.2 2.9 3 .2-2.3 2 .7 3z"/></g></svg>',
|
|
'table-delete-column': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm-4 4h-2V6h-2v2H9V6H5v12h4v-2h2v2h2v-2h2v2h4V6h-4v2zm.3.5l1 1.2-3 2.3 3 2.3-1 1.2L12 13l-3.3 2.6-1-1.2 3-2.3-3-2.3 1-1.2L12 11l3.3-2.5z"/></svg>',
|
|
'table-delete-row': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm0 2H5v3h2.5v2H5v2h2.5v2H5v3h14v-3h-2.5v-2H19v-2h-2.5V9H19V6zm-4.7 1.8l1.2 1L13 12l2.6 3.3-1.2 1-2.3-3-2.3 3-1.2-1L11 12 8.5 8.7l1.2-1 2.3 3 2.3-3z"/></svg>',
|
|
'table-delete-table': '<svg width="24" height="24"><g fill-rule="nonzero"><path d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zM5 6v12h14V6H5z"/><path d="M14.4 8.6l1 1-2.3 2.4 2.3 2.4-1 1-2.4-2.3-2.4 2.3-1-1 2.3-2.4-2.3-2.4 1-1 2.4 2.3z"/></g></svg>',
|
|
'table-insert-column-after': '<svg width="24" height="24"><path fill-rule="nonzero" d="M20 4c.6 0 1 .4 1 1v2a1 1 0 01-2 0V6h-8v12h8v-1a1 1 0 012 0v2c0 .5-.4 1-.9 1H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h15zM9 13H5v5h4v-5zm7-5c.5 0 1 .4 1 .9V11h2a1 1 0 01.1 2H17v2a1 1 0 01-2 .1V13h-2a1 1 0 01-.1-2H15V9c0-.6.4-1 1-1zM9 6H5v5h4V6z"/></svg>',
|
|
'table-insert-column-before': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H4a1 1 0 01-1-1v-2a1 1 0 012 0v1h8V6H5v1a1 1 0 11-2 0V5c0-.6.4-1 1-1h15zm0 9h-4v5h4v-5zM8 8c.5 0 1 .4 1 .9V11h2a1 1 0 01.1 2H9v2a1 1 0 01-2 .1V13H5a1 1 0 01-.1-2H7V9c0-.6.4-1 1-1zm11-2h-4v5h4V6z"/></svg>',
|
|
'table-insert-row-above': '<svg width="24" height="24"><path fill-rule="nonzero" d="M6 4a1 1 0 110 2H5v6h14V6h-1a1 1 0 010-2h2c.6 0 1 .4 1 1v13a2 2 0 01-2 2H5a2 2 0 01-2-2V5c0-.6.4-1 1-1h2zm5 10H5v4h6v-4zm8 0h-6v4h6v-4zM12 3c.5 0 1 .4 1 .9V6h2a1 1 0 010 2h-2v2a1 1 0 01-2 .1V8H9a1 1 0 010-2h2V4c0-.6.4-1 1-1z"/></svg>',
|
|
'table-insert-row-after': '<svg width="24" height="24"><path fill-rule="nonzero" d="M12 13c.5 0 1 .4 1 .9V16h2a1 1 0 01.1 2H13v2a1 1 0 01-2 .1V18H9a1 1 0 01-.1-2H11v-2c0-.6.4-1 1-1zm6 7a1 1 0 010-2h1v-6H5v6h1a1 1 0 010 2H4a1 1 0 01-1-1V6c0-1.1.9-2 2-2h14a2 2 0 012 2v13c0 .5-.4 1-.9 1H18zM11 6H5v4h6V6zm8 0h-6v4h6V6z"/></svg>',
|
|
'table-left-header': '<svg width="24" height="24"><path d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm0 9h-4v5h4v-5zm-6 0H9v5h4v-5zm0-7H9v5h4V6zm6 0h-4v5h4V6z"/></svg>',
|
|
'table-merge-cells': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zM5 15.5V18h3v-2.5H5zm14-5h-9V18h9v-7.5zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6zm-8 7.5h3v-3H5v3z"/></svg>',
|
|
'table-row-numbering-rtl': '<svg width="24" height="24"><path d="M6 4a2 2 0 00-2 2v13c0 1.1.9 2 2 2h12a2 2 0 002-2V6a2 2 0 00-2-2H6zm0 12h8v3H6v-3zm11 0c.6 0 1 .4 1 1v1a1 1 0 01-2 0v-1c0-.6.4-1 1-1zM6 11h8v3H6v-3zm11 0c.6 0 1 .4 1 1v1a1 1 0 01-2 0v-1c0-.6.4-1 1-1zM6 6h8v3H6V6zm11 0c.6 0 1 .4 1 1v1a1 1 0 11-2 0V7c0-.6.4-1 1-1z"/></svg>',
|
|
'table-row-numbering': '<svg width="24" height="24"><path d="M18 4a2 2 0 012 2v13a2 2 0 01-2 2H6a2 2 0 01-2-2V6c0-1.1.9-2 2-2h12zm0 12h-8v3h8v-3zM7 16a1 1 0 00-1 1v1a1 1 0 002 0v-1c0-.6-.4-1-1-1zm11-5h-8v3h8v-3zM7 11a1 1 0 00-1 1v1a1 1 0 002 0v-1c0-.6-.4-1-1-1zm11-5h-8v3h8V6zM7 6a1 1 0 00-1 1v1a1 1 0 102 0V7c0-.6-.4-1-1-1z"/></svg>',
|
|
'table-row-properties': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zM5 15v3h6v-3H5zm14 0h-6v3h6v-3zm0-9h-6v3h6V6zM5 9h6V6H5v3z"/></svg>',
|
|
'table-split-cells': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zM8 15.5H5V18h3v-2.5zm11-5h-9V18h9v-7.5zm-2.5 1l1 1-2 2 2 2-1 1-2-2-2 2-1-1 2-2-2-2 1-1 2 2 2-2zm-8.5-1H5v3h3v-3zM19 6h-4v2.5h4V6zM8 6H5v2.5h3V6zm5 0h-3v2.5h3V6z"/></svg>',
|
|
'table-top-header': '<svg width="24" height="24"><path d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zm-8 11H5v3h6v-3zm8 0h-6v3h6v-3zm0-5h-6v3h6v-3zM5 13h6v-3H5v3z"/></svg>',
|
|
'table': '<svg width="24" height="24"><path fill-rule="nonzero" d="M19 4a2 2 0 012 2v12a2 2 0 01-2 2H5a2 2 0 01-2-2V6c0-1.1.9-2 2-2h14zM5 14v4h6v-4H5zm14 0h-6v4h6v-4zm0-6h-6v4h6V8zM5 12h6V8H5v4z"/></svg>',
|
|
'template': '<svg width="24" height="24"><path d="M19 19v-1H5v1h14zM9 16v-4a5 5 0 116 0v4h4a2 2 0 012 2v3H3v-3c0-1.1.9-2 2-2h4zm4 0v-5l.8-.6a3 3 0 10-3.6 0l.8.6v5h2z" fill-rule="nonzero"/></svg>',
|
|
'temporary-placeholder': '<svg width="24" height="24"><g fill-rule="evenodd"><path d="M9 7.6V6h2.5V4.5a.5.5 0 111 0V6H15v1.6a8 8 0 11-6 0zm-2.6 5.3a.5.5 0 00.3.6c.3 0 .6 0 .6-.3l.1-.2a5 5 0 013.3-2.8c.3-.1.4-.4.4-.6-.1-.3-.4-.5-.6-.4a6 6 0 00-4.1 3.7z"/><circle cx="14" cy="4" r="1"/><circle cx="12" cy="2" r="1"/><circle cx="10" cy="4" r="1"/></g></svg>',
|
|
'text-color': '<svg width="24" height="24"><g fill-rule="evenodd"><path id="tox-icon-text-color__color" d="M3 18h18v3H3z"/><path d="M8.7 16h-.8a.5.5 0 01-.5-.6l2.7-9c.1-.3.3-.4.5-.4h2.8c.2 0 .4.1.5.4l2.7 9a.5.5 0 01-.5.6h-.8a.5.5 0 01-.4-.4l-.7-2.2c0-.3-.3-.4-.5-.4h-3.4c-.2 0-.4.1-.5.4l-.7 2.2c0 .3-.2.4-.4.4zm2.6-7.6l-.6 2a.5.5 0 00.5.6h1.6a.5.5 0 00.5-.6l-.6-2c0-.3-.3-.4-.5-.4h-.4c-.2 0-.4.1-.5.4z"/></g></svg>',
|
|
'toc': '<svg width="24" height="24"><path d="M5 5c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 110-2zm3 0h11c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 110-2zm-3 8c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 010-2zm3 0h11c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 010-2zm0-4c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 110-2zm3 0h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm-3 8c.6 0 1 .4 1 1s-.4 1-1 1a1 1 0 010-2zm3 0h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2z" fill-rule="evenodd"/></svg>',
|
|
'translate': '<svg width="24" height="24"><path d="M12.7 14.3l-.3.7-.4.7-2.2-2.2-3.1 3c-.3.4-.8.4-1 0a.7.7 0 010-1l3.1-3A12.4 12.4 0 016.7 9H8a10.1 10.1 0 001.7 2.4c.5-.5 1-1.1 1.4-1.8l.9-2H4.7a.7.7 0 110-1.5h4.4v-.7c0-.4.3-.8.7-.8.4 0 .7.4.7.8v.7H15c.4 0 .8.3.8.7 0 .4-.4.8-.8.8h-1.4a12.3 12.3 0 01-1 2.4 13.5 13.5 0 01-1.7 2.3l1.9 1.8zm4.3-3l2.7 7.3a.5.5 0 01-.4.7 1 1 0 01-1-.7l-.6-1.5h-3.4l-.6 1.5a1 1 0 01-1 .7.5.5 0 01-.4-.7l2.7-7.4a1 1 0 012 0zm-2.2 4.4h2.4L16 12.5l-1.2 3.2z" fill-rule="evenodd"/></svg>',
|
|
'underline': '<svg width="24" height="24"><path d="M16 5c.6 0 1 .4 1 1v5.5a4 4 0 01-.4 1.8l-1 1.4a5.3 5.3 0 01-5.5 1 5 5 0 01-1.6-1c-.5-.4-.8-.9-1.1-1.4a4 4 0 01-.4-1.8V6c0-.6.4-1 1-1s1 .4 1 1v5.5c0 .3 0 .6.2 1l.6.7a3.3 3.3 0 002.2.8 3.4 3.4 0 002.2-.8c.3-.2.4-.5.6-.8l.2-.9V6c0-.6.4-1 1-1zM8 17h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 010-2z" fill-rule="evenodd"/></svg>',
|
|
'undo': '<svg width="24" height="24"><path d="M6.4 8H12c3.7 0 6.2 2 6.8 5.1.6 2.7-.4 5.6-2.3 6.8a1 1 0 01-1-1.8c1.1-.6 1.8-2.7 1.4-4.6-.5-2.1-2.1-3.5-4.9-3.5H6.4l3.3 3.3a1 1 0 11-1.4 1.4l-5-5a1 1 0 010-1.4l5-5a1 1 0 011.4 1.4L6.4 8z" fill-rule="nonzero"/></svg>',
|
|
'unlink': '<svg width="24" height="24"><path d="M6.2 12.3a1 1 0 011.4 1.4l-2 2a2 2 0 102.6 2.8l4.8-4.8a1 1 0 000-1.4 1 1 0 111.4-1.3 2.9 2.9 0 010 4L9.6 20a3.9 3.9 0 01-5.5-5.5l2-2zm11.6-.6a1 1 0 01-1.4-1.4l2.1-2a2 2 0 10-2.7-2.8L11 10.3a1 1 0 000 1.4A1 1 0 119.6 13a2.9 2.9 0 010-4L14.4 4a3.9 3.9 0 015.5 5.5l-2 2zM7.6 6.3a.8.8 0 01-1 1.1L3.3 4.2a.7.7 0 111-1l3.2 3.1zM5.1 8.6a.8.8 0 010 1.5H3a.8.8 0 010-1.5H5zm5-3.5a.8.8 0 01-1.5 0V3a.8.8 0 011.5 0V5zm6 11.8a.8.8 0 011-1l3.2 3.2a.8.8 0 01-1 1L16 17zm-2.2 2a.8.8 0 011.5 0V21a.8.8 0 01-1.5 0V19zm5-3.5a.7.7 0 110-1.5H21a.8.8 0 010 1.5H19z" fill-rule="nonzero"/></svg>',
|
|
'unlock': '<svg width="24" height="24"><path d="M16 5c.8 0 1.5.3 2.1.9.6.6.9 1.3.9 2.1v3h-2V8a1 1 0 00-.3-.7A1 1 0 0016 7h-2a1 1 0 00-.7.3 1 1 0 00-.3.7v3h.3c.2 0 .3 0 .5.2l.2.6v7.4c0 .3 0 .4-.2.6l-.6.2H4.8c-.3 0-.4 0-.6-.2a.7.7 0 01-.2-.6v-7.4c0-.3 0-.4.2-.6l.5-.2H11V8c0-.8.3-1.5.9-2.1.6-.6 1.3-.9 2.1-.9h2z" fill-rule="evenodd"/></svg>',
|
|
'unordered-list': '<svg width="24" height="24"><path d="M11 5h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 010-2zM4.5 6c0-.4.1-.8.4-1 .3-.4.7-.5 1.1-.5.4 0 .8.1 1 .4.4.3.5.7.5 1.1 0 .4-.1.8-.4 1-.3.4-.7.5-1.1.5-.4 0-.8-.1-1-.4-.4-.3-.5-.7-.5-1.1zm0 6c0-.4.1-.8.4-1 .3-.4.7-.5 1.1-.5.4 0 .8.1 1 .4.4.3.5.7.5 1.1 0 .4-.1.8-.4 1-.3.4-.7.5-1.1.5-.4 0-.8-.1-1-.4-.4-.3-.5-.7-.5-1.1zm0 6c0-.4.1-.8.4-1 .3-.4.7-.5 1.1-.5.4 0 .8.1 1 .4.4.3.5.7.5 1.1 0 .4-.1.8-.4 1-.3.4-.7.5-1.1.5-.4 0-.8-.1-1-.4-.4-.3-.5-.7-.5-1.1z" fill-rule="evenodd"/></svg>',
|
|
'unselected': '<svg width="24" height="24"><path fill-rule="nonzero" d="M6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6c0-1.1.9-2 2-2zm0 1a1 1 0 00-1 1v12c0 .6.4 1 1 1h12c.6 0 1-.4 1-1V6c0-.6-.4-1-1-1H6z"/></svg>',
|
|
'upload': '<svg width="24" height="24"><path d="M18 19v-2a1 1 0 012 0v3c0 .6-.4 1-1 1H5a1 1 0 01-1-1v-3a1 1 0 012 0v2h12zM11 6.4L8.7 8.7a1 1 0 01-1.4-1.4l4-4a1 1 0 011.4 0l4 4a1 1 0 11-1.4 1.4L13 6.4V16a1 1 0 01-2 0V6.4z" fill-rule="nonzero"/></svg>',
|
|
'user': '<svg width="24" height="24"><path d="M12 24a12 12 0 110-24 12 12 0 010 24zm-8.7-5.3a11 11 0 0017.4 0C19.4 16.3 14.6 15 12 15c-2.6 0-7.4 1.3-8.7 3.7zM12 13c2.2 0 4-2 4-4.5S14.2 4 12 4 8 6 8 8.5 9.8 13 12 13z" fill-rule="nonzero"/></svg>',
|
|
'vertical-align': '<svg width="24" height="24"><g fill-rule="nonzero"><rect width="18" height="2" x="3" y="11" rx="1"/><path d="M12 2c.6 0 1 .4 1 1v4l2-1.3a1 1 0 011.2 1.5l-.1.1-4.1 3-4-3a1 1 0 011-1.7l2 1.5V3c0-.6.4-1 1-1zm0 11.8l4 2.9a1 1 0 01-1 1.7l-2-1.5V21c0 .5-.4 1-.9 1H12a1 1 0 01-1-1v-4l-2 1.3a1 1 0 01-1.2-.1l-.1-.1a1 1 0 01.1-1.3l.1-.1 4.1-3z"/></g></svg>',
|
|
'visualblocks': '<svg width="24" height="24"><path d="M9 19v2H7v-2h2zm-4 0v2a2 2 0 01-2-2h2zm8 0v2h-2v-2h2zm8 0a2 2 0 01-2 2v-2h2zm-4 0v2h-2v-2h2zM15 7a1 1 0 010 2v7a1 1 0 01-2 0V9h-1v7a1 1 0 01-2 0v-4a2.5 2.5 0 01-.2-5H15zM5 15v2H3v-2h2zm16 0v2h-2v-2h2zM5 11v2H3v-2h2zm16 0v2h-2v-2h2zM5 7v2H3V7h2zm16 0v2h-2V7h2zM5 3v2H3c0-1.1.9-2 2-2zm8 0v2h-2V3h2zm6 0a2 2 0 012 2h-2V3zM9 3v2H7V3h2zm8 0v2h-2V3h2z" fill-rule="evenodd"/></svg>',
|
|
'visualchars': '<svg width="24" height="24"><path d="M10 5h7a1 1 0 010 2h-1v11a1 1 0 01-2 0V7h-2v11a1 1 0 01-2 0v-6c-.5 0-1 0-1.4-.3A3.4 3.4 0 016.8 10a3.3 3.3 0 010-2.8 3.4 3.4 0 011.8-1.8L10 5z" fill-rule="evenodd"/></svg>',
|
|
'warning': '<svg width="24" height="24"><path d="M19.8 18.3c.2.5.3.9 0 1.2-.1.3-.5.5-1 .5H5.2c-.5 0-.9-.2-1-.5-.3-.3-.2-.7 0-1.2L11 4.7l.5-.5.5-.2c.2 0 .3 0 .5.2.2 0 .3.3.5.5l6.8 13.6zM12 18c.3 0 .5-.1.7-.3.2-.2.3-.4.3-.7a1 1 0 00-.3-.7 1 1 0 00-.7-.3 1 1 0 00-.7.3 1 1 0 00-.3.7c0 .3.1.5.3.7.2.2.4.3.7.3zm.7-3l.3-4a1 1 0 00-.3-.7 1 1 0 00-.7-.3 1 1 0 00-.7.3 1 1 0 00-.3.7l.3 4h1.4z" fill-rule="evenodd"/></svg>',
|
|
'zoom-in': '<svg width="24" height="24"><path d="M16 17.3a8 8 0 111.4-1.4l4.3 4.4a1 1 0 01-1.4 1.4l-4.4-4.3zm-5-.3a6 6 0 100-12 6 6 0 000 12zm-1-9a1 1 0 012 0v6a1 1 0 01-2 0V8zm-2 4a1 1 0 010-2h6a1 1 0 010 2H8z" fill-rule="nonzero"/></svg>',
|
|
'zoom-out': '<svg width="24" height="24"><path d="M16 17.3a8 8 0 111.4-1.4l4.3 4.4a1 1 0 01-1.4 1.4l-4.4-4.3zm-5-.3a6 6 0 100-12 6 6 0 000 12zm-3-5a1 1 0 010-2h6a1 1 0 010 2H8z" fill-rule="nonzero"/></svg>',
|
|
}
|
|
});
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var allowHtmlInNamedAnchor = function (editor) {
|
|
return editor.getParam('allow_html_in_named_anchor', false, 'boolean');
|
|
};
|
|
|
|
var namedAnchorSelector = 'a:not([href])';
|
|
var isEmptyString = function (str) {
|
|
return !str;
|
|
};
|
|
var getIdFromAnchor = function (elm) {
|
|
var id = elm.getAttribute('id') || elm.getAttribute('name');
|
|
return id || '';
|
|
};
|
|
var isAnchor = function (elm) {
|
|
return elm && elm.nodeName.toLowerCase() === 'a';
|
|
};
|
|
var isNamedAnchor = function (elm) {
|
|
return isAnchor(elm) && !elm.getAttribute('href') && getIdFromAnchor(elm) !== '';
|
|
};
|
|
var isEmptyNamedAnchor = function (elm) {
|
|
return isNamedAnchor(elm) && !elm.firstChild;
|
|
};
|
|
|
|
var removeEmptyNamedAnchorsInSelection = function (editor) {
|
|
var dom = editor.dom;
|
|
global$1(dom).walk(editor.selection.getRng(), function (nodes) {
|
|
global.each(nodes, function (node) {
|
|
if (isEmptyNamedAnchor(node)) {
|
|
dom.remove(node, false);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var isValidId = function (id) {
|
|
return /^[A-Za-z][A-Za-z0-9\-:._]*$/.test(id);
|
|
};
|
|
var getNamedAnchor = function (editor) {
|
|
return editor.dom.getParent(editor.selection.getStart(), namedAnchorSelector);
|
|
};
|
|
var getId = function (editor) {
|
|
var anchor = getNamedAnchor(editor);
|
|
if (anchor) {
|
|
return getIdFromAnchor(anchor);
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
var createAnchor = function (editor, id) {
|
|
editor.undoManager.transact(function () {
|
|
if (!allowHtmlInNamedAnchor(editor)) {
|
|
editor.selection.collapse(true);
|
|
}
|
|
if (editor.selection.isCollapsed()) {
|
|
editor.insertContent(editor.dom.createHTML('a', { id: id }));
|
|
} else {
|
|
removeEmptyNamedAnchorsInSelection(editor);
|
|
editor.formatter.remove('namedAnchor', null, null, true);
|
|
editor.formatter.apply('namedAnchor', { value: id });
|
|
editor.addVisual();
|
|
}
|
|
});
|
|
};
|
|
var updateAnchor = function (editor, id, anchorElement) {
|
|
anchorElement.removeAttribute('name');
|
|
anchorElement.id = id;
|
|
editor.addVisual();
|
|
editor.undoManager.add();
|
|
};
|
|
var insert = function (editor, id) {
|
|
var anchor = getNamedAnchor(editor);
|
|
if (anchor) {
|
|
updateAnchor(editor, id, anchor);
|
|
} else {
|
|
createAnchor(editor, id);
|
|
}
|
|
editor.focus();
|
|
};
|
|
|
|
var insertAnchor = function (editor, newId) {
|
|
if (!isValidId(newId)) {
|
|
editor.windowManager.alert('Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.');
|
|
return false;
|
|
} else {
|
|
insert(editor, newId);
|
|
return true;
|
|
}
|
|
};
|
|
var open = function (editor) {
|
|
var currentId = getId(editor);
|
|
editor.windowManager.open({
|
|
title: 'Anchor',
|
|
size: 'normal',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
name: 'id',
|
|
type: 'input',
|
|
label: 'ID',
|
|
placeholder: 'example'
|
|
}]
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: { id: currentId },
|
|
onSubmit: function (api) {
|
|
if (insertAnchor(editor, api.getData().id)) {
|
|
api.close();
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceAnchor', function () {
|
|
open(editor);
|
|
});
|
|
};
|
|
|
|
var isNamedAnchorNode = function (node) {
|
|
return node && isEmptyString(node.attr('href')) && !isEmptyString(node.attr('id') || node.attr('name'));
|
|
};
|
|
var isEmptyNamedAnchorNode = function (node) {
|
|
return isNamedAnchorNode(node) && !node.firstChild;
|
|
};
|
|
var setContentEditable = function (state) {
|
|
return function (nodes) {
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
var node = nodes[i];
|
|
if (isEmptyNamedAnchorNode(node)) {
|
|
node.attr('contenteditable', state);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var setup = function (editor) {
|
|
editor.on('PreInit', function () {
|
|
editor.parser.addNodeFilter('a', setContentEditable('false'));
|
|
editor.serializer.addNodeFilter('a', setContentEditable(null));
|
|
});
|
|
};
|
|
|
|
var registerFormats = function (editor) {
|
|
editor.formatter.register('namedAnchor', {
|
|
inline: 'a',
|
|
selector: namedAnchorSelector,
|
|
remove: 'all',
|
|
split: true,
|
|
deep: true,
|
|
attributes: { id: '%value' },
|
|
onmatch: function (node, _fmt, _itemName) {
|
|
return isNamedAnchor(node);
|
|
}
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
editor.ui.registry.addToggleButton('anchor', {
|
|
icon: 'bookmark',
|
|
tooltip: 'Anchor',
|
|
onAction: function () {
|
|
return editor.execCommand('mceAnchor');
|
|
},
|
|
onSetup: function (buttonApi) {
|
|
return editor.selection.selectorChangedWithUnbind('a:not([href])', buttonApi.setActive).unbind;
|
|
}
|
|
});
|
|
editor.ui.registry.addMenuItem('anchor', {
|
|
icon: 'bookmark',
|
|
text: 'Anchor...',
|
|
onAction: function () {
|
|
return editor.execCommand('mceAnchor');
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$2.add('anchor', function (editor) {
|
|
setup(editor);
|
|
register$1(editor);
|
|
register(editor);
|
|
editor.on('PreInit', function () {
|
|
registerFormats(editor);
|
|
});
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var applyListFormat = function (editor, listName, styleValue) {
|
|
var cmd = listName === 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList';
|
|
editor.execCommand(cmd, false, styleValue === false ? null : { 'list-style-type': styleValue });
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('ApplyUnorderedListStyle', function (ui, value) {
|
|
applyListFormat(editor, 'UL', value['list-style-type']);
|
|
});
|
|
editor.addCommand('ApplyOrderedListStyle', function (ui, value) {
|
|
applyListFormat(editor, 'OL', value['list-style-type']);
|
|
});
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getNumberStyles = function (editor) {
|
|
var styles = editor.getParam('advlist_number_styles', 'default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman');
|
|
return styles ? styles.split(/[ ,]/) : [];
|
|
};
|
|
var getBulletStyles = function (editor) {
|
|
var styles = editor.getParam('advlist_bullet_styles', 'default,circle,square');
|
|
return styles ? styles.split(/[ ,]/) : [];
|
|
};
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var isChildOfBody = function (editor, elm) {
|
|
return editor.$.contains(editor.getBody(), elm);
|
|
};
|
|
var isTableCellNode = function (node) {
|
|
return node && /^(TH|TD)$/.test(node.nodeName);
|
|
};
|
|
var isListNode = function (editor) {
|
|
return function (node) {
|
|
return node && /^(OL|UL|DL)$/.test(node.nodeName) && isChildOfBody(editor, node);
|
|
};
|
|
};
|
|
var getSelectedStyleType = function (editor) {
|
|
var listElm = editor.dom.getParent(editor.selection.getNode(), 'ol,ul');
|
|
var style = editor.dom.getStyle(listElm, 'listStyleType');
|
|
return Optional.from(style);
|
|
};
|
|
|
|
var findIndex = function (list, predicate) {
|
|
for (var index = 0; index < list.length; index++) {
|
|
var element = list[index];
|
|
if (predicate(element)) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
};
|
|
var styleValueToText = function (styleValue) {
|
|
return styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function (chr) {
|
|
return chr.toUpperCase();
|
|
});
|
|
};
|
|
var isWithinList = function (editor, e, nodeName) {
|
|
var tableCellIndex = findIndex(e.parents, isTableCellNode);
|
|
var parents = tableCellIndex !== -1 ? e.parents.slice(0, tableCellIndex) : e.parents;
|
|
var lists = global.grep(parents, isListNode(editor));
|
|
return lists.length > 0 && lists[0].nodeName === nodeName;
|
|
};
|
|
var makeSetupHandler = function (editor, nodeName) {
|
|
return function (api) {
|
|
var nodeChangeHandler = function (e) {
|
|
api.setActive(isWithinList(editor, e, nodeName));
|
|
};
|
|
editor.on('NodeChange', nodeChangeHandler);
|
|
return function () {
|
|
return editor.off('NodeChange', nodeChangeHandler);
|
|
};
|
|
};
|
|
};
|
|
var addSplitButton = function (editor, id, tooltip, cmd, nodeName, styles) {
|
|
editor.ui.registry.addSplitButton(id, {
|
|
tooltip: tooltip,
|
|
icon: nodeName === 'OL' ? 'ordered-list' : 'unordered-list',
|
|
presets: 'listpreview',
|
|
columns: 3,
|
|
fetch: function (callback) {
|
|
var items = global.map(styles, function (styleValue) {
|
|
var iconStyle = nodeName === 'OL' ? 'num' : 'bull';
|
|
var iconName = styleValue === 'disc' || styleValue === 'decimal' ? 'default' : styleValue;
|
|
var itemValue = styleValue === 'default' ? '' : styleValue;
|
|
var displayText = styleValueToText(styleValue);
|
|
return {
|
|
type: 'choiceitem',
|
|
value: itemValue,
|
|
icon: 'list-' + iconStyle + '-' + iconName,
|
|
text: displayText
|
|
};
|
|
});
|
|
callback(items);
|
|
},
|
|
onAction: function () {
|
|
return editor.execCommand(cmd);
|
|
},
|
|
onItemAction: function (_splitButtonApi, value) {
|
|
applyListFormat(editor, nodeName, value);
|
|
},
|
|
select: function (value) {
|
|
var listStyleType = getSelectedStyleType(editor);
|
|
return listStyleType.map(function (listStyle) {
|
|
return value === listStyle;
|
|
}).getOr(false);
|
|
},
|
|
onSetup: makeSetupHandler(editor, nodeName)
|
|
});
|
|
};
|
|
var addButton = function (editor, id, tooltip, cmd, nodeName, _styles) {
|
|
editor.ui.registry.addToggleButton(id, {
|
|
active: false,
|
|
tooltip: tooltip,
|
|
icon: nodeName === 'OL' ? 'ordered-list' : 'unordered-list',
|
|
onSetup: makeSetupHandler(editor, nodeName),
|
|
onAction: function () {
|
|
return editor.execCommand(cmd);
|
|
}
|
|
});
|
|
};
|
|
var addControl = function (editor, id, tooltip, cmd, nodeName, styles) {
|
|
if (styles.length > 1) {
|
|
addSplitButton(editor, id, tooltip, cmd, nodeName, styles);
|
|
} else {
|
|
addButton(editor, id, tooltip, cmd, nodeName);
|
|
}
|
|
};
|
|
var register = function (editor) {
|
|
addControl(editor, 'numlist', 'Numbered list', 'InsertOrderedList', 'OL', getNumberStyles(editor));
|
|
addControl(editor, 'bullist', 'Bullet list', 'InsertUnorderedList', 'UL', getBulletStyles(editor));
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('advlist', function (editor) {
|
|
if (editor.hasPlugin('lists')) {
|
|
register(editor);
|
|
register$1(editor);
|
|
} else {
|
|
console.error('Please use the Lists plugin together with the Advanced List plugin.');
|
|
}
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var checkRange = function (str, substr, start) {
|
|
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
};
|
|
var contains = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
var startsWith = function (str, prefix) {
|
|
return checkRange(str, prefix, 0);
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var link = function () {
|
|
return /(?:[A-Za-z][A-Za-z\d.+-]{0,14}:\/\/(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?|www\.|[-;:&=+$,.\w]+@)[A-Za-z\d-]+(?:\.[A-Za-z\d-]+)*(?::\d+)?(?:\/(?:[-.~*+=!;:'%@$(),\/\w]*[-~*+=%@$()\/\w])?)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g;
|
|
};
|
|
|
|
var defaultLinkPattern = new RegExp('^' + link().source + '$', 'i');
|
|
var getAutoLinkPattern = function (editor) {
|
|
return editor.getParam('autolink_pattern', defaultLinkPattern);
|
|
};
|
|
var getDefaultLinkTarget = function (editor) {
|
|
return editor.getParam('default_link_target', false);
|
|
};
|
|
var getDefaultLinkProtocol = function (editor) {
|
|
return editor.getParam('link_default_protocol', 'http', 'string');
|
|
};
|
|
|
|
var rangeEqualsBracketOrSpace = function (rangeString) {
|
|
return /^[(\[{ \u00a0]$/.test(rangeString);
|
|
};
|
|
var isTextNode = function (node) {
|
|
return node.nodeType === 3;
|
|
};
|
|
var isElement = function (node) {
|
|
return node.nodeType === 1;
|
|
};
|
|
var handleBracket = function (editor) {
|
|
return parseCurrentLine(editor, -1);
|
|
};
|
|
var handleSpacebar = function (editor) {
|
|
return parseCurrentLine(editor, 0);
|
|
};
|
|
var handleEnter = function (editor) {
|
|
return parseCurrentLine(editor, -1);
|
|
};
|
|
var scopeIndex = function (container, index) {
|
|
if (index < 0) {
|
|
index = 0;
|
|
}
|
|
if (isTextNode(container)) {
|
|
var len = container.data.length;
|
|
if (index > len) {
|
|
index = len;
|
|
}
|
|
}
|
|
return index;
|
|
};
|
|
var setStart = function (rng, container, offset) {
|
|
if (!isElement(container) || container.hasChildNodes()) {
|
|
rng.setStart(container, scopeIndex(container, offset));
|
|
} else {
|
|
rng.setStartBefore(container);
|
|
}
|
|
};
|
|
var setEnd = function (rng, container, offset) {
|
|
if (!isElement(container) || container.hasChildNodes()) {
|
|
rng.setEnd(container, scopeIndex(container, offset));
|
|
} else {
|
|
rng.setEndAfter(container);
|
|
}
|
|
};
|
|
var hasProtocol = function (url) {
|
|
return /^([A-Za-z][A-Za-z\d.+-]*:\/\/)|mailto:/.test(url);
|
|
};
|
|
var isPunctuation = function (char) {
|
|
return /[?!,.;:]/.test(char);
|
|
};
|
|
var parseCurrentLine = function (editor, endOffset) {
|
|
var end, endContainer, bookmark, text, prev, len, rngText;
|
|
var autoLinkPattern = getAutoLinkPattern(editor);
|
|
var defaultLinkTarget = getDefaultLinkTarget(editor);
|
|
if (editor.dom.getParent(editor.selection.getNode(), 'a[href]') !== null) {
|
|
return;
|
|
}
|
|
var rng = editor.selection.getRng().cloneRange();
|
|
if (rng.startOffset < 5) {
|
|
prev = rng.endContainer.previousSibling;
|
|
if (!prev) {
|
|
if (!rng.endContainer.firstChild || !rng.endContainer.firstChild.nextSibling) {
|
|
return;
|
|
}
|
|
prev = rng.endContainer.firstChild.nextSibling;
|
|
}
|
|
len = prev.length;
|
|
setStart(rng, prev, len);
|
|
setEnd(rng, prev, len);
|
|
if (rng.endOffset < 5) {
|
|
return;
|
|
}
|
|
end = rng.endOffset;
|
|
endContainer = prev;
|
|
} else {
|
|
endContainer = rng.endContainer;
|
|
if (!isTextNode(endContainer) && endContainer.firstChild) {
|
|
while (!isTextNode(endContainer) && endContainer.firstChild) {
|
|
endContainer = endContainer.firstChild;
|
|
}
|
|
if (isTextNode(endContainer)) {
|
|
setStart(rng, endContainer, 0);
|
|
setEnd(rng, endContainer, endContainer.nodeValue.length);
|
|
}
|
|
}
|
|
if (rng.endOffset === 1) {
|
|
end = 2;
|
|
} else {
|
|
end = rng.endOffset - 1 - endOffset;
|
|
}
|
|
}
|
|
var start = end;
|
|
do {
|
|
setStart(rng, endContainer, end >= 2 ? end - 2 : 0);
|
|
setEnd(rng, endContainer, end >= 1 ? end - 1 : 0);
|
|
end -= 1;
|
|
rngText = rng.toString();
|
|
} while (!rangeEqualsBracketOrSpace(rngText) && end - 2 >= 0);
|
|
if (rangeEqualsBracketOrSpace(rng.toString())) {
|
|
setStart(rng, endContainer, end);
|
|
setEnd(rng, endContainer, start);
|
|
end += 1;
|
|
} else if (rng.startOffset === 0) {
|
|
setStart(rng, endContainer, 0);
|
|
setEnd(rng, endContainer, start);
|
|
} else {
|
|
setStart(rng, endContainer, end);
|
|
setEnd(rng, endContainer, start);
|
|
}
|
|
text = rng.toString();
|
|
if (isPunctuation(text.charAt(text.length - 1))) {
|
|
setEnd(rng, endContainer, start - 1);
|
|
}
|
|
text = rng.toString().trim();
|
|
var matches = text.match(autoLinkPattern);
|
|
var protocol = getDefaultLinkProtocol(editor);
|
|
if (matches) {
|
|
var url = matches[0];
|
|
if (startsWith(url, 'www.')) {
|
|
url = protocol + '://' + url;
|
|
} else if (contains(url, '@') && !hasProtocol(url)) {
|
|
url = 'mailto:' + url;
|
|
}
|
|
bookmark = editor.selection.getBookmark();
|
|
editor.selection.setRng(rng);
|
|
editor.execCommand('createlink', false, url);
|
|
if (defaultLinkTarget !== false) {
|
|
editor.dom.setAttrib(editor.selection.getNode(), 'target', defaultLinkTarget);
|
|
}
|
|
editor.selection.moveToBookmark(bookmark);
|
|
editor.nodeChanged();
|
|
}
|
|
};
|
|
var setup = function (editor) {
|
|
var autoUrlDetectState;
|
|
editor.on('keydown', function (e) {
|
|
if (e.keyCode === 13) {
|
|
return handleEnter(editor);
|
|
}
|
|
});
|
|
if (global.browser.isIE()) {
|
|
editor.on('focus', function () {
|
|
if (!autoUrlDetectState) {
|
|
autoUrlDetectState = true;
|
|
try {
|
|
editor.execCommand('AutoUrlDetect', false, true);
|
|
} catch (ex) {
|
|
}
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
editor.on('keypress', function (e) {
|
|
if (e.keyCode === 41 || e.keyCode === 93 || e.keyCode === 125) {
|
|
return handleBracket(editor);
|
|
}
|
|
});
|
|
editor.on('keyup', function (e) {
|
|
if (e.keyCode === 32) {
|
|
return handleSpacebar(editor);
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('autolink', function (editor) {
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var fireResizeEditor = function (editor) {
|
|
return editor.fire('ResizeEditor');
|
|
};
|
|
|
|
var getAutoResizeMinHeight = function (editor) {
|
|
return editor.getParam('min_height', editor.getElement().offsetHeight, 'number');
|
|
};
|
|
var getAutoResizeMaxHeight = function (editor) {
|
|
return editor.getParam('max_height', 0, 'number');
|
|
};
|
|
var getAutoResizeOverflowPadding = function (editor) {
|
|
return editor.getParam('autoresize_overflow_padding', 1, 'number');
|
|
};
|
|
var getAutoResizeBottomMargin = function (editor) {
|
|
return editor.getParam('autoresize_bottom_margin', 50, 'number');
|
|
};
|
|
var shouldAutoResizeOnInit = function (editor) {
|
|
return editor.getParam('autoresize_on_init', true, 'boolean');
|
|
};
|
|
|
|
var isFullscreen = function (editor) {
|
|
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
|
};
|
|
var wait = function (editor, oldSize, times, interval, callback) {
|
|
global.setEditorTimeout(editor, function () {
|
|
resize(editor, oldSize);
|
|
if (times--) {
|
|
wait(editor, oldSize, times, interval, callback);
|
|
} else if (callback) {
|
|
callback();
|
|
}
|
|
}, interval);
|
|
};
|
|
var toggleScrolling = function (editor, state) {
|
|
var body = editor.getBody();
|
|
if (body) {
|
|
body.style.overflowY = state ? '' : 'hidden';
|
|
if (!state) {
|
|
body.scrollTop = 0;
|
|
}
|
|
}
|
|
};
|
|
var parseCssValueToInt = function (dom, elm, name, computed) {
|
|
var value = parseInt(dom.getStyle(elm, name, computed), 10);
|
|
return isNaN(value) ? 0 : value;
|
|
};
|
|
var shouldScrollIntoView = function (trigger) {
|
|
if ((trigger === null || trigger === void 0 ? void 0 : trigger.type.toLowerCase()) === 'setcontent') {
|
|
var setContentEvent = trigger;
|
|
return setContentEvent.selection === true || setContentEvent.paste === true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
var resize = function (editor, oldSize, trigger) {
|
|
var dom = editor.dom;
|
|
var doc = editor.getDoc();
|
|
if (!doc) {
|
|
return;
|
|
}
|
|
if (isFullscreen(editor)) {
|
|
toggleScrolling(editor, true);
|
|
return;
|
|
}
|
|
var docEle = doc.documentElement;
|
|
var resizeBottomMargin = getAutoResizeBottomMargin(editor);
|
|
var resizeHeight = getAutoResizeMinHeight(editor);
|
|
var marginTop = parseCssValueToInt(dom, docEle, 'margin-top', true);
|
|
var marginBottom = parseCssValueToInt(dom, docEle, 'margin-bottom', true);
|
|
var contentHeight = docEle.offsetHeight + marginTop + marginBottom + resizeBottomMargin;
|
|
if (contentHeight < 0) {
|
|
contentHeight = 0;
|
|
}
|
|
var containerHeight = editor.getContainer().offsetHeight;
|
|
var contentAreaHeight = editor.getContentAreaContainer().offsetHeight;
|
|
var chromeHeight = containerHeight - contentAreaHeight;
|
|
if (contentHeight + chromeHeight > getAutoResizeMinHeight(editor)) {
|
|
resizeHeight = contentHeight + chromeHeight;
|
|
}
|
|
var maxHeight = getAutoResizeMaxHeight(editor);
|
|
if (maxHeight && resizeHeight > maxHeight) {
|
|
resizeHeight = maxHeight;
|
|
toggleScrolling(editor, true);
|
|
} else {
|
|
toggleScrolling(editor, false);
|
|
}
|
|
if (resizeHeight !== oldSize.get()) {
|
|
var deltaSize = resizeHeight - oldSize.get();
|
|
dom.setStyle(editor.getContainer(), 'height', resizeHeight + 'px');
|
|
oldSize.set(resizeHeight);
|
|
fireResizeEditor(editor);
|
|
if (global$1.browser.isSafari() && global$1.mac) {
|
|
var win = editor.getWin();
|
|
win.scrollTo(win.pageXOffset, win.pageYOffset);
|
|
}
|
|
if (editor.hasFocus() && shouldScrollIntoView(trigger)) {
|
|
editor.selection.scrollIntoView();
|
|
}
|
|
if (global$1.webkit && deltaSize < 0) {
|
|
resize(editor, oldSize, trigger);
|
|
}
|
|
}
|
|
};
|
|
var setup = function (editor, oldSize) {
|
|
editor.on('init', function () {
|
|
var overflowPadding = getAutoResizeOverflowPadding(editor);
|
|
var dom = editor.dom;
|
|
dom.setStyles(editor.getDoc().documentElement, { height: 'auto' });
|
|
dom.setStyles(editor.getBody(), {
|
|
'paddingLeft': overflowPadding,
|
|
'paddingRight': overflowPadding,
|
|
'min-height': 0
|
|
});
|
|
});
|
|
editor.on('NodeChange SetContent keyup FullscreenStateChanged ResizeContent', function (e) {
|
|
resize(editor, oldSize, e);
|
|
});
|
|
if (shouldAutoResizeOnInit(editor)) {
|
|
editor.on('init', function () {
|
|
wait(editor, oldSize, 20, 100, function () {
|
|
wait(editor, oldSize, 5, 1000);
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
var register = function (editor, oldSize) {
|
|
editor.addCommand('mceAutoResize', function () {
|
|
resize(editor, oldSize);
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$2.add('autoresize', function (editor) {
|
|
if (!has(editor.settings, 'resize')) {
|
|
editor.settings.resize = false;
|
|
}
|
|
if (!editor.inline) {
|
|
var oldSize = Cell(0);
|
|
register(editor, oldSize);
|
|
setup(editor, oldSize);
|
|
}
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var eq = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isUndefined = eq(undefined);
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.LocalStorage');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var fireRestoreDraft = function (editor) {
|
|
return editor.fire('RestoreDraft');
|
|
};
|
|
var fireStoreDraft = function (editor) {
|
|
return editor.fire('StoreDraft');
|
|
};
|
|
var fireRemoveDraft = function (editor) {
|
|
return editor.fire('RemoveDraft');
|
|
};
|
|
|
|
var parse = function (timeString, defaultTime) {
|
|
var multiples = {
|
|
s: 1000,
|
|
m: 60000
|
|
};
|
|
var toParse = timeString || defaultTime;
|
|
var parsedTime = /^(\d+)([ms]?)$/.exec('' + toParse);
|
|
return (parsedTime[2] ? multiples[parsedTime[2]] : 1) * parseInt(toParse, 10);
|
|
};
|
|
|
|
var shouldAskBeforeUnload = function (editor) {
|
|
return editor.getParam('autosave_ask_before_unload', true);
|
|
};
|
|
var getAutoSavePrefix = function (editor) {
|
|
var location = document.location;
|
|
return editor.getParam('autosave_prefix', 'tinymce-autosave-{path}{query}{hash}-{id}-').replace(/{path}/g, location.pathname).replace(/{query}/g, location.search).replace(/{hash}/g, location.hash).replace(/{id}/g, editor.id);
|
|
};
|
|
var shouldRestoreWhenEmpty = function (editor) {
|
|
return editor.getParam('autosave_restore_when_empty', false);
|
|
};
|
|
var getAutoSaveInterval = function (editor) {
|
|
return parse(editor.getParam('autosave_interval'), '30s');
|
|
};
|
|
var getAutoSaveRetention = function (editor) {
|
|
return parse(editor.getParam('autosave_retention'), '20m');
|
|
};
|
|
|
|
var isEmpty = function (editor, html) {
|
|
if (isUndefined(html)) {
|
|
return editor.dom.isEmpty(editor.getBody());
|
|
} else {
|
|
var trimmedHtml = global$1.trim(html);
|
|
if (trimmedHtml === '') {
|
|
return true;
|
|
} else {
|
|
var fragment = new DOMParser().parseFromString(trimmedHtml, 'text/html');
|
|
return editor.dom.isEmpty(fragment);
|
|
}
|
|
}
|
|
};
|
|
var hasDraft = function (editor) {
|
|
var time = parseInt(global$2.getItem(getAutoSavePrefix(editor) + 'time'), 10) || 0;
|
|
if (new Date().getTime() - time > getAutoSaveRetention(editor)) {
|
|
removeDraft(editor, false);
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
var removeDraft = function (editor, fire) {
|
|
var prefix = getAutoSavePrefix(editor);
|
|
global$2.removeItem(prefix + 'draft');
|
|
global$2.removeItem(prefix + 'time');
|
|
if (fire !== false) {
|
|
fireRemoveDraft(editor);
|
|
}
|
|
};
|
|
var storeDraft = function (editor) {
|
|
var prefix = getAutoSavePrefix(editor);
|
|
if (!isEmpty(editor) && editor.isDirty()) {
|
|
global$2.setItem(prefix + 'draft', editor.getContent({
|
|
format: 'raw',
|
|
no_events: true
|
|
}));
|
|
global$2.setItem(prefix + 'time', new Date().getTime().toString());
|
|
fireStoreDraft(editor);
|
|
}
|
|
};
|
|
var restoreDraft = function (editor) {
|
|
var prefix = getAutoSavePrefix(editor);
|
|
if (hasDraft(editor)) {
|
|
editor.setContent(global$2.getItem(prefix + 'draft'), { format: 'raw' });
|
|
fireRestoreDraft(editor);
|
|
}
|
|
};
|
|
var startStoreDraft = function (editor) {
|
|
var interval = getAutoSaveInterval(editor);
|
|
global$3.setEditorInterval(editor, function () {
|
|
storeDraft(editor);
|
|
}, interval);
|
|
};
|
|
var restoreLastDraft = function (editor) {
|
|
editor.undoManager.transact(function () {
|
|
restoreDraft(editor);
|
|
removeDraft(editor);
|
|
});
|
|
editor.focus();
|
|
};
|
|
|
|
var get = function (editor) {
|
|
return {
|
|
hasDraft: function () {
|
|
return hasDraft(editor);
|
|
},
|
|
storeDraft: function () {
|
|
return storeDraft(editor);
|
|
},
|
|
restoreDraft: function () {
|
|
return restoreDraft(editor);
|
|
},
|
|
removeDraft: function (fire) {
|
|
return removeDraft(editor, fire);
|
|
},
|
|
isEmpty: function (html) {
|
|
return isEmpty(editor, html);
|
|
}
|
|
};
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
|
|
|
var setup = function (editor) {
|
|
editor.editorManager.on('BeforeUnload', function (e) {
|
|
var msg;
|
|
global$1.each(global.get(), function (editor) {
|
|
if (editor.plugins.autosave) {
|
|
editor.plugins.autosave.storeDraft();
|
|
}
|
|
if (!msg && editor.isDirty() && shouldAskBeforeUnload(editor)) {
|
|
msg = editor.translate('You have unsaved changes are you sure you want to navigate away?');
|
|
}
|
|
});
|
|
if (msg) {
|
|
e.preventDefault();
|
|
e.returnValue = msg;
|
|
}
|
|
});
|
|
};
|
|
|
|
var makeSetupHandler = function (editor) {
|
|
return function (api) {
|
|
api.setDisabled(!hasDraft(editor));
|
|
var editorEventCallback = function () {
|
|
return api.setDisabled(!hasDraft(editor));
|
|
};
|
|
editor.on('StoreDraft RestoreDraft RemoveDraft', editorEventCallback);
|
|
return function () {
|
|
return editor.off('StoreDraft RestoreDraft RemoveDraft', editorEventCallback);
|
|
};
|
|
};
|
|
};
|
|
var register = function (editor) {
|
|
startStoreDraft(editor);
|
|
editor.ui.registry.addButton('restoredraft', {
|
|
tooltip: 'Restore last draft',
|
|
icon: 'restore-draft',
|
|
onAction: function () {
|
|
restoreLastDraft(editor);
|
|
},
|
|
onSetup: makeSetupHandler(editor)
|
|
});
|
|
editor.ui.registry.addMenuItem('restoredraft', {
|
|
text: 'Restore last draft',
|
|
icon: 'restore-draft',
|
|
onAction: function () {
|
|
restoreLastDraft(editor);
|
|
},
|
|
onSetup: makeSetupHandler(editor)
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$4.add('autosave', function (editor) {
|
|
setup(editor);
|
|
register(editor);
|
|
editor.on('init', function () {
|
|
if (shouldRestoreWhenEmpty(editor) && editor.dom.isEmpty(editor.getBody())) {
|
|
restoreDraft(editor);
|
|
}
|
|
});
|
|
return get(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var html2bbcode = function (s) {
|
|
s = global.trim(s);
|
|
var rep = function (re, str) {
|
|
s = s.replace(re, str);
|
|
};
|
|
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi, '[url=$1]$2[/url]');
|
|
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi, '[code][color=$1]$2[/color][/code]');
|
|
rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi, '[quote][color=$1]$2[/color][/quote]');
|
|
rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, '[code][color=$1]$2[/color][/code]');
|
|
rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, '[quote][color=$1]$2[/color][/quote]');
|
|
rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi, '[color=$1]$2[/color]');
|
|
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi, '[color=$1]$2[/color]');
|
|
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi, '[size=$1]$2[/size]');
|
|
rep(/<font>(.*?)<\/font>/gi, '$1');
|
|
rep(/<img.*?src=\"(.*?)\".*?\/>/gi, '[img]$1[/img]');
|
|
rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi, '[code]$1[/code]');
|
|
rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi, '[quote]$1[/quote]');
|
|
rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi, '[code][b]$1[/b][/code]');
|
|
rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi, '[quote][b]$1[/b][/quote]');
|
|
rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi, '[code][i]$1[/i][/code]');
|
|
rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi, '[quote][i]$1[/i][/quote]');
|
|
rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi, '[code][u]$1[/u][/code]');
|
|
rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi, '[quote][u]$1[/u][/quote]');
|
|
rep(/<\/(strong|b)>/gi, '[/b]');
|
|
rep(/<(strong|b)>/gi, '[b]');
|
|
rep(/<\/(em|i)>/gi, '[/i]');
|
|
rep(/<(em|i)>/gi, '[i]');
|
|
rep(/<\/u>/gi, '[/u]');
|
|
rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi, '[u]$1[/u]');
|
|
rep(/<u>/gi, '[u]');
|
|
rep(/<blockquote[^>]*>/gi, '[quote]');
|
|
rep(/<\/blockquote>/gi, '[/quote]');
|
|
rep(/<br \/>/gi, '\n');
|
|
rep(/<br\/>/gi, '\n');
|
|
rep(/<br>/gi, '\n');
|
|
rep(/<p>/gi, '');
|
|
rep(/<\/p>/gi, '\n');
|
|
rep(/ |\u00a0/gi, ' ');
|
|
rep(/"/gi, '"');
|
|
rep(/</gi, '<');
|
|
rep(/>/gi, '>');
|
|
rep(/&/gi, '&');
|
|
return s;
|
|
};
|
|
var bbcode2html = function (s) {
|
|
s = global.trim(s);
|
|
var rep = function (re, str) {
|
|
s = s.replace(re, str);
|
|
};
|
|
rep(/\n/gi, '<br />');
|
|
rep(/\[b\]/gi, '<strong>');
|
|
rep(/\[\/b\]/gi, '</strong>');
|
|
rep(/\[i\]/gi, '<em>');
|
|
rep(/\[\/i\]/gi, '</em>');
|
|
rep(/\[u\]/gi, '<u>');
|
|
rep(/\[\/u\]/gi, '</u>');
|
|
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi, '<a href="$1">$2</a>');
|
|
rep(/\[url\](.*?)\[\/url\]/gi, '<a href="$1">$1</a>');
|
|
rep(/\[img\](.*?)\[\/img\]/gi, '<img src="$1" />');
|
|
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi, '<font color="$1">$2</font>');
|
|
rep(/\[code\](.*?)\[\/code\]/gi, '<span class="codeStyle">$1</span> ');
|
|
rep(/\[quote.*?\](.*?)\[\/quote\]/gi, '<span class="quoteStyle">$1</span> ');
|
|
return s;
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('bbcode', function (editor) {
|
|
editor.on('BeforeSetContent', function (e) {
|
|
e.content = bbcode2html(e.content);
|
|
});
|
|
editor.on('PostProcess', function (e) {
|
|
if (e.set) {
|
|
e.content = bbcode2html(e.content);
|
|
}
|
|
if (e.get) {
|
|
e.content = html2bbcode(e.content);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var fireInsertCustomChar = function (editor, chr) {
|
|
return editor.fire('insertCustomChar', { chr: chr });
|
|
};
|
|
|
|
var insertChar = function (editor, chr) {
|
|
var evtChr = fireInsertCustomChar(editor, chr).chr;
|
|
editor.execCommand('mceInsertContent', false, evtChr);
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var eq = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isArray$1 = isType('array');
|
|
var isNull = eq(null);
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var nativePush = Array.prototype.push;
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray$1(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind = function (xs, f) {
|
|
return flatten(map(xs, f));
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getCharMap$1 = function (editor) {
|
|
return editor.getParam('charmap');
|
|
};
|
|
var getCharMapAppend = function (editor) {
|
|
return editor.getParam('charmap_append');
|
|
};
|
|
|
|
var isArray = global$1.isArray;
|
|
var UserDefined = 'User Defined';
|
|
var getDefaultCharMap = function () {
|
|
return [
|
|
{
|
|
name: 'Currency',
|
|
characters: [
|
|
[
|
|
36,
|
|
'dollar sign'
|
|
],
|
|
[
|
|
162,
|
|
'cent sign'
|
|
],
|
|
[
|
|
8364,
|
|
'euro sign'
|
|
],
|
|
[
|
|
163,
|
|
'pound sign'
|
|
],
|
|
[
|
|
165,
|
|
'yen sign'
|
|
],
|
|
[
|
|
164,
|
|
'currency sign'
|
|
],
|
|
[
|
|
8352,
|
|
'euro-currency sign'
|
|
],
|
|
[
|
|
8353,
|
|
'colon sign'
|
|
],
|
|
[
|
|
8354,
|
|
'cruzeiro sign'
|
|
],
|
|
[
|
|
8355,
|
|
'french franc sign'
|
|
],
|
|
[
|
|
8356,
|
|
'lira sign'
|
|
],
|
|
[
|
|
8357,
|
|
'mill sign'
|
|
],
|
|
[
|
|
8358,
|
|
'naira sign'
|
|
],
|
|
[
|
|
8359,
|
|
'peseta sign'
|
|
],
|
|
[
|
|
8360,
|
|
'rupee sign'
|
|
],
|
|
[
|
|
8361,
|
|
'won sign'
|
|
],
|
|
[
|
|
8362,
|
|
'new sheqel sign'
|
|
],
|
|
[
|
|
8363,
|
|
'dong sign'
|
|
],
|
|
[
|
|
8365,
|
|
'kip sign'
|
|
],
|
|
[
|
|
8366,
|
|
'tugrik sign'
|
|
],
|
|
[
|
|
8367,
|
|
'drachma sign'
|
|
],
|
|
[
|
|
8368,
|
|
'german penny symbol'
|
|
],
|
|
[
|
|
8369,
|
|
'peso sign'
|
|
],
|
|
[
|
|
8370,
|
|
'guarani sign'
|
|
],
|
|
[
|
|
8371,
|
|
'austral sign'
|
|
],
|
|
[
|
|
8372,
|
|
'hryvnia sign'
|
|
],
|
|
[
|
|
8373,
|
|
'cedi sign'
|
|
],
|
|
[
|
|
8374,
|
|
'livre tournois sign'
|
|
],
|
|
[
|
|
8375,
|
|
'spesmilo sign'
|
|
],
|
|
[
|
|
8376,
|
|
'tenge sign'
|
|
],
|
|
[
|
|
8377,
|
|
'indian rupee sign'
|
|
],
|
|
[
|
|
8378,
|
|
'turkish lira sign'
|
|
],
|
|
[
|
|
8379,
|
|
'nordic mark sign'
|
|
],
|
|
[
|
|
8380,
|
|
'manat sign'
|
|
],
|
|
[
|
|
8381,
|
|
'ruble sign'
|
|
],
|
|
[
|
|
20870,
|
|
'yen character'
|
|
],
|
|
[
|
|
20803,
|
|
'yuan character'
|
|
],
|
|
[
|
|
22291,
|
|
'yuan character, in hong kong and taiwan'
|
|
],
|
|
[
|
|
22278,
|
|
'yen/yuan character variant one'
|
|
]
|
|
]
|
|
},
|
|
{
|
|
name: 'Text',
|
|
characters: [
|
|
[
|
|
169,
|
|
'copyright sign'
|
|
],
|
|
[
|
|
174,
|
|
'registered sign'
|
|
],
|
|
[
|
|
8482,
|
|
'trade mark sign'
|
|
],
|
|
[
|
|
8240,
|
|
'per mille sign'
|
|
],
|
|
[
|
|
181,
|
|
'micro sign'
|
|
],
|
|
[
|
|
183,
|
|
'middle dot'
|
|
],
|
|
[
|
|
8226,
|
|
'bullet'
|
|
],
|
|
[
|
|
8230,
|
|
'three dot leader'
|
|
],
|
|
[
|
|
8242,
|
|
'minutes / feet'
|
|
],
|
|
[
|
|
8243,
|
|
'seconds / inches'
|
|
],
|
|
[
|
|
167,
|
|
'section sign'
|
|
],
|
|
[
|
|
182,
|
|
'paragraph sign'
|
|
],
|
|
[
|
|
223,
|
|
'sharp s / ess-zed'
|
|
]
|
|
]
|
|
},
|
|
{
|
|
name: 'Quotations',
|
|
characters: [
|
|
[
|
|
8249,
|
|
'single left-pointing angle quotation mark'
|
|
],
|
|
[
|
|
8250,
|
|
'single right-pointing angle quotation mark'
|
|
],
|
|
[
|
|
171,
|
|
'left pointing guillemet'
|
|
],
|
|
[
|
|
187,
|
|
'right pointing guillemet'
|
|
],
|
|
[
|
|
8216,
|
|
'left single quotation mark'
|
|
],
|
|
[
|
|
8217,
|
|
'right single quotation mark'
|
|
],
|
|
[
|
|
8220,
|
|
'left double quotation mark'
|
|
],
|
|
[
|
|
8221,
|
|
'right double quotation mark'
|
|
],
|
|
[
|
|
8218,
|
|
'single low-9 quotation mark'
|
|
],
|
|
[
|
|
8222,
|
|
'double low-9 quotation mark'
|
|
],
|
|
[
|
|
60,
|
|
'less-than sign'
|
|
],
|
|
[
|
|
62,
|
|
'greater-than sign'
|
|
],
|
|
[
|
|
8804,
|
|
'less-than or equal to'
|
|
],
|
|
[
|
|
8805,
|
|
'greater-than or equal to'
|
|
],
|
|
[
|
|
8211,
|
|
'en dash'
|
|
],
|
|
[
|
|
8212,
|
|
'em dash'
|
|
],
|
|
[
|
|
175,
|
|
'macron'
|
|
],
|
|
[
|
|
8254,
|
|
'overline'
|
|
],
|
|
[
|
|
164,
|
|
'currency sign'
|
|
],
|
|
[
|
|
166,
|
|
'broken bar'
|
|
],
|
|
[
|
|
168,
|
|
'diaeresis'
|
|
],
|
|
[
|
|
161,
|
|
'inverted exclamation mark'
|
|
],
|
|
[
|
|
191,
|
|
'turned question mark'
|
|
],
|
|
[
|
|
710,
|
|
'circumflex accent'
|
|
],
|
|
[
|
|
732,
|
|
'small tilde'
|
|
],
|
|
[
|
|
176,
|
|
'degree sign'
|
|
],
|
|
[
|
|
8722,
|
|
'minus sign'
|
|
],
|
|
[
|
|
177,
|
|
'plus-minus sign'
|
|
],
|
|
[
|
|
247,
|
|
'division sign'
|
|
],
|
|
[
|
|
8260,
|
|
'fraction slash'
|
|
],
|
|
[
|
|
215,
|
|
'multiplication sign'
|
|
],
|
|
[
|
|
185,
|
|
'superscript one'
|
|
],
|
|
[
|
|
178,
|
|
'superscript two'
|
|
],
|
|
[
|
|
179,
|
|
'superscript three'
|
|
],
|
|
[
|
|
188,
|
|
'fraction one quarter'
|
|
],
|
|
[
|
|
189,
|
|
'fraction one half'
|
|
],
|
|
[
|
|
190,
|
|
'fraction three quarters'
|
|
]
|
|
]
|
|
},
|
|
{
|
|
name: 'Mathematical',
|
|
characters: [
|
|
[
|
|
402,
|
|
'function / florin'
|
|
],
|
|
[
|
|
8747,
|
|
'integral'
|
|
],
|
|
[
|
|
8721,
|
|
'n-ary sumation'
|
|
],
|
|
[
|
|
8734,
|
|
'infinity'
|
|
],
|
|
[
|
|
8730,
|
|
'square root'
|
|
],
|
|
[
|
|
8764,
|
|
'similar to'
|
|
],
|
|
[
|
|
8773,
|
|
'approximately equal to'
|
|
],
|
|
[
|
|
8776,
|
|
'almost equal to'
|
|
],
|
|
[
|
|
8800,
|
|
'not equal to'
|
|
],
|
|
[
|
|
8801,
|
|
'identical to'
|
|
],
|
|
[
|
|
8712,
|
|
'element of'
|
|
],
|
|
[
|
|
8713,
|
|
'not an element of'
|
|
],
|
|
[
|
|
8715,
|
|
'contains as member'
|
|
],
|
|
[
|
|
8719,
|
|
'n-ary product'
|
|
],
|
|
[
|
|
8743,
|
|
'logical and'
|
|
],
|
|
[
|
|
8744,
|
|
'logical or'
|
|
],
|
|
[
|
|
172,
|
|
'not sign'
|
|
],
|
|
[
|
|
8745,
|
|
'intersection'
|
|
],
|
|
[
|
|
8746,
|
|
'union'
|
|
],
|
|
[
|
|
8706,
|
|
'partial differential'
|
|
],
|
|
[
|
|
8704,
|
|
'for all'
|
|
],
|
|
[
|
|
8707,
|
|
'there exists'
|
|
],
|
|
[
|
|
8709,
|
|
'diameter'
|
|
],
|
|
[
|
|
8711,
|
|
'backward difference'
|
|
],
|
|
[
|
|
8727,
|
|
'asterisk operator'
|
|
],
|
|
[
|
|
8733,
|
|
'proportional to'
|
|
],
|
|
[
|
|
8736,
|
|
'angle'
|
|
]
|
|
]
|
|
},
|
|
{
|
|
name: 'Extended Latin',
|
|
characters: [
|
|
[
|
|
192,
|
|
'A - grave'
|
|
],
|
|
[
|
|
193,
|
|
'A - acute'
|
|
],
|
|
[
|
|
194,
|
|
'A - circumflex'
|
|
],
|
|
[
|
|
195,
|
|
'A - tilde'
|
|
],
|
|
[
|
|
196,
|
|
'A - diaeresis'
|
|
],
|
|
[
|
|
197,
|
|
'A - ring above'
|
|
],
|
|
[
|
|
256,
|
|
'A - macron'
|
|
],
|
|
[
|
|
198,
|
|
'ligature AE'
|
|
],
|
|
[
|
|
199,
|
|
'C - cedilla'
|
|
],
|
|
[
|
|
200,
|
|
'E - grave'
|
|
],
|
|
[
|
|
201,
|
|
'E - acute'
|
|
],
|
|
[
|
|
202,
|
|
'E - circumflex'
|
|
],
|
|
[
|
|
203,
|
|
'E - diaeresis'
|
|
],
|
|
[
|
|
274,
|
|
'E - macron'
|
|
],
|
|
[
|
|
204,
|
|
'I - grave'
|
|
],
|
|
[
|
|
205,
|
|
'I - acute'
|
|
],
|
|
[
|
|
206,
|
|
'I - circumflex'
|
|
],
|
|
[
|
|
207,
|
|
'I - diaeresis'
|
|
],
|
|
[
|
|
298,
|
|
'I - macron'
|
|
],
|
|
[
|
|
208,
|
|
'ETH'
|
|
],
|
|
[
|
|
209,
|
|
'N - tilde'
|
|
],
|
|
[
|
|
210,
|
|
'O - grave'
|
|
],
|
|
[
|
|
211,
|
|
'O - acute'
|
|
],
|
|
[
|
|
212,
|
|
'O - circumflex'
|
|
],
|
|
[
|
|
213,
|
|
'O - tilde'
|
|
],
|
|
[
|
|
214,
|
|
'O - diaeresis'
|
|
],
|
|
[
|
|
216,
|
|
'O - slash'
|
|
],
|
|
[
|
|
332,
|
|
'O - macron'
|
|
],
|
|
[
|
|
338,
|
|
'ligature OE'
|
|
],
|
|
[
|
|
352,
|
|
'S - caron'
|
|
],
|
|
[
|
|
217,
|
|
'U - grave'
|
|
],
|
|
[
|
|
218,
|
|
'U - acute'
|
|
],
|
|
[
|
|
219,
|
|
'U - circumflex'
|
|
],
|
|
[
|
|
220,
|
|
'U - diaeresis'
|
|
],
|
|
[
|
|
362,
|
|
'U - macron'
|
|
],
|
|
[
|
|
221,
|
|
'Y - acute'
|
|
],
|
|
[
|
|
376,
|
|
'Y - diaeresis'
|
|
],
|
|
[
|
|
562,
|
|
'Y - macron'
|
|
],
|
|
[
|
|
222,
|
|
'THORN'
|
|
],
|
|
[
|
|
224,
|
|
'a - grave'
|
|
],
|
|
[
|
|
225,
|
|
'a - acute'
|
|
],
|
|
[
|
|
226,
|
|
'a - circumflex'
|
|
],
|
|
[
|
|
227,
|
|
'a - tilde'
|
|
],
|
|
[
|
|
228,
|
|
'a - diaeresis'
|
|
],
|
|
[
|
|
229,
|
|
'a - ring above'
|
|
],
|
|
[
|
|
257,
|
|
'a - macron'
|
|
],
|
|
[
|
|
230,
|
|
'ligature ae'
|
|
],
|
|
[
|
|
231,
|
|
'c - cedilla'
|
|
],
|
|
[
|
|
232,
|
|
'e - grave'
|
|
],
|
|
[
|
|
233,
|
|
'e - acute'
|
|
],
|
|
[
|
|
234,
|
|
'e - circumflex'
|
|
],
|
|
[
|
|
235,
|
|
'e - diaeresis'
|
|
],
|
|
[
|
|
275,
|
|
'e - macron'
|
|
],
|
|
[
|
|
236,
|
|
'i - grave'
|
|
],
|
|
[
|
|
237,
|
|
'i - acute'
|
|
],
|
|
[
|
|
238,
|
|
'i - circumflex'
|
|
],
|
|
[
|
|
239,
|
|
'i - diaeresis'
|
|
],
|
|
[
|
|
299,
|
|
'i - macron'
|
|
],
|
|
[
|
|
240,
|
|
'eth'
|
|
],
|
|
[
|
|
241,
|
|
'n - tilde'
|
|
],
|
|
[
|
|
242,
|
|
'o - grave'
|
|
],
|
|
[
|
|
243,
|
|
'o - acute'
|
|
],
|
|
[
|
|
244,
|
|
'o - circumflex'
|
|
],
|
|
[
|
|
245,
|
|
'o - tilde'
|
|
],
|
|
[
|
|
246,
|
|
'o - diaeresis'
|
|
],
|
|
[
|
|
248,
|
|
'o slash'
|
|
],
|
|
[
|
|
333,
|
|
'o macron'
|
|
],
|
|
[
|
|
339,
|
|
'ligature oe'
|
|
],
|
|
[
|
|
353,
|
|
's - caron'
|
|
],
|
|
[
|
|
249,
|
|
'u - grave'
|
|
],
|
|
[
|
|
250,
|
|
'u - acute'
|
|
],
|
|
[
|
|
251,
|
|
'u - circumflex'
|
|
],
|
|
[
|
|
252,
|
|
'u - diaeresis'
|
|
],
|
|
[
|
|
363,
|
|
'u - macron'
|
|
],
|
|
[
|
|
253,
|
|
'y - acute'
|
|
],
|
|
[
|
|
254,
|
|
'thorn'
|
|
],
|
|
[
|
|
255,
|
|
'y - diaeresis'
|
|
],
|
|
[
|
|
563,
|
|
'y - macron'
|
|
],
|
|
[
|
|
913,
|
|
'Alpha'
|
|
],
|
|
[
|
|
914,
|
|
'Beta'
|
|
],
|
|
[
|
|
915,
|
|
'Gamma'
|
|
],
|
|
[
|
|
916,
|
|
'Delta'
|
|
],
|
|
[
|
|
917,
|
|
'Epsilon'
|
|
],
|
|
[
|
|
918,
|
|
'Zeta'
|
|
],
|
|
[
|
|
919,
|
|
'Eta'
|
|
],
|
|
[
|
|
920,
|
|
'Theta'
|
|
],
|
|
[
|
|
921,
|
|
'Iota'
|
|
],
|
|
[
|
|
922,
|
|
'Kappa'
|
|
],
|
|
[
|
|
923,
|
|
'Lambda'
|
|
],
|
|
[
|
|
924,
|
|
'Mu'
|
|
],
|
|
[
|
|
925,
|
|
'Nu'
|
|
],
|
|
[
|
|
926,
|
|
'Xi'
|
|
],
|
|
[
|
|
927,
|
|
'Omicron'
|
|
],
|
|
[
|
|
928,
|
|
'Pi'
|
|
],
|
|
[
|
|
929,
|
|
'Rho'
|
|
],
|
|
[
|
|
931,
|
|
'Sigma'
|
|
],
|
|
[
|
|
932,
|
|
'Tau'
|
|
],
|
|
[
|
|
933,
|
|
'Upsilon'
|
|
],
|
|
[
|
|
934,
|
|
'Phi'
|
|
],
|
|
[
|
|
935,
|
|
'Chi'
|
|
],
|
|
[
|
|
936,
|
|
'Psi'
|
|
],
|
|
[
|
|
937,
|
|
'Omega'
|
|
],
|
|
[
|
|
945,
|
|
'alpha'
|
|
],
|
|
[
|
|
946,
|
|
'beta'
|
|
],
|
|
[
|
|
947,
|
|
'gamma'
|
|
],
|
|
[
|
|
948,
|
|
'delta'
|
|
],
|
|
[
|
|
949,
|
|
'epsilon'
|
|
],
|
|
[
|
|
950,
|
|
'zeta'
|
|
],
|
|
[
|
|
951,
|
|
'eta'
|
|
],
|
|
[
|
|
952,
|
|
'theta'
|
|
],
|
|
[
|
|
953,
|
|
'iota'
|
|
],
|
|
[
|
|
954,
|
|
'kappa'
|
|
],
|
|
[
|
|
955,
|
|
'lambda'
|
|
],
|
|
[
|
|
956,
|
|
'mu'
|
|
],
|
|
[
|
|
957,
|
|
'nu'
|
|
],
|
|
[
|
|
958,
|
|
'xi'
|
|
],
|
|
[
|
|
959,
|
|
'omicron'
|
|
],
|
|
[
|
|
960,
|
|
'pi'
|
|
],
|
|
[
|
|
961,
|
|
'rho'
|
|
],
|
|
[
|
|
962,
|
|
'final sigma'
|
|
],
|
|
[
|
|
963,
|
|
'sigma'
|
|
],
|
|
[
|
|
964,
|
|
'tau'
|
|
],
|
|
[
|
|
965,
|
|
'upsilon'
|
|
],
|
|
[
|
|
966,
|
|
'phi'
|
|
],
|
|
[
|
|
967,
|
|
'chi'
|
|
],
|
|
[
|
|
968,
|
|
'psi'
|
|
],
|
|
[
|
|
969,
|
|
'omega'
|
|
]
|
|
]
|
|
},
|
|
{
|
|
name: 'Symbols',
|
|
characters: [
|
|
[
|
|
8501,
|
|
'alef symbol'
|
|
],
|
|
[
|
|
982,
|
|
'pi symbol'
|
|
],
|
|
[
|
|
8476,
|
|
'real part symbol'
|
|
],
|
|
[
|
|
978,
|
|
'upsilon - hook symbol'
|
|
],
|
|
[
|
|
8472,
|
|
'Weierstrass p'
|
|
],
|
|
[
|
|
8465,
|
|
'imaginary part'
|
|
]
|
|
]
|
|
},
|
|
{
|
|
name: 'Arrows',
|
|
characters: [
|
|
[
|
|
8592,
|
|
'leftwards arrow'
|
|
],
|
|
[
|
|
8593,
|
|
'upwards arrow'
|
|
],
|
|
[
|
|
8594,
|
|
'rightwards arrow'
|
|
],
|
|
[
|
|
8595,
|
|
'downwards arrow'
|
|
],
|
|
[
|
|
8596,
|
|
'left right arrow'
|
|
],
|
|
[
|
|
8629,
|
|
'carriage return'
|
|
],
|
|
[
|
|
8656,
|
|
'leftwards double arrow'
|
|
],
|
|
[
|
|
8657,
|
|
'upwards double arrow'
|
|
],
|
|
[
|
|
8658,
|
|
'rightwards double arrow'
|
|
],
|
|
[
|
|
8659,
|
|
'downwards double arrow'
|
|
],
|
|
[
|
|
8660,
|
|
'left right double arrow'
|
|
],
|
|
[
|
|
8756,
|
|
'therefore'
|
|
],
|
|
[
|
|
8834,
|
|
'subset of'
|
|
],
|
|
[
|
|
8835,
|
|
'superset of'
|
|
],
|
|
[
|
|
8836,
|
|
'not a subset of'
|
|
],
|
|
[
|
|
8838,
|
|
'subset of or equal to'
|
|
],
|
|
[
|
|
8839,
|
|
'superset of or equal to'
|
|
],
|
|
[
|
|
8853,
|
|
'circled plus'
|
|
],
|
|
[
|
|
8855,
|
|
'circled times'
|
|
],
|
|
[
|
|
8869,
|
|
'perpendicular'
|
|
],
|
|
[
|
|
8901,
|
|
'dot operator'
|
|
],
|
|
[
|
|
8968,
|
|
'left ceiling'
|
|
],
|
|
[
|
|
8969,
|
|
'right ceiling'
|
|
],
|
|
[
|
|
8970,
|
|
'left floor'
|
|
],
|
|
[
|
|
8971,
|
|
'right floor'
|
|
],
|
|
[
|
|
9001,
|
|
'left-pointing angle bracket'
|
|
],
|
|
[
|
|
9002,
|
|
'right-pointing angle bracket'
|
|
],
|
|
[
|
|
9674,
|
|
'lozenge'
|
|
],
|
|
[
|
|
9824,
|
|
'black spade suit'
|
|
],
|
|
[
|
|
9827,
|
|
'black club suit'
|
|
],
|
|
[
|
|
9829,
|
|
'black heart suit'
|
|
],
|
|
[
|
|
9830,
|
|
'black diamond suit'
|
|
],
|
|
[
|
|
8194,
|
|
'en space'
|
|
],
|
|
[
|
|
8195,
|
|
'em space'
|
|
],
|
|
[
|
|
8201,
|
|
'thin space'
|
|
],
|
|
[
|
|
8204,
|
|
'zero width non-joiner'
|
|
],
|
|
[
|
|
8205,
|
|
'zero width joiner'
|
|
],
|
|
[
|
|
8206,
|
|
'left-to-right mark'
|
|
],
|
|
[
|
|
8207,
|
|
'right-to-left mark'
|
|
]
|
|
]
|
|
}
|
|
];
|
|
};
|
|
var charmapFilter = function (charmap) {
|
|
return global$1.grep(charmap, function (item) {
|
|
return isArray(item) && item.length === 2;
|
|
});
|
|
};
|
|
var getCharsFromSetting = function (settingValue) {
|
|
if (isArray(settingValue)) {
|
|
return charmapFilter(settingValue);
|
|
}
|
|
if (typeof settingValue === 'function') {
|
|
return settingValue();
|
|
}
|
|
return [];
|
|
};
|
|
var extendCharMap = function (editor, charmap) {
|
|
var userCharMap = getCharMap$1(editor);
|
|
if (userCharMap) {
|
|
charmap = [{
|
|
name: UserDefined,
|
|
characters: getCharsFromSetting(userCharMap)
|
|
}];
|
|
}
|
|
var userCharMapAppend = getCharMapAppend(editor);
|
|
if (userCharMapAppend) {
|
|
var userDefinedGroup = global$1.grep(charmap, function (cg) {
|
|
return cg.name === UserDefined;
|
|
});
|
|
if (userDefinedGroup.length) {
|
|
userDefinedGroup[0].characters = [].concat(userDefinedGroup[0].characters).concat(getCharsFromSetting(userCharMapAppend));
|
|
return charmap;
|
|
}
|
|
return charmap.concat({
|
|
name: UserDefined,
|
|
characters: getCharsFromSetting(userCharMapAppend)
|
|
});
|
|
}
|
|
return charmap;
|
|
};
|
|
var getCharMap = function (editor) {
|
|
var groups = extendCharMap(editor, getDefaultCharMap());
|
|
return groups.length > 1 ? [{
|
|
name: 'All',
|
|
characters: bind(groups, function (g) {
|
|
return g.characters;
|
|
})
|
|
}].concat(groups) : groups;
|
|
};
|
|
|
|
var get = function (editor) {
|
|
var getCharMap$1 = function () {
|
|
return getCharMap(editor);
|
|
};
|
|
var insertChar$1 = function (chr) {
|
|
insertChar(editor, chr);
|
|
};
|
|
return {
|
|
getCharMap: getCharMap$1,
|
|
insertChar: insertChar$1
|
|
};
|
|
};
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var last = function (fn, rate) {
|
|
var timer = null;
|
|
var cancel = function () {
|
|
if (!isNull(timer)) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
};
|
|
var throttle = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
cancel();
|
|
timer = setTimeout(function () {
|
|
timer = null;
|
|
fn.apply(null, args);
|
|
}, rate);
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
throttle: throttle
|
|
};
|
|
};
|
|
|
|
var nativeFromCodePoint = String.fromCodePoint;
|
|
var contains = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
var fromCodePoint = function () {
|
|
var codePoints = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
codePoints[_i] = arguments[_i];
|
|
}
|
|
if (nativeFromCodePoint) {
|
|
return nativeFromCodePoint.apply(void 0, codePoints);
|
|
} else {
|
|
var codeUnits = [];
|
|
var codeLen = 0;
|
|
var result = '';
|
|
for (var index = 0, len = codePoints.length; index !== len; ++index) {
|
|
var codePoint = +codePoints[index];
|
|
if (!(codePoint < 1114111 && codePoint >>> 0 === codePoint)) {
|
|
throw RangeError('Invalid code point: ' + codePoint);
|
|
}
|
|
if (codePoint <= 65535) {
|
|
codeLen = codeUnits.push(codePoint);
|
|
} else {
|
|
codePoint -= 65536;
|
|
codeLen = codeUnits.push((codePoint >> 10) + 55296, codePoint % 1024 + 56320);
|
|
}
|
|
if (codeLen >= 16383) {
|
|
result += String.fromCharCode.apply(null, codeUnits);
|
|
codeUnits.length = 0;
|
|
}
|
|
}
|
|
return result + String.fromCharCode.apply(null, codeUnits);
|
|
}
|
|
};
|
|
|
|
var charMatches = function (charCode, name, lowerCasePattern) {
|
|
if (contains(fromCodePoint(charCode).toLowerCase(), lowerCasePattern)) {
|
|
return true;
|
|
} else {
|
|
return contains(name.toLowerCase(), lowerCasePattern) || contains(name.toLowerCase().replace(/\s+/g, ''), lowerCasePattern);
|
|
}
|
|
};
|
|
var scan = function (group, pattern) {
|
|
var matches = [];
|
|
var lowerCasePattern = pattern.toLowerCase();
|
|
each(group.characters, function (g) {
|
|
if (charMatches(g[0], g[1], lowerCasePattern)) {
|
|
matches.push(g);
|
|
}
|
|
});
|
|
return map(matches, function (m) {
|
|
return {
|
|
text: m[1],
|
|
value: fromCodePoint(m[0]),
|
|
icon: fromCodePoint(m[0])
|
|
};
|
|
});
|
|
};
|
|
|
|
var patternName = 'pattern';
|
|
var open = function (editor, charMap) {
|
|
var makeGroupItems = function () {
|
|
return [
|
|
{
|
|
label: 'Search',
|
|
type: 'input',
|
|
name: patternName
|
|
},
|
|
{
|
|
type: 'collection',
|
|
name: 'results'
|
|
}
|
|
];
|
|
};
|
|
var makeTabs = function () {
|
|
return map(charMap, function (charGroup) {
|
|
return {
|
|
title: charGroup.name,
|
|
name: charGroup.name,
|
|
items: makeGroupItems()
|
|
};
|
|
});
|
|
};
|
|
var makePanel = function () {
|
|
return {
|
|
type: 'panel',
|
|
items: makeGroupItems()
|
|
};
|
|
};
|
|
var makeTabPanel = function () {
|
|
return {
|
|
type: 'tabpanel',
|
|
tabs: makeTabs()
|
|
};
|
|
};
|
|
var currentTab = charMap.length === 1 ? Cell(UserDefined) : Cell('All');
|
|
var scanAndSet = function (dialogApi, pattern) {
|
|
find(charMap, function (group) {
|
|
return group.name === currentTab.get();
|
|
}).each(function (f) {
|
|
var items = scan(f, pattern);
|
|
dialogApi.setData({ results: items });
|
|
});
|
|
};
|
|
var SEARCH_DELAY = 40;
|
|
var updateFilter = last(function (dialogApi) {
|
|
var pattern = dialogApi.getData().pattern;
|
|
scanAndSet(dialogApi, pattern);
|
|
}, SEARCH_DELAY);
|
|
var body = charMap.length === 1 ? makePanel() : makeTabPanel();
|
|
var initialData = {
|
|
pattern: '',
|
|
results: scan(charMap[0], '')
|
|
};
|
|
var bridgeSpec = {
|
|
title: 'Special Character',
|
|
size: 'normal',
|
|
body: body,
|
|
buttons: [{
|
|
type: 'cancel',
|
|
name: 'close',
|
|
text: 'Close',
|
|
primary: true
|
|
}],
|
|
initialData: initialData,
|
|
onAction: function (api, details) {
|
|
if (details.name === 'results') {
|
|
insertChar(editor, details.value);
|
|
api.close();
|
|
}
|
|
},
|
|
onTabChange: function (dialogApi, details) {
|
|
currentTab.set(details.newTabName);
|
|
updateFilter.throttle(dialogApi);
|
|
},
|
|
onChange: function (dialogApi, changeData) {
|
|
if (changeData.name === patternName) {
|
|
updateFilter.throttle(dialogApi);
|
|
}
|
|
}
|
|
};
|
|
var dialogApi = editor.windowManager.open(bridgeSpec);
|
|
dialogApi.focus(patternName);
|
|
};
|
|
|
|
var register$1 = function (editor, charMap) {
|
|
editor.addCommand('mceShowCharmap', function () {
|
|
open(editor, charMap);
|
|
});
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var init = function (editor, all) {
|
|
editor.ui.registry.addAutocompleter('charmap', {
|
|
ch: ':',
|
|
columns: 'auto',
|
|
minChars: 2,
|
|
fetch: function (pattern, _maxResults) {
|
|
return new global(function (resolve, _reject) {
|
|
resolve(scan(all, pattern));
|
|
});
|
|
},
|
|
onAction: function (autocompleteApi, rng, value) {
|
|
editor.selection.setRng(rng);
|
|
editor.insertContent(value);
|
|
autocompleteApi.hide();
|
|
}
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
editor.ui.registry.addButton('charmap', {
|
|
icon: 'insert-character',
|
|
tooltip: 'Special character',
|
|
onAction: function () {
|
|
return editor.execCommand('mceShowCharmap');
|
|
}
|
|
});
|
|
editor.ui.registry.addMenuItem('charmap', {
|
|
icon: 'insert-character',
|
|
text: 'Special character...',
|
|
onAction: function () {
|
|
return editor.execCommand('mceShowCharmap');
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$2.add('charmap', function (editor) {
|
|
var charMap = getCharMap(editor);
|
|
register$1(editor, charMap);
|
|
register(editor);
|
|
init(editor, charMap[0]);
|
|
return get(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var get$1 = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get$1(xs, 0);
|
|
};
|
|
|
|
var someIf = function (b, a) {
|
|
return b ? Optional.some(a) : Optional.none();
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var isCodeSample = function (elm) {
|
|
return elm && elm.nodeName === 'PRE' && elm.className.indexOf('language-') !== -1;
|
|
};
|
|
var trimArg = function (predicateFn) {
|
|
return function (arg1, arg2) {
|
|
return predicateFn(arg2);
|
|
};
|
|
};
|
|
|
|
var Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var exports$1 = {}, module = { exports: exports$1 }, global = {};
|
|
(function (define, exports, module, require) {
|
|
var oldprism = window.Prism;
|
|
window.Prism = { manual: true };
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EphoxContactWrapper = factory());
|
|
}(this, function () {
|
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
var prismCore = { exports: {} };
|
|
(function (module) {
|
|
var _self = typeof window !== 'undefined' ? window : typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : {};
|
|
var Prism = function (_self) {
|
|
var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
|
|
var uniqueId = 0;
|
|
var plainTextGrammar = {};
|
|
var _ = {
|
|
manual: _self.Prism && _self.Prism.manual,
|
|
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
|
|
util: {
|
|
encode: function encode(tokens) {
|
|
if (tokens instanceof Token) {
|
|
return new Token(tokens.type, encode(tokens.content), tokens.alias);
|
|
} else if (Array.isArray(tokens)) {
|
|
return tokens.map(encode);
|
|
} else {
|
|
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
|
|
}
|
|
},
|
|
type: function (o) {
|
|
return Object.prototype.toString.call(o).slice(8, -1);
|
|
},
|
|
objId: function (obj) {
|
|
if (!obj['__id']) {
|
|
Object.defineProperty(obj, '__id', { value: ++uniqueId });
|
|
}
|
|
return obj['__id'];
|
|
},
|
|
clone: function deepClone(o, visited) {
|
|
visited = visited || {};
|
|
var clone;
|
|
var id;
|
|
switch (_.util.type(o)) {
|
|
case 'Object':
|
|
id = _.util.objId(o);
|
|
if (visited[id]) {
|
|
return visited[id];
|
|
}
|
|
clone = {};
|
|
visited[id] = clone;
|
|
for (var key in o) {
|
|
if (o.hasOwnProperty(key)) {
|
|
clone[key] = deepClone(o[key], visited);
|
|
}
|
|
}
|
|
return clone;
|
|
case 'Array':
|
|
id = _.util.objId(o);
|
|
if (visited[id]) {
|
|
return visited[id];
|
|
}
|
|
clone = [];
|
|
visited[id] = clone;
|
|
o.forEach(function (v, i) {
|
|
clone[i] = deepClone(v, visited);
|
|
});
|
|
return clone;
|
|
default:
|
|
return o;
|
|
}
|
|
},
|
|
getLanguage: function (element) {
|
|
while (element) {
|
|
var m = lang.exec(element.className);
|
|
if (m) {
|
|
return m[1].toLowerCase();
|
|
}
|
|
element = element.parentElement;
|
|
}
|
|
return 'none';
|
|
},
|
|
setLanguage: function (element, language) {
|
|
element.className = element.className.replace(RegExp(lang.source, 'gi'), '');
|
|
element.classList.add('language-' + language);
|
|
},
|
|
currentScript: function () {
|
|
if (typeof document === 'undefined') {
|
|
return null;
|
|
}
|
|
if ('currentScript' in document && 1 < 2) {
|
|
return document.currentScript;
|
|
}
|
|
try {
|
|
throw new Error();
|
|
} catch (err) {
|
|
var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
|
|
if (src) {
|
|
var scripts = document.getElementsByTagName('script');
|
|
for (var i in scripts) {
|
|
if (scripts[i].src == src) {
|
|
return scripts[i];
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
},
|
|
isActive: function (element, className, defaultActivation) {
|
|
var no = 'no-' + className;
|
|
while (element) {
|
|
var classList = element.classList;
|
|
if (classList.contains(className)) {
|
|
return true;
|
|
}
|
|
if (classList.contains(no)) {
|
|
return false;
|
|
}
|
|
element = element.parentElement;
|
|
}
|
|
return !!defaultActivation;
|
|
}
|
|
},
|
|
languages: {
|
|
plain: plainTextGrammar,
|
|
plaintext: plainTextGrammar,
|
|
text: plainTextGrammar,
|
|
txt: plainTextGrammar,
|
|
extend: function (id, redef) {
|
|
var lang = _.util.clone(_.languages[id]);
|
|
for (var key in redef) {
|
|
lang[key] = redef[key];
|
|
}
|
|
return lang;
|
|
},
|
|
insertBefore: function (inside, before, insert, root) {
|
|
root = root || _.languages;
|
|
var grammar = root[inside];
|
|
var ret = {};
|
|
for (var token in grammar) {
|
|
if (grammar.hasOwnProperty(token)) {
|
|
if (token == before) {
|
|
for (var newToken in insert) {
|
|
if (insert.hasOwnProperty(newToken)) {
|
|
ret[newToken] = insert[newToken];
|
|
}
|
|
}
|
|
}
|
|
if (!insert.hasOwnProperty(token)) {
|
|
ret[token] = grammar[token];
|
|
}
|
|
}
|
|
}
|
|
var old = root[inside];
|
|
root[inside] = ret;
|
|
_.languages.DFS(_.languages, function (key, value) {
|
|
if (value === old && key != inside) {
|
|
this[key] = ret;
|
|
}
|
|
});
|
|
return ret;
|
|
},
|
|
DFS: function DFS(o, callback, type, visited) {
|
|
visited = visited || {};
|
|
var objId = _.util.objId;
|
|
for (var i in o) {
|
|
if (o.hasOwnProperty(i)) {
|
|
callback.call(o, i, o[i], type || i);
|
|
var property = o[i];
|
|
var propertyType = _.util.type(property);
|
|
if (propertyType === 'Object' && !visited[objId(property)]) {
|
|
visited[objId(property)] = true;
|
|
DFS(property, callback, null, visited);
|
|
} else if (propertyType === 'Array' && !visited[objId(property)]) {
|
|
visited[objId(property)] = true;
|
|
DFS(property, callback, i, visited);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
plugins: {},
|
|
highlightAll: function (async, callback) {
|
|
_.highlightAllUnder(document, async, callback);
|
|
},
|
|
highlightAllUnder: function (container, async, callback) {
|
|
var env = {
|
|
callback: callback,
|
|
container: container,
|
|
selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
|
|
};
|
|
_.hooks.run('before-highlightall', env);
|
|
env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
|
|
_.hooks.run('before-all-elements-highlight', env);
|
|
for (var i = 0, element; element = env.elements[i++];) {
|
|
_.highlightElement(element, async === true, env.callback);
|
|
}
|
|
},
|
|
highlightElement: function (element, async, callback) {
|
|
var language = _.util.getLanguage(element);
|
|
var grammar = _.languages[language];
|
|
_.util.setLanguage(element, language);
|
|
var parent = element.parentElement;
|
|
if (parent && parent.nodeName.toLowerCase() === 'pre') {
|
|
_.util.setLanguage(parent, language);
|
|
}
|
|
var code = element.textContent;
|
|
var env = {
|
|
element: element,
|
|
language: language,
|
|
grammar: grammar,
|
|
code: code
|
|
};
|
|
function insertHighlightedCode(highlightedCode) {
|
|
env.highlightedCode = highlightedCode;
|
|
_.hooks.run('before-insert', env);
|
|
env.element.innerHTML = env.highlightedCode;
|
|
_.hooks.run('after-highlight', env);
|
|
_.hooks.run('complete', env);
|
|
callback && callback.call(env.element);
|
|
}
|
|
_.hooks.run('before-sanity-check', env);
|
|
parent = env.element.parentElement;
|
|
if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
|
|
parent.setAttribute('tabindex', '0');
|
|
}
|
|
if (!env.code) {
|
|
_.hooks.run('complete', env);
|
|
callback && callback.call(env.element);
|
|
return;
|
|
}
|
|
_.hooks.run('before-highlight', env);
|
|
if (!env.grammar) {
|
|
insertHighlightedCode(_.util.encode(env.code));
|
|
return;
|
|
}
|
|
if (async && _self.Worker) {
|
|
var worker = new Worker(_.filename);
|
|
worker.onmessage = function (evt) {
|
|
insertHighlightedCode(evt.data);
|
|
};
|
|
worker.postMessage(JSON.stringify({
|
|
language: env.language,
|
|
code: env.code,
|
|
immediateClose: true
|
|
}));
|
|
} else {
|
|
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
|
|
}
|
|
},
|
|
highlight: function (text, grammar, language) {
|
|
var env = {
|
|
code: text,
|
|
grammar: grammar,
|
|
language: language
|
|
};
|
|
_.hooks.run('before-tokenize', env);
|
|
if (!env.grammar) {
|
|
throw new Error('The language "' + env.language + '" has no grammar.');
|
|
}
|
|
env.tokens = _.tokenize(env.code, env.grammar);
|
|
_.hooks.run('after-tokenize', env);
|
|
return Token.stringify(_.util.encode(env.tokens), env.language);
|
|
},
|
|
tokenize: function (text, grammar) {
|
|
var rest = grammar.rest;
|
|
if (rest) {
|
|
for (var token in rest) {
|
|
grammar[token] = rest[token];
|
|
}
|
|
delete grammar.rest;
|
|
}
|
|
var tokenList = new LinkedList();
|
|
addAfter(tokenList, tokenList.head, text);
|
|
matchGrammar(text, tokenList, grammar, tokenList.head, 0);
|
|
return toArray(tokenList);
|
|
},
|
|
hooks: {
|
|
all: {},
|
|
add: function (name, callback) {
|
|
var hooks = _.hooks.all;
|
|
hooks[name] = hooks[name] || [];
|
|
hooks[name].push(callback);
|
|
},
|
|
run: function (name, env) {
|
|
var callbacks = _.hooks.all[name];
|
|
if (!callbacks || !callbacks.length) {
|
|
return;
|
|
}
|
|
for (var i = 0, callback; callback = callbacks[i++];) {
|
|
callback(env);
|
|
}
|
|
}
|
|
},
|
|
Token: Token
|
|
};
|
|
_self.Prism = _;
|
|
function Token(type, content, alias, matchedStr) {
|
|
this.type = type;
|
|
this.content = content;
|
|
this.alias = alias;
|
|
this.length = (matchedStr || '').length | 0;
|
|
}
|
|
Token.stringify = function stringify(o, language) {
|
|
if (typeof o == 'string') {
|
|
return o;
|
|
}
|
|
if (Array.isArray(o)) {
|
|
var s = '';
|
|
o.forEach(function (e) {
|
|
s += stringify(e, language);
|
|
});
|
|
return s;
|
|
}
|
|
var env = {
|
|
type: o.type,
|
|
content: stringify(o.content, language),
|
|
tag: 'span',
|
|
classes: [
|
|
'token',
|
|
o.type
|
|
],
|
|
attributes: {},
|
|
language: language
|
|
};
|
|
var aliases = o.alias;
|
|
if (aliases) {
|
|
if (Array.isArray(aliases)) {
|
|
Array.prototype.push.apply(env.classes, aliases);
|
|
} else {
|
|
env.classes.push(aliases);
|
|
}
|
|
}
|
|
_.hooks.run('wrap', env);
|
|
var attributes = '';
|
|
for (var name in env.attributes) {
|
|
attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"';
|
|
}
|
|
return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>';
|
|
};
|
|
function matchPattern(pattern, pos, text, lookbehind) {
|
|
pattern.lastIndex = pos;
|
|
var match = pattern.exec(text);
|
|
if (match && lookbehind && match[1]) {
|
|
var lookbehindLength = match[1].length;
|
|
match.index += lookbehindLength;
|
|
match[0] = match[0].slice(lookbehindLength);
|
|
}
|
|
return match;
|
|
}
|
|
function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) {
|
|
for (var token in grammar) {
|
|
if (!grammar.hasOwnProperty(token) || !grammar[token]) {
|
|
continue;
|
|
}
|
|
var patterns = grammar[token];
|
|
patterns = Array.isArray(patterns) ? patterns : [patterns];
|
|
for (var j = 0; j < patterns.length; ++j) {
|
|
if (rematch && rematch.cause == token + ',' + j) {
|
|
return;
|
|
}
|
|
var patternObj = patterns[j];
|
|
var inside = patternObj.inside;
|
|
var lookbehind = !!patternObj.lookbehind;
|
|
var greedy = !!patternObj.greedy;
|
|
var alias = patternObj.alias;
|
|
if (greedy && !patternObj.pattern.global) {
|
|
var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
|
|
patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g');
|
|
}
|
|
var pattern = patternObj.pattern || patternObj;
|
|
for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
|
|
if (rematch && pos >= rematch.reach) {
|
|
break;
|
|
}
|
|
var str = currentNode.value;
|
|
if (tokenList.length > text.length) {
|
|
return;
|
|
}
|
|
if (str instanceof Token) {
|
|
continue;
|
|
}
|
|
var removeCount = 1;
|
|
var match;
|
|
if (greedy) {
|
|
match = matchPattern(pattern, pos, text, lookbehind);
|
|
if (!match || match.index >= text.length) {
|
|
break;
|
|
}
|
|
var from = match.index;
|
|
var to = match.index + match[0].length;
|
|
var p = pos;
|
|
p += currentNode.value.length;
|
|
while (from >= p) {
|
|
currentNode = currentNode.next;
|
|
p += currentNode.value.length;
|
|
}
|
|
p -= currentNode.value.length;
|
|
pos = p;
|
|
if (currentNode.value instanceof Token) {
|
|
continue;
|
|
}
|
|
for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === 'string'); k = k.next) {
|
|
removeCount++;
|
|
p += k.value.length;
|
|
}
|
|
removeCount--;
|
|
str = text.slice(pos, p);
|
|
match.index -= pos;
|
|
} else {
|
|
match = matchPattern(pattern, 0, str, lookbehind);
|
|
if (!match) {
|
|
continue;
|
|
}
|
|
}
|
|
var from = match.index;
|
|
var matchStr = match[0];
|
|
var before = str.slice(0, from);
|
|
var after = str.slice(from + matchStr.length);
|
|
var reach = pos + str.length;
|
|
if (rematch && reach > rematch.reach) {
|
|
rematch.reach = reach;
|
|
}
|
|
var removeFrom = currentNode.prev;
|
|
if (before) {
|
|
removeFrom = addAfter(tokenList, removeFrom, before);
|
|
pos += before.length;
|
|
}
|
|
removeRange(tokenList, removeFrom, removeCount);
|
|
var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
|
|
currentNode = addAfter(tokenList, removeFrom, wrapped);
|
|
if (after) {
|
|
addAfter(tokenList, currentNode, after);
|
|
}
|
|
if (removeCount > 1) {
|
|
var nestedRematch = {
|
|
cause: token + ',' + j,
|
|
reach: reach
|
|
};
|
|
matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch);
|
|
if (rematch && nestedRematch.reach > rematch.reach) {
|
|
rematch.reach = nestedRematch.reach;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function LinkedList() {
|
|
var head = {
|
|
value: null,
|
|
prev: null,
|
|
next: null
|
|
};
|
|
var tail = {
|
|
value: null,
|
|
prev: head,
|
|
next: null
|
|
};
|
|
head.next = tail;
|
|
this.head = head;
|
|
this.tail = tail;
|
|
this.length = 0;
|
|
}
|
|
function addAfter(list, node, value) {
|
|
var next = node.next;
|
|
var newNode = {
|
|
value: value,
|
|
prev: node,
|
|
next: next
|
|
};
|
|
node.next = newNode;
|
|
next.prev = newNode;
|
|
list.length++;
|
|
return newNode;
|
|
}
|
|
function removeRange(list, node, count) {
|
|
var next = node.next;
|
|
for (var i = 0; i < count && next !== list.tail; i++) {
|
|
next = next.next;
|
|
}
|
|
node.next = next;
|
|
next.prev = node;
|
|
list.length -= i;
|
|
}
|
|
function toArray(list) {
|
|
var array = [];
|
|
var node = list.head.next;
|
|
while (node !== list.tail) {
|
|
array.push(node.value);
|
|
node = node.next;
|
|
}
|
|
return array;
|
|
}
|
|
if (!_self.document) {
|
|
if (!_self.addEventListener) {
|
|
return _;
|
|
}
|
|
if (!_.disableWorkerMessageHandler) {
|
|
_self.addEventListener('message', function (evt) {
|
|
var message = JSON.parse(evt.data);
|
|
var lang = message.language;
|
|
var code = message.code;
|
|
var immediateClose = message.immediateClose;
|
|
_self.postMessage(_.highlight(code, _.languages[lang], lang));
|
|
if (immediateClose) {
|
|
_self.close();
|
|
}
|
|
}, false);
|
|
}
|
|
return _;
|
|
}
|
|
var script = _.util.currentScript();
|
|
if (script) {
|
|
_.filename = script.src;
|
|
if (script.hasAttribute('data-manual')) {
|
|
_.manual = true;
|
|
}
|
|
}
|
|
function highlightAutomaticallyCallback() {
|
|
if (!_.manual) {
|
|
_.highlightAll();
|
|
}
|
|
}
|
|
if (!_.manual) {
|
|
var readyState = document.readyState;
|
|
if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) {
|
|
document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
|
|
} else {
|
|
if (window.requestAnimationFrame) {
|
|
window.requestAnimationFrame(highlightAutomaticallyCallback);
|
|
} else {
|
|
window.setTimeout(highlightAutomaticallyCallback, 16);
|
|
}
|
|
}
|
|
}
|
|
return _;
|
|
}(_self);
|
|
if (module.exports) {
|
|
module.exports = Prism;
|
|
}
|
|
if (typeof commonjsGlobal !== 'undefined') {
|
|
commonjsGlobal.Prism = Prism;
|
|
}
|
|
}(prismCore));
|
|
Prism.languages.clike = {
|
|
'comment': [
|
|
{
|
|
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
|
|
lookbehind: true,
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /(^|[^\\:])\/\/.*/,
|
|
lookbehind: true,
|
|
greedy: true
|
|
}
|
|
],
|
|
'string': {
|
|
pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
|
greedy: true
|
|
},
|
|
'class-name': {
|
|
pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /[.\\]/ }
|
|
},
|
|
'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
|
|
'boolean': /\b(?:false|true)\b/,
|
|
'function': /\b\w+(?=\()/,
|
|
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
|
|
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
|
|
'punctuation': /[{}[\];(),.:]/
|
|
};
|
|
(function (Prism) {
|
|
function getPlaceholder(language, index) {
|
|
return '___' + language.toUpperCase() + index + '___';
|
|
}
|
|
Object.defineProperties(Prism.languages['markup-templating'] = {}, {
|
|
buildPlaceholders: {
|
|
value: function (env, language, placeholderPattern, replaceFilter) {
|
|
if (env.language !== language) {
|
|
return;
|
|
}
|
|
var tokenStack = env.tokenStack = [];
|
|
env.code = env.code.replace(placeholderPattern, function (match) {
|
|
if (typeof replaceFilter === 'function' && !replaceFilter(match)) {
|
|
return match;
|
|
}
|
|
var i = tokenStack.length;
|
|
var placeholder;
|
|
while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
|
|
++i;
|
|
}
|
|
tokenStack[i] = match;
|
|
return placeholder;
|
|
});
|
|
env.grammar = Prism.languages.markup;
|
|
}
|
|
},
|
|
tokenizePlaceholders: {
|
|
value: function (env, language) {
|
|
if (env.language !== language || !env.tokenStack) {
|
|
return;
|
|
}
|
|
env.grammar = Prism.languages[language];
|
|
var j = 0;
|
|
var keys = Object.keys(env.tokenStack);
|
|
function walkTokens(tokens) {
|
|
for (var i = 0; i < tokens.length; i++) {
|
|
if (j >= keys.length) {
|
|
break;
|
|
}
|
|
var token = tokens[i];
|
|
if (typeof token === 'string' || token.content && typeof token.content === 'string') {
|
|
var k = keys[j];
|
|
var t = env.tokenStack[k];
|
|
var s = typeof token === 'string' ? token : token.content;
|
|
var placeholder = getPlaceholder(language, k);
|
|
var index = s.indexOf(placeholder);
|
|
if (index > -1) {
|
|
++j;
|
|
var before = s.substring(0, index);
|
|
var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t);
|
|
var after = s.substring(index + placeholder.length);
|
|
var replacement = [];
|
|
if (before) {
|
|
replacement.push.apply(replacement, walkTokens([before]));
|
|
}
|
|
replacement.push(middle);
|
|
if (after) {
|
|
replacement.push.apply(replacement, walkTokens([after]));
|
|
}
|
|
if (typeof token === 'string') {
|
|
tokens.splice.apply(tokens, [
|
|
i,
|
|
1
|
|
].concat(replacement));
|
|
} else {
|
|
token.content = replacement;
|
|
}
|
|
}
|
|
} else if (token.content) {
|
|
walkTokens(token.content);
|
|
}
|
|
}
|
|
return tokens;
|
|
}
|
|
walkTokens(env.tokens);
|
|
}
|
|
}
|
|
});
|
|
}(Prism));
|
|
Prism.languages.c = Prism.languages.extend('clike', {
|
|
'comment': {
|
|
pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
|
|
greedy: true
|
|
},
|
|
'string': {
|
|
pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
|
|
greedy: true
|
|
},
|
|
'class-name': {
|
|
pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
|
|
lookbehind: true
|
|
},
|
|
'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
|
|
'function': /\b[a-z_]\w*(?=\s*\()/i,
|
|
'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
|
|
'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
|
|
});
|
|
Prism.languages.insertBefore('c', 'string', {
|
|
'char': {
|
|
pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
|
|
greedy: true
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('c', 'string', {
|
|
'macro': {
|
|
pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
|
|
lookbehind: true,
|
|
greedy: true,
|
|
alias: 'property',
|
|
inside: {
|
|
'string': [
|
|
{
|
|
pattern: /^(#\s*include\s*)<[^>]+>/,
|
|
lookbehind: true
|
|
},
|
|
Prism.languages.c['string']
|
|
],
|
|
'char': Prism.languages.c['char'],
|
|
'comment': Prism.languages.c['comment'],
|
|
'macro-name': [
|
|
{
|
|
pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
|
|
lookbehind: true,
|
|
alias: 'function'
|
|
}
|
|
],
|
|
'directive': {
|
|
pattern: /^(#\s*)[a-z]+/,
|
|
lookbehind: true,
|
|
alias: 'keyword'
|
|
},
|
|
'directive-hash': /^#/,
|
|
'punctuation': /##|\\(?=[\r\n])/,
|
|
'expression': {
|
|
pattern: /\S[\s\S]*/,
|
|
inside: Prism.languages.c
|
|
}
|
|
}
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('c', 'function', { 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/ });
|
|
delete Prism.languages.c['boolean'];
|
|
(function (Prism) {
|
|
var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
|
|
var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () {
|
|
return keyword.source;
|
|
});
|
|
Prism.languages.cpp = Prism.languages.extend('c', {
|
|
'class-name': [
|
|
{
|
|
pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g, function () {
|
|
return keyword.source;
|
|
})),
|
|
lookbehind: true
|
|
},
|
|
/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
|
|
/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
|
|
/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
|
|
],
|
|
'keyword': keyword,
|
|
'number': {
|
|
pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
|
|
greedy: true
|
|
},
|
|
'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
|
|
'boolean': /\b(?:false|true)\b/
|
|
});
|
|
Prism.languages.insertBefore('cpp', 'string', {
|
|
'module': {
|
|
pattern: RegExp(/(\b(?:import|module)\s+)/.source + '(?:' + /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + '|' + /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () {
|
|
return modName;
|
|
}) + ')'),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: {
|
|
'string': /^[<"][\s\S]+/,
|
|
'operator': /:/,
|
|
'punctuation': /\./
|
|
}
|
|
},
|
|
'raw-string': {
|
|
pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
|
|
alias: 'string',
|
|
greedy: true
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('cpp', 'keyword', {
|
|
'generic-function': {
|
|
pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
|
|
inside: {
|
|
'function': /^\w+/,
|
|
'generic': {
|
|
pattern: /<[\s\S]+/,
|
|
alias: 'class-name',
|
|
inside: Prism.languages.cpp
|
|
}
|
|
}
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('cpp', 'operator', {
|
|
'double-colon': {
|
|
pattern: /::/,
|
|
alias: 'punctuation'
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('cpp', 'class-name', {
|
|
'base-clause': {
|
|
pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: Prism.languages.extend('cpp', {})
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('inside', 'double-colon', { 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i }, Prism.languages.cpp['base-clause']);
|
|
}(Prism));
|
|
(function (Prism) {
|
|
function replace(pattern, replacements) {
|
|
return pattern.replace(/<<(\d+)>>/g, function (m, index) {
|
|
return '(?:' + replacements[+index] + ')';
|
|
});
|
|
}
|
|
function re(pattern, replacements, flags) {
|
|
return RegExp(replace(pattern, replacements), flags || '');
|
|
}
|
|
function nested(pattern, depthLog2) {
|
|
for (var i = 0; i < depthLog2; i++) {
|
|
pattern = pattern.replace(/<<self>>/g, function () {
|
|
return '(?:' + pattern + ')';
|
|
});
|
|
}
|
|
return pattern.replace(/<<self>>/g, '[^\\s\\S]');
|
|
}
|
|
var keywordKinds = {
|
|
type: 'bool byte char decimal double dynamic float int long object sbyte short string uint ulong ushort var void',
|
|
typeDeclaration: 'class enum interface record struct',
|
|
contextual: 'add alias and ascending async await by descending from(?=\\s*(?:\\w|$)) get global group into init(?=\\s*;) join let nameof not notnull on or orderby partial remove select set unmanaged value when where with(?=\\s*{)',
|
|
other: 'abstract as base break case catch checked const continue default delegate do else event explicit extern finally fixed for foreach goto if implicit in internal is lock namespace new null operator out override params private protected public readonly ref return sealed sizeof stackalloc static switch this throw try typeof unchecked unsafe using virtual volatile while yield'
|
|
};
|
|
function keywordsToPattern(words) {
|
|
return '\\b(?:' + words.trim().replace(/ /g, '|') + ')\\b';
|
|
}
|
|
var typeDeclarationKeywords = keywordsToPattern(keywordKinds.typeDeclaration);
|
|
var keywords = RegExp(keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other));
|
|
var nonTypeKeywords = keywordsToPattern(keywordKinds.typeDeclaration + ' ' + keywordKinds.contextual + ' ' + keywordKinds.other);
|
|
var nonContextualKeywords = keywordsToPattern(keywordKinds.type + ' ' + keywordKinds.typeDeclaration + ' ' + keywordKinds.other);
|
|
var generic = nested(/<(?:[^<>;=+\-*/%&|^]|<<self>>)*>/.source, 2);
|
|
var nestedRound = nested(/\((?:[^()]|<<self>>)*\)/.source, 2);
|
|
var name = /@?\b[A-Za-z_]\w*\b/.source;
|
|
var genericName = replace(/<<0>>(?:\s*<<1>>)?/.source, [
|
|
name,
|
|
generic
|
|
]);
|
|
var identifier = replace(/(?!<<0>>)<<1>>(?:\s*\.\s*<<1>>)*/.source, [
|
|
nonTypeKeywords,
|
|
genericName
|
|
]);
|
|
var array = /\[\s*(?:,\s*)*\]/.source;
|
|
var typeExpressionWithoutTuple = replace(/<<0>>(?:\s*(?:\?\s*)?<<1>>)*(?:\s*\?)?/.source, [
|
|
identifier,
|
|
array
|
|
]);
|
|
var tupleElement = replace(/[^,()<>[\];=+\-*/%&|^]|<<0>>|<<1>>|<<2>>/.source, [
|
|
generic,
|
|
nestedRound,
|
|
array
|
|
]);
|
|
var tuple = replace(/\(<<0>>+(?:,<<0>>+)+\)/.source, [tupleElement]);
|
|
var typeExpression = replace(/(?:<<0>>|<<1>>)(?:\s*(?:\?\s*)?<<2>>)*(?:\s*\?)?/.source, [
|
|
tuple,
|
|
identifier,
|
|
array
|
|
]);
|
|
var typeInside = {
|
|
'keyword': keywords,
|
|
'punctuation': /[<>()?,.:[\]]/
|
|
};
|
|
var character = /'(?:[^\r\n'\\]|\\.|\\[Uux][\da-fA-F]{1,8})'/.source;
|
|
var regularString = /"(?:\\.|[^\\"\r\n])*"/.source;
|
|
var verbatimString = /@"(?:""|\\[\s\S]|[^\\"])*"(?!")/.source;
|
|
Prism.languages.csharp = Prism.languages.extend('clike', {
|
|
'string': [
|
|
{
|
|
pattern: re(/(^|[^$\\])<<0>>/.source, [verbatimString]),
|
|
lookbehind: true,
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: re(/(^|[^@$\\])<<0>>/.source, [regularString]),
|
|
lookbehind: true,
|
|
greedy: true
|
|
}
|
|
],
|
|
'class-name': [
|
|
{
|
|
pattern: re(/(\busing\s+static\s+)<<0>>(?=\s*;)/.source, [identifier]),
|
|
lookbehind: true,
|
|
inside: typeInside
|
|
},
|
|
{
|
|
pattern: re(/(\busing\s+<<0>>\s*=\s*)<<1>>(?=\s*;)/.source, [
|
|
name,
|
|
typeExpression
|
|
]),
|
|
lookbehind: true,
|
|
inside: typeInside
|
|
},
|
|
{
|
|
pattern: re(/(\busing\s+)<<0>>(?=\s*=)/.source, [name]),
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: re(/(\b<<0>>\s+)<<1>>/.source, [
|
|
typeDeclarationKeywords,
|
|
genericName
|
|
]),
|
|
lookbehind: true,
|
|
inside: typeInside
|
|
},
|
|
{
|
|
pattern: re(/(\bcatch\s*\(\s*)<<0>>/.source, [identifier]),
|
|
lookbehind: true,
|
|
inside: typeInside
|
|
},
|
|
{
|
|
pattern: re(/(\bwhere\s+)<<0>>/.source, [name]),
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: re(/(\b(?:is(?:\s+not)?|as)\s+)<<0>>/.source, [typeExpressionWithoutTuple]),
|
|
lookbehind: true,
|
|
inside: typeInside
|
|
},
|
|
{
|
|
pattern: re(/\b<<0>>(?=\s+(?!<<1>>|with\s*\{)<<2>>(?:\s*[=,;:{)\]]|\s+(?:in|when)\b))/.source, [
|
|
typeExpression,
|
|
nonContextualKeywords,
|
|
name
|
|
]),
|
|
inside: typeInside
|
|
}
|
|
],
|
|
'keyword': keywords,
|
|
'number': /(?:\b0(?:x[\da-f_]*[\da-f]|b[01_]*[01])|(?:\B\.\d+(?:_+\d+)*|\b\d+(?:_+\d+)*(?:\.\d+(?:_+\d+)*)?)(?:e[-+]?\d+(?:_+\d+)*)?)(?:[dflmu]|lu|ul)?\b/i,
|
|
'operator': />>=?|<<=?|[-=]>|([-+&|])\1|~|\?\?=?|[-+*/%&|^!=<>]=?/,
|
|
'punctuation': /\?\.?|::|[{}[\];(),.:]/
|
|
});
|
|
Prism.languages.insertBefore('csharp', 'number', {
|
|
'range': {
|
|
pattern: /\.\./,
|
|
alias: 'operator'
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('csharp', 'punctuation', {
|
|
'named-parameter': {
|
|
pattern: re(/([(,]\s*)<<0>>(?=\s*:)/.source, [name]),
|
|
lookbehind: true,
|
|
alias: 'punctuation'
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('csharp', 'class-name', {
|
|
'namespace': {
|
|
pattern: re(/(\b(?:namespace|using)\s+)<<0>>(?:\s*\.\s*<<0>>)*(?=\s*[;{])/.source, [name]),
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\./ }
|
|
},
|
|
'type-expression': {
|
|
pattern: re(/(\b(?:default|sizeof|typeof)\s*\(\s*(?!\s))(?:[^()\s]|\s(?!\s)|<<0>>)*(?=\s*\))/.source, [nestedRound]),
|
|
lookbehind: true,
|
|
alias: 'class-name',
|
|
inside: typeInside
|
|
},
|
|
'return-type': {
|
|
pattern: re(/<<0>>(?=\s+(?:<<1>>\s*(?:=>|[({]|\.\s*this\s*\[)|this\s*\[))/.source, [
|
|
typeExpression,
|
|
identifier
|
|
]),
|
|
inside: typeInside,
|
|
alias: 'class-name'
|
|
},
|
|
'constructor-invocation': {
|
|
pattern: re(/(\bnew\s+)<<0>>(?=\s*[[({])/.source, [typeExpression]),
|
|
lookbehind: true,
|
|
inside: typeInside,
|
|
alias: 'class-name'
|
|
},
|
|
'generic-method': {
|
|
pattern: re(/<<0>>\s*<<1>>(?=\s*\()/.source, [
|
|
name,
|
|
generic
|
|
]),
|
|
inside: {
|
|
'function': re(/^<<0>>/.source, [name]),
|
|
'generic': {
|
|
pattern: RegExp(generic),
|
|
alias: 'class-name',
|
|
inside: typeInside
|
|
}
|
|
}
|
|
},
|
|
'type-list': {
|
|
pattern: re(/\b((?:<<0>>\s+<<1>>|record\s+<<1>>\s*<<5>>|where\s+<<2>>)\s*:\s*)(?:<<3>>|<<4>>|<<1>>\s*<<5>>|<<6>>)(?:\s*,\s*(?:<<3>>|<<4>>|<<6>>))*(?=\s*(?:where|[{;]|=>|$))/.source, [
|
|
typeDeclarationKeywords,
|
|
genericName,
|
|
name,
|
|
typeExpression,
|
|
keywords.source,
|
|
nestedRound,
|
|
/\bnew\s*\(\s*\)/.source
|
|
]),
|
|
lookbehind: true,
|
|
inside: {
|
|
'record-arguments': {
|
|
pattern: re(/(^(?!new\s*\()<<0>>\s*)<<1>>/.source, [
|
|
genericName,
|
|
nestedRound
|
|
]),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: Prism.languages.csharp
|
|
},
|
|
'keyword': keywords,
|
|
'class-name': {
|
|
pattern: RegExp(typeExpression),
|
|
greedy: true,
|
|
inside: typeInside
|
|
},
|
|
'punctuation': /[,()]/
|
|
}
|
|
},
|
|
'preprocessor': {
|
|
pattern: /(^[\t ]*)#.*/m,
|
|
lookbehind: true,
|
|
alias: 'property',
|
|
inside: {
|
|
'directive': {
|
|
pattern: /(#)\b(?:define|elif|else|endif|endregion|error|if|line|nullable|pragma|region|undef|warning)\b/,
|
|
lookbehind: true,
|
|
alias: 'keyword'
|
|
}
|
|
}
|
|
}
|
|
});
|
|
var regularStringOrCharacter = regularString + '|' + character;
|
|
var regularStringCharacterOrComment = replace(/\/(?![*/])|\/\/[^\r\n]*[\r\n]|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>/.source, [regularStringOrCharacter]);
|
|
var roundExpression = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
|
|
var attrTarget = /\b(?:assembly|event|field|method|module|param|property|return|type)\b/.source;
|
|
var attr = replace(/<<0>>(?:\s*\(<<1>>*\))?/.source, [
|
|
identifier,
|
|
roundExpression
|
|
]);
|
|
Prism.languages.insertBefore('csharp', 'class-name', {
|
|
'attribute': {
|
|
pattern: re(/((?:^|[^\s\w>)?])\s*\[\s*)(?:<<0>>\s*:\s*)?<<1>>(?:\s*,\s*<<1>>)*(?=\s*\])/.source, [
|
|
attrTarget,
|
|
attr
|
|
]),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: {
|
|
'target': {
|
|
pattern: re(/^<<0>>(?=\s*:)/.source, [attrTarget]),
|
|
alias: 'keyword'
|
|
},
|
|
'attribute-arguments': {
|
|
pattern: re(/\(<<0>>*\)/.source, [roundExpression]),
|
|
inside: Prism.languages.csharp
|
|
},
|
|
'class-name': {
|
|
pattern: RegExp(identifier),
|
|
inside: { 'punctuation': /\./ }
|
|
},
|
|
'punctuation': /[:,]/
|
|
}
|
|
}
|
|
});
|
|
var formatString = /:[^}\r\n]+/.source;
|
|
var mInterpolationRound = nested(replace(/[^"'/()]|<<0>>|\(<<self>>*\)/.source, [regularStringCharacterOrComment]), 2);
|
|
var mInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [
|
|
mInterpolationRound,
|
|
formatString
|
|
]);
|
|
var sInterpolationRound = nested(replace(/[^"'/()]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|<<0>>|\(<<self>>*\)/.source, [regularStringOrCharacter]), 2);
|
|
var sInterpolation = replace(/\{(?!\{)(?:(?![}:])<<0>>)*<<1>>?\}/.source, [
|
|
sInterpolationRound,
|
|
formatString
|
|
]);
|
|
function createInterpolationInside(interpolation, interpolationRound) {
|
|
return {
|
|
'interpolation': {
|
|
pattern: re(/((?:^|[^{])(?:\{\{)*)<<0>>/.source, [interpolation]),
|
|
lookbehind: true,
|
|
inside: {
|
|
'format-string': {
|
|
pattern: re(/(^\{(?:(?![}:])<<0>>)*)<<1>>(?=\}$)/.source, [
|
|
interpolationRound,
|
|
formatString
|
|
]),
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /^:/ }
|
|
},
|
|
'punctuation': /^\{|\}$/,
|
|
'expression': {
|
|
pattern: /[\s\S]+/,
|
|
alias: 'language-csharp',
|
|
inside: Prism.languages.csharp
|
|
}
|
|
}
|
|
},
|
|
'string': /[\s\S]+/
|
|
};
|
|
}
|
|
Prism.languages.insertBefore('csharp', 'string', {
|
|
'interpolation-string': [
|
|
{
|
|
pattern: re(/(^|[^\\])(?:\$@|@\$)"(?:""|\\[\s\S]|\{\{|<<0>>|[^\\{"])*"/.source, [mInterpolation]),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: createInterpolationInside(mInterpolation, mInterpolationRound)
|
|
},
|
|
{
|
|
pattern: re(/(^|[^@\\])\$"(?:\\.|\{\{|<<0>>|[^\\"{])*"/.source, [sInterpolation]),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: createInterpolationInside(sInterpolation, sInterpolationRound)
|
|
}
|
|
],
|
|
'char': {
|
|
pattern: RegExp(character),
|
|
greedy: true
|
|
}
|
|
});
|
|
Prism.languages.dotnet = Prism.languages.cs = Prism.languages.csharp;
|
|
}(Prism));
|
|
(function (Prism) {
|
|
var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
|
|
Prism.languages.css = {
|
|
'comment': /\/\*[\s\S]*?\*\//,
|
|
'atrule': {
|
|
pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source),
|
|
inside: {
|
|
'rule': /^@[\w-]+/,
|
|
'selector-function-argument': {
|
|
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,
|
|
lookbehind: true,
|
|
alias: 'selector'
|
|
},
|
|
'keyword': {
|
|
pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
|
|
lookbehind: true
|
|
}
|
|
}
|
|
},
|
|
'url': {
|
|
pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'),
|
|
greedy: true,
|
|
inside: {
|
|
'function': /^url/i,
|
|
'punctuation': /^\(|\)$/,
|
|
'string': {
|
|
pattern: RegExp('^' + string.source + '$'),
|
|
alias: 'url'
|
|
}
|
|
}
|
|
},
|
|
'selector': {
|
|
pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'),
|
|
lookbehind: true
|
|
},
|
|
'string': {
|
|
pattern: string,
|
|
greedy: true
|
|
},
|
|
'property': {
|
|
pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
|
|
lookbehind: true
|
|
},
|
|
'important': /!important\b/i,
|
|
'function': {
|
|
pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
|
|
lookbehind: true
|
|
},
|
|
'punctuation': /[(){};:,]/
|
|
};
|
|
Prism.languages.css['atrule'].inside.rest = Prism.languages.css;
|
|
var markup = Prism.languages.markup;
|
|
if (markup) {
|
|
markup.tag.addInlined('style', 'css');
|
|
markup.tag.addAttribute('style', 'css');
|
|
}
|
|
}(Prism));
|
|
(function (Prism) {
|
|
var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
|
|
var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
|
|
var className = {
|
|
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
|
|
lookbehind: true,
|
|
inside: {
|
|
'namespace': {
|
|
pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
|
|
inside: { 'punctuation': /\./ }
|
|
},
|
|
'punctuation': /\./
|
|
}
|
|
};
|
|
Prism.languages.java = Prism.languages.extend('clike', {
|
|
'string': {
|
|
pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
|
|
lookbehind: true,
|
|
greedy: true
|
|
},
|
|
'class-name': [
|
|
className,
|
|
{
|
|
pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
|
|
lookbehind: true,
|
|
inside: className.inside
|
|
},
|
|
{
|
|
pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
|
|
lookbehind: true,
|
|
inside: className.inside
|
|
}
|
|
],
|
|
'keyword': keywords,
|
|
'function': [
|
|
Prism.languages.clike.function,
|
|
{
|
|
pattern: /(::\s*)[a-z_]\w*/,
|
|
lookbehind: true
|
|
}
|
|
],
|
|
'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
|
|
'operator': {
|
|
pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
|
|
lookbehind: true
|
|
},
|
|
'constant': /\b[A-Z][A-Z_\d]+\b/
|
|
});
|
|
Prism.languages.insertBefore('java', 'string', {
|
|
'triple-quoted-string': {
|
|
pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
|
|
greedy: true,
|
|
alias: 'string'
|
|
},
|
|
'char': {
|
|
pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
|
|
greedy: true
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('java', 'class-name', {
|
|
'annotation': {
|
|
pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
|
|
lookbehind: true,
|
|
alias: 'punctuation'
|
|
},
|
|
'generics': {
|
|
pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
|
|
inside: {
|
|
'class-name': className,
|
|
'keyword': keywords,
|
|
'punctuation': /[<>(),.:]/,
|
|
'operator': /[?&|]/
|
|
}
|
|
},
|
|
'import': [
|
|
{
|
|
pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
|
|
lookbehind: true,
|
|
inside: {
|
|
'namespace': className.inside.namespace,
|
|
'punctuation': /\./,
|
|
'operator': /\*/,
|
|
'class-name': /\w+/
|
|
}
|
|
},
|
|
{
|
|
pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
|
|
lookbehind: true,
|
|
alias: 'static',
|
|
inside: {
|
|
'namespace': className.inside.namespace,
|
|
'static': /\b\w+$/,
|
|
'punctuation': /\./,
|
|
'operator': /\*/,
|
|
'class-name': /\w+/
|
|
}
|
|
}
|
|
],
|
|
'namespace': {
|
|
pattern: RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function () {
|
|
return keywords.source;
|
|
})),
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\./ }
|
|
}
|
|
});
|
|
}(Prism));
|
|
Prism.languages.javascript = Prism.languages.extend('clike', {
|
|
'class-name': [
|
|
Prism.languages.clike['class-name'],
|
|
{
|
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
|
|
lookbehind: true
|
|
}
|
|
],
|
|
'keyword': [
|
|
{
|
|
pattern: /((?:^|\})\s*)catch\b/,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
|
|
lookbehind: true
|
|
}
|
|
],
|
|
'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
|
|
'number': {
|
|
pattern: RegExp(/(^|[^\w$])/.source + '(?:' + (/NaN|Infinity/.source + '|' + /0[bB][01]+(?:_[01]+)*n?/.source + '|' + /0[oO][0-7]+(?:_[0-7]+)*n?/.source + '|' + /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + '|' + /\d+(?:_\d+)*n/.source + '|' + /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ')' + /(?![\w$])/.source),
|
|
lookbehind: true
|
|
},
|
|
'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
|
|
});
|
|
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
|
|
Prism.languages.insertBefore('javascript', 'keyword', {
|
|
'regex': {
|
|
pattern: RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + /\//.source + '(?:' + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + '|' + /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ')' + /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: {
|
|
'regex-source': {
|
|
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
|
|
lookbehind: true,
|
|
alias: 'language-regex',
|
|
inside: Prism.languages.regex
|
|
},
|
|
'regex-delimiter': /^\/|\/$/,
|
|
'regex-flags': /^[a-z]+$/
|
|
}
|
|
},
|
|
'function-variable': {
|
|
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
|
|
alias: 'function'
|
|
},
|
|
'parameter': [
|
|
{
|
|
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,
|
|
lookbehind: true,
|
|
inside: Prism.languages.javascript
|
|
},
|
|
{
|
|
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
|
|
lookbehind: true,
|
|
inside: Prism.languages.javascript
|
|
},
|
|
{
|
|
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
|
|
lookbehind: true,
|
|
inside: Prism.languages.javascript
|
|
},
|
|
{
|
|
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
|
|
lookbehind: true,
|
|
inside: Prism.languages.javascript
|
|
}
|
|
],
|
|
'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/
|
|
});
|
|
Prism.languages.insertBefore('javascript', 'string', {
|
|
'hashbang': {
|
|
pattern: /^#!.*/,
|
|
greedy: true,
|
|
alias: 'comment'
|
|
},
|
|
'template-string': {
|
|
pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
|
|
greedy: true,
|
|
inside: {
|
|
'template-punctuation': {
|
|
pattern: /^`|`$/,
|
|
alias: 'string'
|
|
},
|
|
'interpolation': {
|
|
pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
|
|
lookbehind: true,
|
|
inside: {
|
|
'interpolation-punctuation': {
|
|
pattern: /^\$\{|\}$/,
|
|
alias: 'punctuation'
|
|
},
|
|
rest: Prism.languages.javascript
|
|
}
|
|
},
|
|
'string': /[\s\S]+/
|
|
}
|
|
},
|
|
'string-property': {
|
|
pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
|
|
lookbehind: true,
|
|
greedy: true,
|
|
alias: 'property'
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('javascript', 'operator', {
|
|
'literal-property': {
|
|
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
|
|
lookbehind: true,
|
|
alias: 'property'
|
|
}
|
|
});
|
|
if (Prism.languages.markup) {
|
|
Prism.languages.markup.tag.addInlined('script', 'javascript');
|
|
Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 'javascript');
|
|
}
|
|
Prism.languages.js = Prism.languages.javascript;
|
|
Prism.languages.markup = {
|
|
'comment': {
|
|
pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
|
|
greedy: true
|
|
},
|
|
'prolog': {
|
|
pattern: /<\?[\s\S]+?\?>/,
|
|
greedy: true
|
|
},
|
|
'doctype': {
|
|
pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
|
|
greedy: true,
|
|
inside: {
|
|
'internal-subset': {
|
|
pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: null
|
|
},
|
|
'string': {
|
|
pattern: /"[^"]*"|'[^']*'/,
|
|
greedy: true
|
|
},
|
|
'punctuation': /^<!|>$|[[\]]/,
|
|
'doctype-tag': /^DOCTYPE/i,
|
|
'name': /[^\s<>'"]+/
|
|
}
|
|
},
|
|
'cdata': {
|
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
greedy: true
|
|
},
|
|
'tag': {
|
|
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
|
|
greedy: true,
|
|
inside: {
|
|
'tag': {
|
|
pattern: /^<\/?[^\s>\/]+/,
|
|
inside: {
|
|
'punctuation': /^<\/?/,
|
|
'namespace': /^[^\s>\/:]+:/
|
|
}
|
|
},
|
|
'special-attr': [],
|
|
'attr-value': {
|
|
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
|
|
inside: {
|
|
'punctuation': [
|
|
{
|
|
pattern: /^=/,
|
|
alias: 'attr-equals'
|
|
},
|
|
{
|
|
pattern: /^(\s*)["']|["']$/,
|
|
lookbehind: true
|
|
}
|
|
]
|
|
}
|
|
},
|
|
'punctuation': /\/?>/,
|
|
'attr-name': {
|
|
pattern: /[^\s>\/]+/,
|
|
inside: { 'namespace': /^[^\s>\/:]+:/ }
|
|
}
|
|
}
|
|
},
|
|
'entity': [
|
|
{
|
|
pattern: /&[\da-z]{1,8};/i,
|
|
alias: 'named-entity'
|
|
},
|
|
/&#x?[\da-f]{1,8};/i
|
|
]
|
|
};
|
|
Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = Prism.languages.markup['entity'];
|
|
Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup;
|
|
Prism.hooks.add('wrap', function (env) {
|
|
if (env.type === 'entity') {
|
|
env.attributes['title'] = env.content.replace(/&/, '&');
|
|
}
|
|
});
|
|
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', {
|
|
value: function addInlined(tagName, lang) {
|
|
var includedCdataInside = {};
|
|
includedCdataInside['language-' + lang] = {
|
|
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
|
|
lookbehind: true,
|
|
inside: Prism.languages[lang]
|
|
};
|
|
includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i;
|
|
var inside = {
|
|
'included-cdata': {
|
|
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
|
|
inside: includedCdataInside
|
|
}
|
|
};
|
|
inside['language-' + lang] = {
|
|
pattern: /[\s\S]+/,
|
|
inside: Prism.languages[lang]
|
|
};
|
|
var def = {};
|
|
def[tagName] = {
|
|
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () {
|
|
return tagName;
|
|
}), 'i'),
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: inside
|
|
};
|
|
Prism.languages.insertBefore('markup', 'cdata', def);
|
|
}
|
|
});
|
|
Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', {
|
|
value: function (attrName, lang) {
|
|
Prism.languages.markup.tag.inside['special-attr'].push({
|
|
pattern: RegExp(/(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, 'i'),
|
|
lookbehind: true,
|
|
inside: {
|
|
'attr-name': /^[^\s=]+/,
|
|
'attr-value': {
|
|
pattern: /=[\s\S]+/,
|
|
inside: {
|
|
'value': {
|
|
pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
|
|
lookbehind: true,
|
|
alias: [
|
|
lang,
|
|
'language-' + lang
|
|
],
|
|
inside: Prism.languages[lang]
|
|
},
|
|
'punctuation': [
|
|
{
|
|
pattern: /^=/,
|
|
alias: 'attr-equals'
|
|
},
|
|
/"|'/
|
|
]
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
Prism.languages.html = Prism.languages.markup;
|
|
Prism.languages.mathml = Prism.languages.markup;
|
|
Prism.languages.svg = Prism.languages.markup;
|
|
Prism.languages.xml = Prism.languages.extend('markup', {});
|
|
Prism.languages.ssml = Prism.languages.xml;
|
|
Prism.languages.atom = Prism.languages.xml;
|
|
Prism.languages.rss = Prism.languages.xml;
|
|
(function (Prism) {
|
|
var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
|
|
var constant = [
|
|
{
|
|
pattern: /\b(?:false|true)\b/i,
|
|
alias: 'boolean'
|
|
},
|
|
{
|
|
pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
/\b(?:null)\b/i,
|
|
/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/
|
|
];
|
|
var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
|
|
var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
|
|
var punctuation = /[{}\[\](),:;]/;
|
|
Prism.languages.php = {
|
|
'delimiter': {
|
|
pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
|
|
alias: 'important'
|
|
},
|
|
'comment': comment,
|
|
'variable': /\$+(?:\w+\b|(?=\{))/,
|
|
'package': {
|
|
pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
'class-name-definition': {
|
|
pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
|
|
lookbehind: true,
|
|
alias: 'class-name'
|
|
},
|
|
'function-definition': {
|
|
pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
|
|
lookbehind: true,
|
|
alias: 'function'
|
|
},
|
|
'keyword': [
|
|
{
|
|
pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
|
|
alias: 'type-casting',
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
|
|
alias: 'type-hint',
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
|
|
alias: 'return-type',
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
|
|
alias: 'type-declaration',
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
|
|
alias: 'type-declaration',
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /\b(?:parent|self|static)(?=\s*::)/i,
|
|
alias: 'static-context',
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /(\byield\s+)from\b/i,
|
|
lookbehind: true
|
|
},
|
|
/\bclass\b/i,
|
|
{
|
|
pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
|
|
lookbehind: true
|
|
}
|
|
],
|
|
'argument-name': {
|
|
pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
|
|
lookbehind: true
|
|
},
|
|
'class-name': [
|
|
{
|
|
pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
|
|
alias: 'class-name-fully-qualified',
|
|
greedy: true,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
{
|
|
pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
|
|
alias: 'class-name-fully-qualified',
|
|
greedy: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
{
|
|
pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
|
|
alias: 'class-name-fully-qualified',
|
|
greedy: true,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
{
|
|
pattern: /\b[a-z_]\w*(?=\s*\$)/i,
|
|
alias: 'type-declaration',
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
|
|
alias: [
|
|
'class-name-fully-qualified',
|
|
'type-declaration'
|
|
],
|
|
greedy: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
{
|
|
pattern: /\b[a-z_]\w*(?=\s*::)/i,
|
|
alias: 'static-context',
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
|
|
alias: [
|
|
'class-name-fully-qualified',
|
|
'static-context'
|
|
],
|
|
greedy: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
{
|
|
pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
|
|
alias: 'type-hint',
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
|
|
alias: [
|
|
'class-name-fully-qualified',
|
|
'type-hint'
|
|
],
|
|
greedy: true,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
{
|
|
pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
|
|
alias: 'return-type',
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
|
|
alias: [
|
|
'class-name-fully-qualified',
|
|
'return-type'
|
|
],
|
|
greedy: true,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
}
|
|
],
|
|
'constant': constant,
|
|
'function': {
|
|
pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
},
|
|
'property': {
|
|
pattern: /(->\s*)\w+/,
|
|
lookbehind: true
|
|
},
|
|
'number': number,
|
|
'operator': operator,
|
|
'punctuation': punctuation
|
|
};
|
|
var string_interpolation = {
|
|
pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
|
|
lookbehind: true,
|
|
inside: Prism.languages.php
|
|
};
|
|
var string = [
|
|
{
|
|
pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
|
|
alias: 'nowdoc-string',
|
|
greedy: true,
|
|
inside: {
|
|
'delimiter': {
|
|
pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
|
|
alias: 'symbol',
|
|
inside: { 'punctuation': /^<<<'?|[';]$/ }
|
|
}
|
|
}
|
|
},
|
|
{
|
|
pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
|
|
alias: 'heredoc-string',
|
|
greedy: true,
|
|
inside: {
|
|
'delimiter': {
|
|
pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
|
|
alias: 'symbol',
|
|
inside: { 'punctuation': /^<<<"?|[";]$/ }
|
|
},
|
|
'interpolation': string_interpolation
|
|
}
|
|
},
|
|
{
|
|
pattern: /`(?:\\[\s\S]|[^\\`])*`/,
|
|
alias: 'backtick-quoted-string',
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /'(?:\\[\s\S]|[^\\'])*'/,
|
|
alias: 'single-quoted-string',
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: /"(?:\\[\s\S]|[^\\"])*"/,
|
|
alias: 'double-quoted-string',
|
|
greedy: true,
|
|
inside: { 'interpolation': string_interpolation }
|
|
}
|
|
];
|
|
Prism.languages.insertBefore('php', 'variable', {
|
|
'string': string,
|
|
'attribute': {
|
|
pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
|
|
greedy: true,
|
|
inside: {
|
|
'attribute-content': {
|
|
pattern: /^(#\[)[\s\S]+(?=\]$)/,
|
|
lookbehind: true,
|
|
inside: {
|
|
'comment': comment,
|
|
'string': string,
|
|
'attribute-class-name': [
|
|
{
|
|
pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
|
|
alias: 'class-name',
|
|
greedy: true,
|
|
lookbehind: true
|
|
},
|
|
{
|
|
pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
|
|
alias: [
|
|
'class-name',
|
|
'class-name-fully-qualified'
|
|
],
|
|
greedy: true,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /\\/ }
|
|
}
|
|
],
|
|
'constant': constant,
|
|
'number': number,
|
|
'operator': operator,
|
|
'punctuation': punctuation
|
|
}
|
|
},
|
|
'delimiter': {
|
|
pattern: /^#\[|\]$/,
|
|
alias: 'punctuation'
|
|
}
|
|
}
|
|
}
|
|
});
|
|
Prism.hooks.add('before-tokenize', function (env) {
|
|
if (!/<\?/.test(env.code)) {
|
|
return;
|
|
}
|
|
var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
|
|
Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern);
|
|
});
|
|
Prism.hooks.add('after-tokenize', function (env) {
|
|
Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
|
|
});
|
|
}(Prism));
|
|
Prism.languages.python = {
|
|
'comment': {
|
|
pattern: /(^|[^\\])#.*/,
|
|
lookbehind: true,
|
|
greedy: true
|
|
},
|
|
'string-interpolation': {
|
|
pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
|
|
greedy: true,
|
|
inside: {
|
|
'interpolation': {
|
|
pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
|
|
lookbehind: true,
|
|
inside: {
|
|
'format-spec': {
|
|
pattern: /(:)[^:(){}]+(?=\}$)/,
|
|
lookbehind: true
|
|
},
|
|
'conversion-option': {
|
|
pattern: //,
|
|
alias: 'punctuation'
|
|
},
|
|
rest: null
|
|
}
|
|
},
|
|
'string': /[\s\S]+/
|
|
}
|
|
},
|
|
'triple-quoted-string': {
|
|
pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
|
|
greedy: true,
|
|
alias: 'string'
|
|
},
|
|
'string': {
|
|
pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
|
|
greedy: true
|
|
},
|
|
'function': {
|
|
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
|
|
lookbehind: true
|
|
},
|
|
'class-name': {
|
|
pattern: /(\bclass\s+)\w+/i,
|
|
lookbehind: true
|
|
},
|
|
'decorator': {
|
|
pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
|
|
lookbehind: true,
|
|
alias: [
|
|
'annotation',
|
|
'punctuation'
|
|
],
|
|
inside: { 'punctuation': /\./ }
|
|
},
|
|
'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
|
|
'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
|
|
'boolean': /\b(?:False|None|True)\b/,
|
|
'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
|
|
'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
|
|
'punctuation': /[{}[\];(),.:]/
|
|
};
|
|
Prism.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism.languages.python;
|
|
Prism.languages.py = Prism.languages.python;
|
|
(function (Prism) {
|
|
Prism.languages.ruby = Prism.languages.extend('clike', {
|
|
'comment': {
|
|
pattern: /#.*|^=begin\s[\s\S]*?^=end/m,
|
|
greedy: true
|
|
},
|
|
'class-name': {
|
|
pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,
|
|
lookbehind: true,
|
|
inside: { 'punctuation': /[.\\]/ }
|
|
},
|
|
'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,
|
|
'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,
|
|
'punctuation': /[(){}[\].,;]/
|
|
});
|
|
Prism.languages.insertBefore('ruby', 'operator', {
|
|
'double-colon': {
|
|
pattern: /::/,
|
|
alias: 'punctuation'
|
|
}
|
|
});
|
|
var interpolation = {
|
|
pattern: /((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,
|
|
lookbehind: true,
|
|
inside: {
|
|
'content': {
|
|
pattern: /^(#\{)[\s\S]+(?=\}$)/,
|
|
lookbehind: true,
|
|
inside: Prism.languages.ruby
|
|
},
|
|
'delimiter': {
|
|
pattern: /^#\{|\}$/,
|
|
alias: 'punctuation'
|
|
}
|
|
}
|
|
};
|
|
delete Prism.languages.ruby.function;
|
|
var percentExpression = '(?:' + [
|
|
/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,
|
|
/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,
|
|
/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,
|
|
/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,
|
|
/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source
|
|
].join('|') + ')';
|
|
var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;
|
|
Prism.languages.insertBefore('ruby', 'keyword', {
|
|
'regex-literal': [
|
|
{
|
|
pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source),
|
|
greedy: true,
|
|
inside: {
|
|
'interpolation': interpolation,
|
|
'regex': /[\s\S]+/
|
|
}
|
|
},
|
|
{
|
|
pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,
|
|
lookbehind: true,
|
|
greedy: true,
|
|
inside: {
|
|
'interpolation': interpolation,
|
|
'regex': /[\s\S]+/
|
|
}
|
|
}
|
|
],
|
|
'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,
|
|
'symbol': [
|
|
{
|
|
pattern: RegExp(/(^|[^:]):/.source + symbolName),
|
|
lookbehind: true,
|
|
greedy: true
|
|
},
|
|
{
|
|
pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source),
|
|
lookbehind: true,
|
|
greedy: true
|
|
}
|
|
],
|
|
'method-definition': {
|
|
pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,
|
|
lookbehind: true,
|
|
inside: {
|
|
'function': /\b\w+$/,
|
|
'keyword': /^self\b/,
|
|
'class-name': /^\w+/,
|
|
'punctuation': /\./
|
|
}
|
|
}
|
|
});
|
|
Prism.languages.insertBefore('ruby', 'string', {
|
|
'string-literal': [
|
|
{
|
|
pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression),
|
|
greedy: true,
|
|
inside: {
|
|
'interpolation': interpolation,
|
|
'string': /[\s\S]+/
|
|
}
|
|
},
|
|
{
|
|
pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,
|
|
greedy: true,
|
|
inside: {
|
|
'interpolation': interpolation,
|
|
'string': /[\s\S]+/
|
|
}
|
|
},
|
|
{
|
|
pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
|
|
alias: 'heredoc-string',
|
|
greedy: true,
|
|
inside: {
|
|
'delimiter': {
|
|
pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,
|
|
inside: {
|
|
'symbol': /\b\w+/,
|
|
'punctuation': /^<<[-~]?/
|
|
}
|
|
},
|
|
'interpolation': interpolation,
|
|
'string': /[\s\S]+/
|
|
}
|
|
},
|
|
{
|
|
pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,
|
|
alias: 'heredoc-string',
|
|
greedy: true,
|
|
inside: {
|
|
'delimiter': {
|
|
pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,
|
|
inside: {
|
|
'symbol': /\b\w+/,
|
|
'punctuation': /^<<[-~]?'|'$/
|
|
}
|
|
},
|
|
'string': /[\s\S]+/
|
|
}
|
|
}
|
|
],
|
|
'command-literal': [
|
|
{
|
|
pattern: RegExp(/%x/.source + percentExpression),
|
|
greedy: true,
|
|
inside: {
|
|
'interpolation': interpolation,
|
|
'command': {
|
|
pattern: /[\s\S]+/,
|
|
alias: 'string'
|
|
}
|
|
}
|
|
},
|
|
{
|
|
pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,
|
|
greedy: true,
|
|
inside: {
|
|
'interpolation': interpolation,
|
|
'command': {
|
|
pattern: /[\s\S]+/,
|
|
alias: 'string'
|
|
}
|
|
}
|
|
}
|
|
]
|
|
});
|
|
delete Prism.languages.ruby.string;
|
|
Prism.languages.insertBefore('ruby', 'number', {
|
|
'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,
|
|
'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/
|
|
});
|
|
Prism.languages.rb = Prism.languages.ruby;
|
|
}(Prism));
|
|
var Prism$1 = prismCore.exports;
|
|
var prismjs = { boltExport: Prism$1 };
|
|
return prismjs;
|
|
}));
|
|
var prism = window.Prism;
|
|
window.Prism = oldprism;
|
|
return prism;
|
|
}(undefined, exports$1, module));
|
|
var Prism$1 = module.exports.boltExport;
|
|
|
|
var getLanguages$1 = function (editor) {
|
|
return editor.getParam('codesample_languages');
|
|
};
|
|
var useGlobalPrismJS = function (editor) {
|
|
return editor.getParam('codesample_global_prismjs', false, 'boolean');
|
|
};
|
|
|
|
var get = function (editor) {
|
|
return Global.Prism && useGlobalPrismJS(editor) ? Global.Prism : Prism$1;
|
|
};
|
|
|
|
var getSelectedCodeSample = function (editor) {
|
|
var node = editor.selection ? editor.selection.getNode() : null;
|
|
return someIf(isCodeSample(node), node);
|
|
};
|
|
var insertCodeSample = function (editor, language, code) {
|
|
editor.undoManager.transact(function () {
|
|
var node = getSelectedCodeSample(editor);
|
|
code = global$1.DOM.encode(code);
|
|
return node.fold(function () {
|
|
editor.insertContent('<pre id="__new" class="language-' + language + '">' + code + '</pre>');
|
|
editor.selection.select(editor.$('#__new').removeAttr('id')[0]);
|
|
}, function (n) {
|
|
editor.dom.setAttrib(n, 'class', 'language-' + language);
|
|
n.innerHTML = code;
|
|
get(editor).highlightElement(n);
|
|
editor.selection.select(n);
|
|
});
|
|
});
|
|
};
|
|
var getCurrentCode = function (editor) {
|
|
var node = getSelectedCodeSample(editor);
|
|
return node.fold(constant(''), function (n) {
|
|
return n.textContent;
|
|
});
|
|
};
|
|
|
|
var getLanguages = function (editor) {
|
|
var defaultLanguages = [
|
|
{
|
|
text: 'HTML/XML',
|
|
value: 'markup'
|
|
},
|
|
{
|
|
text: 'JavaScript',
|
|
value: 'javascript'
|
|
},
|
|
{
|
|
text: 'CSS',
|
|
value: 'css'
|
|
},
|
|
{
|
|
text: 'PHP',
|
|
value: 'php'
|
|
},
|
|
{
|
|
text: 'Ruby',
|
|
value: 'ruby'
|
|
},
|
|
{
|
|
text: 'Python',
|
|
value: 'python'
|
|
},
|
|
{
|
|
text: 'Java',
|
|
value: 'java'
|
|
},
|
|
{
|
|
text: 'C',
|
|
value: 'c'
|
|
},
|
|
{
|
|
text: 'C#',
|
|
value: 'csharp'
|
|
},
|
|
{
|
|
text: 'C++',
|
|
value: 'cpp'
|
|
}
|
|
];
|
|
var customLanguages = getLanguages$1(editor);
|
|
return customLanguages ? customLanguages : defaultLanguages;
|
|
};
|
|
var getCurrentLanguage = function (editor, fallback) {
|
|
var node = getSelectedCodeSample(editor);
|
|
return node.fold(function () {
|
|
return fallback;
|
|
}, function (n) {
|
|
var matches = n.className.match(/language-(\w+)/);
|
|
return matches ? matches[1] : fallback;
|
|
});
|
|
};
|
|
|
|
var open = function (editor) {
|
|
var languages = getLanguages(editor);
|
|
var defaultLanguage = head(languages).fold(constant(''), function (l) {
|
|
return l.value;
|
|
});
|
|
var currentLanguage = getCurrentLanguage(editor, defaultLanguage);
|
|
var currentCode = getCurrentCode(editor);
|
|
editor.windowManager.open({
|
|
title: 'Insert/Edit Code Sample',
|
|
size: 'large',
|
|
body: {
|
|
type: 'panel',
|
|
items: [
|
|
{
|
|
type: 'selectbox',
|
|
name: 'language',
|
|
label: 'Language',
|
|
items: languages
|
|
},
|
|
{
|
|
type: 'textarea',
|
|
name: 'code',
|
|
label: 'Code view'
|
|
}
|
|
]
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: {
|
|
language: currentLanguage,
|
|
code: currentCode
|
|
},
|
|
onSubmit: function (api) {
|
|
var data = api.getData();
|
|
insertCodeSample(editor, data.language, data.code);
|
|
api.close();
|
|
}
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('codesample', function () {
|
|
var node = editor.selection.getNode();
|
|
if (editor.selection.isCollapsed() || isCodeSample(node)) {
|
|
open(editor);
|
|
} else {
|
|
editor.formatter.toggle('code');
|
|
}
|
|
});
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
var $ = editor.$;
|
|
editor.on('PreProcess', function (e) {
|
|
$('pre[contenteditable=false]', e.node).filter(trimArg(isCodeSample)).each(function (idx, elm) {
|
|
var $elm = $(elm), code = elm.textContent;
|
|
$elm.attr('class', $.trim($elm.attr('class')));
|
|
$elm.removeAttr('contentEditable');
|
|
$elm.empty().append($('<code></code>').each(function () {
|
|
this.textContent = code;
|
|
}));
|
|
});
|
|
});
|
|
editor.on('SetContent', function () {
|
|
var unprocessedCodeSamples = $('pre').filter(trimArg(isCodeSample)).filter(function (idx, elm) {
|
|
return elm.contentEditable !== 'false';
|
|
});
|
|
if (unprocessedCodeSamples.length) {
|
|
editor.undoManager.transact(function () {
|
|
unprocessedCodeSamples.each(function (idx, elm) {
|
|
$(elm).find('br').each(function (idx, elm) {
|
|
elm.parentNode.replaceChild(editor.getDoc().createTextNode('\n'), elm);
|
|
});
|
|
elm.contentEditable = 'false';
|
|
elm.innerHTML = editor.dom.encode(elm.textContent);
|
|
get(editor).highlightElement(elm);
|
|
elm.className = $.trim(elm.className);
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
var isCodeSampleSelection = function (editor) {
|
|
var node = editor.selection.getStart();
|
|
return editor.dom.is(node, 'pre[class*="language-"]');
|
|
};
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('codesample');
|
|
};
|
|
editor.ui.registry.addToggleButton('codesample', {
|
|
icon: 'code-sample',
|
|
tooltip: 'Insert/edit code sample',
|
|
onAction: onAction,
|
|
onSetup: function (api) {
|
|
var nodeChangeHandler = function () {
|
|
api.setActive(isCodeSampleSelection(editor));
|
|
};
|
|
editor.on('NodeChange', nodeChangeHandler);
|
|
return function () {
|
|
return editor.off('NodeChange', nodeChangeHandler);
|
|
};
|
|
}
|
|
});
|
|
editor.ui.registry.addMenuItem('codesample', {
|
|
text: 'Code sample...',
|
|
icon: 'code-sample',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$2.add('codesample', function (editor) {
|
|
setup(editor);
|
|
register(editor);
|
|
register$1(editor);
|
|
editor.on('dblclick', function (ev) {
|
|
if (isCodeSample(ev.target)) {
|
|
open(editor);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var setContent = function (editor, html) {
|
|
editor.focus();
|
|
editor.undoManager.transact(function () {
|
|
editor.setContent(html);
|
|
});
|
|
editor.selection.setCursorLocation();
|
|
editor.nodeChanged();
|
|
};
|
|
var getContent = function (editor) {
|
|
return editor.getContent({ source_view: true });
|
|
};
|
|
|
|
var open = function (editor) {
|
|
var editorContent = getContent(editor);
|
|
editor.windowManager.open({
|
|
title: 'Source Code',
|
|
size: 'large',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'textarea',
|
|
name: 'code'
|
|
}]
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: { code: editorContent },
|
|
onSubmit: function (api) {
|
|
setContent(editor, api.getData().code);
|
|
api.close();
|
|
}
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceCodeEditor', function () {
|
|
open(editor);
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceCodeEditor');
|
|
};
|
|
editor.ui.registry.addButton('code', {
|
|
icon: 'sourcecode',
|
|
tooltip: 'Source code',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('code', {
|
|
icon: 'sourcecode',
|
|
text: 'Source code',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global.add('code', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
return {};
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
function Plugin () {
|
|
global.add('colorpicker', function () {
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
function Plugin () {
|
|
global.add('contextmenu', function () {
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var compose1 = function (fbc, fab) {
|
|
return function (a) {
|
|
return fbc(fab(a));
|
|
};
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
|
|
var DOCUMENT = 9;
|
|
var DOCUMENT_FRAGMENT = 11;
|
|
var ELEMENT = 1;
|
|
var TEXT = 3;
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var is = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var name = function (element) {
|
|
var r = element.dom.nodeName;
|
|
return r.toLowerCase();
|
|
};
|
|
var type = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type(element) === t;
|
|
};
|
|
};
|
|
var isElement = isType(ELEMENT);
|
|
var isText = isType(TEXT);
|
|
var isDocument = isType(DOCUMENT);
|
|
var isDocumentFragment = isType(DOCUMENT_FRAGMENT);
|
|
var isTag = function (tag) {
|
|
return function (e) {
|
|
return isElement(e) && name(e) === tag;
|
|
};
|
|
};
|
|
|
|
var owner = function (element) {
|
|
return SugarElement.fromDom(element.dom.ownerDocument);
|
|
};
|
|
var documentOrOwner = function (dos) {
|
|
return isDocument(dos) ? dos : owner(dos);
|
|
};
|
|
var parent = function (element) {
|
|
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
};
|
|
var children$2 = function (element) {
|
|
return map(element.dom.childNodes, SugarElement.fromDom);
|
|
};
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
var remove = function (element, key) {
|
|
element.dom.removeAttribute(key);
|
|
};
|
|
|
|
var isShadowRoot = function (dos) {
|
|
return isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
};
|
|
var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
|
|
var getRootNode = supported ? function (e) {
|
|
return SugarElement.fromDom(e.dom.getRootNode());
|
|
} : documentOrOwner;
|
|
var getShadowRoot = function (e) {
|
|
var r = getRootNode(e);
|
|
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
};
|
|
var getShadowHost = function (e) {
|
|
return SugarElement.fromDom(e.dom.host);
|
|
};
|
|
|
|
var inBody = function (element) {
|
|
var dom = isText(element) ? element.dom.parentNode : element.dom;
|
|
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
return false;
|
|
}
|
|
var doc = dom.ownerDocument;
|
|
return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {
|
|
return doc.body.contains(dom);
|
|
}, compose1(inBody, getShadowHost));
|
|
};
|
|
|
|
var ancestor$1 = function (scope, predicate, isRoot) {
|
|
var element = scope.dom;
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
while (element.parentNode) {
|
|
element = element.parentNode;
|
|
var el = SugarElement.fromDom(element);
|
|
if (predicate(el)) {
|
|
return Optional.some(el);
|
|
} else if (stop(el)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var ancestor = function (scope, selector, isRoot) {
|
|
return ancestor$1(scope, function (e) {
|
|
return is(e, selector);
|
|
}, isRoot);
|
|
};
|
|
|
|
var isSupported = function (dom) {
|
|
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
};
|
|
|
|
var get = function (element, property) {
|
|
var dom = element.dom;
|
|
var styles = window.getComputedStyle(dom);
|
|
var r = styles.getPropertyValue(property);
|
|
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
|
|
};
|
|
var getUnsafeProperty = function (dom, property) {
|
|
return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
|
|
};
|
|
|
|
var getDirection = function (element) {
|
|
return get(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
|
|
};
|
|
|
|
var children$1 = function (scope, predicate) {
|
|
return filter(children$2(scope), predicate);
|
|
};
|
|
|
|
var children = function (scope, selector) {
|
|
return children$1(scope, function (e) {
|
|
return is(e, selector);
|
|
});
|
|
};
|
|
|
|
var getParentElement = function (element) {
|
|
return parent(element).filter(isElement);
|
|
};
|
|
var getNormalizedBlock = function (element, isListItem) {
|
|
var normalizedElement = isListItem ? ancestor(element, 'ol,ul') : Optional.some(element);
|
|
return normalizedElement.getOr(element);
|
|
};
|
|
var isListItem = isTag('li');
|
|
var setDir = function (editor, dir) {
|
|
var selectedBlocks = editor.selection.getSelectedBlocks();
|
|
if (selectedBlocks.length > 0) {
|
|
each(selectedBlocks, function (block) {
|
|
var blockElement = SugarElement.fromDom(block);
|
|
var isBlockElementListItem = isListItem(blockElement);
|
|
var normalizedBlock = getNormalizedBlock(blockElement, isBlockElementListItem);
|
|
var normalizedBlockParent = getParentElement(normalizedBlock);
|
|
normalizedBlockParent.each(function (parent) {
|
|
var parentDirection = getDirection(parent);
|
|
if (parentDirection !== dir) {
|
|
set(normalizedBlock, 'dir', dir);
|
|
} else if (getDirection(normalizedBlock) !== dir) {
|
|
remove(normalizedBlock, 'dir');
|
|
}
|
|
if (isBlockElementListItem) {
|
|
var listItems = children(normalizedBlock, 'li[dir]');
|
|
each(listItems, function (listItem) {
|
|
return remove(listItem, 'dir');
|
|
});
|
|
}
|
|
});
|
|
});
|
|
editor.nodeChanged();
|
|
}
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceDirectionLTR', function () {
|
|
setDir(editor, 'ltr');
|
|
});
|
|
editor.addCommand('mceDirectionRTL', function () {
|
|
setDir(editor, 'rtl');
|
|
});
|
|
};
|
|
|
|
var getNodeChangeHandler = function (editor, dir) {
|
|
return function (api) {
|
|
var nodeChangeHandler = function (e) {
|
|
var element = SugarElement.fromDom(e.element);
|
|
api.setActive(getDirection(element) === dir);
|
|
};
|
|
editor.on('NodeChange', nodeChangeHandler);
|
|
return function () {
|
|
return editor.off('NodeChange', nodeChangeHandler);
|
|
};
|
|
};
|
|
};
|
|
var register = function (editor) {
|
|
editor.ui.registry.addToggleButton('ltr', {
|
|
tooltip: 'Left to right',
|
|
icon: 'ltr',
|
|
onAction: function () {
|
|
return editor.execCommand('mceDirectionLTR');
|
|
},
|
|
onSetup: getNodeChangeHandler(editor, 'ltr')
|
|
});
|
|
editor.ui.registry.addToggleButton('rtl', {
|
|
tooltip: 'Right to left',
|
|
icon: 'rtl',
|
|
onAction: function () {
|
|
return editor.execCommand('mceDirectionRTL');
|
|
},
|
|
onSetup: getNodeChangeHandler(editor, 'rtl')
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global.add('directionality', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var eq = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isNull = eq(null);
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var exists = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var map$1 = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var last = function (fn, rate) {
|
|
var timer = null;
|
|
var cancel = function () {
|
|
if (!isNull(timer)) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
};
|
|
var throttle = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
cancel();
|
|
timer = setTimeout(function () {
|
|
timer = null;
|
|
fn.apply(null, args);
|
|
}, rate);
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
throttle: throttle
|
|
};
|
|
};
|
|
|
|
var insertEmoticon = function (editor, ch) {
|
|
editor.insertContent(ch);
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var map = function (obj, f) {
|
|
return tupleMap(obj, function (x, i) {
|
|
return {
|
|
k: i,
|
|
v: f(x, i)
|
|
};
|
|
});
|
|
};
|
|
var tupleMap = function (obj, f) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
var tuple = f(x, i);
|
|
r[tuple.k] = tuple.v;
|
|
});
|
|
return r;
|
|
};
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
var shallow = function (old, nu) {
|
|
return nu;
|
|
};
|
|
var baseMerge = function (merger) {
|
|
return function () {
|
|
var objects = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
objects[_i] = arguments[_i];
|
|
}
|
|
if (objects.length === 0) {
|
|
throw new Error('Can\'t merge zero objects');
|
|
}
|
|
var ret = {};
|
|
for (var j = 0; j < objects.length; j++) {
|
|
var curObject = objects[j];
|
|
for (var key in curObject) {
|
|
if (has(curObject, key)) {
|
|
ret[key] = merger(ret[key], curObject[key]);
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
};
|
|
var merge = baseMerge(shallow);
|
|
|
|
var singleton = function (doRevoke) {
|
|
var subject = Cell(Optional.none());
|
|
var revoke = function () {
|
|
return subject.get().each(doRevoke);
|
|
};
|
|
var clear = function () {
|
|
revoke();
|
|
subject.set(Optional.none());
|
|
};
|
|
var isSet = function () {
|
|
return subject.get().isSome();
|
|
};
|
|
var get = function () {
|
|
return subject.get();
|
|
};
|
|
var set = function (s) {
|
|
revoke();
|
|
subject.set(Optional.some(s));
|
|
};
|
|
return {
|
|
clear: clear,
|
|
isSet: isSet,
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var value = function () {
|
|
var subject = singleton(noop);
|
|
var on = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { on: on });
|
|
};
|
|
|
|
var checkRange = function (str, substr, start) {
|
|
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
};
|
|
var contains = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
var startsWith = function (str, prefix) {
|
|
return checkRange(str, prefix, 0);
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.Resource');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var DEFAULT_ID = 'tinymce.plugins.emoticons';
|
|
var getEmoticonDatabase = function (editor) {
|
|
return editor.getParam('emoticons_database', 'emojis', 'string');
|
|
};
|
|
var getEmoticonDatabaseUrl = function (editor, pluginUrl) {
|
|
var database = getEmoticonDatabase(editor);
|
|
return editor.getParam('emoticons_database_url', pluginUrl + '/js/' + database + editor.suffix + '.js', 'string');
|
|
};
|
|
var getEmoticonDatabaseId = function (editor) {
|
|
return editor.getParam('emoticons_database_id', DEFAULT_ID, 'string');
|
|
};
|
|
var getAppendedEmoticons = function (editor) {
|
|
return editor.getParam('emoticons_append', {}, 'object');
|
|
};
|
|
var getEmotionsImageUrl = function (editor) {
|
|
return editor.getParam('emoticons_images_url', 'https://twemoji.maxcdn.com/v/13.0.1/72x72/', 'string');
|
|
};
|
|
|
|
var ALL_CATEGORY = 'All';
|
|
var categoryNameMap = {
|
|
symbols: 'Symbols',
|
|
people: 'People',
|
|
animals_and_nature: 'Animals and Nature',
|
|
food_and_drink: 'Food and Drink',
|
|
activity: 'Activity',
|
|
travel_and_places: 'Travel and Places',
|
|
objects: 'Objects',
|
|
flags: 'Flags',
|
|
user: 'User Defined'
|
|
};
|
|
var translateCategory = function (categories, name) {
|
|
return has(categories, name) ? categories[name] : name;
|
|
};
|
|
var getUserDefinedEmoticons = function (editor) {
|
|
var userDefinedEmoticons = getAppendedEmoticons(editor);
|
|
return map(userDefinedEmoticons, function (value) {
|
|
return __assign({
|
|
keywords: [],
|
|
category: 'user'
|
|
}, value);
|
|
});
|
|
};
|
|
var initDatabase = function (editor, databaseUrl, databaseId) {
|
|
var categories = value();
|
|
var all = value();
|
|
var emojiImagesUrl = getEmotionsImageUrl(editor);
|
|
var getEmoji = function (lib) {
|
|
if (startsWith(lib.char, '<img')) {
|
|
return lib.char.replace(/src="([^"]+)"/, function (match, url) {
|
|
return 'src="' + emojiImagesUrl + url + '"';
|
|
});
|
|
} else {
|
|
return lib.char;
|
|
}
|
|
};
|
|
var processEmojis = function (emojis) {
|
|
var cats = {};
|
|
var everything = [];
|
|
each(emojis, function (lib, title) {
|
|
var entry = {
|
|
title: title,
|
|
keywords: lib.keywords,
|
|
char: getEmoji(lib),
|
|
category: translateCategory(categoryNameMap, lib.category)
|
|
};
|
|
var current = cats[entry.category] !== undefined ? cats[entry.category] : [];
|
|
cats[entry.category] = current.concat([entry]);
|
|
everything.push(entry);
|
|
});
|
|
categories.set(cats);
|
|
all.set(everything);
|
|
};
|
|
editor.on('init', function () {
|
|
global$2.load(databaseId, databaseUrl).then(function (emojis) {
|
|
var userEmojis = getUserDefinedEmoticons(editor);
|
|
processEmojis(merge(emojis, userEmojis));
|
|
}, function (err) {
|
|
console.log('Failed to load emoticons: ' + err);
|
|
categories.set({});
|
|
all.set([]);
|
|
});
|
|
});
|
|
var listCategory = function (category) {
|
|
if (category === ALL_CATEGORY) {
|
|
return listAll();
|
|
}
|
|
return categories.get().bind(function (cats) {
|
|
return Optional.from(cats[category]);
|
|
}).getOr([]);
|
|
};
|
|
var listAll = function () {
|
|
return all.get().getOr([]);
|
|
};
|
|
var listCategories = function () {
|
|
return [ALL_CATEGORY].concat(keys(categories.get().getOr({})));
|
|
};
|
|
var waitForLoad = function () {
|
|
if (hasLoaded()) {
|
|
return global.resolve(true);
|
|
} else {
|
|
return new global(function (resolve, reject) {
|
|
var numRetries = 15;
|
|
var interval = global$1.setInterval(function () {
|
|
if (hasLoaded()) {
|
|
global$1.clearInterval(interval);
|
|
resolve(true);
|
|
} else {
|
|
numRetries--;
|
|
if (numRetries < 0) {
|
|
console.log('Could not load emojis from url: ' + databaseUrl);
|
|
global$1.clearInterval(interval);
|
|
reject(false);
|
|
}
|
|
}
|
|
}, 100);
|
|
});
|
|
}
|
|
};
|
|
var hasLoaded = function () {
|
|
return categories.isSet() && all.isSet();
|
|
};
|
|
return {
|
|
listCategories: listCategories,
|
|
hasLoaded: hasLoaded,
|
|
waitForLoad: waitForLoad,
|
|
listAll: listAll,
|
|
listCategory: listCategory
|
|
};
|
|
};
|
|
|
|
var emojiMatches = function (emoji, lowerCasePattern) {
|
|
return contains(emoji.title.toLowerCase(), lowerCasePattern) || exists(emoji.keywords, function (k) {
|
|
return contains(k.toLowerCase(), lowerCasePattern);
|
|
});
|
|
};
|
|
var emojisFrom = function (list, pattern, maxResults) {
|
|
var matches = [];
|
|
var lowerCasePattern = pattern.toLowerCase();
|
|
var reachedLimit = maxResults.fold(function () {
|
|
return never;
|
|
}, function (max) {
|
|
return function (size) {
|
|
return size >= max;
|
|
};
|
|
});
|
|
for (var i = 0; i < list.length; i++) {
|
|
if (pattern.length === 0 || emojiMatches(list[i], lowerCasePattern)) {
|
|
matches.push({
|
|
value: list[i].char,
|
|
text: list[i].title,
|
|
icon: list[i].char
|
|
});
|
|
if (reachedLimit(matches.length)) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return matches;
|
|
};
|
|
|
|
var patternName = 'pattern';
|
|
var open = function (editor, database) {
|
|
var initialState = {
|
|
pattern: '',
|
|
results: emojisFrom(database.listAll(), '', Optional.some(300))
|
|
};
|
|
var currentTab = Cell(ALL_CATEGORY);
|
|
var scan = function (dialogApi) {
|
|
var dialogData = dialogApi.getData();
|
|
var category = currentTab.get();
|
|
var candidates = database.listCategory(category);
|
|
var results = emojisFrom(candidates, dialogData[patternName], category === ALL_CATEGORY ? Optional.some(300) : Optional.none());
|
|
dialogApi.setData({ results: results });
|
|
};
|
|
var updateFilter = last(function (dialogApi) {
|
|
scan(dialogApi);
|
|
}, 200);
|
|
var searchField = {
|
|
label: 'Search',
|
|
type: 'input',
|
|
name: patternName
|
|
};
|
|
var resultsField = {
|
|
type: 'collection',
|
|
name: 'results'
|
|
};
|
|
var getInitialState = function () {
|
|
var body = {
|
|
type: 'tabpanel',
|
|
tabs: map$1(database.listCategories(), function (cat) {
|
|
return {
|
|
title: cat,
|
|
name: cat,
|
|
items: [
|
|
searchField,
|
|
resultsField
|
|
]
|
|
};
|
|
})
|
|
};
|
|
return {
|
|
title: 'Emoticons',
|
|
size: 'normal',
|
|
body: body,
|
|
initialData: initialState,
|
|
onTabChange: function (dialogApi, details) {
|
|
currentTab.set(details.newTabName);
|
|
updateFilter.throttle(dialogApi);
|
|
},
|
|
onChange: updateFilter.throttle,
|
|
onAction: function (dialogApi, actionData) {
|
|
if (actionData.name === 'results') {
|
|
insertEmoticon(editor, actionData.value);
|
|
dialogApi.close();
|
|
}
|
|
},
|
|
buttons: [{
|
|
type: 'cancel',
|
|
text: 'Close',
|
|
primary: true
|
|
}]
|
|
};
|
|
};
|
|
var dialogApi = editor.windowManager.open(getInitialState());
|
|
dialogApi.focus(patternName);
|
|
if (!database.hasLoaded()) {
|
|
dialogApi.block('Loading emoticons...');
|
|
database.waitForLoad().then(function () {
|
|
dialogApi.redial(getInitialState());
|
|
updateFilter.throttle(dialogApi);
|
|
dialogApi.focus(patternName);
|
|
dialogApi.unblock();
|
|
}).catch(function (_err) {
|
|
dialogApi.redial({
|
|
title: 'Emoticons',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'alertbanner',
|
|
level: 'error',
|
|
icon: 'warning',
|
|
text: '<p>Could not load emoticons</p>'
|
|
}]
|
|
},
|
|
buttons: [{
|
|
type: 'cancel',
|
|
text: 'Close',
|
|
primary: true
|
|
}],
|
|
initialData: {
|
|
pattern: '',
|
|
results: []
|
|
}
|
|
});
|
|
dialogApi.focus(patternName);
|
|
dialogApi.unblock();
|
|
});
|
|
}
|
|
};
|
|
|
|
var register$1 = function (editor, database) {
|
|
editor.addCommand('mceEmoticons', function () {
|
|
return open(editor, database);
|
|
});
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
editor.on('PreInit', function () {
|
|
editor.parser.addAttributeFilter('data-emoticon', function (nodes) {
|
|
each$1(nodes, function (node) {
|
|
node.attr('data-mce-resize', 'false');
|
|
node.attr('data-mce-placeholder', '1');
|
|
});
|
|
});
|
|
});
|
|
};
|
|
|
|
var init = function (editor, database) {
|
|
editor.ui.registry.addAutocompleter('emoticons', {
|
|
ch: ':',
|
|
columns: 'auto',
|
|
minChars: 2,
|
|
fetch: function (pattern, maxResults) {
|
|
return database.waitForLoad().then(function () {
|
|
var candidates = database.listAll();
|
|
return emojisFrom(candidates, pattern, Optional.some(maxResults));
|
|
});
|
|
},
|
|
onAction: function (autocompleteApi, rng, value) {
|
|
editor.selection.setRng(rng);
|
|
editor.insertContent(value);
|
|
autocompleteApi.hide();
|
|
}
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceEmoticons');
|
|
};
|
|
editor.ui.registry.addButton('emoticons', {
|
|
tooltip: 'Emoticons',
|
|
icon: 'emoji',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('emoticons', {
|
|
text: 'Emoticons...',
|
|
icon: 'emoji',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$3.add('emoticons', function (editor, pluginUrl) {
|
|
var databaseUrl = getEmoticonDatabaseUrl(editor, pluginUrl);
|
|
var databaseId = getEmoticonDatabaseId(editor);
|
|
var database = initDatabase(editor, databaseUrl, databaseId);
|
|
register$1(editor, database);
|
|
register(editor);
|
|
init(editor, database);
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var get$5 = function (fullscreenState) {
|
|
return {
|
|
isFullscreen: function () {
|
|
return fullscreenState.get() !== null;
|
|
}
|
|
};
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isArray = isType$1('array');
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var compose = function (fa, fb) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return fa(fb.apply(null, args));
|
|
};
|
|
};
|
|
var compose1 = function (fbc, fab) {
|
|
return function (a) {
|
|
return fbc(fab(a));
|
|
};
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
function curry(fn) {
|
|
var initialArgs = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
initialArgs[_i - 1] = arguments[_i];
|
|
}
|
|
return function () {
|
|
var restArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
restArgs[_i] = arguments[_i];
|
|
}
|
|
var all = initialArgs.concat(restArgs);
|
|
return fn.apply(null, all);
|
|
};
|
|
}
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var singleton = function (doRevoke) {
|
|
var subject = Cell(Optional.none());
|
|
var revoke = function () {
|
|
return subject.get().each(doRevoke);
|
|
};
|
|
var clear = function () {
|
|
revoke();
|
|
subject.set(Optional.none());
|
|
};
|
|
var isSet = function () {
|
|
return subject.get().isSome();
|
|
};
|
|
var get = function () {
|
|
return subject.get();
|
|
};
|
|
var set = function (s) {
|
|
revoke();
|
|
subject.set(Optional.some(s));
|
|
};
|
|
return {
|
|
clear: clear,
|
|
isSet: isSet,
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var unbindable = function () {
|
|
return singleton(function (s) {
|
|
return s.unbind();
|
|
});
|
|
};
|
|
var value = function () {
|
|
var subject = singleton(noop);
|
|
var on = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { on: on });
|
|
};
|
|
|
|
var nativePush = Array.prototype.push;
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter$1 = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find$1 = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind$3 = function (xs, f) {
|
|
return flatten(map(xs, f));
|
|
};
|
|
var get$4 = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get$4(xs, 0);
|
|
};
|
|
var findMap = function (arr, f) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var r = f(arr[i], i);
|
|
if (r.isSome()) {
|
|
return r;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
|
|
var contains = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
|
|
var isSupported$1 = function (dom) {
|
|
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
};
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var DOCUMENT = 9;
|
|
var DOCUMENT_FRAGMENT = 11;
|
|
var ELEMENT = 1;
|
|
var TEXT = 3;
|
|
|
|
var type = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type(element) === t;
|
|
};
|
|
};
|
|
var isElement = isType(ELEMENT);
|
|
var isText = isType(TEXT);
|
|
var isDocument = isType(DOCUMENT);
|
|
var isDocumentFragment = isType(DOCUMENT_FRAGMENT);
|
|
|
|
var cached = function (f) {
|
|
var called = false;
|
|
var r;
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (!called) {
|
|
called = true;
|
|
r = f.apply(null, args);
|
|
}
|
|
return r;
|
|
};
|
|
};
|
|
|
|
var DeviceType = function (os, browser, userAgent, mediaMatch) {
|
|
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
|
|
var isiPhone = os.isiOS() && !isiPad;
|
|
var isMobile = os.isiOS() || os.isAndroid();
|
|
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
|
|
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
|
|
var isPhone = isiPhone || isMobile && !isTablet;
|
|
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
|
|
var isDesktop = !isPhone && !isTablet && !iOSwebview;
|
|
return {
|
|
isiPad: constant(isiPad),
|
|
isiPhone: constant(isiPhone),
|
|
isTablet: constant(isTablet),
|
|
isPhone: constant(isPhone),
|
|
isTouch: constant(isTouch),
|
|
isAndroid: os.isAndroid,
|
|
isiOS: os.isiOS,
|
|
isWebView: constant(iOSwebview),
|
|
isDesktop: constant(isDesktop)
|
|
};
|
|
};
|
|
|
|
var firstMatch = function (regexes, s) {
|
|
for (var i = 0; i < regexes.length; i++) {
|
|
var x = regexes[i];
|
|
if (x.test(s)) {
|
|
return x;
|
|
}
|
|
}
|
|
return undefined;
|
|
};
|
|
var find = function (regexes, agent) {
|
|
var r = firstMatch(regexes, agent);
|
|
if (!r) {
|
|
return {
|
|
major: 0,
|
|
minor: 0
|
|
};
|
|
}
|
|
var group = function (i) {
|
|
return Number(agent.replace(r, '$' + i));
|
|
};
|
|
return nu$2(group(1), group(2));
|
|
};
|
|
var detect$3 = function (versionRegexes, agent) {
|
|
var cleanedAgent = String(agent).toLowerCase();
|
|
if (versionRegexes.length === 0) {
|
|
return unknown$2();
|
|
}
|
|
return find(versionRegexes, cleanedAgent);
|
|
};
|
|
var unknown$2 = function () {
|
|
return nu$2(0, 0);
|
|
};
|
|
var nu$2 = function (major, minor) {
|
|
return {
|
|
major: major,
|
|
minor: minor
|
|
};
|
|
};
|
|
var Version = {
|
|
nu: nu$2,
|
|
detect: detect$3,
|
|
unknown: unknown$2
|
|
};
|
|
|
|
var detectBrowser$1 = function (browsers, userAgentData) {
|
|
return findMap(userAgentData.brands, function (uaBrand) {
|
|
var lcBrand = uaBrand.brand.toLowerCase();
|
|
return find$1(browsers, function (browser) {
|
|
var _a;
|
|
return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
}).map(function (info) {
|
|
return {
|
|
current: info.name,
|
|
version: Version.nu(parseInt(uaBrand.version, 10), 0)
|
|
};
|
|
});
|
|
});
|
|
};
|
|
|
|
var detect$2 = function (candidates, userAgent) {
|
|
var agent = String(userAgent).toLowerCase();
|
|
return find$1(candidates, function (candidate) {
|
|
return candidate.search(agent);
|
|
});
|
|
};
|
|
var detectBrowser = function (browsers, userAgent) {
|
|
return detect$2(browsers, userAgent).map(function (browser) {
|
|
var version = Version.detect(browser.versionRegexes, userAgent);
|
|
return {
|
|
current: browser.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
var detectOs = function (oses, userAgent) {
|
|
return detect$2(oses, userAgent).map(function (os) {
|
|
var version = Version.detect(os.versionRegexes, userAgent);
|
|
return {
|
|
current: os.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
|
|
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
|
|
var checkContains = function (target) {
|
|
return function (uastring) {
|
|
return contains(uastring, target);
|
|
};
|
|
};
|
|
var browsers = [
|
|
{
|
|
name: 'Edge',
|
|
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
|
|
search: function (uastring) {
|
|
return contains(uastring, 'edge/') && contains(uastring, 'chrome') && contains(uastring, 'safari') && contains(uastring, 'applewebkit');
|
|
}
|
|
},
|
|
{
|
|
name: 'Chrome',
|
|
brand: 'Chromium',
|
|
versionRegexes: [
|
|
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
|
|
normalVersionRegex
|
|
],
|
|
search: function (uastring) {
|
|
return contains(uastring, 'chrome') && !contains(uastring, 'chromeframe');
|
|
}
|
|
},
|
|
{
|
|
name: 'IE',
|
|
versionRegexes: [
|
|
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*?rv:([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return contains(uastring, 'msie') || contains(uastring, 'trident');
|
|
}
|
|
},
|
|
{
|
|
name: 'Opera',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?opera\/([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: checkContains('opera')
|
|
},
|
|
{
|
|
name: 'Firefox',
|
|
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
|
|
search: checkContains('firefox')
|
|
},
|
|
{
|
|
name: 'Safari',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?cpu os ([0-9]+)_([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return (contains(uastring, 'safari') || contains(uastring, 'mobile/')) && contains(uastring, 'applewebkit');
|
|
}
|
|
}
|
|
];
|
|
var oses = [
|
|
{
|
|
name: 'Windows',
|
|
search: checkContains('win'),
|
|
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'iOS',
|
|
search: function (uastring) {
|
|
return contains(uastring, 'iphone') || contains(uastring, 'ipad');
|
|
},
|
|
versionRegexes: [
|
|
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*cpu os ([0-9]+)_([0-9]+).*/,
|
|
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
|
|
]
|
|
},
|
|
{
|
|
name: 'Android',
|
|
search: checkContains('android'),
|
|
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'OSX',
|
|
search: checkContains('mac os x'),
|
|
versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'Linux',
|
|
search: checkContains('linux'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'Solaris',
|
|
search: checkContains('sunos'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'FreeBSD',
|
|
search: checkContains('freebsd'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'ChromeOS',
|
|
search: checkContains('cros'),
|
|
versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
|
|
}
|
|
];
|
|
var PlatformInfo = {
|
|
browsers: constant(browsers),
|
|
oses: constant(oses)
|
|
};
|
|
|
|
var edge = 'Edge';
|
|
var chrome = 'Chrome';
|
|
var ie = 'IE';
|
|
var opera = 'Opera';
|
|
var firefox = 'Firefox';
|
|
var safari = 'Safari';
|
|
var unknown$1 = function () {
|
|
return nu$1({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu$1 = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isBrowser = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isEdge: isBrowser(edge),
|
|
isChrome: isBrowser(chrome),
|
|
isIE: isBrowser(ie),
|
|
isOpera: isBrowser(opera),
|
|
isFirefox: isBrowser(firefox),
|
|
isSafari: isBrowser(safari)
|
|
};
|
|
};
|
|
var Browser = {
|
|
unknown: unknown$1,
|
|
nu: nu$1,
|
|
edge: constant(edge),
|
|
chrome: constant(chrome),
|
|
ie: constant(ie),
|
|
opera: constant(opera),
|
|
firefox: constant(firefox),
|
|
safari: constant(safari)
|
|
};
|
|
|
|
var windows = 'Windows';
|
|
var ios = 'iOS';
|
|
var android = 'Android';
|
|
var linux = 'Linux';
|
|
var osx = 'OSX';
|
|
var solaris = 'Solaris';
|
|
var freebsd = 'FreeBSD';
|
|
var chromeos = 'ChromeOS';
|
|
var unknown = function () {
|
|
return nu({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isOS = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isWindows: isOS(windows),
|
|
isiOS: isOS(ios),
|
|
isAndroid: isOS(android),
|
|
isOSX: isOS(osx),
|
|
isLinux: isOS(linux),
|
|
isSolaris: isOS(solaris),
|
|
isFreeBSD: isOS(freebsd),
|
|
isChromeOS: isOS(chromeos)
|
|
};
|
|
};
|
|
var OperatingSystem = {
|
|
unknown: unknown,
|
|
nu: nu,
|
|
windows: constant(windows),
|
|
ios: constant(ios),
|
|
android: constant(android),
|
|
linux: constant(linux),
|
|
osx: constant(osx),
|
|
solaris: constant(solaris),
|
|
freebsd: constant(freebsd),
|
|
chromeos: constant(chromeos)
|
|
};
|
|
|
|
var detect$1 = function (userAgent, userAgentDataOpt, mediaMatch) {
|
|
var browsers = PlatformInfo.browsers();
|
|
var oses = PlatformInfo.oses();
|
|
var browser = userAgentDataOpt.bind(function (userAgentData) {
|
|
return detectBrowser$1(browsers, userAgentData);
|
|
}).orThunk(function () {
|
|
return detectBrowser(browsers, userAgent);
|
|
}).fold(Browser.unknown, Browser.nu);
|
|
var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
|
|
var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
|
|
return {
|
|
browser: browser,
|
|
os: os,
|
|
deviceType: deviceType
|
|
};
|
|
};
|
|
var PlatformDetection = { detect: detect$1 };
|
|
|
|
var mediaMatch = function (query) {
|
|
return window.matchMedia(query).matches;
|
|
};
|
|
var platform = cached(function () {
|
|
return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
|
|
});
|
|
var detect = function () {
|
|
return platform();
|
|
};
|
|
|
|
var is = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
var bypassSelector = function (dom) {
|
|
return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
|
|
};
|
|
var all$1 = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom);
|
|
};
|
|
|
|
var eq = function (e1, e2) {
|
|
return e1.dom === e2.dom;
|
|
};
|
|
|
|
var owner = function (element) {
|
|
return SugarElement.fromDom(element.dom.ownerDocument);
|
|
};
|
|
var documentOrOwner = function (dos) {
|
|
return isDocument(dos) ? dos : owner(dos);
|
|
};
|
|
var parent = function (element) {
|
|
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
};
|
|
var parents = function (element, isRoot) {
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
var dom = element.dom;
|
|
var ret = [];
|
|
while (dom.parentNode !== null && dom.parentNode !== undefined) {
|
|
var rawParent = dom.parentNode;
|
|
var p = SugarElement.fromDom(rawParent);
|
|
ret.push(p);
|
|
if (stop(p) === true) {
|
|
break;
|
|
} else {
|
|
dom = rawParent;
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
var siblings$2 = function (element) {
|
|
var filterSelf = function (elements) {
|
|
return filter$1(elements, function (x) {
|
|
return !eq(element, x);
|
|
});
|
|
};
|
|
return parent(element).map(children).map(filterSelf).getOr([]);
|
|
};
|
|
var children = function (element) {
|
|
return map(element.dom.childNodes, SugarElement.fromDom);
|
|
};
|
|
|
|
var isShadowRoot = function (dos) {
|
|
return isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
};
|
|
var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
|
|
var isSupported = constant(supported);
|
|
var getRootNode = supported ? function (e) {
|
|
return SugarElement.fromDom(e.dom.getRootNode());
|
|
} : documentOrOwner;
|
|
var getShadowRoot = function (e) {
|
|
var r = getRootNode(e);
|
|
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
};
|
|
var getShadowHost = function (e) {
|
|
return SugarElement.fromDom(e.dom.host);
|
|
};
|
|
var getOriginalEventTarget = function (event) {
|
|
if (isSupported() && isNonNullable(event.target)) {
|
|
var el = SugarElement.fromDom(event.target);
|
|
if (isElement(el) && isOpenShadowHost(el)) {
|
|
if (event.composed && event.composedPath) {
|
|
var composedPath = event.composedPath();
|
|
if (composedPath) {
|
|
return head(composedPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Optional.from(event.target);
|
|
};
|
|
var isOpenShadowHost = function (element) {
|
|
return isNonNullable(element.dom.shadowRoot);
|
|
};
|
|
|
|
var inBody = function (element) {
|
|
var dom = isText(element) ? element.dom.parentNode : element.dom;
|
|
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
return false;
|
|
}
|
|
var doc = dom.ownerDocument;
|
|
return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {
|
|
return doc.body.contains(dom);
|
|
}, compose1(inBody, getShadowHost));
|
|
};
|
|
var getBody = function (doc) {
|
|
var b = doc.dom.body;
|
|
if (b === null || b === undefined) {
|
|
throw new Error('Body is not available yet');
|
|
}
|
|
return SugarElement.fromDom(b);
|
|
};
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
var get$3 = function (element, key) {
|
|
var v = element.dom.getAttribute(key);
|
|
return v === null ? undefined : v;
|
|
};
|
|
var remove = function (element, key) {
|
|
element.dom.removeAttribute(key);
|
|
};
|
|
|
|
var internalSet = function (dom, property, value) {
|
|
if (!isString(value)) {
|
|
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('CSS value must be a string: ' + value);
|
|
}
|
|
if (isSupported$1(dom)) {
|
|
dom.style.setProperty(property, value);
|
|
}
|
|
};
|
|
var setAll = function (element, css) {
|
|
var dom = element.dom;
|
|
each(css, function (v, k) {
|
|
internalSet(dom, k, v);
|
|
});
|
|
};
|
|
var get$2 = function (element, property) {
|
|
var dom = element.dom;
|
|
var styles = window.getComputedStyle(dom);
|
|
var r = styles.getPropertyValue(property);
|
|
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
|
|
};
|
|
var getUnsafeProperty = function (dom, property) {
|
|
return isSupported$1(dom) ? dom.style.getPropertyValue(property) : '';
|
|
};
|
|
|
|
var mkEvent = function (target, x, y, stop, prevent, kill, raw) {
|
|
return {
|
|
target: target,
|
|
x: x,
|
|
y: y,
|
|
stop: stop,
|
|
prevent: prevent,
|
|
kill: kill,
|
|
raw: raw
|
|
};
|
|
};
|
|
var fromRawEvent = function (rawEvent) {
|
|
var target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target));
|
|
var stop = function () {
|
|
return rawEvent.stopPropagation();
|
|
};
|
|
var prevent = function () {
|
|
return rawEvent.preventDefault();
|
|
};
|
|
var kill = compose(prevent, stop);
|
|
return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent);
|
|
};
|
|
var handle = function (filter, handler) {
|
|
return function (rawEvent) {
|
|
if (filter(rawEvent)) {
|
|
handler(fromRawEvent(rawEvent));
|
|
}
|
|
};
|
|
};
|
|
var binder = function (element, event, filter, handler, useCapture) {
|
|
var wrapped = handle(filter, handler);
|
|
element.dom.addEventListener(event, wrapped, useCapture);
|
|
return { unbind: curry(unbind, element, event, wrapped, useCapture) };
|
|
};
|
|
var bind$2 = function (element, event, filter, handler) {
|
|
return binder(element, event, filter, handler, false);
|
|
};
|
|
var unbind = function (element, event, handler, useCapture) {
|
|
element.dom.removeEventListener(event, handler, useCapture);
|
|
};
|
|
|
|
var filter = always;
|
|
var bind$1 = function (element, event, handler) {
|
|
return bind$2(element, event, filter, handler);
|
|
};
|
|
|
|
var r = function (left, top) {
|
|
var translate = function (x, y) {
|
|
return r(left + x, top + y);
|
|
};
|
|
return {
|
|
left: left,
|
|
top: top,
|
|
translate: translate
|
|
};
|
|
};
|
|
var SugarPosition = r;
|
|
|
|
var get$1 = function (_DOC) {
|
|
var doc = _DOC !== undefined ? _DOC.dom : document;
|
|
var x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
|
|
var y = doc.body.scrollTop || doc.documentElement.scrollTop;
|
|
return SugarPosition(x, y);
|
|
};
|
|
|
|
var get = function (_win) {
|
|
var win = _win === undefined ? window : _win;
|
|
if (detect().browser.isFirefox()) {
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.from(win['visualViewport']);
|
|
}
|
|
};
|
|
var bounds = function (x, y, width, height) {
|
|
return {
|
|
x: x,
|
|
y: y,
|
|
width: width,
|
|
height: height,
|
|
right: x + width,
|
|
bottom: y + height
|
|
};
|
|
};
|
|
var getBounds = function (_win) {
|
|
var win = _win === undefined ? window : _win;
|
|
var doc = win.document;
|
|
var scroll = get$1(SugarElement.fromDom(doc));
|
|
return get(win).fold(function () {
|
|
var html = win.document.documentElement;
|
|
var width = html.clientWidth;
|
|
var height = html.clientHeight;
|
|
return bounds(scroll.left, scroll.top, width, height);
|
|
}, function (visualViewport) {
|
|
return bounds(Math.max(visualViewport.pageLeft, scroll.left), Math.max(visualViewport.pageTop, scroll.top), visualViewport.width, visualViewport.height);
|
|
});
|
|
};
|
|
var bind = function (name, callback, _win) {
|
|
return get(_win).map(function (visualViewport) {
|
|
var handler = function (e) {
|
|
return callback(fromRawEvent(e));
|
|
};
|
|
visualViewport.addEventListener(name, handler);
|
|
return {
|
|
unbind: function () {
|
|
return visualViewport.removeEventListener(name, handler);
|
|
}
|
|
};
|
|
}).getOrThunk(function () {
|
|
return { unbind: noop };
|
|
});
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var fireFullscreenStateChanged = function (editor, state) {
|
|
editor.fire('FullscreenStateChanged', { state: state });
|
|
editor.fire('ResizeEditor');
|
|
};
|
|
|
|
var getFullscreenNative = function (editor) {
|
|
return editor.getParam('fullscreen_native', false, 'boolean');
|
|
};
|
|
|
|
var getFullscreenRoot = function (editor) {
|
|
var elem = SugarElement.fromDom(editor.getElement());
|
|
return getShadowRoot(elem).map(getShadowHost).getOrThunk(function () {
|
|
return getBody(owner(elem));
|
|
});
|
|
};
|
|
var getFullscreenElement = function (root) {
|
|
if (root.fullscreenElement !== undefined) {
|
|
return root.fullscreenElement;
|
|
} else if (root.msFullscreenElement !== undefined) {
|
|
return root.msFullscreenElement;
|
|
} else if (root.webkitFullscreenElement !== undefined) {
|
|
return root.webkitFullscreenElement;
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
var getFullscreenchangeEventName = function () {
|
|
if (document.fullscreenElement !== undefined) {
|
|
return 'fullscreenchange';
|
|
} else if (document.msFullscreenElement !== undefined) {
|
|
return 'MSFullscreenChange';
|
|
} else if (document.webkitFullscreenElement !== undefined) {
|
|
return 'webkitfullscreenchange';
|
|
} else {
|
|
return 'fullscreenchange';
|
|
}
|
|
};
|
|
var requestFullscreen = function (sugarElem) {
|
|
var elem = sugarElem.dom;
|
|
if (elem.requestFullscreen) {
|
|
elem.requestFullscreen();
|
|
} else if (elem.msRequestFullscreen) {
|
|
elem.msRequestFullscreen();
|
|
} else if (elem.webkitRequestFullScreen) {
|
|
elem.webkitRequestFullScreen();
|
|
}
|
|
};
|
|
var exitFullscreen = function (sugarDoc) {
|
|
var doc = sugarDoc.dom;
|
|
if (doc.exitFullscreen) {
|
|
doc.exitFullscreen();
|
|
} else if (doc.msExitFullscreen) {
|
|
doc.msExitFullscreen();
|
|
} else if (doc.webkitCancelFullScreen) {
|
|
doc.webkitCancelFullScreen();
|
|
}
|
|
};
|
|
var isFullscreenElement = function (elem) {
|
|
return elem.dom === getFullscreenElement(owner(elem).dom);
|
|
};
|
|
|
|
var ancestors$1 = function (scope, predicate, isRoot) {
|
|
return filter$1(parents(scope, isRoot), predicate);
|
|
};
|
|
var siblings$1 = function (scope, predicate) {
|
|
return filter$1(siblings$2(scope), predicate);
|
|
};
|
|
|
|
var all = function (selector) {
|
|
return all$1(selector);
|
|
};
|
|
var ancestors = function (scope, selector, isRoot) {
|
|
return ancestors$1(scope, function (e) {
|
|
return is(e, selector);
|
|
}, isRoot);
|
|
};
|
|
var siblings = function (scope, selector) {
|
|
return siblings$1(scope, function (e) {
|
|
return is(e, selector);
|
|
});
|
|
};
|
|
|
|
var attr = 'data-ephox-mobile-fullscreen-style';
|
|
var siblingStyles = 'display:none!important;';
|
|
var ancestorPosition = 'position:absolute!important;';
|
|
var ancestorStyles = 'top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;';
|
|
var bgFallback = 'background-color:rgb(255,255,255)!important;';
|
|
var isAndroid = global$1.os.isAndroid();
|
|
var matchColor = function (editorBody) {
|
|
var color = get$2(editorBody, 'background-color');
|
|
return color !== undefined && color !== '' ? 'background-color:' + color + '!important' : bgFallback;
|
|
};
|
|
var clobberStyles = function (dom, container, editorBody) {
|
|
var gatherSiblings = function (element) {
|
|
return siblings(element, '*:not(.tox-silver-sink)');
|
|
};
|
|
var clobber = function (clobberStyle) {
|
|
return function (element) {
|
|
var styles = get$3(element, 'style');
|
|
var backup = styles === undefined ? 'no-styles' : styles.trim();
|
|
if (backup === clobberStyle) {
|
|
return;
|
|
} else {
|
|
set(element, attr, backup);
|
|
setAll(element, dom.parseStyle(clobberStyle));
|
|
}
|
|
};
|
|
};
|
|
var ancestors$1 = ancestors(container, '*');
|
|
var siblings$1 = bind$3(ancestors$1, gatherSiblings);
|
|
var bgColor = matchColor(editorBody);
|
|
each$1(siblings$1, clobber(siblingStyles));
|
|
each$1(ancestors$1, clobber(ancestorPosition + ancestorStyles + bgColor));
|
|
var containerStyles = isAndroid === true ? '' : ancestorPosition;
|
|
clobber(containerStyles + ancestorStyles + bgColor)(container);
|
|
};
|
|
var restoreStyles = function (dom) {
|
|
var clobberedEls = all('[' + attr + ']');
|
|
each$1(clobberedEls, function (element) {
|
|
var restore = get$3(element, attr);
|
|
if (restore !== 'no-styles') {
|
|
setAll(element, dom.parseStyle(restore));
|
|
} else {
|
|
remove(element, 'style');
|
|
}
|
|
remove(element, attr);
|
|
});
|
|
};
|
|
|
|
var DOM = global$2.DOM;
|
|
var getScrollPos = function () {
|
|
return getBounds(window);
|
|
};
|
|
var setScrollPos = function (pos) {
|
|
return window.scrollTo(pos.x, pos.y);
|
|
};
|
|
var viewportUpdate = get().fold(function () {
|
|
return {
|
|
bind: noop,
|
|
unbind: noop
|
|
};
|
|
}, function (visualViewport) {
|
|
var editorContainer = value();
|
|
var resizeBinder = unbindable();
|
|
var scrollBinder = unbindable();
|
|
var refreshScroll = function () {
|
|
document.body.scrollTop = 0;
|
|
document.documentElement.scrollTop = 0;
|
|
};
|
|
var refreshVisualViewport = function () {
|
|
window.requestAnimationFrame(function () {
|
|
editorContainer.on(function (container) {
|
|
return setAll(container, {
|
|
top: visualViewport.offsetTop + 'px',
|
|
left: visualViewport.offsetLeft + 'px',
|
|
height: visualViewport.height + 'px',
|
|
width: visualViewport.width + 'px'
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var update = global.throttle(function () {
|
|
refreshScroll();
|
|
refreshVisualViewport();
|
|
}, 50);
|
|
var bind$1 = function (element) {
|
|
editorContainer.set(element);
|
|
update();
|
|
resizeBinder.set(bind('resize', update));
|
|
scrollBinder.set(bind('scroll', update));
|
|
};
|
|
var unbind = function () {
|
|
editorContainer.on(function () {
|
|
resizeBinder.clear();
|
|
scrollBinder.clear();
|
|
});
|
|
editorContainer.clear();
|
|
};
|
|
return {
|
|
bind: bind$1,
|
|
unbind: unbind
|
|
};
|
|
});
|
|
var toggleFullscreen = function (editor, fullscreenState) {
|
|
var body = document.body;
|
|
var documentElement = document.documentElement;
|
|
var editorContainer = editor.getContainer();
|
|
var editorContainerS = SugarElement.fromDom(editorContainer);
|
|
var fullscreenRoot = getFullscreenRoot(editor);
|
|
var fullscreenInfo = fullscreenState.get();
|
|
var editorBody = SugarElement.fromDom(editor.getBody());
|
|
var isTouch = global$1.deviceType.isTouch();
|
|
var editorContainerStyle = editorContainer.style;
|
|
var iframe = editor.iframeElement;
|
|
var iframeStyle = iframe.style;
|
|
var handleClasses = function (handler) {
|
|
handler(body, 'tox-fullscreen');
|
|
handler(documentElement, 'tox-fullscreen');
|
|
handler(editorContainer, 'tox-fullscreen');
|
|
getShadowRoot(editorContainerS).map(function (root) {
|
|
return getShadowHost(root).dom;
|
|
}).each(function (host) {
|
|
handler(host, 'tox-fullscreen');
|
|
handler(host, 'tox-shadowhost');
|
|
});
|
|
};
|
|
var cleanup = function () {
|
|
if (isTouch) {
|
|
restoreStyles(editor.dom);
|
|
}
|
|
handleClasses(DOM.removeClass);
|
|
viewportUpdate.unbind();
|
|
Optional.from(fullscreenState.get()).each(function (info) {
|
|
return info.fullscreenChangeHandler.unbind();
|
|
});
|
|
};
|
|
if (!fullscreenInfo) {
|
|
var fullscreenChangeHandler = bind$1(owner(fullscreenRoot), getFullscreenchangeEventName(), function (_evt) {
|
|
if (getFullscreenNative(editor)) {
|
|
if (!isFullscreenElement(fullscreenRoot) && fullscreenState.get() !== null) {
|
|
toggleFullscreen(editor, fullscreenState);
|
|
}
|
|
}
|
|
});
|
|
var newFullScreenInfo = {
|
|
scrollPos: getScrollPos(),
|
|
containerWidth: editorContainerStyle.width,
|
|
containerHeight: editorContainerStyle.height,
|
|
containerTop: editorContainerStyle.top,
|
|
containerLeft: editorContainerStyle.left,
|
|
iframeWidth: iframeStyle.width,
|
|
iframeHeight: iframeStyle.height,
|
|
fullscreenChangeHandler: fullscreenChangeHandler
|
|
};
|
|
if (isTouch) {
|
|
clobberStyles(editor.dom, editorContainerS, editorBody);
|
|
}
|
|
iframeStyle.width = iframeStyle.height = '100%';
|
|
editorContainerStyle.width = editorContainerStyle.height = '';
|
|
handleClasses(DOM.addClass);
|
|
viewportUpdate.bind(editorContainerS);
|
|
editor.on('remove', cleanup);
|
|
fullscreenState.set(newFullScreenInfo);
|
|
if (getFullscreenNative(editor)) {
|
|
requestFullscreen(fullscreenRoot);
|
|
}
|
|
fireFullscreenStateChanged(editor, true);
|
|
} else {
|
|
fullscreenInfo.fullscreenChangeHandler.unbind();
|
|
if (getFullscreenNative(editor) && isFullscreenElement(fullscreenRoot)) {
|
|
exitFullscreen(owner(fullscreenRoot));
|
|
}
|
|
iframeStyle.width = fullscreenInfo.iframeWidth;
|
|
iframeStyle.height = fullscreenInfo.iframeHeight;
|
|
editorContainerStyle.width = fullscreenInfo.containerWidth;
|
|
editorContainerStyle.height = fullscreenInfo.containerHeight;
|
|
editorContainerStyle.top = fullscreenInfo.containerTop;
|
|
editorContainerStyle.left = fullscreenInfo.containerLeft;
|
|
cleanup();
|
|
setScrollPos(fullscreenInfo.scrollPos);
|
|
fullscreenState.set(null);
|
|
fireFullscreenStateChanged(editor, false);
|
|
editor.off('remove', cleanup);
|
|
}
|
|
};
|
|
|
|
var register$1 = function (editor, fullscreenState) {
|
|
editor.addCommand('mceFullScreen', function () {
|
|
toggleFullscreen(editor, fullscreenState);
|
|
});
|
|
};
|
|
|
|
var makeSetupHandler = function (editor, fullscreenState) {
|
|
return function (api) {
|
|
api.setActive(fullscreenState.get() !== null);
|
|
var editorEventCallback = function (e) {
|
|
return api.setActive(e.state);
|
|
};
|
|
editor.on('FullscreenStateChanged', editorEventCallback);
|
|
return function () {
|
|
return editor.off('FullscreenStateChanged', editorEventCallback);
|
|
};
|
|
};
|
|
};
|
|
var register = function (editor, fullscreenState) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceFullScreen');
|
|
};
|
|
editor.ui.registry.addToggleMenuItem('fullscreen', {
|
|
text: 'Fullscreen',
|
|
icon: 'fullscreen',
|
|
shortcut: 'Meta+Shift+F',
|
|
onAction: onAction,
|
|
onSetup: makeSetupHandler(editor, fullscreenState)
|
|
});
|
|
editor.ui.registry.addToggleButton('fullscreen', {
|
|
tooltip: 'Fullscreen',
|
|
icon: 'fullscreen',
|
|
onAction: onAction,
|
|
onSetup: makeSetupHandler(editor, fullscreenState)
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$3.add('fullscreen', function (editor) {
|
|
var fullscreenState = Cell(null);
|
|
if (editor.inline) {
|
|
return get$5(fullscreenState);
|
|
}
|
|
register$1(editor, fullscreenState);
|
|
register(editor, fullscreenState);
|
|
editor.addShortcut('Meta+Shift+F', '', 'mceFullScreen');
|
|
return get$5(fullscreenState);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var get$1 = function (customTabs) {
|
|
var addTab = function (spec) {
|
|
var currentCustomTabs = customTabs.get();
|
|
currentCustomTabs[spec.name] = spec;
|
|
customTabs.set(currentCustomTabs);
|
|
};
|
|
return { addTab: addTab };
|
|
};
|
|
|
|
var register$1 = function (editor, dialogOpener) {
|
|
editor.addCommand('mceHelp', dialogOpener);
|
|
};
|
|
|
|
var register = function (editor, dialogOpener) {
|
|
editor.ui.registry.addButton('help', {
|
|
icon: 'help',
|
|
tooltip: 'Help',
|
|
onAction: dialogOpener
|
|
});
|
|
editor.ui.registry.addMenuItem('help', {
|
|
text: 'Help',
|
|
icon: 'help',
|
|
shortcut: 'Alt+0',
|
|
onAction: dialogOpener
|
|
});
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var nativeIndexOf = Array.prototype.indexOf;
|
|
var rawIndexOf = function (ts, t) {
|
|
return nativeIndexOf.call(ts, t);
|
|
};
|
|
var contains = function (xs, x) {
|
|
return rawIndexOf(xs, x) > -1;
|
|
};
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var filter = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var get = function (obj, key) {
|
|
return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
|
|
};
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
var cat = function (arr) {
|
|
var r = [];
|
|
var push = function (x) {
|
|
r.push(x);
|
|
};
|
|
for (var i = 0; i < arr.length; i++) {
|
|
arr[i].each(push);
|
|
}
|
|
return r;
|
|
};
|
|
|
|
var getHelpTabs = function (editor) {
|
|
return Optional.from(editor.getParam('help_tabs'));
|
|
};
|
|
var getForcedPlugins = function (editor) {
|
|
return editor.getParam('forced_plugins');
|
|
};
|
|
|
|
var description = '<h1>Editor UI keyboard navigation</h1>\n\n<h2>Activating keyboard navigation</h2>\n\n<p>The sections of the outer UI of the editor - the menubar, toolbar, sidebar and footer - are all keyboard navigable. As such, there are multiple ways to activate keyboard navigation:</p>\n<ul>\n <li>Focus the menubar: Alt + F9 (Windows) or ⌥F9 (MacOS)</li>\n <li>Focus the toolbar: Alt + F10 (Windows) or ⌥F10 (MacOS)</li>\n <li>Focus the footer: Alt + F11 (Windows) or ⌥F11 (MacOS)</li>\n</ul>\n\n<p>Focusing the menubar or toolbar will start keyboard navigation at the first item in the menubar or toolbar, which will be highlighted with a gray background. Focusing the footer will start keyboard navigation at the first item in the element path, which will be highlighted with an underline. </p>\n\n<h2>Moving between UI sections</h2>\n\n<p>When keyboard navigation is active, pressing tab will move the focus to the next major section of the UI, where applicable. These sections are:</p>\n<ul>\n <li>the menubar</li>\n <li>each group of the toolbar </li>\n <li>the sidebar</li>\n <li>the element path in the footer </li>\n <li>the wordcount toggle button in the footer </li>\n <li>the branding link in the footer </li>\n <li>the editor resize handle in the footer</li>\n</ul>\n\n<p>Pressing shift + tab will move backwards through the same sections, except when moving from the footer to the toolbar. Focusing the element path then pressing shift + tab will move focus to the first toolbar group, not the last.</p>\n\n<h2>Moving within UI sections</h2>\n\n<p>Keyboard navigation within UI sections can usually be achieved using the left and right arrow keys. This includes:</p>\n<ul>\n <li>moving between menus in the menubar</li>\n <li>moving between buttons in a toolbar group</li>\n <li>moving between items in the element path</li>\n</ul>\n\n<p>In all these UI sections, keyboard navigation will cycle within the section. For example, focusing the last button in a toolbar group then pressing right arrow will move focus to the first item in the same toolbar group. </p>\n\n<h1>Executing buttons</h1>\n\n<p>To execute a button, navigate the selection to the desired button and hit space or enter.</p>\n\n<h1>Opening, navigating and closing menus</h1>\n\n<p>When focusing a menubar button or a toolbar button with a menu, pressing space, enter or down arrow will open the menu. When the menu opens the first item will be selected. To move up or down the menu, press the up or down arrow key respectively. This is the same for submenus, which can also be opened and closed using the left and right arrow keys.</p>\n\n<p>To close any active menu, hit the escape key. When a menu is closed the selection will be restored to its previous selection. This also works for closing submenus.</p>\n\n<h1>Context toolbars and menus</h1>\n\n<p>To focus an open context toolbar such as the table context toolbar, press Ctrl + F9 (Windows) or ⌃F9 (MacOS).</p>\n\n<p>Context toolbar navigation is the same as toolbar navigation, and context menu navigation is the same as standard menu navigation.</p>\n\n<h1>Dialog navigation</h1>\n\n<p>There are two types of dialog UIs in TinyMCE: tabbed dialogs and non-tabbed dialogs.</p>\n\n<p>When a non-tabbed dialog is opened, the first interactive component in the dialog will be focused. Users can navigate between interactive components by pressing tab. This includes any footer buttons. Navigation will cycle back to the first dialog component if tab is pressed while focusing the last component in the dialog. Pressing shift + tab will navigate backwards.</p>\n\n<p>When a tabbed dialog is opened, the first button in the tab menu is focused. Pressing tab will navigate to the first interactive component in that tab, and will cycle through the tab\u2019s components, the footer buttons, then back to the tab button. To switch to another tab, focus the tab button for the current tab, then use the arrow keys to cycle through the tab buttons.</p>';
|
|
var tab$3 = function () {
|
|
var body = {
|
|
type: 'htmlpanel',
|
|
presets: 'document',
|
|
html: description
|
|
};
|
|
return {
|
|
name: 'keyboardnav',
|
|
title: 'Keyboard Navigation',
|
|
items: [body]
|
|
};
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var convertText = function (source) {
|
|
var mac = {
|
|
alt: '⌥',
|
|
ctrl: '⌃',
|
|
shift: '⇧',
|
|
meta: '⌘',
|
|
access: '⌃⌥'
|
|
};
|
|
var other = {
|
|
meta: 'Ctrl ',
|
|
access: 'Shift + Alt '
|
|
};
|
|
var replace = global$2.mac ? mac : other;
|
|
var shortcut = source.split('+');
|
|
var updated = map(shortcut, function (segment) {
|
|
var search = segment.toLowerCase().trim();
|
|
return has(replace, search) ? replace[search] : segment;
|
|
});
|
|
return global$2.mac ? updated.join('').replace(/\s/, '') : updated.join('+');
|
|
};
|
|
|
|
var shortcuts = [
|
|
{
|
|
shortcuts: ['Meta + B'],
|
|
action: 'Bold'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + I'],
|
|
action: 'Italic'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + U'],
|
|
action: 'Underline'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + A'],
|
|
action: 'Select all'
|
|
},
|
|
{
|
|
shortcuts: [
|
|
'Meta + Y',
|
|
'Meta + Shift + Z'
|
|
],
|
|
action: 'Redo'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + Z'],
|
|
action: 'Undo'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 1'],
|
|
action: 'Heading 1'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 2'],
|
|
action: 'Heading 2'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 3'],
|
|
action: 'Heading 3'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 4'],
|
|
action: 'Heading 4'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 5'],
|
|
action: 'Heading 5'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 6'],
|
|
action: 'Heading 6'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 7'],
|
|
action: 'Paragraph'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 8'],
|
|
action: 'Div'
|
|
},
|
|
{
|
|
shortcuts: ['Access + 9'],
|
|
action: 'Address'
|
|
},
|
|
{
|
|
shortcuts: ['Alt + 0'],
|
|
action: 'Open help dialog'
|
|
},
|
|
{
|
|
shortcuts: ['Alt + F9'],
|
|
action: 'Focus to menubar'
|
|
},
|
|
{
|
|
shortcuts: ['Alt + F10'],
|
|
action: 'Focus to toolbar'
|
|
},
|
|
{
|
|
shortcuts: ['Alt + F11'],
|
|
action: 'Focus to element path'
|
|
},
|
|
{
|
|
shortcuts: ['Ctrl + F9'],
|
|
action: 'Focus to contextual toolbar'
|
|
},
|
|
{
|
|
shortcuts: ['Shift + Enter'],
|
|
action: 'Open popup menu for split buttons'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + K'],
|
|
action: 'Insert link (if link plugin activated)'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + S'],
|
|
action: 'Save (if save plugin activated)'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + F'],
|
|
action: 'Find (if searchreplace plugin activated)'
|
|
},
|
|
{
|
|
shortcuts: ['Meta + Shift + F'],
|
|
action: 'Switch to or from fullscreen mode'
|
|
}
|
|
];
|
|
|
|
var tab$2 = function () {
|
|
var shortcutList = map(shortcuts, function (shortcut) {
|
|
var shortcutText = map(shortcut.shortcuts, convertText).join(' or ');
|
|
return [
|
|
shortcut.action,
|
|
shortcutText
|
|
];
|
|
});
|
|
var tablePanel = {
|
|
type: 'table',
|
|
header: [
|
|
'Action',
|
|
'Shortcut'
|
|
],
|
|
cells: shortcutList
|
|
};
|
|
return {
|
|
name: 'shortcuts',
|
|
title: 'Handy Shortcuts',
|
|
items: [tablePanel]
|
|
};
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.I18n');
|
|
|
|
var urls = map([
|
|
{
|
|
key: 'advlist',
|
|
name: 'Advanced List'
|
|
},
|
|
{
|
|
key: 'anchor',
|
|
name: 'Anchor'
|
|
},
|
|
{
|
|
key: 'autolink',
|
|
name: 'Autolink'
|
|
},
|
|
{
|
|
key: 'autoresize',
|
|
name: 'Autoresize'
|
|
},
|
|
{
|
|
key: 'autosave',
|
|
name: 'Autosave'
|
|
},
|
|
{
|
|
key: 'bbcode',
|
|
name: 'BBCode'
|
|
},
|
|
{
|
|
key: 'charmap',
|
|
name: 'Character Map'
|
|
},
|
|
{
|
|
key: 'code',
|
|
name: 'Code'
|
|
},
|
|
{
|
|
key: 'codesample',
|
|
name: 'Code Sample'
|
|
},
|
|
{
|
|
key: 'colorpicker',
|
|
name: 'Color Picker'
|
|
},
|
|
{
|
|
key: 'directionality',
|
|
name: 'Directionality'
|
|
},
|
|
{
|
|
key: 'emoticons',
|
|
name: 'Emoticons'
|
|
},
|
|
{
|
|
key: 'fullpage',
|
|
name: 'Full Page'
|
|
},
|
|
{
|
|
key: 'fullscreen',
|
|
name: 'Full Screen'
|
|
},
|
|
{
|
|
key: 'help',
|
|
name: 'Help'
|
|
},
|
|
{
|
|
key: 'hr',
|
|
name: 'Horizontal Rule'
|
|
},
|
|
{
|
|
key: 'image',
|
|
name: 'Image'
|
|
},
|
|
{
|
|
key: 'imagetools',
|
|
name: 'Image Tools'
|
|
},
|
|
{
|
|
key: 'importcss',
|
|
name: 'Import CSS'
|
|
},
|
|
{
|
|
key: 'insertdatetime',
|
|
name: 'Insert Date/Time'
|
|
},
|
|
{
|
|
key: 'legacyoutput',
|
|
name: 'Legacy Output'
|
|
},
|
|
{
|
|
key: 'link',
|
|
name: 'Link'
|
|
},
|
|
{
|
|
key: 'lists',
|
|
name: 'Lists'
|
|
},
|
|
{
|
|
key: 'media',
|
|
name: 'Media'
|
|
},
|
|
{
|
|
key: 'nonbreaking',
|
|
name: 'Nonbreaking'
|
|
},
|
|
{
|
|
key: 'noneditable',
|
|
name: 'Noneditable'
|
|
},
|
|
{
|
|
key: 'pagebreak',
|
|
name: 'Page Break'
|
|
},
|
|
{
|
|
key: 'paste',
|
|
name: 'Paste'
|
|
},
|
|
{
|
|
key: 'preview',
|
|
name: 'Preview'
|
|
},
|
|
{
|
|
key: 'print',
|
|
name: 'Print'
|
|
},
|
|
{
|
|
key: 'quickbars',
|
|
name: 'Quick Toolbars'
|
|
},
|
|
{
|
|
key: 'save',
|
|
name: 'Save'
|
|
},
|
|
{
|
|
key: 'searchreplace',
|
|
name: 'Search and Replace'
|
|
},
|
|
{
|
|
key: 'spellchecker',
|
|
name: 'Spell Checker'
|
|
},
|
|
{
|
|
key: 'tabfocus',
|
|
name: 'Tab Focus'
|
|
},
|
|
{
|
|
key: 'table',
|
|
name: 'Table'
|
|
},
|
|
{
|
|
key: 'template',
|
|
name: 'Template'
|
|
},
|
|
{
|
|
key: 'textcolor',
|
|
name: 'Text Color'
|
|
},
|
|
{
|
|
key: 'textpattern',
|
|
name: 'Text Pattern'
|
|
},
|
|
{
|
|
key: 'toc',
|
|
name: 'Table of Contents'
|
|
},
|
|
{
|
|
key: 'visualblocks',
|
|
name: 'Visual Blocks'
|
|
},
|
|
{
|
|
key: 'visualchars',
|
|
name: 'Visual Characters'
|
|
},
|
|
{
|
|
key: 'wordcount',
|
|
name: 'Word Count'
|
|
},
|
|
{
|
|
key: 'a11ychecker',
|
|
name: 'Accessibility Checker',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'advcode',
|
|
name: 'Advanced Code Editor',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'advtable',
|
|
name: 'Advanced Tables',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'autocorrect',
|
|
name: 'Autocorrect',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'casechange',
|
|
name: 'Case Change',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'checklist',
|
|
name: 'Checklist',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'export',
|
|
name: 'Export',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'mediaembed',
|
|
name: 'Enhanced Media Embed',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'formatpainter',
|
|
name: 'Format Painter',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'linkchecker',
|
|
name: 'Link Checker',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'mentions',
|
|
name: 'Mentions',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'pageembed',
|
|
name: 'Page Embed',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'permanentpen',
|
|
name: 'Permanent Pen',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'powerpaste',
|
|
name: 'PowerPaste',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'rtc',
|
|
name: 'Real-Time Collaboration',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'tinymcespellchecker',
|
|
name: 'Spell Checker Pro',
|
|
type: 'premium'
|
|
},
|
|
{
|
|
key: 'tinycomments',
|
|
name: 'Tiny Comments',
|
|
type: 'premium',
|
|
slug: 'comments'
|
|
},
|
|
{
|
|
key: 'tinydrive',
|
|
name: 'Tiny Drive',
|
|
type: 'premium'
|
|
}
|
|
], function (item) {
|
|
return __assign(__assign({}, item), {
|
|
type: item.type || 'opensource',
|
|
slug: item.slug || item.key
|
|
});
|
|
});
|
|
|
|
var tab$1 = function (editor) {
|
|
var availablePlugins = function () {
|
|
var premiumPlugins = filter(urls, function (_a) {
|
|
var key = _a.key, type = _a.type;
|
|
return key !== 'autocorrect' && type === 'premium';
|
|
});
|
|
var premiumPluginList = map(premiumPlugins, function (plugin) {
|
|
return '<li>' + global$1.translate(plugin.name) + '</li>';
|
|
}).join('');
|
|
return '<div data-mce-tabstop="1" tabindex="-1">' + '<p><b>' + global$1.translate('Premium plugins:') + '</b></p>' + '<ul>' + premiumPluginList + '<li class="tox-help__more-link" "><a href="https://www.tiny.cloud/pricing/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" target="_blank">' + global$1.translate('Learn more...') + '</a></li>' + '</ul>' + '</div>';
|
|
};
|
|
var makeLink = function (p) {
|
|
return '<a href="' + p.url + '" target="_blank" rel="noopener">' + p.name + '</a>';
|
|
};
|
|
var maybeUrlize = function (editor, key) {
|
|
return find(urls, function (x) {
|
|
return x.key === key;
|
|
}).fold(function () {
|
|
var getMetadata = editor.plugins[key].getMetadata;
|
|
return typeof getMetadata === 'function' ? makeLink(getMetadata()) : key;
|
|
}, function (x) {
|
|
var name = x.type === 'premium' ? x.name + '*' : x.name;
|
|
return makeLink({
|
|
name: name,
|
|
url: 'https://www.tiny.cloud/docs/plugins/' + x.type + '/' + x.slug
|
|
});
|
|
});
|
|
};
|
|
var getPluginKeys = function (editor) {
|
|
var keys$1 = keys(editor.plugins);
|
|
var forced_plugins = getForcedPlugins(editor);
|
|
return forced_plugins === undefined ? keys$1 : filter(keys$1, function (k) {
|
|
return !contains(forced_plugins, k);
|
|
});
|
|
};
|
|
var pluginLister = function (editor) {
|
|
var pluginKeys = getPluginKeys(editor);
|
|
var pluginLis = map(pluginKeys, function (key) {
|
|
return '<li>' + maybeUrlize(editor, key) + '</li>';
|
|
});
|
|
var count = pluginLis.length;
|
|
var pluginsString = pluginLis.join('');
|
|
var html = '<p><b>' + global$1.translate([
|
|
'Plugins installed ({0}):',
|
|
count
|
|
]) + '</b></p>' + '<ul>' + pluginsString + '</ul>';
|
|
return html;
|
|
};
|
|
var installedPlugins = function (editor) {
|
|
if (editor == null) {
|
|
return '';
|
|
}
|
|
return '<div data-mce-tabstop="1" tabindex="-1">' + pluginLister(editor) + '</div>';
|
|
};
|
|
var htmlPanel = {
|
|
type: 'htmlpanel',
|
|
presets: 'document',
|
|
html: [
|
|
installedPlugins(editor),
|
|
availablePlugins()
|
|
].join('')
|
|
};
|
|
return {
|
|
name: 'plugins',
|
|
title: 'Plugins',
|
|
items: [htmlPanel]
|
|
};
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
|
|
|
var tab = function () {
|
|
var getVersion = function (major, minor) {
|
|
return major.indexOf('@') === 0 ? 'X.X.X' : major + '.' + minor;
|
|
};
|
|
var version = getVersion(global.majorVersion, global.minorVersion);
|
|
var changeLogLink = '<a href="https://www.tiny.cloud/docs/changelog/?utm_campaign=editor_referral&utm_medium=help_dialog&utm_source=tinymce" target="_blank">TinyMCE ' + version + '</a>';
|
|
var htmlPanel = {
|
|
type: 'htmlpanel',
|
|
html: '<p>' + global$1.translate([
|
|
'You are using {0}',
|
|
changeLogLink
|
|
]) + '</p>',
|
|
presets: 'document'
|
|
};
|
|
return {
|
|
name: 'versions',
|
|
title: 'Version',
|
|
items: [htmlPanel]
|
|
};
|
|
};
|
|
|
|
var parseHelpTabsSetting = function (tabsFromSettings, tabs) {
|
|
var newTabs = {};
|
|
var names = map(tabsFromSettings, function (t) {
|
|
if (typeof t === 'string') {
|
|
if (has(tabs, t)) {
|
|
newTabs[t] = tabs[t];
|
|
}
|
|
return t;
|
|
} else {
|
|
newTabs[t.name] = t;
|
|
return t.name;
|
|
}
|
|
});
|
|
return {
|
|
tabs: newTabs,
|
|
names: names
|
|
};
|
|
};
|
|
var getNamesFromTabs = function (tabs) {
|
|
var names = keys(tabs);
|
|
var idx = names.indexOf('versions');
|
|
if (idx !== -1) {
|
|
names.splice(idx, 1);
|
|
names.push('versions');
|
|
}
|
|
return {
|
|
tabs: tabs,
|
|
names: names
|
|
};
|
|
};
|
|
var parseCustomTabs = function (editor, customTabs) {
|
|
var _a;
|
|
var shortcuts = tab$2();
|
|
var nav = tab$3();
|
|
var plugins = tab$1(editor);
|
|
var versions = tab();
|
|
var tabs = __assign((_a = {}, _a[shortcuts.name] = shortcuts, _a[nav.name] = nav, _a[plugins.name] = plugins, _a[versions.name] = versions, _a), customTabs.get());
|
|
return getHelpTabs(editor).fold(function () {
|
|
return getNamesFromTabs(tabs);
|
|
}, function (tabsFromSettings) {
|
|
return parseHelpTabsSetting(tabsFromSettings, tabs);
|
|
});
|
|
};
|
|
var init = function (editor, customTabs) {
|
|
return function () {
|
|
var _a = parseCustomTabs(editor, customTabs), tabs = _a.tabs, names = _a.names;
|
|
var foundTabs = map(names, function (name) {
|
|
return get(tabs, name);
|
|
});
|
|
var dialogTabs = cat(foundTabs);
|
|
var body = {
|
|
type: 'tabpanel',
|
|
tabs: dialogTabs
|
|
};
|
|
editor.windowManager.open({
|
|
title: 'Help',
|
|
size: 'medium',
|
|
body: body,
|
|
buttons: [{
|
|
type: 'cancel',
|
|
name: 'close',
|
|
text: 'Close',
|
|
primary: true
|
|
}],
|
|
initialData: {}
|
|
});
|
|
};
|
|
};
|
|
|
|
function Plugin () {
|
|
global$3.add('help', function (editor) {
|
|
var customTabs = Cell({});
|
|
var api = get$1(customTabs);
|
|
var dialogOpener = init(editor, customTabs);
|
|
register(editor, dialogOpener);
|
|
register$1(editor, dialogOpener);
|
|
editor.shortcuts.add('Alt+0', 'Open help dialog', 'mceHelp');
|
|
return api;
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.html.DomParser');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.html.Node');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.html.Serializer');
|
|
|
|
var shouldHideInSourceView = function (editor) {
|
|
return editor.getParam('fullpage_hide_in_source_view');
|
|
};
|
|
var getDefaultXmlPi = function (editor) {
|
|
return editor.getParam('fullpage_default_xml_pi');
|
|
};
|
|
var getDefaultEncoding = function (editor) {
|
|
return editor.getParam('fullpage_default_encoding');
|
|
};
|
|
var getDefaultFontFamily = function (editor) {
|
|
return editor.getParam('fullpage_default_font_family');
|
|
};
|
|
var getDefaultFontSize = function (editor) {
|
|
return editor.getParam('fullpage_default_font_size');
|
|
};
|
|
var getDefaultTextColor = function (editor) {
|
|
return editor.getParam('fullpage_default_text_color');
|
|
};
|
|
var getDefaultTitle = function (editor) {
|
|
return editor.getParam('fullpage_default_title');
|
|
};
|
|
var getDefaultDocType = function (editor) {
|
|
return editor.getParam('fullpage_default_doctype', '<!DOCTYPE html>');
|
|
};
|
|
var getProtect = function (editor) {
|
|
return editor.getParam('protect');
|
|
};
|
|
|
|
var parseHeader = function (editor, head) {
|
|
return global$2({
|
|
validate: false,
|
|
root_name: '#document'
|
|
}, editor.schema).parse(head, { format: 'xhtml' });
|
|
};
|
|
var htmlToData = function (editor, head) {
|
|
var headerFragment = parseHeader(editor, head);
|
|
var data = {};
|
|
var elm, matches;
|
|
var getAttr = function (elm, name) {
|
|
var value = elm.attr(name);
|
|
return value || '';
|
|
};
|
|
data.fontface = getDefaultFontFamily(editor);
|
|
data.fontsize = getDefaultFontSize(editor);
|
|
elm = headerFragment.firstChild;
|
|
if (elm.type === 7) {
|
|
data.xml_pi = true;
|
|
matches = /encoding="([^"]+)"/.exec(elm.value);
|
|
if (matches) {
|
|
data.docencoding = matches[1];
|
|
}
|
|
}
|
|
elm = headerFragment.getAll('#doctype')[0];
|
|
if (elm) {
|
|
data.doctype = '<!DOCTYPE' + elm.value + '>';
|
|
}
|
|
elm = headerFragment.getAll('title')[0];
|
|
if (elm && elm.firstChild) {
|
|
data.title = elm.firstChild.value;
|
|
}
|
|
global$3.each(headerFragment.getAll('meta'), function (meta) {
|
|
var name = meta.attr('name');
|
|
var httpEquiv = meta.attr('http-equiv');
|
|
var matches;
|
|
if (name) {
|
|
data[name.toLowerCase()] = meta.attr('content');
|
|
} else if (httpEquiv === 'Content-Type') {
|
|
matches = /charset\s*=\s*(.*)\s*/gi.exec(meta.attr('content'));
|
|
if (matches) {
|
|
data.docencoding = matches[1];
|
|
}
|
|
}
|
|
});
|
|
elm = headerFragment.getAll('html')[0];
|
|
if (elm) {
|
|
data.langcode = getAttr(elm, 'lang') || getAttr(elm, 'xml:lang');
|
|
}
|
|
data.stylesheets = [];
|
|
global$3.each(headerFragment.getAll('link'), function (link) {
|
|
if (link.attr('rel') === 'stylesheet') {
|
|
data.stylesheets.push(link.attr('href'));
|
|
}
|
|
});
|
|
elm = headerFragment.getAll('body')[0];
|
|
if (elm) {
|
|
data.langdir = getAttr(elm, 'dir');
|
|
data.style = getAttr(elm, 'style');
|
|
data.visited_color = getAttr(elm, 'vlink');
|
|
data.link_color = getAttr(elm, 'link');
|
|
data.active_color = getAttr(elm, 'alink');
|
|
}
|
|
return data;
|
|
};
|
|
var dataToHtml = function (editor, data, head) {
|
|
var headElement, elm;
|
|
var dom = editor.dom;
|
|
var setAttr = function (elm, name, value) {
|
|
elm.attr(name, value ? value : undefined);
|
|
};
|
|
var addHeadNode = function (node) {
|
|
if (headElement.firstChild) {
|
|
headElement.insert(node, headElement.firstChild);
|
|
} else {
|
|
headElement.append(node);
|
|
}
|
|
};
|
|
var headerFragment = parseHeader(editor, head);
|
|
headElement = headerFragment.getAll('head')[0];
|
|
if (!headElement) {
|
|
elm = headerFragment.getAll('html')[0];
|
|
headElement = new global$1('head', 1);
|
|
if (elm.firstChild) {
|
|
elm.insert(headElement, elm.firstChild, true);
|
|
} else {
|
|
elm.append(headElement);
|
|
}
|
|
}
|
|
elm = headerFragment.firstChild;
|
|
if (data.xml_pi) {
|
|
var value = 'version="1.0"';
|
|
if (data.docencoding) {
|
|
value += ' encoding="' + data.docencoding + '"';
|
|
}
|
|
if (elm.type !== 7) {
|
|
elm = new global$1('xml', 7);
|
|
headerFragment.insert(elm, headerFragment.firstChild, true);
|
|
}
|
|
elm.value = value;
|
|
} else if (elm && elm.type === 7) {
|
|
elm.remove();
|
|
}
|
|
elm = headerFragment.getAll('#doctype')[0];
|
|
if (data.doctype) {
|
|
if (!elm) {
|
|
elm = new global$1('#doctype', 10);
|
|
if (data.xml_pi) {
|
|
headerFragment.insert(elm, headerFragment.firstChild);
|
|
} else {
|
|
addHeadNode(elm);
|
|
}
|
|
}
|
|
elm.value = data.doctype.substring(9, data.doctype.length - 1);
|
|
} else if (elm) {
|
|
elm.remove();
|
|
}
|
|
elm = null;
|
|
global$3.each(headerFragment.getAll('meta'), function (meta) {
|
|
if (meta.attr('http-equiv') === 'Content-Type') {
|
|
elm = meta;
|
|
}
|
|
});
|
|
if (data.docencoding) {
|
|
if (!elm) {
|
|
elm = new global$1('meta', 1);
|
|
elm.attr('http-equiv', 'Content-Type');
|
|
elm.shortEnded = true;
|
|
addHeadNode(elm);
|
|
}
|
|
elm.attr('content', 'text/html; charset=' + data.docencoding);
|
|
} else if (elm) {
|
|
elm.remove();
|
|
}
|
|
elm = headerFragment.getAll('title')[0];
|
|
if (data.title) {
|
|
if (!elm) {
|
|
elm = new global$1('title', 1);
|
|
addHeadNode(elm);
|
|
} else {
|
|
elm.empty();
|
|
}
|
|
elm.append(new global$1('#text', 3)).value = data.title;
|
|
} else if (elm) {
|
|
elm.remove();
|
|
}
|
|
global$3.each('keywords,description,author,copyright,robots'.split(','), function (name) {
|
|
var nodes = headerFragment.getAll('meta');
|
|
var i, meta;
|
|
var value = data[name];
|
|
for (i = 0; i < nodes.length; i++) {
|
|
meta = nodes[i];
|
|
if (meta.attr('name') === name) {
|
|
if (value) {
|
|
meta.attr('content', value);
|
|
} else {
|
|
meta.remove();
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
if (value) {
|
|
elm = new global$1('meta', 1);
|
|
elm.attr('name', name);
|
|
elm.attr('content', value);
|
|
elm.shortEnded = true;
|
|
addHeadNode(elm);
|
|
}
|
|
});
|
|
var currentStyleSheetsMap = {};
|
|
global$3.each(headerFragment.getAll('link'), function (stylesheet) {
|
|
if (stylesheet.attr('rel') === 'stylesheet') {
|
|
currentStyleSheetsMap[stylesheet.attr('href')] = stylesheet;
|
|
}
|
|
});
|
|
global$3.each(data.stylesheets, function (stylesheet) {
|
|
if (!currentStyleSheetsMap[stylesheet]) {
|
|
elm = new global$1('link', 1);
|
|
elm.attr({
|
|
rel: 'stylesheet',
|
|
text: 'text/css',
|
|
href: stylesheet
|
|
});
|
|
elm.shortEnded = true;
|
|
addHeadNode(elm);
|
|
}
|
|
delete currentStyleSheetsMap[stylesheet];
|
|
});
|
|
global$3.each(currentStyleSheetsMap, function (stylesheet) {
|
|
stylesheet.remove();
|
|
});
|
|
elm = headerFragment.getAll('body')[0];
|
|
if (elm) {
|
|
setAttr(elm, 'dir', data.langdir);
|
|
setAttr(elm, 'style', data.style);
|
|
setAttr(elm, 'vlink', data.visited_color);
|
|
setAttr(elm, 'link', data.link_color);
|
|
setAttr(elm, 'alink', data.active_color);
|
|
dom.setAttribs(editor.getBody(), {
|
|
style: data.style,
|
|
dir: data.dir,
|
|
vLink: data.visited_color,
|
|
link: data.link_color,
|
|
aLink: data.active_color
|
|
});
|
|
}
|
|
elm = headerFragment.getAll('html')[0];
|
|
if (elm) {
|
|
setAttr(elm, 'lang', data.langcode);
|
|
setAttr(elm, 'xml:lang', data.langcode);
|
|
}
|
|
if (!headElement.firstChild) {
|
|
headElement.remove();
|
|
}
|
|
var html = global({
|
|
validate: false,
|
|
indent: true,
|
|
indent_before: 'head,html,body,meta,title,script,link,style',
|
|
indent_after: 'head,html,body,meta,title,script,link,style'
|
|
}).serialize(headerFragment);
|
|
return html.substring(0, html.indexOf('</body>'));
|
|
};
|
|
|
|
var open = function (editor, headState) {
|
|
var data = htmlToData(editor, headState.get());
|
|
var defaultData = {
|
|
title: '',
|
|
keywords: '',
|
|
description: '',
|
|
robots: '',
|
|
author: '',
|
|
docencoding: ''
|
|
};
|
|
var initialData = __assign(__assign({}, defaultData), data);
|
|
editor.windowManager.open({
|
|
title: 'Metadata and Document Properties',
|
|
size: 'normal',
|
|
body: {
|
|
type: 'panel',
|
|
items: [
|
|
{
|
|
name: 'title',
|
|
type: 'input',
|
|
label: 'Title'
|
|
},
|
|
{
|
|
name: 'keywords',
|
|
type: 'input',
|
|
label: 'Keywords'
|
|
},
|
|
{
|
|
name: 'description',
|
|
type: 'input',
|
|
label: 'Description'
|
|
},
|
|
{
|
|
name: 'robots',
|
|
type: 'input',
|
|
label: 'Robots'
|
|
},
|
|
{
|
|
name: 'author',
|
|
type: 'input',
|
|
label: 'Author'
|
|
},
|
|
{
|
|
name: 'docencoding',
|
|
type: 'input',
|
|
label: 'Encoding'
|
|
}
|
|
]
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: initialData,
|
|
onSubmit: function (api) {
|
|
var nuData = api.getData();
|
|
var headHtml = dataToHtml(editor, global$3.extend(data, nuData), headState.get());
|
|
headState.set(headHtml);
|
|
api.close();
|
|
}
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor, headState) {
|
|
editor.addCommand('mceFullPageProperties', function () {
|
|
open(editor, headState);
|
|
});
|
|
};
|
|
|
|
var protectHtml = function (protect, html) {
|
|
global$3.each(protect, function (pattern) {
|
|
html = html.replace(pattern, function (str) {
|
|
return '<!--mce:protected ' + escape(str) + '-->';
|
|
});
|
|
});
|
|
return html;
|
|
};
|
|
var unprotectHtml = function (html) {
|
|
return html.replace(/<!--mce:protected ([\s\S]*?)-->/g, function (a, m) {
|
|
return unescape(m);
|
|
});
|
|
};
|
|
|
|
var each = global$3.each;
|
|
var low = function (s) {
|
|
return s.replace(/<\/?[A-Z]+/g, function (a) {
|
|
return a.toLowerCase();
|
|
});
|
|
};
|
|
var handleSetContent = function (editor, headState, footState, evt) {
|
|
var startPos, endPos, content, styles = '';
|
|
var dom = editor.dom;
|
|
if (evt.selection) {
|
|
return;
|
|
}
|
|
content = protectHtml(getProtect(editor), evt.content);
|
|
if (evt.format === 'raw' && headState.get()) {
|
|
return;
|
|
}
|
|
if (evt.source_view && shouldHideInSourceView(editor)) {
|
|
return;
|
|
}
|
|
if (content.length === 0 && !evt.source_view) {
|
|
content = global$3.trim(headState.get()) + '\n' + global$3.trim(content) + '\n' + global$3.trim(footState.get());
|
|
}
|
|
content = content.replace(/<(\/?)BODY/gi, '<$1body');
|
|
startPos = content.indexOf('<body');
|
|
if (startPos !== -1) {
|
|
startPos = content.indexOf('>', startPos);
|
|
headState.set(low(content.substring(0, startPos + 1)));
|
|
endPos = content.indexOf('</body', startPos);
|
|
if (endPos === -1) {
|
|
endPos = content.length;
|
|
}
|
|
evt.content = global$3.trim(content.substring(startPos + 1, endPos));
|
|
footState.set(low(content.substring(endPos)));
|
|
} else {
|
|
headState.set(getDefaultHeader(editor));
|
|
footState.set('\n</body>\n</html>');
|
|
}
|
|
var headerFragment = parseHeader(editor, headState.get());
|
|
each(headerFragment.getAll('style'), function (node) {
|
|
if (node.firstChild) {
|
|
styles += node.firstChild.value;
|
|
}
|
|
});
|
|
var bodyElm = headerFragment.getAll('body')[0];
|
|
if (bodyElm) {
|
|
dom.setAttribs(editor.getBody(), {
|
|
style: bodyElm.attr('style') || '',
|
|
dir: bodyElm.attr('dir') || '',
|
|
vLink: bodyElm.attr('vlink') || '',
|
|
link: bodyElm.attr('link') || '',
|
|
aLink: bodyElm.attr('alink') || ''
|
|
});
|
|
}
|
|
dom.remove('fullpage_styles');
|
|
var headElm = editor.getDoc().getElementsByTagName('head')[0];
|
|
if (styles) {
|
|
var styleElm = dom.add(headElm, 'style', { id: 'fullpage_styles' });
|
|
styleElm.appendChild(document.createTextNode(styles));
|
|
}
|
|
var currentStyleSheetsMap = {};
|
|
global$3.each(headElm.getElementsByTagName('link'), function (stylesheet) {
|
|
if (stylesheet.rel === 'stylesheet' && stylesheet.getAttribute('data-mce-fullpage')) {
|
|
currentStyleSheetsMap[stylesheet.href] = stylesheet;
|
|
}
|
|
});
|
|
global$3.each(headerFragment.getAll('link'), function (stylesheet) {
|
|
var href = stylesheet.attr('href');
|
|
if (!href) {
|
|
return true;
|
|
}
|
|
if (!currentStyleSheetsMap[href] && stylesheet.attr('rel') === 'stylesheet') {
|
|
dom.add(headElm, 'link', {
|
|
'rel': 'stylesheet',
|
|
'text': 'text/css',
|
|
href: href,
|
|
'data-mce-fullpage': '1'
|
|
});
|
|
}
|
|
delete currentStyleSheetsMap[href];
|
|
});
|
|
global$3.each(currentStyleSheetsMap, function (stylesheet) {
|
|
stylesheet.parentNode.removeChild(stylesheet);
|
|
});
|
|
};
|
|
var getDefaultHeader = function (editor) {
|
|
var header = '', value, styles = '';
|
|
if (getDefaultXmlPi(editor)) {
|
|
var piEncoding = getDefaultEncoding(editor);
|
|
header += '<?xml version="1.0" encoding="' + (piEncoding ? piEncoding : 'ISO-8859-1') + '" ?>\n';
|
|
}
|
|
header += getDefaultDocType(editor);
|
|
header += '\n<html>\n<head>\n';
|
|
if (value = getDefaultTitle(editor)) {
|
|
header += '<title>' + value + '</title>\n';
|
|
}
|
|
if (value = getDefaultEncoding(editor)) {
|
|
header += '<meta http-equiv="Content-Type" content="text/html; charset=' + value + '" />\n';
|
|
}
|
|
if (value = getDefaultFontFamily(editor)) {
|
|
styles += 'font-family: ' + value + ';';
|
|
}
|
|
if (value = getDefaultFontSize(editor)) {
|
|
styles += 'font-size: ' + value + ';';
|
|
}
|
|
if (value = getDefaultTextColor(editor)) {
|
|
styles += 'color: ' + value + ';';
|
|
}
|
|
header += '</head>\n<body' + (styles ? ' style="' + styles + '"' : '') + '>\n';
|
|
return header;
|
|
};
|
|
var handleGetContent = function (editor, head, foot, evt) {
|
|
if (evt.format === 'html' && !evt.selection && (!evt.source_view || !shouldHideInSourceView(editor))) {
|
|
evt.content = unprotectHtml(global$3.trim(head) + '\n' + global$3.trim(evt.content) + '\n' + global$3.trim(foot));
|
|
}
|
|
};
|
|
var setup = function (editor, headState, footState) {
|
|
editor.on('BeforeSetContent', function (evt) {
|
|
handleSetContent(editor, headState, footState, evt);
|
|
});
|
|
editor.on('GetContent', function (evt) {
|
|
handleGetContent(editor, headState.get(), footState.get(), evt);
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
editor.ui.registry.addButton('fullpage', {
|
|
tooltip: 'Metadata and document properties',
|
|
icon: 'document-properties',
|
|
onAction: function () {
|
|
editor.execCommand('mceFullPageProperties');
|
|
}
|
|
});
|
|
editor.ui.registry.addMenuItem('fullpage', {
|
|
text: 'Metadata and document properties',
|
|
icon: 'document-properties',
|
|
onAction: function () {
|
|
editor.execCommand('mceFullPageProperties');
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$4.add('fullpage', function (editor) {
|
|
var headState = Cell(''), footState = Cell('');
|
|
register$1(editor, headState);
|
|
register(editor);
|
|
setup(editor, headState, footState);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('InsertHorizontalRule', function () {
|
|
editor.execCommand('mceInsertContent', false, '<hr />');
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('InsertHorizontalRule');
|
|
};
|
|
editor.ui.registry.addButton('hr', {
|
|
icon: 'horizontal-rule',
|
|
tooltip: 'Horizontal line',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('hr', {
|
|
icon: 'horizontal-rule',
|
|
text: 'Horizontal line',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global.add('hr', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var eq = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isString = isType('string');
|
|
var isObject = isType('object');
|
|
var isArray = isType('array');
|
|
var isNull = eq(null);
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var objAcc = function (r) {
|
|
return function (x, i) {
|
|
r[i] = x;
|
|
};
|
|
};
|
|
var internalFilter = function (obj, pred, onTrue, onFalse) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
});
|
|
return r;
|
|
};
|
|
var filter = function (obj, pred) {
|
|
var t = {};
|
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
return t;
|
|
};
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
var hasNonNullableKey = function (obj, key) {
|
|
return has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
};
|
|
|
|
var nativePush = Array.prototype.push;
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var get = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get(xs, 0);
|
|
};
|
|
var findMap = function (arr, f) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var r = f(arr[i], i);
|
|
if (r.isSome()) {
|
|
return r;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
var remove = function (element, key) {
|
|
element.dom.removeAttribute(key);
|
|
};
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.XHR');
|
|
|
|
var hasDimensions = function (editor) {
|
|
return editor.getParam('image_dimensions', true, 'boolean');
|
|
};
|
|
var hasAdvTab = function (editor) {
|
|
return editor.getParam('image_advtab', false, 'boolean');
|
|
};
|
|
var hasUploadTab = function (editor) {
|
|
return editor.getParam('image_uploadtab', true, 'boolean');
|
|
};
|
|
var getPrependUrl = function (editor) {
|
|
return editor.getParam('image_prepend_url', '', 'string');
|
|
};
|
|
var getClassList = function (editor) {
|
|
return editor.getParam('image_class_list');
|
|
};
|
|
var hasDescription = function (editor) {
|
|
return editor.getParam('image_description', true, 'boolean');
|
|
};
|
|
var hasImageTitle = function (editor) {
|
|
return editor.getParam('image_title', false, 'boolean');
|
|
};
|
|
var hasImageCaption = function (editor) {
|
|
return editor.getParam('image_caption', false, 'boolean');
|
|
};
|
|
var getImageList = function (editor) {
|
|
return editor.getParam('image_list', false);
|
|
};
|
|
var hasUploadUrl = function (editor) {
|
|
return isNonNullable(editor.getParam('images_upload_url'));
|
|
};
|
|
var hasUploadHandler = function (editor) {
|
|
return isNonNullable(editor.getParam('images_upload_handler'));
|
|
};
|
|
var showAccessibilityOptions = function (editor) {
|
|
return editor.getParam('a11y_advanced_options', false, 'boolean');
|
|
};
|
|
var isAutomaticUploadsEnabled = function (editor) {
|
|
return editor.getParam('automatic_uploads', true, 'boolean');
|
|
};
|
|
|
|
var parseIntAndGetMax = function (val1, val2) {
|
|
return Math.max(parseInt(val1, 10), parseInt(val2, 10));
|
|
};
|
|
var getImageSize = function (url) {
|
|
return new global$4(function (callback) {
|
|
var img = document.createElement('img');
|
|
var done = function (dimensions) {
|
|
img.onload = img.onerror = null;
|
|
if (img.parentNode) {
|
|
img.parentNode.removeChild(img);
|
|
}
|
|
callback(dimensions);
|
|
};
|
|
img.onload = function () {
|
|
var width = parseIntAndGetMax(img.width, img.clientWidth);
|
|
var height = parseIntAndGetMax(img.height, img.clientHeight);
|
|
var dimensions = {
|
|
width: width,
|
|
height: height
|
|
};
|
|
done(global$4.resolve(dimensions));
|
|
};
|
|
img.onerror = function () {
|
|
done(global$4.reject('Failed to get image dimensions for: ' + url));
|
|
};
|
|
var style = img.style;
|
|
style.visibility = 'hidden';
|
|
style.position = 'fixed';
|
|
style.bottom = style.left = '0px';
|
|
style.width = style.height = 'auto';
|
|
document.body.appendChild(img);
|
|
img.src = url;
|
|
});
|
|
};
|
|
var removePixelSuffix = function (value) {
|
|
if (value) {
|
|
value = value.replace(/px$/, '');
|
|
}
|
|
return value;
|
|
};
|
|
var addPixelSuffix = function (value) {
|
|
if (value.length > 0 && /^[0-9]+$/.test(value)) {
|
|
value += 'px';
|
|
}
|
|
return value;
|
|
};
|
|
var mergeMargins = function (css) {
|
|
if (css.margin) {
|
|
var splitMargin = String(css.margin).split(' ');
|
|
switch (splitMargin.length) {
|
|
case 1:
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
css['margin-right'] = css['margin-right'] || splitMargin[0];
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[0];
|
|
css['margin-left'] = css['margin-left'] || splitMargin[0];
|
|
break;
|
|
case 2:
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[0];
|
|
css['margin-left'] = css['margin-left'] || splitMargin[1];
|
|
break;
|
|
case 3:
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[2];
|
|
css['margin-left'] = css['margin-left'] || splitMargin[1];
|
|
break;
|
|
case 4:
|
|
css['margin-top'] = css['margin-top'] || splitMargin[0];
|
|
css['margin-right'] = css['margin-right'] || splitMargin[1];
|
|
css['margin-bottom'] = css['margin-bottom'] || splitMargin[2];
|
|
css['margin-left'] = css['margin-left'] || splitMargin[3];
|
|
}
|
|
delete css.margin;
|
|
}
|
|
return css;
|
|
};
|
|
var createImageList = function (editor, callback) {
|
|
var imageList = getImageList(editor);
|
|
if (isString(imageList)) {
|
|
global$2.send({
|
|
url: imageList,
|
|
success: function (text) {
|
|
callback(JSON.parse(text));
|
|
}
|
|
});
|
|
} else if (isFunction(imageList)) {
|
|
imageList(callback);
|
|
} else {
|
|
callback(imageList);
|
|
}
|
|
};
|
|
var waitLoadImage = function (editor, data, imgElm) {
|
|
var selectImage = function () {
|
|
imgElm.onload = imgElm.onerror = null;
|
|
if (editor.selection) {
|
|
editor.selection.select(imgElm);
|
|
editor.nodeChanged();
|
|
}
|
|
};
|
|
imgElm.onload = function () {
|
|
if (!data.width && !data.height && hasDimensions(editor)) {
|
|
editor.dom.setAttribs(imgElm, {
|
|
width: String(imgElm.clientWidth),
|
|
height: String(imgElm.clientHeight)
|
|
});
|
|
}
|
|
selectImage();
|
|
};
|
|
imgElm.onerror = selectImage;
|
|
};
|
|
var blobToDataUri = function (blob) {
|
|
return new global$4(function (resolve, reject) {
|
|
var reader = new FileReader();
|
|
reader.onload = function () {
|
|
resolve(reader.result);
|
|
};
|
|
reader.onerror = function () {
|
|
reject(reader.error.message);
|
|
};
|
|
reader.readAsDataURL(blob);
|
|
});
|
|
};
|
|
var isPlaceholderImage = function (imgElm) {
|
|
return imgElm.nodeName === 'IMG' && (imgElm.hasAttribute('data-mce-object') || imgElm.hasAttribute('data-mce-placeholder'));
|
|
};
|
|
var isSafeImageUrl = function (editor, src) {
|
|
return global$3.isDomSafe(src, 'img', editor.settings);
|
|
};
|
|
|
|
var DOM = global$5.DOM;
|
|
var getHspace = function (image) {
|
|
if (image.style.marginLeft && image.style.marginRight && image.style.marginLeft === image.style.marginRight) {
|
|
return removePixelSuffix(image.style.marginLeft);
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
var getVspace = function (image) {
|
|
if (image.style.marginTop && image.style.marginBottom && image.style.marginTop === image.style.marginBottom) {
|
|
return removePixelSuffix(image.style.marginTop);
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
var getBorder = function (image) {
|
|
if (image.style.borderWidth) {
|
|
return removePixelSuffix(image.style.borderWidth);
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
var getAttrib = function (image, name) {
|
|
if (image.hasAttribute(name)) {
|
|
return image.getAttribute(name);
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
var getStyle = function (image, name) {
|
|
return image.style[name] ? image.style[name] : '';
|
|
};
|
|
var hasCaption = function (image) {
|
|
return image.parentNode !== null && image.parentNode.nodeName === 'FIGURE';
|
|
};
|
|
var updateAttrib = function (image, name, value) {
|
|
if (value === '') {
|
|
image.removeAttribute(name);
|
|
} else {
|
|
image.setAttribute(name, value);
|
|
}
|
|
};
|
|
var wrapInFigure = function (image) {
|
|
var figureElm = DOM.create('figure', { class: 'image' });
|
|
DOM.insertAfter(figureElm, image);
|
|
figureElm.appendChild(image);
|
|
figureElm.appendChild(DOM.create('figcaption', { contentEditable: 'true' }, 'Caption'));
|
|
figureElm.contentEditable = 'false';
|
|
};
|
|
var removeFigure = function (image) {
|
|
var figureElm = image.parentNode;
|
|
DOM.insertAfter(image, figureElm);
|
|
DOM.remove(figureElm);
|
|
};
|
|
var toggleCaption = function (image) {
|
|
if (hasCaption(image)) {
|
|
removeFigure(image);
|
|
} else {
|
|
wrapInFigure(image);
|
|
}
|
|
};
|
|
var normalizeStyle = function (image, normalizeCss) {
|
|
var attrValue = image.getAttribute('style');
|
|
var value = normalizeCss(attrValue !== null ? attrValue : '');
|
|
if (value.length > 0) {
|
|
image.setAttribute('style', value);
|
|
image.setAttribute('data-mce-style', value);
|
|
} else {
|
|
image.removeAttribute('style');
|
|
}
|
|
};
|
|
var setSize = function (name, normalizeCss) {
|
|
return function (image, name, value) {
|
|
if (image.style[name]) {
|
|
image.style[name] = addPixelSuffix(value);
|
|
normalizeStyle(image, normalizeCss);
|
|
} else {
|
|
updateAttrib(image, name, value);
|
|
}
|
|
};
|
|
};
|
|
var getSize = function (image, name) {
|
|
if (image.style[name]) {
|
|
return removePixelSuffix(image.style[name]);
|
|
} else {
|
|
return getAttrib(image, name);
|
|
}
|
|
};
|
|
var setHspace = function (image, value) {
|
|
var pxValue = addPixelSuffix(value);
|
|
image.style.marginLeft = pxValue;
|
|
image.style.marginRight = pxValue;
|
|
};
|
|
var setVspace = function (image, value) {
|
|
var pxValue = addPixelSuffix(value);
|
|
image.style.marginTop = pxValue;
|
|
image.style.marginBottom = pxValue;
|
|
};
|
|
var setBorder = function (image, value) {
|
|
var pxValue = addPixelSuffix(value);
|
|
image.style.borderWidth = pxValue;
|
|
};
|
|
var setBorderStyle = function (image, value) {
|
|
image.style.borderStyle = value;
|
|
};
|
|
var getBorderStyle = function (image) {
|
|
return getStyle(image, 'borderStyle');
|
|
};
|
|
var isFigure = function (elm) {
|
|
return elm.nodeName === 'FIGURE';
|
|
};
|
|
var isImage = function (elm) {
|
|
return elm.nodeName === 'IMG';
|
|
};
|
|
var getIsDecorative = function (image) {
|
|
return DOM.getAttrib(image, 'alt').length === 0 && DOM.getAttrib(image, 'role') === 'presentation';
|
|
};
|
|
var getAlt = function (image) {
|
|
if (getIsDecorative(image)) {
|
|
return '';
|
|
} else {
|
|
return getAttrib(image, 'alt');
|
|
}
|
|
};
|
|
var defaultData = function () {
|
|
return {
|
|
src: '',
|
|
alt: '',
|
|
title: '',
|
|
width: '',
|
|
height: '',
|
|
class: '',
|
|
style: '',
|
|
caption: false,
|
|
hspace: '',
|
|
vspace: '',
|
|
border: '',
|
|
borderStyle: '',
|
|
isDecorative: false
|
|
};
|
|
};
|
|
var getStyleValue = function (normalizeCss, data) {
|
|
var image = document.createElement('img');
|
|
updateAttrib(image, 'style', data.style);
|
|
if (getHspace(image) || data.hspace !== '') {
|
|
setHspace(image, data.hspace);
|
|
}
|
|
if (getVspace(image) || data.vspace !== '') {
|
|
setVspace(image, data.vspace);
|
|
}
|
|
if (getBorder(image) || data.border !== '') {
|
|
setBorder(image, data.border);
|
|
}
|
|
if (getBorderStyle(image) || data.borderStyle !== '') {
|
|
setBorderStyle(image, data.borderStyle);
|
|
}
|
|
return normalizeCss(image.getAttribute('style'));
|
|
};
|
|
var create = function (normalizeCss, data) {
|
|
var image = document.createElement('img');
|
|
write(normalizeCss, __assign(__assign({}, data), { caption: false }), image);
|
|
setAlt(image, data.alt, data.isDecorative);
|
|
if (data.caption) {
|
|
var figure = DOM.create('figure', { class: 'image' });
|
|
figure.appendChild(image);
|
|
figure.appendChild(DOM.create('figcaption', { contentEditable: 'true' }, 'Caption'));
|
|
figure.contentEditable = 'false';
|
|
return figure;
|
|
} else {
|
|
return image;
|
|
}
|
|
};
|
|
var read = function (normalizeCss, image) {
|
|
return {
|
|
src: getAttrib(image, 'src'),
|
|
alt: getAlt(image),
|
|
title: getAttrib(image, 'title'),
|
|
width: getSize(image, 'width'),
|
|
height: getSize(image, 'height'),
|
|
class: getAttrib(image, 'class'),
|
|
style: normalizeCss(getAttrib(image, 'style')),
|
|
caption: hasCaption(image),
|
|
hspace: getHspace(image),
|
|
vspace: getVspace(image),
|
|
border: getBorder(image),
|
|
borderStyle: getStyle(image, 'borderStyle'),
|
|
isDecorative: getIsDecorative(image)
|
|
};
|
|
};
|
|
var updateProp = function (image, oldData, newData, name, set) {
|
|
if (newData[name] !== oldData[name]) {
|
|
set(image, name, newData[name]);
|
|
}
|
|
};
|
|
var setAlt = function (image, alt, isDecorative) {
|
|
if (isDecorative) {
|
|
DOM.setAttrib(image, 'role', 'presentation');
|
|
var sugarImage = SugarElement.fromDom(image);
|
|
set(sugarImage, 'alt', '');
|
|
} else {
|
|
if (isNull(alt)) {
|
|
var sugarImage = SugarElement.fromDom(image);
|
|
remove(sugarImage, 'alt');
|
|
} else {
|
|
var sugarImage = SugarElement.fromDom(image);
|
|
set(sugarImage, 'alt', alt);
|
|
}
|
|
if (DOM.getAttrib(image, 'role') === 'presentation') {
|
|
DOM.setAttrib(image, 'role', '');
|
|
}
|
|
}
|
|
};
|
|
var updateAlt = function (image, oldData, newData) {
|
|
if (newData.alt !== oldData.alt || newData.isDecorative !== oldData.isDecorative) {
|
|
setAlt(image, newData.alt, newData.isDecorative);
|
|
}
|
|
};
|
|
var normalized = function (set, normalizeCss) {
|
|
return function (image, name, value) {
|
|
set(image, value);
|
|
normalizeStyle(image, normalizeCss);
|
|
};
|
|
};
|
|
var write = function (normalizeCss, newData, image) {
|
|
var oldData = read(normalizeCss, image);
|
|
updateProp(image, oldData, newData, 'caption', function (image, _name, _value) {
|
|
return toggleCaption(image);
|
|
});
|
|
updateProp(image, oldData, newData, 'src', updateAttrib);
|
|
updateProp(image, oldData, newData, 'title', updateAttrib);
|
|
updateProp(image, oldData, newData, 'width', setSize('width', normalizeCss));
|
|
updateProp(image, oldData, newData, 'height', setSize('height', normalizeCss));
|
|
updateProp(image, oldData, newData, 'class', updateAttrib);
|
|
updateProp(image, oldData, newData, 'style', normalized(function (image, value) {
|
|
return updateAttrib(image, 'style', value);
|
|
}, normalizeCss));
|
|
updateProp(image, oldData, newData, 'hspace', normalized(setHspace, normalizeCss));
|
|
updateProp(image, oldData, newData, 'vspace', normalized(setVspace, normalizeCss));
|
|
updateProp(image, oldData, newData, 'border', normalized(setBorder, normalizeCss));
|
|
updateProp(image, oldData, newData, 'borderStyle', normalized(setBorderStyle, normalizeCss));
|
|
updateAlt(image, oldData, newData);
|
|
};
|
|
|
|
var normalizeCss$1 = function (editor, cssText) {
|
|
var css = editor.dom.styles.parse(cssText);
|
|
var mergedCss = mergeMargins(css);
|
|
var compressed = editor.dom.styles.parse(editor.dom.styles.serialize(mergedCss));
|
|
return editor.dom.styles.serialize(compressed);
|
|
};
|
|
var getSelectedImage = function (editor) {
|
|
var imgElm = editor.selection.getNode();
|
|
var figureElm = editor.dom.getParent(imgElm, 'figure.image');
|
|
if (figureElm) {
|
|
return editor.dom.select('img', figureElm)[0];
|
|
}
|
|
if (imgElm && (imgElm.nodeName !== 'IMG' || isPlaceholderImage(imgElm))) {
|
|
return null;
|
|
}
|
|
return imgElm;
|
|
};
|
|
var splitTextBlock = function (editor, figure) {
|
|
var dom = editor.dom;
|
|
var textBlockElements = filter(editor.schema.getTextBlockElements(), function (_, parentElm) {
|
|
return !editor.schema.isValidChild(parentElm, 'figure');
|
|
});
|
|
var textBlock = dom.getParent(figure.parentNode, function (node) {
|
|
return hasNonNullableKey(textBlockElements, node.nodeName);
|
|
}, editor.getBody());
|
|
if (textBlock) {
|
|
return dom.split(textBlock, figure);
|
|
} else {
|
|
return figure;
|
|
}
|
|
};
|
|
var readImageDataFromSelection = function (editor) {
|
|
var image = getSelectedImage(editor);
|
|
return image ? read(function (css) {
|
|
return normalizeCss$1(editor, css);
|
|
}, image) : defaultData();
|
|
};
|
|
var insertImageAtCaret = function (editor, data) {
|
|
var elm = create(function (css) {
|
|
return normalizeCss$1(editor, css);
|
|
}, data);
|
|
editor.dom.setAttrib(elm, 'data-mce-id', '__mcenew');
|
|
editor.focus();
|
|
editor.selection.setContent(elm.outerHTML);
|
|
var insertedElm = editor.dom.select('*[data-mce-id="__mcenew"]')[0];
|
|
editor.dom.setAttrib(insertedElm, 'data-mce-id', null);
|
|
if (isFigure(insertedElm)) {
|
|
var figure = splitTextBlock(editor, insertedElm);
|
|
editor.selection.select(figure);
|
|
} else {
|
|
editor.selection.select(insertedElm);
|
|
}
|
|
};
|
|
var syncSrcAttr = function (editor, image) {
|
|
editor.dom.setAttrib(image, 'src', image.getAttribute('src'));
|
|
};
|
|
var deleteImage = function (editor, image) {
|
|
if (image) {
|
|
var elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image;
|
|
editor.dom.remove(elm);
|
|
editor.focus();
|
|
editor.nodeChanged();
|
|
if (editor.dom.isEmpty(editor.getBody())) {
|
|
editor.setContent('');
|
|
editor.selection.setCursorLocation();
|
|
}
|
|
}
|
|
};
|
|
var writeImageDataToSelection = function (editor, data) {
|
|
var image = getSelectedImage(editor);
|
|
write(function (css) {
|
|
return normalizeCss$1(editor, css);
|
|
}, data, image);
|
|
syncSrcAttr(editor, image);
|
|
if (isFigure(image.parentNode)) {
|
|
var figure = image.parentNode;
|
|
splitTextBlock(editor, figure);
|
|
editor.selection.select(image.parentNode);
|
|
} else {
|
|
editor.selection.select(image);
|
|
waitLoadImage(editor, data, image);
|
|
}
|
|
};
|
|
var sanitizeImageData = function (editor, data) {
|
|
var src = data.src;
|
|
return __assign(__assign({}, data), { src: isSafeImageUrl(editor, src) ? src : '' });
|
|
};
|
|
var insertOrUpdateImage = function (editor, partialData) {
|
|
var image = getSelectedImage(editor);
|
|
if (image) {
|
|
var selectedImageData = read(function (css) {
|
|
return normalizeCss$1(editor, css);
|
|
}, image);
|
|
var data = __assign(__assign({}, selectedImageData), partialData);
|
|
var sanitizedData = sanitizeImageData(editor, data);
|
|
if (data.src) {
|
|
writeImageDataToSelection(editor, sanitizedData);
|
|
} else {
|
|
deleteImage(editor, image);
|
|
}
|
|
} else if (partialData.src) {
|
|
insertImageAtCaret(editor, __assign(__assign({}, defaultData()), partialData));
|
|
}
|
|
};
|
|
|
|
var deep = function (old, nu) {
|
|
var bothObjects = isObject(old) && isObject(nu);
|
|
return bothObjects ? deepMerge(old, nu) : nu;
|
|
};
|
|
var baseMerge = function (merger) {
|
|
return function () {
|
|
var objects = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
objects[_i] = arguments[_i];
|
|
}
|
|
if (objects.length === 0) {
|
|
throw new Error('Can\'t merge zero objects');
|
|
}
|
|
var ret = {};
|
|
for (var j = 0; j < objects.length; j++) {
|
|
var curObject = objects[j];
|
|
for (var key in curObject) {
|
|
if (has(curObject, key)) {
|
|
ret[key] = merger(ret[key], curObject[key]);
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
};
|
|
var deepMerge = baseMerge(deep);
|
|
|
|
var isNotEmpty = function (s) {
|
|
return s.length > 0;
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.ImageUploader');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getValue = function (item) {
|
|
return isString(item.value) ? item.value : '';
|
|
};
|
|
var getText = function (item) {
|
|
if (isString(item.text)) {
|
|
return item.text;
|
|
} else if (isString(item.title)) {
|
|
return item.title;
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
var sanitizeList = function (list, extractValue) {
|
|
var out = [];
|
|
global.each(list, function (item) {
|
|
var text = getText(item);
|
|
if (item.menu !== undefined) {
|
|
var items = sanitizeList(item.menu, extractValue);
|
|
out.push({
|
|
text: text,
|
|
items: items
|
|
});
|
|
} else {
|
|
var value = extractValue(item);
|
|
out.push({
|
|
text: text,
|
|
value: value
|
|
});
|
|
}
|
|
});
|
|
return out;
|
|
};
|
|
var sanitizer = function (extractor) {
|
|
if (extractor === void 0) {
|
|
extractor = getValue;
|
|
}
|
|
return function (list) {
|
|
if (list) {
|
|
return Optional.from(list).map(function (list) {
|
|
return sanitizeList(list, extractor);
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
};
|
|
var sanitize = function (list) {
|
|
return sanitizer(getValue)(list);
|
|
};
|
|
var isGroup = function (item) {
|
|
return has(item, 'items');
|
|
};
|
|
var findEntryDelegate = function (list, value) {
|
|
return findMap(list, function (item) {
|
|
if (isGroup(item)) {
|
|
return findEntryDelegate(item.items, value);
|
|
} else if (item.value === value) {
|
|
return Optional.some(item);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
};
|
|
var findEntry = function (optList, value) {
|
|
return optList.bind(function (list) {
|
|
return findEntryDelegate(list, value);
|
|
});
|
|
};
|
|
var ListUtils = {
|
|
sanitizer: sanitizer,
|
|
sanitize: sanitize,
|
|
findEntry: findEntry
|
|
};
|
|
|
|
var makeTab$2 = function (_info) {
|
|
return {
|
|
title: 'Advanced',
|
|
name: 'advanced',
|
|
items: [
|
|
{
|
|
type: 'input',
|
|
label: 'Style',
|
|
name: 'style'
|
|
},
|
|
{
|
|
type: 'grid',
|
|
columns: 2,
|
|
items: [
|
|
{
|
|
type: 'input',
|
|
label: 'Vertical space',
|
|
name: 'vspace',
|
|
inputMode: 'numeric'
|
|
},
|
|
{
|
|
type: 'input',
|
|
label: 'Horizontal space',
|
|
name: 'hspace',
|
|
inputMode: 'numeric'
|
|
},
|
|
{
|
|
type: 'input',
|
|
label: 'Border width',
|
|
name: 'border',
|
|
inputMode: 'numeric'
|
|
},
|
|
{
|
|
type: 'listbox',
|
|
name: 'borderstyle',
|
|
label: 'Border style',
|
|
items: [
|
|
{
|
|
text: 'Select...',
|
|
value: ''
|
|
},
|
|
{
|
|
text: 'Solid',
|
|
value: 'solid'
|
|
},
|
|
{
|
|
text: 'Dotted',
|
|
value: 'dotted'
|
|
},
|
|
{
|
|
text: 'Dashed',
|
|
value: 'dashed'
|
|
},
|
|
{
|
|
text: 'Double',
|
|
value: 'double'
|
|
},
|
|
{
|
|
text: 'Groove',
|
|
value: 'groove'
|
|
},
|
|
{
|
|
text: 'Ridge',
|
|
value: 'ridge'
|
|
},
|
|
{
|
|
text: 'Inset',
|
|
value: 'inset'
|
|
},
|
|
{
|
|
text: 'Outset',
|
|
value: 'outset'
|
|
},
|
|
{
|
|
text: 'None',
|
|
value: 'none'
|
|
},
|
|
{
|
|
text: 'Hidden',
|
|
value: 'hidden'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
};
|
|
};
|
|
var AdvTab = { makeTab: makeTab$2 };
|
|
|
|
var collect = function (editor) {
|
|
var urlListSanitizer = ListUtils.sanitizer(function (item) {
|
|
return editor.convertURL(item.value || item.url, 'src');
|
|
});
|
|
var futureImageList = new global$4(function (completer) {
|
|
createImageList(editor, function (imageList) {
|
|
completer(urlListSanitizer(imageList).map(function (items) {
|
|
return flatten([
|
|
[{
|
|
text: 'None',
|
|
value: ''
|
|
}],
|
|
items
|
|
]);
|
|
}));
|
|
});
|
|
});
|
|
var classList = ListUtils.sanitize(getClassList(editor));
|
|
var hasAdvTab$1 = hasAdvTab(editor);
|
|
var hasUploadTab$1 = hasUploadTab(editor);
|
|
var hasUploadUrl$1 = hasUploadUrl(editor);
|
|
var hasUploadHandler$1 = hasUploadHandler(editor);
|
|
var image = readImageDataFromSelection(editor);
|
|
var hasDescription$1 = hasDescription(editor);
|
|
var hasImageTitle$1 = hasImageTitle(editor);
|
|
var hasDimensions$1 = hasDimensions(editor);
|
|
var hasImageCaption$1 = hasImageCaption(editor);
|
|
var hasAccessibilityOptions = showAccessibilityOptions(editor);
|
|
var automaticUploads = isAutomaticUploadsEnabled(editor);
|
|
var prependURL = Optional.some(getPrependUrl(editor)).filter(function (preUrl) {
|
|
return isString(preUrl) && preUrl.length > 0;
|
|
});
|
|
return futureImageList.then(function (imageList) {
|
|
return {
|
|
image: image,
|
|
imageList: imageList,
|
|
classList: classList,
|
|
hasAdvTab: hasAdvTab$1,
|
|
hasUploadTab: hasUploadTab$1,
|
|
hasUploadUrl: hasUploadUrl$1,
|
|
hasUploadHandler: hasUploadHandler$1,
|
|
hasDescription: hasDescription$1,
|
|
hasImageTitle: hasImageTitle$1,
|
|
hasDimensions: hasDimensions$1,
|
|
hasImageCaption: hasImageCaption$1,
|
|
prependURL: prependURL,
|
|
hasAccessibilityOptions: hasAccessibilityOptions,
|
|
automaticUploads: automaticUploads
|
|
};
|
|
});
|
|
};
|
|
|
|
var makeItems = function (info) {
|
|
var imageUrl = {
|
|
name: 'src',
|
|
type: 'urlinput',
|
|
filetype: 'image',
|
|
label: 'Source'
|
|
};
|
|
var imageList = info.imageList.map(function (items) {
|
|
return {
|
|
name: 'images',
|
|
type: 'listbox',
|
|
label: 'Image list',
|
|
items: items
|
|
};
|
|
});
|
|
var imageDescription = {
|
|
name: 'alt',
|
|
type: 'input',
|
|
label: 'Alternative description',
|
|
disabled: info.hasAccessibilityOptions && info.image.isDecorative
|
|
};
|
|
var imageTitle = {
|
|
name: 'title',
|
|
type: 'input',
|
|
label: 'Image title'
|
|
};
|
|
var imageDimensions = {
|
|
name: 'dimensions',
|
|
type: 'sizeinput'
|
|
};
|
|
var isDecorative = {
|
|
type: 'label',
|
|
label: 'Accessibility',
|
|
items: [{
|
|
name: 'isDecorative',
|
|
type: 'checkbox',
|
|
label: 'Image is decorative'
|
|
}]
|
|
};
|
|
var classList = info.classList.map(function (items) {
|
|
return {
|
|
name: 'classes',
|
|
type: 'listbox',
|
|
label: 'Class',
|
|
items: items
|
|
};
|
|
});
|
|
var caption = {
|
|
type: 'label',
|
|
label: 'Caption',
|
|
items: [{
|
|
type: 'checkbox',
|
|
name: 'caption',
|
|
label: 'Show caption'
|
|
}]
|
|
};
|
|
var getDialogContainerType = function (useColumns) {
|
|
return useColumns ? {
|
|
type: 'grid',
|
|
columns: 2
|
|
} : { type: 'panel' };
|
|
};
|
|
return flatten([
|
|
[imageUrl],
|
|
imageList.toArray(),
|
|
info.hasAccessibilityOptions && info.hasDescription ? [isDecorative] : [],
|
|
info.hasDescription ? [imageDescription] : [],
|
|
info.hasImageTitle ? [imageTitle] : [],
|
|
info.hasDimensions ? [imageDimensions] : [],
|
|
[__assign(__assign({}, getDialogContainerType(info.classList.isSome() && info.hasImageCaption)), {
|
|
items: flatten([
|
|
classList.toArray(),
|
|
info.hasImageCaption ? [caption] : []
|
|
])
|
|
})]
|
|
]);
|
|
};
|
|
var makeTab$1 = function (info) {
|
|
return {
|
|
title: 'General',
|
|
name: 'general',
|
|
items: makeItems(info)
|
|
};
|
|
};
|
|
var MainTab = {
|
|
makeTab: makeTab$1,
|
|
makeItems: makeItems
|
|
};
|
|
|
|
var makeTab = function (_info) {
|
|
var items = [{
|
|
type: 'dropzone',
|
|
name: 'fileinput'
|
|
}];
|
|
return {
|
|
title: 'Upload',
|
|
name: 'upload',
|
|
items: items
|
|
};
|
|
};
|
|
var UploadTab = { makeTab: makeTab };
|
|
|
|
var createState = function (info) {
|
|
return {
|
|
prevImage: ListUtils.findEntry(info.imageList, info.image.src),
|
|
prevAlt: info.image.alt,
|
|
open: true
|
|
};
|
|
};
|
|
var fromImageData = function (image) {
|
|
return {
|
|
src: {
|
|
value: image.src,
|
|
meta: {}
|
|
},
|
|
images: image.src,
|
|
alt: image.alt,
|
|
title: image.title,
|
|
dimensions: {
|
|
width: image.width,
|
|
height: image.height
|
|
},
|
|
classes: image.class,
|
|
caption: image.caption,
|
|
style: image.style,
|
|
vspace: image.vspace,
|
|
border: image.border,
|
|
hspace: image.hspace,
|
|
borderstyle: image.borderStyle,
|
|
fileinput: [],
|
|
isDecorative: image.isDecorative
|
|
};
|
|
};
|
|
var toImageData = function (data, removeEmptyAlt) {
|
|
return {
|
|
src: data.src.value,
|
|
alt: data.alt.length === 0 && removeEmptyAlt ? null : data.alt,
|
|
title: data.title,
|
|
width: data.dimensions.width,
|
|
height: data.dimensions.height,
|
|
class: data.classes,
|
|
style: data.style,
|
|
caption: data.caption,
|
|
hspace: data.hspace,
|
|
vspace: data.vspace,
|
|
border: data.border,
|
|
borderStyle: data.borderstyle,
|
|
isDecorative: data.isDecorative
|
|
};
|
|
};
|
|
var addPrependUrl2 = function (info, srcURL) {
|
|
if (!/^(?:[a-zA-Z]+:)?\/\//.test(srcURL)) {
|
|
return info.prependURL.bind(function (prependUrl) {
|
|
if (srcURL.substring(0, prependUrl.length) !== prependUrl) {
|
|
return Optional.some(prependUrl + srcURL);
|
|
}
|
|
return Optional.none();
|
|
});
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var addPrependUrl = function (info, api) {
|
|
var data = api.getData();
|
|
addPrependUrl2(info, data.src.value).each(function (srcURL) {
|
|
api.setData({
|
|
src: {
|
|
value: srcURL,
|
|
meta: data.src.meta
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var formFillFromMeta2 = function (info, data, meta) {
|
|
if (info.hasDescription && isString(meta.alt)) {
|
|
data.alt = meta.alt;
|
|
}
|
|
if (info.hasAccessibilityOptions) {
|
|
data.isDecorative = meta.isDecorative || data.isDecorative || false;
|
|
}
|
|
if (info.hasImageTitle && isString(meta.title)) {
|
|
data.title = meta.title;
|
|
}
|
|
if (info.hasDimensions) {
|
|
if (isString(meta.width)) {
|
|
data.dimensions.width = meta.width;
|
|
}
|
|
if (isString(meta.height)) {
|
|
data.dimensions.height = meta.height;
|
|
}
|
|
}
|
|
if (isString(meta.class)) {
|
|
ListUtils.findEntry(info.classList, meta.class).each(function (entry) {
|
|
data.classes = entry.value;
|
|
});
|
|
}
|
|
if (info.hasImageCaption) {
|
|
if (isBoolean(meta.caption)) {
|
|
data.caption = meta.caption;
|
|
}
|
|
}
|
|
if (info.hasAdvTab) {
|
|
if (isString(meta.style)) {
|
|
data.style = meta.style;
|
|
}
|
|
if (isString(meta.vspace)) {
|
|
data.vspace = meta.vspace;
|
|
}
|
|
if (isString(meta.border)) {
|
|
data.border = meta.border;
|
|
}
|
|
if (isString(meta.hspace)) {
|
|
data.hspace = meta.hspace;
|
|
}
|
|
if (isString(meta.borderstyle)) {
|
|
data.borderstyle = meta.borderstyle;
|
|
}
|
|
}
|
|
};
|
|
var formFillFromMeta = function (info, api) {
|
|
var data = api.getData();
|
|
var meta = data.src.meta;
|
|
if (meta !== undefined) {
|
|
var newData = deepMerge({}, data);
|
|
formFillFromMeta2(info, newData, meta);
|
|
api.setData(newData);
|
|
}
|
|
};
|
|
var calculateImageSize = function (helpers, info, state, api) {
|
|
var data = api.getData();
|
|
var url = data.src.value;
|
|
var meta = data.src.meta || {};
|
|
if (!meta.width && !meta.height && info.hasDimensions) {
|
|
if (isNotEmpty(url)) {
|
|
helpers.imageSize(url).then(function (size) {
|
|
if (state.open) {
|
|
api.setData({ dimensions: size });
|
|
}
|
|
}).catch(function (e) {
|
|
return console.error(e);
|
|
});
|
|
} else {
|
|
api.setData({
|
|
dimensions: {
|
|
width: '',
|
|
height: ''
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
var updateImagesDropdown = function (info, state, api) {
|
|
var data = api.getData();
|
|
var image = ListUtils.findEntry(info.imageList, data.src.value);
|
|
state.prevImage = image;
|
|
api.setData({
|
|
images: image.map(function (entry) {
|
|
return entry.value;
|
|
}).getOr('')
|
|
});
|
|
};
|
|
var changeSrc = function (helpers, info, state, api) {
|
|
addPrependUrl(info, api);
|
|
formFillFromMeta(info, api);
|
|
calculateImageSize(helpers, info, state, api);
|
|
updateImagesDropdown(info, state, api);
|
|
};
|
|
var changeImages = function (helpers, info, state, api) {
|
|
var data = api.getData();
|
|
var image = ListUtils.findEntry(info.imageList, data.images);
|
|
image.each(function (img) {
|
|
var updateAlt = data.alt === '' || state.prevImage.map(function (image) {
|
|
return image.text === data.alt;
|
|
}).getOr(false);
|
|
if (updateAlt) {
|
|
if (img.value === '') {
|
|
api.setData({
|
|
src: img,
|
|
alt: state.prevAlt
|
|
});
|
|
} else {
|
|
api.setData({
|
|
src: img,
|
|
alt: img.text
|
|
});
|
|
}
|
|
} else {
|
|
api.setData({ src: img });
|
|
}
|
|
});
|
|
state.prevImage = image;
|
|
changeSrc(helpers, info, state, api);
|
|
};
|
|
var calcVSpace = function (css) {
|
|
var matchingTopBottom = css['margin-top'] && css['margin-bottom'] && css['margin-top'] === css['margin-bottom'];
|
|
return matchingTopBottom ? removePixelSuffix(String(css['margin-top'])) : '';
|
|
};
|
|
var calcHSpace = function (css) {
|
|
var matchingLeftRight = css['margin-right'] && css['margin-left'] && css['margin-right'] === css['margin-left'];
|
|
return matchingLeftRight ? removePixelSuffix(String(css['margin-right'])) : '';
|
|
};
|
|
var calcBorderWidth = function (css) {
|
|
return css['border-width'] ? removePixelSuffix(String(css['border-width'])) : '';
|
|
};
|
|
var calcBorderStyle = function (css) {
|
|
return css['border-style'] ? String(css['border-style']) : '';
|
|
};
|
|
var calcStyle = function (parseStyle, serializeStyle, css) {
|
|
return serializeStyle(parseStyle(serializeStyle(css)));
|
|
};
|
|
var changeStyle2 = function (parseStyle, serializeStyle, data) {
|
|
var css = mergeMargins(parseStyle(data.style));
|
|
var dataCopy = deepMerge({}, data);
|
|
dataCopy.vspace = calcVSpace(css);
|
|
dataCopy.hspace = calcHSpace(css);
|
|
dataCopy.border = calcBorderWidth(css);
|
|
dataCopy.borderstyle = calcBorderStyle(css);
|
|
dataCopy.style = calcStyle(parseStyle, serializeStyle, css);
|
|
return dataCopy;
|
|
};
|
|
var changeStyle = function (helpers, api) {
|
|
var data = api.getData();
|
|
var newData = changeStyle2(helpers.parseStyle, helpers.serializeStyle, data);
|
|
api.setData(newData);
|
|
};
|
|
var changeAStyle = function (helpers, info, api) {
|
|
var data = deepMerge(fromImageData(info.image), api.getData());
|
|
var style = getStyleValue(helpers.normalizeCss, toImageData(data, false));
|
|
api.setData({ style: style });
|
|
};
|
|
var changeFileInput = function (helpers, info, state, api) {
|
|
var data = api.getData();
|
|
api.block('Uploading image');
|
|
head(data.fileinput).fold(function () {
|
|
api.unblock();
|
|
}, function (file) {
|
|
var blobUri = URL.createObjectURL(file);
|
|
var finalize = function () {
|
|
api.unblock();
|
|
URL.revokeObjectURL(blobUri);
|
|
};
|
|
var updateSrcAndSwitchTab = function (url) {
|
|
api.setData({
|
|
src: {
|
|
value: url,
|
|
meta: {}
|
|
}
|
|
});
|
|
api.showTab('general');
|
|
changeSrc(helpers, info, state, api);
|
|
};
|
|
blobToDataUri(file).then(function (dataUrl) {
|
|
var blobInfo = helpers.createBlobCache(file, blobUri, dataUrl);
|
|
if (info.automaticUploads) {
|
|
helpers.uploadImage(blobInfo).then(function (result) {
|
|
updateSrcAndSwitchTab(result.url);
|
|
finalize();
|
|
}).catch(function (err) {
|
|
finalize();
|
|
helpers.alertErr(err);
|
|
});
|
|
} else {
|
|
helpers.addToBlobCache(blobInfo);
|
|
updateSrcAndSwitchTab(blobInfo.blobUri());
|
|
api.unblock();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var changeHandler = function (helpers, info, state) {
|
|
return function (api, evt) {
|
|
if (evt.name === 'src') {
|
|
changeSrc(helpers, info, state, api);
|
|
} else if (evt.name === 'images') {
|
|
changeImages(helpers, info, state, api);
|
|
} else if (evt.name === 'alt') {
|
|
state.prevAlt = api.getData().alt;
|
|
} else if (evt.name === 'style') {
|
|
changeStyle(helpers, api);
|
|
} else if (evt.name === 'vspace' || evt.name === 'hspace' || evt.name === 'border' || evt.name === 'borderstyle') {
|
|
changeAStyle(helpers, info, api);
|
|
} else if (evt.name === 'fileinput') {
|
|
changeFileInput(helpers, info, state, api);
|
|
} else if (evt.name === 'isDecorative') {
|
|
if (api.getData().isDecorative) {
|
|
api.disable('alt');
|
|
} else {
|
|
api.enable('alt');
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var closeHandler = function (state) {
|
|
return function () {
|
|
state.open = false;
|
|
};
|
|
};
|
|
var makeDialogBody = function (info) {
|
|
if (info.hasAdvTab || info.hasUploadUrl || info.hasUploadHandler) {
|
|
var tabPanel = {
|
|
type: 'tabpanel',
|
|
tabs: flatten([
|
|
[MainTab.makeTab(info)],
|
|
info.hasAdvTab ? [AdvTab.makeTab(info)] : [],
|
|
info.hasUploadTab && (info.hasUploadUrl || info.hasUploadHandler) ? [UploadTab.makeTab(info)] : []
|
|
])
|
|
};
|
|
return tabPanel;
|
|
} else {
|
|
var panel = {
|
|
type: 'panel',
|
|
items: MainTab.makeItems(info)
|
|
};
|
|
return panel;
|
|
}
|
|
};
|
|
var makeDialog = function (helpers) {
|
|
return function (info) {
|
|
var state = createState(info);
|
|
return {
|
|
title: 'Insert/Edit Image',
|
|
size: 'normal',
|
|
body: makeDialogBody(info),
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: fromImageData(info.image),
|
|
onSubmit: helpers.onSubmit(info),
|
|
onChange: changeHandler(helpers, info, state),
|
|
onClose: closeHandler(state)
|
|
};
|
|
};
|
|
};
|
|
var submitHandler = function (editor) {
|
|
return function (info) {
|
|
return function (api) {
|
|
var data = deepMerge(fromImageData(info.image), api.getData());
|
|
editor.execCommand('mceUpdateImage', false, toImageData(data, info.hasAccessibilityOptions));
|
|
editor.editorUpload.uploadImagesAuto();
|
|
api.close();
|
|
};
|
|
};
|
|
};
|
|
var imageSize = function (editor) {
|
|
return function (url) {
|
|
if (!isSafeImageUrl(editor, url)) {
|
|
return global$4.resolve({
|
|
width: '',
|
|
height: ''
|
|
});
|
|
} else {
|
|
return getImageSize(editor.documentBaseURI.toAbsolute(url)).then(function (dimensions) {
|
|
return {
|
|
width: String(dimensions.width),
|
|
height: String(dimensions.height)
|
|
};
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var createBlobCache = function (editor) {
|
|
return function (file, blobUri, dataUrl) {
|
|
return editor.editorUpload.blobCache.create({
|
|
blob: file,
|
|
blobUri: blobUri,
|
|
name: file.name ? file.name.replace(/\.[^\.]+$/, '') : null,
|
|
filename: file.name,
|
|
base64: dataUrl.split(',')[1]
|
|
});
|
|
};
|
|
};
|
|
var addToBlobCache = function (editor) {
|
|
return function (blobInfo) {
|
|
editor.editorUpload.blobCache.add(blobInfo);
|
|
};
|
|
};
|
|
var alertErr = function (editor) {
|
|
return function (message) {
|
|
editor.windowManager.alert(message);
|
|
};
|
|
};
|
|
var normalizeCss = function (editor) {
|
|
return function (cssText) {
|
|
return normalizeCss$1(editor, cssText);
|
|
};
|
|
};
|
|
var parseStyle = function (editor) {
|
|
return function (cssText) {
|
|
return editor.dom.parseStyle(cssText);
|
|
};
|
|
};
|
|
var serializeStyle = function (editor) {
|
|
return function (stylesArg, name) {
|
|
return editor.dom.serializeStyle(stylesArg, name);
|
|
};
|
|
};
|
|
var uploadImage = function (editor) {
|
|
return function (blobInfo) {
|
|
return global$1(editor).upload([blobInfo], false).then(function (results) {
|
|
if (results.length === 0) {
|
|
return global$4.reject('Failed to upload image');
|
|
} else if (results[0].status === false) {
|
|
return global$4.reject(results[0].error.message);
|
|
} else {
|
|
return results[0];
|
|
}
|
|
});
|
|
};
|
|
};
|
|
var Dialog = function (editor) {
|
|
var helpers = {
|
|
onSubmit: submitHandler(editor),
|
|
imageSize: imageSize(editor),
|
|
addToBlobCache: addToBlobCache(editor),
|
|
createBlobCache: createBlobCache(editor),
|
|
alertErr: alertErr(editor),
|
|
normalizeCss: normalizeCss(editor),
|
|
parseStyle: parseStyle(editor),
|
|
serializeStyle: serializeStyle(editor),
|
|
uploadImage: uploadImage(editor)
|
|
};
|
|
var open = function () {
|
|
collect(editor).then(makeDialog(helpers)).then(editor.windowManager.open);
|
|
};
|
|
return { open: open };
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceImage', Dialog(editor).open);
|
|
editor.addCommand('mceUpdateImage', function (_ui, data) {
|
|
editor.undoManager.transact(function () {
|
|
return insertOrUpdateImage(editor, data);
|
|
});
|
|
});
|
|
};
|
|
|
|
var hasImageClass = function (node) {
|
|
var className = node.attr('class');
|
|
return className && /\bimage\b/.test(className);
|
|
};
|
|
var toggleContentEditableState = function (state) {
|
|
return function (nodes) {
|
|
var i = nodes.length;
|
|
var toggleContentEditable = function (node) {
|
|
node.attr('contenteditable', state ? 'true' : null);
|
|
};
|
|
while (i--) {
|
|
var node = nodes[i];
|
|
if (hasImageClass(node)) {
|
|
node.attr('contenteditable', state ? 'false' : null);
|
|
global.each(node.getAll('figcaption'), toggleContentEditable);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var setup = function (editor) {
|
|
editor.on('PreInit', function () {
|
|
editor.parser.addNodeFilter('figure', toggleContentEditableState(true));
|
|
editor.serializer.addNodeFilter('figure', toggleContentEditableState(false));
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
editor.ui.registry.addToggleButton('image', {
|
|
icon: 'image',
|
|
tooltip: 'Insert/edit image',
|
|
onAction: Dialog(editor).open,
|
|
onSetup: function (buttonApi) {
|
|
buttonApi.setActive(isNonNullable(getSelectedImage(editor)));
|
|
return editor.selection.selectorChangedWithUnbind('img:not([data-mce-object],[data-mce-placeholder]),figure.image', buttonApi.setActive).unbind;
|
|
}
|
|
});
|
|
editor.ui.registry.addMenuItem('image', {
|
|
icon: 'image',
|
|
text: 'Image...',
|
|
onAction: Dialog(editor).open
|
|
});
|
|
editor.ui.registry.addContextMenu('image', {
|
|
update: function (element) {
|
|
return isFigure(element) || isImage(element) && !isPlaceholderImage(element) ? ['image'] : [];
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$6.add('image', function (editor) {
|
|
setup(editor);
|
|
register(editor);
|
|
register$1(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isArray = isType('array');
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var exports$1 = {}, module = { exports: exports$1 };
|
|
(function (define, exports, module, require) {
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EphoxContactWrapper = factory());
|
|
}(this, function () {
|
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
var promise = { exports: {} };
|
|
(function (module) {
|
|
(function (root) {
|
|
var setTimeoutFunc = setTimeout;
|
|
function noop() {
|
|
}
|
|
function bind(fn, thisArg) {
|
|
return function () {
|
|
fn.apply(thisArg, arguments);
|
|
};
|
|
}
|
|
function Promise(fn) {
|
|
if (typeof this !== 'object')
|
|
throw new TypeError('Promises must be constructed via new');
|
|
if (typeof fn !== 'function')
|
|
throw new TypeError('not a function');
|
|
this._state = 0;
|
|
this._handled = false;
|
|
this._value = undefined;
|
|
this._deferreds = [];
|
|
doResolve(fn, this);
|
|
}
|
|
function handle(self, deferred) {
|
|
while (self._state === 3) {
|
|
self = self._value;
|
|
}
|
|
if (self._state === 0) {
|
|
self._deferreds.push(deferred);
|
|
return;
|
|
}
|
|
self._handled = true;
|
|
Promise._immediateFn(function () {
|
|
var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
|
|
if (cb === null) {
|
|
(self._state === 1 ? resolve : reject)(deferred.promise, self._value);
|
|
return;
|
|
}
|
|
var ret;
|
|
try {
|
|
ret = cb(self._value);
|
|
} catch (e) {
|
|
reject(deferred.promise, e);
|
|
return;
|
|
}
|
|
resolve(deferred.promise, ret);
|
|
});
|
|
}
|
|
function resolve(self, newValue) {
|
|
try {
|
|
if (newValue === self)
|
|
throw new TypeError('A promise cannot be resolved with itself.');
|
|
if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) {
|
|
var then = newValue.then;
|
|
if (newValue instanceof Promise) {
|
|
self._state = 3;
|
|
self._value = newValue;
|
|
finale(self);
|
|
return;
|
|
} else if (typeof then === 'function') {
|
|
doResolve(bind(then, newValue), self);
|
|
return;
|
|
}
|
|
}
|
|
self._state = 1;
|
|
self._value = newValue;
|
|
finale(self);
|
|
} catch (e) {
|
|
reject(self, e);
|
|
}
|
|
}
|
|
function reject(self, newValue) {
|
|
self._state = 2;
|
|
self._value = newValue;
|
|
finale(self);
|
|
}
|
|
function finale(self) {
|
|
if (self._state === 2 && self._deferreds.length === 0) {
|
|
Promise._immediateFn(function () {
|
|
if (!self._handled) {
|
|
Promise._unhandledRejectionFn(self._value);
|
|
}
|
|
});
|
|
}
|
|
for (var i = 0, len = self._deferreds.length; i < len; i++) {
|
|
handle(self, self._deferreds[i]);
|
|
}
|
|
self._deferreds = null;
|
|
}
|
|
function Handler(onFulfilled, onRejected, promise) {
|
|
this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
|
|
this.onRejected = typeof onRejected === 'function' ? onRejected : null;
|
|
this.promise = promise;
|
|
}
|
|
function doResolve(fn, self) {
|
|
var done = false;
|
|
try {
|
|
fn(function (value) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
resolve(self, value);
|
|
}, function (reason) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
reject(self, reason);
|
|
});
|
|
} catch (ex) {
|
|
if (done)
|
|
return;
|
|
done = true;
|
|
reject(self, ex);
|
|
}
|
|
}
|
|
Promise.prototype['catch'] = function (onRejected) {
|
|
return this.then(null, onRejected);
|
|
};
|
|
Promise.prototype.then = function (onFulfilled, onRejected) {
|
|
var prom = new this.constructor(noop);
|
|
handle(this, new Handler(onFulfilled, onRejected, prom));
|
|
return prom;
|
|
};
|
|
Promise.all = function (arr) {
|
|
var args = Array.prototype.slice.call(arr);
|
|
return new Promise(function (resolve, reject) {
|
|
if (args.length === 0)
|
|
return resolve([]);
|
|
var remaining = args.length;
|
|
function res(i, val) {
|
|
try {
|
|
if (val && (typeof val === 'object' || typeof val === 'function')) {
|
|
var then = val.then;
|
|
if (typeof then === 'function') {
|
|
then.call(val, function (val) {
|
|
res(i, val);
|
|
}, reject);
|
|
return;
|
|
}
|
|
}
|
|
args[i] = val;
|
|
if (--remaining === 0) {
|
|
resolve(args);
|
|
}
|
|
} catch (ex) {
|
|
reject(ex);
|
|
}
|
|
}
|
|
for (var i = 0; i < args.length; i++) {
|
|
res(i, args[i]);
|
|
}
|
|
});
|
|
};
|
|
Promise.resolve = function (value) {
|
|
if (value && typeof value === 'object' && value.constructor === Promise) {
|
|
return value;
|
|
}
|
|
return new Promise(function (resolve) {
|
|
resolve(value);
|
|
});
|
|
};
|
|
Promise.reject = function (value) {
|
|
return new Promise(function (resolve, reject) {
|
|
reject(value);
|
|
});
|
|
};
|
|
Promise.race = function (values) {
|
|
return new Promise(function (resolve, reject) {
|
|
for (var i = 0, len = values.length; i < len; i++) {
|
|
values[i].then(resolve, reject);
|
|
}
|
|
});
|
|
};
|
|
Promise._immediateFn = typeof setImmediate === 'function' ? function (fn) {
|
|
setImmediate(fn);
|
|
} : function (fn) {
|
|
setTimeoutFunc(fn, 0);
|
|
};
|
|
Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
|
|
if (typeof console !== 'undefined' && console) {
|
|
console.warn('Possible Unhandled Promise Rejection:', err);
|
|
}
|
|
};
|
|
Promise._setImmediateFn = function _setImmediateFn(fn) {
|
|
Promise._immediateFn = fn;
|
|
};
|
|
Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
|
|
Promise._unhandledRejectionFn = fn;
|
|
};
|
|
if (module.exports) {
|
|
module.exports = Promise;
|
|
} else if (!root.Promise) {
|
|
root.Promise = Promise;
|
|
}
|
|
}(commonjsGlobal));
|
|
}(promise));
|
|
var promisePolyfill = promise.exports;
|
|
var Global = function () {
|
|
if (typeof window !== 'undefined') {
|
|
return window;
|
|
} else {
|
|
return Function('return this;')();
|
|
}
|
|
}();
|
|
var promisePolyfill_1 = { boltExport: Global.Promise || promisePolyfill };
|
|
return promisePolyfill_1;
|
|
}));
|
|
}(undefined, exports$1, module));
|
|
var Promise$1 = module.exports.boltExport;
|
|
|
|
var create$1 = function (width, height) {
|
|
return resize(document.createElement('canvas'), width, height);
|
|
};
|
|
var clone = function (canvas) {
|
|
var tCanvas = create$1(canvas.width, canvas.height);
|
|
var ctx = get2dContext(tCanvas);
|
|
ctx.drawImage(canvas, 0, 0);
|
|
return tCanvas;
|
|
};
|
|
var get2dContext = function (canvas) {
|
|
return canvas.getContext('2d');
|
|
};
|
|
var resize = function (canvas, width, height) {
|
|
canvas.width = width;
|
|
canvas.height = height;
|
|
return canvas;
|
|
};
|
|
|
|
var getWidth = function (image) {
|
|
return image.naturalWidth || image.width;
|
|
};
|
|
var getHeight = function (image) {
|
|
return image.naturalHeight || image.height;
|
|
};
|
|
|
|
var imageToBlob$2 = function (image) {
|
|
var src = image.src;
|
|
if (src.indexOf('data:') === 0) {
|
|
return dataUriToBlob(src);
|
|
}
|
|
return anyUriToBlob(src);
|
|
};
|
|
var blobToImage$1 = function (blob) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
var blobUrl = URL.createObjectURL(blob);
|
|
var image = new Image();
|
|
var removeListeners = function () {
|
|
image.removeEventListener('load', loaded);
|
|
image.removeEventListener('error', error);
|
|
};
|
|
var loaded = function () {
|
|
removeListeners();
|
|
resolve(image);
|
|
};
|
|
var error = function () {
|
|
removeListeners();
|
|
reject('Unable to load data of type ' + blob.type + ': ' + blobUrl);
|
|
};
|
|
image.addEventListener('load', loaded);
|
|
image.addEventListener('error', error);
|
|
image.src = blobUrl;
|
|
if (image.complete) {
|
|
setTimeout(loaded, 0);
|
|
}
|
|
});
|
|
};
|
|
var anyUriToBlob = function (url) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', url, true);
|
|
xhr.responseType = 'blob';
|
|
xhr.onload = function () {
|
|
if (this.status === 200) {
|
|
resolve(this.response);
|
|
}
|
|
};
|
|
xhr.onerror = function () {
|
|
var _this = this;
|
|
var corsError = function () {
|
|
var obj = new Error('No access to download image');
|
|
obj.code = 18;
|
|
obj.name = 'SecurityError';
|
|
return obj;
|
|
};
|
|
var genericError = function () {
|
|
return new Error('Error ' + _this.status + ' downloading image');
|
|
};
|
|
reject(this.status === 0 ? corsError() : genericError());
|
|
};
|
|
xhr.send();
|
|
});
|
|
};
|
|
var dataUriToBlobSync = function (uri) {
|
|
var data = uri.split(',');
|
|
var matches = /data:([^;]+)/.exec(data[0]);
|
|
if (!matches) {
|
|
return Optional.none();
|
|
}
|
|
var mimetype = matches[1];
|
|
var base64 = data[1];
|
|
var sliceSize = 1024;
|
|
var byteCharacters = atob(base64);
|
|
var bytesLength = byteCharacters.length;
|
|
var slicesCount = Math.ceil(bytesLength / sliceSize);
|
|
var byteArrays = new Array(slicesCount);
|
|
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
|
var begin = sliceIndex * sliceSize;
|
|
var end = Math.min(begin + sliceSize, bytesLength);
|
|
var bytes = new Array(end - begin);
|
|
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
|
|
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
|
}
|
|
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
|
}
|
|
return Optional.some(new Blob(byteArrays, { type: mimetype }));
|
|
};
|
|
var dataUriToBlob = function (uri) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
dataUriToBlobSync(uri).fold(function () {
|
|
reject('uri is not base64: ' + uri);
|
|
}, resolve);
|
|
});
|
|
};
|
|
var canvasToBlob = function (canvas, type, quality) {
|
|
type = type || 'image/png';
|
|
if (isFunction(HTMLCanvasElement.prototype.toBlob)) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
canvas.toBlob(function (blob) {
|
|
if (blob) {
|
|
resolve(blob);
|
|
} else {
|
|
reject();
|
|
}
|
|
}, type, quality);
|
|
});
|
|
} else {
|
|
return dataUriToBlob(canvas.toDataURL(type, quality));
|
|
}
|
|
};
|
|
var canvasToDataURL = function (canvas, type, quality) {
|
|
type = type || 'image/png';
|
|
return canvas.toDataURL(type, quality);
|
|
};
|
|
var blobToCanvas = function (blob) {
|
|
return blobToImage$1(blob).then(function (image) {
|
|
revokeImageUrl(image);
|
|
var canvas = create$1(getWidth(image), getHeight(image));
|
|
var context = get2dContext(canvas);
|
|
context.drawImage(image, 0, 0);
|
|
return canvas;
|
|
});
|
|
};
|
|
var blobToDataUri = function (blob) {
|
|
return new Promise$1(function (resolve) {
|
|
var reader = new FileReader();
|
|
reader.onloadend = function () {
|
|
resolve(reader.result);
|
|
};
|
|
reader.readAsDataURL(blob);
|
|
});
|
|
};
|
|
var revokeImageUrl = function (image) {
|
|
URL.revokeObjectURL(image.src);
|
|
};
|
|
|
|
var blobToImage = function (blob) {
|
|
return blobToImage$1(blob);
|
|
};
|
|
var imageToBlob$1 = function (image) {
|
|
return imageToBlob$2(image);
|
|
};
|
|
|
|
var nativeIndexOf = Array.prototype.indexOf;
|
|
var rawIndexOf = function (ts, t) {
|
|
return nativeIndexOf.call(ts, t);
|
|
};
|
|
var contains = function (xs, x) {
|
|
return rawIndexOf(xs, x) > -1;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each$1(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var forall = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
var x = xs[i];
|
|
if (pred(x, i) !== true) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
|
|
var generate = function (cases) {
|
|
if (!isArray(cases)) {
|
|
throw new Error('cases must be an array');
|
|
}
|
|
if (cases.length === 0) {
|
|
throw new Error('there must be at least one case');
|
|
}
|
|
var constructors = [];
|
|
var adt = {};
|
|
each$1(cases, function (acase, count) {
|
|
var keys$1 = keys(acase);
|
|
if (keys$1.length !== 1) {
|
|
throw new Error('one and only one name per case');
|
|
}
|
|
var key = keys$1[0];
|
|
var value = acase[key];
|
|
if (adt[key] !== undefined) {
|
|
throw new Error('duplicate key detected:' + key);
|
|
} else if (key === 'cata') {
|
|
throw new Error('cannot have a case named cata (sorry)');
|
|
} else if (!isArray(value)) {
|
|
throw new Error('case arguments must be an array');
|
|
}
|
|
constructors.push(key);
|
|
adt[key] = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var argLength = args.length;
|
|
if (argLength !== value.length) {
|
|
throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
|
|
}
|
|
var match = function (branches) {
|
|
var branchKeys = keys(branches);
|
|
if (constructors.length !== branchKeys.length) {
|
|
throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
|
|
}
|
|
var allReqd = forall(constructors, function (reqKey) {
|
|
return contains(branchKeys, reqKey);
|
|
});
|
|
if (!allReqd) {
|
|
throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
|
|
}
|
|
return branches[key].apply(null, args);
|
|
};
|
|
return {
|
|
fold: function () {
|
|
var foldArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
foldArgs[_i] = arguments[_i];
|
|
}
|
|
if (foldArgs.length !== cases.length) {
|
|
throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
|
|
}
|
|
var target = foldArgs[count];
|
|
return target.apply(null, args);
|
|
},
|
|
match: match,
|
|
log: function (label) {
|
|
console.log(label, {
|
|
constructors: constructors,
|
|
constructor: key,
|
|
params: args
|
|
});
|
|
}
|
|
};
|
|
};
|
|
});
|
|
return adt;
|
|
};
|
|
var Adt = { generate: generate };
|
|
|
|
Adt.generate([
|
|
{
|
|
bothErrors: [
|
|
'error1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
firstError: [
|
|
'error1',
|
|
'value2'
|
|
]
|
|
},
|
|
{
|
|
secondError: [
|
|
'value1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
bothValues: [
|
|
'value1',
|
|
'value2'
|
|
]
|
|
}
|
|
]);
|
|
|
|
var create = function (getCanvas, blob, uri) {
|
|
var initialType = blob.type;
|
|
var getType = constant(initialType);
|
|
var toBlob = function () {
|
|
return Promise$1.resolve(blob);
|
|
};
|
|
var toDataURL = constant(uri);
|
|
var toBase64 = function () {
|
|
return uri.split(',')[1];
|
|
};
|
|
var toAdjustedBlob = function (type, quality) {
|
|
return getCanvas.then(function (canvas) {
|
|
return canvasToBlob(canvas, type, quality);
|
|
});
|
|
};
|
|
var toAdjustedDataURL = function (type, quality) {
|
|
return getCanvas.then(function (canvas) {
|
|
return canvasToDataURL(canvas, type, quality);
|
|
});
|
|
};
|
|
var toAdjustedBase64 = function (type, quality) {
|
|
return toAdjustedDataURL(type, quality).then(function (dataurl) {
|
|
return dataurl.split(',')[1];
|
|
});
|
|
};
|
|
var toCanvas = function () {
|
|
return getCanvas.then(clone);
|
|
};
|
|
return {
|
|
getType: getType,
|
|
toBlob: toBlob,
|
|
toDataURL: toDataURL,
|
|
toBase64: toBase64,
|
|
toAdjustedBlob: toAdjustedBlob,
|
|
toAdjustedDataURL: toAdjustedDataURL,
|
|
toAdjustedBase64: toAdjustedBase64,
|
|
toCanvas: toCanvas
|
|
};
|
|
};
|
|
var fromBlob = function (blob) {
|
|
return blobToDataUri(blob).then(function (uri) {
|
|
return create(blobToCanvas(blob), blob, uri);
|
|
});
|
|
};
|
|
var fromCanvas = function (canvas, type) {
|
|
return canvasToBlob(canvas, type).then(function (blob) {
|
|
return create(Promise$1.resolve(canvas), blob, canvas.toDataURL());
|
|
});
|
|
};
|
|
|
|
var ceilWithPrecision = function (num, precision) {
|
|
if (precision === void 0) {
|
|
precision = 2;
|
|
}
|
|
var mul = Math.pow(10, precision);
|
|
var upper = Math.round(num * mul);
|
|
return Math.ceil(upper / mul);
|
|
};
|
|
var rotate$2 = function (ir, angle) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return applyRotate(canvas, ir.getType(), angle);
|
|
});
|
|
};
|
|
var applyRotate = function (image, type, angle) {
|
|
var degrees = angle < 0 ? 360 + angle : angle;
|
|
var rad = degrees * Math.PI / 180;
|
|
var width = image.width;
|
|
var height = image.height;
|
|
var sin = Math.sin(rad);
|
|
var cos = Math.cos(rad);
|
|
var newWidth = ceilWithPrecision(Math.abs(width * cos) + Math.abs(height * sin));
|
|
var newHeight = ceilWithPrecision(Math.abs(width * sin) + Math.abs(height * cos));
|
|
var canvas = create$1(newWidth, newHeight);
|
|
var context = get2dContext(canvas);
|
|
context.translate(newWidth / 2, newHeight / 2);
|
|
context.rotate(rad);
|
|
context.drawImage(image, -width / 2, -height / 2);
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
var flip$2 = function (ir, axis) {
|
|
return ir.toCanvas().then(function (canvas) {
|
|
return applyFlip(canvas, ir.getType(), axis);
|
|
});
|
|
};
|
|
var applyFlip = function (image, type, axis) {
|
|
var canvas = create$1(image.width, image.height);
|
|
var context = get2dContext(canvas);
|
|
if (axis === 'v') {
|
|
context.scale(1, -1);
|
|
context.drawImage(image, 0, -canvas.height);
|
|
} else {
|
|
context.scale(-1, 1);
|
|
context.drawImage(image, -canvas.width, 0);
|
|
}
|
|
return fromCanvas(canvas, type);
|
|
};
|
|
|
|
var flip$1 = function (ir, axis) {
|
|
return flip$2(ir, axis);
|
|
};
|
|
var rotate$1 = function (ir, angle) {
|
|
return rotate$2(ir, angle);
|
|
};
|
|
|
|
var sendRequest = function (url, headers, withCredentials) {
|
|
if (withCredentials === void 0) {
|
|
withCredentials = false;
|
|
}
|
|
return new Promise$1(function (resolve) {
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.onreadystatechange = function () {
|
|
if (xhr.readyState === 4) {
|
|
resolve({
|
|
status: xhr.status,
|
|
blob: xhr.response
|
|
});
|
|
}
|
|
};
|
|
xhr.open('GET', url, true);
|
|
xhr.withCredentials = withCredentials;
|
|
each(headers, function (value, key) {
|
|
xhr.setRequestHeader(key, value);
|
|
});
|
|
xhr.responseType = 'blob';
|
|
xhr.send();
|
|
});
|
|
};
|
|
var readBlobText = function (blob) {
|
|
return new Promise$1(function (resolve, reject) {
|
|
var reader = new FileReader();
|
|
reader.onload = function () {
|
|
resolve(reader.result);
|
|
};
|
|
reader.onerror = function (e) {
|
|
reject(e);
|
|
};
|
|
reader.readAsText(blob);
|
|
});
|
|
};
|
|
var parseJson = function (text) {
|
|
try {
|
|
return Optional.some(JSON.parse(text));
|
|
} catch (ex) {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
|
|
var friendlyHttpErrors = [
|
|
{
|
|
code: 404,
|
|
message: 'Could not find Image Proxy'
|
|
},
|
|
{
|
|
code: 403,
|
|
message: 'Rejected request'
|
|
},
|
|
{
|
|
code: 0,
|
|
message: 'Incorrect Image Proxy URL'
|
|
}
|
|
];
|
|
var friendlyServiceErrors = [
|
|
{
|
|
type: 'not_found',
|
|
message: 'Failed to load image.'
|
|
},
|
|
{
|
|
type: 'key_missing',
|
|
message: 'The request did not include an api key.'
|
|
},
|
|
{
|
|
type: 'key_not_found',
|
|
message: 'The provided api key could not be found.'
|
|
},
|
|
{
|
|
type: 'domain_not_trusted',
|
|
message: 'The api key is not valid for the request origins.'
|
|
}
|
|
];
|
|
var traverseJson = function (json, path) {
|
|
var value = foldl(path, function (result, key) {
|
|
return isNonNullable(result) ? result[key] : undefined;
|
|
}, json);
|
|
return Optional.from(value);
|
|
};
|
|
var isServiceErrorCode = function (code, blob) {
|
|
return (blob === null || blob === void 0 ? void 0 : blob.type) === 'application/json' && (code === 400 || code === 403 || code === 404 || code === 500);
|
|
};
|
|
var getHttpErrorMsg = function (status) {
|
|
var message = find(friendlyHttpErrors, function (error) {
|
|
return status === error.code;
|
|
}).fold(constant('Unknown ImageProxy error'), function (error) {
|
|
return error.message;
|
|
});
|
|
return 'ImageProxy HTTP error: ' + message;
|
|
};
|
|
var handleHttpError = function (status) {
|
|
var message = getHttpErrorMsg(status);
|
|
return Promise$1.reject(message);
|
|
};
|
|
var getServiceErrorMsg = function (type) {
|
|
return find(friendlyServiceErrors, function (error) {
|
|
return error.type === type;
|
|
}).fold(constant('Unknown service error'), function (error) {
|
|
return error.message;
|
|
});
|
|
};
|
|
var getServiceError = function (text) {
|
|
var serviceError = parseJson(text);
|
|
var errorMsg = serviceError.bind(function (err) {
|
|
return traverseJson(err, [
|
|
'error',
|
|
'type'
|
|
]).map(getServiceErrorMsg);
|
|
}).getOr('Invalid JSON in service error message');
|
|
return 'ImageProxy Service error: ' + errorMsg;
|
|
};
|
|
var handleServiceError = function (blob) {
|
|
return readBlobText(blob).then(function (text) {
|
|
var serviceError = getServiceError(text);
|
|
return Promise$1.reject(serviceError);
|
|
});
|
|
};
|
|
var handleServiceErrorResponse = function (status, blob) {
|
|
return isServiceErrorCode(status, blob) ? handleServiceError(blob) : handleHttpError(status);
|
|
};
|
|
|
|
var appendApiKey = function (url, apiKey) {
|
|
var separator = url.indexOf('?') === -1 ? '?' : '&';
|
|
if (/[?&]apiKey=/.test(url)) {
|
|
return url;
|
|
} else {
|
|
return url + separator + 'apiKey=' + encodeURIComponent(apiKey);
|
|
}
|
|
};
|
|
var isError = function (status) {
|
|
return status < 200 || status >= 300;
|
|
};
|
|
var requestServiceBlob = function (url, apiKey) {
|
|
var headers = {
|
|
'Content-Type': 'application/json;charset=UTF-8',
|
|
'tiny-api-key': apiKey
|
|
};
|
|
return sendRequest(appendApiKey(url, apiKey), headers).then(function (result) {
|
|
return isError(result.status) ? handleServiceErrorResponse(result.status, result.blob) : Promise$1.resolve(result.blob);
|
|
});
|
|
};
|
|
var requestBlob = function (url, withCredentials) {
|
|
return sendRequest(url, {}, withCredentials).then(function (result) {
|
|
return isError(result.status) ? handleHttpError(result.status) : Promise$1.resolve(result.blob);
|
|
});
|
|
};
|
|
var getUrl = function (url, apiKey, withCredentials) {
|
|
if (withCredentials === void 0) {
|
|
withCredentials = false;
|
|
}
|
|
return apiKey ? requestServiceBlob(url, apiKey) : requestBlob(url, withCredentials);
|
|
};
|
|
|
|
var blobToImageResult = function (blob) {
|
|
return fromBlob(blob);
|
|
};
|
|
|
|
var ELEMENT = 1;
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var is = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var child$1 = function (scope, predicate) {
|
|
var pred = function (node) {
|
|
return predicate(SugarElement.fromDom(node));
|
|
};
|
|
var result = find(scope.dom.childNodes, pred);
|
|
return result.map(SugarElement.fromDom);
|
|
};
|
|
|
|
var child = function (scope, selector) {
|
|
return child$1(scope, function (e) {
|
|
return is(e, selector);
|
|
});
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
|
|
var getToolbarItems = function (editor) {
|
|
return editor.getParam('imagetools_toolbar', 'rotateleft rotateright flipv fliph editimage imageoptions');
|
|
};
|
|
var getProxyUrl = function (editor) {
|
|
return editor.getParam('imagetools_proxy');
|
|
};
|
|
var getCorsHosts = function (editor) {
|
|
return editor.getParam('imagetools_cors_hosts', [], 'string[]');
|
|
};
|
|
var getCredentialsHosts = function (editor) {
|
|
return editor.getParam('imagetools_credentials_hosts', [], 'string[]');
|
|
};
|
|
var getFetchImage = function (editor) {
|
|
return Optional.from(editor.getParam('imagetools_fetch_image', null, 'function'));
|
|
};
|
|
var getApiKey = function (editor) {
|
|
return editor.getParam('api_key', editor.getParam('imagetools_api_key', '', 'string'), 'string');
|
|
};
|
|
var getUploadTimeout = function (editor) {
|
|
return editor.getParam('images_upload_timeout', 30000, 'number');
|
|
};
|
|
var shouldReuseFilename = function (editor) {
|
|
return editor.getParam('images_reuse_filename', false, 'boolean');
|
|
};
|
|
|
|
var getImageSize = function (img) {
|
|
var width, height;
|
|
var isPxValue = function (value) {
|
|
return /^[0-9\.]+px$/.test(value);
|
|
};
|
|
width = img.style.width;
|
|
height = img.style.height;
|
|
if (width || height) {
|
|
if (isPxValue(width) && isPxValue(height)) {
|
|
return {
|
|
w: parseInt(width, 10),
|
|
h: parseInt(height, 10)
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
width = img.width;
|
|
height = img.height;
|
|
if (width && height) {
|
|
return {
|
|
w: parseInt(width, 10),
|
|
h: parseInt(height, 10)
|
|
};
|
|
}
|
|
return null;
|
|
};
|
|
var setImageSize = function (img, size) {
|
|
var width, height;
|
|
if (size) {
|
|
width = img.style.width;
|
|
height = img.style.height;
|
|
if (width || height) {
|
|
img.style.width = size.w + 'px';
|
|
img.style.height = size.h + 'px';
|
|
img.removeAttribute('data-mce-style');
|
|
}
|
|
width = img.width;
|
|
height = img.height;
|
|
if (width || height) {
|
|
img.setAttribute('width', String(size.w));
|
|
img.setAttribute('height', String(size.h));
|
|
}
|
|
}
|
|
};
|
|
var getNaturalImageSize = function (img) {
|
|
return {
|
|
w: img.naturalWidth,
|
|
h: img.naturalHeight
|
|
};
|
|
};
|
|
|
|
var count = 0;
|
|
var getFigureImg = function (elem) {
|
|
return child(SugarElement.fromDom(elem), 'img');
|
|
};
|
|
var isFigure = function (editor, elem) {
|
|
return editor.dom.is(elem, 'figure');
|
|
};
|
|
var isImage = function (editor, imgNode) {
|
|
return editor.dom.is(imgNode, 'img:not([data-mce-object],[data-mce-placeholder])');
|
|
};
|
|
var getEditableImage = function (editor, node) {
|
|
var isEditable = function (imgNode) {
|
|
return isImage(editor, imgNode) && (isLocalImage(editor, imgNode) || isCorsImage(editor, imgNode) || isNonNullable(getProxyUrl(editor)));
|
|
};
|
|
if (isFigure(editor, node)) {
|
|
return getFigureImg(node).bind(function (img) {
|
|
return isEditable(img.dom) ? Optional.some(img.dom) : Optional.none();
|
|
});
|
|
} else {
|
|
return isEditable(node) ? Optional.some(node) : Optional.none();
|
|
}
|
|
};
|
|
var displayError = function (editor, error) {
|
|
editor.notificationManager.open({
|
|
text: error,
|
|
type: 'error'
|
|
});
|
|
};
|
|
var getSelectedImage = function (editor) {
|
|
var elem = editor.selection.getNode();
|
|
var figureElm = editor.dom.getParent(elem, 'figure.image');
|
|
if (figureElm !== null && isFigure(editor, figureElm)) {
|
|
return getFigureImg(figureElm);
|
|
} else if (isImage(editor, elem)) {
|
|
return Optional.some(SugarElement.fromDom(elem));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var extractFilename = function (editor, url, group) {
|
|
var m = url.match(/(?:\/|^)(([^\/\?]+)\.(?:[a-z0-9.]+))(?:\?|$)/i);
|
|
return isNonNullable(m) ? editor.dom.encode(m[group]) : null;
|
|
};
|
|
var createId = function () {
|
|
return 'imagetools' + count++;
|
|
};
|
|
var isLocalImage = function (editor, img) {
|
|
var url = img.src;
|
|
return url.indexOf('data:') === 0 || url.indexOf('blob:') === 0 || new global$1(url).host === editor.documentBaseURI.host;
|
|
};
|
|
var isCorsImage = function (editor, img) {
|
|
return global$4.inArray(getCorsHosts(editor), new global$1(img.src).host) !== -1;
|
|
};
|
|
var isCorsWithCredentialsImage = function (editor, img) {
|
|
return global$4.inArray(getCredentialsHosts(editor), new global$1(img.src).host) !== -1;
|
|
};
|
|
var defaultFetchImage = function (editor, img) {
|
|
if (isCorsImage(editor, img)) {
|
|
return getUrl(img.src, null, isCorsWithCredentialsImage(editor, img));
|
|
}
|
|
if (!isLocalImage(editor, img)) {
|
|
var proxyUrl = getProxyUrl(editor);
|
|
var src = proxyUrl + (proxyUrl.indexOf('?') === -1 ? '?' : '&') + 'url=' + encodeURIComponent(img.src);
|
|
var apiKey = getApiKey(editor);
|
|
return getUrl(src, apiKey, false);
|
|
}
|
|
return imageToBlob$1(img);
|
|
};
|
|
var imageToBlob = function (editor, img) {
|
|
return getFetchImage(editor).fold(function () {
|
|
return defaultFetchImage(editor, img);
|
|
}, function (customFetchImage) {
|
|
return customFetchImage(img);
|
|
});
|
|
};
|
|
var findBlob = function (editor, img) {
|
|
var blobInfo = editor.editorUpload.blobCache.getByUri(img.src);
|
|
if (blobInfo) {
|
|
return global$2.resolve(blobInfo.blob());
|
|
}
|
|
return imageToBlob(editor, img);
|
|
};
|
|
var startTimedUpload = function (editor, imageUploadTimerState) {
|
|
var imageUploadTimer = global$3.setEditorTimeout(editor, function () {
|
|
editor.editorUpload.uploadImagesAuto();
|
|
}, getUploadTimeout(editor));
|
|
imageUploadTimerState.set(imageUploadTimer);
|
|
};
|
|
var cancelTimedUpload = function (imageUploadTimerState) {
|
|
global$3.clearTimeout(imageUploadTimerState.get());
|
|
};
|
|
var updateSelectedImage = function (editor, origBlob, ir, uploadImmediately, imageUploadTimerState, selectedImage, size) {
|
|
return ir.toBlob().then(function (blob) {
|
|
var uri, name, filename, blobInfo;
|
|
var blobCache = editor.editorUpload.blobCache;
|
|
uri = selectedImage.src;
|
|
var useFilename = origBlob.type === blob.type;
|
|
if (shouldReuseFilename(editor)) {
|
|
blobInfo = blobCache.getByUri(uri);
|
|
if (isNonNullable(blobInfo)) {
|
|
uri = blobInfo.uri();
|
|
name = blobInfo.name();
|
|
filename = blobInfo.filename();
|
|
} else {
|
|
name = extractFilename(editor, uri, 2);
|
|
filename = extractFilename(editor, uri, 1);
|
|
}
|
|
}
|
|
blobInfo = blobCache.create({
|
|
id: createId(),
|
|
blob: blob,
|
|
base64: ir.toBase64(),
|
|
uri: uri,
|
|
name: name,
|
|
filename: useFilename ? filename : undefined
|
|
});
|
|
blobCache.add(blobInfo);
|
|
editor.undoManager.transact(function () {
|
|
var imageLoadedHandler = function () {
|
|
editor.$(selectedImage).off('load', imageLoadedHandler);
|
|
editor.nodeChanged();
|
|
if (uploadImmediately) {
|
|
editor.editorUpload.uploadImagesAuto();
|
|
} else {
|
|
cancelTimedUpload(imageUploadTimerState);
|
|
startTimedUpload(editor, imageUploadTimerState);
|
|
}
|
|
};
|
|
editor.$(selectedImage).on('load', imageLoadedHandler);
|
|
if (size) {
|
|
editor.$(selectedImage).attr({
|
|
width: size.w,
|
|
height: size.h
|
|
});
|
|
}
|
|
editor.$(selectedImage).attr({ src: blobInfo.blobUri() }).removeAttr('data-mce-src');
|
|
});
|
|
return blobInfo;
|
|
});
|
|
};
|
|
var selectedImageOperation = function (editor, imageUploadTimerState, fn, size) {
|
|
return function () {
|
|
var imgOpt = getSelectedImage(editor);
|
|
return imgOpt.fold(function () {
|
|
displayError(editor, 'Could not find selected image');
|
|
}, function (img) {
|
|
return editor._scanForImages().then(function () {
|
|
return findBlob(editor, img.dom);
|
|
}).then(function (blob) {
|
|
return blobToImageResult(blob).then(fn).then(function (imageResult) {
|
|
return updateSelectedImage(editor, blob, imageResult, false, imageUploadTimerState, img.dom, size);
|
|
});
|
|
}).catch(function (error) {
|
|
displayError(editor, error);
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var rotate = function (editor, imageUploadTimerState, angle) {
|
|
return function () {
|
|
var imgOpt = getSelectedImage(editor);
|
|
var flippedSize = imgOpt.map(function (img) {
|
|
var size = getImageSize(img.dom);
|
|
return size ? {
|
|
w: size.h,
|
|
h: size.w
|
|
} : null;
|
|
}).getOrNull();
|
|
return selectedImageOperation(editor, imageUploadTimerState, function (imageResult) {
|
|
return rotate$1(imageResult, angle);
|
|
}, flippedSize)();
|
|
};
|
|
};
|
|
var flip = function (editor, imageUploadTimerState, axis) {
|
|
return function () {
|
|
return selectedImageOperation(editor, imageUploadTimerState, function (imageResult) {
|
|
return flip$1(imageResult, axis);
|
|
})();
|
|
};
|
|
};
|
|
var handleDialogBlob = function (editor, imageUploadTimerState, img, originalSize, blob) {
|
|
return blobToImage(blob).then(function (newImage) {
|
|
var newSize = getNaturalImageSize(newImage);
|
|
if (originalSize.w !== newSize.w || originalSize.h !== newSize.h) {
|
|
if (getImageSize(img)) {
|
|
setImageSize(img, newSize);
|
|
}
|
|
}
|
|
URL.revokeObjectURL(newImage.src);
|
|
return blob;
|
|
}).then(blobToImageResult).then(function (imageResult) {
|
|
return updateSelectedImage(editor, blob, imageResult, true, imageUploadTimerState, img);
|
|
});
|
|
};
|
|
|
|
var saveState = 'save-state';
|
|
var disable = 'disable';
|
|
var enable = 'enable';
|
|
|
|
var createState = function (blob) {
|
|
return {
|
|
blob: blob,
|
|
url: URL.createObjectURL(blob)
|
|
};
|
|
};
|
|
var makeOpen = function (editor, imageUploadTimerState) {
|
|
return function () {
|
|
var getLoadedSpec = function (currentState) {
|
|
return {
|
|
title: 'Edit Image',
|
|
size: 'large',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'imagetools',
|
|
name: 'imagetools',
|
|
label: 'Edit Image',
|
|
currentState: currentState
|
|
}]
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true,
|
|
disabled: true
|
|
}
|
|
],
|
|
onSubmit: function (api) {
|
|
var blob = api.getData().imagetools.blob;
|
|
originalImgOpt.each(function (originalImg) {
|
|
originalSizeOpt.each(function (originalSize) {
|
|
handleDialogBlob(editor, imageUploadTimerState, originalImg.dom, originalSize, blob);
|
|
});
|
|
});
|
|
api.close();
|
|
},
|
|
onCancel: noop,
|
|
onAction: function (api, details) {
|
|
switch (details.name) {
|
|
case saveState:
|
|
if (details.value) {
|
|
api.enable('save');
|
|
} else {
|
|
api.disable('save');
|
|
}
|
|
break;
|
|
case disable:
|
|
api.disable('save');
|
|
api.disable('cancel');
|
|
break;
|
|
case enable:
|
|
api.enable('cancel');
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
var originalImgOpt = getSelectedImage(editor);
|
|
var originalSizeOpt = originalImgOpt.map(function (origImg) {
|
|
return getNaturalImageSize(origImg.dom);
|
|
});
|
|
originalImgOpt.each(function (img) {
|
|
getEditableImage(editor, img.dom).each(function (_) {
|
|
findBlob(editor, img.dom).then(function (blob) {
|
|
var state = createState(blob);
|
|
editor.windowManager.open(getLoadedSpec(state));
|
|
});
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
var register$2 = function (editor, imageUploadTimerState) {
|
|
global$4.each({
|
|
mceImageRotateLeft: rotate(editor, imageUploadTimerState, -90),
|
|
mceImageRotateRight: rotate(editor, imageUploadTimerState, 90),
|
|
mceImageFlipVertical: flip(editor, imageUploadTimerState, 'v'),
|
|
mceImageFlipHorizontal: flip(editor, imageUploadTimerState, 'h'),
|
|
mceEditImage: makeOpen(editor, imageUploadTimerState)
|
|
}, function (fn, cmd) {
|
|
editor.addCommand(cmd, fn);
|
|
});
|
|
};
|
|
|
|
var setup = function (editor, imageUploadTimerState, lastSelectedImageState) {
|
|
editor.on('NodeChange', function (e) {
|
|
var lastSelectedImage = lastSelectedImageState.get();
|
|
var selectedImage = getEditableImage(editor, e.element);
|
|
if (lastSelectedImage && !selectedImage.exists(function (img) {
|
|
return lastSelectedImage.src === img.src;
|
|
})) {
|
|
cancelTimedUpload(imageUploadTimerState);
|
|
editor.editorUpload.uploadImagesAuto();
|
|
lastSelectedImageState.set(null);
|
|
}
|
|
selectedImage.each(lastSelectedImageState.set);
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
var changeHandlers = [];
|
|
var cmd = function (command) {
|
|
return function () {
|
|
return editor.execCommand(command);
|
|
};
|
|
};
|
|
var isEditableImage = function () {
|
|
return getSelectedImage(editor).exists(function (element) {
|
|
return getEditableImage(editor, element.dom).isSome();
|
|
});
|
|
};
|
|
var onSetup = function (api) {
|
|
var handler = function (isEditableImage) {
|
|
return api.setDisabled(!isEditableImage);
|
|
};
|
|
handler(isEditableImage());
|
|
changeHandlers = changeHandlers.concat([handler]);
|
|
return function () {
|
|
changeHandlers = filter(changeHandlers, function (h) {
|
|
return h !== handler;
|
|
});
|
|
};
|
|
};
|
|
editor.on('NodeChange', function () {
|
|
var isEditable = isEditableImage();
|
|
each$1(changeHandlers, function (handler) {
|
|
return handler(isEditable);
|
|
});
|
|
});
|
|
editor.ui.registry.addButton('rotateleft', {
|
|
tooltip: 'Rotate counterclockwise',
|
|
icon: 'rotate-left',
|
|
onAction: cmd('mceImageRotateLeft'),
|
|
onSetup: onSetup
|
|
});
|
|
editor.ui.registry.addButton('rotateright', {
|
|
tooltip: 'Rotate clockwise',
|
|
icon: 'rotate-right',
|
|
onAction: cmd('mceImageRotateRight'),
|
|
onSetup: onSetup
|
|
});
|
|
editor.ui.registry.addButton('flipv', {
|
|
tooltip: 'Flip vertically',
|
|
icon: 'flip-vertically',
|
|
onAction: cmd('mceImageFlipVertical'),
|
|
onSetup: onSetup
|
|
});
|
|
editor.ui.registry.addButton('fliph', {
|
|
tooltip: 'Flip horizontally',
|
|
icon: 'flip-horizontally',
|
|
onAction: cmd('mceImageFlipHorizontal'),
|
|
onSetup: onSetup
|
|
});
|
|
editor.ui.registry.addButton('editimage', {
|
|
tooltip: 'Edit image',
|
|
icon: 'edit-image',
|
|
onAction: cmd('mceEditImage'),
|
|
onSetup: onSetup
|
|
});
|
|
editor.ui.registry.addButton('imageoptions', {
|
|
tooltip: 'Image options',
|
|
icon: 'image',
|
|
onAction: cmd('mceImage')
|
|
});
|
|
editor.ui.registry.addContextMenu('imagetools', {
|
|
update: function (element) {
|
|
return getEditableImage(editor, element).map(function (_) {
|
|
return {
|
|
text: 'Edit image',
|
|
icon: 'edit-image',
|
|
onAction: cmd('mceEditImage')
|
|
};
|
|
}).toArray();
|
|
}
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
editor.ui.registry.addContextToolbar('imagetools', {
|
|
items: getToolbarItems(editor),
|
|
predicate: function (elem) {
|
|
return getEditableImage(editor, elem).isSome();
|
|
},
|
|
position: 'node',
|
|
scope: 'node'
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$5.add('imagetools', function (editor) {
|
|
var imageUploadTimerState = Cell(0);
|
|
var lastSelectedImageState = Cell(null);
|
|
register$2(editor, imageUploadTimerState);
|
|
register$1(editor);
|
|
register(editor);
|
|
setup(editor, imageUploadTimerState, lastSelectedImageState);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isString = isType('string');
|
|
var isArray = isType('array');
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var shouldMergeClasses = function (editor) {
|
|
return editor.getParam('importcss_merge_classes');
|
|
};
|
|
var shouldImportExclusive = function (editor) {
|
|
return editor.getParam('importcss_exclusive');
|
|
};
|
|
var getSelectorConverter = function (editor) {
|
|
return editor.getParam('importcss_selector_converter');
|
|
};
|
|
var getSelectorFilter = function (editor) {
|
|
return editor.getParam('importcss_selector_filter');
|
|
};
|
|
var getCssGroups = function (editor) {
|
|
return editor.getParam('importcss_groups');
|
|
};
|
|
var shouldAppend = function (editor) {
|
|
return editor.getParam('importcss_append');
|
|
};
|
|
var getFileFilter = function (editor) {
|
|
return editor.getParam('importcss_file_filter');
|
|
};
|
|
var getSkin = function (editor) {
|
|
var skin = editor.getParam('skin');
|
|
return skin !== false ? skin || 'oxide' : false;
|
|
};
|
|
var getSkinUrl = function (editor) {
|
|
return editor.getParam('skin_url');
|
|
};
|
|
|
|
var nativePush = Array.prototype.push;
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind = function (xs, f) {
|
|
return flatten(map(xs, f));
|
|
};
|
|
|
|
var generate = function () {
|
|
var ungroupedOrder = [];
|
|
var groupOrder = [];
|
|
var groups = {};
|
|
var addItemToGroup = function (groupTitle, itemInfo) {
|
|
if (groups[groupTitle]) {
|
|
groups[groupTitle].push(itemInfo);
|
|
} else {
|
|
groupOrder.push(groupTitle);
|
|
groups[groupTitle] = [itemInfo];
|
|
}
|
|
};
|
|
var addItem = function (itemInfo) {
|
|
ungroupedOrder.push(itemInfo);
|
|
};
|
|
var toFormats = function () {
|
|
var groupItems = bind(groupOrder, function (g) {
|
|
var items = groups[g];
|
|
return items.length === 0 ? [] : [{
|
|
title: g,
|
|
items: items
|
|
}];
|
|
});
|
|
return groupItems.concat(ungroupedOrder);
|
|
};
|
|
return {
|
|
addItemToGroup: addItemToGroup,
|
|
addItem: addItem,
|
|
toFormats: toFormats
|
|
};
|
|
};
|
|
|
|
var internalEditorStyle = /^\.(?:ephox|tiny-pageembed|mce)(?:[.-]+\w+)+$/;
|
|
var removeCacheSuffix = function (url) {
|
|
var cacheSuffix = global$1.cacheSuffix;
|
|
if (isString(url)) {
|
|
url = url.replace('?' + cacheSuffix, '').replace('&' + cacheSuffix, '');
|
|
}
|
|
return url;
|
|
};
|
|
var isSkinContentCss = function (editor, href) {
|
|
var skin = getSkin(editor);
|
|
if (skin) {
|
|
var skinUrlBase = getSkinUrl(editor);
|
|
var skinUrl = skinUrlBase ? editor.documentBaseURI.toAbsolute(skinUrlBase) : global$2.baseURL + '/skins/ui/' + skin;
|
|
var contentSkinUrlPart = global$2.baseURL + '/skins/content/';
|
|
return href === skinUrl + '/content' + (editor.inline ? '.inline' : '') + '.min.css' || href.indexOf(contentSkinUrlPart) !== -1;
|
|
}
|
|
return false;
|
|
};
|
|
var compileFilter = function (filter) {
|
|
if (isString(filter)) {
|
|
return function (value) {
|
|
return value.indexOf(filter) !== -1;
|
|
};
|
|
} else if (filter instanceof RegExp) {
|
|
return function (value) {
|
|
return filter.test(value);
|
|
};
|
|
}
|
|
return filter;
|
|
};
|
|
var isCssImportRule = function (rule) {
|
|
return rule.styleSheet;
|
|
};
|
|
var isCssPageRule = function (rule) {
|
|
return rule.selectorText;
|
|
};
|
|
var getSelectors = function (editor, doc, fileFilter) {
|
|
var selectors = [];
|
|
var contentCSSUrls = {};
|
|
var append = function (styleSheet, imported) {
|
|
var href = styleSheet.href, rules;
|
|
href = removeCacheSuffix(href);
|
|
if (!href || !fileFilter(href, imported) || isSkinContentCss(editor, href)) {
|
|
return;
|
|
}
|
|
global.each(styleSheet.imports, function (styleSheet) {
|
|
append(styleSheet, true);
|
|
});
|
|
try {
|
|
rules = styleSheet.cssRules || styleSheet.rules;
|
|
} catch (e) {
|
|
}
|
|
global.each(rules, function (cssRule) {
|
|
if (isCssImportRule(cssRule)) {
|
|
append(cssRule.styleSheet, true);
|
|
} else if (isCssPageRule(cssRule)) {
|
|
global.each(cssRule.selectorText.split(','), function (selector) {
|
|
selectors.push(global.trim(selector));
|
|
});
|
|
}
|
|
});
|
|
};
|
|
global.each(editor.contentCSS, function (url) {
|
|
contentCSSUrls[url] = true;
|
|
});
|
|
if (!fileFilter) {
|
|
fileFilter = function (href, imported) {
|
|
return imported || contentCSSUrls[href];
|
|
};
|
|
}
|
|
try {
|
|
global.each(doc.styleSheets, function (styleSheet) {
|
|
append(styleSheet);
|
|
});
|
|
} catch (e) {
|
|
}
|
|
return selectors;
|
|
};
|
|
var defaultConvertSelectorToFormat = function (editor, selectorText) {
|
|
var format;
|
|
var selector = /^(?:([a-z0-9\-_]+))?(\.[a-z0-9_\-\.]+)$/i.exec(selectorText);
|
|
if (!selector) {
|
|
return;
|
|
}
|
|
var elementName = selector[1];
|
|
var classes = selector[2].substr(1).split('.').join(' ');
|
|
var inlineSelectorElements = global.makeMap('a,img');
|
|
if (selector[1]) {
|
|
format = { title: selectorText };
|
|
if (editor.schema.getTextBlockElements()[elementName]) {
|
|
format.block = elementName;
|
|
} else if (editor.schema.getBlockElements()[elementName] || inlineSelectorElements[elementName.toLowerCase()]) {
|
|
format.selector = elementName;
|
|
} else {
|
|
format.inline = elementName;
|
|
}
|
|
} else if (selector[2]) {
|
|
format = {
|
|
inline: 'span',
|
|
title: selectorText.substr(1),
|
|
classes: classes
|
|
};
|
|
}
|
|
if (shouldMergeClasses(editor) !== false) {
|
|
format.classes = classes;
|
|
} else {
|
|
format.attributes = { class: classes };
|
|
}
|
|
return format;
|
|
};
|
|
var getGroupsBySelector = function (groups, selector) {
|
|
return global.grep(groups, function (group) {
|
|
return !group.filter || group.filter(selector);
|
|
});
|
|
};
|
|
var compileUserDefinedGroups = function (groups) {
|
|
return global.map(groups, function (group) {
|
|
return global.extend({}, group, {
|
|
original: group,
|
|
selectors: {},
|
|
filter: compileFilter(group.filter)
|
|
});
|
|
});
|
|
};
|
|
var isExclusiveMode = function (editor, group) {
|
|
return group === null || shouldImportExclusive(editor) !== false;
|
|
};
|
|
var isUniqueSelector = function (editor, selector, group, globallyUniqueSelectors) {
|
|
return !(isExclusiveMode(editor, group) ? selector in globallyUniqueSelectors : selector in group.selectors);
|
|
};
|
|
var markUniqueSelector = function (editor, selector, group, globallyUniqueSelectors) {
|
|
if (isExclusiveMode(editor, group)) {
|
|
globallyUniqueSelectors[selector] = true;
|
|
} else {
|
|
group.selectors[selector] = true;
|
|
}
|
|
};
|
|
var convertSelectorToFormat = function (editor, plugin, selector, group) {
|
|
var selectorConverter;
|
|
if (group && group.selector_converter) {
|
|
selectorConverter = group.selector_converter;
|
|
} else if (getSelectorConverter(editor)) {
|
|
selectorConverter = getSelectorConverter(editor);
|
|
} else {
|
|
selectorConverter = function () {
|
|
return defaultConvertSelectorToFormat(editor, selector);
|
|
};
|
|
}
|
|
return selectorConverter.call(plugin, selector, group);
|
|
};
|
|
var setup = function (editor) {
|
|
editor.on('init', function () {
|
|
var model = generate();
|
|
var globallyUniqueSelectors = {};
|
|
var selectorFilter = compileFilter(getSelectorFilter(editor));
|
|
var groups = compileUserDefinedGroups(getCssGroups(editor));
|
|
var processSelector = function (selector, group) {
|
|
if (isUniqueSelector(editor, selector, group, globallyUniqueSelectors)) {
|
|
markUniqueSelector(editor, selector, group, globallyUniqueSelectors);
|
|
var format = convertSelectorToFormat(editor, editor.plugins.importcss, selector, group);
|
|
if (format) {
|
|
var formatName = format.name || global$3.DOM.uniqueId();
|
|
editor.formatter.register(formatName, format);
|
|
return {
|
|
title: format.title,
|
|
format: formatName
|
|
};
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
global.each(getSelectors(editor, editor.getDoc(), compileFilter(getFileFilter(editor))), function (selector) {
|
|
if (!internalEditorStyle.test(selector)) {
|
|
if (!selectorFilter || selectorFilter(selector)) {
|
|
var selectorGroups = getGroupsBySelector(groups, selector);
|
|
if (selectorGroups.length > 0) {
|
|
global.each(selectorGroups, function (group) {
|
|
var menuItem = processSelector(selector, group);
|
|
if (menuItem) {
|
|
model.addItemToGroup(group.title, menuItem);
|
|
}
|
|
});
|
|
} else {
|
|
var menuItem = processSelector(selector, null);
|
|
if (menuItem) {
|
|
model.addItem(menuItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
var items = model.toFormats();
|
|
editor.fire('addStyleModifications', {
|
|
items: items,
|
|
replace: !shouldAppend(editor)
|
|
});
|
|
});
|
|
};
|
|
|
|
var get = function (editor) {
|
|
var convertSelectorToFormat = function (selectorText) {
|
|
return defaultConvertSelectorToFormat(editor, selectorText);
|
|
};
|
|
return { convertSelectorToFormat: convertSelectorToFormat };
|
|
};
|
|
|
|
function Plugin () {
|
|
global$4.add('importcss', function (editor) {
|
|
setup(editor);
|
|
return get(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var getDateFormat = function (editor) {
|
|
return editor.getParam('insertdatetime_dateformat', editor.translate('%Y-%m-%d'));
|
|
};
|
|
var getTimeFormat = function (editor) {
|
|
return editor.getParam('insertdatetime_timeformat', editor.translate('%H:%M:%S'));
|
|
};
|
|
var getFormats = function (editor) {
|
|
return editor.getParam('insertdatetime_formats', [
|
|
'%H:%M:%S',
|
|
'%Y-%m-%d',
|
|
'%I:%M:%S %p',
|
|
'%D'
|
|
]);
|
|
};
|
|
var getDefaultDateTime = function (editor) {
|
|
var formats = getFormats(editor);
|
|
return formats.length > 0 ? formats[0] : getTimeFormat(editor);
|
|
};
|
|
var shouldInsertTimeElement = function (editor) {
|
|
return editor.getParam('insertdatetime_element', false);
|
|
};
|
|
|
|
var daysShort = 'Sun Mon Tue Wed Thu Fri Sat Sun'.split(' ');
|
|
var daysLong = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday'.split(' ');
|
|
var monthsShort = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
|
|
var monthsLong = 'January February March April May June July August September October November December'.split(' ');
|
|
var addZeros = function (value, len) {
|
|
value = '' + value;
|
|
if (value.length < len) {
|
|
for (var i = 0; i < len - value.length; i++) {
|
|
value = '0' + value;
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
var getDateTime = function (editor, fmt, date) {
|
|
if (date === void 0) {
|
|
date = new Date();
|
|
}
|
|
fmt = fmt.replace('%D', '%m/%d/%Y');
|
|
fmt = fmt.replace('%r', '%I:%M:%S %p');
|
|
fmt = fmt.replace('%Y', '' + date.getFullYear());
|
|
fmt = fmt.replace('%y', '' + date.getYear());
|
|
fmt = fmt.replace('%m', addZeros(date.getMonth() + 1, 2));
|
|
fmt = fmt.replace('%d', addZeros(date.getDate(), 2));
|
|
fmt = fmt.replace('%H', '' + addZeros(date.getHours(), 2));
|
|
fmt = fmt.replace('%M', '' + addZeros(date.getMinutes(), 2));
|
|
fmt = fmt.replace('%S', '' + addZeros(date.getSeconds(), 2));
|
|
fmt = fmt.replace('%I', '' + ((date.getHours() + 11) % 12 + 1));
|
|
fmt = fmt.replace('%p', '' + (date.getHours() < 12 ? 'AM' : 'PM'));
|
|
fmt = fmt.replace('%B', '' + editor.translate(monthsLong[date.getMonth()]));
|
|
fmt = fmt.replace('%b', '' + editor.translate(monthsShort[date.getMonth()]));
|
|
fmt = fmt.replace('%A', '' + editor.translate(daysLong[date.getDay()]));
|
|
fmt = fmt.replace('%a', '' + editor.translate(daysShort[date.getDay()]));
|
|
fmt = fmt.replace('%%', '%');
|
|
return fmt;
|
|
};
|
|
var updateElement = function (editor, timeElm, computerTime, userTime) {
|
|
var newTimeElm = editor.dom.create('time', { datetime: computerTime }, userTime);
|
|
timeElm.parentNode.insertBefore(newTimeElm, timeElm);
|
|
editor.dom.remove(timeElm);
|
|
editor.selection.select(newTimeElm, true);
|
|
editor.selection.collapse(false);
|
|
};
|
|
var insertDateTime = function (editor, format) {
|
|
if (shouldInsertTimeElement(editor)) {
|
|
var userTime = getDateTime(editor, format);
|
|
var computerTime = void 0;
|
|
if (/%[HMSIp]/.test(format)) {
|
|
computerTime = getDateTime(editor, '%Y-%m-%dT%H:%M');
|
|
} else {
|
|
computerTime = getDateTime(editor, '%Y-%m-%d');
|
|
}
|
|
var timeElm = editor.dom.getParent(editor.selection.getStart(), 'time');
|
|
if (timeElm) {
|
|
updateElement(editor, timeElm, computerTime, userTime);
|
|
} else {
|
|
editor.insertContent('<time datetime="' + computerTime + '">' + userTime + '</time>');
|
|
}
|
|
} else {
|
|
editor.insertContent(getDateTime(editor, format));
|
|
}
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceInsertDate', function (_ui, value) {
|
|
insertDateTime(editor, value !== null && value !== void 0 ? value : getDateFormat(editor));
|
|
});
|
|
editor.addCommand('mceInsertTime', function (_ui, value) {
|
|
insertDateTime(editor, value !== null && value !== void 0 ? value : getTimeFormat(editor));
|
|
});
|
|
};
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var register = function (editor) {
|
|
var formats = getFormats(editor);
|
|
var defaultFormat = Cell(getDefaultDateTime(editor));
|
|
var insertDateTime = function (format) {
|
|
return editor.execCommand('mceInsertDate', false, format);
|
|
};
|
|
editor.ui.registry.addSplitButton('insertdatetime', {
|
|
icon: 'insert-time',
|
|
tooltip: 'Insert date/time',
|
|
select: function (value) {
|
|
return value === defaultFormat.get();
|
|
},
|
|
fetch: function (done) {
|
|
done(global.map(formats, function (format) {
|
|
return {
|
|
type: 'choiceitem',
|
|
text: getDateTime(editor, format),
|
|
value: format
|
|
};
|
|
}));
|
|
},
|
|
onAction: function (_api) {
|
|
insertDateTime(defaultFormat.get());
|
|
},
|
|
onItemAction: function (_api, value) {
|
|
defaultFormat.set(value);
|
|
insertDateTime(value);
|
|
}
|
|
});
|
|
var makeMenuItemHandler = function (format) {
|
|
return function () {
|
|
defaultFormat.set(format);
|
|
insertDateTime(format);
|
|
};
|
|
};
|
|
editor.ui.registry.addNestedMenuItem('insertdatetime', {
|
|
icon: 'insert-time',
|
|
text: 'Date/time',
|
|
getSubmenuItems: function () {
|
|
return global.map(formats, function (format) {
|
|
return {
|
|
type: 'menuitem',
|
|
text: getDateTime(editor, format),
|
|
onAction: makeMenuItemHandler(format)
|
|
};
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('insertdatetime', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getFontSizeFormats = function (editor) {
|
|
return editor.getParam('fontsize_formats');
|
|
};
|
|
var setFontSizeFormats = function (editor, fontsize_formats) {
|
|
editor.settings.fontsize_formats = fontsize_formats;
|
|
};
|
|
var getFontFormats = function (editor) {
|
|
return editor.getParam('font_formats');
|
|
};
|
|
var setFontFormats = function (editor, font_formats) {
|
|
editor.settings.font_formats = font_formats;
|
|
};
|
|
var getFontSizeStyleValues = function (editor) {
|
|
return editor.getParam('font_size_style_values', 'xx-small,x-small,small,medium,large,x-large,xx-large');
|
|
};
|
|
var setInlineStyles = function (editor, inline_styles) {
|
|
editor.settings.inline_styles = inline_styles;
|
|
};
|
|
|
|
var overrideFormats = function (editor) {
|
|
var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table', fontSizes = global.explode(getFontSizeStyleValues(editor)), schema = editor.schema;
|
|
editor.formatter.register({
|
|
alignleft: {
|
|
selector: alignElements,
|
|
attributes: { align: 'left' }
|
|
},
|
|
aligncenter: {
|
|
selector: alignElements,
|
|
attributes: { align: 'center' }
|
|
},
|
|
alignright: {
|
|
selector: alignElements,
|
|
attributes: { align: 'right' }
|
|
},
|
|
alignjustify: {
|
|
selector: alignElements,
|
|
attributes: { align: 'justify' }
|
|
},
|
|
bold: [
|
|
{
|
|
inline: 'b',
|
|
remove: 'all',
|
|
preserve_attributes: [
|
|
'class',
|
|
'style'
|
|
]
|
|
},
|
|
{
|
|
inline: 'strong',
|
|
remove: 'all',
|
|
preserve_attributes: [
|
|
'class',
|
|
'style'
|
|
]
|
|
},
|
|
{
|
|
inline: 'span',
|
|
styles: { fontWeight: 'bold' }
|
|
}
|
|
],
|
|
italic: [
|
|
{
|
|
inline: 'i',
|
|
remove: 'all',
|
|
preserve_attributes: [
|
|
'class',
|
|
'style'
|
|
]
|
|
},
|
|
{
|
|
inline: 'em',
|
|
remove: 'all',
|
|
preserve_attributes: [
|
|
'class',
|
|
'style'
|
|
]
|
|
},
|
|
{
|
|
inline: 'span',
|
|
styles: { fontStyle: 'italic' }
|
|
}
|
|
],
|
|
underline: [
|
|
{
|
|
inline: 'u',
|
|
remove: 'all',
|
|
preserve_attributes: [
|
|
'class',
|
|
'style'
|
|
]
|
|
},
|
|
{
|
|
inline: 'span',
|
|
styles: { textDecoration: 'underline' },
|
|
exact: true
|
|
}
|
|
],
|
|
strikethrough: [
|
|
{
|
|
inline: 'strike',
|
|
remove: 'all',
|
|
preserve_attributes: [
|
|
'class',
|
|
'style'
|
|
]
|
|
},
|
|
{
|
|
inline: 'span',
|
|
styles: { textDecoration: 'line-through' },
|
|
exact: true
|
|
}
|
|
],
|
|
fontname: {
|
|
inline: 'font',
|
|
toggle: false,
|
|
attributes: { face: '%value' }
|
|
},
|
|
fontsize: {
|
|
inline: 'font',
|
|
toggle: false,
|
|
attributes: {
|
|
size: function (vars) {
|
|
return String(global.inArray(fontSizes, vars.value) + 1);
|
|
}
|
|
}
|
|
},
|
|
forecolor: {
|
|
inline: 'font',
|
|
attributes: { color: '%value' },
|
|
links: true,
|
|
remove_similar: true,
|
|
clear_child_styles: true
|
|
},
|
|
hilitecolor: {
|
|
inline: 'font',
|
|
styles: { backgroundColor: '%value' },
|
|
links: true,
|
|
remove_similar: true,
|
|
clear_child_styles: true
|
|
}
|
|
});
|
|
global.each('b,i,u,strike'.split(','), function (name) {
|
|
schema.addValidElements(name + '[*]');
|
|
});
|
|
if (!schema.getElementRule('font')) {
|
|
schema.addValidElements('font[face|size|color|style]');
|
|
}
|
|
global.each(alignElements.split(','), function (name) {
|
|
var rule = schema.getElementRule(name);
|
|
if (rule) {
|
|
if (!rule.attributes.align) {
|
|
rule.attributes.align = {};
|
|
rule.attributesOrder.push('align');
|
|
}
|
|
}
|
|
});
|
|
};
|
|
var overrideSettings = function (editor) {
|
|
var defaultFontsizeFormats = '8pt=1 10pt=2 12pt=3 14pt=4 18pt=5 24pt=6 36pt=7';
|
|
var defaultFontsFormats = 'Andale Mono=andale mono,monospace;' + 'Arial=arial,helvetica,sans-serif;' + 'Arial Black=arial black,sans-serif;' + 'Book Antiqua=book antiqua,palatino,serif;' + 'Comic Sans MS=comic sans ms,sans-serif;' + 'Courier New=courier new,courier,monospace;' + 'Georgia=georgia,palatino,serif;' + 'Helvetica=helvetica,arial,sans-serif;' + 'Impact=impact,sans-serif;' + 'Symbol=symbol;' + 'Tahoma=tahoma,arial,helvetica,sans-serif;' + 'Terminal=terminal,monaco,monospace;' + 'Times New Roman=times new roman,times,serif;' + 'Trebuchet MS=trebuchet ms,geneva,sans-serif;' + 'Verdana=verdana,geneva,sans-serif;' + 'Webdings=webdings;' + 'Wingdings=wingdings,zapf dingbats';
|
|
setInlineStyles(editor, false);
|
|
if (!getFontSizeFormats(editor)) {
|
|
setFontSizeFormats(editor, defaultFontsizeFormats);
|
|
}
|
|
if (!getFontFormats(editor)) {
|
|
setFontFormats(editor, defaultFontsFormats);
|
|
}
|
|
};
|
|
var setup = function (editor) {
|
|
overrideSettings(editor);
|
|
editor.on('PreInit', function () {
|
|
return overrideFormats(editor);
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('legacyoutput', function (editor) {
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$7 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var eq = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isString = isType('string');
|
|
var isArray = isType('array');
|
|
var isNull = eq(null);
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isFunction = isSimpleType('function');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var tripleEquals = function (a, b) {
|
|
return a === b;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var nativeIndexOf = Array.prototype.indexOf;
|
|
var nativePush = Array.prototype.push;
|
|
var rawIndexOf = function (ts, t) {
|
|
return nativeIndexOf.call(ts, t);
|
|
};
|
|
var contains = function (xs, x) {
|
|
return rawIndexOf(xs, x) > -1;
|
|
};
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each$1(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind = function (xs, f) {
|
|
return flatten(map(xs, f));
|
|
};
|
|
var findMap = function (arr, f) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var r = f(arr[i], i);
|
|
if (r.isSome()) {
|
|
return r;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var is = function (lhs, rhs, comparator) {
|
|
if (comparator === void 0) {
|
|
comparator = tripleEquals;
|
|
}
|
|
return lhs.exists(function (left) {
|
|
return comparator(left, rhs);
|
|
});
|
|
};
|
|
var cat = function (arr) {
|
|
var r = [];
|
|
var push = function (x) {
|
|
r.push(x);
|
|
};
|
|
for (var i = 0; i < arr.length; i++) {
|
|
arr[i].each(push);
|
|
}
|
|
return r;
|
|
};
|
|
var someIf = function (b, a) {
|
|
return b ? Optional.some(a) : Optional.none();
|
|
};
|
|
|
|
var assumeExternalTargets = function (editor) {
|
|
var externalTargets = editor.getParam('link_assume_external_targets', false);
|
|
if (isBoolean(externalTargets) && externalTargets) {
|
|
return 1;
|
|
} else if (isString(externalTargets) && (externalTargets === 'http' || externalTargets === 'https')) {
|
|
return externalTargets;
|
|
}
|
|
return 0;
|
|
};
|
|
var hasContextToolbar = function (editor) {
|
|
return editor.getParam('link_context_toolbar', false, 'boolean');
|
|
};
|
|
var getLinkList = function (editor) {
|
|
return editor.getParam('link_list');
|
|
};
|
|
var getDefaultLinkTarget = function (editor) {
|
|
return editor.getParam('default_link_target');
|
|
};
|
|
var getTargetList = function (editor) {
|
|
return editor.getParam('target_list', true);
|
|
};
|
|
var getRelList = function (editor) {
|
|
return editor.getParam('rel_list', [], 'array');
|
|
};
|
|
var getLinkClassList = function (editor) {
|
|
return editor.getParam('link_class_list', [], 'array');
|
|
};
|
|
var shouldShowLinkTitle = function (editor) {
|
|
return editor.getParam('link_title', true, 'boolean');
|
|
};
|
|
var allowUnsafeLinkTarget = function (editor) {
|
|
return editor.getParam('allow_unsafe_link_target', false, 'boolean');
|
|
};
|
|
var useQuickLink = function (editor) {
|
|
return editor.getParam('link_quicklink', false, 'boolean');
|
|
};
|
|
var getDefaultLinkProtocol = function (editor) {
|
|
return editor.getParam('link_default_protocol', 'http', 'string');
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getValue = function (item) {
|
|
return isString(item.value) ? item.value : '';
|
|
};
|
|
var getText = function (item) {
|
|
if (isString(item.text)) {
|
|
return item.text;
|
|
} else if (isString(item.title)) {
|
|
return item.title;
|
|
} else {
|
|
return '';
|
|
}
|
|
};
|
|
var sanitizeList = function (list, extractValue) {
|
|
var out = [];
|
|
global$5.each(list, function (item) {
|
|
var text = getText(item);
|
|
if (item.menu !== undefined) {
|
|
var items = sanitizeList(item.menu, extractValue);
|
|
out.push({
|
|
text: text,
|
|
items: items
|
|
});
|
|
} else {
|
|
var value = extractValue(item);
|
|
out.push({
|
|
text: text,
|
|
value: value
|
|
});
|
|
}
|
|
});
|
|
return out;
|
|
};
|
|
var sanitizeWith = function (extracter) {
|
|
if (extracter === void 0) {
|
|
extracter = getValue;
|
|
}
|
|
return function (list) {
|
|
return Optional.from(list).map(function (list) {
|
|
return sanitizeList(list, extracter);
|
|
});
|
|
};
|
|
};
|
|
var sanitize = function (list) {
|
|
return sanitizeWith(getValue)(list);
|
|
};
|
|
var createUi = function (name, label) {
|
|
return function (items) {
|
|
return {
|
|
name: name,
|
|
type: 'listbox',
|
|
label: label,
|
|
items: items
|
|
};
|
|
};
|
|
};
|
|
var ListOptions = {
|
|
sanitize: sanitize,
|
|
sanitizeWith: sanitizeWith,
|
|
createUi: createUi,
|
|
getValue: getValue
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var objAcc = function (r) {
|
|
return function (x, i) {
|
|
r[i] = x;
|
|
};
|
|
};
|
|
var internalFilter = function (obj, pred, onTrue, onFalse) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
});
|
|
return r;
|
|
};
|
|
var filter = function (obj, pred) {
|
|
var t = {};
|
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
return t;
|
|
};
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
var hasNonNullableKey = function (obj, key) {
|
|
return has(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
};
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
|
|
var isAnchor = function (elm) {
|
|
return elm && elm.nodeName.toLowerCase() === 'a';
|
|
};
|
|
var isLink = function (elm) {
|
|
return isAnchor(elm) && !!getHref(elm);
|
|
};
|
|
var collectNodesInRange = function (rng, predicate) {
|
|
if (rng.collapsed) {
|
|
return [];
|
|
} else {
|
|
var contents = rng.cloneContents();
|
|
var walker = new global$4(contents.firstChild, contents);
|
|
var elements = [];
|
|
var current = contents.firstChild;
|
|
do {
|
|
if (predicate(current)) {
|
|
elements.push(current);
|
|
}
|
|
} while (current = walker.next());
|
|
return elements;
|
|
}
|
|
};
|
|
var hasProtocol = function (url) {
|
|
return /^\w+:/i.test(url);
|
|
};
|
|
var getHref = function (elm) {
|
|
var href = elm.getAttribute('data-mce-href');
|
|
return href ? href : elm.getAttribute('href');
|
|
};
|
|
var applyRelTargetRules = function (rel, isUnsafe) {
|
|
var rules = ['noopener'];
|
|
var rels = rel ? rel.split(/\s+/) : [];
|
|
var toString = function (rels) {
|
|
return global$5.trim(rels.sort().join(' '));
|
|
};
|
|
var addTargetRules = function (rels) {
|
|
rels = removeTargetRules(rels);
|
|
return rels.length > 0 ? rels.concat(rules) : rules;
|
|
};
|
|
var removeTargetRules = function (rels) {
|
|
return rels.filter(function (val) {
|
|
return global$5.inArray(rules, val) === -1;
|
|
});
|
|
};
|
|
var newRels = isUnsafe ? addTargetRules(rels) : removeTargetRules(rels);
|
|
return newRels.length > 0 ? toString(newRels) : '';
|
|
};
|
|
var trimCaretContainers = function (text) {
|
|
return text.replace(/\uFEFF/g, '');
|
|
};
|
|
var getAnchorElement = function (editor, selectedElm) {
|
|
selectedElm = selectedElm || editor.selection.getNode();
|
|
if (isImageFigure(selectedElm)) {
|
|
return editor.dom.select('a[href]', selectedElm)[0];
|
|
} else {
|
|
return editor.dom.getParent(selectedElm, 'a[href]');
|
|
}
|
|
};
|
|
var getAnchorText = function (selection, anchorElm) {
|
|
var text = anchorElm ? anchorElm.innerText || anchorElm.textContent : selection.getContent({ format: 'text' });
|
|
return trimCaretContainers(text);
|
|
};
|
|
var hasLinks = function (elements) {
|
|
return global$5.grep(elements, isLink).length > 0;
|
|
};
|
|
var hasLinksInSelection = function (rng) {
|
|
return collectNodesInRange(rng, isLink).length > 0;
|
|
};
|
|
var isOnlyTextSelected = function (editor) {
|
|
var inlineTextElements = editor.schema.getTextInlineElements();
|
|
var isElement = function (elm) {
|
|
return elm.nodeType === 1 && !isAnchor(elm) && !has(inlineTextElements, elm.nodeName.toLowerCase());
|
|
};
|
|
var elements = collectNodesInRange(editor.selection.getRng(), isElement);
|
|
return elements.length === 0;
|
|
};
|
|
var isImageFigure = function (elm) {
|
|
return elm && elm.nodeName === 'FIGURE' && /\bimage\b/i.test(elm.className);
|
|
};
|
|
var getLinkAttrs = function (data) {
|
|
var attrs = [
|
|
'title',
|
|
'rel',
|
|
'class',
|
|
'target'
|
|
];
|
|
return foldl(attrs, function (acc, key) {
|
|
data[key].each(function (value) {
|
|
acc[key] = value.length > 0 ? value : null;
|
|
});
|
|
return acc;
|
|
}, { href: data.href });
|
|
};
|
|
var handleExternalTargets = function (href, assumeExternalTargets) {
|
|
if ((assumeExternalTargets === 'http' || assumeExternalTargets === 'https') && !hasProtocol(href)) {
|
|
return assumeExternalTargets + '://' + href;
|
|
}
|
|
return href;
|
|
};
|
|
var applyLinkOverrides = function (editor, linkAttrs) {
|
|
var newLinkAttrs = __assign({}, linkAttrs);
|
|
if (!(getRelList(editor).length > 0) && allowUnsafeLinkTarget(editor) === false) {
|
|
var newRel = applyRelTargetRules(newLinkAttrs.rel, newLinkAttrs.target === '_blank');
|
|
newLinkAttrs.rel = newRel ? newRel : null;
|
|
}
|
|
if (Optional.from(newLinkAttrs.target).isNone() && getTargetList(editor) === false) {
|
|
newLinkAttrs.target = getDefaultLinkTarget(editor);
|
|
}
|
|
newLinkAttrs.href = handleExternalTargets(newLinkAttrs.href, assumeExternalTargets(editor));
|
|
return newLinkAttrs;
|
|
};
|
|
var updateLink = function (editor, anchorElm, text, linkAttrs) {
|
|
text.each(function (text) {
|
|
if (has(anchorElm, 'innerText')) {
|
|
anchorElm.innerText = text;
|
|
} else {
|
|
anchorElm.textContent = text;
|
|
}
|
|
});
|
|
editor.dom.setAttribs(anchorElm, linkAttrs);
|
|
editor.selection.select(anchorElm);
|
|
};
|
|
var createLink = function (editor, selectedElm, text, linkAttrs) {
|
|
if (isImageFigure(selectedElm)) {
|
|
linkImageFigure(editor, selectedElm, linkAttrs);
|
|
} else {
|
|
text.fold(function () {
|
|
editor.execCommand('mceInsertLink', false, linkAttrs);
|
|
}, function (text) {
|
|
editor.insertContent(editor.dom.createHTML('a', linkAttrs, editor.dom.encode(text)));
|
|
});
|
|
}
|
|
};
|
|
var linkDomMutation = function (editor, attachState, data) {
|
|
var selectedElm = editor.selection.getNode();
|
|
var anchorElm = getAnchorElement(editor, selectedElm);
|
|
var linkAttrs = applyLinkOverrides(editor, getLinkAttrs(data));
|
|
editor.undoManager.transact(function () {
|
|
if (data.href === attachState.href) {
|
|
attachState.attach();
|
|
}
|
|
if (anchorElm) {
|
|
editor.focus();
|
|
updateLink(editor, anchorElm, data.text, linkAttrs);
|
|
} else {
|
|
createLink(editor, selectedElm, data.text, linkAttrs);
|
|
}
|
|
});
|
|
};
|
|
var unlinkSelection = function (editor) {
|
|
var dom = editor.dom, selection = editor.selection;
|
|
var bookmark = selection.getBookmark();
|
|
var rng = selection.getRng().cloneRange();
|
|
var startAnchorElm = dom.getParent(rng.startContainer, 'a[href]', editor.getBody());
|
|
var endAnchorElm = dom.getParent(rng.endContainer, 'a[href]', editor.getBody());
|
|
if (startAnchorElm) {
|
|
rng.setStartBefore(startAnchorElm);
|
|
}
|
|
if (endAnchorElm) {
|
|
rng.setEndAfter(endAnchorElm);
|
|
}
|
|
selection.setRng(rng);
|
|
editor.execCommand('unlink');
|
|
selection.moveToBookmark(bookmark);
|
|
};
|
|
var unlinkDomMutation = function (editor) {
|
|
editor.undoManager.transact(function () {
|
|
var node = editor.selection.getNode();
|
|
if (isImageFigure(node)) {
|
|
unlinkImageFigure(editor, node);
|
|
} else {
|
|
unlinkSelection(editor);
|
|
}
|
|
editor.focus();
|
|
});
|
|
};
|
|
var unwrapOptions = function (data) {
|
|
var cls = data.class, href = data.href, rel = data.rel, target = data.target, text = data.text, title = data.title;
|
|
return filter({
|
|
class: cls.getOrNull(),
|
|
href: href,
|
|
rel: rel.getOrNull(),
|
|
target: target.getOrNull(),
|
|
text: text.getOrNull(),
|
|
title: title.getOrNull()
|
|
}, function (v, _k) {
|
|
return isNull(v) === false;
|
|
});
|
|
};
|
|
var sanitizeData = function (editor, data) {
|
|
var href = data.href;
|
|
return __assign(__assign({}, data), { href: global$3.isDomSafe(href, 'a', editor.settings) ? href : '' });
|
|
};
|
|
var link = function (editor, attachState, data) {
|
|
var sanitizedData = sanitizeData(editor, data);
|
|
editor.hasPlugin('rtc', true) ? editor.execCommand('createlink', false, unwrapOptions(sanitizedData)) : linkDomMutation(editor, attachState, sanitizedData);
|
|
};
|
|
var unlink = function (editor) {
|
|
editor.hasPlugin('rtc', true) ? editor.execCommand('unlink') : unlinkDomMutation(editor);
|
|
};
|
|
var unlinkImageFigure = function (editor, fig) {
|
|
var img = editor.dom.select('img', fig)[0];
|
|
if (img) {
|
|
var a = editor.dom.getParents(img, 'a[href]', fig)[0];
|
|
if (a) {
|
|
a.parentNode.insertBefore(img, a);
|
|
editor.dom.remove(a);
|
|
}
|
|
}
|
|
};
|
|
var linkImageFigure = function (editor, fig, attrs) {
|
|
var img = editor.dom.select('img', fig)[0];
|
|
if (img) {
|
|
var a = editor.dom.create('a', attrs);
|
|
img.parentNode.insertBefore(a, img);
|
|
a.appendChild(img);
|
|
}
|
|
};
|
|
|
|
var isListGroup = function (item) {
|
|
return hasNonNullableKey(item, 'items');
|
|
};
|
|
var findTextByValue = function (value, catalog) {
|
|
return findMap(catalog, function (item) {
|
|
if (isListGroup(item)) {
|
|
return findTextByValue(value, item.items);
|
|
} else {
|
|
return someIf(item.value === value, item);
|
|
}
|
|
});
|
|
};
|
|
var getDelta = function (persistentText, fieldName, catalog, data) {
|
|
var value = data[fieldName];
|
|
var hasPersistentText = persistentText.length > 0;
|
|
return value !== undefined ? findTextByValue(value, catalog).map(function (i) {
|
|
return {
|
|
url: {
|
|
value: i.value,
|
|
meta: {
|
|
text: hasPersistentText ? persistentText : i.text,
|
|
attach: noop
|
|
}
|
|
},
|
|
text: hasPersistentText ? persistentText : i.text
|
|
};
|
|
}) : Optional.none();
|
|
};
|
|
var findCatalog = function (catalogs, fieldName) {
|
|
if (fieldName === 'link') {
|
|
return catalogs.link;
|
|
} else if (fieldName === 'anchor') {
|
|
return catalogs.anchor;
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var init = function (initialData, linkCatalog) {
|
|
var persistentData = {
|
|
text: initialData.text,
|
|
title: initialData.title
|
|
};
|
|
var getTitleFromUrlChange = function (url) {
|
|
return someIf(persistentData.title.length <= 0, Optional.from(url.meta.title).getOr(''));
|
|
};
|
|
var getTextFromUrlChange = function (url) {
|
|
return someIf(persistentData.text.length <= 0, Optional.from(url.meta.text).getOr(url.value));
|
|
};
|
|
var onUrlChange = function (data) {
|
|
var text = getTextFromUrlChange(data.url);
|
|
var title = getTitleFromUrlChange(data.url);
|
|
if (text.isSome() || title.isSome()) {
|
|
return Optional.some(__assign(__assign({}, text.map(function (text) {
|
|
return { text: text };
|
|
}).getOr({})), title.map(function (title) {
|
|
return { title: title };
|
|
}).getOr({})));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var onCatalogChange = function (data, change) {
|
|
var catalog = findCatalog(linkCatalog, change.name).getOr([]);
|
|
return getDelta(persistentData.text, change.name, catalog, data);
|
|
};
|
|
var onChange = function (getData, change) {
|
|
var name = change.name;
|
|
if (name === 'url') {
|
|
return onUrlChange(getData());
|
|
} else if (contains([
|
|
'anchor',
|
|
'link'
|
|
], name)) {
|
|
return onCatalogChange(getData(), change);
|
|
} else if (name === 'text' || name === 'title') {
|
|
persistentData[name] = getData()[name];
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
return { onChange: onChange };
|
|
};
|
|
var DialogChanges = {
|
|
init: init,
|
|
getDelta: getDelta
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var delayedConfirm = function (editor, message, callback) {
|
|
var rng = editor.selection.getRng();
|
|
global$2.setEditorTimeout(editor, function () {
|
|
editor.windowManager.confirm(message, function (state) {
|
|
editor.selection.setRng(rng);
|
|
callback(state);
|
|
});
|
|
});
|
|
};
|
|
var tryEmailTransform = function (data) {
|
|
var url = data.href;
|
|
var suggestMailTo = url.indexOf('@') > 0 && url.indexOf('/') === -1 && url.indexOf('mailto:') === -1;
|
|
return suggestMailTo ? Optional.some({
|
|
message: 'The URL you entered seems to be an email address. Do you want to add the required mailto: prefix?',
|
|
preprocess: function (oldData) {
|
|
return __assign(__assign({}, oldData), { href: 'mailto:' + url });
|
|
}
|
|
}) : Optional.none();
|
|
};
|
|
var tryProtocolTransform = function (assumeExternalTargets, defaultLinkProtocol) {
|
|
return function (data) {
|
|
var url = data.href;
|
|
var suggestProtocol = assumeExternalTargets === 1 && !hasProtocol(url) || assumeExternalTargets === 0 && /^\s*www(\.|\d\.)/i.test(url);
|
|
return suggestProtocol ? Optional.some({
|
|
message: 'The URL you entered seems to be an external link. Do you want to add the required ' + defaultLinkProtocol + ':// prefix?',
|
|
preprocess: function (oldData) {
|
|
return __assign(__assign({}, oldData), { href: defaultLinkProtocol + '://' + url });
|
|
}
|
|
}) : Optional.none();
|
|
};
|
|
};
|
|
var preprocess = function (editor, data) {
|
|
return findMap([
|
|
tryEmailTransform,
|
|
tryProtocolTransform(assumeExternalTargets(editor), getDefaultLinkProtocol(editor))
|
|
], function (f) {
|
|
return f(data);
|
|
}).fold(function () {
|
|
return global$1.resolve(data);
|
|
}, function (transform) {
|
|
return new global$1(function (callback) {
|
|
delayedConfirm(editor, transform.message, function (state) {
|
|
callback(state ? transform.preprocess(data) : data);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var DialogConfirms = { preprocess: preprocess };
|
|
|
|
var getAnchors = function (editor) {
|
|
var anchorNodes = editor.dom.select('a:not([href])');
|
|
var anchors = bind(anchorNodes, function (anchor) {
|
|
var id = anchor.name || anchor.id;
|
|
return id ? [{
|
|
text: id,
|
|
value: '#' + id
|
|
}] : [];
|
|
});
|
|
return anchors.length > 0 ? Optional.some([{
|
|
text: 'None',
|
|
value: ''
|
|
}].concat(anchors)) : Optional.none();
|
|
};
|
|
var AnchorListOptions = { getAnchors: getAnchors };
|
|
|
|
var getClasses = function (editor) {
|
|
var list = getLinkClassList(editor);
|
|
if (list.length > 0) {
|
|
return ListOptions.sanitize(list);
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var ClassListOptions = { getClasses: getClasses };
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.XHR');
|
|
|
|
var parseJson = function (text) {
|
|
try {
|
|
return Optional.some(JSON.parse(text));
|
|
} catch (err) {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var getLinks = function (editor) {
|
|
var extractor = function (item) {
|
|
return editor.convertURL(item.value || item.url, 'href');
|
|
};
|
|
var linkList = getLinkList(editor);
|
|
return new global$1(function (callback) {
|
|
if (isString(linkList)) {
|
|
global.send({
|
|
url: linkList,
|
|
success: function (text) {
|
|
return callback(parseJson(text));
|
|
},
|
|
error: function (_) {
|
|
return callback(Optional.none());
|
|
}
|
|
});
|
|
} else if (isFunction(linkList)) {
|
|
linkList(function (output) {
|
|
return callback(Optional.some(output));
|
|
});
|
|
} else {
|
|
callback(Optional.from(linkList));
|
|
}
|
|
}).then(function (optItems) {
|
|
return optItems.bind(ListOptions.sanitizeWith(extractor)).map(function (items) {
|
|
if (items.length > 0) {
|
|
var noneItem = [{
|
|
text: 'None',
|
|
value: ''
|
|
}];
|
|
return noneItem.concat(items);
|
|
} else {
|
|
return items;
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var LinkListOptions = { getLinks: getLinks };
|
|
|
|
var getRels = function (editor, initialTarget) {
|
|
var list = getRelList(editor);
|
|
if (list.length > 0) {
|
|
var isTargetBlank_1 = is(initialTarget, '_blank');
|
|
var enforceSafe = allowUnsafeLinkTarget(editor) === false;
|
|
var safeRelExtractor = function (item) {
|
|
return applyRelTargetRules(ListOptions.getValue(item), isTargetBlank_1);
|
|
};
|
|
var sanitizer = enforceSafe ? ListOptions.sanitizeWith(safeRelExtractor) : ListOptions.sanitize;
|
|
return sanitizer(list);
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var RelOptions = { getRels: getRels };
|
|
|
|
var fallbacks = [
|
|
{
|
|
text: 'Current window',
|
|
value: ''
|
|
},
|
|
{
|
|
text: 'New window',
|
|
value: '_blank'
|
|
}
|
|
];
|
|
var getTargets = function (editor) {
|
|
var list = getTargetList(editor);
|
|
if (isArray(list)) {
|
|
return ListOptions.sanitize(list).orThunk(function () {
|
|
return Optional.some(fallbacks);
|
|
});
|
|
} else if (list === false) {
|
|
return Optional.none();
|
|
}
|
|
return Optional.some(fallbacks);
|
|
};
|
|
var TargetOptions = { getTargets: getTargets };
|
|
|
|
var nonEmptyAttr = function (dom, elem, name) {
|
|
var val = dom.getAttrib(elem, name);
|
|
return val !== null && val.length > 0 ? Optional.some(val) : Optional.none();
|
|
};
|
|
var extractFromAnchor = function (editor, anchor) {
|
|
var dom = editor.dom;
|
|
var onlyText = isOnlyTextSelected(editor);
|
|
var text = onlyText ? Optional.some(getAnchorText(editor.selection, anchor)) : Optional.none();
|
|
var url = anchor ? Optional.some(dom.getAttrib(anchor, 'href')) : Optional.none();
|
|
var target = anchor ? Optional.from(dom.getAttrib(anchor, 'target')) : Optional.none();
|
|
var rel = nonEmptyAttr(dom, anchor, 'rel');
|
|
var linkClass = nonEmptyAttr(dom, anchor, 'class');
|
|
var title = nonEmptyAttr(dom, anchor, 'title');
|
|
return {
|
|
url: url,
|
|
text: text,
|
|
title: title,
|
|
target: target,
|
|
rel: rel,
|
|
linkClass: linkClass
|
|
};
|
|
};
|
|
var collect = function (editor, linkNode) {
|
|
return LinkListOptions.getLinks(editor).then(function (links) {
|
|
var anchor = extractFromAnchor(editor, linkNode);
|
|
return {
|
|
anchor: anchor,
|
|
catalogs: {
|
|
targets: TargetOptions.getTargets(editor),
|
|
rels: RelOptions.getRels(editor, anchor.target),
|
|
classes: ClassListOptions.getClasses(editor),
|
|
anchor: AnchorListOptions.getAnchors(editor),
|
|
link: links
|
|
},
|
|
optNode: Optional.from(linkNode),
|
|
flags: { titleEnabled: shouldShowLinkTitle(editor) }
|
|
};
|
|
});
|
|
};
|
|
var DialogInfo = { collect: collect };
|
|
|
|
var handleSubmit = function (editor, info) {
|
|
return function (api) {
|
|
var data = api.getData();
|
|
if (!data.url.value) {
|
|
unlink(editor);
|
|
api.close();
|
|
return;
|
|
}
|
|
var getChangedValue = function (key) {
|
|
return Optional.from(data[key]).filter(function (value) {
|
|
return !is(info.anchor[key], value);
|
|
});
|
|
};
|
|
var changedData = {
|
|
href: data.url.value,
|
|
text: getChangedValue('text'),
|
|
target: getChangedValue('target'),
|
|
rel: getChangedValue('rel'),
|
|
class: getChangedValue('linkClass'),
|
|
title: getChangedValue('title')
|
|
};
|
|
var attachState = {
|
|
href: data.url.value,
|
|
attach: data.url.meta !== undefined && data.url.meta.attach ? data.url.meta.attach : noop
|
|
};
|
|
DialogConfirms.preprocess(editor, changedData).then(function (pData) {
|
|
link(editor, attachState, pData);
|
|
});
|
|
api.close();
|
|
};
|
|
};
|
|
var collectData = function (editor) {
|
|
var anchorNode = getAnchorElement(editor);
|
|
return DialogInfo.collect(editor, anchorNode);
|
|
};
|
|
var getInitialData = function (info, defaultTarget) {
|
|
var anchor = info.anchor;
|
|
var url = anchor.url.getOr('');
|
|
return {
|
|
url: {
|
|
value: url,
|
|
meta: { original: { value: url } }
|
|
},
|
|
text: anchor.text.getOr(''),
|
|
title: anchor.title.getOr(''),
|
|
anchor: url,
|
|
link: url,
|
|
rel: anchor.rel.getOr(''),
|
|
target: anchor.target.or(defaultTarget).getOr(''),
|
|
linkClass: anchor.linkClass.getOr('')
|
|
};
|
|
};
|
|
var makeDialog = function (settings, onSubmit, editor) {
|
|
var urlInput = [{
|
|
name: 'url',
|
|
type: 'urlinput',
|
|
filetype: 'file',
|
|
label: 'URL'
|
|
}];
|
|
var displayText = settings.anchor.text.map(function () {
|
|
return {
|
|
name: 'text',
|
|
type: 'input',
|
|
label: 'Text to display'
|
|
};
|
|
}).toArray();
|
|
var titleText = settings.flags.titleEnabled ? [{
|
|
name: 'title',
|
|
type: 'input',
|
|
label: 'Title'
|
|
}] : [];
|
|
var defaultTarget = Optional.from(getDefaultLinkTarget(editor));
|
|
var initialData = getInitialData(settings, defaultTarget);
|
|
var catalogs = settings.catalogs;
|
|
var dialogDelta = DialogChanges.init(initialData, catalogs);
|
|
var body = {
|
|
type: 'panel',
|
|
items: flatten([
|
|
urlInput,
|
|
displayText,
|
|
titleText,
|
|
cat([
|
|
catalogs.anchor.map(ListOptions.createUi('anchor', 'Anchors')),
|
|
catalogs.rels.map(ListOptions.createUi('rel', 'Rel')),
|
|
catalogs.targets.map(ListOptions.createUi('target', 'Open link in...')),
|
|
catalogs.link.map(ListOptions.createUi('link', 'Link list')),
|
|
catalogs.classes.map(ListOptions.createUi('linkClass', 'Class'))
|
|
])
|
|
])
|
|
};
|
|
return {
|
|
title: 'Insert/Edit Link',
|
|
size: 'normal',
|
|
body: body,
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: initialData,
|
|
onChange: function (api, _a) {
|
|
var name = _a.name;
|
|
dialogDelta.onChange(api.getData, { name: name }).each(function (newData) {
|
|
api.setData(newData);
|
|
});
|
|
},
|
|
onSubmit: onSubmit
|
|
};
|
|
};
|
|
var open$1 = function (editor) {
|
|
var data = collectData(editor);
|
|
data.then(function (info) {
|
|
var onSubmit = handleSubmit(editor, info);
|
|
return makeDialog(info, onSubmit, editor);
|
|
}).then(function (spec) {
|
|
editor.windowManager.open(spec);
|
|
});
|
|
};
|
|
|
|
var appendClickRemove = function (link, evt) {
|
|
document.body.appendChild(link);
|
|
link.dispatchEvent(evt);
|
|
document.body.removeChild(link);
|
|
};
|
|
var open = function (url) {
|
|
var link = document.createElement('a');
|
|
link.target = '_blank';
|
|
link.href = url;
|
|
link.rel = 'noreferrer noopener';
|
|
var evt = document.createEvent('MouseEvents');
|
|
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
|
appendClickRemove(link, evt);
|
|
};
|
|
|
|
var getLink = function (editor, elm) {
|
|
return editor.dom.getParent(elm, 'a[href]');
|
|
};
|
|
var getSelectedLink = function (editor) {
|
|
return getLink(editor, editor.selection.getStart());
|
|
};
|
|
var hasOnlyAltModifier = function (e) {
|
|
return e.altKey === true && e.shiftKey === false && e.ctrlKey === false && e.metaKey === false;
|
|
};
|
|
var gotoLink = function (editor, a) {
|
|
if (a) {
|
|
var href = getHref(a);
|
|
if (/^#/.test(href)) {
|
|
var targetEl = editor.$(href);
|
|
if (targetEl.length) {
|
|
editor.selection.scrollIntoView(targetEl[0], true);
|
|
}
|
|
} else {
|
|
open(a.href);
|
|
}
|
|
}
|
|
};
|
|
var openDialog = function (editor) {
|
|
return function () {
|
|
open$1(editor);
|
|
};
|
|
};
|
|
var gotoSelectedLink = function (editor) {
|
|
return function () {
|
|
gotoLink(editor, getSelectedLink(editor));
|
|
};
|
|
};
|
|
var setupGotoLinks = function (editor) {
|
|
editor.on('click', function (e) {
|
|
var link = getLink(editor, e.target);
|
|
if (link && global$6.metaKeyPressed(e)) {
|
|
e.preventDefault();
|
|
gotoLink(editor, link);
|
|
}
|
|
});
|
|
editor.on('keydown', function (e) {
|
|
var link = getSelectedLink(editor);
|
|
if (link && e.keyCode === 13 && hasOnlyAltModifier(e)) {
|
|
e.preventDefault();
|
|
gotoLink(editor, link);
|
|
}
|
|
});
|
|
};
|
|
var toggleState = function (editor, toggler) {
|
|
editor.on('NodeChange', toggler);
|
|
return function () {
|
|
return editor.off('NodeChange', toggler);
|
|
};
|
|
};
|
|
var toggleActiveState = function (editor) {
|
|
return function (api) {
|
|
var updateState = function () {
|
|
return api.setActive(!editor.mode.isReadOnly() && getAnchorElement(editor, editor.selection.getNode()) !== null);
|
|
};
|
|
updateState();
|
|
return toggleState(editor, updateState);
|
|
};
|
|
};
|
|
var toggleEnabledState = function (editor) {
|
|
return function (api) {
|
|
var updateState = function () {
|
|
return api.setDisabled(getAnchorElement(editor, editor.selection.getNode()) === null);
|
|
};
|
|
updateState();
|
|
return toggleState(editor, updateState);
|
|
};
|
|
};
|
|
var toggleUnlinkState = function (editor) {
|
|
return function (api) {
|
|
var hasLinks$1 = function (parents) {
|
|
return hasLinks(parents) || hasLinksInSelection(editor.selection.getRng());
|
|
};
|
|
var parents = editor.dom.getParents(editor.selection.getStart());
|
|
api.setDisabled(!hasLinks$1(parents));
|
|
return toggleState(editor, function (e) {
|
|
return api.setDisabled(!hasLinks$1(e.parents));
|
|
});
|
|
};
|
|
};
|
|
|
|
var register = function (editor) {
|
|
editor.addCommand('mceLink', function () {
|
|
if (useQuickLink(editor)) {
|
|
editor.fire('contexttoolbar-show', { toolbarKey: 'quicklink' });
|
|
} else {
|
|
openDialog(editor)();
|
|
}
|
|
});
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
editor.addShortcut('Meta+K', '', function () {
|
|
editor.execCommand('mceLink');
|
|
});
|
|
};
|
|
|
|
var setupButtons = function (editor) {
|
|
editor.ui.registry.addToggleButton('link', {
|
|
icon: 'link',
|
|
tooltip: 'Insert/edit link',
|
|
onAction: openDialog(editor),
|
|
onSetup: toggleActiveState(editor)
|
|
});
|
|
editor.ui.registry.addButton('openlink', {
|
|
icon: 'new-tab',
|
|
tooltip: 'Open link',
|
|
onAction: gotoSelectedLink(editor),
|
|
onSetup: toggleEnabledState(editor)
|
|
});
|
|
editor.ui.registry.addButton('unlink', {
|
|
icon: 'unlink',
|
|
tooltip: 'Remove link',
|
|
onAction: function () {
|
|
return unlink(editor);
|
|
},
|
|
onSetup: toggleUnlinkState(editor)
|
|
});
|
|
};
|
|
var setupMenuItems = function (editor) {
|
|
editor.ui.registry.addMenuItem('openlink', {
|
|
text: 'Open link',
|
|
icon: 'new-tab',
|
|
onAction: gotoSelectedLink(editor),
|
|
onSetup: toggleEnabledState(editor)
|
|
});
|
|
editor.ui.registry.addMenuItem('link', {
|
|
icon: 'link',
|
|
text: 'Link...',
|
|
shortcut: 'Meta+K',
|
|
onAction: openDialog(editor)
|
|
});
|
|
editor.ui.registry.addMenuItem('unlink', {
|
|
icon: 'unlink',
|
|
text: 'Remove link',
|
|
onAction: function () {
|
|
return unlink(editor);
|
|
},
|
|
onSetup: toggleUnlinkState(editor)
|
|
});
|
|
};
|
|
var setupContextMenu = function (editor) {
|
|
var inLink = 'link unlink openlink';
|
|
var noLink = 'link';
|
|
editor.ui.registry.addContextMenu('link', {
|
|
update: function (element) {
|
|
return hasLinks(editor.dom.getParents(element, 'a')) ? inLink : noLink;
|
|
}
|
|
});
|
|
};
|
|
var setupContextToolbars = function (editor) {
|
|
var collapseSelectionToEnd = function (editor) {
|
|
editor.selection.collapse(false);
|
|
};
|
|
var onSetupLink = function (buttonApi) {
|
|
var node = editor.selection.getNode();
|
|
buttonApi.setDisabled(!getAnchorElement(editor, node));
|
|
return noop;
|
|
};
|
|
var getLinkText = function (value) {
|
|
var anchor = getAnchorElement(editor);
|
|
var onlyText = isOnlyTextSelected(editor);
|
|
if (!anchor && onlyText) {
|
|
var text = getAnchorText(editor.selection, anchor);
|
|
return Optional.some(text.length > 0 ? text : value);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
editor.ui.registry.addContextForm('quicklink', {
|
|
launch: {
|
|
type: 'contextformtogglebutton',
|
|
icon: 'link',
|
|
tooltip: 'Link',
|
|
onSetup: toggleActiveState(editor)
|
|
},
|
|
label: 'Link',
|
|
predicate: function (node) {
|
|
return !!getAnchorElement(editor, node) && hasContextToolbar(editor);
|
|
},
|
|
initValue: function () {
|
|
var elm = getAnchorElement(editor);
|
|
return !!elm ? getHref(elm) : '';
|
|
},
|
|
commands: [
|
|
{
|
|
type: 'contextformtogglebutton',
|
|
icon: 'link',
|
|
tooltip: 'Link',
|
|
primary: true,
|
|
onSetup: function (buttonApi) {
|
|
var node = editor.selection.getNode();
|
|
buttonApi.setActive(!!getAnchorElement(editor, node));
|
|
return toggleActiveState(editor)(buttonApi);
|
|
},
|
|
onAction: function (formApi) {
|
|
var value = formApi.getValue();
|
|
var text = getLinkText(value);
|
|
var attachState = {
|
|
href: value,
|
|
attach: noop
|
|
};
|
|
link(editor, attachState, {
|
|
href: value,
|
|
text: text,
|
|
title: Optional.none(),
|
|
rel: Optional.none(),
|
|
target: Optional.none(),
|
|
class: Optional.none()
|
|
});
|
|
collapseSelectionToEnd(editor);
|
|
formApi.hide();
|
|
}
|
|
},
|
|
{
|
|
type: 'contextformbutton',
|
|
icon: 'unlink',
|
|
tooltip: 'Remove link',
|
|
onSetup: onSetupLink,
|
|
onAction: function (formApi) {
|
|
unlink(editor);
|
|
formApi.hide();
|
|
}
|
|
},
|
|
{
|
|
type: 'contextformbutton',
|
|
icon: 'new-tab',
|
|
tooltip: 'Open link',
|
|
onSetup: onSetupLink,
|
|
onAction: function (formApi) {
|
|
gotoSelectedLink(editor)();
|
|
formApi.hide();
|
|
}
|
|
}
|
|
]
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$7.add('link', function (editor) {
|
|
setupButtons(editor);
|
|
setupMenuItems(editor);
|
|
setupContextMenu(editor);
|
|
setupContextToolbars(editor);
|
|
setupGotoLinks(editor);
|
|
register(editor);
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$7 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isObject = isType$1('object');
|
|
var isArray = isType$1('array');
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isFunction = isSimpleType('function');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var tripleEquals = function (a, b) {
|
|
return a === b;
|
|
};
|
|
var not = function (f) {
|
|
return function (t) {
|
|
return !f(t);
|
|
};
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var nativeSlice = Array.prototype.slice;
|
|
var nativePush = Array.prototype.push;
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter$1 = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var groupBy = function (xs, f) {
|
|
if (xs.length === 0) {
|
|
return [];
|
|
} else {
|
|
var wasType = f(xs[0]);
|
|
var r = [];
|
|
var group = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
var type = f(x);
|
|
if (type !== wasType) {
|
|
r.push(group);
|
|
group = [];
|
|
}
|
|
wasType = type;
|
|
group.push(x);
|
|
}
|
|
if (group.length !== 0) {
|
|
r.push(group);
|
|
}
|
|
return r;
|
|
}
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each$1(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find$1 = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind = function (xs, f) {
|
|
return flatten(map(xs, f));
|
|
};
|
|
var reverse = function (xs) {
|
|
var r = nativeSlice.call(xs, 0);
|
|
r.reverse();
|
|
return r;
|
|
};
|
|
var get$1 = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get$1(xs, 0);
|
|
};
|
|
var last = function (xs) {
|
|
return get$1(xs, xs.length - 1);
|
|
};
|
|
var findMap = function (arr, f) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var r = f(arr[i], i);
|
|
if (r.isSome()) {
|
|
return r;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
function __spreadArray(to, from, pack) {
|
|
if (pack || arguments.length === 2)
|
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
if (ar || !(i in from)) {
|
|
if (!ar)
|
|
ar = Array.prototype.slice.call(from, 0, i);
|
|
ar[i] = from[i];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
}
|
|
|
|
var cached = function (f) {
|
|
var called = false;
|
|
var r;
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (!called) {
|
|
called = true;
|
|
r = f.apply(null, args);
|
|
}
|
|
return r;
|
|
};
|
|
};
|
|
|
|
var DeviceType = function (os, browser, userAgent, mediaMatch) {
|
|
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
|
|
var isiPhone = os.isiOS() && !isiPad;
|
|
var isMobile = os.isiOS() || os.isAndroid();
|
|
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
|
|
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
|
|
var isPhone = isiPhone || isMobile && !isTablet;
|
|
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
|
|
var isDesktop = !isPhone && !isTablet && !iOSwebview;
|
|
return {
|
|
isiPad: constant(isiPad),
|
|
isiPhone: constant(isiPhone),
|
|
isTablet: constant(isTablet),
|
|
isPhone: constant(isPhone),
|
|
isTouch: constant(isTouch),
|
|
isAndroid: os.isAndroid,
|
|
isiOS: os.isiOS,
|
|
isWebView: constant(iOSwebview),
|
|
isDesktop: constant(isDesktop)
|
|
};
|
|
};
|
|
|
|
var firstMatch = function (regexes, s) {
|
|
for (var i = 0; i < regexes.length; i++) {
|
|
var x = regexes[i];
|
|
if (x.test(s)) {
|
|
return x;
|
|
}
|
|
}
|
|
return undefined;
|
|
};
|
|
var find = function (regexes, agent) {
|
|
var r = firstMatch(regexes, agent);
|
|
if (!r) {
|
|
return {
|
|
major: 0,
|
|
minor: 0
|
|
};
|
|
}
|
|
var group = function (i) {
|
|
return Number(agent.replace(r, '$' + i));
|
|
};
|
|
return nu$2(group(1), group(2));
|
|
};
|
|
var detect$3 = function (versionRegexes, agent) {
|
|
var cleanedAgent = String(agent).toLowerCase();
|
|
if (versionRegexes.length === 0) {
|
|
return unknown$2();
|
|
}
|
|
return find(versionRegexes, cleanedAgent);
|
|
};
|
|
var unknown$2 = function () {
|
|
return nu$2(0, 0);
|
|
};
|
|
var nu$2 = function (major, minor) {
|
|
return {
|
|
major: major,
|
|
minor: minor
|
|
};
|
|
};
|
|
var Version = {
|
|
nu: nu$2,
|
|
detect: detect$3,
|
|
unknown: unknown$2
|
|
};
|
|
|
|
var detectBrowser$1 = function (browsers, userAgentData) {
|
|
return findMap(userAgentData.brands, function (uaBrand) {
|
|
var lcBrand = uaBrand.brand.toLowerCase();
|
|
return find$1(browsers, function (browser) {
|
|
var _a;
|
|
return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
}).map(function (info) {
|
|
return {
|
|
current: info.name,
|
|
version: Version.nu(parseInt(uaBrand.version, 10), 0)
|
|
};
|
|
});
|
|
});
|
|
};
|
|
|
|
var detect$2 = function (candidates, userAgent) {
|
|
var agent = String(userAgent).toLowerCase();
|
|
return find$1(candidates, function (candidate) {
|
|
return candidate.search(agent);
|
|
});
|
|
};
|
|
var detectBrowser = function (browsers, userAgent) {
|
|
return detect$2(browsers, userAgent).map(function (browser) {
|
|
var version = Version.detect(browser.versionRegexes, userAgent);
|
|
return {
|
|
current: browser.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
var detectOs = function (oses, userAgent) {
|
|
return detect$2(oses, userAgent).map(function (os) {
|
|
var version = Version.detect(os.versionRegexes, userAgent);
|
|
return {
|
|
current: os.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
|
|
var contains$1 = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
var blank = function (r) {
|
|
return function (s) {
|
|
return s.replace(r, '');
|
|
};
|
|
};
|
|
var trim = blank(/^\s+|\s+$/g);
|
|
var isNotEmpty = function (s) {
|
|
return s.length > 0;
|
|
};
|
|
var isEmpty$1 = function (s) {
|
|
return !isNotEmpty(s);
|
|
};
|
|
|
|
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
|
|
var checkContains = function (target) {
|
|
return function (uastring) {
|
|
return contains$1(uastring, target);
|
|
};
|
|
};
|
|
var browsers = [
|
|
{
|
|
name: 'Edge',
|
|
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
|
|
}
|
|
},
|
|
{
|
|
name: 'Chrome',
|
|
brand: 'Chromium',
|
|
versionRegexes: [
|
|
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
|
|
normalVersionRegex
|
|
],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');
|
|
}
|
|
},
|
|
{
|
|
name: 'IE',
|
|
versionRegexes: [
|
|
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*?rv:([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'msie') || contains$1(uastring, 'trident');
|
|
}
|
|
},
|
|
{
|
|
name: 'Opera',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?opera\/([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: checkContains('opera')
|
|
},
|
|
{
|
|
name: 'Firefox',
|
|
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
|
|
search: checkContains('firefox')
|
|
},
|
|
{
|
|
name: 'Safari',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?cpu os ([0-9]+)_([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');
|
|
}
|
|
}
|
|
];
|
|
var oses = [
|
|
{
|
|
name: 'Windows',
|
|
search: checkContains('win'),
|
|
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'iOS',
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad');
|
|
},
|
|
versionRegexes: [
|
|
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*cpu os ([0-9]+)_([0-9]+).*/,
|
|
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
|
|
]
|
|
},
|
|
{
|
|
name: 'Android',
|
|
search: checkContains('android'),
|
|
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'OSX',
|
|
search: checkContains('mac os x'),
|
|
versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'Linux',
|
|
search: checkContains('linux'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'Solaris',
|
|
search: checkContains('sunos'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'FreeBSD',
|
|
search: checkContains('freebsd'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'ChromeOS',
|
|
search: checkContains('cros'),
|
|
versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
|
|
}
|
|
];
|
|
var PlatformInfo = {
|
|
browsers: constant(browsers),
|
|
oses: constant(oses)
|
|
};
|
|
|
|
var edge = 'Edge';
|
|
var chrome = 'Chrome';
|
|
var ie = 'IE';
|
|
var opera = 'Opera';
|
|
var firefox = 'Firefox';
|
|
var safari = 'Safari';
|
|
var unknown$1 = function () {
|
|
return nu$1({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu$1 = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isBrowser = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isEdge: isBrowser(edge),
|
|
isChrome: isBrowser(chrome),
|
|
isIE: isBrowser(ie),
|
|
isOpera: isBrowser(opera),
|
|
isFirefox: isBrowser(firefox),
|
|
isSafari: isBrowser(safari)
|
|
};
|
|
};
|
|
var Browser = {
|
|
unknown: unknown$1,
|
|
nu: nu$1,
|
|
edge: constant(edge),
|
|
chrome: constant(chrome),
|
|
ie: constant(ie),
|
|
opera: constant(opera),
|
|
firefox: constant(firefox),
|
|
safari: constant(safari)
|
|
};
|
|
|
|
var windows = 'Windows';
|
|
var ios = 'iOS';
|
|
var android = 'Android';
|
|
var linux = 'Linux';
|
|
var osx = 'OSX';
|
|
var solaris = 'Solaris';
|
|
var freebsd = 'FreeBSD';
|
|
var chromeos = 'ChromeOS';
|
|
var unknown = function () {
|
|
return nu({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isOS = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isWindows: isOS(windows),
|
|
isiOS: isOS(ios),
|
|
isAndroid: isOS(android),
|
|
isOSX: isOS(osx),
|
|
isLinux: isOS(linux),
|
|
isSolaris: isOS(solaris),
|
|
isFreeBSD: isOS(freebsd),
|
|
isChromeOS: isOS(chromeos)
|
|
};
|
|
};
|
|
var OperatingSystem = {
|
|
unknown: unknown,
|
|
nu: nu,
|
|
windows: constant(windows),
|
|
ios: constant(ios),
|
|
android: constant(android),
|
|
linux: constant(linux),
|
|
osx: constant(osx),
|
|
solaris: constant(solaris),
|
|
freebsd: constant(freebsd),
|
|
chromeos: constant(chromeos)
|
|
};
|
|
|
|
var detect$1 = function (userAgent, userAgentDataOpt, mediaMatch) {
|
|
var browsers = PlatformInfo.browsers();
|
|
var oses = PlatformInfo.oses();
|
|
var browser = userAgentDataOpt.bind(function (userAgentData) {
|
|
return detectBrowser$1(browsers, userAgentData);
|
|
}).orThunk(function () {
|
|
return detectBrowser(browsers, userAgent);
|
|
}).fold(Browser.unknown, Browser.nu);
|
|
var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
|
|
var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
|
|
return {
|
|
browser: browser,
|
|
os: os,
|
|
deviceType: deviceType
|
|
};
|
|
};
|
|
var PlatformDetection = { detect: detect$1 };
|
|
|
|
var mediaMatch = function (query) {
|
|
return window.matchMedia(query).matches;
|
|
};
|
|
var platform = cached(function () {
|
|
return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
|
|
});
|
|
var detect = function () {
|
|
return platform();
|
|
};
|
|
|
|
var compareDocumentPosition = function (a, b, match) {
|
|
return (a.compareDocumentPosition(b) & match) !== 0;
|
|
};
|
|
var documentPositionContainedBy = function (a, b) {
|
|
return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY);
|
|
};
|
|
|
|
var ELEMENT = 1;
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var is$2 = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
|
|
var eq = function (e1, e2) {
|
|
return e1.dom === e2.dom;
|
|
};
|
|
var regularContains = function (e1, e2) {
|
|
var d1 = e1.dom;
|
|
var d2 = e2.dom;
|
|
return d1 === d2 ? false : d1.contains(d2);
|
|
};
|
|
var ieContains = function (e1, e2) {
|
|
return documentPositionContainedBy(e1.dom, e2.dom);
|
|
};
|
|
var contains = function (e1, e2) {
|
|
return detect().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);
|
|
};
|
|
var is$1 = is$2;
|
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var keys = Object.keys;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var objAcc = function (r) {
|
|
return function (x, i) {
|
|
r[i] = x;
|
|
};
|
|
};
|
|
var internalFilter = function (obj, pred, onTrue, onFalse) {
|
|
var r = {};
|
|
each(obj, function (x, i) {
|
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
});
|
|
return r;
|
|
};
|
|
var filter = function (obj, pred) {
|
|
var t = {};
|
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
return t;
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var name = function (element) {
|
|
var r = element.dom.nodeName;
|
|
return r.toLowerCase();
|
|
};
|
|
var type = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type(element) === t;
|
|
};
|
|
};
|
|
var isElement = isType(ELEMENT);
|
|
var isTag = function (tag) {
|
|
return function (e) {
|
|
return isElement(e) && name(e) === tag;
|
|
};
|
|
};
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var setAll = function (element, attrs) {
|
|
var dom = element.dom;
|
|
each(attrs, function (v, k) {
|
|
rawSet(dom, k, v);
|
|
});
|
|
};
|
|
var clone$1 = function (element) {
|
|
return foldl(element.dom.attributes, function (acc, attr) {
|
|
acc[attr.name] = attr.value;
|
|
return acc;
|
|
}, {});
|
|
};
|
|
|
|
var parent = function (element) {
|
|
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
};
|
|
var children = function (element) {
|
|
return map(element.dom.childNodes, SugarElement.fromDom);
|
|
};
|
|
var child = function (element, index) {
|
|
var cs = element.dom.childNodes;
|
|
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
|
};
|
|
var firstChild = function (element) {
|
|
return child(element, 0);
|
|
};
|
|
var lastChild = function (element) {
|
|
return child(element, element.dom.childNodes.length - 1);
|
|
};
|
|
|
|
var before$1 = function (marker, element) {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
v.dom.insertBefore(element.dom, marker.dom);
|
|
});
|
|
};
|
|
var append$1 = function (parent, element) {
|
|
parent.dom.appendChild(element.dom);
|
|
};
|
|
|
|
var before = function (marker, elements) {
|
|
each$1(elements, function (x) {
|
|
before$1(marker, x);
|
|
});
|
|
};
|
|
var append = function (parent, elements) {
|
|
each$1(elements, function (x) {
|
|
append$1(parent, x);
|
|
});
|
|
};
|
|
|
|
var remove = function (element) {
|
|
var dom = element.dom;
|
|
if (dom.parentNode !== null) {
|
|
dom.parentNode.removeChild(dom);
|
|
}
|
|
};
|
|
|
|
var clone = function (original, isDeep) {
|
|
return SugarElement.fromDom(original.dom.cloneNode(isDeep));
|
|
};
|
|
var deep = function (original) {
|
|
return clone(original, true);
|
|
};
|
|
var shallowAs = function (original, tag) {
|
|
var nu = SugarElement.fromTag(tag);
|
|
var attributes = clone$1(original);
|
|
setAll(nu, attributes);
|
|
return nu;
|
|
};
|
|
var mutate = function (original, tag) {
|
|
var nu = shallowAs(original, tag);
|
|
before$1(original, nu);
|
|
var children$1 = children(original);
|
|
append(nu, children$1);
|
|
remove(original);
|
|
return nu;
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var matchNodeName = function (name) {
|
|
return function (node) {
|
|
return node && node.nodeName.toLowerCase() === name;
|
|
};
|
|
};
|
|
var matchNodeNames = function (regex) {
|
|
return function (node) {
|
|
return node && regex.test(node.nodeName);
|
|
};
|
|
};
|
|
var isTextNode = function (node) {
|
|
return node && node.nodeType === 3;
|
|
};
|
|
var isListNode = matchNodeNames(/^(OL|UL|DL)$/);
|
|
var isOlUlNode = matchNodeNames(/^(OL|UL)$/);
|
|
var isOlNode = matchNodeName('ol');
|
|
var isListItemNode = matchNodeNames(/^(LI|DT|DD)$/);
|
|
var isDlItemNode = matchNodeNames(/^(DT|DD)$/);
|
|
var isTableCellNode = matchNodeNames(/^(TH|TD)$/);
|
|
var isBr = matchNodeName('br');
|
|
var isFirstChild = function (node) {
|
|
return node.parentNode.firstChild === node;
|
|
};
|
|
var isTextBlock = function (editor, node) {
|
|
return node && !!editor.schema.getTextBlockElements()[node.nodeName];
|
|
};
|
|
var isBlock = function (node, blockElements) {
|
|
return node && node.nodeName in blockElements;
|
|
};
|
|
var isBogusBr = function (dom, node) {
|
|
if (!isBr(node)) {
|
|
return false;
|
|
}
|
|
return dom.isBlock(node.nextSibling) && !isBr(node.previousSibling);
|
|
};
|
|
var isEmpty = function (dom, elm, keepBookmarks) {
|
|
var empty = dom.isEmpty(elm);
|
|
if (keepBookmarks && dom.select('span[data-mce-type=bookmark]', elm).length > 0) {
|
|
return false;
|
|
}
|
|
return empty;
|
|
};
|
|
var isChildOfBody = function (dom, elm) {
|
|
return dom.isChildOf(elm, dom.getRoot());
|
|
};
|
|
|
|
var shouldIndentOnTab = function (editor) {
|
|
return editor.getParam('lists_indent_on_tab', true);
|
|
};
|
|
var getForcedRootBlock = function (editor) {
|
|
var block = editor.getParam('forced_root_block', 'p');
|
|
if (block === false) {
|
|
return '';
|
|
} else if (block === true) {
|
|
return 'p';
|
|
} else {
|
|
return block;
|
|
}
|
|
};
|
|
var getForcedRootBlockAttrs = function (editor) {
|
|
return editor.getParam('forced_root_block_attrs', {});
|
|
};
|
|
|
|
var createTextBlock = function (editor, contentNode) {
|
|
var dom = editor.dom;
|
|
var blockElements = editor.schema.getBlockElements();
|
|
var fragment = dom.createFragment();
|
|
var blockName = getForcedRootBlock(editor);
|
|
var node, textBlock, hasContentNode;
|
|
if (blockName) {
|
|
textBlock = dom.create(blockName);
|
|
if (textBlock.tagName === blockName.toUpperCase()) {
|
|
dom.setAttribs(textBlock, getForcedRootBlockAttrs(editor));
|
|
}
|
|
if (!isBlock(contentNode.firstChild, blockElements)) {
|
|
fragment.appendChild(textBlock);
|
|
}
|
|
}
|
|
if (contentNode) {
|
|
while (node = contentNode.firstChild) {
|
|
var nodeName = node.nodeName;
|
|
if (!hasContentNode && (nodeName !== 'SPAN' || node.getAttribute('data-mce-type') !== 'bookmark')) {
|
|
hasContentNode = true;
|
|
}
|
|
if (isBlock(node, blockElements)) {
|
|
fragment.appendChild(node);
|
|
textBlock = null;
|
|
} else {
|
|
if (blockName) {
|
|
if (!textBlock) {
|
|
textBlock = dom.create(blockName);
|
|
fragment.appendChild(textBlock);
|
|
}
|
|
textBlock.appendChild(node);
|
|
} else {
|
|
fragment.appendChild(node);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!blockName) {
|
|
fragment.appendChild(dom.create('br'));
|
|
} else {
|
|
if (!hasContentNode) {
|
|
textBlock.appendChild(dom.create('br', { 'data-mce-bogus': '1' }));
|
|
}
|
|
}
|
|
return fragment;
|
|
};
|
|
|
|
var DOM$2 = global$3.DOM;
|
|
var splitList = function (editor, list, li) {
|
|
var removeAndKeepBookmarks = function (targetNode) {
|
|
global$2.each(bookmarks, function (node) {
|
|
targetNode.parentNode.insertBefore(node, li.parentNode);
|
|
});
|
|
DOM$2.remove(targetNode);
|
|
};
|
|
var bookmarks = DOM$2.select('span[data-mce-type="bookmark"]', list);
|
|
var newBlock = createTextBlock(editor, li);
|
|
var tmpRng = DOM$2.createRng();
|
|
tmpRng.setStartAfter(li);
|
|
tmpRng.setEndAfter(list);
|
|
var fragment = tmpRng.extractContents();
|
|
for (var node = fragment.firstChild; node; node = node.firstChild) {
|
|
if (node.nodeName === 'LI' && editor.dom.isEmpty(node)) {
|
|
DOM$2.remove(node);
|
|
break;
|
|
}
|
|
}
|
|
if (!editor.dom.isEmpty(fragment)) {
|
|
DOM$2.insertAfter(fragment, list);
|
|
}
|
|
DOM$2.insertAfter(newBlock, list);
|
|
if (isEmpty(editor.dom, li.parentNode)) {
|
|
removeAndKeepBookmarks(li.parentNode);
|
|
}
|
|
DOM$2.remove(li);
|
|
if (isEmpty(editor.dom, list)) {
|
|
DOM$2.remove(list);
|
|
}
|
|
};
|
|
|
|
var isDescriptionDetail = isTag('dd');
|
|
var isDescriptionTerm = isTag('dt');
|
|
var outdentDlItem = function (editor, item) {
|
|
if (isDescriptionDetail(item)) {
|
|
mutate(item, 'dt');
|
|
} else if (isDescriptionTerm(item)) {
|
|
parent(item).each(function (dl) {
|
|
return splitList(editor, dl.dom, item.dom);
|
|
});
|
|
}
|
|
};
|
|
var indentDlItem = function (item) {
|
|
if (isDescriptionTerm(item)) {
|
|
mutate(item, 'dd');
|
|
}
|
|
};
|
|
var dlIndentation = function (editor, indentation, dlItems) {
|
|
if (indentation === 'Indent') {
|
|
each$1(dlItems, indentDlItem);
|
|
} else {
|
|
each$1(dlItems, function (item) {
|
|
return outdentDlItem(editor, item);
|
|
});
|
|
}
|
|
};
|
|
|
|
var getNormalizedPoint = function (container, offset) {
|
|
if (isTextNode(container)) {
|
|
return {
|
|
container: container,
|
|
offset: offset
|
|
};
|
|
}
|
|
var node = global$6.getNode(container, offset);
|
|
if (isTextNode(node)) {
|
|
return {
|
|
container: node,
|
|
offset: offset >= container.childNodes.length ? node.data.length : 0
|
|
};
|
|
} else if (node.previousSibling && isTextNode(node.previousSibling)) {
|
|
return {
|
|
container: node.previousSibling,
|
|
offset: node.previousSibling.data.length
|
|
};
|
|
} else if (node.nextSibling && isTextNode(node.nextSibling)) {
|
|
return {
|
|
container: node.nextSibling,
|
|
offset: 0
|
|
};
|
|
}
|
|
return {
|
|
container: container,
|
|
offset: offset
|
|
};
|
|
};
|
|
var normalizeRange = function (rng) {
|
|
var outRng = rng.cloneRange();
|
|
var rangeStart = getNormalizedPoint(rng.startContainer, rng.startOffset);
|
|
outRng.setStart(rangeStart.container, rangeStart.offset);
|
|
var rangeEnd = getNormalizedPoint(rng.endContainer, rng.endOffset);
|
|
outRng.setEnd(rangeEnd.container, rangeEnd.offset);
|
|
return outRng;
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DomQuery');
|
|
|
|
var getParentList = function (editor, node) {
|
|
var selectionStart = node || editor.selection.getStart(true);
|
|
return editor.dom.getParent(selectionStart, 'OL,UL,DL', getClosestListRootElm(editor, selectionStart));
|
|
};
|
|
var isParentListSelected = function (parentList, selectedBlocks) {
|
|
return parentList && selectedBlocks.length === 1 && selectedBlocks[0] === parentList;
|
|
};
|
|
var findSubLists = function (parentList) {
|
|
return filter$1(parentList.querySelectorAll('ol,ul,dl'), isListNode);
|
|
};
|
|
var getSelectedSubLists = function (editor) {
|
|
var parentList = getParentList(editor);
|
|
var selectedBlocks = editor.selection.getSelectedBlocks();
|
|
if (isParentListSelected(parentList, selectedBlocks)) {
|
|
return findSubLists(parentList);
|
|
} else {
|
|
return filter$1(selectedBlocks, function (elm) {
|
|
return isListNode(elm) && parentList !== elm;
|
|
});
|
|
}
|
|
};
|
|
var findParentListItemsNodes = function (editor, elms) {
|
|
var listItemsElms = global$2.map(elms, function (elm) {
|
|
var parentLi = editor.dom.getParent(elm, 'li,dd,dt', getClosestListRootElm(editor, elm));
|
|
return parentLi ? parentLi : elm;
|
|
});
|
|
return global$1.unique(listItemsElms);
|
|
};
|
|
var getSelectedListItems = function (editor) {
|
|
var selectedBlocks = editor.selection.getSelectedBlocks();
|
|
return filter$1(findParentListItemsNodes(editor, selectedBlocks), isListItemNode);
|
|
};
|
|
var getSelectedDlItems = function (editor) {
|
|
return filter$1(getSelectedListItems(editor), isDlItemNode);
|
|
};
|
|
var getClosestListRootElm = function (editor, elm) {
|
|
var parentTableCell = editor.dom.getParents(elm, 'TD,TH');
|
|
return parentTableCell.length > 0 ? parentTableCell[0] : editor.getBody();
|
|
};
|
|
var findLastParentListNode = function (editor, elm) {
|
|
var parentLists = editor.dom.getParents(elm, 'ol,ul', getClosestListRootElm(editor, elm));
|
|
return last(parentLists);
|
|
};
|
|
var getSelectedLists = function (editor) {
|
|
var firstList = findLastParentListNode(editor, editor.selection.getStart());
|
|
var subsequentLists = filter$1(editor.selection.getSelectedBlocks(), isOlUlNode);
|
|
return firstList.toArray().concat(subsequentLists);
|
|
};
|
|
var getSelectedListRoots = function (editor) {
|
|
var selectedLists = getSelectedLists(editor);
|
|
return getUniqueListRoots(editor, selectedLists);
|
|
};
|
|
var getUniqueListRoots = function (editor, lists) {
|
|
var listRoots = map(lists, function (list) {
|
|
return findLastParentListNode(editor, list).getOr(list);
|
|
});
|
|
return global$1.unique(listRoots);
|
|
};
|
|
|
|
var is = function (lhs, rhs, comparator) {
|
|
if (comparator === void 0) {
|
|
comparator = tripleEquals;
|
|
}
|
|
return lhs.exists(function (left) {
|
|
return comparator(left, rhs);
|
|
});
|
|
};
|
|
var lift2 = function (oa, ob, f) {
|
|
return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
|
|
};
|
|
|
|
var fromElements = function (elements, scope) {
|
|
var doc = scope || document;
|
|
var fragment = doc.createDocumentFragment();
|
|
each$1(elements, function (element) {
|
|
fragment.appendChild(element.dom);
|
|
});
|
|
return SugarElement.fromDom(fragment);
|
|
};
|
|
|
|
var fireListEvent = function (editor, action, element) {
|
|
return editor.fire('ListMutation', {
|
|
action: action,
|
|
element: element
|
|
});
|
|
};
|
|
|
|
var isSupported = function (dom) {
|
|
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
};
|
|
|
|
var internalSet = function (dom, property, value) {
|
|
if (!isString(value)) {
|
|
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('CSS value must be a string: ' + value);
|
|
}
|
|
if (isSupported(dom)) {
|
|
dom.style.setProperty(property, value);
|
|
}
|
|
};
|
|
var set = function (element, property, value) {
|
|
var dom = element.dom;
|
|
internalSet(dom, property, value);
|
|
};
|
|
|
|
var joinSegment = function (parent, child) {
|
|
append$1(parent.item, child.list);
|
|
};
|
|
var joinSegments = function (segments) {
|
|
for (var i = 1; i < segments.length; i++) {
|
|
joinSegment(segments[i - 1], segments[i]);
|
|
}
|
|
};
|
|
var appendSegments = function (head$1, tail) {
|
|
lift2(last(head$1), head(tail), joinSegment);
|
|
};
|
|
var createSegment = function (scope, listType) {
|
|
var segment = {
|
|
list: SugarElement.fromTag(listType, scope),
|
|
item: SugarElement.fromTag('li', scope)
|
|
};
|
|
append$1(segment.list, segment.item);
|
|
return segment;
|
|
};
|
|
var createSegments = function (scope, entry, size) {
|
|
var segments = [];
|
|
for (var i = 0; i < size; i++) {
|
|
segments.push(createSegment(scope, entry.listType));
|
|
}
|
|
return segments;
|
|
};
|
|
var populateSegments = function (segments, entry) {
|
|
for (var i = 0; i < segments.length - 1; i++) {
|
|
set(segments[i].item, 'list-style-type', 'none');
|
|
}
|
|
last(segments).each(function (segment) {
|
|
setAll(segment.list, entry.listAttributes);
|
|
setAll(segment.item, entry.itemAttributes);
|
|
append(segment.item, entry.content);
|
|
});
|
|
};
|
|
var normalizeSegment = function (segment, entry) {
|
|
if (name(segment.list) !== entry.listType) {
|
|
segment.list = mutate(segment.list, entry.listType);
|
|
}
|
|
setAll(segment.list, entry.listAttributes);
|
|
};
|
|
var createItem = function (scope, attr, content) {
|
|
var item = SugarElement.fromTag('li', scope);
|
|
setAll(item, attr);
|
|
append(item, content);
|
|
return item;
|
|
};
|
|
var appendItem = function (segment, item) {
|
|
append$1(segment.list, item);
|
|
segment.item = item;
|
|
};
|
|
var writeShallow = function (scope, cast, entry) {
|
|
var newCast = cast.slice(0, entry.depth);
|
|
last(newCast).each(function (segment) {
|
|
var item = createItem(scope, entry.itemAttributes, entry.content);
|
|
appendItem(segment, item);
|
|
normalizeSegment(segment, entry);
|
|
});
|
|
return newCast;
|
|
};
|
|
var writeDeep = function (scope, cast, entry) {
|
|
var segments = createSegments(scope, entry, entry.depth - cast.length);
|
|
joinSegments(segments);
|
|
populateSegments(segments, entry);
|
|
appendSegments(cast, segments);
|
|
return cast.concat(segments);
|
|
};
|
|
var composeList = function (scope, entries) {
|
|
var cast = foldl(entries, function (cast, entry) {
|
|
return entry.depth > cast.length ? writeDeep(scope, cast, entry) : writeShallow(scope, cast, entry);
|
|
}, []);
|
|
return head(cast).map(function (segment) {
|
|
return segment.list;
|
|
});
|
|
};
|
|
|
|
var isList = function (el) {
|
|
return is$1(el, 'OL,UL');
|
|
};
|
|
var hasFirstChildList = function (el) {
|
|
return firstChild(el).exists(isList);
|
|
};
|
|
var hasLastChildList = function (el) {
|
|
return lastChild(el).exists(isList);
|
|
};
|
|
|
|
var isIndented = function (entry) {
|
|
return entry.depth > 0;
|
|
};
|
|
var isSelected = function (entry) {
|
|
return entry.isSelected;
|
|
};
|
|
var cloneItemContent = function (li) {
|
|
var children$1 = children(li);
|
|
var content = hasLastChildList(li) ? children$1.slice(0, -1) : children$1;
|
|
return map(content, deep);
|
|
};
|
|
var createEntry = function (li, depth, isSelected) {
|
|
return parent(li).filter(isElement).map(function (list) {
|
|
return {
|
|
depth: depth,
|
|
dirty: false,
|
|
isSelected: isSelected,
|
|
content: cloneItemContent(li),
|
|
itemAttributes: clone$1(li),
|
|
listAttributes: clone$1(list),
|
|
listType: name(list)
|
|
};
|
|
});
|
|
};
|
|
|
|
var indentEntry = function (indentation, entry) {
|
|
switch (indentation) {
|
|
case 'Indent':
|
|
entry.depth++;
|
|
break;
|
|
case 'Outdent':
|
|
entry.depth--;
|
|
break;
|
|
case 'Flatten':
|
|
entry.depth = 0;
|
|
}
|
|
entry.dirty = true;
|
|
};
|
|
|
|
var cloneListProperties = function (target, source) {
|
|
target.listType = source.listType;
|
|
target.listAttributes = __assign({}, source.listAttributes);
|
|
};
|
|
var cleanListProperties = function (entry) {
|
|
entry.listAttributes = filter(entry.listAttributes, function (_value, key) {
|
|
return key !== 'start';
|
|
});
|
|
};
|
|
var closestSiblingEntry = function (entries, start) {
|
|
var depth = entries[start].depth;
|
|
var matches = function (entry) {
|
|
return entry.depth === depth && !entry.dirty;
|
|
};
|
|
var until = function (entry) {
|
|
return entry.depth < depth;
|
|
};
|
|
return findUntil(reverse(entries.slice(0, start)), matches, until).orThunk(function () {
|
|
return findUntil(entries.slice(start + 1), matches, until);
|
|
});
|
|
};
|
|
var normalizeEntries = function (entries) {
|
|
each$1(entries, function (entry, i) {
|
|
closestSiblingEntry(entries, i).fold(function () {
|
|
if (entry.dirty) {
|
|
cleanListProperties(entry);
|
|
}
|
|
}, function (matchingEntry) {
|
|
return cloneListProperties(entry, matchingEntry);
|
|
});
|
|
});
|
|
return entries;
|
|
};
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var parseItem = function (depth, itemSelection, selectionState, item) {
|
|
return firstChild(item).filter(isList).fold(function () {
|
|
itemSelection.each(function (selection) {
|
|
if (eq(selection.start, item)) {
|
|
selectionState.set(true);
|
|
}
|
|
});
|
|
var currentItemEntry = createEntry(item, depth, selectionState.get());
|
|
itemSelection.each(function (selection) {
|
|
if (eq(selection.end, item)) {
|
|
selectionState.set(false);
|
|
}
|
|
});
|
|
var childListEntries = lastChild(item).filter(isList).map(function (list) {
|
|
return parseList(depth, itemSelection, selectionState, list);
|
|
}).getOr([]);
|
|
return currentItemEntry.toArray().concat(childListEntries);
|
|
}, function (list) {
|
|
return parseList(depth, itemSelection, selectionState, list);
|
|
});
|
|
};
|
|
var parseList = function (depth, itemSelection, selectionState, list) {
|
|
return bind(children(list), function (element) {
|
|
var parser = isList(element) ? parseList : parseItem;
|
|
var newDepth = depth + 1;
|
|
return parser(newDepth, itemSelection, selectionState, element);
|
|
});
|
|
};
|
|
var parseLists = function (lists, itemSelection) {
|
|
var selectionState = Cell(false);
|
|
var initialDepth = 0;
|
|
return map(lists, function (list) {
|
|
return {
|
|
sourceList: list,
|
|
entries: parseList(initialDepth, itemSelection, selectionState, list)
|
|
};
|
|
});
|
|
};
|
|
|
|
var outdentedComposer = function (editor, entries) {
|
|
var normalizedEntries = normalizeEntries(entries);
|
|
return map(normalizedEntries, function (entry) {
|
|
var content = fromElements(entry.content);
|
|
return SugarElement.fromDom(createTextBlock(editor, content.dom));
|
|
});
|
|
};
|
|
var indentedComposer = function (editor, entries) {
|
|
var normalizedEntries = normalizeEntries(entries);
|
|
return composeList(editor.contentDocument, normalizedEntries).toArray();
|
|
};
|
|
var composeEntries = function (editor, entries) {
|
|
return bind(groupBy(entries, isIndented), function (entries) {
|
|
var groupIsIndented = head(entries).exists(isIndented);
|
|
return groupIsIndented ? indentedComposer(editor, entries) : outdentedComposer(editor, entries);
|
|
});
|
|
};
|
|
var indentSelectedEntries = function (entries, indentation) {
|
|
each$1(filter$1(entries, isSelected), function (entry) {
|
|
return indentEntry(indentation, entry);
|
|
});
|
|
};
|
|
var getItemSelection = function (editor) {
|
|
var selectedListItems = map(getSelectedListItems(editor), SugarElement.fromDom);
|
|
return lift2(find$1(selectedListItems, not(hasFirstChildList)), find$1(reverse(selectedListItems), not(hasFirstChildList)), function (start, end) {
|
|
return {
|
|
start: start,
|
|
end: end
|
|
};
|
|
});
|
|
};
|
|
var listIndentation = function (editor, lists, indentation) {
|
|
var entrySets = parseLists(lists, getItemSelection(editor));
|
|
each$1(entrySets, function (entrySet) {
|
|
indentSelectedEntries(entrySet.entries, indentation);
|
|
var composedLists = composeEntries(editor, entrySet.entries);
|
|
each$1(composedLists, function (composedList) {
|
|
fireListEvent(editor, indentation === 'Indent' ? 'IndentList' : 'OutdentList', composedList.dom);
|
|
});
|
|
before(entrySet.sourceList, composedLists);
|
|
remove(entrySet.sourceList);
|
|
});
|
|
};
|
|
|
|
var selectionIndentation = function (editor, indentation) {
|
|
var lists = map(getSelectedListRoots(editor), SugarElement.fromDom);
|
|
var dlItems = map(getSelectedDlItems(editor), SugarElement.fromDom);
|
|
var isHandled = false;
|
|
if (lists.length || dlItems.length) {
|
|
var bookmark = editor.selection.getBookmark();
|
|
listIndentation(editor, lists, indentation);
|
|
dlIndentation(editor, indentation, dlItems);
|
|
editor.selection.moveToBookmark(bookmark);
|
|
editor.selection.setRng(normalizeRange(editor.selection.getRng()));
|
|
editor.nodeChanged();
|
|
isHandled = true;
|
|
}
|
|
return isHandled;
|
|
};
|
|
var indentListSelection = function (editor) {
|
|
return selectionIndentation(editor, 'Indent');
|
|
};
|
|
var outdentListSelection = function (editor) {
|
|
return selectionIndentation(editor, 'Outdent');
|
|
};
|
|
var flattenListSelection = function (editor) {
|
|
return selectionIndentation(editor, 'Flatten');
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.dom.BookmarkManager');
|
|
|
|
var DOM$1 = global$3.DOM;
|
|
var createBookmark = function (rng) {
|
|
var bookmark = {};
|
|
var setupEndPoint = function (start) {
|
|
var container = rng[start ? 'startContainer' : 'endContainer'];
|
|
var offset = rng[start ? 'startOffset' : 'endOffset'];
|
|
if (container.nodeType === 1) {
|
|
var offsetNode = DOM$1.create('span', { 'data-mce-type': 'bookmark' });
|
|
if (container.hasChildNodes()) {
|
|
offset = Math.min(offset, container.childNodes.length - 1);
|
|
if (start) {
|
|
container.insertBefore(offsetNode, container.childNodes[offset]);
|
|
} else {
|
|
DOM$1.insertAfter(offsetNode, container.childNodes[offset]);
|
|
}
|
|
} else {
|
|
container.appendChild(offsetNode);
|
|
}
|
|
container = offsetNode;
|
|
offset = 0;
|
|
}
|
|
bookmark[start ? 'startContainer' : 'endContainer'] = container;
|
|
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
|
|
};
|
|
setupEndPoint(true);
|
|
if (!rng.collapsed) {
|
|
setupEndPoint();
|
|
}
|
|
return bookmark;
|
|
};
|
|
var resolveBookmark = function (bookmark) {
|
|
var restoreEndPoint = function (start) {
|
|
var node;
|
|
var nodeIndex = function (container) {
|
|
var node = container.parentNode.firstChild, idx = 0;
|
|
while (node) {
|
|
if (node === container) {
|
|
return idx;
|
|
}
|
|
if (node.nodeType !== 1 || node.getAttribute('data-mce-type') !== 'bookmark') {
|
|
idx++;
|
|
}
|
|
node = node.nextSibling;
|
|
}
|
|
return -1;
|
|
};
|
|
var container = node = bookmark[start ? 'startContainer' : 'endContainer'];
|
|
var offset = bookmark[start ? 'startOffset' : 'endOffset'];
|
|
if (!container) {
|
|
return;
|
|
}
|
|
if (container.nodeType === 1) {
|
|
offset = nodeIndex(container);
|
|
container = container.parentNode;
|
|
DOM$1.remove(node);
|
|
if (!container.hasChildNodes() && DOM$1.isBlock(container)) {
|
|
container.appendChild(DOM$1.create('br'));
|
|
}
|
|
}
|
|
bookmark[start ? 'startContainer' : 'endContainer'] = container;
|
|
bookmark[start ? 'startOffset' : 'endOffset'] = offset;
|
|
};
|
|
restoreEndPoint(true);
|
|
restoreEndPoint();
|
|
var rng = DOM$1.createRng();
|
|
rng.setStart(bookmark.startContainer, bookmark.startOffset);
|
|
if (bookmark.endContainer) {
|
|
rng.setEnd(bookmark.endContainer, bookmark.endOffset);
|
|
}
|
|
return normalizeRange(rng);
|
|
};
|
|
|
|
var listToggleActionFromListName = function (listName) {
|
|
switch (listName) {
|
|
case 'UL':
|
|
return 'ToggleUlList';
|
|
case 'OL':
|
|
return 'ToggleOlList';
|
|
case 'DL':
|
|
return 'ToggleDLList';
|
|
}
|
|
};
|
|
|
|
var isCustomList = function (list) {
|
|
return /\btox\-/.test(list.className);
|
|
};
|
|
var listState = function (editor, listName, activate) {
|
|
var nodeChangeHandler = function (e) {
|
|
var inList = findUntil(e.parents, isListNode, isTableCellNode).filter(function (list) {
|
|
return list.nodeName === listName && !isCustomList(list);
|
|
}).isSome();
|
|
activate(inList);
|
|
};
|
|
var parents = editor.dom.getParents(editor.selection.getNode());
|
|
nodeChangeHandler({ parents: parents });
|
|
editor.on('NodeChange', nodeChangeHandler);
|
|
return function () {
|
|
return editor.off('NodeChange', nodeChangeHandler);
|
|
};
|
|
};
|
|
|
|
var updateListStyle = function (dom, el, detail) {
|
|
var type = detail['list-style-type'] ? detail['list-style-type'] : null;
|
|
dom.setStyle(el, 'list-style-type', type);
|
|
};
|
|
var setAttribs = function (elm, attrs) {
|
|
global$2.each(attrs, function (value, key) {
|
|
elm.setAttribute(key, value);
|
|
});
|
|
};
|
|
var updateListAttrs = function (dom, el, detail) {
|
|
setAttribs(el, detail['list-attributes']);
|
|
global$2.each(dom.select('li', el), function (li) {
|
|
setAttribs(li, detail['list-item-attributes']);
|
|
});
|
|
};
|
|
var updateListWithDetails = function (dom, el, detail) {
|
|
updateListStyle(dom, el, detail);
|
|
updateListAttrs(dom, el, detail);
|
|
};
|
|
var removeStyles = function (dom, element, styles) {
|
|
global$2.each(styles, function (style) {
|
|
var _a;
|
|
return dom.setStyle(element, (_a = {}, _a[style] = '', _a));
|
|
});
|
|
};
|
|
var getEndPointNode = function (editor, rng, start, root) {
|
|
var container = rng[start ? 'startContainer' : 'endContainer'];
|
|
var offset = rng[start ? 'startOffset' : 'endOffset'];
|
|
if (container.nodeType === 1) {
|
|
container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
|
|
}
|
|
if (!start && isBr(container.nextSibling)) {
|
|
container = container.nextSibling;
|
|
}
|
|
while (container.parentNode !== root) {
|
|
if (isTextBlock(editor, container)) {
|
|
return container;
|
|
}
|
|
if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
|
|
return container;
|
|
}
|
|
container = container.parentNode;
|
|
}
|
|
return container;
|
|
};
|
|
var getSelectedTextBlocks = function (editor, rng, root) {
|
|
var textBlocks = [];
|
|
var dom = editor.dom;
|
|
var startNode = getEndPointNode(editor, rng, true, root);
|
|
var endNode = getEndPointNode(editor, rng, false, root);
|
|
var block;
|
|
var siblings = [];
|
|
for (var node = startNode; node; node = node.nextSibling) {
|
|
siblings.push(node);
|
|
if (node === endNode) {
|
|
break;
|
|
}
|
|
}
|
|
global$2.each(siblings, function (node) {
|
|
if (isTextBlock(editor, node)) {
|
|
textBlocks.push(node);
|
|
block = null;
|
|
return;
|
|
}
|
|
if (dom.isBlock(node) || isBr(node)) {
|
|
if (isBr(node)) {
|
|
dom.remove(node);
|
|
}
|
|
block = null;
|
|
return;
|
|
}
|
|
var nextSibling = node.nextSibling;
|
|
if (global.isBookmarkNode(node)) {
|
|
if (isListNode(nextSibling) || isTextBlock(editor, nextSibling) || !nextSibling && node.parentNode === root) {
|
|
block = null;
|
|
return;
|
|
}
|
|
}
|
|
if (!block) {
|
|
block = dom.create('p');
|
|
node.parentNode.insertBefore(block, node);
|
|
textBlocks.push(block);
|
|
}
|
|
block.appendChild(node);
|
|
});
|
|
return textBlocks;
|
|
};
|
|
var hasCompatibleStyle = function (dom, sib, detail) {
|
|
var sibStyle = dom.getStyle(sib, 'list-style-type');
|
|
var detailStyle = detail ? detail['list-style-type'] : '';
|
|
detailStyle = detailStyle === null ? '' : detailStyle;
|
|
return sibStyle === detailStyle;
|
|
};
|
|
var applyList = function (editor, listName, detail) {
|
|
var rng = editor.selection.getRng();
|
|
var listItemName = 'LI';
|
|
var root = getClosestListRootElm(editor, editor.selection.getStart(true));
|
|
var dom = editor.dom;
|
|
if (dom.getContentEditable(editor.selection.getNode()) === 'false') {
|
|
return;
|
|
}
|
|
listName = listName.toUpperCase();
|
|
if (listName === 'DL') {
|
|
listItemName = 'DT';
|
|
}
|
|
var bookmark = createBookmark(rng);
|
|
var selectedTextBlocks = getSelectedTextBlocks(editor, rng, root);
|
|
global$2.each(selectedTextBlocks, function (block) {
|
|
var listBlock;
|
|
var sibling = block.previousSibling;
|
|
var parent = block.parentNode;
|
|
if (!isListItemNode(parent)) {
|
|
if (sibling && isListNode(sibling) && sibling.nodeName === listName && hasCompatibleStyle(dom, sibling, detail)) {
|
|
listBlock = sibling;
|
|
block = dom.rename(block, listItemName);
|
|
sibling.appendChild(block);
|
|
} else {
|
|
listBlock = dom.create(listName);
|
|
block.parentNode.insertBefore(listBlock, block);
|
|
listBlock.appendChild(block);
|
|
block = dom.rename(block, listItemName);
|
|
}
|
|
removeStyles(dom, block, [
|
|
'margin',
|
|
'margin-right',
|
|
'margin-bottom',
|
|
'margin-left',
|
|
'margin-top',
|
|
'padding',
|
|
'padding-right',
|
|
'padding-bottom',
|
|
'padding-left',
|
|
'padding-top'
|
|
]);
|
|
updateListWithDetails(dom, listBlock, detail);
|
|
mergeWithAdjacentLists(editor.dom, listBlock);
|
|
}
|
|
});
|
|
editor.selection.setRng(resolveBookmark(bookmark));
|
|
};
|
|
var isValidLists = function (list1, list2) {
|
|
return list1 && list2 && isListNode(list1) && list1.nodeName === list2.nodeName;
|
|
};
|
|
var hasSameListStyle = function (dom, list1, list2) {
|
|
var targetStyle = dom.getStyle(list1, 'list-style-type', true);
|
|
var style = dom.getStyle(list2, 'list-style-type', true);
|
|
return targetStyle === style;
|
|
};
|
|
var hasSameClasses = function (elm1, elm2) {
|
|
return elm1.className === elm2.className;
|
|
};
|
|
var shouldMerge = function (dom, list1, list2) {
|
|
return isValidLists(list1, list2) && hasSameListStyle(dom, list1, list2) && hasSameClasses(list1, list2);
|
|
};
|
|
var mergeWithAdjacentLists = function (dom, listBlock) {
|
|
var sibling, node;
|
|
sibling = listBlock.nextSibling;
|
|
if (shouldMerge(dom, listBlock, sibling)) {
|
|
while (node = sibling.firstChild) {
|
|
listBlock.appendChild(node);
|
|
}
|
|
dom.remove(sibling);
|
|
}
|
|
sibling = listBlock.previousSibling;
|
|
if (shouldMerge(dom, listBlock, sibling)) {
|
|
while (node = sibling.lastChild) {
|
|
listBlock.insertBefore(node, listBlock.firstChild);
|
|
}
|
|
dom.remove(sibling);
|
|
}
|
|
};
|
|
var updateList$1 = function (editor, list, listName, detail) {
|
|
if (list.nodeName !== listName) {
|
|
var newList = editor.dom.rename(list, listName);
|
|
updateListWithDetails(editor.dom, newList, detail);
|
|
fireListEvent(editor, listToggleActionFromListName(listName), newList);
|
|
} else {
|
|
updateListWithDetails(editor.dom, list, detail);
|
|
fireListEvent(editor, listToggleActionFromListName(listName), list);
|
|
}
|
|
};
|
|
var toggleMultipleLists = function (editor, parentList, lists, listName, detail) {
|
|
var parentIsList = isListNode(parentList);
|
|
if (parentIsList && parentList.nodeName === listName && !hasListStyleDetail(detail)) {
|
|
flattenListSelection(editor);
|
|
} else {
|
|
applyList(editor, listName, detail);
|
|
var bookmark = createBookmark(editor.selection.getRng());
|
|
var allLists = parentIsList ? __spreadArray([parentList], lists, true) : lists;
|
|
global$2.each(allLists, function (elm) {
|
|
updateList$1(editor, elm, listName, detail);
|
|
});
|
|
editor.selection.setRng(resolveBookmark(bookmark));
|
|
}
|
|
};
|
|
var hasListStyleDetail = function (detail) {
|
|
return 'list-style-type' in detail;
|
|
};
|
|
var toggleSingleList = function (editor, parentList, listName, detail) {
|
|
if (parentList === editor.getBody()) {
|
|
return;
|
|
}
|
|
if (parentList) {
|
|
if (parentList.nodeName === listName && !hasListStyleDetail(detail) && !isCustomList(parentList)) {
|
|
flattenListSelection(editor);
|
|
} else {
|
|
var bookmark = createBookmark(editor.selection.getRng());
|
|
updateListWithDetails(editor.dom, parentList, detail);
|
|
var newList = editor.dom.rename(parentList, listName);
|
|
mergeWithAdjacentLists(editor.dom, newList);
|
|
editor.selection.setRng(resolveBookmark(bookmark));
|
|
applyList(editor, listName, detail);
|
|
fireListEvent(editor, listToggleActionFromListName(listName), newList);
|
|
}
|
|
} else {
|
|
applyList(editor, listName, detail);
|
|
fireListEvent(editor, listToggleActionFromListName(listName), parentList);
|
|
}
|
|
};
|
|
var toggleList = function (editor, listName, _detail) {
|
|
var parentList = getParentList(editor);
|
|
var selectedSubLists = getSelectedSubLists(editor);
|
|
var detail = isObject(_detail) ? _detail : {};
|
|
if (selectedSubLists.length > 0) {
|
|
toggleMultipleLists(editor, parentList, selectedSubLists, listName, detail);
|
|
} else {
|
|
toggleSingleList(editor, parentList, listName, detail);
|
|
}
|
|
};
|
|
|
|
var DOM = global$3.DOM;
|
|
var normalizeList = function (dom, list) {
|
|
var parentNode = list.parentNode;
|
|
if (parentNode.nodeName === 'LI' && parentNode.firstChild === list) {
|
|
var sibling = parentNode.previousSibling;
|
|
if (sibling && sibling.nodeName === 'LI') {
|
|
sibling.appendChild(list);
|
|
if (isEmpty(dom, parentNode)) {
|
|
DOM.remove(parentNode);
|
|
}
|
|
} else {
|
|
DOM.setStyle(parentNode, 'listStyleType', 'none');
|
|
}
|
|
}
|
|
if (isListNode(parentNode)) {
|
|
var sibling = parentNode.previousSibling;
|
|
if (sibling && sibling.nodeName === 'LI') {
|
|
sibling.appendChild(list);
|
|
}
|
|
}
|
|
};
|
|
var normalizeLists = function (dom, element) {
|
|
var lists = global$2.grep(dom.select('ol,ul', element));
|
|
global$2.each(lists, function (list) {
|
|
normalizeList(dom, list);
|
|
});
|
|
};
|
|
|
|
var findNextCaretContainer = function (editor, rng, isForward, root) {
|
|
var node = rng.startContainer;
|
|
var offset = rng.startOffset;
|
|
if (isTextNode(node) && (isForward ? offset < node.data.length : offset > 0)) {
|
|
return node;
|
|
}
|
|
var nonEmptyBlocks = editor.schema.getNonEmptyElements();
|
|
if (node.nodeType === 1) {
|
|
node = global$6.getNode(node, offset);
|
|
}
|
|
var walker = new global$5(node, root);
|
|
if (isForward) {
|
|
if (isBogusBr(editor.dom, node)) {
|
|
walker.next();
|
|
}
|
|
}
|
|
while (node = walker[isForward ? 'next' : 'prev2']()) {
|
|
if (node.nodeName === 'LI' && !node.hasChildNodes()) {
|
|
return node;
|
|
}
|
|
if (nonEmptyBlocks[node.nodeName]) {
|
|
return node;
|
|
}
|
|
if (isTextNode(node) && node.data.length > 0) {
|
|
return node;
|
|
}
|
|
}
|
|
};
|
|
var hasOnlyOneBlockChild = function (dom, elm) {
|
|
var childNodes = elm.childNodes;
|
|
return childNodes.length === 1 && !isListNode(childNodes[0]) && dom.isBlock(childNodes[0]);
|
|
};
|
|
var unwrapSingleBlockChild = function (dom, elm) {
|
|
if (hasOnlyOneBlockChild(dom, elm)) {
|
|
dom.remove(elm.firstChild, true);
|
|
}
|
|
};
|
|
var moveChildren = function (dom, fromElm, toElm) {
|
|
var node;
|
|
var targetElm = hasOnlyOneBlockChild(dom, toElm) ? toElm.firstChild : toElm;
|
|
unwrapSingleBlockChild(dom, fromElm);
|
|
if (!isEmpty(dom, fromElm, true)) {
|
|
while (node = fromElm.firstChild) {
|
|
targetElm.appendChild(node);
|
|
}
|
|
}
|
|
};
|
|
var mergeLiElements = function (dom, fromElm, toElm) {
|
|
var listNode;
|
|
var ul = fromElm.parentNode;
|
|
if (!isChildOfBody(dom, fromElm) || !isChildOfBody(dom, toElm)) {
|
|
return;
|
|
}
|
|
if (isListNode(toElm.lastChild)) {
|
|
listNode = toElm.lastChild;
|
|
}
|
|
if (ul === toElm.lastChild) {
|
|
if (isBr(ul.previousSibling)) {
|
|
dom.remove(ul.previousSibling);
|
|
}
|
|
}
|
|
var node = toElm.lastChild;
|
|
if (node && isBr(node) && fromElm.hasChildNodes()) {
|
|
dom.remove(node);
|
|
}
|
|
if (isEmpty(dom, toElm, true)) {
|
|
dom.$(toElm).empty();
|
|
}
|
|
moveChildren(dom, fromElm, toElm);
|
|
if (listNode) {
|
|
toElm.appendChild(listNode);
|
|
}
|
|
var contains$1 = contains(SugarElement.fromDom(toElm), SugarElement.fromDom(fromElm));
|
|
var nestedLists = contains$1 ? dom.getParents(fromElm, isListNode, toElm) : [];
|
|
dom.remove(fromElm);
|
|
each$1(nestedLists, function (list) {
|
|
if (isEmpty(dom, list) && list !== dom.getRoot()) {
|
|
dom.remove(list);
|
|
}
|
|
});
|
|
};
|
|
var mergeIntoEmptyLi = function (editor, fromLi, toLi) {
|
|
editor.dom.$(toLi).empty();
|
|
mergeLiElements(editor.dom, fromLi, toLi);
|
|
editor.selection.setCursorLocation(toLi, 0);
|
|
};
|
|
var mergeForward = function (editor, rng, fromLi, toLi) {
|
|
var dom = editor.dom;
|
|
if (dom.isEmpty(toLi)) {
|
|
mergeIntoEmptyLi(editor, fromLi, toLi);
|
|
} else {
|
|
var bookmark = createBookmark(rng);
|
|
mergeLiElements(dom, fromLi, toLi);
|
|
editor.selection.setRng(resolveBookmark(bookmark));
|
|
}
|
|
};
|
|
var mergeBackward = function (editor, rng, fromLi, toLi) {
|
|
var bookmark = createBookmark(rng);
|
|
mergeLiElements(editor.dom, fromLi, toLi);
|
|
var resolvedBookmark = resolveBookmark(bookmark);
|
|
editor.selection.setRng(resolvedBookmark);
|
|
};
|
|
var backspaceDeleteFromListToListCaret = function (editor, isForward) {
|
|
var dom = editor.dom, selection = editor.selection;
|
|
var selectionStartElm = selection.getStart();
|
|
var root = getClosestListRootElm(editor, selectionStartElm);
|
|
var li = dom.getParent(selection.getStart(), 'LI', root);
|
|
if (li) {
|
|
var ul = li.parentNode;
|
|
if (ul === editor.getBody() && isEmpty(dom, ul)) {
|
|
return true;
|
|
}
|
|
var rng_1 = normalizeRange(selection.getRng());
|
|
var otherLi_1 = dom.getParent(findNextCaretContainer(editor, rng_1, isForward, root), 'LI', root);
|
|
if (otherLi_1 && otherLi_1 !== li) {
|
|
editor.undoManager.transact(function () {
|
|
if (isForward) {
|
|
mergeForward(editor, rng_1, otherLi_1, li);
|
|
} else {
|
|
if (isFirstChild(li)) {
|
|
outdentListSelection(editor);
|
|
} else {
|
|
mergeBackward(editor, rng_1, li, otherLi_1);
|
|
}
|
|
}
|
|
});
|
|
return true;
|
|
} else if (!otherLi_1) {
|
|
if (!isForward && rng_1.startOffset === 0 && rng_1.endOffset === 0) {
|
|
editor.undoManager.transact(function () {
|
|
flattenListSelection(editor);
|
|
});
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var removeBlock = function (dom, block, root) {
|
|
var parentBlock = dom.getParent(block.parentNode, dom.isBlock, root);
|
|
dom.remove(block);
|
|
if (parentBlock && dom.isEmpty(parentBlock)) {
|
|
dom.remove(parentBlock);
|
|
}
|
|
};
|
|
var backspaceDeleteIntoListCaret = function (editor, isForward) {
|
|
var dom = editor.dom;
|
|
var selectionStartElm = editor.selection.getStart();
|
|
var root = getClosestListRootElm(editor, selectionStartElm);
|
|
var block = dom.getParent(selectionStartElm, dom.isBlock, root);
|
|
if (block && dom.isEmpty(block)) {
|
|
var rng = normalizeRange(editor.selection.getRng());
|
|
var otherLi_2 = dom.getParent(findNextCaretContainer(editor, rng, isForward, root), 'LI', root);
|
|
if (otherLi_2) {
|
|
editor.undoManager.transact(function () {
|
|
removeBlock(dom, block, root);
|
|
mergeWithAdjacentLists(dom, otherLi_2.parentNode);
|
|
editor.selection.select(otherLi_2, true);
|
|
editor.selection.collapse(isForward);
|
|
});
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var backspaceDeleteCaret = function (editor, isForward) {
|
|
return backspaceDeleteFromListToListCaret(editor, isForward) || backspaceDeleteIntoListCaret(editor, isForward);
|
|
};
|
|
var backspaceDeleteRange = function (editor) {
|
|
var selectionStartElm = editor.selection.getStart();
|
|
var root = getClosestListRootElm(editor, selectionStartElm);
|
|
var startListParent = editor.dom.getParent(selectionStartElm, 'LI,DT,DD', root);
|
|
if (startListParent || getSelectedListItems(editor).length > 0) {
|
|
editor.undoManager.transact(function () {
|
|
editor.execCommand('Delete');
|
|
normalizeLists(editor.dom, editor.getBody());
|
|
});
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
var backspaceDelete = function (editor, isForward) {
|
|
return editor.selection.isCollapsed() ? backspaceDeleteCaret(editor, isForward) : backspaceDeleteRange(editor);
|
|
};
|
|
var setup$1 = function (editor) {
|
|
editor.on('keydown', function (e) {
|
|
if (e.keyCode === global$4.BACKSPACE) {
|
|
if (backspaceDelete(editor, false)) {
|
|
e.preventDefault();
|
|
}
|
|
} else if (e.keyCode === global$4.DELETE) {
|
|
if (backspaceDelete(editor, true)) {
|
|
e.preventDefault();
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
var get = function (editor) {
|
|
return {
|
|
backspaceDelete: function (isForward) {
|
|
backspaceDelete(editor, isForward);
|
|
}
|
|
};
|
|
};
|
|
|
|
var updateList = function (editor, update) {
|
|
var parentList = getParentList(editor);
|
|
editor.undoManager.transact(function () {
|
|
if (isObject(update.styles)) {
|
|
editor.dom.setStyles(parentList, update.styles);
|
|
}
|
|
if (isObject(update.attrs)) {
|
|
each(update.attrs, function (v, k) {
|
|
return editor.dom.setAttrib(parentList, k, v);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
var parseAlphabeticBase26 = function (str) {
|
|
var chars = reverse(trim(str).split(''));
|
|
var values = map(chars, function (char, i) {
|
|
var charValue = char.toUpperCase().charCodeAt(0) - 'A'.charCodeAt(0) + 1;
|
|
return Math.pow(26, i) * charValue;
|
|
});
|
|
return foldl(values, function (sum, v) {
|
|
return sum + v;
|
|
}, 0);
|
|
};
|
|
var composeAlphabeticBase26 = function (value) {
|
|
value--;
|
|
if (value < 0) {
|
|
return '';
|
|
} else {
|
|
var remainder = value % 26;
|
|
var quotient = Math.floor(value / 26);
|
|
var rest = composeAlphabeticBase26(quotient);
|
|
var char = String.fromCharCode('A'.charCodeAt(0) + remainder);
|
|
return rest + char;
|
|
}
|
|
};
|
|
var isUppercase = function (str) {
|
|
return /^[A-Z]+$/.test(str);
|
|
};
|
|
var isLowercase = function (str) {
|
|
return /^[a-z]+$/.test(str);
|
|
};
|
|
var isNumeric = function (str) {
|
|
return /^[0-9]+$/.test(str);
|
|
};
|
|
var deduceListType = function (start) {
|
|
if (isNumeric(start)) {
|
|
return 2;
|
|
} else if (isUppercase(start)) {
|
|
return 0;
|
|
} else if (isLowercase(start)) {
|
|
return 1;
|
|
} else if (isEmpty$1(start)) {
|
|
return 3;
|
|
} else {
|
|
return 4;
|
|
}
|
|
};
|
|
var parseStartValue = function (start) {
|
|
switch (deduceListType(start)) {
|
|
case 2:
|
|
return Optional.some({
|
|
listStyleType: Optional.none(),
|
|
start: start
|
|
});
|
|
case 0:
|
|
return Optional.some({
|
|
listStyleType: Optional.some('upper-alpha'),
|
|
start: parseAlphabeticBase26(start).toString()
|
|
});
|
|
case 1:
|
|
return Optional.some({
|
|
listStyleType: Optional.some('lower-alpha'),
|
|
start: parseAlphabeticBase26(start).toString()
|
|
});
|
|
case 3:
|
|
return Optional.some({
|
|
listStyleType: Optional.none(),
|
|
start: ''
|
|
});
|
|
case 4:
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var parseDetail = function (detail) {
|
|
var start = parseInt(detail.start, 10);
|
|
if (is(detail.listStyleType, 'upper-alpha')) {
|
|
return composeAlphabeticBase26(start);
|
|
} else if (is(detail.listStyleType, 'lower-alpha')) {
|
|
return composeAlphabeticBase26(start).toLowerCase();
|
|
} else {
|
|
return detail.start;
|
|
}
|
|
};
|
|
|
|
var open = function (editor) {
|
|
var currentList = getParentList(editor);
|
|
if (!isOlNode(currentList)) {
|
|
return;
|
|
}
|
|
editor.windowManager.open({
|
|
title: 'List Properties',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'input',
|
|
name: 'start',
|
|
label: 'Start list at number',
|
|
inputMode: 'numeric'
|
|
}]
|
|
},
|
|
initialData: {
|
|
start: parseDetail({
|
|
start: editor.dom.getAttrib(currentList, 'start', '1'),
|
|
listStyleType: Optional.some(editor.dom.getStyle(currentList, 'list-style-type'))
|
|
})
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
onSubmit: function (api) {
|
|
var data = api.getData();
|
|
parseStartValue(data.start).each(function (detail) {
|
|
editor.execCommand('mceListUpdate', false, {
|
|
attrs: { start: detail.start === '1' ? '' : detail.start },
|
|
styles: { 'list-style-type': detail.listStyleType.getOr('') }
|
|
});
|
|
});
|
|
api.close();
|
|
}
|
|
});
|
|
};
|
|
|
|
var queryListCommandState = function (editor, listName) {
|
|
return function () {
|
|
var parentList = getParentList(editor);
|
|
return parentList && parentList.nodeName === listName;
|
|
};
|
|
};
|
|
var registerDialog = function (editor) {
|
|
editor.addCommand('mceListProps', function () {
|
|
open(editor);
|
|
});
|
|
};
|
|
var register$2 = function (editor) {
|
|
editor.on('BeforeExecCommand', function (e) {
|
|
var cmd = e.command.toLowerCase();
|
|
if (cmd === 'indent') {
|
|
indentListSelection(editor);
|
|
} else if (cmd === 'outdent') {
|
|
outdentListSelection(editor);
|
|
}
|
|
});
|
|
editor.addCommand('InsertUnorderedList', function (ui, detail) {
|
|
toggleList(editor, 'UL', detail);
|
|
});
|
|
editor.addCommand('InsertOrderedList', function (ui, detail) {
|
|
toggleList(editor, 'OL', detail);
|
|
});
|
|
editor.addCommand('InsertDefinitionList', function (ui, detail) {
|
|
toggleList(editor, 'DL', detail);
|
|
});
|
|
editor.addCommand('RemoveList', function () {
|
|
flattenListSelection(editor);
|
|
});
|
|
registerDialog(editor);
|
|
editor.addCommand('mceListUpdate', function (ui, detail) {
|
|
if (isObject(detail)) {
|
|
updateList(editor, detail);
|
|
}
|
|
});
|
|
editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState(editor, 'UL'));
|
|
editor.addQueryStateHandler('InsertOrderedList', queryListCommandState(editor, 'OL'));
|
|
editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState(editor, 'DL'));
|
|
};
|
|
|
|
var setupTabKey = function (editor) {
|
|
editor.on('keydown', function (e) {
|
|
if (e.keyCode !== global$4.TAB || global$4.metaKeyPressed(e)) {
|
|
return;
|
|
}
|
|
editor.undoManager.transact(function () {
|
|
if (e.shiftKey ? outdentListSelection(editor) : indentListSelection(editor)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var setup = function (editor) {
|
|
if (shouldIndentOnTab(editor)) {
|
|
setupTabKey(editor);
|
|
}
|
|
setup$1(editor);
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
var exec = function (command) {
|
|
return function () {
|
|
return editor.execCommand(command);
|
|
};
|
|
};
|
|
if (!editor.hasPlugin('advlist')) {
|
|
editor.ui.registry.addToggleButton('numlist', {
|
|
icon: 'ordered-list',
|
|
active: false,
|
|
tooltip: 'Numbered list',
|
|
onAction: exec('InsertOrderedList'),
|
|
onSetup: function (api) {
|
|
return listState(editor, 'OL', api.setActive);
|
|
}
|
|
});
|
|
editor.ui.registry.addToggleButton('bullist', {
|
|
icon: 'unordered-list',
|
|
active: false,
|
|
tooltip: 'Bullet list',
|
|
onAction: exec('InsertUnorderedList'),
|
|
onSetup: function (api) {
|
|
return listState(editor, 'UL', api.setActive);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var listProperties = {
|
|
text: 'List properties...',
|
|
icon: 'ordered-list',
|
|
onAction: function () {
|
|
return editor.execCommand('mceListProps');
|
|
},
|
|
onSetup: function (api) {
|
|
return listState(editor, 'OL', function (active) {
|
|
return api.setDisabled(!active);
|
|
});
|
|
}
|
|
};
|
|
editor.ui.registry.addMenuItem('listprops', listProperties);
|
|
editor.ui.registry.addContextMenu('lists', {
|
|
update: function (node) {
|
|
var parentList = getParentList(editor, node);
|
|
return isOlNode(parentList) ? ['listprops'] : [];
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$7.add('lists', function (editor) {
|
|
if (editor.hasPlugin('rtc', true) === false) {
|
|
setup(editor);
|
|
register$2(editor);
|
|
} else {
|
|
registerDialog(editor);
|
|
}
|
|
register$1(editor);
|
|
register(editor);
|
|
return get(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$9 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isString = isType('string');
|
|
var isObject = isType('object');
|
|
var isArray = isType('array');
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var nativePush = Array.prototype.push;
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var get$1 = function (obj, key) {
|
|
return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
|
|
};
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
var getScripts = function (editor) {
|
|
return editor.getParam('media_scripts');
|
|
};
|
|
var getAudioTemplateCallback = function (editor) {
|
|
return editor.getParam('audio_template_callback');
|
|
};
|
|
var getVideoTemplateCallback = function (editor) {
|
|
return editor.getParam('video_template_callback');
|
|
};
|
|
var hasLiveEmbeds = function (editor) {
|
|
return editor.getParam('media_live_embeds', true);
|
|
};
|
|
var shouldFilterHtml = function (editor) {
|
|
return editor.getParam('media_filter_html', true);
|
|
};
|
|
var getUrlResolver = function (editor) {
|
|
return editor.getParam('media_url_resolver');
|
|
};
|
|
var hasAltSource = function (editor) {
|
|
return editor.getParam('media_alt_source', true);
|
|
};
|
|
var hasPoster = function (editor) {
|
|
return editor.getParam('media_poster', true);
|
|
};
|
|
var hasDimensions = function (editor) {
|
|
return editor.getParam('media_dimensions', true);
|
|
};
|
|
|
|
var global$8 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var global$7 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.html.SaxParser');
|
|
|
|
var getVideoScriptMatch = function (prefixes, src) {
|
|
if (prefixes) {
|
|
for (var i = 0; i < prefixes.length; i++) {
|
|
if (src.indexOf(prefixes[i].filter) !== -1) {
|
|
return prefixes[i];
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
var DOM$1 = global$7.DOM;
|
|
var trimPx = function (value) {
|
|
return value.replace(/px$/, '');
|
|
};
|
|
var getEphoxEmbedData = function (attrs) {
|
|
var style = attrs.map.style;
|
|
var styles = style ? DOM$1.parseStyle(style) : {};
|
|
return {
|
|
type: 'ephox-embed-iri',
|
|
source: attrs.map['data-ephox-embed-iri'],
|
|
altsource: '',
|
|
poster: '',
|
|
width: get$1(styles, 'max-width').map(trimPx).getOr(''),
|
|
height: get$1(styles, 'max-height').map(trimPx).getOr('')
|
|
};
|
|
};
|
|
var htmlToData = function (prefixes, html) {
|
|
var isEphoxEmbed = Cell(false);
|
|
var data = {};
|
|
global$6({
|
|
validate: false,
|
|
allow_conditional_comments: true,
|
|
start: function (name, attrs) {
|
|
if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
|
|
isEphoxEmbed.set(true);
|
|
data = getEphoxEmbedData(attrs);
|
|
} else {
|
|
if (!data.source && name === 'param') {
|
|
data.source = attrs.map.movie;
|
|
}
|
|
if (name === 'iframe' || name === 'object' || name === 'embed' || name === 'video' || name === 'audio') {
|
|
if (!data.type) {
|
|
data.type = name;
|
|
}
|
|
data = global$8.extend(attrs.map, data);
|
|
}
|
|
if (name === 'script') {
|
|
var videoScript = getVideoScriptMatch(prefixes, attrs.map.src);
|
|
if (!videoScript) {
|
|
return;
|
|
}
|
|
data = {
|
|
type: 'script',
|
|
source: attrs.map.src,
|
|
width: String(videoScript.width),
|
|
height: String(videoScript.height)
|
|
};
|
|
}
|
|
if (name === 'source') {
|
|
if (!data.source) {
|
|
data.source = attrs.map.src;
|
|
} else if (!data.altsource) {
|
|
data.altsource = attrs.map.src;
|
|
}
|
|
}
|
|
if (name === 'img' && !data.poster) {
|
|
data.poster = attrs.map.src;
|
|
}
|
|
}
|
|
}
|
|
}).parse(html);
|
|
data.source = data.source || data.src || data.data;
|
|
data.altsource = data.altsource || '';
|
|
data.poster = data.poster || '';
|
|
return data;
|
|
};
|
|
|
|
var guess = function (url) {
|
|
var mimes = {
|
|
mp3: 'audio/mpeg',
|
|
m4a: 'audio/x-m4a',
|
|
wav: 'audio/wav',
|
|
mp4: 'video/mp4',
|
|
webm: 'video/webm',
|
|
ogg: 'video/ogg',
|
|
swf: 'application/x-shockwave-flash'
|
|
};
|
|
var fileEnd = url.toLowerCase().split('.').pop();
|
|
var mime = mimes[fileEnd];
|
|
return mime ? mime : '';
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.html.Schema');
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.html.Writer');
|
|
|
|
var DOM = global$7.DOM;
|
|
var addPx = function (value) {
|
|
return /^[0-9.]+$/.test(value) ? value + 'px' : value;
|
|
};
|
|
var setAttributes = function (attrs, updatedAttrs) {
|
|
each(updatedAttrs, function (val, name) {
|
|
var value = '' + val;
|
|
if (attrs.map[name]) {
|
|
var i = attrs.length;
|
|
while (i--) {
|
|
var attr = attrs[i];
|
|
if (attr.name === name) {
|
|
if (value) {
|
|
attrs.map[name] = value;
|
|
attr.value = value;
|
|
} else {
|
|
delete attrs.map[name];
|
|
attrs.splice(i, 1);
|
|
}
|
|
}
|
|
}
|
|
} else if (value) {
|
|
attrs.push({
|
|
name: name,
|
|
value: value
|
|
});
|
|
attrs.map[name] = value;
|
|
}
|
|
});
|
|
};
|
|
var updateEphoxEmbed = function (data, attrs) {
|
|
var style = attrs.map.style;
|
|
var styleMap = style ? DOM.parseStyle(style) : {};
|
|
styleMap['max-width'] = addPx(data.width);
|
|
styleMap['max-height'] = addPx(data.height);
|
|
setAttributes(attrs, { style: DOM.serializeStyle(styleMap) });
|
|
};
|
|
var sources = [
|
|
'source',
|
|
'altsource'
|
|
];
|
|
var updateHtml = function (html, data, updateAll) {
|
|
var writer = global$4();
|
|
var isEphoxEmbed = Cell(false);
|
|
var sourceCount = 0;
|
|
var hasImage;
|
|
global$6({
|
|
validate: false,
|
|
allow_conditional_comments: true,
|
|
comment: function (text) {
|
|
writer.comment(text);
|
|
},
|
|
cdata: function (text) {
|
|
writer.cdata(text);
|
|
},
|
|
text: function (text, raw) {
|
|
writer.text(text, raw);
|
|
},
|
|
start: function (name, attrs, empty) {
|
|
if (isEphoxEmbed.get()) ; else if (has(attrs.map, 'data-ephox-embed-iri')) {
|
|
isEphoxEmbed.set(true);
|
|
updateEphoxEmbed(data, attrs);
|
|
} else {
|
|
switch (name) {
|
|
case 'video':
|
|
case 'object':
|
|
case 'embed':
|
|
case 'img':
|
|
case 'iframe':
|
|
if (data.height !== undefined && data.width !== undefined) {
|
|
setAttributes(attrs, {
|
|
width: data.width,
|
|
height: data.height
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
if (updateAll) {
|
|
switch (name) {
|
|
case 'video':
|
|
setAttributes(attrs, {
|
|
poster: data.poster,
|
|
src: ''
|
|
});
|
|
if (data.altsource) {
|
|
setAttributes(attrs, { src: '' });
|
|
}
|
|
break;
|
|
case 'iframe':
|
|
setAttributes(attrs, { src: data.source });
|
|
break;
|
|
case 'source':
|
|
if (sourceCount < 2) {
|
|
setAttributes(attrs, {
|
|
src: data[sources[sourceCount]],
|
|
type: data[sources[sourceCount] + 'mime']
|
|
});
|
|
if (!data[sources[sourceCount]]) {
|
|
return;
|
|
}
|
|
}
|
|
sourceCount++;
|
|
break;
|
|
case 'img':
|
|
if (!data.poster) {
|
|
return;
|
|
}
|
|
hasImage = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
writer.start(name, attrs, empty);
|
|
},
|
|
end: function (name) {
|
|
if (!isEphoxEmbed.get()) {
|
|
if (name === 'video' && updateAll) {
|
|
for (var index = 0; index < 2; index++) {
|
|
if (data[sources[index]]) {
|
|
var attrs = [];
|
|
attrs.map = {};
|
|
if (sourceCount <= index) {
|
|
setAttributes(attrs, {
|
|
src: data[sources[index]],
|
|
type: data[sources[index] + 'mime']
|
|
});
|
|
writer.start('source', attrs, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (data.poster && name === 'object' && updateAll && !hasImage) {
|
|
var imgAttrs = [];
|
|
imgAttrs.map = {};
|
|
setAttributes(imgAttrs, {
|
|
src: data.poster,
|
|
width: data.width,
|
|
height: data.height
|
|
});
|
|
writer.start('img', imgAttrs, true);
|
|
}
|
|
}
|
|
writer.end(name);
|
|
}
|
|
}, global$5({})).parse(html);
|
|
return writer.getContent();
|
|
};
|
|
|
|
var urlPatterns = [
|
|
{
|
|
regex: /youtu\.be\/([\w\-_\?&=.]+)/i,
|
|
type: 'iframe',
|
|
w: 560,
|
|
h: 314,
|
|
url: 'www.youtube.com/embed/$1',
|
|
allowFullscreen: true
|
|
},
|
|
{
|
|
regex: /youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,
|
|
type: 'iframe',
|
|
w: 560,
|
|
h: 314,
|
|
url: 'www.youtube.com/embed/$2?$4',
|
|
allowFullscreen: true
|
|
},
|
|
{
|
|
regex: /youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,
|
|
type: 'iframe',
|
|
w: 560,
|
|
h: 314,
|
|
url: 'www.youtube.com/embed/$1',
|
|
allowFullscreen: true
|
|
},
|
|
{
|
|
regex: /vimeo\.com\/([0-9]+)/,
|
|
type: 'iframe',
|
|
w: 425,
|
|
h: 350,
|
|
url: 'player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc',
|
|
allowFullscreen: true
|
|
},
|
|
{
|
|
regex: /vimeo\.com\/(.*)\/([0-9]+)/,
|
|
type: 'iframe',
|
|
w: 425,
|
|
h: 350,
|
|
url: 'player.vimeo.com/video/$2?title=0&byline=0',
|
|
allowFullscreen: true
|
|
},
|
|
{
|
|
regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,
|
|
type: 'iframe',
|
|
w: 425,
|
|
h: 350,
|
|
url: 'maps.google.com/maps/ms?msid=$2&output=embed"',
|
|
allowFullscreen: false
|
|
},
|
|
{
|
|
regex: /dailymotion\.com\/video\/([^_]+)/,
|
|
type: 'iframe',
|
|
w: 480,
|
|
h: 270,
|
|
url: 'www.dailymotion.com/embed/video/$1',
|
|
allowFullscreen: true
|
|
},
|
|
{
|
|
regex: /dai\.ly\/([^_]+)/,
|
|
type: 'iframe',
|
|
w: 480,
|
|
h: 270,
|
|
url: 'www.dailymotion.com/embed/video/$1',
|
|
allowFullscreen: true
|
|
}
|
|
];
|
|
var getProtocol = function (url) {
|
|
var protocolMatches = url.match(/^(https?:\/\/|www\.)(.+)$/i);
|
|
if (protocolMatches && protocolMatches.length > 1) {
|
|
return protocolMatches[1] === 'www.' ? 'https://' : protocolMatches[1];
|
|
} else {
|
|
return 'https://';
|
|
}
|
|
};
|
|
var getUrl = function (pattern, url) {
|
|
var protocol = getProtocol(url);
|
|
var match = pattern.regex.exec(url);
|
|
var newUrl = protocol + pattern.url;
|
|
var _loop_1 = function (i) {
|
|
newUrl = newUrl.replace('$' + i, function () {
|
|
return match[i] ? match[i] : '';
|
|
});
|
|
};
|
|
for (var i = 0; i < match.length; i++) {
|
|
_loop_1(i);
|
|
}
|
|
return newUrl.replace(/\?$/, '');
|
|
};
|
|
var matchPattern = function (url) {
|
|
var patterns = urlPatterns.filter(function (pattern) {
|
|
return pattern.regex.test(url);
|
|
});
|
|
if (patterns.length > 0) {
|
|
return global$8.extend({}, patterns[0], { url: getUrl(patterns[0], url) });
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
|
|
var getIframeHtml = function (data) {
|
|
var allowFullscreen = data.allowfullscreen ? ' allowFullscreen="1"' : '';
|
|
return '<iframe src="' + data.source + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>';
|
|
};
|
|
var getFlashHtml = function (data) {
|
|
var html = '<object data="' + data.source + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">';
|
|
if (data.poster) {
|
|
html += '<img src="' + data.poster + '" width="' + data.width + '" height="' + data.height + '" />';
|
|
}
|
|
html += '</object>';
|
|
return html;
|
|
};
|
|
var getAudioHtml = function (data, audioTemplateCallback) {
|
|
if (audioTemplateCallback) {
|
|
return audioTemplateCallback(data);
|
|
} else {
|
|
return '<audio controls="controls" src="' + data.source + '">' + (data.altsource ? '\n<source src="' + data.altsource + '"' + (data.altsourcemime ? ' type="' + data.altsourcemime + '"' : '') + ' />\n' : '') + '</audio>';
|
|
}
|
|
};
|
|
var getVideoHtml = function (data, videoTemplateCallback) {
|
|
if (videoTemplateCallback) {
|
|
return videoTemplateCallback(data);
|
|
} else {
|
|
return '<video width="' + data.width + '" height="' + data.height + '"' + (data.poster ? ' poster="' + data.poster + '"' : '') + ' controls="controls">\n' + '<source src="' + data.source + '"' + (data.sourcemime ? ' type="' + data.sourcemime + '"' : '') + ' />\n' + (data.altsource ? '<source src="' + data.altsource + '"' + (data.altsourcemime ? ' type="' + data.altsourcemime + '"' : '') + ' />\n' : '') + '</video>';
|
|
}
|
|
};
|
|
var getScriptHtml = function (data) {
|
|
return '<script src="' + data.source + '"></script>';
|
|
};
|
|
var dataToHtml = function (editor, dataIn) {
|
|
var data = global$8.extend({}, dataIn);
|
|
if (!data.source) {
|
|
global$8.extend(data, htmlToData(getScripts(editor), data.embed));
|
|
if (!data.source) {
|
|
return '';
|
|
}
|
|
}
|
|
if (!data.altsource) {
|
|
data.altsource = '';
|
|
}
|
|
if (!data.poster) {
|
|
data.poster = '';
|
|
}
|
|
data.source = editor.convertURL(data.source, 'source');
|
|
data.altsource = editor.convertURL(data.altsource, 'source');
|
|
data.sourcemime = guess(data.source);
|
|
data.altsourcemime = guess(data.altsource);
|
|
data.poster = editor.convertURL(data.poster, 'poster');
|
|
var pattern = matchPattern(data.source);
|
|
if (pattern) {
|
|
data.source = pattern.url;
|
|
data.type = pattern.type;
|
|
data.allowfullscreen = pattern.allowFullscreen;
|
|
data.width = data.width || String(pattern.w);
|
|
data.height = data.height || String(pattern.h);
|
|
}
|
|
if (data.embed) {
|
|
return updateHtml(data.embed, data, true);
|
|
} else {
|
|
var videoScript = getVideoScriptMatch(getScripts(editor), data.source);
|
|
if (videoScript) {
|
|
data.type = 'script';
|
|
data.width = String(videoScript.width);
|
|
data.height = String(videoScript.height);
|
|
}
|
|
var audioTemplateCallback = getAudioTemplateCallback(editor);
|
|
var videoTemplateCallback = getVideoTemplateCallback(editor);
|
|
data.width = data.width || '300';
|
|
data.height = data.height || '150';
|
|
global$8.each(data, function (value, key) {
|
|
data[key] = editor.dom.encode('' + value);
|
|
});
|
|
if (data.type === 'iframe') {
|
|
return getIframeHtml(data);
|
|
} else if (data.sourcemime === 'application/x-shockwave-flash') {
|
|
return getFlashHtml(data);
|
|
} else if (data.sourcemime.indexOf('audio') !== -1) {
|
|
return getAudioHtml(data, audioTemplateCallback);
|
|
} else if (data.type === 'script') {
|
|
return getScriptHtml(data);
|
|
} else {
|
|
return getVideoHtml(data, videoTemplateCallback);
|
|
}
|
|
}
|
|
};
|
|
|
|
var isMediaElement = function (element) {
|
|
return element.hasAttribute('data-mce-object') || element.hasAttribute('data-ephox-embed-iri');
|
|
};
|
|
var setup$2 = function (editor) {
|
|
editor.on('click keyup touchend', function () {
|
|
var selectedNode = editor.selection.getNode();
|
|
if (selectedNode && editor.dom.hasClass(selectedNode, 'mce-preview-object')) {
|
|
if (editor.dom.getAttrib(selectedNode, 'data-mce-selected')) {
|
|
selectedNode.setAttribute('data-mce-selected', '2');
|
|
}
|
|
}
|
|
});
|
|
editor.on('ObjectSelected', function (e) {
|
|
var objectType = e.target.getAttribute('data-mce-object');
|
|
if (objectType === 'script') {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
editor.on('ObjectResized', function (e) {
|
|
var target = e.target;
|
|
if (target.getAttribute('data-mce-object')) {
|
|
var html = target.getAttribute('data-mce-html');
|
|
if (html) {
|
|
html = unescape(html);
|
|
target.setAttribute('data-mce-html', escape(updateHtml(html, {
|
|
width: String(e.width),
|
|
height: String(e.height)
|
|
})));
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var cache = {};
|
|
var embedPromise = function (data, dataToHtml, handler) {
|
|
return new global$3(function (res, rej) {
|
|
var wrappedResolve = function (response) {
|
|
if (response.html) {
|
|
cache[data.source] = response;
|
|
}
|
|
return res({
|
|
url: data.source,
|
|
html: response.html ? response.html : dataToHtml(data)
|
|
});
|
|
};
|
|
if (cache[data.source]) {
|
|
wrappedResolve(cache[data.source]);
|
|
} else {
|
|
handler({ url: data.source }, wrappedResolve, rej);
|
|
}
|
|
});
|
|
};
|
|
var defaultPromise = function (data, dataToHtml) {
|
|
return global$3.resolve({
|
|
html: dataToHtml(data),
|
|
url: data.source
|
|
});
|
|
};
|
|
var loadedData = function (editor) {
|
|
return function (data) {
|
|
return dataToHtml(editor, data);
|
|
};
|
|
};
|
|
var getEmbedHtml = function (editor, data) {
|
|
var embedHandler = getUrlResolver(editor);
|
|
return embedHandler ? embedPromise(data, loadedData(editor), embedHandler) : defaultPromise(data, loadedData(editor));
|
|
};
|
|
var isCached = function (url) {
|
|
return has(cache, url);
|
|
};
|
|
|
|
var extractMeta = function (sourceInput, data) {
|
|
return get$1(data, sourceInput).bind(function (mainData) {
|
|
return get$1(mainData, 'meta');
|
|
});
|
|
};
|
|
var getValue = function (data, metaData, sourceInput) {
|
|
return function (prop) {
|
|
var _a;
|
|
var getFromData = function () {
|
|
return get$1(data, prop);
|
|
};
|
|
var getFromMetaData = function () {
|
|
return get$1(metaData, prop);
|
|
};
|
|
var getNonEmptyValue = function (c) {
|
|
return get$1(c, 'value').bind(function (v) {
|
|
return v.length > 0 ? Optional.some(v) : Optional.none();
|
|
});
|
|
};
|
|
var getFromValueFirst = function () {
|
|
return getFromData().bind(function (child) {
|
|
return isObject(child) ? getNonEmptyValue(child).orThunk(getFromMetaData) : getFromMetaData().orThunk(function () {
|
|
return Optional.from(child);
|
|
});
|
|
});
|
|
};
|
|
var getFromMetaFirst = function () {
|
|
return getFromMetaData().orThunk(function () {
|
|
return getFromData().bind(function (child) {
|
|
return isObject(child) ? getNonEmptyValue(child) : Optional.from(child);
|
|
});
|
|
});
|
|
};
|
|
return _a = {}, _a[prop] = (prop === sourceInput ? getFromValueFirst() : getFromMetaFirst()).getOr(''), _a;
|
|
};
|
|
};
|
|
var getDimensions = function (data, metaData) {
|
|
var dimensions = {};
|
|
get$1(data, 'dimensions').each(function (dims) {
|
|
each$1([
|
|
'width',
|
|
'height'
|
|
], function (prop) {
|
|
get$1(metaData, prop).orThunk(function () {
|
|
return get$1(dims, prop);
|
|
}).each(function (value) {
|
|
return dimensions[prop] = value;
|
|
});
|
|
});
|
|
});
|
|
return dimensions;
|
|
};
|
|
var unwrap = function (data, sourceInput) {
|
|
var metaData = sourceInput ? extractMeta(sourceInput, data).getOr({}) : {};
|
|
var get = getValue(data, metaData, sourceInput);
|
|
return __assign(__assign(__assign(__assign(__assign({}, get('source')), get('altsource')), get('poster')), get('embed')), getDimensions(data, metaData));
|
|
};
|
|
var wrap = function (data) {
|
|
var wrapped = __assign(__assign({}, data), {
|
|
source: { value: get$1(data, 'source').getOr('') },
|
|
altsource: { value: get$1(data, 'altsource').getOr('') },
|
|
poster: { value: get$1(data, 'poster').getOr('') }
|
|
});
|
|
each$1([
|
|
'width',
|
|
'height'
|
|
], function (prop) {
|
|
get$1(data, prop).each(function (value) {
|
|
var dimensions = wrapped.dimensions || {};
|
|
dimensions[prop] = value;
|
|
wrapped.dimensions = dimensions;
|
|
});
|
|
});
|
|
return wrapped;
|
|
};
|
|
var handleError = function (editor) {
|
|
return function (error) {
|
|
var errorMessage = error && error.msg ? 'Media embed handler error: ' + error.msg : 'Media embed handler threw unknown error.';
|
|
editor.notificationManager.open({
|
|
type: 'error',
|
|
text: errorMessage
|
|
});
|
|
};
|
|
};
|
|
var snippetToData = function (editor, embedSnippet) {
|
|
return htmlToData(getScripts(editor), embedSnippet);
|
|
};
|
|
var getEditorData = function (editor) {
|
|
var element = editor.selection.getNode();
|
|
var snippet = isMediaElement(element) ? editor.serializer.serialize(element, { selection: true }) : '';
|
|
return __assign({ embed: snippet }, htmlToData(getScripts(editor), snippet));
|
|
};
|
|
var addEmbedHtml = function (api, editor) {
|
|
return function (response) {
|
|
if (isString(response.url) && response.url.trim().length > 0) {
|
|
var html = response.html;
|
|
var snippetData = snippetToData(editor, html);
|
|
var nuData = __assign(__assign({}, snippetData), {
|
|
source: response.url,
|
|
embed: html
|
|
});
|
|
api.setData(wrap(nuData));
|
|
}
|
|
};
|
|
};
|
|
var selectPlaceholder = function (editor, beforeObjects) {
|
|
var afterObjects = editor.dom.select('*[data-mce-object]');
|
|
for (var i = 0; i < beforeObjects.length; i++) {
|
|
for (var y = afterObjects.length - 1; y >= 0; y--) {
|
|
if (beforeObjects[i] === afterObjects[y]) {
|
|
afterObjects.splice(y, 1);
|
|
}
|
|
}
|
|
}
|
|
editor.selection.select(afterObjects[0]);
|
|
};
|
|
var handleInsert = function (editor, html) {
|
|
var beforeObjects = editor.dom.select('*[data-mce-object]');
|
|
editor.insertContent(html);
|
|
selectPlaceholder(editor, beforeObjects);
|
|
editor.nodeChanged();
|
|
};
|
|
var submitForm = function (prevData, newData, editor) {
|
|
newData.embed = updateHtml(newData.embed, newData);
|
|
if (newData.embed && (prevData.source === newData.source || isCached(newData.source))) {
|
|
handleInsert(editor, newData.embed);
|
|
} else {
|
|
getEmbedHtml(editor, newData).then(function (response) {
|
|
handleInsert(editor, response.html);
|
|
}).catch(handleError(editor));
|
|
}
|
|
};
|
|
var showDialog = function (editor) {
|
|
var editorData = getEditorData(editor);
|
|
var currentData = Cell(editorData);
|
|
var initialData = wrap(editorData);
|
|
var handleSource = function (prevData, api) {
|
|
var serviceData = unwrap(api.getData(), 'source');
|
|
if (prevData.source !== serviceData.source) {
|
|
addEmbedHtml(win, editor)({
|
|
url: serviceData.source,
|
|
html: ''
|
|
});
|
|
getEmbedHtml(editor, serviceData).then(addEmbedHtml(win, editor)).catch(handleError(editor));
|
|
}
|
|
};
|
|
var handleEmbed = function (api) {
|
|
var data = unwrap(api.getData());
|
|
var dataFromEmbed = snippetToData(editor, data.embed);
|
|
api.setData(wrap(dataFromEmbed));
|
|
};
|
|
var handleUpdate = function (api, sourceInput) {
|
|
var data = unwrap(api.getData(), sourceInput);
|
|
var embed = dataToHtml(editor, data);
|
|
api.setData(wrap(__assign(__assign({}, data), { embed: embed })));
|
|
};
|
|
var mediaInput = [{
|
|
name: 'source',
|
|
type: 'urlinput',
|
|
filetype: 'media',
|
|
label: 'Source'
|
|
}];
|
|
var sizeInput = !hasDimensions(editor) ? [] : [{
|
|
type: 'sizeinput',
|
|
name: 'dimensions',
|
|
label: 'Constrain proportions',
|
|
constrain: true
|
|
}];
|
|
var generalTab = {
|
|
title: 'General',
|
|
name: 'general',
|
|
items: flatten([
|
|
mediaInput,
|
|
sizeInput
|
|
])
|
|
};
|
|
var embedTextarea = {
|
|
type: 'textarea',
|
|
name: 'embed',
|
|
label: 'Paste your embed code below:'
|
|
};
|
|
var embedTab = {
|
|
title: 'Embed',
|
|
items: [embedTextarea]
|
|
};
|
|
var advancedFormItems = [];
|
|
if (hasAltSource(editor)) {
|
|
advancedFormItems.push({
|
|
name: 'altsource',
|
|
type: 'urlinput',
|
|
filetype: 'media',
|
|
label: 'Alternative source URL'
|
|
});
|
|
}
|
|
if (hasPoster(editor)) {
|
|
advancedFormItems.push({
|
|
name: 'poster',
|
|
type: 'urlinput',
|
|
filetype: 'image',
|
|
label: 'Media poster (Image URL)'
|
|
});
|
|
}
|
|
var advancedTab = {
|
|
title: 'Advanced',
|
|
name: 'advanced',
|
|
items: advancedFormItems
|
|
};
|
|
var tabs = [
|
|
generalTab,
|
|
embedTab
|
|
];
|
|
if (advancedFormItems.length > 0) {
|
|
tabs.push(advancedTab);
|
|
}
|
|
var body = {
|
|
type: 'tabpanel',
|
|
tabs: tabs
|
|
};
|
|
var win = editor.windowManager.open({
|
|
title: 'Insert/Edit Media',
|
|
size: 'normal',
|
|
body: body,
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
onSubmit: function (api) {
|
|
var serviceData = unwrap(api.getData());
|
|
submitForm(currentData.get(), serviceData, editor);
|
|
api.close();
|
|
},
|
|
onChange: function (api, detail) {
|
|
switch (detail.name) {
|
|
case 'source':
|
|
handleSource(currentData.get(), api);
|
|
break;
|
|
case 'embed':
|
|
handleEmbed(api);
|
|
break;
|
|
case 'dimensions':
|
|
case 'altsource':
|
|
case 'poster':
|
|
handleUpdate(api, detail.name);
|
|
break;
|
|
}
|
|
currentData.set(unwrap(api.getData()));
|
|
},
|
|
initialData: initialData
|
|
});
|
|
};
|
|
|
|
var get = function (editor) {
|
|
var showDialog$1 = function () {
|
|
showDialog(editor);
|
|
};
|
|
return { showDialog: showDialog$1 };
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
var showDialog$1 = function () {
|
|
showDialog(editor);
|
|
};
|
|
editor.addCommand('mceMedia', showDialog$1);
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.html.DomParser');
|
|
|
|
var sanitize = function (editor, html) {
|
|
if (shouldFilterHtml(editor) === false) {
|
|
return html;
|
|
}
|
|
var writer = global$4();
|
|
var blocked;
|
|
global$6({
|
|
validate: false,
|
|
allow_conditional_comments: false,
|
|
comment: function (text) {
|
|
if (!blocked) {
|
|
writer.comment(text);
|
|
}
|
|
},
|
|
cdata: function (text) {
|
|
if (!blocked) {
|
|
writer.cdata(text);
|
|
}
|
|
},
|
|
text: function (text, raw) {
|
|
if (!blocked) {
|
|
writer.text(text, raw);
|
|
}
|
|
},
|
|
start: function (name, attrs, empty) {
|
|
blocked = true;
|
|
if (name === 'script' || name === 'noscript' || name === 'svg') {
|
|
return;
|
|
}
|
|
for (var i = attrs.length - 1; i >= 0; i--) {
|
|
var attrName = attrs[i].name;
|
|
if (attrName.indexOf('on') === 0) {
|
|
delete attrs.map[attrName];
|
|
attrs.splice(i, 1);
|
|
}
|
|
if (attrName === 'style') {
|
|
attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name);
|
|
}
|
|
}
|
|
writer.start(name, attrs, empty);
|
|
blocked = false;
|
|
},
|
|
end: function (name) {
|
|
if (blocked) {
|
|
return;
|
|
}
|
|
writer.end(name);
|
|
}
|
|
}, global$5({})).parse(html);
|
|
return writer.getContent();
|
|
};
|
|
|
|
var isLiveEmbedNode = function (node) {
|
|
var name = node.name;
|
|
return name === 'iframe' || name === 'video' || name === 'audio';
|
|
};
|
|
var getDimension = function (node, styles, dimension, defaultValue) {
|
|
if (defaultValue === void 0) {
|
|
defaultValue = null;
|
|
}
|
|
var value = node.attr(dimension);
|
|
if (isNonNullable(value)) {
|
|
return value;
|
|
} else if (!has(styles, dimension)) {
|
|
return defaultValue;
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
var setDimensions = function (node, previewNode, styles) {
|
|
var useDefaults = previewNode.name === 'img' || node.name === 'video';
|
|
var defaultWidth = useDefaults ? '300' : null;
|
|
var fallbackHeight = node.name === 'audio' ? '30' : '150';
|
|
var defaultHeight = useDefaults ? fallbackHeight : null;
|
|
previewNode.attr({
|
|
width: getDimension(node, styles, 'width', defaultWidth),
|
|
height: getDimension(node, styles, 'height', defaultHeight)
|
|
});
|
|
};
|
|
var appendNodeContent = function (editor, nodeName, previewNode, html) {
|
|
var newNode = global({
|
|
forced_root_block: false,
|
|
validate: false
|
|
}, editor.schema).parse(html, { context: nodeName });
|
|
while (newNode.firstChild) {
|
|
previewNode.append(newNode.firstChild);
|
|
}
|
|
};
|
|
var createPlaceholderNode = function (editor, node) {
|
|
var name = node.name;
|
|
var placeHolder = new global$2('img', 1);
|
|
placeHolder.shortEnded = true;
|
|
retainAttributesAndInnerHtml(editor, node, placeHolder);
|
|
setDimensions(node, placeHolder, {});
|
|
placeHolder.attr({
|
|
'style': node.attr('style'),
|
|
'src': global$1.transparentSrc,
|
|
'data-mce-object': name,
|
|
'class': 'mce-object mce-object-' + name
|
|
});
|
|
return placeHolder;
|
|
};
|
|
var createPreviewNode = function (editor, node) {
|
|
var name = node.name;
|
|
var previewWrapper = new global$2('span', 1);
|
|
previewWrapper.attr({
|
|
'contentEditable': 'false',
|
|
'style': node.attr('style'),
|
|
'data-mce-object': name,
|
|
'class': 'mce-preview-object mce-object-' + name
|
|
});
|
|
retainAttributesAndInnerHtml(editor, node, previewWrapper);
|
|
var styles = editor.dom.parseStyle(node.attr('style'));
|
|
var previewNode = new global$2(name, 1);
|
|
setDimensions(node, previewNode, styles);
|
|
previewNode.attr({
|
|
src: node.attr('src'),
|
|
style: node.attr('style'),
|
|
class: node.attr('class')
|
|
});
|
|
if (name === 'iframe') {
|
|
previewNode.attr({
|
|
allowfullscreen: node.attr('allowfullscreen'),
|
|
frameborder: '0'
|
|
});
|
|
} else {
|
|
var attrs = [
|
|
'controls',
|
|
'crossorigin',
|
|
'currentTime',
|
|
'loop',
|
|
'muted',
|
|
'poster',
|
|
'preload'
|
|
];
|
|
each$1(attrs, function (attrName) {
|
|
previewNode.attr(attrName, node.attr(attrName));
|
|
});
|
|
var sanitizedHtml = previewWrapper.attr('data-mce-html');
|
|
if (isNonNullable(sanitizedHtml)) {
|
|
appendNodeContent(editor, name, previewNode, unescape(sanitizedHtml));
|
|
}
|
|
}
|
|
var shimNode = new global$2('span', 1);
|
|
shimNode.attr('class', 'mce-shim');
|
|
previewWrapper.append(previewNode);
|
|
previewWrapper.append(shimNode);
|
|
return previewWrapper;
|
|
};
|
|
var retainAttributesAndInnerHtml = function (editor, sourceNode, targetNode) {
|
|
var attribs = sourceNode.attributes;
|
|
var ai = attribs.length;
|
|
while (ai--) {
|
|
var attrName = attribs[ai].name;
|
|
var attrValue = attribs[ai].value;
|
|
if (attrName !== 'width' && attrName !== 'height' && attrName !== 'style') {
|
|
if (attrName === 'data' || attrName === 'src') {
|
|
attrValue = editor.convertURL(attrValue, attrName);
|
|
}
|
|
targetNode.attr('data-mce-p-' + attrName, attrValue);
|
|
}
|
|
}
|
|
var innerHtml = sourceNode.firstChild && sourceNode.firstChild.value;
|
|
if (innerHtml) {
|
|
targetNode.attr('data-mce-html', escape(sanitize(editor, innerHtml)));
|
|
targetNode.firstChild = null;
|
|
}
|
|
};
|
|
var isPageEmbedWrapper = function (node) {
|
|
var nodeClass = node.attr('class');
|
|
return nodeClass && /\btiny-pageembed\b/.test(nodeClass);
|
|
};
|
|
var isWithinEmbedWrapper = function (node) {
|
|
while (node = node.parent) {
|
|
if (node.attr('data-ephox-embed-iri') || isPageEmbedWrapper(node)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var placeHolderConverter = function (editor) {
|
|
return function (nodes) {
|
|
var i = nodes.length;
|
|
var node;
|
|
var videoScript;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
if (!node.parent) {
|
|
continue;
|
|
}
|
|
if (node.parent.attr('data-mce-object')) {
|
|
continue;
|
|
}
|
|
if (node.name === 'script') {
|
|
videoScript = getVideoScriptMatch(getScripts(editor), node.attr('src'));
|
|
if (!videoScript) {
|
|
continue;
|
|
}
|
|
}
|
|
if (videoScript) {
|
|
if (videoScript.width) {
|
|
node.attr('width', videoScript.width.toString());
|
|
}
|
|
if (videoScript.height) {
|
|
node.attr('height', videoScript.height.toString());
|
|
}
|
|
}
|
|
if (isLiveEmbedNode(node) && hasLiveEmbeds(editor) && global$1.ceFalse) {
|
|
if (!isWithinEmbedWrapper(node)) {
|
|
node.replace(createPreviewNode(editor, node));
|
|
}
|
|
} else {
|
|
if (!isWithinEmbedWrapper(node)) {
|
|
node.replace(createPlaceholderNode(editor, node));
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
var setup$1 = function (editor) {
|
|
editor.on('preInit', function () {
|
|
var specialElements = editor.schema.getSpecialElements();
|
|
global$8.each('video audio iframe object'.split(' '), function (name) {
|
|
specialElements[name] = new RegExp('</' + name + '[^>]*>', 'gi');
|
|
});
|
|
var boolAttrs = editor.schema.getBoolAttrs();
|
|
global$8.each('webkitallowfullscreen mozallowfullscreen allowfullscreen'.split(' '), function (name) {
|
|
boolAttrs[name] = {};
|
|
});
|
|
editor.parser.addNodeFilter('iframe,video,audio,object,embed,script', placeHolderConverter(editor));
|
|
editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) {
|
|
var i = nodes.length;
|
|
var node;
|
|
var realElm;
|
|
var ai;
|
|
var attribs;
|
|
var innerHtml;
|
|
var innerNode;
|
|
var realElmName;
|
|
var className;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
if (!node.parent) {
|
|
continue;
|
|
}
|
|
realElmName = node.attr(name);
|
|
realElm = new global$2(realElmName, 1);
|
|
if (realElmName !== 'audio' && realElmName !== 'script') {
|
|
className = node.attr('class');
|
|
if (className && className.indexOf('mce-preview-object') !== -1) {
|
|
realElm.attr({
|
|
width: node.firstChild.attr('width'),
|
|
height: node.firstChild.attr('height')
|
|
});
|
|
} else {
|
|
realElm.attr({
|
|
width: node.attr('width'),
|
|
height: node.attr('height')
|
|
});
|
|
}
|
|
}
|
|
realElm.attr({ style: node.attr('style') });
|
|
attribs = node.attributes;
|
|
ai = attribs.length;
|
|
while (ai--) {
|
|
var attrName = attribs[ai].name;
|
|
if (attrName.indexOf('data-mce-p-') === 0) {
|
|
realElm.attr(attrName.substr(11), attribs[ai].value);
|
|
}
|
|
}
|
|
if (realElmName === 'script') {
|
|
realElm.attr('type', 'text/javascript');
|
|
}
|
|
innerHtml = node.attr('data-mce-html');
|
|
if (innerHtml) {
|
|
innerNode = new global$2('#text', 3);
|
|
innerNode.raw = true;
|
|
innerNode.value = sanitize(editor, unescape(innerHtml));
|
|
realElm.append(innerNode);
|
|
}
|
|
node.replace(realElm);
|
|
}
|
|
});
|
|
});
|
|
editor.on('SetContent', function () {
|
|
editor.$('span.mce-preview-object').each(function (index, elm) {
|
|
var $elm = editor.$(elm);
|
|
if ($elm.find('span.mce-shim').length === 0) {
|
|
$elm.append('<span class="mce-shim"></span>');
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
editor.on('ResolveName', function (e) {
|
|
var name;
|
|
if (e.target.nodeType === 1 && (name = e.target.getAttribute('data-mce-object'))) {
|
|
e.name = name;
|
|
}
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceMedia');
|
|
};
|
|
editor.ui.registry.addToggleButton('media', {
|
|
tooltip: 'Insert/edit media',
|
|
icon: 'embed',
|
|
onAction: onAction,
|
|
onSetup: function (buttonApi) {
|
|
var selection = editor.selection;
|
|
buttonApi.setActive(isMediaElement(selection.getNode()));
|
|
return selection.selectorChangedWithUnbind('img[data-mce-object],span[data-mce-object],div[data-ephox-embed-iri]', buttonApi.setActive).unbind;
|
|
}
|
|
});
|
|
editor.ui.registry.addMenuItem('media', {
|
|
icon: 'embed',
|
|
text: 'Media...',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$9.add('media', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
setup(editor);
|
|
setup$1(editor);
|
|
setup$2(editor);
|
|
return get(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var getKeyboardSpaces = function (editor) {
|
|
var spaces = editor.getParam('nonbreaking_force_tab', 0);
|
|
if (typeof spaces === 'boolean') {
|
|
return spaces === true ? 3 : 0;
|
|
} else {
|
|
return spaces;
|
|
}
|
|
};
|
|
var wrapNbsps = function (editor) {
|
|
return editor.getParam('nonbreaking_wrap', true, 'boolean');
|
|
};
|
|
|
|
var stringRepeat = function (string, repeats) {
|
|
var str = '';
|
|
for (var index = 0; index < repeats; index++) {
|
|
str += string;
|
|
}
|
|
return str;
|
|
};
|
|
var isVisualCharsEnabled = function (editor) {
|
|
return editor.plugins.visualchars ? editor.plugins.visualchars.isEnabled() : false;
|
|
};
|
|
var insertNbsp = function (editor, times) {
|
|
var classes = function () {
|
|
return isVisualCharsEnabled(editor) ? 'mce-nbsp-wrap mce-nbsp' : 'mce-nbsp-wrap';
|
|
};
|
|
var nbspSpan = function () {
|
|
return '<span class="' + classes() + '" contenteditable="false">' + stringRepeat(' ', times) + '</span>';
|
|
};
|
|
var shouldWrap = wrapNbsps(editor);
|
|
var html = shouldWrap || editor.plugins.visualchars ? nbspSpan() : stringRepeat(' ', times);
|
|
editor.undoManager.transact(function () {
|
|
return editor.insertContent(html);
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceNonBreaking', function () {
|
|
insertNbsp(editor, 1);
|
|
});
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var setup = function (editor) {
|
|
var spaces = getKeyboardSpaces(editor);
|
|
if (spaces > 0) {
|
|
editor.on('keydown', function (e) {
|
|
if (e.keyCode === global.TAB && !e.isDefaultPrevented()) {
|
|
if (e.shiftKey) {
|
|
return;
|
|
}
|
|
e.preventDefault();
|
|
e.stopImmediatePropagation();
|
|
insertNbsp(editor, spaces);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceNonBreaking');
|
|
};
|
|
editor.ui.registry.addButton('nonbreaking', {
|
|
icon: 'non-breaking',
|
|
tooltip: 'Nonbreaking space',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('nonbreaking', {
|
|
icon: 'non-breaking',
|
|
text: 'Nonbreaking space',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('nonbreaking', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getNonEditableClass = function (editor) {
|
|
return editor.getParam('noneditable_noneditable_class', 'mceNonEditable');
|
|
};
|
|
var getEditableClass = function (editor) {
|
|
return editor.getParam('noneditable_editable_class', 'mceEditable');
|
|
};
|
|
var getNonEditableRegExps = function (editor) {
|
|
var nonEditableRegExps = editor.getParam('noneditable_regexp', []);
|
|
if (nonEditableRegExps && nonEditableRegExps.constructor === RegExp) {
|
|
return [nonEditableRegExps];
|
|
} else {
|
|
return nonEditableRegExps;
|
|
}
|
|
};
|
|
|
|
var hasClass = function (checkClassName) {
|
|
return function (node) {
|
|
return (' ' + node.attr('class') + ' ').indexOf(checkClassName) !== -1;
|
|
};
|
|
};
|
|
var replaceMatchWithSpan = function (editor, content, cls) {
|
|
return function (match) {
|
|
var args = arguments, index = args[args.length - 2];
|
|
var prevChar = index > 0 ? content.charAt(index - 1) : '';
|
|
if (prevChar === '"') {
|
|
return match;
|
|
}
|
|
if (prevChar === '>') {
|
|
var findStartTagIndex = content.lastIndexOf('<', index);
|
|
if (findStartTagIndex !== -1) {
|
|
var tagHtml = content.substring(findStartTagIndex, index);
|
|
if (tagHtml.indexOf('contenteditable="false"') !== -1) {
|
|
return match;
|
|
}
|
|
}
|
|
}
|
|
return '<span class="' + cls + '" data-mce-content="' + editor.dom.encode(args[0]) + '">' + editor.dom.encode(typeof args[1] === 'string' ? args[1] : args[0]) + '</span>';
|
|
};
|
|
};
|
|
var convertRegExpsToNonEditable = function (editor, nonEditableRegExps, e) {
|
|
var i = nonEditableRegExps.length, content = e.content;
|
|
if (e.format === 'raw') {
|
|
return;
|
|
}
|
|
while (i--) {
|
|
content = content.replace(nonEditableRegExps[i], replaceMatchWithSpan(editor, content, getNonEditableClass(editor)));
|
|
}
|
|
e.content = content;
|
|
};
|
|
var setup = function (editor) {
|
|
var contentEditableAttrName = 'contenteditable';
|
|
var editClass = ' ' + global.trim(getEditableClass(editor)) + ' ';
|
|
var nonEditClass = ' ' + global.trim(getNonEditableClass(editor)) + ' ';
|
|
var hasEditClass = hasClass(editClass);
|
|
var hasNonEditClass = hasClass(nonEditClass);
|
|
var nonEditableRegExps = getNonEditableRegExps(editor);
|
|
editor.on('PreInit', function () {
|
|
if (nonEditableRegExps.length > 0) {
|
|
editor.on('BeforeSetContent', function (e) {
|
|
convertRegExpsToNonEditable(editor, nonEditableRegExps, e);
|
|
});
|
|
}
|
|
editor.parser.addAttributeFilter('class', function (nodes) {
|
|
var i = nodes.length, node;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
if (hasEditClass(node)) {
|
|
node.attr(contentEditableAttrName, 'true');
|
|
} else if (hasNonEditClass(node)) {
|
|
node.attr(contentEditableAttrName, 'false');
|
|
}
|
|
}
|
|
});
|
|
editor.serializer.addAttributeFilter(contentEditableAttrName, function (nodes) {
|
|
var i = nodes.length, node;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
if (!hasEditClass(node) && !hasNonEditClass(node)) {
|
|
continue;
|
|
}
|
|
if (nonEditableRegExps.length > 0 && node.attr('data-mce-content')) {
|
|
node.name = '#text';
|
|
node.type = 3;
|
|
node.raw = true;
|
|
node.value = node.attr('data-mce-content');
|
|
} else {
|
|
node.attr(contentEditableAttrName, null);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('noneditable', function (editor) {
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var getSeparatorHtml = function (editor) {
|
|
return editor.getParam('pagebreak_separator', '<!-- pagebreak -->');
|
|
};
|
|
var shouldSplitBlock = function (editor) {
|
|
return editor.getParam('pagebreak_split_block', false);
|
|
};
|
|
|
|
var pageBreakClass = 'mce-pagebreak';
|
|
var getPlaceholderHtml = function (shouldSplitBlock) {
|
|
var html = '<img src="' + global.transparentSrc + '" class="' + pageBreakClass + '" data-mce-resize="false" data-mce-placeholder />';
|
|
return shouldSplitBlock ? '<p>' + html + '</p>' : html;
|
|
};
|
|
var setup$1 = function (editor) {
|
|
var separatorHtml = getSeparatorHtml(editor);
|
|
var shouldSplitBlock$1 = function () {
|
|
return shouldSplitBlock(editor);
|
|
};
|
|
var pageBreakSeparatorRegExp = new RegExp(separatorHtml.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function (a) {
|
|
return '\\' + a;
|
|
}), 'gi');
|
|
editor.on('BeforeSetContent', function (e) {
|
|
e.content = e.content.replace(pageBreakSeparatorRegExp, getPlaceholderHtml(shouldSplitBlock$1()));
|
|
});
|
|
editor.on('PreInit', function () {
|
|
editor.serializer.addNodeFilter('img', function (nodes) {
|
|
var i = nodes.length, node, className;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
className = node.attr('class');
|
|
if (className && className.indexOf(pageBreakClass) !== -1) {
|
|
var parentNode = node.parent;
|
|
if (editor.schema.getBlockElements()[parentNode.name] && shouldSplitBlock$1()) {
|
|
parentNode.type = 3;
|
|
parentNode.value = separatorHtml;
|
|
parentNode.raw = true;
|
|
node.remove();
|
|
continue;
|
|
}
|
|
node.type = 3;
|
|
node.value = separatorHtml;
|
|
node.raw = true;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mcePageBreak', function () {
|
|
editor.insertContent(getPlaceholderHtml(shouldSplitBlock(editor)));
|
|
});
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
editor.on('ResolveName', function (e) {
|
|
if (e.target.nodeName === 'IMG' && editor.dom.hasClass(e.target, pageBreakClass)) {
|
|
e.name = 'pagebreak';
|
|
}
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mcePageBreak');
|
|
};
|
|
editor.ui.registry.addButton('pagebreak', {
|
|
icon: 'page-break',
|
|
tooltip: 'Page break',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('pagebreak', {
|
|
text: 'Page break',
|
|
icon: 'page-break',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('pagebreak', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
setup$1(editor);
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$b = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var hasProPlugin = function (editor) {
|
|
if (editor.hasPlugin('powerpaste', true)) {
|
|
if (typeof window.console !== 'undefined' && window.console.log) {
|
|
window.console.log('PowerPaste is incompatible with Paste plugin! Remove \'paste\' from the \'plugins\' option.');
|
|
}
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
var get = function (clipboard) {
|
|
return { clipboard: clipboard };
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isArray = isType('array');
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from$1 = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from$1
|
|
};
|
|
|
|
var nativeSlice = Array.prototype.slice;
|
|
var nativePush = Array.prototype.push;
|
|
var exists = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter$1 = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind = function (xs, f) {
|
|
return flatten(map(xs, f));
|
|
};
|
|
var from = isFunction(Array.from) ? Array.from : function (x) {
|
|
return nativeSlice.call(x);
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var singleton = function (doRevoke) {
|
|
var subject = Cell(Optional.none());
|
|
var revoke = function () {
|
|
return subject.get().each(doRevoke);
|
|
};
|
|
var clear = function () {
|
|
revoke();
|
|
subject.set(Optional.none());
|
|
};
|
|
var isSet = function () {
|
|
return subject.get().isSome();
|
|
};
|
|
var get = function () {
|
|
return subject.get();
|
|
};
|
|
var set = function (s) {
|
|
revoke();
|
|
subject.set(Optional.some(s));
|
|
};
|
|
return {
|
|
clear: clear,
|
|
isSet: isSet,
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var value = function () {
|
|
var subject = singleton(noop);
|
|
var on = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { on: on });
|
|
};
|
|
|
|
var checkRange = function (str, substr, start) {
|
|
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
};
|
|
var startsWith = function (str, prefix) {
|
|
return checkRange(str, prefix, 0);
|
|
};
|
|
var endsWith = function (str, suffix) {
|
|
return checkRange(str, suffix, str.length - suffix.length);
|
|
};
|
|
var repeat = function (s, count) {
|
|
return count <= 0 ? '' : new Array(count + 1).join(s);
|
|
};
|
|
|
|
var global$a = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global$9 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var global$8 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var global$7 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var firePastePreProcess = function (editor, html, internal, isWordHtml) {
|
|
return editor.fire('PastePreProcess', {
|
|
content: html,
|
|
internal: internal,
|
|
wordContent: isWordHtml
|
|
});
|
|
};
|
|
var firePastePostProcess = function (editor, node, internal, isWordHtml) {
|
|
return editor.fire('PastePostProcess', {
|
|
node: node,
|
|
internal: internal,
|
|
wordContent: isWordHtml
|
|
});
|
|
};
|
|
var firePastePlainTextToggle = function (editor, state) {
|
|
return editor.fire('PastePlainTextToggle', { state: state });
|
|
};
|
|
var firePaste = function (editor, ieFake) {
|
|
return editor.fire('paste', { ieFake: ieFake });
|
|
};
|
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var shouldBlockDrop = function (editor) {
|
|
return editor.getParam('paste_block_drop', false);
|
|
};
|
|
var shouldPasteDataImages = function (editor) {
|
|
return editor.getParam('paste_data_images', false);
|
|
};
|
|
var shouldFilterDrop = function (editor) {
|
|
return editor.getParam('paste_filter_drop', true);
|
|
};
|
|
var getPreProcess = function (editor) {
|
|
return editor.getParam('paste_preprocess');
|
|
};
|
|
var getPostProcess = function (editor) {
|
|
return editor.getParam('paste_postprocess');
|
|
};
|
|
var getWebkitStyles = function (editor) {
|
|
return editor.getParam('paste_webkit_styles');
|
|
};
|
|
var shouldRemoveWebKitStyles = function (editor) {
|
|
return editor.getParam('paste_remove_styles_if_webkit', true);
|
|
};
|
|
var shouldMergeFormats = function (editor) {
|
|
return editor.getParam('paste_merge_formats', true);
|
|
};
|
|
var isSmartPasteEnabled = function (editor) {
|
|
return editor.getParam('smart_paste', true);
|
|
};
|
|
var isPasteAsTextEnabled = function (editor) {
|
|
return editor.getParam('paste_as_text', false);
|
|
};
|
|
var getRetainStyleProps = function (editor) {
|
|
return editor.getParam('paste_retain_style_properties');
|
|
};
|
|
var getWordValidElements = function (editor) {
|
|
var defaultValidElements = '-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' + '-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' + 'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody';
|
|
return editor.getParam('paste_word_valid_elements', defaultValidElements);
|
|
};
|
|
var shouldConvertWordFakeLists = function (editor) {
|
|
return editor.getParam('paste_convert_word_fake_lists', true);
|
|
};
|
|
var shouldUseDefaultFilters = function (editor) {
|
|
return editor.getParam('paste_enable_default_filters', true);
|
|
};
|
|
var getValidate = function (editor) {
|
|
return editor.getParam('validate');
|
|
};
|
|
var getAllowHtmlDataUrls = function (editor) {
|
|
return editor.getParam('allow_html_data_urls', false, 'boolean');
|
|
};
|
|
var getPasteDataImages = function (editor) {
|
|
return editor.getParam('paste_data_images', false, 'boolean');
|
|
};
|
|
var getImagesDataImgFilter = function (editor) {
|
|
return editor.getParam('images_dataimg_filter');
|
|
};
|
|
var getImagesReuseFilename = function (editor) {
|
|
return editor.getParam('images_reuse_filename');
|
|
};
|
|
var getForcedRootBlock = function (editor) {
|
|
return editor.getParam('forced_root_block');
|
|
};
|
|
var getForcedRootBlockAttrs = function (editor) {
|
|
return editor.getParam('forced_root_block_attrs');
|
|
};
|
|
var getTabSpaces = function (editor) {
|
|
return editor.getParam('paste_tab_spaces', 4, 'number');
|
|
};
|
|
var getAllowedImageFileTypes = function (editor) {
|
|
var defaultImageFileTypes = 'jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp';
|
|
return global$6.explode(editor.getParam('images_file_types', defaultImageFileTypes, 'string'));
|
|
};
|
|
|
|
var internalMimeType = 'x-tinymce/html';
|
|
var internalMark = '<!-- ' + internalMimeType + ' -->';
|
|
var mark = function (html) {
|
|
return internalMark + html;
|
|
};
|
|
var unmark = function (html) {
|
|
return html.replace(internalMark, '');
|
|
};
|
|
var isMarked = function (html) {
|
|
return html.indexOf(internalMark) !== -1;
|
|
};
|
|
var internalHtmlMime = constant(internalMimeType);
|
|
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.html.Entities');
|
|
|
|
var isPlainText = function (text) {
|
|
return !/<(?:\/?(?!(?:div|p|br|span)>)\w+|(?:(?!(?:span style="white-space:\s?pre;?">)|br\s?\/>))\w+\s[^>]+)>/i.test(text);
|
|
};
|
|
var toBRs = function (text) {
|
|
return text.replace(/\r?\n/g, '<br>');
|
|
};
|
|
var openContainer = function (rootTag, rootAttrs) {
|
|
var attrs = [];
|
|
var tag = '<' + rootTag;
|
|
if (typeof rootAttrs === 'object') {
|
|
for (var key in rootAttrs) {
|
|
if (has(rootAttrs, key)) {
|
|
attrs.push(key + '="' + global$5.encodeAllRaw(rootAttrs[key]) + '"');
|
|
}
|
|
}
|
|
if (attrs.length) {
|
|
tag += ' ' + attrs.join(' ');
|
|
}
|
|
}
|
|
return tag + '>';
|
|
};
|
|
var toBlockElements = function (text, rootTag, rootAttrs) {
|
|
var blocks = text.split(/\n\n/);
|
|
var tagOpen = openContainer(rootTag, rootAttrs);
|
|
var tagClose = '</' + rootTag + '>';
|
|
var paragraphs = global$6.map(blocks, function (p) {
|
|
return p.split(/\n/).join('<br />');
|
|
});
|
|
var stitch = function (p) {
|
|
return tagOpen + p + tagClose;
|
|
};
|
|
return paragraphs.length === 1 ? paragraphs[0] : global$6.map(paragraphs, stitch).join('');
|
|
};
|
|
var convert = function (text, rootTag, rootAttrs) {
|
|
return rootTag ? toBlockElements(text, rootTag === true ? 'p' : rootTag, rootAttrs) : toBRs(text);
|
|
};
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.html.DomParser');
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.html.Serializer');
|
|
|
|
var nbsp = '\xA0';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.html.Node');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.html.Schema');
|
|
|
|
var isRegExp = function (val) {
|
|
return val.constructor === RegExp;
|
|
};
|
|
var filter = function (content, items) {
|
|
global$6.each(items, function (v) {
|
|
if (isRegExp(v)) {
|
|
content = content.replace(v, '');
|
|
} else {
|
|
content = content.replace(v[0], v[1]);
|
|
}
|
|
});
|
|
return content;
|
|
};
|
|
var innerText = function (html) {
|
|
var schema = global$1();
|
|
var domParser = global$4({}, schema);
|
|
var text = '';
|
|
var shortEndedElements = schema.getShortEndedElements();
|
|
var ignoreElements = global$6.makeMap('script noscript style textarea video audio iframe object', ' ');
|
|
var blockElements = schema.getBlockElements();
|
|
var walk = function (node) {
|
|
var name = node.name, currentNode = node;
|
|
if (name === 'br') {
|
|
text += '\n';
|
|
return;
|
|
}
|
|
if (name === 'wbr') {
|
|
return;
|
|
}
|
|
if (shortEndedElements[name]) {
|
|
text += ' ';
|
|
}
|
|
if (ignoreElements[name]) {
|
|
text += ' ';
|
|
return;
|
|
}
|
|
if (node.type === 3) {
|
|
text += node.value;
|
|
}
|
|
if (!node.shortEnded) {
|
|
if (node = node.firstChild) {
|
|
do {
|
|
walk(node);
|
|
} while (node = node.next);
|
|
}
|
|
}
|
|
if (blockElements[name] && currentNode.next) {
|
|
text += '\n';
|
|
if (name === 'p') {
|
|
text += '\n';
|
|
}
|
|
}
|
|
};
|
|
html = filter(html, [/<!\[[^\]]+\]>/g]);
|
|
walk(domParser.parse(html));
|
|
return text;
|
|
};
|
|
var trimHtml = function (html) {
|
|
var trimSpaces = function (all, s1, s2) {
|
|
if (!s1 && !s2) {
|
|
return ' ';
|
|
}
|
|
return nbsp;
|
|
};
|
|
html = filter(html, [
|
|
/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/ig,
|
|
/<!--StartFragment-->|<!--EndFragment-->/g,
|
|
[
|
|
/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,
|
|
trimSpaces
|
|
],
|
|
/<br class="Apple-interchange-newline">/g,
|
|
/<br>$/i
|
|
]);
|
|
return html;
|
|
};
|
|
var createIdGenerator = function (prefix) {
|
|
var count = 0;
|
|
return function () {
|
|
return prefix + count++;
|
|
};
|
|
};
|
|
var getImageMimeType = function (ext) {
|
|
var lowerExt = ext.toLowerCase();
|
|
var mimeOverrides = {
|
|
jpg: 'jpeg',
|
|
jpe: 'jpeg',
|
|
jfi: 'jpeg',
|
|
jif: 'jpeg',
|
|
jfif: 'jpeg',
|
|
pjpeg: 'jpeg',
|
|
pjp: 'jpeg',
|
|
svg: 'svg+xml'
|
|
};
|
|
return global$6.hasOwn(mimeOverrides, lowerExt) ? 'image/' + mimeOverrides[lowerExt] : 'image/' + lowerExt;
|
|
};
|
|
|
|
var isWordContent = function (content) {
|
|
return /<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^']*\bmso-|w:WordDocument/i.test(content) || /class="OutlineElement/.test(content) || /id="?docs\-internal\-guid\-/.test(content);
|
|
};
|
|
var isNumericList = function (text) {
|
|
var found = false;
|
|
var patterns = [
|
|
/^[IVXLMCD]+\.[ \u00a0]/,
|
|
/^[ivxlmcd]+\.[ \u00a0]/,
|
|
/^[a-z]{1,2}[\.\)][ \u00a0]/,
|
|
/^[A-Z]{1,2}[\.\)][ \u00a0]/,
|
|
/^[0-9]+\.[ \u00a0]/,
|
|
/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/,
|
|
/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/
|
|
];
|
|
text = text.replace(/^[\u00a0 ]+/, '');
|
|
global$6.each(patterns, function (pattern) {
|
|
if (pattern.test(text)) {
|
|
found = true;
|
|
return false;
|
|
}
|
|
});
|
|
return found;
|
|
};
|
|
var isBulletList = function (text) {
|
|
return /^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(text);
|
|
};
|
|
var convertFakeListsToProperLists = function (node) {
|
|
var currentListNode, prevListNode, lastLevel = 1;
|
|
var getText = function (node) {
|
|
var txt = '';
|
|
if (node.type === 3) {
|
|
return node.value;
|
|
}
|
|
if (node = node.firstChild) {
|
|
do {
|
|
txt += getText(node);
|
|
} while (node = node.next);
|
|
}
|
|
return txt;
|
|
};
|
|
var trimListStart = function (node, regExp) {
|
|
if (node.type === 3) {
|
|
if (regExp.test(node.value)) {
|
|
node.value = node.value.replace(regExp, '');
|
|
return false;
|
|
}
|
|
}
|
|
if (node = node.firstChild) {
|
|
do {
|
|
if (!trimListStart(node, regExp)) {
|
|
return false;
|
|
}
|
|
} while (node = node.next);
|
|
}
|
|
return true;
|
|
};
|
|
var removeIgnoredNodes = function (node) {
|
|
if (node._listIgnore) {
|
|
node.remove();
|
|
return;
|
|
}
|
|
if (node = node.firstChild) {
|
|
do {
|
|
removeIgnoredNodes(node);
|
|
} while (node = node.next);
|
|
}
|
|
};
|
|
var convertParagraphToLi = function (paragraphNode, listName, start) {
|
|
var level = paragraphNode._listLevel || lastLevel;
|
|
if (level !== lastLevel) {
|
|
if (level < lastLevel) {
|
|
if (currentListNode) {
|
|
currentListNode = currentListNode.parent.parent;
|
|
}
|
|
} else {
|
|
prevListNode = currentListNode;
|
|
currentListNode = null;
|
|
}
|
|
}
|
|
if (!currentListNode || currentListNode.name !== listName) {
|
|
prevListNode = prevListNode || currentListNode;
|
|
currentListNode = new global$2(listName, 1);
|
|
if (start > 1) {
|
|
currentListNode.attr('start', '' + start);
|
|
}
|
|
paragraphNode.wrap(currentListNode);
|
|
} else {
|
|
currentListNode.append(paragraphNode);
|
|
}
|
|
paragraphNode.name = 'li';
|
|
if (level > lastLevel && prevListNode) {
|
|
prevListNode.lastChild.append(currentListNode);
|
|
}
|
|
lastLevel = level;
|
|
removeIgnoredNodes(paragraphNode);
|
|
trimListStart(paragraphNode, /^\u00a0+/);
|
|
trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
|
|
trimListStart(paragraphNode, /^\u00a0+/);
|
|
};
|
|
var elements = [];
|
|
var child = node.firstChild;
|
|
while (typeof child !== 'undefined' && child !== null) {
|
|
elements.push(child);
|
|
child = child.walk();
|
|
if (child !== null) {
|
|
while (typeof child !== 'undefined' && child.parent !== node) {
|
|
child = child.walk();
|
|
}
|
|
}
|
|
}
|
|
for (var i = 0; i < elements.length; i++) {
|
|
node = elements[i];
|
|
if (node.name === 'p' && node.firstChild) {
|
|
var nodeText = getText(node);
|
|
if (isBulletList(nodeText)) {
|
|
convertParagraphToLi(node, 'ul');
|
|
continue;
|
|
}
|
|
if (isNumericList(nodeText)) {
|
|
var matches = /([0-9]+)\./.exec(nodeText);
|
|
var start = 1;
|
|
if (matches) {
|
|
start = parseInt(matches[1], 10);
|
|
}
|
|
convertParagraphToLi(node, 'ol', start);
|
|
continue;
|
|
}
|
|
if (node._listLevel) {
|
|
convertParagraphToLi(node, 'ul', 1);
|
|
continue;
|
|
}
|
|
currentListNode = null;
|
|
} else {
|
|
prevListNode = currentListNode;
|
|
currentListNode = null;
|
|
}
|
|
}
|
|
};
|
|
var filterStyles = function (editor, validStyles, node, styleValue) {
|
|
var outputStyles = {};
|
|
var styles = editor.dom.parseStyle(styleValue);
|
|
global$6.each(styles, function (value, name) {
|
|
switch (name) {
|
|
case 'mso-list':
|
|
var matches = /\w+ \w+([0-9]+)/i.exec(styleValue);
|
|
if (matches) {
|
|
node._listLevel = parseInt(matches[1], 10);
|
|
}
|
|
if (/Ignore/i.test(value) && node.firstChild) {
|
|
node._listIgnore = true;
|
|
node.firstChild._listIgnore = true;
|
|
}
|
|
break;
|
|
case 'horiz-align':
|
|
name = 'text-align';
|
|
break;
|
|
case 'vert-align':
|
|
name = 'vertical-align';
|
|
break;
|
|
case 'font-color':
|
|
case 'mso-foreground':
|
|
name = 'color';
|
|
break;
|
|
case 'mso-background':
|
|
case 'mso-highlight':
|
|
name = 'background';
|
|
break;
|
|
case 'font-weight':
|
|
case 'font-style':
|
|
if (value !== 'normal') {
|
|
outputStyles[name] = value;
|
|
}
|
|
return;
|
|
case 'mso-element':
|
|
if (/^(comment|comment-list)$/i.test(value)) {
|
|
node.remove();
|
|
return;
|
|
}
|
|
break;
|
|
}
|
|
if (name.indexOf('mso-comment') === 0) {
|
|
node.remove();
|
|
return;
|
|
}
|
|
if (name.indexOf('mso-') === 0) {
|
|
return;
|
|
}
|
|
if (getRetainStyleProps(editor) === 'all' || validStyles && validStyles[name]) {
|
|
outputStyles[name] = value;
|
|
}
|
|
});
|
|
if (/(bold)/i.test(outputStyles['font-weight'])) {
|
|
delete outputStyles['font-weight'];
|
|
node.wrap(new global$2('b', 1));
|
|
}
|
|
if (/(italic)/i.test(outputStyles['font-style'])) {
|
|
delete outputStyles['font-style'];
|
|
node.wrap(new global$2('i', 1));
|
|
}
|
|
var outputStyle = editor.dom.serializeStyle(outputStyles, node.name);
|
|
if (outputStyle) {
|
|
return outputStyle;
|
|
}
|
|
return null;
|
|
};
|
|
var filterWordContent = function (editor, content) {
|
|
var validStyles;
|
|
var retainStyleProperties = getRetainStyleProps(editor);
|
|
if (retainStyleProperties) {
|
|
validStyles = global$6.makeMap(retainStyleProperties.split(/[, ]/));
|
|
}
|
|
content = filter(content, [
|
|
/<br class="?Apple-interchange-newline"?>/gi,
|
|
/<b[^>]+id="?docs-internal-[^>]*>/gi,
|
|
/<!--[\s\S]+?-->/gi,
|
|
/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
|
|
[
|
|
/<(\/?)s>/gi,
|
|
'<$1strike>'
|
|
],
|
|
[
|
|
/ /gi,
|
|
nbsp
|
|
],
|
|
[
|
|
/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,
|
|
function (str, spaces) {
|
|
return spaces.length > 0 ? spaces.replace(/./, ' ').slice(Math.floor(spaces.length / 2)).split('').join(nbsp) : '';
|
|
}
|
|
]
|
|
]);
|
|
var validElements = getWordValidElements(editor);
|
|
var schema = global$1({
|
|
valid_elements: validElements,
|
|
valid_children: '-li[p]'
|
|
});
|
|
global$6.each(schema.elements, function (rule) {
|
|
if (!rule.attributes.class) {
|
|
rule.attributes.class = {};
|
|
rule.attributesOrder.push('class');
|
|
}
|
|
if (!rule.attributes.style) {
|
|
rule.attributes.style = {};
|
|
rule.attributesOrder.push('style');
|
|
}
|
|
});
|
|
var domParser = global$4({}, schema);
|
|
domParser.addAttributeFilter('style', function (nodes) {
|
|
var i = nodes.length, node;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
node.attr('style', filterStyles(editor, validStyles, node, node.attr('style')));
|
|
if (node.name === 'span' && node.parent && !node.attributes.length) {
|
|
node.unwrap();
|
|
}
|
|
}
|
|
});
|
|
domParser.addAttributeFilter('class', function (nodes) {
|
|
var i = nodes.length, node, className;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
className = node.attr('class');
|
|
if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) {
|
|
node.remove();
|
|
}
|
|
node.attr('class', null);
|
|
}
|
|
});
|
|
domParser.addNodeFilter('del', function (nodes) {
|
|
var i = nodes.length;
|
|
while (i--) {
|
|
nodes[i].remove();
|
|
}
|
|
});
|
|
domParser.addNodeFilter('a', function (nodes) {
|
|
var i = nodes.length, node, href, name;
|
|
while (i--) {
|
|
node = nodes[i];
|
|
href = node.attr('href');
|
|
name = node.attr('name');
|
|
if (href && href.indexOf('#_msocom_') !== -1) {
|
|
node.remove();
|
|
continue;
|
|
}
|
|
if (href && href.indexOf('file://') === 0) {
|
|
href = href.split('#')[1];
|
|
if (href) {
|
|
href = '#' + href;
|
|
}
|
|
}
|
|
if (!href && !name) {
|
|
node.unwrap();
|
|
} else {
|
|
if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) {
|
|
node.unwrap();
|
|
continue;
|
|
}
|
|
node.attr({
|
|
href: href,
|
|
name: name
|
|
});
|
|
}
|
|
}
|
|
});
|
|
var rootNode = domParser.parse(content);
|
|
if (shouldConvertWordFakeLists(editor)) {
|
|
convertFakeListsToProperLists(rootNode);
|
|
}
|
|
content = global$3({ validate: getValidate(editor) }, schema).serialize(rootNode);
|
|
return content;
|
|
};
|
|
var preProcess$1 = function (editor, content) {
|
|
return shouldUseDefaultFilters(editor) ? filterWordContent(editor, content) : content;
|
|
};
|
|
|
|
var preProcess = function (editor, html) {
|
|
var parser = global$4({}, editor.schema);
|
|
parser.addNodeFilter('meta', function (nodes) {
|
|
global$6.each(nodes, function (node) {
|
|
node.remove();
|
|
});
|
|
});
|
|
var fragment = parser.parse(html, {
|
|
forced_root_block: false,
|
|
isRootContent: true
|
|
});
|
|
return global$3({ validate: getValidate(editor) }, editor.schema).serialize(fragment);
|
|
};
|
|
var processResult = function (content, cancelled) {
|
|
return {
|
|
content: content,
|
|
cancelled: cancelled
|
|
};
|
|
};
|
|
var postProcessFilter = function (editor, html, internal, isWordHtml) {
|
|
var tempBody = editor.dom.create('div', { style: 'display:none' }, html);
|
|
var postProcessArgs = firePastePostProcess(editor, tempBody, internal, isWordHtml);
|
|
return processResult(postProcessArgs.node.innerHTML, postProcessArgs.isDefaultPrevented());
|
|
};
|
|
var filterContent = function (editor, content, internal, isWordHtml) {
|
|
var preProcessArgs = firePastePreProcess(editor, content, internal, isWordHtml);
|
|
var filteredContent = preProcess(editor, preProcessArgs.content);
|
|
if (editor.hasEventListeners('PastePostProcess') && !preProcessArgs.isDefaultPrevented()) {
|
|
return postProcessFilter(editor, filteredContent, internal, isWordHtml);
|
|
} else {
|
|
return processResult(filteredContent, preProcessArgs.isDefaultPrevented());
|
|
}
|
|
};
|
|
var process = function (editor, html, internal) {
|
|
var isWordHtml = isWordContent(html);
|
|
var content = isWordHtml ? preProcess$1(editor, html) : html;
|
|
return filterContent(editor, content, internal, isWordHtml);
|
|
};
|
|
|
|
var pasteHtml$1 = function (editor, html) {
|
|
editor.insertContent(html, {
|
|
merge: shouldMergeFormats(editor),
|
|
paste: true
|
|
});
|
|
return true;
|
|
};
|
|
var isAbsoluteUrl = function (url) {
|
|
return /^https?:\/\/[\w\-\/+=.,!;:&%@^~(){}?#]+$/i.test(url);
|
|
};
|
|
var isImageUrl = function (editor, url) {
|
|
return isAbsoluteUrl(url) && exists(getAllowedImageFileTypes(editor), function (type) {
|
|
return endsWith(url.toLowerCase(), '.' + type.toLowerCase());
|
|
});
|
|
};
|
|
var createImage = function (editor, url, pasteHtmlFn) {
|
|
editor.undoManager.extra(function () {
|
|
pasteHtmlFn(editor, url);
|
|
}, function () {
|
|
editor.insertContent('<img src="' + url + '">');
|
|
});
|
|
return true;
|
|
};
|
|
var createLink = function (editor, url, pasteHtmlFn) {
|
|
editor.undoManager.extra(function () {
|
|
pasteHtmlFn(editor, url);
|
|
}, function () {
|
|
editor.execCommand('mceInsertLink', false, url);
|
|
});
|
|
return true;
|
|
};
|
|
var linkSelection = function (editor, html, pasteHtmlFn) {
|
|
return editor.selection.isCollapsed() === false && isAbsoluteUrl(html) ? createLink(editor, html, pasteHtmlFn) : false;
|
|
};
|
|
var insertImage = function (editor, html, pasteHtmlFn) {
|
|
return isImageUrl(editor, html) ? createImage(editor, html, pasteHtmlFn) : false;
|
|
};
|
|
var smartInsertContent = function (editor, html) {
|
|
global$6.each([
|
|
linkSelection,
|
|
insertImage,
|
|
pasteHtml$1
|
|
], function (action) {
|
|
return action(editor, html, pasteHtml$1) !== true;
|
|
});
|
|
};
|
|
var insertContent = function (editor, html, pasteAsText) {
|
|
if (pasteAsText || isSmartPasteEnabled(editor) === false) {
|
|
pasteHtml$1(editor, html);
|
|
} else {
|
|
smartInsertContent(editor, html);
|
|
}
|
|
};
|
|
|
|
var isCollapsibleWhitespace = function (c) {
|
|
return ' \f\t\x0B'.indexOf(c) !== -1;
|
|
};
|
|
var isNewLineChar = function (c) {
|
|
return c === '\n' || c === '\r';
|
|
};
|
|
var isNewline = function (text, idx) {
|
|
return idx < text.length && idx >= 0 ? isNewLineChar(text[idx]) : false;
|
|
};
|
|
var normalizeWhitespace = function (editor, text) {
|
|
var tabSpace = repeat(' ', getTabSpaces(editor));
|
|
var normalizedText = text.replace(/\t/g, tabSpace);
|
|
var result = foldl(normalizedText, function (acc, c) {
|
|
if (isCollapsibleWhitespace(c) || c === nbsp) {
|
|
if (acc.pcIsSpace || acc.str === '' || acc.str.length === normalizedText.length - 1 || isNewline(normalizedText, acc.str.length + 1)) {
|
|
return {
|
|
pcIsSpace: false,
|
|
str: acc.str + nbsp
|
|
};
|
|
} else {
|
|
return {
|
|
pcIsSpace: true,
|
|
str: acc.str + ' '
|
|
};
|
|
}
|
|
} else {
|
|
return {
|
|
pcIsSpace: isNewLineChar(c),
|
|
str: acc.str + c
|
|
};
|
|
}
|
|
}, {
|
|
pcIsSpace: false,
|
|
str: ''
|
|
});
|
|
return result.str;
|
|
};
|
|
|
|
var doPaste = function (editor, content, internal, pasteAsText) {
|
|
var args = process(editor, content, internal);
|
|
if (args.cancelled === false) {
|
|
insertContent(editor, args.content, pasteAsText);
|
|
}
|
|
};
|
|
var pasteHtml = function (editor, html, internalFlag) {
|
|
var internal = internalFlag ? internalFlag : isMarked(html);
|
|
doPaste(editor, unmark(html), internal, false);
|
|
};
|
|
var pasteText = function (editor, text) {
|
|
var encodedText = editor.dom.encode(text).replace(/\r\n/g, '\n');
|
|
var normalizedText = normalizeWhitespace(editor, encodedText);
|
|
var html = convert(normalizedText, getForcedRootBlock(editor), getForcedRootBlockAttrs(editor));
|
|
doPaste(editor, html, false, true);
|
|
};
|
|
var getDataTransferItems = function (dataTransfer) {
|
|
var items = {};
|
|
var mceInternalUrlPrefix = 'data:text/mce-internal,';
|
|
if (dataTransfer) {
|
|
if (dataTransfer.getData) {
|
|
var legacyText = dataTransfer.getData('Text');
|
|
if (legacyText && legacyText.length > 0) {
|
|
if (legacyText.indexOf(mceInternalUrlPrefix) === -1) {
|
|
items['text/plain'] = legacyText;
|
|
}
|
|
}
|
|
}
|
|
if (dataTransfer.types) {
|
|
for (var i = 0; i < dataTransfer.types.length; i++) {
|
|
var contentType = dataTransfer.types[i];
|
|
try {
|
|
items[contentType] = dataTransfer.getData(contentType);
|
|
} catch (ex) {
|
|
items[contentType] = '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return items;
|
|
};
|
|
var getClipboardContent = function (editor, clipboardEvent) {
|
|
return getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer);
|
|
};
|
|
var hasContentType = function (clipboardContent, mimeType) {
|
|
return mimeType in clipboardContent && clipboardContent[mimeType].length > 0;
|
|
};
|
|
var hasHtmlOrText = function (content) {
|
|
return hasContentType(content, 'text/html') || hasContentType(content, 'text/plain');
|
|
};
|
|
var parseDataUri = function (uri) {
|
|
var matches = /data:([^;]+);base64,([a-z0-9\+\/=]+)/i.exec(uri);
|
|
if (matches) {
|
|
return {
|
|
type: matches[1],
|
|
data: decodeURIComponent(matches[2])
|
|
};
|
|
} else {
|
|
return {
|
|
type: null,
|
|
data: null
|
|
};
|
|
}
|
|
};
|
|
var isValidDataUriImage = function (editor, imgElm) {
|
|
var filter = getImagesDataImgFilter(editor);
|
|
return filter ? filter(imgElm) : true;
|
|
};
|
|
var extractFilename = function (editor, str) {
|
|
var m = str.match(/([\s\S]+?)(?:\.[a-z0-9.]+)$/i);
|
|
return isNonNullable(m) ? editor.dom.encode(m[1]) : null;
|
|
};
|
|
var uniqueId = createIdGenerator('mceclip');
|
|
var pasteImage = function (editor, imageItem) {
|
|
var _a = parseDataUri(imageItem.uri), base64 = _a.data, type = _a.type;
|
|
var id = uniqueId();
|
|
var file = imageItem.blob;
|
|
var img = new Image();
|
|
img.src = imageItem.uri;
|
|
if (isValidDataUriImage(editor, img)) {
|
|
var blobCache = editor.editorUpload.blobCache;
|
|
var blobInfo = void 0;
|
|
var existingBlobInfo = blobCache.getByData(base64, type);
|
|
if (!existingBlobInfo) {
|
|
var useFileName = getImagesReuseFilename(editor) && isNonNullable(file.name);
|
|
var name_1 = useFileName ? extractFilename(editor, file.name) : id;
|
|
var filename = useFileName ? file.name : undefined;
|
|
blobInfo = blobCache.create(id, file, base64, name_1, filename);
|
|
blobCache.add(blobInfo);
|
|
} else {
|
|
blobInfo = existingBlobInfo;
|
|
}
|
|
pasteHtml(editor, '<img src="' + blobInfo.blobUri() + '">', false);
|
|
} else {
|
|
pasteHtml(editor, '<img src="' + imageItem.uri + '">', false);
|
|
}
|
|
};
|
|
var isClipboardEvent = function (event) {
|
|
return event.type === 'paste';
|
|
};
|
|
var isDataTransferItem = function (item) {
|
|
return isNonNullable(item.getAsFile);
|
|
};
|
|
var readFilesAsDataUris = function (items) {
|
|
return global$8.all(map(items, function (item) {
|
|
return new global$8(function (resolve) {
|
|
var blob = isDataTransferItem(item) ? item.getAsFile() : item;
|
|
var reader = new window.FileReader();
|
|
reader.onload = function () {
|
|
resolve({
|
|
blob: blob,
|
|
uri: reader.result
|
|
});
|
|
};
|
|
reader.readAsDataURL(blob);
|
|
});
|
|
}));
|
|
};
|
|
var isImage = function (editor) {
|
|
var allowedExtensions = getAllowedImageFileTypes(editor);
|
|
return function (file) {
|
|
return startsWith(file.type, 'image/') && exists(allowedExtensions, function (extension) {
|
|
return getImageMimeType(extension) === file.type;
|
|
});
|
|
};
|
|
};
|
|
var getImagesFromDataTransfer = function (editor, dataTransfer) {
|
|
var items = dataTransfer.items ? bind(from(dataTransfer.items), function (item) {
|
|
return item.kind === 'file' ? [item.getAsFile()] : [];
|
|
}) : [];
|
|
var files = dataTransfer.files ? from(dataTransfer.files) : [];
|
|
return filter$1(items.length > 0 ? items : files, isImage(editor));
|
|
};
|
|
var pasteImageData = function (editor, e, rng) {
|
|
var dataTransfer = isClipboardEvent(e) ? e.clipboardData : e.dataTransfer;
|
|
if (getPasteDataImages(editor) && dataTransfer) {
|
|
var images = getImagesFromDataTransfer(editor, dataTransfer);
|
|
if (images.length > 0) {
|
|
e.preventDefault();
|
|
readFilesAsDataUris(images).then(function (fileResults) {
|
|
if (rng) {
|
|
editor.selection.setRng(rng);
|
|
}
|
|
each(fileResults, function (result) {
|
|
pasteImage(editor, result);
|
|
});
|
|
});
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var isBrokenAndroidClipboardEvent = function (e) {
|
|
var clipboardData = e.clipboardData;
|
|
return navigator.userAgent.indexOf('Android') !== -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
|
|
};
|
|
var isKeyboardPasteEvent = function (e) {
|
|
return global$7.metaKeyPressed(e) && e.keyCode === 86 || e.shiftKey && e.keyCode === 45;
|
|
};
|
|
var registerEventHandlers = function (editor, pasteBin, pasteFormat) {
|
|
var keyboardPasteEvent = value();
|
|
var keyboardPastePressed = value();
|
|
var keyboardPastePlainTextState;
|
|
editor.on('keyup', keyboardPastePressed.clear);
|
|
editor.on('keydown', function (e) {
|
|
var removePasteBinOnKeyUp = function (e) {
|
|
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
|
pasteBin.remove();
|
|
}
|
|
};
|
|
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
|
keyboardPastePlainTextState = e.shiftKey && e.keyCode === 86;
|
|
if (keyboardPastePlainTextState && global$a.webkit && navigator.userAgent.indexOf('Version/') !== -1) {
|
|
return;
|
|
}
|
|
e.stopImmediatePropagation();
|
|
keyboardPasteEvent.set(e);
|
|
keyboardPastePressed.set(true);
|
|
if (global$a.ie && keyboardPastePlainTextState) {
|
|
e.preventDefault();
|
|
firePaste(editor, true);
|
|
return;
|
|
}
|
|
pasteBin.remove();
|
|
pasteBin.create();
|
|
editor.once('keyup', removePasteBinOnKeyUp);
|
|
editor.once('paste', function () {
|
|
editor.off('keyup', removePasteBinOnKeyUp);
|
|
});
|
|
}
|
|
});
|
|
var insertClipboardContent = function (editor, clipboardContent, isKeyBoardPaste, plainTextMode, internal) {
|
|
var content;
|
|
if (hasContentType(clipboardContent, 'text/html')) {
|
|
content = clipboardContent['text/html'];
|
|
} else {
|
|
content = pasteBin.getHtml();
|
|
internal = internal ? internal : isMarked(content);
|
|
if (pasteBin.isDefaultContent(content)) {
|
|
plainTextMode = true;
|
|
}
|
|
}
|
|
content = trimHtml(content);
|
|
pasteBin.remove();
|
|
var isPlainTextHtml = internal === false && isPlainText(content);
|
|
var isAbsoluteUrl$1 = isAbsoluteUrl(content);
|
|
if (!content.length || isPlainTextHtml && !isAbsoluteUrl$1) {
|
|
plainTextMode = true;
|
|
}
|
|
if (plainTextMode || isAbsoluteUrl$1) {
|
|
if (hasContentType(clipboardContent, 'text/plain') && isPlainTextHtml) {
|
|
content = clipboardContent['text/plain'];
|
|
} else {
|
|
content = innerText(content);
|
|
}
|
|
}
|
|
if (pasteBin.isDefaultContent(content)) {
|
|
if (!isKeyBoardPaste) {
|
|
editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
|
|
}
|
|
return;
|
|
}
|
|
if (plainTextMode) {
|
|
pasteText(editor, content);
|
|
} else {
|
|
pasteHtml(editor, content, internal);
|
|
}
|
|
};
|
|
var getLastRng = function () {
|
|
return pasteBin.getLastRng() || editor.selection.getRng();
|
|
};
|
|
editor.on('paste', function (e) {
|
|
var isKeyboardPaste = keyboardPasteEvent.isSet() || keyboardPastePressed.isSet();
|
|
if (isKeyboardPaste) {
|
|
keyboardPasteEvent.clear();
|
|
}
|
|
var clipboardContent = getClipboardContent(editor, e);
|
|
var plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState;
|
|
var internal = hasContentType(clipboardContent, internalHtmlMime());
|
|
keyboardPastePlainTextState = false;
|
|
if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
|
|
pasteBin.remove();
|
|
return;
|
|
}
|
|
if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) {
|
|
pasteBin.remove();
|
|
return;
|
|
}
|
|
if (!isKeyboardPaste) {
|
|
e.preventDefault();
|
|
}
|
|
if (global$a.ie && (!isKeyboardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) {
|
|
pasteBin.create();
|
|
editor.dom.bind(pasteBin.getEl(), 'paste', function (e) {
|
|
e.stopPropagation();
|
|
});
|
|
editor.getDoc().execCommand('Paste', false, null);
|
|
clipboardContent['text/html'] = pasteBin.getHtml();
|
|
}
|
|
if (hasContentType(clipboardContent, 'text/html')) {
|
|
e.preventDefault();
|
|
if (!internal) {
|
|
internal = isMarked(clipboardContent['text/html']);
|
|
}
|
|
insertClipboardContent(editor, clipboardContent, isKeyboardPaste, plainTextMode, internal);
|
|
} else {
|
|
global$9.setEditorTimeout(editor, function () {
|
|
insertClipboardContent(editor, clipboardContent, isKeyboardPaste, plainTextMode, internal);
|
|
}, 0);
|
|
}
|
|
});
|
|
};
|
|
var registerEventsAndFilters = function (editor, pasteBin, pasteFormat) {
|
|
registerEventHandlers(editor, pasteBin, pasteFormat);
|
|
var src;
|
|
editor.parser.addNodeFilter('img', function (nodes, name, args) {
|
|
var isPasteInsert = function (args) {
|
|
return args.data && args.data.paste === true;
|
|
};
|
|
var remove = function (node) {
|
|
if (!node.attr('data-mce-object') && src !== global$a.transparentSrc) {
|
|
node.remove();
|
|
}
|
|
};
|
|
var isWebKitFakeUrl = function (src) {
|
|
return src.indexOf('webkit-fake-url') === 0;
|
|
};
|
|
var isDataUri = function (src) {
|
|
return src.indexOf('data:') === 0;
|
|
};
|
|
if (!getPasteDataImages(editor) && isPasteInsert(args)) {
|
|
var i = nodes.length;
|
|
while (i--) {
|
|
src = nodes[i].attr('src');
|
|
if (!src) {
|
|
continue;
|
|
}
|
|
if (isWebKitFakeUrl(src)) {
|
|
remove(nodes[i]);
|
|
} else if (!getAllowHtmlDataUrls(editor) && isDataUri(src)) {
|
|
remove(nodes[i]);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
var getPasteBinParent = function (editor) {
|
|
return global$a.ie && editor.inline ? document.body : editor.getBody();
|
|
};
|
|
var isExternalPasteBin = function (editor) {
|
|
return getPasteBinParent(editor) !== editor.getBody();
|
|
};
|
|
var delegatePasteEvents = function (editor, pasteBinElm, pasteBinDefaultContent) {
|
|
if (isExternalPasteBin(editor)) {
|
|
editor.dom.bind(pasteBinElm, 'paste keyup', function (_e) {
|
|
if (!isDefault(editor, pasteBinDefaultContent)) {
|
|
editor.fire('paste');
|
|
}
|
|
});
|
|
}
|
|
};
|
|
var create = function (editor, lastRngCell, pasteBinDefaultContent) {
|
|
var dom = editor.dom, body = editor.getBody();
|
|
lastRngCell.set(editor.selection.getRng());
|
|
var pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', {
|
|
'id': 'mcepastebin',
|
|
'class': 'mce-pastebin',
|
|
'contentEditable': true,
|
|
'data-mce-bogus': 'all',
|
|
'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0'
|
|
}, pasteBinDefaultContent);
|
|
if (global$a.ie || global$a.gecko) {
|
|
dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 65535 : -65535);
|
|
}
|
|
dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) {
|
|
e.stopPropagation();
|
|
});
|
|
delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent);
|
|
pasteBinElm.focus();
|
|
editor.selection.select(pasteBinElm, true);
|
|
};
|
|
var remove = function (editor, lastRngCell) {
|
|
if (getEl(editor)) {
|
|
var pasteBinClone = void 0;
|
|
var lastRng = lastRngCell.get();
|
|
while (pasteBinClone = editor.dom.get('mcepastebin')) {
|
|
editor.dom.remove(pasteBinClone);
|
|
editor.dom.unbind(pasteBinClone);
|
|
}
|
|
if (lastRng) {
|
|
editor.selection.setRng(lastRng);
|
|
}
|
|
}
|
|
lastRngCell.set(null);
|
|
};
|
|
var getEl = function (editor) {
|
|
return editor.dom.get('mcepastebin');
|
|
};
|
|
var getHtml = function (editor) {
|
|
var copyAndRemove = function (toElm, fromElm) {
|
|
toElm.appendChild(fromElm);
|
|
editor.dom.remove(fromElm, true);
|
|
};
|
|
var pasteBinClones = global$6.grep(getPasteBinParent(editor).childNodes, function (elm) {
|
|
return elm.id === 'mcepastebin';
|
|
});
|
|
var pasteBinElm = pasteBinClones.shift();
|
|
global$6.each(pasteBinClones, function (pasteBinClone) {
|
|
copyAndRemove(pasteBinElm, pasteBinClone);
|
|
});
|
|
var dirtyWrappers = editor.dom.select('div[id=mcepastebin]', pasteBinElm);
|
|
for (var i = dirtyWrappers.length - 1; i >= 0; i--) {
|
|
var cleanWrapper = editor.dom.create('div');
|
|
pasteBinElm.insertBefore(cleanWrapper, dirtyWrappers[i]);
|
|
copyAndRemove(cleanWrapper, dirtyWrappers[i]);
|
|
}
|
|
return pasteBinElm ? pasteBinElm.innerHTML : '';
|
|
};
|
|
var isDefaultContent = function (pasteBinDefaultContent, content) {
|
|
return content === pasteBinDefaultContent;
|
|
};
|
|
var isPasteBin = function (elm) {
|
|
return elm && elm.id === 'mcepastebin';
|
|
};
|
|
var isDefault = function (editor, pasteBinDefaultContent) {
|
|
var pasteBinElm = getEl(editor);
|
|
return isPasteBin(pasteBinElm) && isDefaultContent(pasteBinDefaultContent, pasteBinElm.innerHTML);
|
|
};
|
|
var PasteBin = function (editor) {
|
|
var lastRng = Cell(null);
|
|
var pasteBinDefaultContent = '%MCEPASTEBIN%';
|
|
return {
|
|
create: function () {
|
|
return create(editor, lastRng, pasteBinDefaultContent);
|
|
},
|
|
remove: function () {
|
|
return remove(editor, lastRng);
|
|
},
|
|
getEl: function () {
|
|
return getEl(editor);
|
|
},
|
|
getHtml: function () {
|
|
return getHtml(editor);
|
|
},
|
|
getLastRng: lastRng.get,
|
|
isDefault: function () {
|
|
return isDefault(editor, pasteBinDefaultContent);
|
|
},
|
|
isDefaultContent: function (content) {
|
|
return isDefaultContent(pasteBinDefaultContent, content);
|
|
}
|
|
};
|
|
};
|
|
|
|
var Clipboard = function (editor, pasteFormat) {
|
|
var pasteBin = PasteBin(editor);
|
|
editor.on('PreInit', function () {
|
|
return registerEventsAndFilters(editor, pasteBin, pasteFormat);
|
|
});
|
|
return {
|
|
pasteFormat: pasteFormat,
|
|
pasteHtml: function (html, internalFlag) {
|
|
return pasteHtml(editor, html, internalFlag);
|
|
},
|
|
pasteText: function (text) {
|
|
return pasteText(editor, text);
|
|
},
|
|
pasteImageData: function (e, rng) {
|
|
return pasteImageData(editor, e, rng);
|
|
},
|
|
getDataTransferItems: getDataTransferItems,
|
|
hasHtmlOrText: hasHtmlOrText,
|
|
hasContentType: hasContentType
|
|
};
|
|
};
|
|
|
|
var togglePlainTextPaste = function (editor, clipboard) {
|
|
if (clipboard.pasteFormat.get() === 'text') {
|
|
clipboard.pasteFormat.set('html');
|
|
firePastePlainTextToggle(editor, false);
|
|
} else {
|
|
clipboard.pasteFormat.set('text');
|
|
firePastePlainTextToggle(editor, true);
|
|
}
|
|
editor.focus();
|
|
};
|
|
|
|
var register$2 = function (editor, clipboard) {
|
|
editor.addCommand('mceTogglePlainTextPaste', function () {
|
|
togglePlainTextPaste(editor, clipboard);
|
|
});
|
|
editor.addCommand('mceInsertClipboardContent', function (ui, value) {
|
|
if (value.content) {
|
|
clipboard.pasteHtml(value.content, value.internal);
|
|
}
|
|
if (value.text) {
|
|
clipboard.pasteText(value.text);
|
|
}
|
|
});
|
|
};
|
|
|
|
var hasWorkingClipboardApi = function (clipboardData) {
|
|
return global$a.iOS === false && typeof (clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.setData) === 'function';
|
|
};
|
|
var setHtml5Clipboard = function (clipboardData, html, text) {
|
|
if (hasWorkingClipboardApi(clipboardData)) {
|
|
try {
|
|
clipboardData.clearData();
|
|
clipboardData.setData('text/html', html);
|
|
clipboardData.setData('text/plain', text);
|
|
clipboardData.setData(internalHtmlMime(), html);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
var setClipboardData = function (evt, data, fallback, done) {
|
|
if (setHtml5Clipboard(evt.clipboardData, data.html, data.text)) {
|
|
evt.preventDefault();
|
|
done();
|
|
} else {
|
|
fallback(data.html, done);
|
|
}
|
|
};
|
|
var fallback = function (editor) {
|
|
return function (html, done) {
|
|
var markedHtml = mark(html);
|
|
var outer = editor.dom.create('div', {
|
|
'contenteditable': 'false',
|
|
'data-mce-bogus': 'all'
|
|
});
|
|
var inner = editor.dom.create('div', { contenteditable: 'true' }, markedHtml);
|
|
editor.dom.setStyles(outer, {
|
|
position: 'fixed',
|
|
top: '0',
|
|
left: '-3000px',
|
|
width: '1000px',
|
|
overflow: 'hidden'
|
|
});
|
|
outer.appendChild(inner);
|
|
editor.dom.add(editor.getBody(), outer);
|
|
var range = editor.selection.getRng();
|
|
inner.focus();
|
|
var offscreenRange = editor.dom.createRng();
|
|
offscreenRange.selectNodeContents(inner);
|
|
editor.selection.setRng(offscreenRange);
|
|
global$9.setTimeout(function () {
|
|
editor.selection.setRng(range);
|
|
outer.parentNode.removeChild(outer);
|
|
done();
|
|
}, 0);
|
|
};
|
|
};
|
|
var getData = function (editor) {
|
|
return {
|
|
html: editor.selection.getContent({ contextual: true }),
|
|
text: editor.selection.getContent({ format: 'text' })
|
|
};
|
|
};
|
|
var isTableSelection = function (editor) {
|
|
return !!editor.dom.getParent(editor.selection.getStart(), 'td[data-mce-selected],th[data-mce-selected]', editor.getBody());
|
|
};
|
|
var hasSelectedContent = function (editor) {
|
|
return !editor.selection.isCollapsed() || isTableSelection(editor);
|
|
};
|
|
var cut = function (editor) {
|
|
return function (evt) {
|
|
if (hasSelectedContent(editor)) {
|
|
setClipboardData(evt, getData(editor), fallback(editor), function () {
|
|
if (global$a.browser.isChrome() || global$a.browser.isFirefox()) {
|
|
var rng_1 = editor.selection.getRng();
|
|
global$9.setEditorTimeout(editor, function () {
|
|
editor.selection.setRng(rng_1);
|
|
editor.execCommand('Delete');
|
|
}, 0);
|
|
} else {
|
|
editor.execCommand('Delete');
|
|
}
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var copy = function (editor) {
|
|
return function (evt) {
|
|
if (hasSelectedContent(editor)) {
|
|
setClipboardData(evt, getData(editor), fallback(editor), noop);
|
|
}
|
|
};
|
|
};
|
|
var register$1 = function (editor) {
|
|
editor.on('cut', cut(editor));
|
|
editor.on('copy', copy(editor));
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.dom.RangeUtils');
|
|
|
|
var getCaretRangeFromEvent = function (editor, e) {
|
|
return global.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
|
|
};
|
|
var isPlainTextFileUrl = function (content) {
|
|
var plainTextContent = content['text/plain'];
|
|
return plainTextContent ? plainTextContent.indexOf('file://') === 0 : false;
|
|
};
|
|
var setFocusedRange = function (editor, rng) {
|
|
editor.focus();
|
|
editor.selection.setRng(rng);
|
|
};
|
|
var setup$2 = function (editor, clipboard, draggingInternallyState) {
|
|
if (shouldBlockDrop(editor)) {
|
|
editor.on('dragend dragover draggesture dragdrop drop drag', function (e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
});
|
|
}
|
|
if (!shouldPasteDataImages(editor)) {
|
|
editor.on('drop', function (e) {
|
|
var dataTransfer = e.dataTransfer;
|
|
if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
editor.on('drop', function (e) {
|
|
var rng = getCaretRangeFromEvent(editor, e);
|
|
if (e.isDefaultPrevented() || draggingInternallyState.get()) {
|
|
return;
|
|
}
|
|
var dropContent = clipboard.getDataTransferItems(e.dataTransfer);
|
|
var internal = clipboard.hasContentType(dropContent, internalHtmlMime());
|
|
if ((!clipboard.hasHtmlOrText(dropContent) || isPlainTextFileUrl(dropContent)) && clipboard.pasteImageData(e, rng)) {
|
|
return;
|
|
}
|
|
if (rng && shouldFilterDrop(editor)) {
|
|
var content_1 = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
|
|
if (content_1) {
|
|
e.preventDefault();
|
|
global$9.setEditorTimeout(editor, function () {
|
|
editor.undoManager.transact(function () {
|
|
if (dropContent['mce-internal']) {
|
|
editor.execCommand('Delete');
|
|
}
|
|
setFocusedRange(editor, rng);
|
|
content_1 = trimHtml(content_1);
|
|
if (!dropContent['text/html']) {
|
|
clipboard.pasteText(content_1);
|
|
} else {
|
|
clipboard.pasteHtml(content_1, internal);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
editor.on('dragstart', function (_e) {
|
|
draggingInternallyState.set(true);
|
|
});
|
|
editor.on('dragover dragend', function (e) {
|
|
if (shouldPasteDataImages(editor) && draggingInternallyState.get() === false) {
|
|
e.preventDefault();
|
|
setFocusedRange(editor, getCaretRangeFromEvent(editor, e));
|
|
}
|
|
if (e.type === 'dragend') {
|
|
draggingInternallyState.set(false);
|
|
}
|
|
});
|
|
};
|
|
|
|
var setup$1 = function (editor) {
|
|
var plugin = editor.plugins.paste;
|
|
var preProcess = getPreProcess(editor);
|
|
if (preProcess) {
|
|
editor.on('PastePreProcess', function (e) {
|
|
preProcess.call(plugin, plugin, e);
|
|
});
|
|
}
|
|
var postProcess = getPostProcess(editor);
|
|
if (postProcess) {
|
|
editor.on('PastePostProcess', function (e) {
|
|
postProcess.call(plugin, plugin, e);
|
|
});
|
|
}
|
|
};
|
|
|
|
var addPreProcessFilter = function (editor, filterFunc) {
|
|
editor.on('PastePreProcess', function (e) {
|
|
e.content = filterFunc(editor, e.content, e.internal, e.wordContent);
|
|
});
|
|
};
|
|
var addPostProcessFilter = function (editor, filterFunc) {
|
|
editor.on('PastePostProcess', function (e) {
|
|
filterFunc(editor, e.node);
|
|
});
|
|
};
|
|
var removeExplorerBrElementsAfterBlocks = function (editor, html) {
|
|
if (!isWordContent(html)) {
|
|
return html;
|
|
}
|
|
var blockElements = [];
|
|
global$6.each(editor.schema.getBlockElements(), function (block, blockName) {
|
|
blockElements.push(blockName);
|
|
});
|
|
var explorerBlocksRegExp = new RegExp('(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*', 'g');
|
|
html = filter(html, [[
|
|
explorerBlocksRegExp,
|
|
'$1'
|
|
]]);
|
|
html = filter(html, [
|
|
[
|
|
/<br><br>/g,
|
|
'<BR><BR>'
|
|
],
|
|
[
|
|
/<br>/g,
|
|
' '
|
|
],
|
|
[
|
|
/<BR><BR>/g,
|
|
'<br>'
|
|
]
|
|
]);
|
|
return html;
|
|
};
|
|
var removeWebKitStyles = function (editor, content, internal, isWordHtml) {
|
|
if (isWordHtml || internal) {
|
|
return content;
|
|
}
|
|
var webKitStylesSetting = getWebkitStyles(editor);
|
|
var webKitStyles;
|
|
if (shouldRemoveWebKitStyles(editor) === false || webKitStylesSetting === 'all') {
|
|
return content;
|
|
}
|
|
if (webKitStylesSetting) {
|
|
webKitStyles = webKitStylesSetting.split(/[, ]/);
|
|
}
|
|
if (webKitStyles) {
|
|
var dom_1 = editor.dom, node_1 = editor.selection.getNode();
|
|
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function (all, before, value, after) {
|
|
var inputStyles = dom_1.parseStyle(dom_1.decode(value));
|
|
var outputStyles = {};
|
|
if (webKitStyles === 'none') {
|
|
return before + after;
|
|
}
|
|
for (var i = 0; i < webKitStyles.length; i++) {
|
|
var inputValue = inputStyles[webKitStyles[i]], currentValue = dom_1.getStyle(node_1, webKitStyles[i], true);
|
|
if (/color/.test(webKitStyles[i])) {
|
|
inputValue = dom_1.toHex(inputValue);
|
|
currentValue = dom_1.toHex(currentValue);
|
|
}
|
|
if (currentValue !== inputValue) {
|
|
outputStyles[webKitStyles[i]] = inputValue;
|
|
}
|
|
}
|
|
var outputStyle = dom_1.serializeStyle(outputStyles, 'span');
|
|
if (outputStyle) {
|
|
return before + ' style="' + outputStyle + '"' + after;
|
|
}
|
|
return before + after;
|
|
});
|
|
} else {
|
|
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
|
|
}
|
|
content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function (all, before, value, after) {
|
|
return before + ' style="' + value + '"' + after;
|
|
});
|
|
return content;
|
|
};
|
|
var removeUnderlineAndFontInAnchor = function (editor, root) {
|
|
editor.$('a', root).find('font,u').each(function (i, node) {
|
|
editor.dom.remove(node, true);
|
|
});
|
|
};
|
|
var setup = function (editor) {
|
|
if (global$a.webkit) {
|
|
addPreProcessFilter(editor, removeWebKitStyles);
|
|
}
|
|
if (global$a.ie) {
|
|
addPreProcessFilter(editor, removeExplorerBrElementsAfterBlocks);
|
|
addPostProcessFilter(editor, removeUnderlineAndFontInAnchor);
|
|
}
|
|
};
|
|
|
|
var makeSetupHandler = function (editor, clipboard) {
|
|
return function (api) {
|
|
api.setActive(clipboard.pasteFormat.get() === 'text');
|
|
var pastePlainTextToggleHandler = function (e) {
|
|
return api.setActive(e.state);
|
|
};
|
|
editor.on('PastePlainTextToggle', pastePlainTextToggleHandler);
|
|
return function () {
|
|
return editor.off('PastePlainTextToggle', pastePlainTextToggleHandler);
|
|
};
|
|
};
|
|
};
|
|
var register = function (editor, clipboard) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceTogglePlainTextPaste');
|
|
};
|
|
editor.ui.registry.addToggleButton('pastetext', {
|
|
active: false,
|
|
icon: 'paste-text',
|
|
tooltip: 'Paste as text',
|
|
onAction: onAction,
|
|
onSetup: makeSetupHandler(editor, clipboard)
|
|
});
|
|
editor.ui.registry.addToggleMenuItem('pastetext', {
|
|
text: 'Paste as text',
|
|
icon: 'paste-text',
|
|
onAction: onAction,
|
|
onSetup: makeSetupHandler(editor, clipboard)
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$b.add('paste', function (editor) {
|
|
if (hasProPlugin(editor) === false) {
|
|
var draggingInternallyState = Cell(false);
|
|
var pasteFormat = Cell(isPasteAsTextEnabled(editor) ? 'text' : 'html');
|
|
var clipboard = Clipboard(editor, pasteFormat);
|
|
setup(editor);
|
|
register(editor, clipboard);
|
|
register$2(editor, clipboard);
|
|
setup$1(editor);
|
|
register$1(editor);
|
|
setup$2(editor, clipboard, draggingInternallyState);
|
|
return get(clipboard);
|
|
}
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getContentStyle = function (editor) {
|
|
return editor.getParam('content_style', '', 'string');
|
|
};
|
|
var shouldUseContentCssCors = function (editor) {
|
|
return editor.getParam('content_css_cors', false, 'boolean');
|
|
};
|
|
var getBodyClassByHash = function (editor) {
|
|
var bodyClass = editor.getParam('body_class', '', 'hash');
|
|
return bodyClass[editor.id] || '';
|
|
};
|
|
var getBodyClass = function (editor) {
|
|
var bodyClass = editor.getParam('body_class', '', 'string');
|
|
if (bodyClass.indexOf('=') === -1) {
|
|
return bodyClass;
|
|
} else {
|
|
return getBodyClassByHash(editor);
|
|
}
|
|
};
|
|
var getBodyIdByHash = function (editor) {
|
|
var bodyId = editor.getParam('body_id', '', 'hash');
|
|
return bodyId[editor.id] || bodyId;
|
|
};
|
|
var getBodyId = function (editor) {
|
|
var bodyId = editor.getParam('body_id', 'tinymce', 'string');
|
|
if (bodyId.indexOf('=') === -1) {
|
|
return bodyId;
|
|
} else {
|
|
return getBodyIdByHash(editor);
|
|
}
|
|
};
|
|
|
|
var getPreviewHtml = function (editor) {
|
|
var headHtml = '';
|
|
var encode = editor.dom.encode;
|
|
var contentStyle = getContentStyle(editor);
|
|
headHtml += '<base href="' + encode(editor.documentBaseURI.getURI()) + '">';
|
|
var cors = shouldUseContentCssCors(editor) ? ' crossorigin="anonymous"' : '';
|
|
global.each(editor.contentCSS, function (url) {
|
|
headHtml += '<link type="text/css" rel="stylesheet" href="' + encode(editor.documentBaseURI.toAbsolute(url)) + '"' + cors + '>';
|
|
});
|
|
if (contentStyle) {
|
|
headHtml += '<style type="text/css">' + contentStyle + '</style>';
|
|
}
|
|
var bodyId = getBodyId(editor);
|
|
var bodyClass = getBodyClass(editor);
|
|
var isMetaKeyPressed = global$1.mac ? 'e.metaKey' : 'e.ctrlKey && !e.altKey';
|
|
var preventClicksOnLinksScript = '<script>' + 'document.addEventListener && document.addEventListener("click", function(e) {' + 'for (var elm = e.target; elm; elm = elm.parentNode) {' + 'if (elm.nodeName === "A" && !(' + isMetaKeyPressed + ')) {' + 'e.preventDefault();' + '}' + '}' + '}, false);' + '</script> ';
|
|
var directionality = editor.getBody().dir;
|
|
var dirAttr = directionality ? ' dir="' + encode(directionality) + '"' : '';
|
|
var previewHtml = '<!DOCTYPE html>' + '<html>' + '<head>' + headHtml + '</head>' + '<body id="' + encode(bodyId) + '" class="mce-content-body ' + encode(bodyClass) + '"' + dirAttr + '>' + editor.getContent() + preventClicksOnLinksScript + '</body>' + '</html>';
|
|
return previewHtml;
|
|
};
|
|
|
|
var open = function (editor) {
|
|
var content = getPreviewHtml(editor);
|
|
var dataApi = editor.windowManager.open({
|
|
title: 'Preview',
|
|
size: 'large',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
name: 'preview',
|
|
type: 'iframe',
|
|
sandboxed: true
|
|
}]
|
|
},
|
|
buttons: [{
|
|
type: 'cancel',
|
|
name: 'close',
|
|
text: 'Close',
|
|
primary: true
|
|
}],
|
|
initialData: { preview: content }
|
|
});
|
|
dataApi.focus('close');
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mcePreview', function () {
|
|
open(editor);
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mcePreview');
|
|
};
|
|
editor.ui.registry.addButton('preview', {
|
|
icon: 'preview',
|
|
tooltip: 'Preview',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('preview', {
|
|
icon: 'preview',
|
|
text: 'Preview',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$2.add('preview', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mcePrint', function () {
|
|
if (global.browser.isIE()) {
|
|
editor.getDoc().execCommand('print', false, null);
|
|
} else {
|
|
editor.getWin().print();
|
|
}
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mcePrint');
|
|
};
|
|
editor.ui.registry.addButton('print', {
|
|
icon: 'print',
|
|
tooltip: 'Print',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('print', {
|
|
text: 'Print...',
|
|
icon: 'print',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('print', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
editor.addShortcut('Meta+P', '', 'mcePrint');
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var unique = 0;
|
|
var generate = function (prefix) {
|
|
var date = new Date();
|
|
var time = date.getTime();
|
|
var random = Math.floor(Math.random() * 1000000000);
|
|
unique++;
|
|
return prefix + '_' + random + unique + String(time);
|
|
};
|
|
|
|
var createTableHtml = function (cols, rows) {
|
|
var html = '<table data-mce-id="mce" style="width: 100%">';
|
|
html += '<tbody>';
|
|
for (var y = 0; y < rows; y++) {
|
|
html += '<tr>';
|
|
for (var x = 0; x < cols; x++) {
|
|
html += '<td><br></td>';
|
|
}
|
|
html += '</tr>';
|
|
}
|
|
html += '</tbody>';
|
|
html += '</table>';
|
|
return html;
|
|
};
|
|
var getInsertedElement = function (editor) {
|
|
var elms = editor.dom.select('*[data-mce-id]');
|
|
return elms[0];
|
|
};
|
|
var insertTableHtml = function (editor, cols, rows) {
|
|
editor.undoManager.transact(function () {
|
|
editor.insertContent(createTableHtml(cols, rows));
|
|
var tableElm = getInsertedElement(editor);
|
|
tableElm.removeAttribute('data-mce-id');
|
|
var cellElm = editor.dom.select('td,th', tableElm);
|
|
editor.selection.setCursorLocation(cellElm[0], 0);
|
|
});
|
|
};
|
|
var insertTable = function (editor, cols, rows) {
|
|
editor.plugins.table ? editor.plugins.table.insertTable(cols, rows) : insertTableHtml(editor, cols, rows);
|
|
};
|
|
var insertBlob = function (editor, base64, blob) {
|
|
var blobCache = editor.editorUpload.blobCache;
|
|
var blobInfo = blobCache.create(generate('mceu'), blob, base64);
|
|
blobCache.add(blobInfo);
|
|
editor.insertContent(editor.dom.createHTML('img', { src: blobInfo.blobUri() }));
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var blobToBase64 = function (blob) {
|
|
return new global$2(function (resolve) {
|
|
var reader = new FileReader();
|
|
reader.onloadend = function () {
|
|
resolve(reader.result.split(',')[1]);
|
|
};
|
|
reader.readAsDataURL(blob);
|
|
});
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var pickFile = function (editor) {
|
|
return new global$2(function (resolve) {
|
|
var fileInput = document.createElement('input');
|
|
fileInput.type = 'file';
|
|
fileInput.accept = 'image/*';
|
|
fileInput.style.position = 'fixed';
|
|
fileInput.style.left = '0';
|
|
fileInput.style.top = '0';
|
|
fileInput.style.opacity = '0.001';
|
|
document.body.appendChild(fileInput);
|
|
var changeHandler = function (e) {
|
|
resolve(Array.prototype.slice.call(e.target.files));
|
|
};
|
|
fileInput.addEventListener('change', changeHandler);
|
|
var cancelHandler = function (e) {
|
|
var cleanup = function () {
|
|
resolve([]);
|
|
fileInput.parentNode.removeChild(fileInput);
|
|
};
|
|
if (global$1.os.isAndroid() && e.type !== 'remove') {
|
|
global.setEditorTimeout(editor, cleanup, 0);
|
|
} else {
|
|
cleanup();
|
|
}
|
|
editor.off('focusin remove', cancelHandler);
|
|
};
|
|
editor.on('focusin remove', cancelHandler);
|
|
fileInput.click();
|
|
});
|
|
};
|
|
|
|
var setupButtons = function (editor) {
|
|
editor.ui.registry.addButton('quickimage', {
|
|
icon: 'image',
|
|
tooltip: 'Insert image',
|
|
onAction: function () {
|
|
pickFile(editor).then(function (files) {
|
|
if (files.length > 0) {
|
|
var blob_1 = files[0];
|
|
blobToBase64(blob_1).then(function (base64) {
|
|
insertBlob(editor, base64, blob_1);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
editor.ui.registry.addButton('quicktable', {
|
|
icon: 'table',
|
|
tooltip: 'Insert table',
|
|
onAction: function () {
|
|
insertTable(editor, 2, 2);
|
|
}
|
|
});
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var eq = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isString = isType('string');
|
|
var isObject = isType('object');
|
|
var isArray = isType('array');
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isUndefined = eq(undefined);
|
|
var isFunction = isSimpleType('function');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
function ClosestOrAncestor (is, ancestor, scope, a, isRoot) {
|
|
if (is(scope, a)) {
|
|
return Optional.some(scope);
|
|
} else if (isFunction(isRoot) && isRoot(scope)) {
|
|
return Optional.none();
|
|
} else {
|
|
return ancestor(scope, a, isRoot);
|
|
}
|
|
}
|
|
|
|
var ELEMENT = 1;
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var is = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var name = function (element) {
|
|
var r = element.dom.nodeName;
|
|
return r.toLowerCase();
|
|
};
|
|
|
|
var ancestor$1 = function (scope, predicate, isRoot) {
|
|
var element = scope.dom;
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
while (element.parentNode) {
|
|
element = element.parentNode;
|
|
var el = SugarElement.fromDom(element);
|
|
if (predicate(el)) {
|
|
return Optional.some(el);
|
|
} else if (stop(el)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var closest$1 = function (scope, predicate, isRoot) {
|
|
var is = function (s, test) {
|
|
return test(s);
|
|
};
|
|
return ClosestOrAncestor(is, ancestor$1, scope, predicate, isRoot);
|
|
};
|
|
|
|
var ancestor = function (scope, selector, isRoot) {
|
|
return ancestor$1(scope, function (e) {
|
|
return is(e, selector);
|
|
}, isRoot);
|
|
};
|
|
var closest = function (scope, selector, isRoot) {
|
|
var is$1 = function (element, selector) {
|
|
return is(element, selector);
|
|
};
|
|
return ClosestOrAncestor(is$1, ancestor, scope, selector, isRoot);
|
|
};
|
|
|
|
var validDefaultOrDie = function (value, predicate) {
|
|
if (predicate(value)) {
|
|
return true;
|
|
}
|
|
throw new Error('Default value doesn\'t match requested type.');
|
|
};
|
|
var items = function (value, defaultValue) {
|
|
if (isArray(value) || isObject(value)) {
|
|
throw new Error('expected a string but found: ' + value);
|
|
}
|
|
if (isUndefined(value)) {
|
|
return defaultValue;
|
|
}
|
|
if (isBoolean(value)) {
|
|
return value === false ? '' : defaultValue;
|
|
}
|
|
return value;
|
|
};
|
|
var getToolbarItemsOr_ = function (predicate) {
|
|
return function (editor, name, defaultValue) {
|
|
validDefaultOrDie(defaultValue, predicate);
|
|
var value = editor.getParam(name, defaultValue);
|
|
return items(value, defaultValue);
|
|
};
|
|
};
|
|
var getToolbarItemsOr = getToolbarItemsOr_(isString);
|
|
|
|
var getTextSelectionToolbarItems = function (editor) {
|
|
return getToolbarItemsOr(editor, 'quickbars_selection_toolbar', 'bold italic | quicklink h2 h3 blockquote');
|
|
};
|
|
var getInsertToolbarItems = function (editor) {
|
|
return getToolbarItemsOr(editor, 'quickbars_insert_toolbar', 'quickimage quicktable');
|
|
};
|
|
var getImageToolbarItems = function (editor) {
|
|
return getToolbarItemsOr(editor, 'quickbars_image_toolbar', 'alignleft aligncenter alignright');
|
|
};
|
|
|
|
var addToEditor$1 = function (editor) {
|
|
var insertToolbarItems = getInsertToolbarItems(editor);
|
|
if (insertToolbarItems.trim().length > 0) {
|
|
editor.ui.registry.addContextToolbar('quickblock', {
|
|
predicate: function (node) {
|
|
var sugarNode = SugarElement.fromDom(node);
|
|
var textBlockElementsMap = editor.schema.getTextBlockElements();
|
|
var isRoot = function (elem) {
|
|
return elem.dom === editor.getBody();
|
|
};
|
|
return closest(sugarNode, 'table', isRoot).fold(function () {
|
|
return closest$1(sugarNode, function (elem) {
|
|
return name(elem) in textBlockElementsMap && editor.dom.isEmpty(elem.dom);
|
|
}, isRoot).isSome();
|
|
}, never);
|
|
},
|
|
items: insertToolbarItems,
|
|
position: 'line',
|
|
scope: 'editor'
|
|
});
|
|
}
|
|
};
|
|
|
|
var addToEditor = function (editor) {
|
|
var isEditable = function (node) {
|
|
return editor.dom.getContentEditableParent(node) !== 'false';
|
|
};
|
|
var isImage = function (node) {
|
|
return node.nodeName === 'IMG' || node.nodeName === 'FIGURE' && /image/i.test(node.className);
|
|
};
|
|
var imageToolbarItems = getImageToolbarItems(editor);
|
|
if (imageToolbarItems.trim().length > 0) {
|
|
editor.ui.registry.addContextToolbar('imageselection', {
|
|
predicate: isImage,
|
|
items: imageToolbarItems,
|
|
position: 'node'
|
|
});
|
|
}
|
|
var textToolbarItems = getTextSelectionToolbarItems(editor);
|
|
if (textToolbarItems.trim().length > 0) {
|
|
editor.ui.registry.addContextToolbar('textselection', {
|
|
predicate: function (node) {
|
|
return !isImage(node) && !editor.selection.isCollapsed() && isEditable(node);
|
|
},
|
|
items: textToolbarItems,
|
|
position: 'selection',
|
|
scope: 'editor'
|
|
});
|
|
}
|
|
};
|
|
|
|
function Plugin () {
|
|
global$3.add('quickbars', function (editor) {
|
|
setupButtons(editor);
|
|
addToEditor$1(editor);
|
|
addToEditor(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var enableWhenDirty = function (editor) {
|
|
return editor.getParam('save_enablewhendirty', true);
|
|
};
|
|
var hasOnSaveCallback = function (editor) {
|
|
return !!editor.getParam('save_onsavecallback');
|
|
};
|
|
var hasOnCancelCallback = function (editor) {
|
|
return !!editor.getParam('save_oncancelcallback');
|
|
};
|
|
|
|
var displayErrorMessage = function (editor, message) {
|
|
editor.notificationManager.open({
|
|
text: message,
|
|
type: 'error'
|
|
});
|
|
};
|
|
var save = function (editor) {
|
|
var formObj = global$1.DOM.getParent(editor.id, 'form');
|
|
if (enableWhenDirty(editor) && !editor.isDirty()) {
|
|
return;
|
|
}
|
|
editor.save();
|
|
if (hasOnSaveCallback(editor)) {
|
|
editor.execCallback('save_onsavecallback', editor);
|
|
editor.nodeChanged();
|
|
return;
|
|
}
|
|
if (formObj) {
|
|
editor.setDirty(false);
|
|
if (!formObj.onsubmit || formObj.onsubmit()) {
|
|
if (typeof formObj.submit === 'function') {
|
|
formObj.submit();
|
|
} else {
|
|
displayErrorMessage(editor, 'Error: Form submit field collision.');
|
|
}
|
|
}
|
|
editor.nodeChanged();
|
|
} else {
|
|
displayErrorMessage(editor, 'Error: No form element found.');
|
|
}
|
|
};
|
|
var cancel = function (editor) {
|
|
var h = global.trim(editor.startContent);
|
|
if (hasOnCancelCallback(editor)) {
|
|
editor.execCallback('save_oncancelcallback', editor);
|
|
return;
|
|
}
|
|
editor.resetContent(h);
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceSave', function () {
|
|
save(editor);
|
|
});
|
|
editor.addCommand('mceCancel', function () {
|
|
cancel(editor);
|
|
});
|
|
};
|
|
|
|
var stateToggle = function (editor) {
|
|
return function (api) {
|
|
var handler = function () {
|
|
api.setDisabled(enableWhenDirty(editor) && !editor.isDirty());
|
|
};
|
|
handler();
|
|
editor.on('NodeChange dirty', handler);
|
|
return function () {
|
|
return editor.off('NodeChange dirty', handler);
|
|
};
|
|
};
|
|
};
|
|
var register = function (editor) {
|
|
editor.ui.registry.addButton('save', {
|
|
icon: 'save',
|
|
tooltip: 'Save',
|
|
disabled: true,
|
|
onAction: function () {
|
|
return editor.execCommand('mceSave');
|
|
},
|
|
onSetup: stateToggle(editor)
|
|
});
|
|
editor.ui.registry.addButton('cancel', {
|
|
icon: 'cancel',
|
|
tooltip: 'Cancel',
|
|
disabled: true,
|
|
onAction: function () {
|
|
return editor.execCommand('mceCancel');
|
|
},
|
|
onSetup: stateToggle(editor)
|
|
});
|
|
editor.addShortcut('Meta+S', '', 'mceSave');
|
|
};
|
|
|
|
function Plugin () {
|
|
global$2.add('save', function (editor) {
|
|
register(editor);
|
|
register$1(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isArray = isType$1('array');
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var punctuationStr = '[!-#%-*,-\\/:;?@\\[-\\]_{}\xA1\xAB\xB7\xBB\xBF;\xB7\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1361-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u3008\u3009\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30\u2E31\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uff3f\uFF5B\uFF5D\uFF5F-\uFF65]';
|
|
|
|
var punctuation$1 = constant(punctuationStr);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var punctuation = punctuation$1;
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var nativeSlice = Array.prototype.slice;
|
|
var nativePush = Array.prototype.push;
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var eachr = function (xs, f) {
|
|
for (var i = xs.length - 1; i >= 0; i--) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var groupBy = function (xs, f) {
|
|
if (xs.length === 0) {
|
|
return [];
|
|
} else {
|
|
var wasType = f(xs[0]);
|
|
var r = [];
|
|
var group = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
var type = f(x);
|
|
if (type !== wasType) {
|
|
r.push(group);
|
|
group = [];
|
|
}
|
|
wasType = type;
|
|
group.push(x);
|
|
}
|
|
if (group.length !== 0) {
|
|
r.push(group);
|
|
}
|
|
return r;
|
|
}
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var flatten = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind = function (xs, f) {
|
|
return flatten(map(xs, f));
|
|
};
|
|
var sort = function (xs, comparator) {
|
|
var copy = nativeSlice.call(xs, 0);
|
|
copy.sort(comparator);
|
|
return copy;
|
|
};
|
|
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var DOCUMENT = 9;
|
|
var DOCUMENT_FRAGMENT = 11;
|
|
var ELEMENT = 1;
|
|
var TEXT = 3;
|
|
|
|
var type = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type(element) === t;
|
|
};
|
|
};
|
|
var isText$1 = isType(TEXT);
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
|
|
var compareDocumentPosition = function (a, b, match) {
|
|
return (a.compareDocumentPosition(b) & match) !== 0;
|
|
};
|
|
var documentPositionPreceding = function (a, b) {
|
|
return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_PRECEDING);
|
|
};
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var bypassSelector = function (dom) {
|
|
return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
|
|
};
|
|
var all = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), SugarElement.fromDom);
|
|
};
|
|
|
|
var parent = function (element) {
|
|
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
};
|
|
var children = function (element) {
|
|
return map(element.dom.childNodes, SugarElement.fromDom);
|
|
};
|
|
var spot = function (element, offset) {
|
|
return {
|
|
element: element,
|
|
offset: offset
|
|
};
|
|
};
|
|
var leaf = function (element, offset) {
|
|
var cs = children(element);
|
|
return cs.length > 0 && offset < cs.length ? spot(cs[offset], 0) : spot(element, offset);
|
|
};
|
|
|
|
var before = function (marker, element) {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
v.dom.insertBefore(element.dom, marker.dom);
|
|
});
|
|
};
|
|
var append = function (parent, element) {
|
|
parent.dom.appendChild(element.dom);
|
|
};
|
|
var wrap = function (element, wrapper) {
|
|
before(element, wrapper);
|
|
append(wrapper, element);
|
|
};
|
|
|
|
var NodeValue = function (is, name) {
|
|
var get = function (element) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
return getOption(element).getOr('');
|
|
};
|
|
var getOption = function (element) {
|
|
return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
|
|
};
|
|
var set = function (element, value) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
element.dom.nodeValue = value;
|
|
};
|
|
return {
|
|
get: get,
|
|
getOption: getOption,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var api = NodeValue(isText$1, 'text');
|
|
var get$1 = function (element) {
|
|
return api.get(element);
|
|
};
|
|
|
|
var descendants = function (scope, selector) {
|
|
return all(selector, scope);
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
|
|
|
var isSimpleBoundary = function (dom, node) {
|
|
return dom.isBlock(node) || has(dom.schema.getShortEndedElements(), node.nodeName);
|
|
};
|
|
var isContentEditableFalse = function (dom, node) {
|
|
return dom.getContentEditable(node) === 'false';
|
|
};
|
|
var isContentEditableTrueInCef = function (dom, node) {
|
|
return dom.getContentEditable(node) === 'true' && dom.getContentEditableParent(node.parentNode) === 'false';
|
|
};
|
|
var isHidden = function (dom, node) {
|
|
return !dom.isBlock(node) && has(dom.schema.getWhiteSpaceElements(), node.nodeName);
|
|
};
|
|
var isBoundary = function (dom, node) {
|
|
return isSimpleBoundary(dom, node) || isContentEditableFalse(dom, node) || isHidden(dom, node) || isContentEditableTrueInCef(dom, node);
|
|
};
|
|
var isText = function (node) {
|
|
return node.nodeType === 3;
|
|
};
|
|
var nuSection = function () {
|
|
return {
|
|
sOffset: 0,
|
|
fOffset: 0,
|
|
elements: []
|
|
};
|
|
};
|
|
var toLeaf = function (node, offset) {
|
|
return leaf(SugarElement.fromDom(node), offset);
|
|
};
|
|
var walk = function (dom, walkerFn, startNode, callbacks, endNode, skipStart) {
|
|
if (skipStart === void 0) {
|
|
skipStart = true;
|
|
}
|
|
var next = skipStart ? walkerFn(false) : startNode;
|
|
while (next) {
|
|
var isCefNode = isContentEditableFalse(dom, next);
|
|
if (isCefNode || isHidden(dom, next)) {
|
|
var stopWalking = isCefNode ? callbacks.cef(next) : callbacks.boundary(next);
|
|
if (stopWalking) {
|
|
break;
|
|
} else {
|
|
next = walkerFn(true);
|
|
continue;
|
|
}
|
|
} else if (isSimpleBoundary(dom, next)) {
|
|
if (callbacks.boundary(next)) {
|
|
break;
|
|
}
|
|
} else if (isText(next)) {
|
|
callbacks.text(next);
|
|
}
|
|
if (next === endNode) {
|
|
break;
|
|
} else {
|
|
next = walkerFn(false);
|
|
}
|
|
}
|
|
};
|
|
var collectTextToBoundary = function (dom, section, node, rootNode, forwards) {
|
|
if (isBoundary(dom, node)) {
|
|
return;
|
|
}
|
|
var rootBlock = dom.getParent(rootNode, dom.isBlock);
|
|
var walker = new global(node, rootBlock);
|
|
var walkerFn = forwards ? walker.next.bind(walker) : walker.prev.bind(walker);
|
|
walk(dom, walkerFn, node, {
|
|
boundary: always,
|
|
cef: always,
|
|
text: function (next) {
|
|
if (forwards) {
|
|
section.fOffset += next.length;
|
|
} else {
|
|
section.sOffset += next.length;
|
|
}
|
|
section.elements.push(SugarElement.fromDom(next));
|
|
}
|
|
});
|
|
};
|
|
var collect = function (dom, rootNode, startNode, endNode, callbacks, skipStart) {
|
|
if (skipStart === void 0) {
|
|
skipStart = true;
|
|
}
|
|
var walker = new global(startNode, rootNode);
|
|
var sections = [];
|
|
var current = nuSection();
|
|
collectTextToBoundary(dom, current, startNode, rootNode, false);
|
|
var finishSection = function () {
|
|
if (current.elements.length > 0) {
|
|
sections.push(current);
|
|
current = nuSection();
|
|
}
|
|
return false;
|
|
};
|
|
walk(dom, walker.next.bind(walker), startNode, {
|
|
boundary: finishSection,
|
|
cef: function (node) {
|
|
finishSection();
|
|
if (callbacks) {
|
|
sections.push.apply(sections, callbacks.cef(node));
|
|
}
|
|
return false;
|
|
},
|
|
text: function (next) {
|
|
current.elements.push(SugarElement.fromDom(next));
|
|
if (callbacks) {
|
|
callbacks.text(next, current);
|
|
}
|
|
}
|
|
}, endNode, skipStart);
|
|
if (endNode) {
|
|
collectTextToBoundary(dom, current, endNode, rootNode, true);
|
|
}
|
|
finishSection();
|
|
return sections;
|
|
};
|
|
var collectRangeSections = function (dom, rng) {
|
|
var start = toLeaf(rng.startContainer, rng.startOffset);
|
|
var startNode = start.element.dom;
|
|
var end = toLeaf(rng.endContainer, rng.endOffset);
|
|
var endNode = end.element.dom;
|
|
return collect(dom, rng.commonAncestorContainer, startNode, endNode, {
|
|
text: function (node, section) {
|
|
if (node === endNode) {
|
|
section.fOffset += node.length - end.offset;
|
|
} else if (node === startNode) {
|
|
section.sOffset += start.offset;
|
|
}
|
|
},
|
|
cef: function (node) {
|
|
var sections = bind(descendants(SugarElement.fromDom(node), '*[contenteditable=true]'), function (e) {
|
|
var ceTrueNode = e.dom;
|
|
return collect(dom, ceTrueNode, ceTrueNode);
|
|
});
|
|
return sort(sections, function (a, b) {
|
|
return documentPositionPreceding(a.elements[0].dom, b.elements[0].dom) ? 1 : -1;
|
|
});
|
|
}
|
|
}, false);
|
|
};
|
|
var fromRng = function (dom, rng) {
|
|
return rng.collapsed ? [] : collectRangeSections(dom, rng);
|
|
};
|
|
var fromNode = function (dom, node) {
|
|
var rng = dom.createRng();
|
|
rng.selectNode(node);
|
|
return fromRng(dom, rng);
|
|
};
|
|
var fromNodes = function (dom, nodes) {
|
|
return bind(nodes, function (node) {
|
|
return fromNode(dom, node);
|
|
});
|
|
};
|
|
|
|
var find$2 = function (text, pattern, start, finish) {
|
|
if (start === void 0) {
|
|
start = 0;
|
|
}
|
|
if (finish === void 0) {
|
|
finish = text.length;
|
|
}
|
|
var regex = pattern.regex;
|
|
regex.lastIndex = start;
|
|
var results = [];
|
|
var match;
|
|
while (match = regex.exec(text)) {
|
|
var matchedText = match[pattern.matchIndex];
|
|
var matchStart = match.index + match[0].indexOf(matchedText);
|
|
var matchFinish = matchStart + matchedText.length;
|
|
if (matchFinish > finish) {
|
|
break;
|
|
}
|
|
results.push({
|
|
start: matchStart,
|
|
finish: matchFinish
|
|
});
|
|
regex.lastIndex = matchFinish;
|
|
}
|
|
return results;
|
|
};
|
|
var extract = function (elements, matches) {
|
|
var nodePositions = foldl(elements, function (acc, element) {
|
|
var content = get$1(element);
|
|
var start = acc.last;
|
|
var finish = start + content.length;
|
|
var positions = bind(matches, function (match, matchIdx) {
|
|
if (match.start < finish && match.finish > start) {
|
|
return [{
|
|
element: element,
|
|
start: Math.max(start, match.start) - start,
|
|
finish: Math.min(finish, match.finish) - start,
|
|
matchId: matchIdx
|
|
}];
|
|
} else {
|
|
return [];
|
|
}
|
|
});
|
|
return {
|
|
results: acc.results.concat(positions),
|
|
last: finish
|
|
};
|
|
}, {
|
|
results: [],
|
|
last: 0
|
|
}).results;
|
|
return groupBy(nodePositions, function (position) {
|
|
return position.matchId;
|
|
});
|
|
};
|
|
|
|
var find$1 = function (pattern, sections) {
|
|
return bind(sections, function (section) {
|
|
var elements = section.elements;
|
|
var content = map(elements, get$1).join('');
|
|
var positions = find$2(content, pattern, section.sOffset, content.length - section.fOffset);
|
|
return extract(elements, positions);
|
|
});
|
|
};
|
|
var mark = function (matches, replacementNode) {
|
|
eachr(matches, function (match, idx) {
|
|
eachr(match, function (pos) {
|
|
var wrapper = SugarElement.fromDom(replacementNode.cloneNode(false));
|
|
set(wrapper, 'data-mce-index', idx);
|
|
var textNode = pos.element.dom;
|
|
if (textNode.length === pos.finish && pos.start === 0) {
|
|
wrap(pos.element, wrapper);
|
|
} else {
|
|
if (textNode.length !== pos.finish) {
|
|
textNode.splitText(pos.finish);
|
|
}
|
|
var matchNode = textNode.splitText(pos.start);
|
|
wrap(SugarElement.fromDom(matchNode), wrapper);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var findAndMark = function (dom, pattern, node, replacementNode) {
|
|
var textSections = fromNode(dom, node);
|
|
var matches = find$1(pattern, textSections);
|
|
mark(matches, replacementNode);
|
|
return matches.length;
|
|
};
|
|
var findAndMarkInSelection = function (dom, pattern, selection, replacementNode) {
|
|
var bookmark = selection.getBookmark();
|
|
var nodes = dom.select('td[data-mce-selected],th[data-mce-selected]');
|
|
var textSections = nodes.length > 0 ? fromNodes(dom, nodes) : fromRng(dom, selection.getRng());
|
|
var matches = find$1(pattern, textSections);
|
|
mark(matches, replacementNode);
|
|
selection.moveToBookmark(bookmark);
|
|
return matches.length;
|
|
};
|
|
|
|
var getElmIndex = function (elm) {
|
|
var value = elm.getAttribute('data-mce-index');
|
|
if (typeof value === 'number') {
|
|
return '' + value;
|
|
}
|
|
return value;
|
|
};
|
|
var markAllMatches = function (editor, currentSearchState, pattern, inSelection) {
|
|
var marker = editor.dom.create('span', { 'data-mce-bogus': 1 });
|
|
marker.className = 'mce-match-marker';
|
|
var node = editor.getBody();
|
|
done(editor, currentSearchState, false);
|
|
if (inSelection) {
|
|
return findAndMarkInSelection(editor.dom, pattern, editor.selection, marker);
|
|
} else {
|
|
return findAndMark(editor.dom, pattern, node, marker);
|
|
}
|
|
};
|
|
var unwrap = function (node) {
|
|
var parentNode = node.parentNode;
|
|
if (node.firstChild) {
|
|
parentNode.insertBefore(node.firstChild, node);
|
|
}
|
|
node.parentNode.removeChild(node);
|
|
};
|
|
var findSpansByIndex = function (editor, index) {
|
|
var spans = [];
|
|
var nodes = global$1.toArray(editor.getBody().getElementsByTagName('span'));
|
|
if (nodes.length) {
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
var nodeIndex = getElmIndex(nodes[i]);
|
|
if (nodeIndex === null || !nodeIndex.length) {
|
|
continue;
|
|
}
|
|
if (nodeIndex === index.toString()) {
|
|
spans.push(nodes[i]);
|
|
}
|
|
}
|
|
}
|
|
return spans;
|
|
};
|
|
var moveSelection = function (editor, currentSearchState, forward) {
|
|
var searchState = currentSearchState.get();
|
|
var testIndex = searchState.index;
|
|
var dom = editor.dom;
|
|
forward = forward !== false;
|
|
if (forward) {
|
|
if (testIndex + 1 === searchState.count) {
|
|
testIndex = 0;
|
|
} else {
|
|
testIndex++;
|
|
}
|
|
} else {
|
|
if (testIndex - 1 === -1) {
|
|
testIndex = searchState.count - 1;
|
|
} else {
|
|
testIndex--;
|
|
}
|
|
}
|
|
dom.removeClass(findSpansByIndex(editor, searchState.index), 'mce-match-marker-selected');
|
|
var spans = findSpansByIndex(editor, testIndex);
|
|
if (spans.length) {
|
|
dom.addClass(findSpansByIndex(editor, testIndex), 'mce-match-marker-selected');
|
|
editor.selection.scrollIntoView(spans[0]);
|
|
return testIndex;
|
|
}
|
|
return -1;
|
|
};
|
|
var removeNode = function (dom, node) {
|
|
var parent = node.parentNode;
|
|
dom.remove(node);
|
|
if (dom.isEmpty(parent)) {
|
|
dom.remove(parent);
|
|
}
|
|
};
|
|
var escapeSearchText = function (text, wholeWord) {
|
|
var escapedText = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&').replace(/\s/g, '[^\\S\\r\\n\\uFEFF]');
|
|
var wordRegex = '(' + escapedText + ')';
|
|
return wholeWord ? '(?:^|\\s|' + punctuation() + ')' + wordRegex + ('(?=$|\\s|' + punctuation() + ')') : wordRegex;
|
|
};
|
|
var find = function (editor, currentSearchState, text, matchCase, wholeWord, inSelection) {
|
|
var selection = editor.selection;
|
|
var escapedText = escapeSearchText(text, wholeWord);
|
|
var isForwardSelection = selection.isForward();
|
|
var pattern = {
|
|
regex: new RegExp(escapedText, matchCase ? 'g' : 'gi'),
|
|
matchIndex: 1
|
|
};
|
|
var count = markAllMatches(editor, currentSearchState, pattern, inSelection);
|
|
if (global$2.browser.isSafari()) {
|
|
selection.setRng(selection.getRng(), isForwardSelection);
|
|
}
|
|
if (count) {
|
|
var newIndex = moveSelection(editor, currentSearchState, true);
|
|
currentSearchState.set({
|
|
index: newIndex,
|
|
count: count,
|
|
text: text,
|
|
matchCase: matchCase,
|
|
wholeWord: wholeWord,
|
|
inSelection: inSelection
|
|
});
|
|
}
|
|
return count;
|
|
};
|
|
var next = function (editor, currentSearchState) {
|
|
var index = moveSelection(editor, currentSearchState, true);
|
|
currentSearchState.set(__assign(__assign({}, currentSearchState.get()), { index: index }));
|
|
};
|
|
var prev = function (editor, currentSearchState) {
|
|
var index = moveSelection(editor, currentSearchState, false);
|
|
currentSearchState.set(__assign(__assign({}, currentSearchState.get()), { index: index }));
|
|
};
|
|
var isMatchSpan = function (node) {
|
|
var matchIndex = getElmIndex(node);
|
|
return matchIndex !== null && matchIndex.length > 0;
|
|
};
|
|
var replace = function (editor, currentSearchState, text, forward, all) {
|
|
var searchState = currentSearchState.get();
|
|
var currentIndex = searchState.index;
|
|
var currentMatchIndex, nextIndex = currentIndex;
|
|
forward = forward !== false;
|
|
var node = editor.getBody();
|
|
var nodes = global$1.grep(global$1.toArray(node.getElementsByTagName('span')), isMatchSpan);
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
var nodeIndex = getElmIndex(nodes[i]);
|
|
var matchIndex = currentMatchIndex = parseInt(nodeIndex, 10);
|
|
if (all || matchIndex === searchState.index) {
|
|
if (text.length) {
|
|
nodes[i].firstChild.nodeValue = text;
|
|
unwrap(nodes[i]);
|
|
} else {
|
|
removeNode(editor.dom, nodes[i]);
|
|
}
|
|
while (nodes[++i]) {
|
|
matchIndex = parseInt(getElmIndex(nodes[i]), 10);
|
|
if (matchIndex === currentMatchIndex) {
|
|
removeNode(editor.dom, nodes[i]);
|
|
} else {
|
|
i--;
|
|
break;
|
|
}
|
|
}
|
|
if (forward) {
|
|
nextIndex--;
|
|
}
|
|
} else if (currentMatchIndex > currentIndex) {
|
|
nodes[i].setAttribute('data-mce-index', String(currentMatchIndex - 1));
|
|
}
|
|
}
|
|
currentSearchState.set(__assign(__assign({}, searchState), {
|
|
count: all ? 0 : searchState.count - 1,
|
|
index: nextIndex
|
|
}));
|
|
if (forward) {
|
|
next(editor, currentSearchState);
|
|
} else {
|
|
prev(editor, currentSearchState);
|
|
}
|
|
return !all && currentSearchState.get().count > 0;
|
|
};
|
|
var done = function (editor, currentSearchState, keepEditorSelection) {
|
|
var startContainer, endContainer;
|
|
var searchState = currentSearchState.get();
|
|
var nodes = global$1.toArray(editor.getBody().getElementsByTagName('span'));
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
var nodeIndex = getElmIndex(nodes[i]);
|
|
if (nodeIndex !== null && nodeIndex.length) {
|
|
if (nodeIndex === searchState.index.toString()) {
|
|
if (!startContainer) {
|
|
startContainer = nodes[i].firstChild;
|
|
}
|
|
endContainer = nodes[i].firstChild;
|
|
}
|
|
unwrap(nodes[i]);
|
|
}
|
|
}
|
|
currentSearchState.set(__assign(__assign({}, searchState), {
|
|
index: -1,
|
|
count: 0,
|
|
text: ''
|
|
}));
|
|
if (startContainer && endContainer) {
|
|
var rng = editor.dom.createRng();
|
|
rng.setStart(startContainer, 0);
|
|
rng.setEnd(endContainer, endContainer.data.length);
|
|
if (keepEditorSelection !== false) {
|
|
editor.selection.setRng(rng);
|
|
}
|
|
return rng;
|
|
}
|
|
};
|
|
var hasNext = function (editor, currentSearchState) {
|
|
return currentSearchState.get().count > 1;
|
|
};
|
|
var hasPrev = function (editor, currentSearchState) {
|
|
return currentSearchState.get().count > 1;
|
|
};
|
|
|
|
var get = function (editor, currentState) {
|
|
var done$1 = function (keepEditorSelection) {
|
|
return done(editor, currentState, keepEditorSelection);
|
|
};
|
|
var find$1 = function (text, matchCase, wholeWord, inSelection) {
|
|
if (inSelection === void 0) {
|
|
inSelection = false;
|
|
}
|
|
return find(editor, currentState, text, matchCase, wholeWord, inSelection);
|
|
};
|
|
var next$1 = function () {
|
|
return next(editor, currentState);
|
|
};
|
|
var prev$1 = function () {
|
|
return prev(editor, currentState);
|
|
};
|
|
var replace$1 = function (text, forward, all) {
|
|
return replace(editor, currentState, text, forward, all);
|
|
};
|
|
return {
|
|
done: done$1,
|
|
find: find$1,
|
|
next: next$1,
|
|
prev: prev$1,
|
|
replace: replace$1
|
|
};
|
|
};
|
|
|
|
var singleton = function (doRevoke) {
|
|
var subject = Cell(Optional.none());
|
|
var revoke = function () {
|
|
return subject.get().each(doRevoke);
|
|
};
|
|
var clear = function () {
|
|
revoke();
|
|
subject.set(Optional.none());
|
|
};
|
|
var isSet = function () {
|
|
return subject.get().isSome();
|
|
};
|
|
var get = function () {
|
|
return subject.get();
|
|
};
|
|
var set = function (s) {
|
|
revoke();
|
|
subject.set(Optional.some(s));
|
|
};
|
|
return {
|
|
clear: clear,
|
|
isSet: isSet,
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var value = function () {
|
|
var subject = singleton(noop);
|
|
var on = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { on: on });
|
|
};
|
|
|
|
var open = function (editor, currentSearchState) {
|
|
var dialogApi = value();
|
|
editor.undoManager.add();
|
|
var selectedText = global$1.trim(editor.selection.getContent({ format: 'text' }));
|
|
var updateButtonStates = function (api) {
|
|
var updateNext = hasNext(editor, currentSearchState) ? api.enable : api.disable;
|
|
updateNext('next');
|
|
var updatePrev = hasPrev(editor, currentSearchState) ? api.enable : api.disable;
|
|
updatePrev('prev');
|
|
};
|
|
var updateSearchState = function (api) {
|
|
var data = api.getData();
|
|
var current = currentSearchState.get();
|
|
currentSearchState.set(__assign(__assign({}, current), {
|
|
matchCase: data.matchcase,
|
|
wholeWord: data.wholewords,
|
|
inSelection: data.inselection
|
|
}));
|
|
};
|
|
var disableAll = function (api, disable) {
|
|
var buttons = [
|
|
'replace',
|
|
'replaceall',
|
|
'prev',
|
|
'next'
|
|
];
|
|
var toggle = disable ? api.disable : api.enable;
|
|
each(buttons, toggle);
|
|
};
|
|
var notFoundAlert = function (api) {
|
|
editor.windowManager.alert('Could not find the specified string.', function () {
|
|
api.focus('findtext');
|
|
});
|
|
};
|
|
var focusButtonIfRequired = function (api, name) {
|
|
if (global$2.browser.isSafari() && global$2.deviceType.isTouch() && (name === 'find' || name === 'replace' || name === 'replaceall')) {
|
|
api.focus(name);
|
|
}
|
|
};
|
|
var reset = function (api) {
|
|
done(editor, currentSearchState, false);
|
|
disableAll(api, true);
|
|
updateButtonStates(api);
|
|
};
|
|
var doFind = function (api) {
|
|
var data = api.getData();
|
|
var last = currentSearchState.get();
|
|
if (!data.findtext.length) {
|
|
reset(api);
|
|
return;
|
|
}
|
|
if (last.text === data.findtext && last.matchCase === data.matchcase && last.wholeWord === data.wholewords) {
|
|
next(editor, currentSearchState);
|
|
} else {
|
|
var count = find(editor, currentSearchState, data.findtext, data.matchcase, data.wholewords, data.inselection);
|
|
if (count <= 0) {
|
|
notFoundAlert(api);
|
|
}
|
|
disableAll(api, count === 0);
|
|
}
|
|
updateButtonStates(api);
|
|
};
|
|
var initialState = currentSearchState.get();
|
|
var initialData = {
|
|
findtext: selectedText,
|
|
replacetext: '',
|
|
wholewords: initialState.wholeWord,
|
|
matchcase: initialState.matchCase,
|
|
inselection: initialState.inSelection
|
|
};
|
|
var spec = {
|
|
title: 'Find and Replace',
|
|
size: 'normal',
|
|
body: {
|
|
type: 'panel',
|
|
items: [
|
|
{
|
|
type: 'bar',
|
|
items: [
|
|
{
|
|
type: 'input',
|
|
name: 'findtext',
|
|
placeholder: 'Find',
|
|
maximized: true,
|
|
inputMode: 'search'
|
|
},
|
|
{
|
|
type: 'button',
|
|
name: 'prev',
|
|
text: 'Previous',
|
|
icon: 'action-prev',
|
|
disabled: true,
|
|
borderless: true
|
|
},
|
|
{
|
|
type: 'button',
|
|
name: 'next',
|
|
text: 'Next',
|
|
icon: 'action-next',
|
|
disabled: true,
|
|
borderless: true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
type: 'input',
|
|
name: 'replacetext',
|
|
placeholder: 'Replace with',
|
|
inputMode: 'search'
|
|
}
|
|
]
|
|
},
|
|
buttons: [
|
|
{
|
|
type: 'menu',
|
|
name: 'options',
|
|
icon: 'preferences',
|
|
tooltip: 'Preferences',
|
|
align: 'start',
|
|
items: [
|
|
{
|
|
type: 'togglemenuitem',
|
|
name: 'matchcase',
|
|
text: 'Match case'
|
|
},
|
|
{
|
|
type: 'togglemenuitem',
|
|
name: 'wholewords',
|
|
text: 'Find whole words only'
|
|
},
|
|
{
|
|
type: 'togglemenuitem',
|
|
name: 'inselection',
|
|
text: 'Find in selection'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
type: 'custom',
|
|
name: 'find',
|
|
text: 'Find',
|
|
primary: true
|
|
},
|
|
{
|
|
type: 'custom',
|
|
name: 'replace',
|
|
text: 'Replace',
|
|
disabled: true
|
|
},
|
|
{
|
|
type: 'custom',
|
|
name: 'replaceall',
|
|
text: 'Replace all',
|
|
disabled: true
|
|
}
|
|
],
|
|
initialData: initialData,
|
|
onChange: function (api, details) {
|
|
if (details.name === 'findtext' && currentSearchState.get().count > 0) {
|
|
reset(api);
|
|
}
|
|
},
|
|
onAction: function (api, details) {
|
|
var data = api.getData();
|
|
switch (details.name) {
|
|
case 'find':
|
|
doFind(api);
|
|
break;
|
|
case 'replace':
|
|
if (!replace(editor, currentSearchState, data.replacetext)) {
|
|
reset(api);
|
|
} else {
|
|
updateButtonStates(api);
|
|
}
|
|
break;
|
|
case 'replaceall':
|
|
replace(editor, currentSearchState, data.replacetext, true, true);
|
|
reset(api);
|
|
break;
|
|
case 'prev':
|
|
prev(editor, currentSearchState);
|
|
updateButtonStates(api);
|
|
break;
|
|
case 'next':
|
|
next(editor, currentSearchState);
|
|
updateButtonStates(api);
|
|
break;
|
|
case 'matchcase':
|
|
case 'wholewords':
|
|
case 'inselection':
|
|
updateSearchState(api);
|
|
reset(api);
|
|
break;
|
|
}
|
|
focusButtonIfRequired(api, details.name);
|
|
},
|
|
onSubmit: function (api) {
|
|
doFind(api);
|
|
focusButtonIfRequired(api, 'find');
|
|
},
|
|
onClose: function () {
|
|
editor.focus();
|
|
done(editor, currentSearchState);
|
|
editor.undoManager.add();
|
|
}
|
|
};
|
|
dialogApi.set(editor.windowManager.open(spec, { inline: 'toolbar' }));
|
|
};
|
|
|
|
var register$1 = function (editor, currentSearchState) {
|
|
editor.addCommand('SearchReplace', function () {
|
|
open(editor, currentSearchState);
|
|
});
|
|
};
|
|
|
|
var showDialog = function (editor, currentSearchState) {
|
|
return function () {
|
|
open(editor, currentSearchState);
|
|
};
|
|
};
|
|
var register = function (editor, currentSearchState) {
|
|
editor.ui.registry.addMenuItem('searchreplace', {
|
|
text: 'Find and replace...',
|
|
shortcut: 'Meta+F',
|
|
onAction: showDialog(editor, currentSearchState),
|
|
icon: 'search'
|
|
});
|
|
editor.ui.registry.addButton('searchreplace', {
|
|
tooltip: 'Find and replace',
|
|
onAction: showDialog(editor, currentSearchState),
|
|
icon: 'search'
|
|
});
|
|
editor.shortcuts.add('Meta+F', '', showDialog(editor, currentSearchState));
|
|
};
|
|
|
|
function Plugin () {
|
|
global$3.add('searchreplace', function (editor) {
|
|
var currentSearchState = Cell({
|
|
index: -1,
|
|
count: 0,
|
|
text: '',
|
|
matchCase: false,
|
|
wholeWord: false,
|
|
inSelection: false
|
|
});
|
|
register$1(editor, currentSearchState);
|
|
register(editor, currentSearchState);
|
|
return get(editor, currentSearchState);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var hasProPlugin = function (editor) {
|
|
if (editor.hasPlugin('tinymcespellchecker', true)) {
|
|
if (typeof window.console !== 'undefined' && window.console.log) {
|
|
window.console.log('Spell Checker Pro is incompatible with Spell Checker plugin! ' + 'Remove \'spellchecker\' from the \'plugins\' option.');
|
|
}
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var isEmpty = function (r) {
|
|
for (var x in r) {
|
|
if (hasOwnProperty.call(r, x)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.URI');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.XHR');
|
|
|
|
var fireSpellcheckStart = function (editor) {
|
|
return editor.fire('SpellcheckStart');
|
|
};
|
|
var fireSpellcheckEnd = function (editor) {
|
|
return editor.fire('SpellcheckEnd');
|
|
};
|
|
|
|
var getLanguages = function (editor) {
|
|
var defaultLanguages = 'English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr_FR,German=de,Italian=it,Polish=pl,Portuguese=pt_BR,Spanish=es,Swedish=sv';
|
|
return editor.getParam('spellchecker_languages', defaultLanguages);
|
|
};
|
|
var getLanguage = function (editor) {
|
|
var defaultLanguage = editor.getParam('language', 'en');
|
|
return editor.getParam('spellchecker_language', defaultLanguage);
|
|
};
|
|
var getRpcUrl = function (editor) {
|
|
return editor.getParam('spellchecker_rpc_url');
|
|
};
|
|
var getSpellcheckerCallback = function (editor) {
|
|
return editor.getParam('spellchecker_callback');
|
|
};
|
|
var getSpellcheckerWordcharPattern = function (editor) {
|
|
var defaultPattern = new RegExp('[^' + '\\s!"#$%&()*+,-./:;<=>?@[\\]^_{|}`' + '\xA7\xA9\xAB\xAE\xB1\xB6\xB7\xB8\xBB' + '\xBC\xBD\xBE\xBF\xD7\xF7\xA4\u201D\u201C\u201E\xA0\u2002\u2003\u2009' + ']+', 'g');
|
|
return editor.getParam('spellchecker_wordchar_pattern', defaultPattern);
|
|
};
|
|
|
|
var isContentEditableFalse = function (node) {
|
|
return node && node.nodeType === 1 && node.contentEditable === 'false';
|
|
};
|
|
var DomTextMatcher = function (node, editor) {
|
|
var m, matches = [];
|
|
var dom = editor.dom;
|
|
var blockElementsMap = editor.schema.getBlockElements();
|
|
var hiddenTextElementsMap = editor.schema.getWhiteSpaceElements();
|
|
var shortEndedElementsMap = editor.schema.getShortEndedElements();
|
|
var createMatch = function (m, data) {
|
|
if (!m[0]) {
|
|
throw new Error('findAndReplaceDOMText cannot handle zero-length matches');
|
|
}
|
|
return {
|
|
start: m.index,
|
|
end: m.index + m[0].length,
|
|
text: m[0],
|
|
data: data
|
|
};
|
|
};
|
|
var getText = function (node) {
|
|
if (node.nodeType === 3) {
|
|
return node.data;
|
|
}
|
|
if (hiddenTextElementsMap[node.nodeName] && !blockElementsMap[node.nodeName]) {
|
|
return '';
|
|
}
|
|
if (isContentEditableFalse(node)) {
|
|
return '\n';
|
|
}
|
|
var txt = '';
|
|
if (blockElementsMap[node.nodeName] || shortEndedElementsMap[node.nodeName]) {
|
|
txt += '\n';
|
|
}
|
|
if (node = node.firstChild) {
|
|
do {
|
|
txt += getText(node);
|
|
} while (node = node.nextSibling);
|
|
}
|
|
return txt;
|
|
};
|
|
var stepThroughMatches = function (node, matches, replaceFn) {
|
|
var startNode, endNode, startNodeIndex, endNodeIndex, innerNodes = [], atIndex = 0, curNode = node, matchLocation, matchIndex = 0;
|
|
matches = matches.slice(0);
|
|
matches.sort(function (a, b) {
|
|
return a.start - b.start;
|
|
});
|
|
matchLocation = matches.shift();
|
|
out:
|
|
while (true) {
|
|
if (blockElementsMap[curNode.nodeName] || shortEndedElementsMap[curNode.nodeName] || isContentEditableFalse(curNode)) {
|
|
atIndex++;
|
|
}
|
|
if (curNode.nodeType === 3) {
|
|
if (!endNode && curNode.length + atIndex >= matchLocation.end) {
|
|
endNode = curNode;
|
|
endNodeIndex = matchLocation.end - atIndex;
|
|
} else if (startNode) {
|
|
innerNodes.push(curNode);
|
|
}
|
|
if (!startNode && curNode.length + atIndex > matchLocation.start) {
|
|
startNode = curNode;
|
|
startNodeIndex = matchLocation.start - atIndex;
|
|
}
|
|
atIndex += curNode.length;
|
|
}
|
|
if (startNode && endNode) {
|
|
curNode = replaceFn({
|
|
startNode: startNode,
|
|
startNodeIndex: startNodeIndex,
|
|
endNode: endNode,
|
|
endNodeIndex: endNodeIndex,
|
|
innerNodes: innerNodes,
|
|
match: matchLocation.text,
|
|
matchIndex: matchIndex
|
|
});
|
|
atIndex -= endNode.length - endNodeIndex;
|
|
startNode = null;
|
|
endNode = null;
|
|
innerNodes = [];
|
|
matchLocation = matches.shift();
|
|
matchIndex++;
|
|
if (!matchLocation) {
|
|
break;
|
|
}
|
|
} else if ((!hiddenTextElementsMap[curNode.nodeName] || blockElementsMap[curNode.nodeName]) && curNode.firstChild) {
|
|
if (!isContentEditableFalse(curNode)) {
|
|
curNode = curNode.firstChild;
|
|
continue;
|
|
}
|
|
} else if (curNode.nextSibling) {
|
|
curNode = curNode.nextSibling;
|
|
continue;
|
|
}
|
|
while (true) {
|
|
if (curNode.nextSibling) {
|
|
curNode = curNode.nextSibling;
|
|
break;
|
|
} else if (curNode.parentNode !== node) {
|
|
curNode = curNode.parentNode;
|
|
} else {
|
|
break out;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
var genReplacer = function (callback) {
|
|
var makeReplacementNode = function (fill, matchIndex) {
|
|
var match = matches[matchIndex];
|
|
if (!match.stencil) {
|
|
match.stencil = callback(match);
|
|
}
|
|
var clone = match.stencil.cloneNode(false);
|
|
clone.setAttribute('data-mce-index', '' + matchIndex);
|
|
if (fill) {
|
|
clone.appendChild(dom.doc.createTextNode(fill));
|
|
}
|
|
return clone;
|
|
};
|
|
return function (range) {
|
|
var before;
|
|
var after;
|
|
var parentNode;
|
|
var startNode = range.startNode;
|
|
var endNode = range.endNode;
|
|
var matchIndex = range.matchIndex;
|
|
var doc = dom.doc;
|
|
if (startNode === endNode) {
|
|
var node_1 = startNode;
|
|
parentNode = node_1.parentNode;
|
|
if (range.startNodeIndex > 0) {
|
|
before = doc.createTextNode(node_1.data.substring(0, range.startNodeIndex));
|
|
parentNode.insertBefore(before, node_1);
|
|
}
|
|
var el = makeReplacementNode(range.match, matchIndex);
|
|
parentNode.insertBefore(el, node_1);
|
|
if (range.endNodeIndex < node_1.length) {
|
|
after = doc.createTextNode(node_1.data.substring(range.endNodeIndex));
|
|
parentNode.insertBefore(after, node_1);
|
|
}
|
|
node_1.parentNode.removeChild(node_1);
|
|
return el;
|
|
}
|
|
before = doc.createTextNode(startNode.data.substring(0, range.startNodeIndex));
|
|
after = doc.createTextNode(endNode.data.substring(range.endNodeIndex));
|
|
var elA = makeReplacementNode(startNode.data.substring(range.startNodeIndex), matchIndex);
|
|
for (var i = 0, l = range.innerNodes.length; i < l; ++i) {
|
|
var innerNode = range.innerNodes[i];
|
|
var innerEl = makeReplacementNode(innerNode.data, matchIndex);
|
|
innerNode.parentNode.replaceChild(innerEl, innerNode);
|
|
}
|
|
var elB = makeReplacementNode(endNode.data.substring(0, range.endNodeIndex), matchIndex);
|
|
parentNode = startNode.parentNode;
|
|
parentNode.insertBefore(before, startNode);
|
|
parentNode.insertBefore(elA, startNode);
|
|
parentNode.removeChild(startNode);
|
|
parentNode = endNode.parentNode;
|
|
parentNode.insertBefore(elB, endNode);
|
|
parentNode.insertBefore(after, endNode);
|
|
parentNode.removeChild(endNode);
|
|
return elB;
|
|
};
|
|
};
|
|
var unwrapElement = function (element) {
|
|
var parentNode = element.parentNode;
|
|
while (element.childNodes.length > 0) {
|
|
parentNode.insertBefore(element.childNodes[0], element);
|
|
}
|
|
parentNode.removeChild(element);
|
|
};
|
|
var hasClass = function (elm) {
|
|
return elm.className.indexOf('mce-spellchecker-word') !== -1;
|
|
};
|
|
var getWrappersByIndex = function (index) {
|
|
var elements = node.getElementsByTagName('*'), wrappers = [];
|
|
index = typeof index === 'number' ? '' + index : null;
|
|
for (var i = 0; i < elements.length; i++) {
|
|
var element = elements[i], dataIndex = element.getAttribute('data-mce-index');
|
|
if (dataIndex !== null && dataIndex.length && hasClass(element)) {
|
|
if (dataIndex === index || index === null) {
|
|
wrappers.push(element);
|
|
}
|
|
}
|
|
}
|
|
return wrappers;
|
|
};
|
|
var indexOf = function (match) {
|
|
var i = matches.length;
|
|
while (i--) {
|
|
if (matches[i] === match) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
};
|
|
function filter(callback) {
|
|
var filteredMatches = [];
|
|
each(function (match, i) {
|
|
if (callback(match, i)) {
|
|
filteredMatches.push(match);
|
|
}
|
|
});
|
|
matches = filteredMatches;
|
|
return this;
|
|
}
|
|
function each(callback) {
|
|
for (var i = 0, l = matches.length; i < l; i++) {
|
|
if (callback(matches[i], i) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
function wrap(callback) {
|
|
if (matches.length) {
|
|
stepThroughMatches(node, matches, genReplacer(callback));
|
|
}
|
|
return this;
|
|
}
|
|
function find(regex, data) {
|
|
if (text && regex.global) {
|
|
while (m = regex.exec(text)) {
|
|
matches.push(createMatch(m, data));
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
function unwrap(match) {
|
|
var i;
|
|
var elements = getWrappersByIndex(match ? indexOf(match) : null);
|
|
i = elements.length;
|
|
while (i--) {
|
|
unwrapElement(elements[i]);
|
|
}
|
|
return this;
|
|
}
|
|
var matchFromElement = function (element) {
|
|
return matches[element.getAttribute('data-mce-index')];
|
|
};
|
|
var elementFromMatch = function (match) {
|
|
return getWrappersByIndex(indexOf(match))[0];
|
|
};
|
|
function add(start, length, data) {
|
|
matches.push({
|
|
start: start,
|
|
end: start + length,
|
|
text: text.substr(start, length),
|
|
data: data
|
|
});
|
|
return this;
|
|
}
|
|
var rangeFromMatch = function (match) {
|
|
var wrappers = getWrappersByIndex(indexOf(match));
|
|
var rng = editor.dom.createRng();
|
|
rng.setStartBefore(wrappers[0]);
|
|
rng.setEndAfter(wrappers[wrappers.length - 1]);
|
|
return rng;
|
|
};
|
|
var replace = function (match, text) {
|
|
var rng = rangeFromMatch(match);
|
|
rng.deleteContents();
|
|
if (text.length > 0) {
|
|
rng.insertNode(editor.dom.doc.createTextNode(text));
|
|
}
|
|
return rng;
|
|
};
|
|
function reset() {
|
|
matches.splice(0, matches.length);
|
|
unwrap();
|
|
return this;
|
|
}
|
|
var text = getText(node);
|
|
return {
|
|
text: text,
|
|
matches: matches,
|
|
each: each,
|
|
filter: filter,
|
|
reset: reset,
|
|
matchFromElement: matchFromElement,
|
|
elementFromMatch: elementFromMatch,
|
|
find: find,
|
|
add: add,
|
|
wrap: wrap,
|
|
unwrap: unwrap,
|
|
replace: replace,
|
|
rangeFromMatch: rangeFromMatch,
|
|
indexOf: indexOf
|
|
};
|
|
};
|
|
|
|
var getTextMatcher = function (editor, textMatcherState) {
|
|
if (!textMatcherState.get()) {
|
|
var textMatcher = DomTextMatcher(editor.getBody(), editor);
|
|
textMatcherState.set(textMatcher);
|
|
}
|
|
return textMatcherState.get();
|
|
};
|
|
var defaultSpellcheckCallback = function (editor, pluginUrl, currentLanguageState) {
|
|
return function (method, text, doneCallback, errorCallback) {
|
|
var data = {
|
|
method: method,
|
|
lang: currentLanguageState.get()
|
|
};
|
|
var postData = '';
|
|
data[method === 'addToDictionary' ? 'word' : 'text'] = text;
|
|
global$2.each(data, function (value, key) {
|
|
if (postData) {
|
|
postData += '&';
|
|
}
|
|
postData += key + '=' + encodeURIComponent(value);
|
|
});
|
|
global.send({
|
|
url: new global$1(pluginUrl).toAbsolute(getRpcUrl(editor)),
|
|
type: 'post',
|
|
content_type: 'application/x-www-form-urlencoded',
|
|
data: postData,
|
|
success: function (result) {
|
|
var parseResult = JSON.parse(result);
|
|
if (!parseResult) {
|
|
var message = editor.translate('Server response wasn\'t proper JSON.');
|
|
errorCallback(message);
|
|
} else if (parseResult.error) {
|
|
errorCallback(parseResult.error);
|
|
} else {
|
|
doneCallback(parseResult);
|
|
}
|
|
},
|
|
error: function () {
|
|
var message = editor.translate('The spelling service was not found: (') + getRpcUrl(editor) + editor.translate(')');
|
|
errorCallback(message);
|
|
}
|
|
});
|
|
};
|
|
};
|
|
var sendRpcCall = function (editor, pluginUrl, currentLanguageState, name, data, successCallback, errorCallback) {
|
|
var userSpellcheckCallback = getSpellcheckerCallback(editor);
|
|
var spellCheckCallback = userSpellcheckCallback ? userSpellcheckCallback : defaultSpellcheckCallback(editor, pluginUrl, currentLanguageState);
|
|
spellCheckCallback.call(editor.plugins.spellchecker, name, data, successCallback, errorCallback);
|
|
};
|
|
var spellcheck = function (editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState) {
|
|
if (finish(editor, startedState, textMatcherState)) {
|
|
return;
|
|
}
|
|
var errorCallback = function (message) {
|
|
editor.notificationManager.open({
|
|
text: message,
|
|
type: 'error'
|
|
});
|
|
editor.setProgressState(false);
|
|
finish(editor, startedState, textMatcherState);
|
|
};
|
|
var successCallback = function (data) {
|
|
markErrors(editor, startedState, textMatcherState, lastSuggestionsState, data);
|
|
};
|
|
editor.setProgressState(true);
|
|
sendRpcCall(editor, pluginUrl, currentLanguageState, 'spellcheck', getTextMatcher(editor, textMatcherState).text, successCallback, errorCallback);
|
|
editor.focus();
|
|
};
|
|
var checkIfFinished = function (editor, startedState, textMatcherState) {
|
|
if (!editor.dom.select('span.mce-spellchecker-word').length) {
|
|
finish(editor, startedState, textMatcherState);
|
|
}
|
|
};
|
|
var addToDictionary = function (editor, pluginUrl, startedState, textMatcherState, currentLanguageState, word, spans) {
|
|
editor.setProgressState(true);
|
|
sendRpcCall(editor, pluginUrl, currentLanguageState, 'addToDictionary', word, function () {
|
|
editor.setProgressState(false);
|
|
editor.dom.remove(spans, true);
|
|
checkIfFinished(editor, startedState, textMatcherState);
|
|
}, function (message) {
|
|
editor.notificationManager.open({
|
|
text: message,
|
|
type: 'error'
|
|
});
|
|
editor.setProgressState(false);
|
|
});
|
|
};
|
|
var ignoreWord = function (editor, startedState, textMatcherState, word, spans, all) {
|
|
editor.selection.collapse();
|
|
if (all) {
|
|
global$2.each(editor.dom.select('span.mce-spellchecker-word'), function (span) {
|
|
if (span.getAttribute('data-mce-word') === word) {
|
|
editor.dom.remove(span, true);
|
|
}
|
|
});
|
|
} else {
|
|
editor.dom.remove(spans, true);
|
|
}
|
|
checkIfFinished(editor, startedState, textMatcherState);
|
|
};
|
|
var finish = function (editor, startedState, textMatcherState) {
|
|
var bookmark = editor.selection.getBookmark();
|
|
getTextMatcher(editor, textMatcherState).reset();
|
|
editor.selection.moveToBookmark(bookmark);
|
|
textMatcherState.set(null);
|
|
if (startedState.get()) {
|
|
startedState.set(false);
|
|
fireSpellcheckEnd(editor);
|
|
return true;
|
|
}
|
|
};
|
|
var getElmIndex = function (elm) {
|
|
var value = elm.getAttribute('data-mce-index');
|
|
if (typeof value === 'number') {
|
|
return '' + value;
|
|
}
|
|
return value;
|
|
};
|
|
var findSpansByIndex = function (editor, index) {
|
|
var spans = [];
|
|
var nodes = global$2.toArray(editor.getBody().getElementsByTagName('span'));
|
|
if (nodes.length) {
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
var nodeIndex = getElmIndex(nodes[i]);
|
|
if (nodeIndex === null || !nodeIndex.length) {
|
|
continue;
|
|
}
|
|
if (nodeIndex === index.toString()) {
|
|
spans.push(nodes[i]);
|
|
}
|
|
}
|
|
}
|
|
return spans;
|
|
};
|
|
var markErrors = function (editor, startedState, textMatcherState, lastSuggestionsState, data) {
|
|
var hasDictionarySupport = !!data.dictionary;
|
|
var suggestions = data.words;
|
|
editor.setProgressState(false);
|
|
if (isEmpty(suggestions)) {
|
|
var message = editor.translate('No misspellings found.');
|
|
editor.notificationManager.open({
|
|
text: message,
|
|
type: 'info'
|
|
});
|
|
startedState.set(false);
|
|
return;
|
|
}
|
|
lastSuggestionsState.set({
|
|
suggestions: suggestions,
|
|
hasDictionarySupport: hasDictionarySupport
|
|
});
|
|
var bookmark = editor.selection.getBookmark();
|
|
getTextMatcher(editor, textMatcherState).find(getSpellcheckerWordcharPattern(editor)).filter(function (match) {
|
|
return !!suggestions[match.text];
|
|
}).wrap(function (match) {
|
|
return editor.dom.create('span', {
|
|
'class': 'mce-spellchecker-word',
|
|
'aria-invalid': 'spelling',
|
|
'data-mce-bogus': 1,
|
|
'data-mce-word': match.text
|
|
});
|
|
});
|
|
editor.selection.moveToBookmark(bookmark);
|
|
startedState.set(true);
|
|
fireSpellcheckStart(editor);
|
|
};
|
|
|
|
var get = function (editor, startedState, lastSuggestionsState, textMatcherState, currentLanguageState) {
|
|
var getWordCharPattern = function () {
|
|
return getSpellcheckerWordcharPattern(editor);
|
|
};
|
|
var markErrors$1 = function (data) {
|
|
markErrors(editor, startedState, textMatcherState, lastSuggestionsState, data);
|
|
};
|
|
return {
|
|
getTextMatcher: textMatcherState.get,
|
|
getWordCharPattern: getWordCharPattern,
|
|
markErrors: markErrors$1,
|
|
getLanguage: currentLanguageState.get
|
|
};
|
|
};
|
|
|
|
var register$1 = function (editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState) {
|
|
editor.addCommand('mceSpellCheck', function () {
|
|
spellcheck(editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState);
|
|
});
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var spellcheckerEvents = 'SpellcheckStart SpellcheckEnd';
|
|
var buildMenuItems = function (listName, languageValues) {
|
|
var items = [];
|
|
global$2.each(languageValues, function (languageValue) {
|
|
items.push({
|
|
selectable: true,
|
|
text: languageValue.name,
|
|
data: languageValue.value
|
|
});
|
|
});
|
|
return items;
|
|
};
|
|
var getItems = function (editor) {
|
|
return global$2.map(getLanguages(editor).split(','), function (langPair) {
|
|
var langPairs = langPair.split('=');
|
|
return {
|
|
name: langPairs[0],
|
|
value: langPairs[1]
|
|
};
|
|
});
|
|
};
|
|
var register = function (editor, pluginUrl, startedState, textMatcherState, currentLanguageState, lastSuggestionsState) {
|
|
var languageMenuItems = buildMenuItems('Language', getItems(editor));
|
|
var startSpellchecking = function () {
|
|
spellcheck(editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState);
|
|
};
|
|
var buttonArgs = {
|
|
tooltip: 'Spellcheck',
|
|
onAction: startSpellchecking,
|
|
icon: 'spell-check',
|
|
onSetup: function (buttonApi) {
|
|
var setButtonState = function () {
|
|
buttonApi.setActive(startedState.get());
|
|
};
|
|
editor.on(spellcheckerEvents, setButtonState);
|
|
return function () {
|
|
editor.off(spellcheckerEvents, setButtonState);
|
|
};
|
|
}
|
|
};
|
|
var splitButtonArgs = __assign(__assign({}, buttonArgs), {
|
|
type: 'splitbutton',
|
|
select: function (value) {
|
|
return value === currentLanguageState.get();
|
|
},
|
|
fetch: function (callback) {
|
|
var items = global$2.map(languageMenuItems, function (languageItem) {
|
|
return {
|
|
type: 'choiceitem',
|
|
value: languageItem.data,
|
|
text: languageItem.text
|
|
};
|
|
});
|
|
callback(items);
|
|
},
|
|
onItemAction: function (splitButtonApi, value) {
|
|
currentLanguageState.set(value);
|
|
}
|
|
});
|
|
if (languageMenuItems.length > 1) {
|
|
editor.ui.registry.addSplitButton('spellchecker', splitButtonArgs);
|
|
} else {
|
|
editor.ui.registry.addToggleButton('spellchecker', buttonArgs);
|
|
}
|
|
editor.ui.registry.addToggleMenuItem('spellchecker', {
|
|
text: 'Spellcheck',
|
|
icon: 'spell-check',
|
|
onSetup: function (menuApi) {
|
|
menuApi.setActive(startedState.get());
|
|
var setMenuItemCheck = function () {
|
|
menuApi.setActive(startedState.get());
|
|
};
|
|
editor.on(spellcheckerEvents, setMenuItemCheck);
|
|
return function () {
|
|
editor.off(spellcheckerEvents, setMenuItemCheck);
|
|
};
|
|
},
|
|
onAction: startSpellchecking
|
|
});
|
|
};
|
|
|
|
var ignoreAll = true;
|
|
var getSuggestions = function (editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState, word, spans) {
|
|
var items = [];
|
|
var suggestions = lastSuggestionsState.get().suggestions[word];
|
|
global$2.each(suggestions, function (suggestion) {
|
|
items.push({
|
|
text: suggestion,
|
|
onAction: function () {
|
|
editor.insertContent(editor.dom.encode(suggestion));
|
|
editor.dom.remove(spans);
|
|
checkIfFinished(editor, startedState, textMatcherState);
|
|
}
|
|
});
|
|
});
|
|
var hasDictionarySupport = lastSuggestionsState.get().hasDictionarySupport;
|
|
if (hasDictionarySupport) {
|
|
items.push({ type: 'separator' });
|
|
items.push({
|
|
text: 'Add to dictionary',
|
|
onAction: function () {
|
|
addToDictionary(editor, pluginUrl, startedState, textMatcherState, currentLanguageState, word, spans);
|
|
}
|
|
});
|
|
}
|
|
items.push.apply(items, [
|
|
{ type: 'separator' },
|
|
{
|
|
text: 'Ignore',
|
|
onAction: function () {
|
|
ignoreWord(editor, startedState, textMatcherState, word, spans);
|
|
}
|
|
},
|
|
{
|
|
text: 'Ignore all',
|
|
onAction: function () {
|
|
ignoreWord(editor, startedState, textMatcherState, word, spans, ignoreAll);
|
|
}
|
|
}
|
|
]);
|
|
return items;
|
|
};
|
|
var setup = function (editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState) {
|
|
var update = function (element) {
|
|
var target = element;
|
|
if (target.className === 'mce-spellchecker-word') {
|
|
var spans = findSpansByIndex(editor, getElmIndex(target));
|
|
if (spans.length > 0) {
|
|
var rng = editor.dom.createRng();
|
|
rng.setStartBefore(spans[0]);
|
|
rng.setEndAfter(spans[spans.length - 1]);
|
|
editor.selection.setRng(rng);
|
|
return getSuggestions(editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState, target.getAttribute('data-mce-word'), spans);
|
|
}
|
|
} else {
|
|
return [];
|
|
}
|
|
};
|
|
editor.ui.registry.addContextMenu('spellchecker', { update: update });
|
|
};
|
|
|
|
function Plugin () {
|
|
global$3.add('spellchecker', function (editor, pluginUrl) {
|
|
if (hasProPlugin(editor) === false) {
|
|
var startedState = Cell(false);
|
|
var currentLanguageState = Cell(getLanguage(editor));
|
|
var textMatcherState = Cell(null);
|
|
var lastSuggestionsState = Cell(null);
|
|
register(editor, pluginUrl, startedState, textMatcherState, currentLanguageState, lastSuggestionsState);
|
|
setup(editor, pluginUrl, lastSuggestionsState, startedState, textMatcherState, currentLanguageState);
|
|
register$1(editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState);
|
|
return get(editor, startedState, lastSuggestionsState, textMatcherState, currentLanguageState);
|
|
}
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$6 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.EditorManager');
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var getTabFocusElements = function (editor) {
|
|
return editor.getParam('tabfocus_elements', ':prev,:next');
|
|
};
|
|
var getTabFocus = function (editor) {
|
|
return editor.getParam('tab_focus', getTabFocusElements(editor));
|
|
};
|
|
|
|
var DOM = global$5.DOM;
|
|
var tabCancel = function (e) {
|
|
if (e.keyCode === global.TAB && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
|
e.preventDefault();
|
|
}
|
|
};
|
|
var setup = function (editor) {
|
|
var tabHandler = function (e) {
|
|
var x;
|
|
if (e.keyCode !== global.TAB || e.ctrlKey || e.altKey || e.metaKey || e.isDefaultPrevented()) {
|
|
return;
|
|
}
|
|
var find = function (direction) {
|
|
var el = DOM.select(':input:enabled,*[tabindex]:not(iframe)');
|
|
var canSelectRecursive = function (e) {
|
|
var castElem = e;
|
|
return e.nodeName === 'BODY' || castElem.type !== 'hidden' && castElem.style.display !== 'none' && castElem.style.visibility !== 'hidden' && canSelectRecursive(e.parentNode);
|
|
};
|
|
var canSelect = function (el) {
|
|
return /INPUT|TEXTAREA|BUTTON/.test(el.tagName) && global$4.get(e.id) && el.tabIndex !== -1 && canSelectRecursive(el);
|
|
};
|
|
global$1.each(el, function (e, i) {
|
|
if (e.id === editor.id) {
|
|
x = i;
|
|
return false;
|
|
}
|
|
});
|
|
if (direction > 0) {
|
|
for (var i = x + 1; i < el.length; i++) {
|
|
if (canSelect(el[i])) {
|
|
return el[i];
|
|
}
|
|
}
|
|
} else {
|
|
for (var i = x - 1; i >= 0; i--) {
|
|
if (canSelect(el[i])) {
|
|
return el[i];
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
var v = global$1.explode(getTabFocus(editor));
|
|
if (v.length === 1) {
|
|
v[1] = v[0];
|
|
v[0] = ':prev';
|
|
}
|
|
var el;
|
|
if (e.shiftKey) {
|
|
if (v[0] === ':prev') {
|
|
el = find(-1);
|
|
} else {
|
|
el = DOM.get(v[0]);
|
|
}
|
|
} else {
|
|
if (v[1] === ':next') {
|
|
el = find(1);
|
|
} else {
|
|
el = DOM.get(v[1]);
|
|
}
|
|
}
|
|
if (el) {
|
|
var focusEditor = global$4.get(el.id || el.name);
|
|
if (el.id && focusEditor) {
|
|
focusEditor.focus();
|
|
} else {
|
|
global$2.setTimeout(function () {
|
|
if (!global$3.webkit) {
|
|
window.focus();
|
|
}
|
|
el.focus();
|
|
}, 10);
|
|
}
|
|
e.preventDefault();
|
|
}
|
|
};
|
|
editor.on('init', function () {
|
|
if (editor.inline) {
|
|
DOM.setAttrib(editor.getBody(), 'tabIndex', null);
|
|
}
|
|
editor.on('keyup', tabCancel);
|
|
if (global$3.gecko) {
|
|
editor.on('keypress keydown', tabHandler);
|
|
} else {
|
|
editor.on('keydown', tabHandler);
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$6.add('tabfocus', function (editor) {
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var eq$2 = function (t) {
|
|
return function (a) {
|
|
return t === a;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isObject = isType$1('object');
|
|
var isArray = isType$1('array');
|
|
var isNull = eq$2(null);
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isUndefined = eq$2(undefined);
|
|
var isNullable = function (a) {
|
|
return a === null || a === undefined;
|
|
};
|
|
var isNonNullable = function (a) {
|
|
return !isNullable(a);
|
|
};
|
|
var isFunction = isSimpleType('function');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var compose = function (fa, fb) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
return fa(fb.apply(null, args));
|
|
};
|
|
};
|
|
var compose1 = function (fbc, fab) {
|
|
return function (a) {
|
|
return fbc(fab(a));
|
|
};
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var tripleEquals = function (a, b) {
|
|
return a === b;
|
|
};
|
|
function curry(fn) {
|
|
var initialArgs = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
initialArgs[_i - 1] = arguments[_i];
|
|
}
|
|
return function () {
|
|
var restArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
restArgs[_i] = arguments[_i];
|
|
}
|
|
var all = initialArgs.concat(restArgs);
|
|
return fn.apply(null, all);
|
|
};
|
|
}
|
|
var not = function (f) {
|
|
return function (t) {
|
|
return !f(t);
|
|
};
|
|
};
|
|
var die = function (msg) {
|
|
return function () {
|
|
throw new Error(msg);
|
|
};
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none$2 = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none$2,
|
|
each: noop,
|
|
bind: none$2,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none$2();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from$1 = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none$2,
|
|
from: from$1
|
|
};
|
|
|
|
var nativeSlice = Array.prototype.slice;
|
|
var nativeIndexOf = Array.prototype.indexOf;
|
|
var nativePush = Array.prototype.push;
|
|
var rawIndexOf = function (ts, t) {
|
|
return nativeIndexOf.call(ts, t);
|
|
};
|
|
var contains$2 = function (xs, x) {
|
|
return rawIndexOf(xs, x) > -1;
|
|
};
|
|
var exists = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var range$1 = function (num, f) {
|
|
var r = [];
|
|
for (var i = 0; i < num; i++) {
|
|
r.push(f(i));
|
|
}
|
|
return r;
|
|
};
|
|
var map$1 = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$2 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var eachr = function (xs, f) {
|
|
for (var i = xs.length - 1; i >= 0; i--) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var partition = function (xs, pred) {
|
|
var pass = [];
|
|
var fail = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
var arr = pred(x, i) ? pass : fail;
|
|
arr.push(x);
|
|
}
|
|
return {
|
|
pass: pass,
|
|
fail: fail
|
|
};
|
|
};
|
|
var filter$2 = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var foldr = function (xs, f, acc) {
|
|
eachr(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each$2(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find$1 = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var findIndex = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(i);
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var flatten$1 = function (xs) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
if (!isArray(xs[i])) {
|
|
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
|
|
}
|
|
nativePush.apply(r, xs[i]);
|
|
}
|
|
return r;
|
|
};
|
|
var bind$2 = function (xs, f) {
|
|
return flatten$1(map$1(xs, f));
|
|
};
|
|
var forall = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
var x = xs[i];
|
|
if (pred(x, i) !== true) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
var reverse = function (xs) {
|
|
var r = nativeSlice.call(xs, 0);
|
|
r.reverse();
|
|
return r;
|
|
};
|
|
var mapToObject = function (xs, f) {
|
|
var r = {};
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
r[String(x)] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var pure = function (x) {
|
|
return [x];
|
|
};
|
|
var sort$1 = function (xs, comparator) {
|
|
var copy = nativeSlice.call(xs, 0);
|
|
copy.sort(comparator);
|
|
return copy;
|
|
};
|
|
var get$d = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get$d(xs, 0);
|
|
};
|
|
var last$2 = function (xs) {
|
|
return get$d(xs, xs.length - 1);
|
|
};
|
|
var findMap = function (arr, f) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
var r = f(arr[i], i);
|
|
if (r.isSome()) {
|
|
return r;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
function __spreadArray(to, from, pack) {
|
|
if (pack || arguments.length === 2)
|
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
if (ar || !(i in from)) {
|
|
if (!ar)
|
|
ar = Array.prototype.slice.call(from, 0, i);
|
|
ar[i] = from[i];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
}
|
|
|
|
var cached = function (f) {
|
|
var called = false;
|
|
var r;
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (!called) {
|
|
called = true;
|
|
r = f.apply(null, args);
|
|
}
|
|
return r;
|
|
};
|
|
};
|
|
|
|
var DeviceType = function (os, browser, userAgent, mediaMatch) {
|
|
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
|
|
var isiPhone = os.isiOS() && !isiPad;
|
|
var isMobile = os.isiOS() || os.isAndroid();
|
|
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
|
|
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
|
|
var isPhone = isiPhone || isMobile && !isTablet;
|
|
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
|
|
var isDesktop = !isPhone && !isTablet && !iOSwebview;
|
|
return {
|
|
isiPad: constant(isiPad),
|
|
isiPhone: constant(isiPhone),
|
|
isTablet: constant(isTablet),
|
|
isPhone: constant(isPhone),
|
|
isTouch: constant(isTouch),
|
|
isAndroid: os.isAndroid,
|
|
isiOS: os.isiOS,
|
|
isWebView: constant(iOSwebview),
|
|
isDesktop: constant(isDesktop)
|
|
};
|
|
};
|
|
|
|
var firstMatch = function (regexes, s) {
|
|
for (var i = 0; i < regexes.length; i++) {
|
|
var x = regexes[i];
|
|
if (x.test(s)) {
|
|
return x;
|
|
}
|
|
}
|
|
return undefined;
|
|
};
|
|
var find = function (regexes, agent) {
|
|
var r = firstMatch(regexes, agent);
|
|
if (!r) {
|
|
return {
|
|
major: 0,
|
|
minor: 0
|
|
};
|
|
}
|
|
var group = function (i) {
|
|
return Number(agent.replace(r, '$' + i));
|
|
};
|
|
return nu$2(group(1), group(2));
|
|
};
|
|
var detect$6 = function (versionRegexes, agent) {
|
|
var cleanedAgent = String(agent).toLowerCase();
|
|
if (versionRegexes.length === 0) {
|
|
return unknown$2();
|
|
}
|
|
return find(versionRegexes, cleanedAgent);
|
|
};
|
|
var unknown$2 = function () {
|
|
return nu$2(0, 0);
|
|
};
|
|
var nu$2 = function (major, minor) {
|
|
return {
|
|
major: major,
|
|
minor: minor
|
|
};
|
|
};
|
|
var Version = {
|
|
nu: nu$2,
|
|
detect: detect$6,
|
|
unknown: unknown$2
|
|
};
|
|
|
|
var detectBrowser$1 = function (browsers, userAgentData) {
|
|
return findMap(userAgentData.brands, function (uaBrand) {
|
|
var lcBrand = uaBrand.brand.toLowerCase();
|
|
return find$1(browsers, function (browser) {
|
|
var _a;
|
|
return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
}).map(function (info) {
|
|
return {
|
|
current: info.name,
|
|
version: Version.nu(parseInt(uaBrand.version, 10), 0)
|
|
};
|
|
});
|
|
});
|
|
};
|
|
|
|
var detect$5 = function (candidates, userAgent) {
|
|
var agent = String(userAgent).toLowerCase();
|
|
return find$1(candidates, function (candidate) {
|
|
return candidate.search(agent);
|
|
});
|
|
};
|
|
var detectBrowser = function (browsers, userAgent) {
|
|
return detect$5(browsers, userAgent).map(function (browser) {
|
|
var version = Version.detect(browser.versionRegexes, userAgent);
|
|
return {
|
|
current: browser.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
var detectOs = function (oses, userAgent) {
|
|
return detect$5(oses, userAgent).map(function (os) {
|
|
var version = Version.detect(os.versionRegexes, userAgent);
|
|
return {
|
|
current: os.name,
|
|
version: version
|
|
};
|
|
});
|
|
};
|
|
|
|
var removeFromStart = function (str, numChars) {
|
|
return str.substring(numChars);
|
|
};
|
|
|
|
var checkRange = function (str, substr, start) {
|
|
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
};
|
|
var removeLeading = function (str, prefix) {
|
|
return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
|
|
};
|
|
var contains$1 = function (str, substr) {
|
|
return str.indexOf(substr) !== -1;
|
|
};
|
|
var startsWith = function (str, prefix) {
|
|
return checkRange(str, prefix, 0);
|
|
};
|
|
var endsWith = function (str, suffix) {
|
|
return checkRange(str, suffix, str.length - suffix.length);
|
|
};
|
|
var blank = function (r) {
|
|
return function (s) {
|
|
return s.replace(r, '');
|
|
};
|
|
};
|
|
var trim = blank(/^\s+|\s+$/g);
|
|
var isNotEmpty = function (s) {
|
|
return s.length > 0;
|
|
};
|
|
var isEmpty$1 = function (s) {
|
|
return !isNotEmpty(s);
|
|
};
|
|
var toFloat = function (value) {
|
|
var num = parseFloat(value);
|
|
return isNaN(num) ? Optional.none() : Optional.some(num);
|
|
};
|
|
|
|
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
|
|
var checkContains = function (target) {
|
|
return function (uastring) {
|
|
return contains$1(uastring, target);
|
|
};
|
|
};
|
|
var browsers = [
|
|
{
|
|
name: 'Edge',
|
|
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
|
|
}
|
|
},
|
|
{
|
|
name: 'Chrome',
|
|
brand: 'Chromium',
|
|
versionRegexes: [
|
|
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
|
|
normalVersionRegex
|
|
],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');
|
|
}
|
|
},
|
|
{
|
|
name: 'IE',
|
|
versionRegexes: [
|
|
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*?rv:([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'msie') || contains$1(uastring, 'trident');
|
|
}
|
|
},
|
|
{
|
|
name: 'Opera',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?opera\/([0-9]+)\.([0-9]+).*/
|
|
],
|
|
search: checkContains('opera')
|
|
},
|
|
{
|
|
name: 'Firefox',
|
|
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
|
|
search: checkContains('firefox')
|
|
},
|
|
{
|
|
name: 'Safari',
|
|
versionRegexes: [
|
|
normalVersionRegex,
|
|
/.*?cpu os ([0-9]+)_([0-9]+).*/
|
|
],
|
|
search: function (uastring) {
|
|
return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');
|
|
}
|
|
}
|
|
];
|
|
var oses = [
|
|
{
|
|
name: 'Windows',
|
|
search: checkContains('win'),
|
|
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'iOS',
|
|
search: function (uastring) {
|
|
return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad');
|
|
},
|
|
versionRegexes: [
|
|
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
|
|
/.*cpu os ([0-9]+)_([0-9]+).*/,
|
|
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
|
|
]
|
|
},
|
|
{
|
|
name: 'Android',
|
|
search: checkContains('android'),
|
|
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'OSX',
|
|
search: checkContains('mac os x'),
|
|
versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
|
|
},
|
|
{
|
|
name: 'Linux',
|
|
search: checkContains('linux'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'Solaris',
|
|
search: checkContains('sunos'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'FreeBSD',
|
|
search: checkContains('freebsd'),
|
|
versionRegexes: []
|
|
},
|
|
{
|
|
name: 'ChromeOS',
|
|
search: checkContains('cros'),
|
|
versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
|
|
}
|
|
];
|
|
var PlatformInfo = {
|
|
browsers: constant(browsers),
|
|
oses: constant(oses)
|
|
};
|
|
|
|
var edge = 'Edge';
|
|
var chrome = 'Chrome';
|
|
var ie = 'IE';
|
|
var opera = 'Opera';
|
|
var firefox = 'Firefox';
|
|
var safari = 'Safari';
|
|
var unknown$1 = function () {
|
|
return nu$1({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu$1 = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isBrowser = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isEdge: isBrowser(edge),
|
|
isChrome: isBrowser(chrome),
|
|
isIE: isBrowser(ie),
|
|
isOpera: isBrowser(opera),
|
|
isFirefox: isBrowser(firefox),
|
|
isSafari: isBrowser(safari)
|
|
};
|
|
};
|
|
var Browser = {
|
|
unknown: unknown$1,
|
|
nu: nu$1,
|
|
edge: constant(edge),
|
|
chrome: constant(chrome),
|
|
ie: constant(ie),
|
|
opera: constant(opera),
|
|
firefox: constant(firefox),
|
|
safari: constant(safari)
|
|
};
|
|
|
|
var windows = 'Windows';
|
|
var ios = 'iOS';
|
|
var android = 'Android';
|
|
var linux = 'Linux';
|
|
var osx = 'OSX';
|
|
var solaris = 'Solaris';
|
|
var freebsd = 'FreeBSD';
|
|
var chromeos = 'ChromeOS';
|
|
var unknown = function () {
|
|
return nu({
|
|
current: undefined,
|
|
version: Version.unknown()
|
|
});
|
|
};
|
|
var nu = function (info) {
|
|
var current = info.current;
|
|
var version = info.version;
|
|
var isOS = function (name) {
|
|
return function () {
|
|
return current === name;
|
|
};
|
|
};
|
|
return {
|
|
current: current,
|
|
version: version,
|
|
isWindows: isOS(windows),
|
|
isiOS: isOS(ios),
|
|
isAndroid: isOS(android),
|
|
isOSX: isOS(osx),
|
|
isLinux: isOS(linux),
|
|
isSolaris: isOS(solaris),
|
|
isFreeBSD: isOS(freebsd),
|
|
isChromeOS: isOS(chromeos)
|
|
};
|
|
};
|
|
var OperatingSystem = {
|
|
unknown: unknown,
|
|
nu: nu,
|
|
windows: constant(windows),
|
|
ios: constant(ios),
|
|
android: constant(android),
|
|
linux: constant(linux),
|
|
osx: constant(osx),
|
|
solaris: constant(solaris),
|
|
freebsd: constant(freebsd),
|
|
chromeos: constant(chromeos)
|
|
};
|
|
|
|
var detect$4 = function (userAgent, userAgentDataOpt, mediaMatch) {
|
|
var browsers = PlatformInfo.browsers();
|
|
var oses = PlatformInfo.oses();
|
|
var browser = userAgentDataOpt.bind(function (userAgentData) {
|
|
return detectBrowser$1(browsers, userAgentData);
|
|
}).orThunk(function () {
|
|
return detectBrowser(browsers, userAgent);
|
|
}).fold(Browser.unknown, Browser.nu);
|
|
var os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
|
|
var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
|
|
return {
|
|
browser: browser,
|
|
os: os,
|
|
deviceType: deviceType
|
|
};
|
|
};
|
|
var PlatformDetection = { detect: detect$4 };
|
|
|
|
var mediaMatch = function (query) {
|
|
return window.matchMedia(query).matches;
|
|
};
|
|
var platform = cached(function () {
|
|
return PlatformDetection.detect(navigator.userAgent, Optional.from(navigator.userAgentData), mediaMatch);
|
|
});
|
|
var detect$3 = function () {
|
|
return platform();
|
|
};
|
|
|
|
var compareDocumentPosition = function (a, b, match) {
|
|
return (a.compareDocumentPosition(b) & match) !== 0;
|
|
};
|
|
var documentPositionContainedBy = function (a, b) {
|
|
return compareDocumentPosition(a, b, Node.DOCUMENT_POSITION_CONTAINED_BY);
|
|
};
|
|
|
|
var COMMENT = 8;
|
|
var DOCUMENT = 9;
|
|
var DOCUMENT_FRAGMENT = 11;
|
|
var ELEMENT = 1;
|
|
var TEXT = 3;
|
|
|
|
var fromHtml$1 = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom$1(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom$1(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom$1(node);
|
|
};
|
|
var fromDom$1 = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint$1 = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom$1);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml$1,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom$1,
|
|
fromPoint: fromPoint$1
|
|
};
|
|
|
|
var is$2 = function (element, selector) {
|
|
var dom = element.dom;
|
|
if (dom.nodeType !== ELEMENT) {
|
|
return false;
|
|
} else {
|
|
var elem = dom;
|
|
if (elem.matches !== undefined) {
|
|
return elem.matches(selector);
|
|
} else if (elem.msMatchesSelector !== undefined) {
|
|
return elem.msMatchesSelector(selector);
|
|
} else if (elem.webkitMatchesSelector !== undefined) {
|
|
return elem.webkitMatchesSelector(selector);
|
|
} else if (elem.mozMatchesSelector !== undefined) {
|
|
return elem.mozMatchesSelector(selector);
|
|
} else {
|
|
throw new Error('Browser lacks native selectors');
|
|
}
|
|
}
|
|
};
|
|
var bypassSelector = function (dom) {
|
|
return dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
|
|
};
|
|
var all$1 = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? [] : map$1(base.querySelectorAll(selector), SugarElement.fromDom);
|
|
};
|
|
var one = function (selector, scope) {
|
|
var base = scope === undefined ? document : scope.dom;
|
|
return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
|
|
};
|
|
|
|
var eq$1 = function (e1, e2) {
|
|
return e1.dom === e2.dom;
|
|
};
|
|
var regularContains = function (e1, e2) {
|
|
var d1 = e1.dom;
|
|
var d2 = e2.dom;
|
|
return d1 === d2 ? false : d1.contains(d2);
|
|
};
|
|
var ieContains = function (e1, e2) {
|
|
return documentPositionContainedBy(e1.dom, e2.dom);
|
|
};
|
|
var contains = function (e1, e2) {
|
|
return detect$3().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);
|
|
};
|
|
var is$1 = is$2;
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var each$1 = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var map = function (obj, f) {
|
|
return tupleMap(obj, function (x, i) {
|
|
return {
|
|
k: i,
|
|
v: f(x, i)
|
|
};
|
|
});
|
|
};
|
|
var tupleMap = function (obj, f) {
|
|
var r = {};
|
|
each$1(obj, function (x, i) {
|
|
var tuple = f(x, i);
|
|
r[tuple.k] = tuple.v;
|
|
});
|
|
return r;
|
|
};
|
|
var objAcc = function (r) {
|
|
return function (x, i) {
|
|
r[i] = x;
|
|
};
|
|
};
|
|
var internalFilter = function (obj, pred, onTrue, onFalse) {
|
|
var r = {};
|
|
each$1(obj, function (x, i) {
|
|
(pred(x, i) ? onTrue : onFalse)(x, i);
|
|
});
|
|
return r;
|
|
};
|
|
var filter$1 = function (obj, pred) {
|
|
var t = {};
|
|
internalFilter(obj, pred, objAcc(t), noop);
|
|
return t;
|
|
};
|
|
var mapToArray = function (obj, f) {
|
|
var r = [];
|
|
each$1(obj, function (value, name) {
|
|
r.push(f(value, name));
|
|
});
|
|
return r;
|
|
};
|
|
var values = function (obj) {
|
|
return mapToArray(obj, identity);
|
|
};
|
|
var size = function (obj) {
|
|
return keys(obj).length;
|
|
};
|
|
var get$c = function (obj, key) {
|
|
return has$1(obj, key) ? Optional.from(obj[key]) : Optional.none();
|
|
};
|
|
var has$1 = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
var hasNonNullableKey = function (obj, key) {
|
|
return has$1(obj, key) && obj[key] !== undefined && obj[key] !== null;
|
|
};
|
|
var isEmpty = function (r) {
|
|
for (var x in r) {
|
|
if (hasOwnProperty.call(r, x)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
var validSectionList = [
|
|
'tfoot',
|
|
'thead',
|
|
'tbody',
|
|
'colgroup'
|
|
];
|
|
var isValidSection = function (parentName) {
|
|
return contains$2(validSectionList, parentName);
|
|
};
|
|
var grid = function (rows, columns) {
|
|
return {
|
|
rows: rows,
|
|
columns: columns
|
|
};
|
|
};
|
|
var address = function (row, column) {
|
|
return {
|
|
row: row,
|
|
column: column
|
|
};
|
|
};
|
|
var detail = function (element, rowspan, colspan) {
|
|
return {
|
|
element: element,
|
|
rowspan: rowspan,
|
|
colspan: colspan
|
|
};
|
|
};
|
|
var detailnew = function (element, rowspan, colspan, isNew) {
|
|
return {
|
|
element: element,
|
|
rowspan: rowspan,
|
|
colspan: colspan,
|
|
isNew: isNew
|
|
};
|
|
};
|
|
var extended = function (element, rowspan, colspan, row, column, isLocked) {
|
|
return {
|
|
element: element,
|
|
rowspan: rowspan,
|
|
colspan: colspan,
|
|
row: row,
|
|
column: column,
|
|
isLocked: isLocked
|
|
};
|
|
};
|
|
var rowdetail = function (element, cells, section) {
|
|
return {
|
|
element: element,
|
|
cells: cells,
|
|
section: section
|
|
};
|
|
};
|
|
var rowdetailnew = function (element, cells, section, isNew) {
|
|
return {
|
|
element: element,
|
|
cells: cells,
|
|
section: section,
|
|
isNew: isNew
|
|
};
|
|
};
|
|
var elementnew = function (element, isNew, isLocked) {
|
|
return {
|
|
element: element,
|
|
isNew: isNew,
|
|
isLocked: isLocked
|
|
};
|
|
};
|
|
var rowcells = function (element, cells, section, isNew) {
|
|
return {
|
|
element: element,
|
|
cells: cells,
|
|
section: section,
|
|
isNew: isNew
|
|
};
|
|
};
|
|
var bounds = function (startRow, startCol, finishRow, finishCol) {
|
|
return {
|
|
startRow: startRow,
|
|
startCol: startCol,
|
|
finishRow: finishRow,
|
|
finishCol: finishCol
|
|
};
|
|
};
|
|
var columnext = function (element, colspan, column) {
|
|
return {
|
|
element: element,
|
|
colspan: colspan,
|
|
column: column
|
|
};
|
|
};
|
|
var colgroup = function (element, columns) {
|
|
return {
|
|
element: element,
|
|
columns: columns
|
|
};
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var name = function (element) {
|
|
var r = element.dom.nodeName;
|
|
return r.toLowerCase();
|
|
};
|
|
var type$1 = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type$1(element) === t;
|
|
};
|
|
};
|
|
var isComment = function (element) {
|
|
return type$1(element) === COMMENT || name(element) === '#comment';
|
|
};
|
|
var isElement = isType(ELEMENT);
|
|
var isText = isType(TEXT);
|
|
var isDocument = isType(DOCUMENT);
|
|
var isDocumentFragment = isType(DOCUMENT_FRAGMENT);
|
|
var isTag = function (tag) {
|
|
return function (e) {
|
|
return isElement(e) && name(e) === tag;
|
|
};
|
|
};
|
|
|
|
var owner = function (element) {
|
|
return SugarElement.fromDom(element.dom.ownerDocument);
|
|
};
|
|
var documentOrOwner = function (dos) {
|
|
return isDocument(dos) ? dos : owner(dos);
|
|
};
|
|
var defaultView = function (element) {
|
|
return SugarElement.fromDom(documentOrOwner(element).dom.defaultView);
|
|
};
|
|
var parent = function (element) {
|
|
return Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
|
|
};
|
|
var parentElement = function (element) {
|
|
return Optional.from(element.dom.parentElement).map(SugarElement.fromDom);
|
|
};
|
|
var parents = function (element, isRoot) {
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
var dom = element.dom;
|
|
var ret = [];
|
|
while (dom.parentNode !== null && dom.parentNode !== undefined) {
|
|
var rawParent = dom.parentNode;
|
|
var p = SugarElement.fromDom(rawParent);
|
|
ret.push(p);
|
|
if (stop(p) === true) {
|
|
break;
|
|
} else {
|
|
dom = rawParent;
|
|
}
|
|
}
|
|
return ret;
|
|
};
|
|
var prevSibling = function (element) {
|
|
return Optional.from(element.dom.previousSibling).map(SugarElement.fromDom);
|
|
};
|
|
var nextSibling = function (element) {
|
|
return Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
|
|
};
|
|
var children$3 = function (element) {
|
|
return map$1(element.dom.childNodes, SugarElement.fromDom);
|
|
};
|
|
var child$3 = function (element, index) {
|
|
var cs = element.dom.childNodes;
|
|
return Optional.from(cs[index]).map(SugarElement.fromDom);
|
|
};
|
|
var firstChild = function (element) {
|
|
return child$3(element, 0);
|
|
};
|
|
|
|
var isShadowRoot = function (dos) {
|
|
return isDocumentFragment(dos) && isNonNullable(dos.dom.host);
|
|
};
|
|
var supported = isFunction(Element.prototype.attachShadow) && isFunction(Node.prototype.getRootNode);
|
|
var isSupported$1 = constant(supported);
|
|
var getRootNode = supported ? function (e) {
|
|
return SugarElement.fromDom(e.dom.getRootNode());
|
|
} : documentOrOwner;
|
|
var getShadowRoot = function (e) {
|
|
var r = getRootNode(e);
|
|
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
|
|
};
|
|
var getShadowHost = function (e) {
|
|
return SugarElement.fromDom(e.dom.host);
|
|
};
|
|
var getOriginalEventTarget = function (event) {
|
|
if (isSupported$1() && isNonNullable(event.target)) {
|
|
var el = SugarElement.fromDom(event.target);
|
|
if (isElement(el) && isOpenShadowHost(el)) {
|
|
if (event.composed && event.composedPath) {
|
|
var composedPath = event.composedPath();
|
|
if (composedPath) {
|
|
return head(composedPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Optional.from(event.target);
|
|
};
|
|
var isOpenShadowHost = function (element) {
|
|
return isNonNullable(element.dom.shadowRoot);
|
|
};
|
|
|
|
var inBody = function (element) {
|
|
var dom = isText(element) ? element.dom.parentNode : element.dom;
|
|
if (dom === undefined || dom === null || dom.ownerDocument === null) {
|
|
return false;
|
|
}
|
|
var doc = dom.ownerDocument;
|
|
return getShadowRoot(SugarElement.fromDom(dom)).fold(function () {
|
|
return doc.body.contains(dom);
|
|
}, compose1(inBody, getShadowHost));
|
|
};
|
|
var body$1 = function () {
|
|
return getBody$1(SugarElement.fromDom(document));
|
|
};
|
|
var getBody$1 = function (doc) {
|
|
var b = doc.dom.body;
|
|
if (b === null || b === undefined) {
|
|
throw new Error('Body is not available yet');
|
|
}
|
|
return SugarElement.fromDom(b);
|
|
};
|
|
|
|
var ancestors$4 = function (scope, predicate, isRoot) {
|
|
return filter$2(parents(scope, isRoot), predicate);
|
|
};
|
|
var children$2 = function (scope, predicate) {
|
|
return filter$2(children$3(scope), predicate);
|
|
};
|
|
var descendants$1 = function (scope, predicate) {
|
|
var result = [];
|
|
each$2(children$3(scope), function (x) {
|
|
if (predicate(x)) {
|
|
result = result.concat([x]);
|
|
}
|
|
result = result.concat(descendants$1(x, predicate));
|
|
});
|
|
return result;
|
|
};
|
|
|
|
var ancestors$3 = function (scope, selector, isRoot) {
|
|
return ancestors$4(scope, function (e) {
|
|
return is$2(e, selector);
|
|
}, isRoot);
|
|
};
|
|
var children$1 = function (scope, selector) {
|
|
return children$2(scope, function (e) {
|
|
return is$2(e, selector);
|
|
});
|
|
};
|
|
var descendants = function (scope, selector) {
|
|
return all$1(selector, scope);
|
|
};
|
|
|
|
function ClosestOrAncestor (is, ancestor, scope, a, isRoot) {
|
|
if (is(scope, a)) {
|
|
return Optional.some(scope);
|
|
} else if (isFunction(isRoot) && isRoot(scope)) {
|
|
return Optional.none();
|
|
} else {
|
|
return ancestor(scope, a, isRoot);
|
|
}
|
|
}
|
|
|
|
var ancestor$2 = function (scope, predicate, isRoot) {
|
|
var element = scope.dom;
|
|
var stop = isFunction(isRoot) ? isRoot : never;
|
|
while (element.parentNode) {
|
|
element = element.parentNode;
|
|
var el = SugarElement.fromDom(element);
|
|
if (predicate(el)) {
|
|
return Optional.some(el);
|
|
} else if (stop(el)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var closest$2 = function (scope, predicate, isRoot) {
|
|
var is = function (s, test) {
|
|
return test(s);
|
|
};
|
|
return ClosestOrAncestor(is, ancestor$2, scope, predicate, isRoot);
|
|
};
|
|
var child$2 = function (scope, predicate) {
|
|
var pred = function (node) {
|
|
return predicate(SugarElement.fromDom(node));
|
|
};
|
|
var result = find$1(scope.dom.childNodes, pred);
|
|
return result.map(SugarElement.fromDom);
|
|
};
|
|
var descendant$1 = function (scope, predicate) {
|
|
var descend = function (node) {
|
|
for (var i = 0; i < node.childNodes.length; i++) {
|
|
var child_1 = SugarElement.fromDom(node.childNodes[i]);
|
|
if (predicate(child_1)) {
|
|
return Optional.some(child_1);
|
|
}
|
|
var res = descend(node.childNodes[i]);
|
|
if (res.isSome()) {
|
|
return res;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
return descend(scope.dom);
|
|
};
|
|
|
|
var ancestor$1 = function (scope, selector, isRoot) {
|
|
return ancestor$2(scope, function (e) {
|
|
return is$2(e, selector);
|
|
}, isRoot);
|
|
};
|
|
var child$1 = function (scope, selector) {
|
|
return child$2(scope, function (e) {
|
|
return is$2(e, selector);
|
|
});
|
|
};
|
|
var descendant = function (scope, selector) {
|
|
return one(selector, scope);
|
|
};
|
|
var closest$1 = function (scope, selector, isRoot) {
|
|
var is = function (element, selector) {
|
|
return is$2(element, selector);
|
|
};
|
|
return ClosestOrAncestor(is, ancestor$1, scope, selector, isRoot);
|
|
};
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set$2 = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
var setAll$1 = function (element, attrs) {
|
|
var dom = element.dom;
|
|
each$1(attrs, function (v, k) {
|
|
rawSet(dom, k, v);
|
|
});
|
|
};
|
|
var setOptions = function (element, attrs) {
|
|
each$1(attrs, function (v, k) {
|
|
v.fold(function () {
|
|
remove$7(element, k);
|
|
}, function (value) {
|
|
rawSet(element.dom, k, value);
|
|
});
|
|
});
|
|
};
|
|
var get$b = function (element, key) {
|
|
var v = element.dom.getAttribute(key);
|
|
return v === null ? undefined : v;
|
|
};
|
|
var getOpt = function (element, key) {
|
|
return Optional.from(get$b(element, key));
|
|
};
|
|
var remove$7 = function (element, key) {
|
|
element.dom.removeAttribute(key);
|
|
};
|
|
var clone$2 = function (element) {
|
|
return foldl(element.dom.attributes, function (acc, attr) {
|
|
acc[attr.name] = attr.value;
|
|
return acc;
|
|
}, {});
|
|
};
|
|
|
|
var is = function (lhs, rhs, comparator) {
|
|
if (comparator === void 0) {
|
|
comparator = tripleEquals;
|
|
}
|
|
return lhs.exists(function (left) {
|
|
return comparator(left, rhs);
|
|
});
|
|
};
|
|
var cat = function (arr) {
|
|
var r = [];
|
|
var push = function (x) {
|
|
r.push(x);
|
|
};
|
|
for (var i = 0; i < arr.length; i++) {
|
|
arr[i].each(push);
|
|
}
|
|
return r;
|
|
};
|
|
var lift2 = function (oa, ob, f) {
|
|
return oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
|
|
};
|
|
var bindFrom = function (a, f) {
|
|
return a !== undefined && a !== null ? f(a) : Optional.none();
|
|
};
|
|
var flatten = function (oot) {
|
|
return oot.bind(identity);
|
|
};
|
|
var someIf = function (b, a) {
|
|
return b ? Optional.some(a) : Optional.none();
|
|
};
|
|
|
|
var isSupported = function (dom) {
|
|
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
|
|
};
|
|
|
|
var internalSet = function (dom, property, value) {
|
|
if (!isString(value)) {
|
|
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('CSS value must be a string: ' + value);
|
|
}
|
|
if (isSupported(dom)) {
|
|
dom.style.setProperty(property, value);
|
|
}
|
|
};
|
|
var internalRemove = function (dom, property) {
|
|
if (isSupported(dom)) {
|
|
dom.style.removeProperty(property);
|
|
}
|
|
};
|
|
var set$1 = function (element, property, value) {
|
|
var dom = element.dom;
|
|
internalSet(dom, property, value);
|
|
};
|
|
var setAll = function (element, css) {
|
|
var dom = element.dom;
|
|
each$1(css, function (v, k) {
|
|
internalSet(dom, k, v);
|
|
});
|
|
};
|
|
var get$a = function (element, property) {
|
|
var dom = element.dom;
|
|
var styles = window.getComputedStyle(dom);
|
|
var r = styles.getPropertyValue(property);
|
|
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
|
|
};
|
|
var getUnsafeProperty = function (dom, property) {
|
|
return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
|
|
};
|
|
var getRaw$2 = function (element, property) {
|
|
var dom = element.dom;
|
|
var raw = getUnsafeProperty(dom, property);
|
|
return Optional.from(raw).filter(function (r) {
|
|
return r.length > 0;
|
|
});
|
|
};
|
|
var remove$6 = function (element, property) {
|
|
var dom = element.dom;
|
|
internalRemove(dom, property);
|
|
if (is(getOpt(element, 'style').map(trim), '')) {
|
|
remove$7(element, 'style');
|
|
}
|
|
};
|
|
var copy$2 = function (source, target) {
|
|
var sourceDom = source.dom;
|
|
var targetDom = target.dom;
|
|
if (isSupported(sourceDom) && isSupported(targetDom)) {
|
|
targetDom.style.cssText = sourceDom.style.cssText;
|
|
}
|
|
};
|
|
|
|
var getAttrValue = function (cell, name, fallback) {
|
|
if (fallback === void 0) {
|
|
fallback = 0;
|
|
}
|
|
return getOpt(cell, name).map(function (value) {
|
|
return parseInt(value, 10);
|
|
}).getOr(fallback);
|
|
};
|
|
var getSpan = function (cell, type) {
|
|
return getAttrValue(cell, type, 1);
|
|
};
|
|
var hasColspan = function (cellOrCol) {
|
|
if (isTag('col')(cellOrCol)) {
|
|
return getAttrValue(cellOrCol, 'span', 1) > 1;
|
|
} else {
|
|
return getSpan(cellOrCol, 'colspan') > 1;
|
|
}
|
|
};
|
|
var hasRowspan = function (cell) {
|
|
return getSpan(cell, 'rowspan') > 1;
|
|
};
|
|
var getCssValue = function (element, property) {
|
|
return parseInt(get$a(element, property), 10);
|
|
};
|
|
var minWidth = constant(10);
|
|
var minHeight = constant(10);
|
|
|
|
var firstLayer = function (scope, selector) {
|
|
return filterFirstLayer(scope, selector, always);
|
|
};
|
|
var filterFirstLayer = function (scope, selector, predicate) {
|
|
return bind$2(children$3(scope), function (x) {
|
|
if (is$2(x, selector)) {
|
|
return predicate(x) ? [x] : [];
|
|
} else {
|
|
return filterFirstLayer(x, selector, predicate);
|
|
}
|
|
});
|
|
};
|
|
|
|
var lookup = function (tags, element, isRoot) {
|
|
if (isRoot === void 0) {
|
|
isRoot = never;
|
|
}
|
|
if (isRoot(element)) {
|
|
return Optional.none();
|
|
}
|
|
if (contains$2(tags, name(element))) {
|
|
return Optional.some(element);
|
|
}
|
|
var isRootOrUpperTable = function (elm) {
|
|
return is$2(elm, 'table') || isRoot(elm);
|
|
};
|
|
return ancestor$1(element, tags.join(','), isRootOrUpperTable);
|
|
};
|
|
var cell = function (element, isRoot) {
|
|
return lookup([
|
|
'td',
|
|
'th'
|
|
], element, isRoot);
|
|
};
|
|
var cells$1 = function (ancestor) {
|
|
return firstLayer(ancestor, 'th,td');
|
|
};
|
|
var columns$1 = function (ancestor) {
|
|
if (is$2(ancestor, 'colgroup')) {
|
|
return children$1(ancestor, 'col');
|
|
} else {
|
|
return bind$2(columnGroups(ancestor), function (columnGroup) {
|
|
return children$1(columnGroup, 'col');
|
|
});
|
|
}
|
|
};
|
|
var table = function (element, isRoot) {
|
|
return closest$1(element, 'table', isRoot);
|
|
};
|
|
var rows$1 = function (ancestor) {
|
|
return firstLayer(ancestor, 'tr');
|
|
};
|
|
var columnGroups = function (ancestor) {
|
|
return table(ancestor).fold(constant([]), function (table) {
|
|
return children$1(table, 'colgroup');
|
|
});
|
|
};
|
|
|
|
var fromRowsOrColGroups = function (elems, getSection) {
|
|
return map$1(elems, function (row) {
|
|
if (name(row) === 'colgroup') {
|
|
var cells = map$1(columns$1(row), function (column) {
|
|
var colspan = getAttrValue(column, 'span', 1);
|
|
return detail(column, 1, colspan);
|
|
});
|
|
return rowdetail(row, cells, 'colgroup');
|
|
} else {
|
|
var cells = map$1(cells$1(row), function (cell) {
|
|
var rowspan = getAttrValue(cell, 'rowspan', 1);
|
|
var colspan = getAttrValue(cell, 'colspan', 1);
|
|
return detail(cell, rowspan, colspan);
|
|
});
|
|
return rowdetail(row, cells, getSection(row));
|
|
}
|
|
});
|
|
};
|
|
var getParentSection = function (group) {
|
|
return parent(group).map(function (parent) {
|
|
var parentName = name(parent);
|
|
return isValidSection(parentName) ? parentName : 'tbody';
|
|
}).getOr('tbody');
|
|
};
|
|
var fromTable$1 = function (table) {
|
|
var rows = rows$1(table);
|
|
var columnGroups$1 = columnGroups(table);
|
|
var elems = __spreadArray(__spreadArray([], columnGroups$1, true), rows, true);
|
|
return fromRowsOrColGroups(elems, getParentSection);
|
|
};
|
|
var fromPastedRows = function (elems, section) {
|
|
return fromRowsOrColGroups(elems, function () {
|
|
return section;
|
|
});
|
|
};
|
|
|
|
var addCells = function (gridRow, index, cells) {
|
|
var existingCells = gridRow.cells;
|
|
var before = existingCells.slice(0, index);
|
|
var after = existingCells.slice(index);
|
|
var newCells = before.concat(cells).concat(after);
|
|
return setCells(gridRow, newCells);
|
|
};
|
|
var addCell = function (gridRow, index, cell) {
|
|
return addCells(gridRow, index, [cell]);
|
|
};
|
|
var mutateCell = function (gridRow, index, cell) {
|
|
var cells = gridRow.cells;
|
|
cells[index] = cell;
|
|
};
|
|
var setCells = function (gridRow, cells) {
|
|
return rowcells(gridRow.element, cells, gridRow.section, gridRow.isNew);
|
|
};
|
|
var mapCells = function (gridRow, f) {
|
|
var cells = gridRow.cells;
|
|
var r = map$1(cells, f);
|
|
return rowcells(gridRow.element, r, gridRow.section, gridRow.isNew);
|
|
};
|
|
var getCell = function (gridRow, index) {
|
|
return gridRow.cells[index];
|
|
};
|
|
var getCellElement = function (gridRow, index) {
|
|
return getCell(gridRow, index).element;
|
|
};
|
|
var cellLength = function (gridRow) {
|
|
return gridRow.cells.length;
|
|
};
|
|
var extractGridDetails = function (grid) {
|
|
var result = partition(grid, function (row) {
|
|
return row.section === 'colgroup';
|
|
});
|
|
return {
|
|
rows: result.fail,
|
|
cols: result.pass
|
|
};
|
|
};
|
|
var clone$1 = function (gridRow, cloneRow, cloneCell) {
|
|
var newCells = map$1(gridRow.cells, cloneCell);
|
|
return rowcells(cloneRow(gridRow.element), newCells, gridRow.section, true);
|
|
};
|
|
|
|
var LOCKED_COL_ATTR = 'data-snooker-locked-cols';
|
|
var getLockedColumnsFromTable = function (table) {
|
|
return getOpt(table, LOCKED_COL_ATTR).bind(function (lockedColStr) {
|
|
return Optional.from(lockedColStr.match(/\d+/g));
|
|
}).map(function (lockedCols) {
|
|
return mapToObject(lockedCols, always);
|
|
});
|
|
};
|
|
var getLockedColumnsFromGrid = function (grid) {
|
|
var locked = foldl(extractGridDetails(grid).rows, function (acc, row) {
|
|
each$2(row.cells, function (cell, idx) {
|
|
if (cell.isLocked) {
|
|
acc[idx] = true;
|
|
}
|
|
});
|
|
return acc;
|
|
}, {});
|
|
var lockedArr = mapToArray(locked, function (_val, key) {
|
|
return parseInt(key, 10);
|
|
});
|
|
return sort$1(lockedArr);
|
|
};
|
|
|
|
var key = function (row, column) {
|
|
return row + ',' + column;
|
|
};
|
|
var getAt = function (warehouse, row, column) {
|
|
return Optional.from(warehouse.access[key(row, column)]);
|
|
};
|
|
var findItem = function (warehouse, item, comparator) {
|
|
var filtered = filterItems(warehouse, function (detail) {
|
|
return comparator(item, detail.element);
|
|
});
|
|
return filtered.length > 0 ? Optional.some(filtered[0]) : Optional.none();
|
|
};
|
|
var filterItems = function (warehouse, predicate) {
|
|
var all = bind$2(warehouse.all, function (r) {
|
|
return r.cells;
|
|
});
|
|
return filter$2(all, predicate);
|
|
};
|
|
var generateColumns = function (rowData) {
|
|
var columnsGroup = {};
|
|
var index = 0;
|
|
each$2(rowData.cells, function (column) {
|
|
var colspan = column.colspan;
|
|
range$1(colspan, function (columnIndex) {
|
|
var colIndex = index + columnIndex;
|
|
columnsGroup[colIndex] = columnext(column.element, colspan, colIndex);
|
|
});
|
|
index += colspan;
|
|
});
|
|
return columnsGroup;
|
|
};
|
|
var generate$1 = function (list) {
|
|
var access = {};
|
|
var cells = [];
|
|
var tableOpt = head(list).map(function (rowData) {
|
|
return rowData.element;
|
|
}).bind(table);
|
|
var lockedColumns = tableOpt.bind(getLockedColumnsFromTable).getOr({});
|
|
var maxRows = 0;
|
|
var maxColumns = 0;
|
|
var rowCount = 0;
|
|
var _a = partition(list, function (rowData) {
|
|
return rowData.section === 'colgroup';
|
|
}), colgroupRows = _a.pass, rows = _a.fail;
|
|
each$2(rows, function (rowData) {
|
|
var currentRow = [];
|
|
each$2(rowData.cells, function (rowCell) {
|
|
var start = 0;
|
|
while (access[key(rowCount, start)] !== undefined) {
|
|
start++;
|
|
}
|
|
var isLocked = hasNonNullableKey(lockedColumns, start.toString());
|
|
var current = extended(rowCell.element, rowCell.rowspan, rowCell.colspan, rowCount, start, isLocked);
|
|
for (var occupiedColumnPosition = 0; occupiedColumnPosition < rowCell.colspan; occupiedColumnPosition++) {
|
|
for (var occupiedRowPosition = 0; occupiedRowPosition < rowCell.rowspan; occupiedRowPosition++) {
|
|
var rowPosition = rowCount + occupiedRowPosition;
|
|
var columnPosition = start + occupiedColumnPosition;
|
|
var newpos = key(rowPosition, columnPosition);
|
|
access[newpos] = current;
|
|
maxColumns = Math.max(maxColumns, columnPosition + 1);
|
|
}
|
|
}
|
|
currentRow.push(current);
|
|
});
|
|
maxRows++;
|
|
cells.push(rowdetail(rowData.element, currentRow, rowData.section));
|
|
rowCount++;
|
|
});
|
|
var _b = last$2(colgroupRows).map(function (rowData) {
|
|
var columns = generateColumns(rowData);
|
|
var colgroup$1 = colgroup(rowData.element, values(columns));
|
|
return {
|
|
colgroups: [colgroup$1],
|
|
columns: columns
|
|
};
|
|
}).getOrThunk(function () {
|
|
return {
|
|
colgroups: [],
|
|
columns: {}
|
|
};
|
|
}), columns = _b.columns, colgroups = _b.colgroups;
|
|
var grid$1 = grid(maxRows, maxColumns);
|
|
return {
|
|
grid: grid$1,
|
|
access: access,
|
|
all: cells,
|
|
columns: columns,
|
|
colgroups: colgroups
|
|
};
|
|
};
|
|
var fromTable = function (table) {
|
|
var list = fromTable$1(table);
|
|
return generate$1(list);
|
|
};
|
|
var justCells = function (warehouse) {
|
|
return bind$2(warehouse.all, function (w) {
|
|
return w.cells;
|
|
});
|
|
};
|
|
var justColumns = function (warehouse) {
|
|
return values(warehouse.columns);
|
|
};
|
|
var hasColumns = function (warehouse) {
|
|
return keys(warehouse.columns).length > 0;
|
|
};
|
|
var getColumnAt = function (warehouse, columnIndex) {
|
|
return Optional.from(warehouse.columns[columnIndex]);
|
|
};
|
|
var Warehouse = {
|
|
fromTable: fromTable,
|
|
generate: generate$1,
|
|
getAt: getAt,
|
|
findItem: findItem,
|
|
filterItems: filterItems,
|
|
justCells: justCells,
|
|
justColumns: justColumns,
|
|
hasColumns: hasColumns,
|
|
getColumnAt: getColumnAt
|
|
};
|
|
|
|
var inSelection = function (bounds, detail) {
|
|
var leftEdge = detail.column;
|
|
var rightEdge = detail.column + detail.colspan - 1;
|
|
var topEdge = detail.row;
|
|
var bottomEdge = detail.row + detail.rowspan - 1;
|
|
return leftEdge <= bounds.finishCol && rightEdge >= bounds.startCol && (topEdge <= bounds.finishRow && bottomEdge >= bounds.startRow);
|
|
};
|
|
var isWithin = function (bounds, detail) {
|
|
return detail.column >= bounds.startCol && detail.column + detail.colspan - 1 <= bounds.finishCol && detail.row >= bounds.startRow && detail.row + detail.rowspan - 1 <= bounds.finishRow;
|
|
};
|
|
var isRectangular = function (warehouse, bounds) {
|
|
var isRect = true;
|
|
var detailIsWithin = curry(isWithin, bounds);
|
|
for (var i = bounds.startRow; i <= bounds.finishRow; i++) {
|
|
for (var j = bounds.startCol; j <= bounds.finishCol; j++) {
|
|
isRect = isRect && Warehouse.getAt(warehouse, i, j).exists(detailIsWithin);
|
|
}
|
|
}
|
|
return isRect ? Optional.some(bounds) : Optional.none();
|
|
};
|
|
|
|
var getBounds = function (detailA, detailB) {
|
|
return bounds(Math.min(detailA.row, detailB.row), Math.min(detailA.column, detailB.column), Math.max(detailA.row + detailA.rowspan - 1, detailB.row + detailB.rowspan - 1), Math.max(detailA.column + detailA.colspan - 1, detailB.column + detailB.colspan - 1));
|
|
};
|
|
var getAnyBox = function (warehouse, startCell, finishCell) {
|
|
var startCoords = Warehouse.findItem(warehouse, startCell, eq$1);
|
|
var finishCoords = Warehouse.findItem(warehouse, finishCell, eq$1);
|
|
return startCoords.bind(function (sc) {
|
|
return finishCoords.map(function (fc) {
|
|
return getBounds(sc, fc);
|
|
});
|
|
});
|
|
};
|
|
var getBox$1 = function (warehouse, startCell, finishCell) {
|
|
return getAnyBox(warehouse, startCell, finishCell).bind(function (bounds) {
|
|
return isRectangular(warehouse, bounds);
|
|
});
|
|
};
|
|
|
|
var moveBy$1 = function (warehouse, cell, row, column) {
|
|
return Warehouse.findItem(warehouse, cell, eq$1).bind(function (detail) {
|
|
var startRow = row > 0 ? detail.row + detail.rowspan - 1 : detail.row;
|
|
var startCol = column > 0 ? detail.column + detail.colspan - 1 : detail.column;
|
|
var dest = Warehouse.getAt(warehouse, startRow + row, startCol + column);
|
|
return dest.map(function (d) {
|
|
return d.element;
|
|
});
|
|
});
|
|
};
|
|
var intercepts$1 = function (warehouse, start, finish) {
|
|
return getAnyBox(warehouse, start, finish).map(function (bounds) {
|
|
var inside = Warehouse.filterItems(warehouse, curry(inSelection, bounds));
|
|
return map$1(inside, function (detail) {
|
|
return detail.element;
|
|
});
|
|
});
|
|
};
|
|
var parentCell = function (warehouse, innerCell) {
|
|
var isContainedBy = function (c1, c2) {
|
|
return contains(c2, c1);
|
|
};
|
|
return Warehouse.findItem(warehouse, innerCell, isContainedBy).map(function (detail) {
|
|
return detail.element;
|
|
});
|
|
};
|
|
|
|
var moveBy = function (cell, deltaRow, deltaColumn) {
|
|
return table(cell).bind(function (table) {
|
|
var warehouse = getWarehouse(table);
|
|
return moveBy$1(warehouse, cell, deltaRow, deltaColumn);
|
|
});
|
|
};
|
|
var intercepts = function (table, first, last) {
|
|
var warehouse = getWarehouse(table);
|
|
return intercepts$1(warehouse, first, last);
|
|
};
|
|
var nestedIntercepts = function (table, first, firstTable, last, lastTable) {
|
|
var warehouse = getWarehouse(table);
|
|
var optStartCell = eq$1(table, firstTable) ? Optional.some(first) : parentCell(warehouse, first);
|
|
var optLastCell = eq$1(table, lastTable) ? Optional.some(last) : parentCell(warehouse, last);
|
|
return optStartCell.bind(function (startCell) {
|
|
return optLastCell.bind(function (lastCell) {
|
|
return intercepts$1(warehouse, startCell, lastCell);
|
|
});
|
|
});
|
|
};
|
|
var getBox = function (table, first, last) {
|
|
var warehouse = getWarehouse(table);
|
|
return getBox$1(warehouse, first, last);
|
|
};
|
|
var getWarehouse = Warehouse.fromTable;
|
|
|
|
var before$4 = function (marker, element) {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
v.dom.insertBefore(element.dom, marker.dom);
|
|
});
|
|
};
|
|
var after$5 = function (marker, element) {
|
|
var sibling = nextSibling(marker);
|
|
sibling.fold(function () {
|
|
var parent$1 = parent(marker);
|
|
parent$1.each(function (v) {
|
|
append$1(v, element);
|
|
});
|
|
}, function (v) {
|
|
before$4(v, element);
|
|
});
|
|
};
|
|
var prepend = function (parent, element) {
|
|
var firstChild$1 = firstChild(parent);
|
|
firstChild$1.fold(function () {
|
|
append$1(parent, element);
|
|
}, function (v) {
|
|
parent.dom.insertBefore(element.dom, v.dom);
|
|
});
|
|
};
|
|
var append$1 = function (parent, element) {
|
|
parent.dom.appendChild(element.dom);
|
|
};
|
|
var appendAt = function (parent, element, index) {
|
|
child$3(parent, index).fold(function () {
|
|
append$1(parent, element);
|
|
}, function (v) {
|
|
before$4(v, element);
|
|
});
|
|
};
|
|
var wrap = function (element, wrapper) {
|
|
before$4(element, wrapper);
|
|
append$1(wrapper, element);
|
|
};
|
|
|
|
var before$3 = function (marker, elements) {
|
|
each$2(elements, function (x) {
|
|
before$4(marker, x);
|
|
});
|
|
};
|
|
var after$4 = function (marker, elements) {
|
|
each$2(elements, function (x, i) {
|
|
var e = i === 0 ? marker : elements[i - 1];
|
|
after$5(e, x);
|
|
});
|
|
};
|
|
var append = function (parent, elements) {
|
|
each$2(elements, function (x) {
|
|
append$1(parent, x);
|
|
});
|
|
};
|
|
|
|
var empty = function (element) {
|
|
element.dom.textContent = '';
|
|
each$2(children$3(element), function (rogue) {
|
|
remove$5(rogue);
|
|
});
|
|
};
|
|
var remove$5 = function (element) {
|
|
var dom = element.dom;
|
|
if (dom.parentNode !== null) {
|
|
dom.parentNode.removeChild(dom);
|
|
}
|
|
};
|
|
var unwrap = function (wrapper) {
|
|
var children = children$3(wrapper);
|
|
if (children.length > 0) {
|
|
before$3(wrapper, children);
|
|
}
|
|
remove$5(wrapper);
|
|
};
|
|
|
|
var NodeValue = function (is, name) {
|
|
var get = function (element) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only get ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
return getOption(element).getOr('');
|
|
};
|
|
var getOption = function (element) {
|
|
return is(element) ? Optional.from(element.dom.nodeValue) : Optional.none();
|
|
};
|
|
var set = function (element, value) {
|
|
if (!is(element)) {
|
|
throw new Error('Can only set raw ' + name + ' value of a ' + name + ' node');
|
|
}
|
|
element.dom.nodeValue = value;
|
|
};
|
|
return {
|
|
get: get,
|
|
getOption: getOption,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var api$2 = NodeValue(isText, 'text');
|
|
var get$9 = function (element) {
|
|
return api$2.get(element);
|
|
};
|
|
var getOption = function (element) {
|
|
return api$2.getOption(element);
|
|
};
|
|
var set = function (element, value) {
|
|
return api$2.set(element, value);
|
|
};
|
|
|
|
var TagBoundaries = [
|
|
'body',
|
|
'p',
|
|
'div',
|
|
'article',
|
|
'aside',
|
|
'figcaption',
|
|
'figure',
|
|
'footer',
|
|
'header',
|
|
'nav',
|
|
'section',
|
|
'ol',
|
|
'ul',
|
|
'li',
|
|
'table',
|
|
'thead',
|
|
'tbody',
|
|
'tfoot',
|
|
'caption',
|
|
'tr',
|
|
'td',
|
|
'th',
|
|
'h1',
|
|
'h2',
|
|
'h3',
|
|
'h4',
|
|
'h5',
|
|
'h6',
|
|
'blockquote',
|
|
'pre',
|
|
'address'
|
|
];
|
|
|
|
function DomUniverse () {
|
|
var clone = function (element) {
|
|
return SugarElement.fromDom(element.dom.cloneNode(false));
|
|
};
|
|
var document = function (element) {
|
|
return documentOrOwner(element).dom;
|
|
};
|
|
var isBoundary = function (element) {
|
|
if (!isElement(element)) {
|
|
return false;
|
|
}
|
|
if (name(element) === 'body') {
|
|
return true;
|
|
}
|
|
return contains$2(TagBoundaries, name(element));
|
|
};
|
|
var isEmptyTag = function (element) {
|
|
if (!isElement(element)) {
|
|
return false;
|
|
}
|
|
return contains$2([
|
|
'br',
|
|
'img',
|
|
'hr',
|
|
'input'
|
|
], name(element));
|
|
};
|
|
var isNonEditable = function (element) {
|
|
return isElement(element) && get$b(element, 'contenteditable') === 'false';
|
|
};
|
|
var comparePosition = function (element, other) {
|
|
return element.dom.compareDocumentPosition(other.dom);
|
|
};
|
|
var copyAttributesTo = function (source, destination) {
|
|
var as = clone$2(source);
|
|
setAll$1(destination, as);
|
|
};
|
|
var isSpecial = function (element) {
|
|
var tag = name(element);
|
|
return contains$2([
|
|
'script',
|
|
'noscript',
|
|
'iframe',
|
|
'noframes',
|
|
'noembed',
|
|
'title',
|
|
'style',
|
|
'textarea',
|
|
'xmp'
|
|
], tag);
|
|
};
|
|
var getLanguage = function (element) {
|
|
return isElement(element) ? getOpt(element, 'lang') : Optional.none();
|
|
};
|
|
return {
|
|
up: constant({
|
|
selector: ancestor$1,
|
|
closest: closest$1,
|
|
predicate: ancestor$2,
|
|
all: parents
|
|
}),
|
|
down: constant({
|
|
selector: descendants,
|
|
predicate: descendants$1
|
|
}),
|
|
styles: constant({
|
|
get: get$a,
|
|
getRaw: getRaw$2,
|
|
set: set$1,
|
|
remove: remove$6
|
|
}),
|
|
attrs: constant({
|
|
get: get$b,
|
|
set: set$2,
|
|
remove: remove$7,
|
|
copyTo: copyAttributesTo
|
|
}),
|
|
insert: constant({
|
|
before: before$4,
|
|
after: after$5,
|
|
afterAll: after$4,
|
|
append: append$1,
|
|
appendAll: append,
|
|
prepend: prepend,
|
|
wrap: wrap
|
|
}),
|
|
remove: constant({
|
|
unwrap: unwrap,
|
|
remove: remove$5
|
|
}),
|
|
create: constant({
|
|
nu: SugarElement.fromTag,
|
|
clone: clone,
|
|
text: SugarElement.fromText
|
|
}),
|
|
query: constant({
|
|
comparePosition: comparePosition,
|
|
prevSibling: prevSibling,
|
|
nextSibling: nextSibling
|
|
}),
|
|
property: constant({
|
|
children: children$3,
|
|
name: name,
|
|
parent: parent,
|
|
document: document,
|
|
isText: isText,
|
|
isComment: isComment,
|
|
isElement: isElement,
|
|
isSpecial: isSpecial,
|
|
getLanguage: getLanguage,
|
|
getText: get$9,
|
|
setText: set,
|
|
isBoundary: isBoundary,
|
|
isEmptyTag: isEmptyTag,
|
|
isNonEditable: isNonEditable
|
|
}),
|
|
eq: eq$1,
|
|
is: is$1
|
|
};
|
|
}
|
|
|
|
var all = function (universe, look, elements, f) {
|
|
var head = elements[0];
|
|
var tail = elements.slice(1);
|
|
return f(universe, look, head, tail);
|
|
};
|
|
var oneAll = function (universe, look, elements) {
|
|
return elements.length > 0 ? all(universe, look, elements, unsafeOne) : Optional.none();
|
|
};
|
|
var unsafeOne = function (universe, look, head, tail) {
|
|
var start = look(universe, head);
|
|
return foldr(tail, function (b, a) {
|
|
var current = look(universe, a);
|
|
return commonElement(universe, b, current);
|
|
}, start);
|
|
};
|
|
var commonElement = function (universe, start, end) {
|
|
return start.bind(function (s) {
|
|
return end.filter(curry(universe.eq, s));
|
|
});
|
|
};
|
|
|
|
var eq = function (universe, item) {
|
|
return curry(universe.eq, item);
|
|
};
|
|
var ancestors$2 = function (universe, start, end, isRoot) {
|
|
if (isRoot === void 0) {
|
|
isRoot = never;
|
|
}
|
|
var ps1 = [start].concat(universe.up().all(start));
|
|
var ps2 = [end].concat(universe.up().all(end));
|
|
var prune = function (path) {
|
|
var index = findIndex(path, isRoot);
|
|
return index.fold(function () {
|
|
return path;
|
|
}, function (ind) {
|
|
return path.slice(0, ind + 1);
|
|
});
|
|
};
|
|
var pruned1 = prune(ps1);
|
|
var pruned2 = prune(ps2);
|
|
var shared = find$1(pruned1, function (x) {
|
|
return exists(pruned2, eq(universe, x));
|
|
});
|
|
return {
|
|
firstpath: pruned1,
|
|
secondpath: pruned2,
|
|
shared: shared
|
|
};
|
|
};
|
|
|
|
var sharedOne$1 = oneAll;
|
|
var ancestors$1 = ancestors$2;
|
|
|
|
var universe$3 = DomUniverse();
|
|
var sharedOne = function (look, elements) {
|
|
return sharedOne$1(universe$3, function (_universe, element) {
|
|
return look(element);
|
|
}, elements);
|
|
};
|
|
var ancestors = function (start, finish, isRoot) {
|
|
return ancestors$1(universe$3, start, finish, isRoot);
|
|
};
|
|
|
|
var lookupTable = function (container) {
|
|
return ancestor$1(container, 'table');
|
|
};
|
|
var identify = function (start, finish, isRoot) {
|
|
var getIsRoot = function (rootTable) {
|
|
return function (element) {
|
|
return isRoot !== undefined && isRoot(element) || eq$1(element, rootTable);
|
|
};
|
|
};
|
|
if (eq$1(start, finish)) {
|
|
return Optional.some({
|
|
boxes: Optional.some([start]),
|
|
start: start,
|
|
finish: finish
|
|
});
|
|
} else {
|
|
return lookupTable(start).bind(function (startTable) {
|
|
return lookupTable(finish).bind(function (finishTable) {
|
|
if (eq$1(startTable, finishTable)) {
|
|
return Optional.some({
|
|
boxes: intercepts(startTable, start, finish),
|
|
start: start,
|
|
finish: finish
|
|
});
|
|
} else if (contains(startTable, finishTable)) {
|
|
var ancestorCells = ancestors$3(finish, 'td,th', getIsRoot(startTable));
|
|
var finishCell = ancestorCells.length > 0 ? ancestorCells[ancestorCells.length - 1] : finish;
|
|
return Optional.some({
|
|
boxes: nestedIntercepts(startTable, start, startTable, finish, finishTable),
|
|
start: start,
|
|
finish: finishCell
|
|
});
|
|
} else if (contains(finishTable, startTable)) {
|
|
var ancestorCells = ancestors$3(start, 'td,th', getIsRoot(finishTable));
|
|
var startCell = ancestorCells.length > 0 ? ancestorCells[ancestorCells.length - 1] : start;
|
|
return Optional.some({
|
|
boxes: nestedIntercepts(finishTable, start, startTable, finish, finishTable),
|
|
start: start,
|
|
finish: startCell
|
|
});
|
|
} else {
|
|
return ancestors(start, finish).shared.bind(function (lca) {
|
|
return closest$1(lca, 'table', isRoot).bind(function (lcaTable) {
|
|
var finishAncestorCells = ancestors$3(finish, 'td,th', getIsRoot(lcaTable));
|
|
var finishCell = finishAncestorCells.length > 0 ? finishAncestorCells[finishAncestorCells.length - 1] : finish;
|
|
var startAncestorCells = ancestors$3(start, 'td,th', getIsRoot(lcaTable));
|
|
var startCell = startAncestorCells.length > 0 ? startAncestorCells[startAncestorCells.length - 1] : start;
|
|
return Optional.some({
|
|
boxes: nestedIntercepts(lcaTable, start, startTable, finish, finishTable),
|
|
start: startCell,
|
|
finish: finishCell
|
|
});
|
|
});
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var retrieve$1 = function (container, selector) {
|
|
var sels = descendants(container, selector);
|
|
return sels.length > 0 ? Optional.some(sels) : Optional.none();
|
|
};
|
|
var getLast = function (boxes, lastSelectedSelector) {
|
|
return find$1(boxes, function (box) {
|
|
return is$2(box, lastSelectedSelector);
|
|
});
|
|
};
|
|
var getEdges = function (container, firstSelectedSelector, lastSelectedSelector) {
|
|
return descendant(container, firstSelectedSelector).bind(function (first) {
|
|
return descendant(container, lastSelectedSelector).bind(function (last) {
|
|
return sharedOne(lookupTable, [
|
|
first,
|
|
last
|
|
]).map(function (table) {
|
|
return {
|
|
first: first,
|
|
last: last,
|
|
table: table
|
|
};
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var expandTo = function (finish, firstSelectedSelector) {
|
|
return ancestor$1(finish, 'table').bind(function (table) {
|
|
return descendant(table, firstSelectedSelector).bind(function (start) {
|
|
return identify(start, finish).bind(function (identified) {
|
|
return identified.boxes.map(function (boxes) {
|
|
return {
|
|
boxes: boxes,
|
|
start: identified.start,
|
|
finish: identified.finish
|
|
};
|
|
});
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var shiftSelection = function (boxes, deltaRow, deltaColumn, firstSelectedSelector, lastSelectedSelector) {
|
|
return getLast(boxes, lastSelectedSelector).bind(function (last) {
|
|
return moveBy(last, deltaRow, deltaColumn).bind(function (finish) {
|
|
return expandTo(finish, firstSelectedSelector);
|
|
});
|
|
});
|
|
};
|
|
|
|
var retrieve = function (container, selector) {
|
|
return retrieve$1(container, selector);
|
|
};
|
|
var retrieveBox = function (container, firstSelectedSelector, lastSelectedSelector) {
|
|
return getEdges(container, firstSelectedSelector, lastSelectedSelector).bind(function (edges) {
|
|
var isRoot = function (ancestor) {
|
|
return eq$1(container, ancestor);
|
|
};
|
|
var sectionSelector = 'thead,tfoot,tbody,table';
|
|
var firstAncestor = ancestor$1(edges.first, sectionSelector, isRoot);
|
|
var lastAncestor = ancestor$1(edges.last, sectionSelector, isRoot);
|
|
return firstAncestor.bind(function (fA) {
|
|
return lastAncestor.bind(function (lA) {
|
|
return eq$1(fA, lA) ? getBox(edges.table, edges.first, edges.last) : Optional.none();
|
|
});
|
|
});
|
|
});
|
|
};
|
|
|
|
var generate = function (cases) {
|
|
if (!isArray(cases)) {
|
|
throw new Error('cases must be an array');
|
|
}
|
|
if (cases.length === 0) {
|
|
throw new Error('there must be at least one case');
|
|
}
|
|
var constructors = [];
|
|
var adt = {};
|
|
each$2(cases, function (acase, count) {
|
|
var keys$1 = keys(acase);
|
|
if (keys$1.length !== 1) {
|
|
throw new Error('one and only one name per case');
|
|
}
|
|
var key = keys$1[0];
|
|
var value = acase[key];
|
|
if (adt[key] !== undefined) {
|
|
throw new Error('duplicate key detected:' + key);
|
|
} else if (key === 'cata') {
|
|
throw new Error('cannot have a case named cata (sorry)');
|
|
} else if (!isArray(value)) {
|
|
throw new Error('case arguments must be an array');
|
|
}
|
|
constructors.push(key);
|
|
adt[key] = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var argLength = args.length;
|
|
if (argLength !== value.length) {
|
|
throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
|
|
}
|
|
var match = function (branches) {
|
|
var branchKeys = keys(branches);
|
|
if (constructors.length !== branchKeys.length) {
|
|
throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
|
|
}
|
|
var allReqd = forall(constructors, function (reqKey) {
|
|
return contains$2(branchKeys, reqKey);
|
|
});
|
|
if (!allReqd) {
|
|
throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
|
|
}
|
|
return branches[key].apply(null, args);
|
|
};
|
|
return {
|
|
fold: function () {
|
|
var foldArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
foldArgs[_i] = arguments[_i];
|
|
}
|
|
if (foldArgs.length !== cases.length) {
|
|
throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
|
|
}
|
|
var target = foldArgs[count];
|
|
return target.apply(null, args);
|
|
},
|
|
match: match,
|
|
log: function (label) {
|
|
console.log(label, {
|
|
constructors: constructors,
|
|
constructor: key,
|
|
params: args
|
|
});
|
|
}
|
|
};
|
|
};
|
|
});
|
|
return adt;
|
|
};
|
|
var Adt = { generate: generate };
|
|
|
|
var type = Adt.generate([
|
|
{ none: [] },
|
|
{ multiple: ['elements'] },
|
|
{ single: ['element'] }
|
|
]);
|
|
var cata$2 = function (subject, onNone, onMultiple, onSingle) {
|
|
return subject.fold(onNone, onMultiple, onSingle);
|
|
};
|
|
var none$1 = type.none;
|
|
var multiple = type.multiple;
|
|
var single = type.single;
|
|
|
|
var Selections = function (lazyRoot, getStart, selectedSelector) {
|
|
var get = function () {
|
|
return retrieve(lazyRoot(), selectedSelector).fold(function () {
|
|
return getStart().fold(none$1, single);
|
|
}, function (cells) {
|
|
return multiple(cells);
|
|
});
|
|
};
|
|
return { get: get };
|
|
};
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var clone = function (original, isDeep) {
|
|
return SugarElement.fromDom(original.dom.cloneNode(isDeep));
|
|
};
|
|
var shallow = function (original) {
|
|
return clone(original, false);
|
|
};
|
|
var deep = function (original) {
|
|
return clone(original, true);
|
|
};
|
|
var shallowAs = function (original, tag) {
|
|
var nu = SugarElement.fromTag(tag);
|
|
var attributes = clone$2(original);
|
|
setAll$1(nu, attributes);
|
|
return nu;
|
|
};
|
|
var copy$1 = function (original, tag) {
|
|
var nu = shallowAs(original, tag);
|
|
var cloneChildren = children$3(deep(original));
|
|
append(nu, cloneChildren);
|
|
return nu;
|
|
};
|
|
var mutate$1 = function (original, tag) {
|
|
var nu = shallowAs(original, tag);
|
|
before$4(original, nu);
|
|
var children = children$3(original);
|
|
append(nu, children);
|
|
remove$5(original);
|
|
return nu;
|
|
};
|
|
|
|
var Dimension = function (name, getOffset) {
|
|
var set = function (element, h) {
|
|
if (!isNumber(h) && !h.match(/^[0-9]+$/)) {
|
|
throw new Error(name + '.set accepts only positive integer values. Value was ' + h);
|
|
}
|
|
var dom = element.dom;
|
|
if (isSupported(dom)) {
|
|
dom.style[name] = h + 'px';
|
|
}
|
|
};
|
|
var get = function (element) {
|
|
var r = getOffset(element);
|
|
if (r <= 0 || r === null) {
|
|
var css = get$a(element, name);
|
|
return parseFloat(css) || 0;
|
|
}
|
|
return r;
|
|
};
|
|
var getOuter = get;
|
|
var aggregate = function (element, properties) {
|
|
return foldl(properties, function (acc, property) {
|
|
var val = get$a(element, property);
|
|
var value = val === undefined ? 0 : parseInt(val, 10);
|
|
return isNaN(value) ? acc : acc + value;
|
|
}, 0);
|
|
};
|
|
var max = function (element, value, properties) {
|
|
var cumulativeInclusions = aggregate(element, properties);
|
|
var absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;
|
|
return absoluteMax;
|
|
};
|
|
return {
|
|
set: set,
|
|
get: get,
|
|
getOuter: getOuter,
|
|
aggregate: aggregate,
|
|
max: max
|
|
};
|
|
};
|
|
|
|
var needManualCalc = function () {
|
|
var browser = detect$3().browser;
|
|
return browser.isIE() || browser.isEdge();
|
|
};
|
|
var toNumber = function (px, fallback) {
|
|
return toFloat(px).getOr(fallback);
|
|
};
|
|
var getProp = function (element, name, fallback) {
|
|
return toNumber(get$a(element, name), fallback);
|
|
};
|
|
var getBoxSizing = function (element) {
|
|
return get$a(element, 'box-sizing');
|
|
};
|
|
var calcContentBoxSize = function (element, size, upper, lower) {
|
|
var paddingUpper = getProp(element, 'padding-' + upper, 0);
|
|
var paddingLower = getProp(element, 'padding-' + lower, 0);
|
|
var borderUpper = getProp(element, 'border-' + upper + '-width', 0);
|
|
var borderLower = getProp(element, 'border-' + lower + '-width', 0);
|
|
return size - paddingUpper - paddingLower - borderUpper - borderLower;
|
|
};
|
|
var getCalculatedHeight = function (element, boxSizing) {
|
|
var dom = element.dom;
|
|
var height = dom.getBoundingClientRect().height || dom.offsetHeight;
|
|
return boxSizing === 'border-box' ? height : calcContentBoxSize(element, height, 'top', 'bottom');
|
|
};
|
|
var getCalculatedWidth = function (element, boxSizing) {
|
|
var dom = element.dom;
|
|
var width = dom.getBoundingClientRect().width || dom.offsetWidth;
|
|
return boxSizing === 'border-box' ? width : calcContentBoxSize(element, width, 'left', 'right');
|
|
};
|
|
var getHeight$1 = function (element) {
|
|
return needManualCalc() ? getCalculatedHeight(element, getBoxSizing(element)) : getProp(element, 'height', element.dom.offsetHeight);
|
|
};
|
|
var getWidth = function (element) {
|
|
return needManualCalc() ? getCalculatedWidth(element, getBoxSizing(element)) : getProp(element, 'width', element.dom.offsetWidth);
|
|
};
|
|
var getInnerWidth = function (element) {
|
|
return getCalculatedWidth(element, 'content-box');
|
|
};
|
|
|
|
var api$1 = Dimension('width', function (element) {
|
|
return element.dom.offsetWidth;
|
|
});
|
|
var get$8 = function (element) {
|
|
return api$1.get(element);
|
|
};
|
|
var getOuter$2 = function (element) {
|
|
return api$1.getOuter(element);
|
|
};
|
|
var getInner = getInnerWidth;
|
|
var getRuntime$1 = getWidth;
|
|
|
|
var columns = function (warehouse, isValidCell) {
|
|
if (isValidCell === void 0) {
|
|
isValidCell = always;
|
|
}
|
|
var grid = warehouse.grid;
|
|
var cols = range$1(grid.columns, identity);
|
|
var rowsArr = range$1(grid.rows, identity);
|
|
return map$1(cols, function (col) {
|
|
var getBlock = function () {
|
|
return bind$2(rowsArr, function (r) {
|
|
return Warehouse.getAt(warehouse, r, col).filter(function (detail) {
|
|
return detail.column === col;
|
|
}).toArray();
|
|
});
|
|
};
|
|
var isValid = function (detail) {
|
|
return detail.colspan === 1 && isValidCell(detail.element);
|
|
};
|
|
var getFallback = function () {
|
|
return Warehouse.getAt(warehouse, 0, col);
|
|
};
|
|
return decide(getBlock, isValid, getFallback);
|
|
});
|
|
};
|
|
var decide = function (getBlock, isValid, getFallback) {
|
|
var inBlock = getBlock();
|
|
var validInBlock = find$1(inBlock, isValid);
|
|
var detailOption = validInBlock.orThunk(function () {
|
|
return Optional.from(inBlock[0]).orThunk(getFallback);
|
|
});
|
|
return detailOption.map(function (detail) {
|
|
return detail.element;
|
|
});
|
|
};
|
|
var rows = function (warehouse) {
|
|
var grid = warehouse.grid;
|
|
var rowsArr = range$1(grid.rows, identity);
|
|
var cols = range$1(grid.columns, identity);
|
|
return map$1(rowsArr, function (row) {
|
|
var getBlock = function () {
|
|
return bind$2(cols, function (c) {
|
|
return Warehouse.getAt(warehouse, row, c).filter(function (detail) {
|
|
return detail.row === row;
|
|
}).fold(constant([]), function (detail) {
|
|
return [detail];
|
|
});
|
|
});
|
|
};
|
|
var isSingle = function (detail) {
|
|
return detail.rowspan === 1;
|
|
};
|
|
var getFallback = function () {
|
|
return Warehouse.getAt(warehouse, row, 0);
|
|
};
|
|
return decide(getBlock, isSingle, getFallback);
|
|
});
|
|
};
|
|
|
|
var deduce = function (xs, index) {
|
|
if (index < 0 || index >= xs.length - 1) {
|
|
return Optional.none();
|
|
}
|
|
var current = xs[index].fold(function () {
|
|
var rest = reverse(xs.slice(0, index));
|
|
return findMap(rest, function (a, i) {
|
|
return a.map(function (aa) {
|
|
return {
|
|
value: aa,
|
|
delta: i + 1
|
|
};
|
|
});
|
|
});
|
|
}, function (c) {
|
|
return Optional.some({
|
|
value: c,
|
|
delta: 0
|
|
});
|
|
});
|
|
var next = xs[index + 1].fold(function () {
|
|
var rest = xs.slice(index + 1);
|
|
return findMap(rest, function (a, i) {
|
|
return a.map(function (aa) {
|
|
return {
|
|
value: aa,
|
|
delta: i + 1
|
|
};
|
|
});
|
|
});
|
|
}, function (n) {
|
|
return Optional.some({
|
|
value: n,
|
|
delta: 1
|
|
});
|
|
});
|
|
return current.bind(function (c) {
|
|
return next.map(function (n) {
|
|
var extras = n.delta + c.delta;
|
|
return Math.abs(n.value - c.value) / extras;
|
|
});
|
|
});
|
|
};
|
|
|
|
var onDirection = function (isLtr, isRtl) {
|
|
return function (element) {
|
|
return getDirection(element) === 'rtl' ? isRtl : isLtr;
|
|
};
|
|
};
|
|
var getDirection = function (element) {
|
|
return get$a(element, 'direction') === 'rtl' ? 'rtl' : 'ltr';
|
|
};
|
|
|
|
var api = Dimension('height', function (element) {
|
|
var dom = element.dom;
|
|
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
|
|
});
|
|
var get$7 = function (element) {
|
|
return api.get(element);
|
|
};
|
|
var getOuter$1 = function (element) {
|
|
return api.getOuter(element);
|
|
};
|
|
var getRuntime = getHeight$1;
|
|
|
|
var r = function (left, top) {
|
|
var translate = function (x, y) {
|
|
return r(left + x, top + y);
|
|
};
|
|
return {
|
|
left: left,
|
|
top: top,
|
|
translate: translate
|
|
};
|
|
};
|
|
var SugarPosition = r;
|
|
|
|
var boxPosition = function (dom) {
|
|
var box = dom.getBoundingClientRect();
|
|
return SugarPosition(box.left, box.top);
|
|
};
|
|
var firstDefinedOrZero = function (a, b) {
|
|
if (a !== undefined) {
|
|
return a;
|
|
} else {
|
|
return b !== undefined ? b : 0;
|
|
}
|
|
};
|
|
var absolute = function (element) {
|
|
var doc = element.dom.ownerDocument;
|
|
var body = doc.body;
|
|
var win = doc.defaultView;
|
|
var html = doc.documentElement;
|
|
if (body === element.dom) {
|
|
return SugarPosition(body.offsetLeft, body.offsetTop);
|
|
}
|
|
var scrollTop = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageYOffset, html.scrollTop);
|
|
var scrollLeft = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageXOffset, html.scrollLeft);
|
|
var clientTop = firstDefinedOrZero(html.clientTop, body.clientTop);
|
|
var clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft);
|
|
return viewport(element).translate(scrollLeft - clientLeft, scrollTop - clientTop);
|
|
};
|
|
var viewport = function (element) {
|
|
var dom = element.dom;
|
|
var doc = dom.ownerDocument;
|
|
var body = doc.body;
|
|
if (body === dom) {
|
|
return SugarPosition(body.offsetLeft, body.offsetTop);
|
|
}
|
|
if (!inBody(element)) {
|
|
return SugarPosition(0, 0);
|
|
}
|
|
return boxPosition(dom);
|
|
};
|
|
|
|
var rowInfo = function (row, y) {
|
|
return {
|
|
row: row,
|
|
y: y
|
|
};
|
|
};
|
|
var colInfo = function (col, x) {
|
|
return {
|
|
col: col,
|
|
x: x
|
|
};
|
|
};
|
|
var rtlEdge = function (cell) {
|
|
var pos = absolute(cell);
|
|
return pos.left + getOuter$2(cell);
|
|
};
|
|
var ltrEdge = function (cell) {
|
|
return absolute(cell).left;
|
|
};
|
|
var getLeftEdge = function (index, cell) {
|
|
return colInfo(index, ltrEdge(cell));
|
|
};
|
|
var getRightEdge = function (index, cell) {
|
|
return colInfo(index, rtlEdge(cell));
|
|
};
|
|
var getTop$1 = function (cell) {
|
|
return absolute(cell).top;
|
|
};
|
|
var getTopEdge = function (index, cell) {
|
|
return rowInfo(index, getTop$1(cell));
|
|
};
|
|
var getBottomEdge = function (index, cell) {
|
|
return rowInfo(index, getTop$1(cell) + getOuter$1(cell));
|
|
};
|
|
var findPositions = function (getInnerEdge, getOuterEdge, array) {
|
|
if (array.length === 0) {
|
|
return [];
|
|
}
|
|
var lines = map$1(array.slice(1), function (cellOption, index) {
|
|
return cellOption.map(function (cell) {
|
|
return getInnerEdge(index, cell);
|
|
});
|
|
});
|
|
var lastLine = array[array.length - 1].map(function (cell) {
|
|
return getOuterEdge(array.length - 1, cell);
|
|
});
|
|
return lines.concat([lastLine]);
|
|
};
|
|
var negate = function (step) {
|
|
return -step;
|
|
};
|
|
var height = {
|
|
delta: identity,
|
|
positions: function (optElements) {
|
|
return findPositions(getTopEdge, getBottomEdge, optElements);
|
|
},
|
|
edge: getTop$1
|
|
};
|
|
var ltr$1 = {
|
|
delta: identity,
|
|
edge: ltrEdge,
|
|
positions: function (optElements) {
|
|
return findPositions(getLeftEdge, getRightEdge, optElements);
|
|
}
|
|
};
|
|
var rtl$1 = {
|
|
delta: negate,
|
|
edge: rtlEdge,
|
|
positions: function (optElements) {
|
|
return findPositions(getRightEdge, getLeftEdge, optElements);
|
|
}
|
|
};
|
|
var detect$2 = onDirection(ltr$1, rtl$1);
|
|
var width = {
|
|
delta: function (amount, table) {
|
|
return detect$2(table).delta(amount, table);
|
|
},
|
|
positions: function (cols, table) {
|
|
return detect$2(table).positions(cols, table);
|
|
},
|
|
edge: function (cell) {
|
|
return detect$2(cell).edge(cell);
|
|
}
|
|
};
|
|
|
|
var units = {
|
|
unsupportedLength: [
|
|
'em',
|
|
'ex',
|
|
'cap',
|
|
'ch',
|
|
'ic',
|
|
'rem',
|
|
'lh',
|
|
'rlh',
|
|
'vw',
|
|
'vh',
|
|
'vi',
|
|
'vb',
|
|
'vmin',
|
|
'vmax',
|
|
'cm',
|
|
'mm',
|
|
'Q',
|
|
'in',
|
|
'pc',
|
|
'pt',
|
|
'px'
|
|
],
|
|
fixed: [
|
|
'px',
|
|
'pt'
|
|
],
|
|
relative: ['%'],
|
|
empty: ['']
|
|
};
|
|
var pattern = function () {
|
|
var decimalDigits = '[0-9]+';
|
|
var signedInteger = '[+-]?' + decimalDigits;
|
|
var exponentPart = '[eE]' + signedInteger;
|
|
var dot = '\\.';
|
|
var opt = function (input) {
|
|
return '(?:' + input + ')?';
|
|
};
|
|
var unsignedDecimalLiteral = [
|
|
'Infinity',
|
|
decimalDigits + dot + opt(decimalDigits) + opt(exponentPart),
|
|
dot + decimalDigits + opt(exponentPart),
|
|
decimalDigits + opt(exponentPart)
|
|
].join('|');
|
|
var float = '[+-]?(?:' + unsignedDecimalLiteral + ')';
|
|
return new RegExp('^(' + float + ')(.*)$');
|
|
}();
|
|
var isUnit = function (unit, accepted) {
|
|
return exists(accepted, function (acc) {
|
|
return exists(units[acc], function (check) {
|
|
return unit === check;
|
|
});
|
|
});
|
|
};
|
|
var parse = function (input, accepted) {
|
|
var match = Optional.from(pattern.exec(input));
|
|
return match.bind(function (array) {
|
|
var value = Number(array[1]);
|
|
var unitRaw = array[2];
|
|
if (isUnit(unitRaw, accepted)) {
|
|
return Optional.some({
|
|
value: value,
|
|
unit: unitRaw
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
};
|
|
|
|
var rPercentageBasedSizeRegex = /(\d+(\.\d+)?)%/;
|
|
var rPixelBasedSizeRegex = /(\d+(\.\d+)?)px|em/;
|
|
var isCol$2 = isTag('col');
|
|
var getPercentSize = function (elm, outerGetter, innerGetter) {
|
|
var relativeParent = parentElement(elm).getOrThunk(function () {
|
|
return getBody$1(owner(elm));
|
|
});
|
|
return outerGetter(elm) / innerGetter(relativeParent) * 100;
|
|
};
|
|
var setPixelWidth = function (cell, amount) {
|
|
set$1(cell, 'width', amount + 'px');
|
|
};
|
|
var setPercentageWidth = function (cell, amount) {
|
|
set$1(cell, 'width', amount + '%');
|
|
};
|
|
var setHeight = function (cell, amount) {
|
|
set$1(cell, 'height', amount + 'px');
|
|
};
|
|
var getHeightValue = function (cell) {
|
|
return getRuntime(cell) + 'px';
|
|
};
|
|
var convert = function (cell, number, getter, setter) {
|
|
var newSize = table(cell).map(function (table) {
|
|
var total = getter(table);
|
|
return Math.floor(number / 100 * total);
|
|
}).getOr(number);
|
|
setter(cell, newSize);
|
|
return newSize;
|
|
};
|
|
var normalizePixelSize = function (value, cell, getter, setter) {
|
|
var number = parseFloat(value);
|
|
return endsWith(value, '%') && name(cell) !== 'table' ? convert(cell, number, getter, setter) : number;
|
|
};
|
|
var getTotalHeight = function (cell) {
|
|
var value = getHeightValue(cell);
|
|
if (!value) {
|
|
return get$7(cell);
|
|
}
|
|
return normalizePixelSize(value, cell, get$7, setHeight);
|
|
};
|
|
var get$6 = function (cell, type, f) {
|
|
var v = f(cell);
|
|
var span = getSpan(cell, type);
|
|
return v / span;
|
|
};
|
|
var getRaw$1 = function (element, prop) {
|
|
return getRaw$2(element, prop).orThunk(function () {
|
|
return getOpt(element, prop).map(function (val) {
|
|
return val + 'px';
|
|
});
|
|
});
|
|
};
|
|
var getRawWidth$1 = function (element) {
|
|
return getRaw$1(element, 'width');
|
|
};
|
|
var getRawHeight = function (element) {
|
|
return getRaw$1(element, 'height');
|
|
};
|
|
var getPercentageWidth = function (cell) {
|
|
return getPercentSize(cell, get$8, getInner);
|
|
};
|
|
var getPixelWidth$1 = function (cell) {
|
|
return isCol$2(cell) ? get$8(cell) : getRuntime$1(cell);
|
|
};
|
|
var getHeight = function (cell) {
|
|
return get$6(cell, 'rowspan', getTotalHeight);
|
|
};
|
|
var getGenericWidth = function (cell) {
|
|
var width = getRawWidth$1(cell);
|
|
return width.bind(function (w) {
|
|
return parse(w, [
|
|
'fixed',
|
|
'relative',
|
|
'empty'
|
|
]);
|
|
});
|
|
};
|
|
var setGenericWidth = function (cell, amount, unit) {
|
|
set$1(cell, 'width', amount + unit);
|
|
};
|
|
var getPixelTableWidth = function (table) {
|
|
return get$8(table) + 'px';
|
|
};
|
|
var getPercentTableWidth = function (table) {
|
|
return getPercentSize(table, get$8, getInner) + '%';
|
|
};
|
|
var isPercentSizing$1 = function (table) {
|
|
return getRawWidth$1(table).exists(function (size) {
|
|
return rPercentageBasedSizeRegex.test(size);
|
|
});
|
|
};
|
|
var isPixelSizing$1 = function (table) {
|
|
return getRawWidth$1(table).exists(function (size) {
|
|
return rPixelBasedSizeRegex.test(size);
|
|
});
|
|
};
|
|
var isNoneSizing$1 = function (table) {
|
|
return getRawWidth$1(table).isNone();
|
|
};
|
|
var percentageBasedSizeRegex = constant(rPercentageBasedSizeRegex);
|
|
|
|
var isCol$1 = isTag('col');
|
|
var getRawW = function (cell) {
|
|
return getRawWidth$1(cell).getOrThunk(function () {
|
|
return getPixelWidth$1(cell) + 'px';
|
|
});
|
|
};
|
|
var getRawH = function (cell) {
|
|
return getRawHeight(cell).getOrThunk(function () {
|
|
return getHeight(cell) + 'px';
|
|
});
|
|
};
|
|
var justCols = function (warehouse) {
|
|
return map$1(Warehouse.justColumns(warehouse), function (column) {
|
|
return Optional.from(column.element);
|
|
});
|
|
};
|
|
var isValidColumn = function (cell) {
|
|
var browser = detect$3().browser;
|
|
var supportsColWidths = browser.isChrome() || browser.isFirefox();
|
|
return isCol$1(cell) ? supportsColWidths : true;
|
|
};
|
|
var getDimension = function (cellOpt, index, backups, filter, getter, fallback) {
|
|
return cellOpt.filter(filter).fold(function () {
|
|
return fallback(deduce(backups, index));
|
|
}, function (cell) {
|
|
return getter(cell);
|
|
});
|
|
};
|
|
var getWidthFrom = function (warehouse, table, getWidth, fallback) {
|
|
var columnCells = columns(warehouse);
|
|
var columns$1 = Warehouse.hasColumns(warehouse) ? justCols(warehouse) : columnCells;
|
|
var backups = [Optional.some(width.edge(table))].concat(map$1(width.positions(columnCells, table), function (pos) {
|
|
return pos.map(function (p) {
|
|
return p.x;
|
|
});
|
|
}));
|
|
var colFilter = not(hasColspan);
|
|
return map$1(columns$1, function (cellOption, c) {
|
|
return getDimension(cellOption, c, backups, colFilter, function (column) {
|
|
if (isValidColumn(column)) {
|
|
return getWidth(column);
|
|
} else {
|
|
var cell = bindFrom(columnCells[c], identity);
|
|
return getDimension(cell, c, backups, colFilter, function (cell) {
|
|
return fallback(Optional.some(get$8(cell)));
|
|
}, fallback);
|
|
}
|
|
}, fallback);
|
|
});
|
|
};
|
|
var getDeduced = function (deduced) {
|
|
return deduced.map(function (d) {
|
|
return d + 'px';
|
|
}).getOr('');
|
|
};
|
|
var getRawWidths = function (warehouse, table) {
|
|
return getWidthFrom(warehouse, table, getRawW, getDeduced);
|
|
};
|
|
var getPercentageWidths = function (warehouse, table, tableSize) {
|
|
return getWidthFrom(warehouse, table, getPercentageWidth, function (deduced) {
|
|
return deduced.fold(function () {
|
|
return tableSize.minCellWidth();
|
|
}, function (cellWidth) {
|
|
return cellWidth / tableSize.pixelWidth() * 100;
|
|
});
|
|
});
|
|
};
|
|
var getPixelWidths = function (warehouse, table, tableSize) {
|
|
return getWidthFrom(warehouse, table, getPixelWidth$1, function (deduced) {
|
|
return deduced.getOrThunk(tableSize.minCellWidth);
|
|
});
|
|
};
|
|
var getHeightFrom = function (warehouse, table, direction, getHeight, fallback) {
|
|
var rows$1 = rows(warehouse);
|
|
var backups = [Optional.some(direction.edge(table))].concat(map$1(direction.positions(rows$1, table), function (pos) {
|
|
return pos.map(function (p) {
|
|
return p.y;
|
|
});
|
|
}));
|
|
return map$1(rows$1, function (cellOption, c) {
|
|
return getDimension(cellOption, c, backups, not(hasRowspan), getHeight, fallback);
|
|
});
|
|
};
|
|
var getPixelHeights = function (warehouse, table, direction) {
|
|
return getHeightFrom(warehouse, table, direction, getHeight, function (deduced) {
|
|
return deduced.getOrThunk(minHeight);
|
|
});
|
|
};
|
|
var getRawHeights = function (warehouse, table, direction) {
|
|
return getHeightFrom(warehouse, table, direction, getRawH, getDeduced);
|
|
};
|
|
|
|
var widthLookup = function (table, getter) {
|
|
return function () {
|
|
if (inBody(table)) {
|
|
return getter(table);
|
|
} else {
|
|
return parseFloat(getRaw$2(table, 'width').getOr('0'));
|
|
}
|
|
};
|
|
};
|
|
var noneSize = function (table) {
|
|
var getWidth = widthLookup(table, get$8);
|
|
var zero = constant(0);
|
|
var getWidths = function (warehouse, tableSize) {
|
|
return getPixelWidths(warehouse, table, tableSize);
|
|
};
|
|
return {
|
|
width: getWidth,
|
|
pixelWidth: getWidth,
|
|
getWidths: getWidths,
|
|
getCellDelta: zero,
|
|
singleColumnWidth: constant([0]),
|
|
minCellWidth: zero,
|
|
setElementWidth: noop,
|
|
adjustTableWidth: noop,
|
|
isRelative: true,
|
|
label: 'none'
|
|
};
|
|
};
|
|
var percentageSize = function (table) {
|
|
var getFloatWidth = widthLookup(table, function (elem) {
|
|
return parseFloat(getPercentTableWidth(elem));
|
|
});
|
|
var getWidth = widthLookup(table, get$8);
|
|
var getCellDelta = function (delta) {
|
|
return delta / getWidth() * 100;
|
|
};
|
|
var singleColumnWidth = function (w, _delta) {
|
|
return [100 - w];
|
|
};
|
|
var minCellWidth = function () {
|
|
return minWidth() / getWidth() * 100;
|
|
};
|
|
var adjustTableWidth = function (delta) {
|
|
var currentWidth = getFloatWidth();
|
|
var change = delta / 100 * currentWidth;
|
|
var newWidth = currentWidth + change;
|
|
setPercentageWidth(table, newWidth);
|
|
};
|
|
var getWidths = function (warehouse, tableSize) {
|
|
return getPercentageWidths(warehouse, table, tableSize);
|
|
};
|
|
return {
|
|
width: getFloatWidth,
|
|
pixelWidth: getWidth,
|
|
getWidths: getWidths,
|
|
getCellDelta: getCellDelta,
|
|
singleColumnWidth: singleColumnWidth,
|
|
minCellWidth: minCellWidth,
|
|
setElementWidth: setPercentageWidth,
|
|
adjustTableWidth: adjustTableWidth,
|
|
isRelative: true,
|
|
label: 'percent'
|
|
};
|
|
};
|
|
var pixelSize = function (table) {
|
|
var getWidth = widthLookup(table, get$8);
|
|
var getCellDelta = identity;
|
|
var singleColumnWidth = function (w, delta) {
|
|
var newNext = Math.max(minWidth(), w + delta);
|
|
return [newNext - w];
|
|
};
|
|
var adjustTableWidth = function (delta) {
|
|
var newWidth = getWidth() + delta;
|
|
setPixelWidth(table, newWidth);
|
|
};
|
|
var getWidths = function (warehouse, tableSize) {
|
|
return getPixelWidths(warehouse, table, tableSize);
|
|
};
|
|
return {
|
|
width: getWidth,
|
|
pixelWidth: getWidth,
|
|
getWidths: getWidths,
|
|
getCellDelta: getCellDelta,
|
|
singleColumnWidth: singleColumnWidth,
|
|
minCellWidth: minWidth,
|
|
setElementWidth: setPixelWidth,
|
|
adjustTableWidth: adjustTableWidth,
|
|
isRelative: false,
|
|
label: 'pixel'
|
|
};
|
|
};
|
|
var chooseSize = function (element, width) {
|
|
var percentMatch = percentageBasedSizeRegex().exec(width);
|
|
if (percentMatch !== null) {
|
|
return percentageSize(element);
|
|
} else {
|
|
return pixelSize(element);
|
|
}
|
|
};
|
|
var getTableSize = function (table) {
|
|
var width = getRawWidth$1(table);
|
|
return width.fold(function () {
|
|
return noneSize(table);
|
|
}, function (w) {
|
|
return chooseSize(table, w);
|
|
});
|
|
};
|
|
var TableSize = {
|
|
getTableSize: getTableSize,
|
|
pixelSize: pixelSize,
|
|
percentageSize: percentageSize,
|
|
noneSize: noneSize
|
|
};
|
|
|
|
var statsStruct = function (minRow, minCol, maxRow, maxCol, allCells, selectedCells) {
|
|
return {
|
|
minRow: minRow,
|
|
minCol: minCol,
|
|
maxRow: maxRow,
|
|
maxCol: maxCol,
|
|
allCells: allCells,
|
|
selectedCells: selectedCells
|
|
};
|
|
};
|
|
var findSelectedStats = function (house, isSelected) {
|
|
var totalColumns = house.grid.columns;
|
|
var totalRows = house.grid.rows;
|
|
var minRow = totalRows;
|
|
var minCol = totalColumns;
|
|
var maxRow = 0;
|
|
var maxCol = 0;
|
|
var allCells = [];
|
|
var selectedCells = [];
|
|
each$1(house.access, function (detail) {
|
|
allCells.push(detail);
|
|
if (isSelected(detail)) {
|
|
selectedCells.push(detail);
|
|
var startRow = detail.row;
|
|
var endRow = startRow + detail.rowspan - 1;
|
|
var startCol = detail.column;
|
|
var endCol = startCol + detail.colspan - 1;
|
|
if (startRow < minRow) {
|
|
minRow = startRow;
|
|
} else if (endRow > maxRow) {
|
|
maxRow = endRow;
|
|
}
|
|
if (startCol < minCol) {
|
|
minCol = startCol;
|
|
} else if (endCol > maxCol) {
|
|
maxCol = endCol;
|
|
}
|
|
}
|
|
});
|
|
return statsStruct(minRow, minCol, maxRow, maxCol, allCells, selectedCells);
|
|
};
|
|
var makeCell = function (list, seenSelected, rowIndex) {
|
|
var row = list[rowIndex].element;
|
|
var td = SugarElement.fromTag('td');
|
|
append$1(td, SugarElement.fromTag('br'));
|
|
var f = seenSelected ? append$1 : prepend;
|
|
f(row, td);
|
|
};
|
|
var fillInGaps = function (list, house, stats, isSelected) {
|
|
var totalColumns = house.grid.columns;
|
|
var totalRows = house.grid.rows;
|
|
for (var i = 0; i < totalRows; i++) {
|
|
var seenSelected = false;
|
|
for (var j = 0; j < totalColumns; j++) {
|
|
if (!(i < stats.minRow || i > stats.maxRow || j < stats.minCol || j > stats.maxCol)) {
|
|
var needCell = Warehouse.getAt(house, i, j).filter(isSelected).isNone();
|
|
if (needCell) {
|
|
makeCell(list, seenSelected, i);
|
|
} else {
|
|
seenSelected = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
var clean = function (replica, stats, house, widthDelta) {
|
|
each$1(house.columns, function (col) {
|
|
if (col.column < stats.minCol || col.column > stats.maxCol) {
|
|
remove$5(col.element);
|
|
}
|
|
});
|
|
var emptyRows = filter$2(firstLayer(replica, 'tr'), function (row) {
|
|
return row.dom.childElementCount === 0;
|
|
});
|
|
each$2(emptyRows, remove$5);
|
|
if (stats.minCol === stats.maxCol || stats.minRow === stats.maxRow) {
|
|
each$2(firstLayer(replica, 'th,td'), function (cell) {
|
|
remove$7(cell, 'rowspan');
|
|
remove$7(cell, 'colspan');
|
|
});
|
|
}
|
|
remove$7(replica, LOCKED_COL_ATTR);
|
|
remove$7(replica, 'data-snooker-col-series');
|
|
var tableSize = TableSize.getTableSize(replica);
|
|
tableSize.adjustTableWidth(widthDelta);
|
|
};
|
|
var getTableWidthDelta = function (table, warehouse, tableSize, stats) {
|
|
if (stats.minCol === 0 && warehouse.grid.columns === stats.maxCol + 1) {
|
|
return 0;
|
|
}
|
|
var colWidths = getPixelWidths(warehouse, table, tableSize);
|
|
var allColsWidth = foldl(colWidths, function (acc, width) {
|
|
return acc + width;
|
|
}, 0);
|
|
var selectedColsWidth = foldl(colWidths.slice(stats.minCol, stats.maxCol + 1), function (acc, width) {
|
|
return acc + width;
|
|
}, 0);
|
|
var newWidth = selectedColsWidth / allColsWidth * tableSize.pixelWidth();
|
|
var delta = newWidth - tableSize.pixelWidth();
|
|
return tableSize.getCellDelta(delta);
|
|
};
|
|
var extract$1 = function (table, selectedSelector) {
|
|
var isSelected = function (detail) {
|
|
return is$2(detail.element, selectedSelector);
|
|
};
|
|
var replica = deep(table);
|
|
var list = fromTable$1(replica);
|
|
var tableSize = TableSize.getTableSize(table);
|
|
var replicaHouse = Warehouse.generate(list);
|
|
var replicaStats = findSelectedStats(replicaHouse, isSelected);
|
|
var selector = 'th:not(' + selectedSelector + ')' + ',td:not(' + selectedSelector + ')';
|
|
var unselectedCells = filterFirstLayer(replica, 'th,td', function (cell) {
|
|
return is$2(cell, selector);
|
|
});
|
|
each$2(unselectedCells, remove$5);
|
|
fillInGaps(list, replicaHouse, replicaStats, isSelected);
|
|
var house = Warehouse.fromTable(table);
|
|
var widthDelta = getTableWidthDelta(table, house, tableSize, replicaStats);
|
|
clean(replica, replicaStats, replicaHouse, widthDelta);
|
|
return replica;
|
|
};
|
|
|
|
var nbsp = '\xA0';
|
|
|
|
var getEnd = function (element) {
|
|
return name(element) === 'img' ? 1 : getOption(element).fold(function () {
|
|
return children$3(element).length;
|
|
}, function (v) {
|
|
return v.length;
|
|
});
|
|
};
|
|
var isTextNodeWithCursorPosition = function (el) {
|
|
return getOption(el).filter(function (text) {
|
|
return text.trim().length !== 0 || text.indexOf(nbsp) > -1;
|
|
}).isSome();
|
|
};
|
|
var elementsWithCursorPosition = [
|
|
'img',
|
|
'br'
|
|
];
|
|
var isCursorPosition = function (elem) {
|
|
var hasCursorPosition = isTextNodeWithCursorPosition(elem);
|
|
return hasCursorPosition || contains$2(elementsWithCursorPosition, name(elem));
|
|
};
|
|
|
|
var first = function (element) {
|
|
return descendant$1(element, isCursorPosition);
|
|
};
|
|
var last$1 = function (element) {
|
|
return descendantRtl(element, isCursorPosition);
|
|
};
|
|
var descendantRtl = function (scope, predicate) {
|
|
var descend = function (element) {
|
|
var children = children$3(element);
|
|
for (var i = children.length - 1; i >= 0; i--) {
|
|
var child = children[i];
|
|
if (predicate(child)) {
|
|
return Optional.some(child);
|
|
}
|
|
var res = descend(child);
|
|
if (res.isSome()) {
|
|
return res;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
return descend(scope);
|
|
};
|
|
|
|
var transferableAttributes = {
|
|
scope: [
|
|
'row',
|
|
'col'
|
|
]
|
|
};
|
|
var createCell = function (doc) {
|
|
return function () {
|
|
var td = SugarElement.fromTag('td', doc.dom);
|
|
append$1(td, SugarElement.fromTag('br', doc.dom));
|
|
return td;
|
|
};
|
|
};
|
|
var createCol = function (doc) {
|
|
return function () {
|
|
return SugarElement.fromTag('col', doc.dom);
|
|
};
|
|
};
|
|
var createColgroup = function (doc) {
|
|
return function () {
|
|
return SugarElement.fromTag('colgroup', doc.dom);
|
|
};
|
|
};
|
|
var createRow$1 = function (doc) {
|
|
return function () {
|
|
return SugarElement.fromTag('tr', doc.dom);
|
|
};
|
|
};
|
|
var replace$1 = function (cell, tag, attrs) {
|
|
var replica = copy$1(cell, tag);
|
|
each$1(attrs, function (v, k) {
|
|
if (v === null) {
|
|
remove$7(replica, k);
|
|
} else {
|
|
set$2(replica, k, v);
|
|
}
|
|
});
|
|
return replica;
|
|
};
|
|
var pasteReplace = function (cell) {
|
|
return cell;
|
|
};
|
|
var cloneFormats = function (oldCell, newCell, formats) {
|
|
var first$1 = first(oldCell);
|
|
return first$1.map(function (firstText) {
|
|
var formatSelector = formats.join(',');
|
|
var parents = ancestors$3(firstText, formatSelector, function (element) {
|
|
return eq$1(element, oldCell);
|
|
});
|
|
return foldr(parents, function (last, parent) {
|
|
var clonedFormat = shallow(parent);
|
|
remove$7(clonedFormat, 'contenteditable');
|
|
append$1(last, clonedFormat);
|
|
return clonedFormat;
|
|
}, newCell);
|
|
}).getOr(newCell);
|
|
};
|
|
var cloneAppropriateAttributes = function (original, clone) {
|
|
each$1(transferableAttributes, function (validAttributes, attributeName) {
|
|
return getOpt(original, attributeName).filter(function (attribute) {
|
|
return contains$2(validAttributes, attribute);
|
|
}).each(function (attribute) {
|
|
return set$2(clone, attributeName, attribute);
|
|
});
|
|
});
|
|
};
|
|
var cellOperations = function (mutate, doc, formatsToClone) {
|
|
var cloneCss = function (prev, clone) {
|
|
copy$2(prev.element, clone);
|
|
remove$6(clone, 'height');
|
|
if (prev.colspan !== 1) {
|
|
remove$6(clone, 'width');
|
|
}
|
|
};
|
|
var newCell = function (prev) {
|
|
var td = SugarElement.fromTag(name(prev.element), doc.dom);
|
|
var formats = formatsToClone.getOr([
|
|
'strong',
|
|
'em',
|
|
'b',
|
|
'i',
|
|
'span',
|
|
'font',
|
|
'h1',
|
|
'h2',
|
|
'h3',
|
|
'h4',
|
|
'h5',
|
|
'h6',
|
|
'p',
|
|
'div'
|
|
]);
|
|
var lastNode = formats.length > 0 ? cloneFormats(prev.element, td, formats) : td;
|
|
append$1(lastNode, SugarElement.fromTag('br'));
|
|
cloneCss(prev, td);
|
|
cloneAppropriateAttributes(prev.element, td);
|
|
mutate(prev.element, td);
|
|
return td;
|
|
};
|
|
var newCol = function (prev) {
|
|
var col = SugarElement.fromTag(name(prev.element), doc.dom);
|
|
cloneCss(prev, col);
|
|
mutate(prev.element, col);
|
|
return col;
|
|
};
|
|
return {
|
|
col: newCol,
|
|
colgroup: createColgroup(doc),
|
|
row: createRow$1(doc),
|
|
cell: newCell,
|
|
replace: replace$1,
|
|
colGap: createCol(doc),
|
|
gap: createCell(doc)
|
|
};
|
|
};
|
|
var paste$1 = function (doc) {
|
|
return {
|
|
col: createCol(doc),
|
|
colgroup: createColgroup(doc),
|
|
row: createRow$1(doc),
|
|
cell: createCell(doc),
|
|
replace: pasteReplace,
|
|
colGap: createCol(doc),
|
|
gap: createCell(doc)
|
|
};
|
|
};
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
return children$3(SugarElement.fromDom(div));
|
|
};
|
|
var fromDom = function (nodes) {
|
|
return map$1(nodes, SugarElement.fromDom);
|
|
};
|
|
|
|
var getNodeName = function (elm) {
|
|
return elm.nodeName.toLowerCase();
|
|
};
|
|
var getBody = function (editor) {
|
|
return SugarElement.fromDom(editor.getBody());
|
|
};
|
|
var getPixelWidth = function (elm) {
|
|
return elm.getBoundingClientRect().width;
|
|
};
|
|
var getPixelHeight = function (elm) {
|
|
return elm.getBoundingClientRect().height;
|
|
};
|
|
var getIsRoot = function (editor) {
|
|
return function (element) {
|
|
return eq$1(element, getBody(editor));
|
|
};
|
|
};
|
|
var removePxSuffix = function (size) {
|
|
return size ? size.replace(/px$/, '') : '';
|
|
};
|
|
var addPxSuffix = function (size) {
|
|
return /^\d+(\.\d+)?$/.test(size) ? size + 'px' : size;
|
|
};
|
|
var removeDataStyle = function (table) {
|
|
remove$7(table, 'data-mce-style');
|
|
var removeStyleAttribute = function (element) {
|
|
return remove$7(element, 'data-mce-style');
|
|
};
|
|
each$2(cells$1(table), removeStyleAttribute);
|
|
each$2(columns$1(table), removeStyleAttribute);
|
|
each$2(rows$1(table), removeStyleAttribute);
|
|
};
|
|
var getRawWidth = function (editor, elm) {
|
|
var raw = editor.dom.getStyle(elm, 'width') || editor.dom.getAttrib(elm, 'width');
|
|
return Optional.from(raw).filter(isNotEmpty);
|
|
};
|
|
var isPercentage$1 = function (value) {
|
|
return /^(\d+(\.\d+)?)%$/.test(value);
|
|
};
|
|
var isPixel = function (value) {
|
|
return /^(\d+(\.\d+)?)px$/.test(value);
|
|
};
|
|
var getSelectionStart = function (editor) {
|
|
return SugarElement.fromDom(editor.selection.getStart());
|
|
};
|
|
var getSelectionEnd = function (editor) {
|
|
return SugarElement.fromDom(editor.selection.getEnd());
|
|
};
|
|
|
|
var selection = function (selections) {
|
|
return cata$2(selections.get(), constant([]), identity, pure);
|
|
};
|
|
var unmergable = function (selections) {
|
|
var hasSpan = function (elem, type) {
|
|
return getOpt(elem, type).exists(function (span) {
|
|
return parseInt(span, 10) > 1;
|
|
});
|
|
};
|
|
var hasRowOrColSpan = function (elem) {
|
|
return hasSpan(elem, 'rowspan') || hasSpan(elem, 'colspan');
|
|
};
|
|
var candidates = selection(selections);
|
|
return candidates.length > 0 && forall(candidates, hasRowOrColSpan) ? Optional.some(candidates) : Optional.none();
|
|
};
|
|
var mergable = function (table, selections, ephemera) {
|
|
return cata$2(selections.get(), Optional.none, function (cells) {
|
|
if (cells.length <= 1) {
|
|
return Optional.none();
|
|
} else {
|
|
return retrieveBox(table, ephemera.firstSelectedSelector, ephemera.lastSelectedSelector).map(function (bounds) {
|
|
return {
|
|
bounds: bounds,
|
|
cells: cells
|
|
};
|
|
});
|
|
}
|
|
}, Optional.none);
|
|
};
|
|
|
|
var strSelected = 'data-mce-selected';
|
|
var strSelectedSelector = 'td[' + strSelected + '],th[' + strSelected + ']';
|
|
var strAttributeSelector = '[' + strSelected + ']';
|
|
var strFirstSelected = 'data-mce-first-selected';
|
|
var strFirstSelectedSelector = 'td[' + strFirstSelected + '],th[' + strFirstSelected + ']';
|
|
var strLastSelected = 'data-mce-last-selected';
|
|
var strLastSelectedSelector = 'td[' + strLastSelected + '],th[' + strLastSelected + ']';
|
|
var attributeSelector = strAttributeSelector;
|
|
var ephemera = {
|
|
selected: strSelected,
|
|
selectedSelector: strSelectedSelector,
|
|
firstSelected: strFirstSelected,
|
|
firstSelectedSelector: strFirstSelectedSelector,
|
|
lastSelected: strLastSelected,
|
|
lastSelectedSelector: strLastSelectedSelector
|
|
};
|
|
|
|
var noMenu = function (cell) {
|
|
return {
|
|
element: cell,
|
|
mergable: Optional.none(),
|
|
unmergable: Optional.none(),
|
|
selection: [cell]
|
|
};
|
|
};
|
|
var forMenu = function (selections, table, cell) {
|
|
return {
|
|
element: cell,
|
|
mergable: mergable(table, selections, ephemera),
|
|
unmergable: unmergable(selections),
|
|
selection: selection(selections)
|
|
};
|
|
};
|
|
var paste = function (element, clipboard, generators) {
|
|
return {
|
|
element: element,
|
|
clipboard: clipboard,
|
|
generators: generators
|
|
};
|
|
};
|
|
var pasteRows = function (selections, cell, clipboard, generators) {
|
|
return {
|
|
selection: selection(selections),
|
|
clipboard: clipboard,
|
|
generators: generators
|
|
};
|
|
};
|
|
|
|
var getSelectionCellFallback = function (element) {
|
|
return table(element).bind(function (table) {
|
|
return retrieve(table, ephemera.firstSelectedSelector);
|
|
}).fold(constant(element), function (cells) {
|
|
return cells[0];
|
|
});
|
|
};
|
|
var getSelectionFromSelector = function (selector) {
|
|
return function (initCell, isRoot) {
|
|
var cellName = name(initCell);
|
|
var cell = cellName === 'col' || cellName === 'colgroup' ? getSelectionCellFallback(initCell) : initCell;
|
|
return closest$1(cell, selector, isRoot);
|
|
};
|
|
};
|
|
var getSelectionCellOrCaption = getSelectionFromSelector('th,td,caption');
|
|
var getSelectionCell = getSelectionFromSelector('th,td');
|
|
var getCellsFromSelection = function (selections) {
|
|
return selection(selections);
|
|
};
|
|
var getRowsFromSelection = function (selected, selector) {
|
|
var cellOpt = getSelectionCell(selected);
|
|
var rowsOpt = cellOpt.bind(function (cell) {
|
|
return table(cell);
|
|
}).map(function (table) {
|
|
return rows$1(table);
|
|
});
|
|
return lift2(cellOpt, rowsOpt, function (cell, rows) {
|
|
return filter$2(rows, function (row) {
|
|
return exists(fromDom(row.dom.cells), function (rowCell) {
|
|
return get$b(rowCell, selector) === '1' || eq$1(rowCell, cell);
|
|
});
|
|
});
|
|
}).getOr([]);
|
|
};
|
|
|
|
var extractSelected = function (cells) {
|
|
return table(cells[0]).map(function (table) {
|
|
var replica = extract$1(table, attributeSelector);
|
|
removeDataStyle(replica);
|
|
return [replica];
|
|
});
|
|
};
|
|
var serializeElements = function (editor, elements) {
|
|
return map$1(elements, function (elm) {
|
|
return editor.selection.serializer.serialize(elm.dom, {});
|
|
}).join('');
|
|
};
|
|
var getTextContent = function (elements) {
|
|
return map$1(elements, function (element) {
|
|
return element.dom.innerText;
|
|
}).join('');
|
|
};
|
|
var registerEvents = function (editor, selections, actions) {
|
|
editor.on('BeforeGetContent', function (e) {
|
|
var multiCellContext = function (cells) {
|
|
e.preventDefault();
|
|
extractSelected(cells).each(function (elements) {
|
|
e.content = e.format === 'text' ? getTextContent(elements) : serializeElements(editor, elements);
|
|
});
|
|
};
|
|
if (e.selection === true) {
|
|
cata$2(selections.get(), noop, multiCellContext, noop);
|
|
}
|
|
});
|
|
editor.on('BeforeSetContent', function (e) {
|
|
if (e.selection === true && e.paste === true) {
|
|
var selectedCells = getCellsFromSelection(selections);
|
|
head(selectedCells).each(function (cell) {
|
|
table(cell).each(function (table) {
|
|
var elements = filter$2(fromHtml(e.content), function (content) {
|
|
return name(content) !== 'meta';
|
|
});
|
|
var isTable = isTag('table');
|
|
if (elements.length === 1 && isTable(elements[0])) {
|
|
e.preventDefault();
|
|
var doc = SugarElement.fromDom(editor.getDoc());
|
|
var generators = paste$1(doc);
|
|
var targets = paste(cell, elements[0], generators);
|
|
actions.pasteCells(table, targets).each(function () {
|
|
editor.focus();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
var adt$7 = Adt.generate([
|
|
{ none: [] },
|
|
{ only: ['index'] },
|
|
{
|
|
left: [
|
|
'index',
|
|
'next'
|
|
]
|
|
},
|
|
{
|
|
middle: [
|
|
'prev',
|
|
'index',
|
|
'next'
|
|
]
|
|
},
|
|
{
|
|
right: [
|
|
'prev',
|
|
'index'
|
|
]
|
|
}
|
|
]);
|
|
var ColumnContext = __assign({}, adt$7);
|
|
|
|
var neighbours = function (input, index) {
|
|
if (input.length === 0) {
|
|
return ColumnContext.none();
|
|
}
|
|
if (input.length === 1) {
|
|
return ColumnContext.only(0);
|
|
}
|
|
if (index === 0) {
|
|
return ColumnContext.left(0, 1);
|
|
}
|
|
if (index === input.length - 1) {
|
|
return ColumnContext.right(index - 1, index);
|
|
}
|
|
if (index > 0 && index < input.length - 1) {
|
|
return ColumnContext.middle(index - 1, index, index + 1);
|
|
}
|
|
return ColumnContext.none();
|
|
};
|
|
var determine = function (input, column, step, tableSize, resize) {
|
|
var result = input.slice(0);
|
|
var context = neighbours(input, column);
|
|
var onNone = constant(map$1(result, constant(0)));
|
|
var onOnly = function (index) {
|
|
return tableSize.singleColumnWidth(result[index], step);
|
|
};
|
|
var onLeft = function (index, next) {
|
|
return resize.calcLeftEdgeDeltas(result, index, next, step, tableSize.minCellWidth(), tableSize.isRelative);
|
|
};
|
|
var onMiddle = function (prev, index, next) {
|
|
return resize.calcMiddleDeltas(result, prev, index, next, step, tableSize.minCellWidth(), tableSize.isRelative);
|
|
};
|
|
var onRight = function (prev, index) {
|
|
return resize.calcRightEdgeDeltas(result, prev, index, step, tableSize.minCellWidth(), tableSize.isRelative);
|
|
};
|
|
return context.fold(onNone, onOnly, onLeft, onMiddle, onRight);
|
|
};
|
|
|
|
var total = function (start, end, measures) {
|
|
var r = 0;
|
|
for (var i = start; i < end; i++) {
|
|
r += measures[i] !== undefined ? measures[i] : 0;
|
|
}
|
|
return r;
|
|
};
|
|
var recalculateWidthForCells = function (warehouse, widths) {
|
|
var all = Warehouse.justCells(warehouse);
|
|
return map$1(all, function (cell) {
|
|
var width = total(cell.column, cell.column + cell.colspan, widths);
|
|
return {
|
|
element: cell.element,
|
|
width: width,
|
|
colspan: cell.colspan
|
|
};
|
|
});
|
|
};
|
|
var recalculateWidthForColumns = function (warehouse, widths) {
|
|
var groups = Warehouse.justColumns(warehouse);
|
|
return map$1(groups, function (column, index) {
|
|
return {
|
|
element: column.element,
|
|
width: widths[index],
|
|
colspan: column.colspan
|
|
};
|
|
});
|
|
};
|
|
var recalculateHeightForCells = function (warehouse, heights) {
|
|
var all = Warehouse.justCells(warehouse);
|
|
return map$1(all, function (cell) {
|
|
var height = total(cell.row, cell.row + cell.rowspan, heights);
|
|
return {
|
|
element: cell.element,
|
|
height: height,
|
|
rowspan: cell.rowspan
|
|
};
|
|
});
|
|
};
|
|
var matchRowHeight = function (warehouse, heights) {
|
|
return map$1(warehouse.all, function (row, i) {
|
|
return {
|
|
element: row.element,
|
|
height: heights[i]
|
|
};
|
|
});
|
|
};
|
|
|
|
var sumUp = function (newSize) {
|
|
return foldr(newSize, function (b, a) {
|
|
return b + a;
|
|
}, 0);
|
|
};
|
|
var recalculate = function (warehouse, widths) {
|
|
if (Warehouse.hasColumns(warehouse)) {
|
|
return recalculateWidthForColumns(warehouse, widths);
|
|
} else {
|
|
return recalculateWidthForCells(warehouse, widths);
|
|
}
|
|
};
|
|
var recalculateAndApply = function (warehouse, widths, tableSize) {
|
|
var newSizes = recalculate(warehouse, widths);
|
|
each$2(newSizes, function (cell) {
|
|
tableSize.setElementWidth(cell.element, cell.width);
|
|
});
|
|
};
|
|
var adjustWidth = function (table, delta, index, resizing, tableSize) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var step = tableSize.getCellDelta(delta);
|
|
var widths = tableSize.getWidths(warehouse, tableSize);
|
|
var isLastColumn = index === warehouse.grid.columns - 1;
|
|
var clampedStep = resizing.clampTableDelta(widths, index, step, tableSize.minCellWidth(), isLastColumn);
|
|
var deltas = determine(widths, index, clampedStep, tableSize, resizing);
|
|
var newWidths = map$1(deltas, function (dx, i) {
|
|
return dx + widths[i];
|
|
});
|
|
recalculateAndApply(warehouse, newWidths, tableSize);
|
|
resizing.resizeTable(tableSize.adjustTableWidth, clampedStep, isLastColumn);
|
|
};
|
|
var adjustHeight = function (table, delta, index, direction) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var heights = getPixelHeights(warehouse, table, direction);
|
|
var newHeights = map$1(heights, function (dy, i) {
|
|
return index === i ? Math.max(delta + dy, minHeight()) : dy;
|
|
});
|
|
var newCellSizes = recalculateHeightForCells(warehouse, newHeights);
|
|
var newRowSizes = matchRowHeight(warehouse, newHeights);
|
|
each$2(newRowSizes, function (row) {
|
|
setHeight(row.element, row.height);
|
|
});
|
|
each$2(newCellSizes, function (cell) {
|
|
setHeight(cell.element, cell.height);
|
|
});
|
|
var total = sumUp(newHeights);
|
|
setHeight(table, total);
|
|
};
|
|
var adjustAndRedistributeWidths$1 = function (_table, list, details, tableSize, resizeBehaviour) {
|
|
var warehouse = Warehouse.generate(list);
|
|
var sizes = tableSize.getWidths(warehouse, tableSize);
|
|
var tablePixelWidth = tableSize.pixelWidth();
|
|
var _a = resizeBehaviour.calcRedestributedWidths(sizes, tablePixelWidth, details.pixelDelta, tableSize.isRelative), newSizes = _a.newSizes, delta = _a.delta;
|
|
recalculateAndApply(warehouse, newSizes, tableSize);
|
|
tableSize.adjustTableWidth(delta);
|
|
};
|
|
var adjustWidthTo = function (_table, list, _info, tableSize) {
|
|
var warehouse = Warehouse.generate(list);
|
|
var widths = tableSize.getWidths(warehouse, tableSize);
|
|
recalculateAndApply(warehouse, widths, tableSize);
|
|
};
|
|
|
|
var zero = function (array) {
|
|
return map$1(array, constant(0));
|
|
};
|
|
var surround = function (sizes, startIndex, endIndex, results, f) {
|
|
return f(sizes.slice(0, startIndex)).concat(results).concat(f(sizes.slice(endIndex)));
|
|
};
|
|
var clampDeltaHelper = function (predicate) {
|
|
return function (sizes, index, delta, minCellSize) {
|
|
if (!predicate(delta)) {
|
|
return delta;
|
|
} else {
|
|
var newSize = Math.max(minCellSize, sizes[index] - Math.abs(delta));
|
|
var diff = Math.abs(newSize - sizes[index]);
|
|
return delta >= 0 ? diff : -diff;
|
|
}
|
|
};
|
|
};
|
|
var clampNegativeDelta = clampDeltaHelper(function (delta) {
|
|
return delta < 0;
|
|
});
|
|
var clampDelta = clampDeltaHelper(always);
|
|
var resizeTable = function () {
|
|
var calcFixedDeltas = function (sizes, index, next, delta, minCellSize) {
|
|
var clampedDelta = clampNegativeDelta(sizes, index, delta, minCellSize);
|
|
return surround(sizes, index, next + 1, [
|
|
clampedDelta,
|
|
0
|
|
], zero);
|
|
};
|
|
var calcRelativeDeltas = function (sizes, index, delta, minCellSize) {
|
|
var ratio = (100 + delta) / 100;
|
|
var newThis = Math.max(minCellSize, (sizes[index] + delta) / ratio);
|
|
return map$1(sizes, function (size, idx) {
|
|
var newSize = idx === index ? newThis : size / ratio;
|
|
return newSize - size;
|
|
});
|
|
};
|
|
var calcLeftEdgeDeltas = function (sizes, index, next, delta, minCellSize, isRelative) {
|
|
if (isRelative) {
|
|
return calcRelativeDeltas(sizes, index, delta, minCellSize);
|
|
} else {
|
|
return calcFixedDeltas(sizes, index, next, delta, minCellSize);
|
|
}
|
|
};
|
|
var calcMiddleDeltas = function (sizes, _prev, index, next, delta, minCellSize, isRelative) {
|
|
return calcLeftEdgeDeltas(sizes, index, next, delta, minCellSize, isRelative);
|
|
};
|
|
var resizeTable = function (resizer, delta) {
|
|
return resizer(delta);
|
|
};
|
|
var calcRightEdgeDeltas = function (sizes, _prev, index, delta, minCellSize, isRelative) {
|
|
if (isRelative) {
|
|
return calcRelativeDeltas(sizes, index, delta, minCellSize);
|
|
} else {
|
|
var clampedDelta = clampNegativeDelta(sizes, index, delta, minCellSize);
|
|
return zero(sizes.slice(0, index)).concat([clampedDelta]);
|
|
}
|
|
};
|
|
var calcRedestributedWidths = function (sizes, totalWidth, pixelDelta, isRelative) {
|
|
if (isRelative) {
|
|
var tableWidth = totalWidth + pixelDelta;
|
|
var ratio_1 = tableWidth / totalWidth;
|
|
var newSizes = map$1(sizes, function (size) {
|
|
return size / ratio_1;
|
|
});
|
|
return {
|
|
delta: ratio_1 * 100 - 100,
|
|
newSizes: newSizes
|
|
};
|
|
} else {
|
|
return {
|
|
delta: pixelDelta,
|
|
newSizes: sizes
|
|
};
|
|
}
|
|
};
|
|
return {
|
|
resizeTable: resizeTable,
|
|
clampTableDelta: clampNegativeDelta,
|
|
calcLeftEdgeDeltas: calcLeftEdgeDeltas,
|
|
calcMiddleDeltas: calcMiddleDeltas,
|
|
calcRightEdgeDeltas: calcRightEdgeDeltas,
|
|
calcRedestributedWidths: calcRedestributedWidths
|
|
};
|
|
};
|
|
var preserveTable = function () {
|
|
var calcLeftEdgeDeltas = function (sizes, index, next, delta, minCellSize) {
|
|
var idx = delta >= 0 ? next : index;
|
|
var clampedDelta = clampDelta(sizes, idx, delta, minCellSize);
|
|
return surround(sizes, index, next + 1, [
|
|
clampedDelta,
|
|
-clampedDelta
|
|
], zero);
|
|
};
|
|
var calcMiddleDeltas = function (sizes, _prev, index, next, delta, minCellSize) {
|
|
return calcLeftEdgeDeltas(sizes, index, next, delta, minCellSize);
|
|
};
|
|
var resizeTable = function (resizer, delta, isLastColumn) {
|
|
if (isLastColumn) {
|
|
resizer(delta);
|
|
}
|
|
};
|
|
var calcRightEdgeDeltas = function (sizes, _prev, _index, delta, _minCellSize, isRelative) {
|
|
if (isRelative) {
|
|
return zero(sizes);
|
|
} else {
|
|
var diff = delta / sizes.length;
|
|
return map$1(sizes, constant(diff));
|
|
}
|
|
};
|
|
var clampTableDelta = function (sizes, index, delta, minCellSize, isLastColumn) {
|
|
if (isLastColumn) {
|
|
if (delta >= 0) {
|
|
return delta;
|
|
} else {
|
|
var maxDelta = foldl(sizes, function (a, b) {
|
|
return a + b - minCellSize;
|
|
}, 0);
|
|
return Math.max(-maxDelta, delta);
|
|
}
|
|
} else {
|
|
return clampNegativeDelta(sizes, index, delta, minCellSize);
|
|
}
|
|
};
|
|
var calcRedestributedWidths = function (sizes, _totalWidth, _pixelDelta, _isRelative) {
|
|
return {
|
|
delta: 0,
|
|
newSizes: sizes
|
|
};
|
|
};
|
|
return {
|
|
resizeTable: resizeTable,
|
|
clampTableDelta: clampTableDelta,
|
|
calcLeftEdgeDeltas: calcLeftEdgeDeltas,
|
|
calcMiddleDeltas: calcMiddleDeltas,
|
|
calcRightEdgeDeltas: calcRightEdgeDeltas,
|
|
calcRedestributedWidths: calcRedestributedWidths
|
|
};
|
|
};
|
|
|
|
var only = function (element, isResizable) {
|
|
var parent = Optional.from(element.dom.documentElement).map(SugarElement.fromDom).getOr(element);
|
|
return {
|
|
parent: constant(parent),
|
|
view: constant(element),
|
|
origin: constant(SugarPosition(0, 0)),
|
|
isResizable: isResizable
|
|
};
|
|
};
|
|
var detached = function (editable, chrome, isResizable) {
|
|
var origin = function () {
|
|
return absolute(chrome);
|
|
};
|
|
return {
|
|
parent: constant(chrome),
|
|
view: constant(editable),
|
|
origin: origin,
|
|
isResizable: isResizable
|
|
};
|
|
};
|
|
var body = function (editable, chrome, isResizable) {
|
|
return {
|
|
parent: constant(chrome),
|
|
view: constant(editable),
|
|
origin: constant(SugarPosition(0, 0)),
|
|
isResizable: isResizable
|
|
};
|
|
};
|
|
var ResizeWire = {
|
|
only: only,
|
|
detached: detached,
|
|
body: body
|
|
};
|
|
|
|
var adt$6 = Adt.generate([
|
|
{ invalid: ['raw'] },
|
|
{ pixels: ['value'] },
|
|
{ percent: ['value'] }
|
|
]);
|
|
var validateFor = function (suffix, type, value) {
|
|
var rawAmount = value.substring(0, value.length - suffix.length);
|
|
var amount = parseFloat(rawAmount);
|
|
return rawAmount === amount.toString() ? type(amount) : adt$6.invalid(value);
|
|
};
|
|
var from = function (value) {
|
|
if (endsWith(value, '%')) {
|
|
return validateFor('%', adt$6.percent, value);
|
|
}
|
|
if (endsWith(value, 'px')) {
|
|
return validateFor('px', adt$6.pixels, value);
|
|
}
|
|
return adt$6.invalid(value);
|
|
};
|
|
var Size = __assign(__assign({}, adt$6), { from: from });
|
|
|
|
var redistributeToPercent = function (widths, totalWidth) {
|
|
return map$1(widths, function (w) {
|
|
var colType = Size.from(w);
|
|
return colType.fold(function () {
|
|
return w;
|
|
}, function (px) {
|
|
var ratio = px / totalWidth * 100;
|
|
return ratio + '%';
|
|
}, function (pc) {
|
|
return pc + '%';
|
|
});
|
|
});
|
|
};
|
|
var redistributeToPx = function (widths, totalWidth, newTotalWidth) {
|
|
var scale = newTotalWidth / totalWidth;
|
|
return map$1(widths, function (w) {
|
|
var colType = Size.from(w);
|
|
return colType.fold(function () {
|
|
return w;
|
|
}, function (px) {
|
|
return px * scale + 'px';
|
|
}, function (pc) {
|
|
return pc / 100 * newTotalWidth + 'px';
|
|
});
|
|
});
|
|
};
|
|
var redistributeEmpty = function (newWidthType, columns) {
|
|
var f = newWidthType.fold(function () {
|
|
return constant('');
|
|
}, function (pixels) {
|
|
var num = pixels / columns;
|
|
return constant(num + 'px');
|
|
}, function () {
|
|
var num = 100 / columns;
|
|
return constant(num + '%');
|
|
});
|
|
return range$1(columns, f);
|
|
};
|
|
var redistributeValues = function (newWidthType, widths, totalWidth) {
|
|
return newWidthType.fold(function () {
|
|
return widths;
|
|
}, function (px) {
|
|
return redistributeToPx(widths, totalWidth, px);
|
|
}, function (_pc) {
|
|
return redistributeToPercent(widths, totalWidth);
|
|
});
|
|
};
|
|
var redistribute$1 = function (widths, totalWidth, newWidth) {
|
|
var newType = Size.from(newWidth);
|
|
var floats = forall(widths, function (s) {
|
|
return s === '0px';
|
|
}) ? redistributeEmpty(newType, widths.length) : redistributeValues(newType, widths, totalWidth);
|
|
return normalize(floats);
|
|
};
|
|
var sum = function (values, fallback) {
|
|
if (values.length === 0) {
|
|
return fallback;
|
|
}
|
|
return foldr(values, function (rest, v) {
|
|
return Size.from(v).fold(constant(0), identity, identity) + rest;
|
|
}, 0);
|
|
};
|
|
var roundDown = function (num, unit) {
|
|
var floored = Math.floor(num);
|
|
return {
|
|
value: floored + unit,
|
|
remainder: num - floored
|
|
};
|
|
};
|
|
var add$3 = function (value, amount) {
|
|
return Size.from(value).fold(constant(value), function (px) {
|
|
return px + amount + 'px';
|
|
}, function (pc) {
|
|
return pc + amount + '%';
|
|
});
|
|
};
|
|
var normalize = function (values) {
|
|
if (values.length === 0) {
|
|
return values;
|
|
}
|
|
var scan = foldr(values, function (rest, value) {
|
|
var info = Size.from(value).fold(function () {
|
|
return {
|
|
value: value,
|
|
remainder: 0
|
|
};
|
|
}, function (num) {
|
|
return roundDown(num, 'px');
|
|
}, function (num) {
|
|
return {
|
|
value: num + '%',
|
|
remainder: 0
|
|
};
|
|
});
|
|
return {
|
|
output: [info.value].concat(rest.output),
|
|
remainder: rest.remainder + info.remainder
|
|
};
|
|
}, {
|
|
output: [],
|
|
remainder: 0
|
|
});
|
|
var r = scan.output;
|
|
return r.slice(0, r.length - 1).concat([add$3(r[r.length - 1], Math.round(scan.remainder))]);
|
|
};
|
|
var validate = Size.from;
|
|
|
|
var redistributeToW = function (newWidths, cells, unit) {
|
|
each$2(cells, function (cell) {
|
|
var widths = newWidths.slice(cell.column, cell.colspan + cell.column);
|
|
var w = sum(widths, minWidth());
|
|
set$1(cell.element, 'width', w + unit);
|
|
});
|
|
};
|
|
var redistributeToColumns = function (newWidths, columns, unit) {
|
|
each$2(columns, function (column, index) {
|
|
var width = sum([newWidths[index]], minWidth());
|
|
set$1(column.element, 'width', width + unit);
|
|
});
|
|
};
|
|
var redistributeToH = function (newHeights, rows, cells, unit) {
|
|
each$2(cells, function (cell) {
|
|
var heights = newHeights.slice(cell.row, cell.rowspan + cell.row);
|
|
var h = sum(heights, minHeight());
|
|
set$1(cell.element, 'height', h + unit);
|
|
});
|
|
each$2(rows, function (row, i) {
|
|
set$1(row.element, 'height', newHeights[i]);
|
|
});
|
|
};
|
|
var getUnit = function (newSize) {
|
|
return validate(newSize).fold(constant('px'), constant('px'), constant('%'));
|
|
};
|
|
var redistribute = function (table, optWidth, optHeight) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var rows = warehouse.all;
|
|
var cells = Warehouse.justCells(warehouse);
|
|
var columns = Warehouse.justColumns(warehouse);
|
|
optWidth.each(function (newWidth) {
|
|
var widthUnit = getUnit(newWidth);
|
|
var totalWidth = get$8(table);
|
|
var oldWidths = getRawWidths(warehouse, table);
|
|
var nuWidths = redistribute$1(oldWidths, totalWidth, newWidth);
|
|
if (Warehouse.hasColumns(warehouse)) {
|
|
redistributeToColumns(nuWidths, columns, widthUnit);
|
|
} else {
|
|
redistributeToW(nuWidths, cells, widthUnit);
|
|
}
|
|
set$1(table, 'width', newWidth);
|
|
});
|
|
optHeight.each(function (newHeight) {
|
|
var hUnit = getUnit(newHeight);
|
|
var totalHeight = get$7(table);
|
|
var oldHeights = getRawHeights(warehouse, table, height);
|
|
var nuHeights = redistribute$1(oldHeights, totalHeight, newHeight);
|
|
redistributeToH(nuHeights, rows, cells, hUnit);
|
|
set$1(table, 'height', newHeight);
|
|
});
|
|
};
|
|
var isPercentSizing = isPercentSizing$1;
|
|
var isPixelSizing = isPixelSizing$1;
|
|
var isNoneSizing = isNoneSizing$1;
|
|
|
|
var getGridSize = function (table) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
return warehouse.grid;
|
|
};
|
|
|
|
var Event = function (fields) {
|
|
var handlers = [];
|
|
var bind = function (handler) {
|
|
if (handler === undefined) {
|
|
throw new Error('Event bind error: undefined handler');
|
|
}
|
|
handlers.push(handler);
|
|
};
|
|
var unbind = function (handler) {
|
|
handlers = filter$2(handlers, function (h) {
|
|
return h !== handler;
|
|
});
|
|
};
|
|
var trigger = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var event = {};
|
|
each$2(fields, function (name, i) {
|
|
event[name] = args[i];
|
|
});
|
|
each$2(handlers, function (handler) {
|
|
handler(event);
|
|
});
|
|
};
|
|
return {
|
|
bind: bind,
|
|
unbind: unbind,
|
|
trigger: trigger
|
|
};
|
|
};
|
|
|
|
var create$4 = function (typeDefs) {
|
|
var registry = map(typeDefs, function (event) {
|
|
return {
|
|
bind: event.bind,
|
|
unbind: event.unbind
|
|
};
|
|
});
|
|
var trigger = map(typeDefs, function (event) {
|
|
return event.trigger;
|
|
});
|
|
return {
|
|
registry: registry,
|
|
trigger: trigger
|
|
};
|
|
};
|
|
|
|
var last = function (fn, rate) {
|
|
var timer = null;
|
|
var cancel = function () {
|
|
if (!isNull(timer)) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
};
|
|
var throttle = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
cancel();
|
|
timer = setTimeout(function () {
|
|
timer = null;
|
|
fn.apply(null, args);
|
|
}, rate);
|
|
};
|
|
return {
|
|
cancel: cancel,
|
|
throttle: throttle
|
|
};
|
|
};
|
|
|
|
var sort = function (arr) {
|
|
return arr.slice(0).sort();
|
|
};
|
|
var reqMessage = function (required, keys) {
|
|
throw new Error('All required keys (' + sort(required).join(', ') + ') were not specified. Specified keys were: ' + sort(keys).join(', ') + '.');
|
|
};
|
|
var unsuppMessage = function (unsupported) {
|
|
throw new Error('Unsupported keys for object: ' + sort(unsupported).join(', '));
|
|
};
|
|
var validateStrArr = function (label, array) {
|
|
if (!isArray(array)) {
|
|
throw new Error('The ' + label + ' fields must be an array. Was: ' + array + '.');
|
|
}
|
|
each$2(array, function (a) {
|
|
if (!isString(a)) {
|
|
throw new Error('The value ' + a + ' in the ' + label + ' fields was not a string.');
|
|
}
|
|
});
|
|
};
|
|
var invalidTypeMessage = function (incorrect, type) {
|
|
throw new Error('All values need to be of type: ' + type + '. Keys (' + sort(incorrect).join(', ') + ') were not.');
|
|
};
|
|
var checkDupes = function (everything) {
|
|
var sorted = sort(everything);
|
|
var dupe = find$1(sorted, function (s, i) {
|
|
return i < sorted.length - 1 && s === sorted[i + 1];
|
|
});
|
|
dupe.each(function (d) {
|
|
throw new Error('The field: ' + d + ' occurs more than once in the combined fields: [' + sorted.join(', ') + '].');
|
|
});
|
|
};
|
|
|
|
var base = function (handleUnsupported, required) {
|
|
return baseWith(handleUnsupported, required, {
|
|
validate: isFunction,
|
|
label: 'function'
|
|
});
|
|
};
|
|
var baseWith = function (handleUnsupported, required, pred) {
|
|
if (required.length === 0) {
|
|
throw new Error('You must specify at least one required field.');
|
|
}
|
|
validateStrArr('required', required);
|
|
checkDupes(required);
|
|
return function (obj) {
|
|
var keys$1 = keys(obj);
|
|
var allReqd = forall(required, function (req) {
|
|
return contains$2(keys$1, req);
|
|
});
|
|
if (!allReqd) {
|
|
reqMessage(required, keys$1);
|
|
}
|
|
handleUnsupported(required, keys$1);
|
|
var invalidKeys = filter$2(required, function (key) {
|
|
return !pred.validate(obj[key], key);
|
|
});
|
|
if (invalidKeys.length > 0) {
|
|
invalidTypeMessage(invalidKeys, pred.label);
|
|
}
|
|
return obj;
|
|
};
|
|
};
|
|
var handleExact = function (required, keys) {
|
|
var unsupported = filter$2(keys, function (key) {
|
|
return !contains$2(required, key);
|
|
});
|
|
if (unsupported.length > 0) {
|
|
unsuppMessage(unsupported);
|
|
}
|
|
};
|
|
var exactly = function (required) {
|
|
return base(handleExact, required);
|
|
};
|
|
|
|
var DragMode = exactly([
|
|
'compare',
|
|
'extract',
|
|
'mutate',
|
|
'sink'
|
|
]);
|
|
var DragSink = exactly([
|
|
'element',
|
|
'start',
|
|
'stop',
|
|
'destroy'
|
|
]);
|
|
var DragApi = exactly([
|
|
'forceDrop',
|
|
'drop',
|
|
'move',
|
|
'delayDrop'
|
|
]);
|
|
|
|
var InDrag = function () {
|
|
var previous = Optional.none();
|
|
var reset = function () {
|
|
previous = Optional.none();
|
|
};
|
|
var update = function (mode, nu) {
|
|
var result = previous.map(function (old) {
|
|
return mode.compare(old, nu);
|
|
});
|
|
previous = Optional.some(nu);
|
|
return result;
|
|
};
|
|
var onEvent = function (event, mode) {
|
|
var dataOption = mode.extract(event);
|
|
dataOption.each(function (data) {
|
|
var offset = update(mode, data);
|
|
offset.each(function (d) {
|
|
events.trigger.move(d);
|
|
});
|
|
});
|
|
};
|
|
var events = create$4({ move: Event(['info']) });
|
|
return {
|
|
onEvent: onEvent,
|
|
reset: reset,
|
|
events: events.registry
|
|
};
|
|
};
|
|
|
|
var NoDrag = function () {
|
|
var events = create$4({ move: Event(['info']) });
|
|
return {
|
|
onEvent: noop,
|
|
reset: noop,
|
|
events: events.registry
|
|
};
|
|
};
|
|
|
|
var Movement = function () {
|
|
var noDragState = NoDrag();
|
|
var inDragState = InDrag();
|
|
var dragState = noDragState;
|
|
var on = function () {
|
|
dragState.reset();
|
|
dragState = inDragState;
|
|
};
|
|
var off = function () {
|
|
dragState.reset();
|
|
dragState = noDragState;
|
|
};
|
|
var onEvent = function (event, mode) {
|
|
dragState.onEvent(event, mode);
|
|
};
|
|
var isOn = function () {
|
|
return dragState === inDragState;
|
|
};
|
|
return {
|
|
on: on,
|
|
off: off,
|
|
isOn: isOn,
|
|
onEvent: onEvent,
|
|
events: inDragState.events
|
|
};
|
|
};
|
|
|
|
var setup = function (mutation, mode, settings) {
|
|
var active = false;
|
|
var events = create$4({
|
|
start: Event([]),
|
|
stop: Event([])
|
|
});
|
|
var movement = Movement();
|
|
var drop = function () {
|
|
sink.stop();
|
|
if (movement.isOn()) {
|
|
movement.off();
|
|
events.trigger.stop();
|
|
}
|
|
};
|
|
var throttledDrop = last(drop, 200);
|
|
var go = function (parent) {
|
|
sink.start(parent);
|
|
movement.on();
|
|
events.trigger.start();
|
|
};
|
|
var mousemove = function (event) {
|
|
throttledDrop.cancel();
|
|
movement.onEvent(event, mode);
|
|
};
|
|
movement.events.move.bind(function (event) {
|
|
mode.mutate(mutation, event.info);
|
|
});
|
|
var on = function () {
|
|
active = true;
|
|
};
|
|
var off = function () {
|
|
active = false;
|
|
};
|
|
var runIfActive = function (f) {
|
|
return function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (active) {
|
|
f.apply(null, args);
|
|
}
|
|
};
|
|
};
|
|
var sink = mode.sink(DragApi({
|
|
forceDrop: drop,
|
|
drop: runIfActive(drop),
|
|
move: runIfActive(mousemove),
|
|
delayDrop: runIfActive(throttledDrop.throttle)
|
|
}), settings);
|
|
var destroy = function () {
|
|
sink.destroy();
|
|
};
|
|
return {
|
|
element: sink.element,
|
|
go: go,
|
|
on: on,
|
|
off: off,
|
|
destroy: destroy,
|
|
events: events.registry
|
|
};
|
|
};
|
|
|
|
var mkEvent = function (target, x, y, stop, prevent, kill, raw) {
|
|
return {
|
|
target: target,
|
|
x: x,
|
|
y: y,
|
|
stop: stop,
|
|
prevent: prevent,
|
|
kill: kill,
|
|
raw: raw
|
|
};
|
|
};
|
|
var fromRawEvent$1 = function (rawEvent) {
|
|
var target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target));
|
|
var stop = function () {
|
|
return rawEvent.stopPropagation();
|
|
};
|
|
var prevent = function () {
|
|
return rawEvent.preventDefault();
|
|
};
|
|
var kill = compose(prevent, stop);
|
|
return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent);
|
|
};
|
|
var handle$2 = function (filter, handler) {
|
|
return function (rawEvent) {
|
|
if (filter(rawEvent)) {
|
|
handler(fromRawEvent$1(rawEvent));
|
|
}
|
|
};
|
|
};
|
|
var binder = function (element, event, filter, handler, useCapture) {
|
|
var wrapped = handle$2(filter, handler);
|
|
element.dom.addEventListener(event, wrapped, useCapture);
|
|
return { unbind: curry(unbind, element, event, wrapped, useCapture) };
|
|
};
|
|
var bind$1 = function (element, event, filter, handler) {
|
|
return binder(element, event, filter, handler, false);
|
|
};
|
|
var unbind = function (element, event, handler, useCapture) {
|
|
element.dom.removeEventListener(event, handler, useCapture);
|
|
};
|
|
|
|
var filter = always;
|
|
var bind = function (element, event, handler) {
|
|
return bind$1(element, event, filter, handler);
|
|
};
|
|
var fromRawEvent = fromRawEvent$1;
|
|
|
|
var read = function (element, attr) {
|
|
var value = get$b(element, attr);
|
|
return value === undefined || value === '' ? [] : value.split(' ');
|
|
};
|
|
var add$2 = function (element, attr, id) {
|
|
var old = read(element, attr);
|
|
var nu = old.concat([id]);
|
|
set$2(element, attr, nu.join(' '));
|
|
return true;
|
|
};
|
|
var remove$4 = function (element, attr, id) {
|
|
var nu = filter$2(read(element, attr), function (v) {
|
|
return v !== id;
|
|
});
|
|
if (nu.length > 0) {
|
|
set$2(element, attr, nu.join(' '));
|
|
} else {
|
|
remove$7(element, attr);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
var supports = function (element) {
|
|
return element.dom.classList !== undefined;
|
|
};
|
|
var get$5 = function (element) {
|
|
return read(element, 'class');
|
|
};
|
|
var add$1 = function (element, clazz) {
|
|
return add$2(element, 'class', clazz);
|
|
};
|
|
var remove$3 = function (element, clazz) {
|
|
return remove$4(element, 'class', clazz);
|
|
};
|
|
|
|
var add = function (element, clazz) {
|
|
if (supports(element)) {
|
|
element.dom.classList.add(clazz);
|
|
} else {
|
|
add$1(element, clazz);
|
|
}
|
|
};
|
|
var cleanClass = function (element) {
|
|
var classList = supports(element) ? element.dom.classList : get$5(element);
|
|
if (classList.length === 0) {
|
|
remove$7(element, 'class');
|
|
}
|
|
};
|
|
var remove$2 = function (element, clazz) {
|
|
if (supports(element)) {
|
|
var classList = element.dom.classList;
|
|
classList.remove(clazz);
|
|
} else {
|
|
remove$3(element, clazz);
|
|
}
|
|
cleanClass(element);
|
|
};
|
|
var has = function (element, clazz) {
|
|
return supports(element) && element.dom.classList.contains(clazz);
|
|
};
|
|
|
|
var css = function (namespace) {
|
|
var dashNamespace = namespace.replace(/\./g, '-');
|
|
var resolve = function (str) {
|
|
return dashNamespace + '-' + str;
|
|
};
|
|
return { resolve: resolve };
|
|
};
|
|
|
|
var styles$1 = css('ephox-dragster');
|
|
var resolve$1 = styles$1.resolve;
|
|
|
|
var Blocker = function (options) {
|
|
var settings = __assign({ layerClass: resolve$1('blocker') }, options);
|
|
var div = SugarElement.fromTag('div');
|
|
set$2(div, 'role', 'presentation');
|
|
setAll(div, {
|
|
position: 'fixed',
|
|
left: '0px',
|
|
top: '0px',
|
|
width: '100%',
|
|
height: '100%'
|
|
});
|
|
add(div, resolve$1('blocker'));
|
|
add(div, settings.layerClass);
|
|
var element = constant(div);
|
|
var destroy = function () {
|
|
remove$5(div);
|
|
};
|
|
return {
|
|
element: element,
|
|
destroy: destroy
|
|
};
|
|
};
|
|
|
|
var compare = function (old, nu) {
|
|
return SugarPosition(nu.left - old.left, nu.top - old.top);
|
|
};
|
|
var extract = function (event) {
|
|
return Optional.some(SugarPosition(event.x, event.y));
|
|
};
|
|
var mutate = function (mutation, info) {
|
|
mutation.mutate(info.left, info.top);
|
|
};
|
|
var sink = function (dragApi, settings) {
|
|
var blocker = Blocker(settings);
|
|
var mdown = bind(blocker.element(), 'mousedown', dragApi.forceDrop);
|
|
var mup = bind(blocker.element(), 'mouseup', dragApi.drop);
|
|
var mmove = bind(blocker.element(), 'mousemove', dragApi.move);
|
|
var mout = bind(blocker.element(), 'mouseout', dragApi.delayDrop);
|
|
var destroy = function () {
|
|
blocker.destroy();
|
|
mup.unbind();
|
|
mmove.unbind();
|
|
mout.unbind();
|
|
mdown.unbind();
|
|
};
|
|
var start = function (parent) {
|
|
append$1(parent, blocker.element());
|
|
};
|
|
var stop = function () {
|
|
remove$5(blocker.element());
|
|
};
|
|
return DragSink({
|
|
element: blocker.element,
|
|
start: start,
|
|
stop: stop,
|
|
destroy: destroy
|
|
});
|
|
};
|
|
var MouseDrag = DragMode({
|
|
compare: compare,
|
|
extract: extract,
|
|
sink: sink,
|
|
mutate: mutate
|
|
});
|
|
|
|
var transform$1 = function (mutation, settings) {
|
|
if (settings === void 0) {
|
|
settings = {};
|
|
}
|
|
var mode = settings.mode !== undefined ? settings.mode : MouseDrag;
|
|
return setup(mutation, mode, settings);
|
|
};
|
|
|
|
var closest = function (target) {
|
|
return closest$1(target, '[contenteditable]');
|
|
};
|
|
var isEditable$1 = function (element, assumeEditable) {
|
|
if (assumeEditable === void 0) {
|
|
assumeEditable = false;
|
|
}
|
|
if (!detect$3().browser.isIE() && inBody(element)) {
|
|
return element.dom.isContentEditable;
|
|
} else {
|
|
return closest(element).fold(constant(assumeEditable), function (editable) {
|
|
return getRaw(editable) === 'true';
|
|
});
|
|
}
|
|
};
|
|
var getRaw = function (element) {
|
|
return element.dom.contentEditable;
|
|
};
|
|
|
|
var styles = css('ephox-snooker');
|
|
var resolve = styles.resolve;
|
|
|
|
var Mutation = function () {
|
|
var events = create$4({
|
|
drag: Event([
|
|
'xDelta',
|
|
'yDelta'
|
|
])
|
|
});
|
|
var mutate = function (x, y) {
|
|
events.trigger.drag(x, y);
|
|
};
|
|
return {
|
|
mutate: mutate,
|
|
events: events.registry
|
|
};
|
|
};
|
|
|
|
var BarMutation = function () {
|
|
var events = create$4({
|
|
drag: Event([
|
|
'xDelta',
|
|
'yDelta',
|
|
'target'
|
|
])
|
|
});
|
|
var target = Optional.none();
|
|
var delegate = Mutation();
|
|
delegate.events.drag.bind(function (event) {
|
|
target.each(function (t) {
|
|
events.trigger.drag(event.xDelta, event.yDelta, t);
|
|
});
|
|
});
|
|
var assign = function (t) {
|
|
target = Optional.some(t);
|
|
};
|
|
var get = function () {
|
|
return target;
|
|
};
|
|
return {
|
|
assign: assign,
|
|
get: get,
|
|
mutate: delegate.mutate,
|
|
events: events.registry
|
|
};
|
|
};
|
|
|
|
var col = function (column, x, y, w, h) {
|
|
var bar = SugarElement.fromTag('div');
|
|
setAll(bar, {
|
|
position: 'absolute',
|
|
left: x - w / 2 + 'px',
|
|
top: y + 'px',
|
|
height: h + 'px',
|
|
width: w + 'px'
|
|
});
|
|
setAll$1(bar, {
|
|
'data-column': column,
|
|
'role': 'presentation'
|
|
});
|
|
return bar;
|
|
};
|
|
var row = function (r, x, y, w, h) {
|
|
var bar = SugarElement.fromTag('div');
|
|
setAll(bar, {
|
|
position: 'absolute',
|
|
left: x + 'px',
|
|
top: y - h / 2 + 'px',
|
|
height: h + 'px',
|
|
width: w + 'px'
|
|
});
|
|
setAll$1(bar, {
|
|
'data-row': r,
|
|
'role': 'presentation'
|
|
});
|
|
return bar;
|
|
};
|
|
|
|
var resizeBar = resolve('resizer-bar');
|
|
var resizeRowBar = resolve('resizer-rows');
|
|
var resizeColBar = resolve('resizer-cols');
|
|
var BAR_THICKNESS = 7;
|
|
var resizableRows = function (warehouse, isResizable) {
|
|
return bind$2(warehouse.all, function (row, i) {
|
|
return isResizable(row.element) ? [i] : [];
|
|
});
|
|
};
|
|
var resizableColumns = function (warehouse, isResizable) {
|
|
var resizableCols = [];
|
|
range$1(warehouse.grid.columns, function (index) {
|
|
var colElmOpt = Warehouse.getColumnAt(warehouse, index).map(function (col) {
|
|
return col.element;
|
|
});
|
|
if (colElmOpt.forall(isResizable)) {
|
|
resizableCols.push(index);
|
|
}
|
|
});
|
|
return filter$2(resizableCols, function (colIndex) {
|
|
var columnCells = Warehouse.filterItems(warehouse, function (cell) {
|
|
return cell.column === colIndex;
|
|
});
|
|
return forall(columnCells, function (cell) {
|
|
return isResizable(cell.element);
|
|
});
|
|
});
|
|
};
|
|
var destroy = function (wire) {
|
|
var previous = descendants(wire.parent(), '.' + resizeBar);
|
|
each$2(previous, remove$5);
|
|
};
|
|
var drawBar = function (wire, positions, create) {
|
|
var origin = wire.origin();
|
|
each$2(positions, function (cpOption) {
|
|
cpOption.each(function (cp) {
|
|
var bar = create(origin, cp);
|
|
add(bar, resizeBar);
|
|
append$1(wire.parent(), bar);
|
|
});
|
|
});
|
|
};
|
|
var refreshCol = function (wire, colPositions, position, tableHeight) {
|
|
drawBar(wire, colPositions, function (origin, cp) {
|
|
var colBar = col(cp.col, cp.x - origin.left, position.top - origin.top, BAR_THICKNESS, tableHeight);
|
|
add(colBar, resizeColBar);
|
|
return colBar;
|
|
});
|
|
};
|
|
var refreshRow = function (wire, rowPositions, position, tableWidth) {
|
|
drawBar(wire, rowPositions, function (origin, cp) {
|
|
var rowBar = row(cp.row, position.left - origin.left, cp.y - origin.top, tableWidth, BAR_THICKNESS);
|
|
add(rowBar, resizeRowBar);
|
|
return rowBar;
|
|
});
|
|
};
|
|
var refreshGrid = function (warhouse, wire, table, rows, cols) {
|
|
var position = absolute(table);
|
|
var isResizable = wire.isResizable;
|
|
var rowPositions = rows.length > 0 ? height.positions(rows, table) : [];
|
|
var resizableRowBars = rowPositions.length > 0 ? resizableRows(warhouse, isResizable) : [];
|
|
var resizableRowPositions = filter$2(rowPositions, function (_pos, i) {
|
|
return exists(resizableRowBars, function (barIndex) {
|
|
return i === barIndex;
|
|
});
|
|
});
|
|
refreshRow(wire, resizableRowPositions, position, getOuter$2(table));
|
|
var colPositions = cols.length > 0 ? width.positions(cols, table) : [];
|
|
var resizableColBars = colPositions.length > 0 ? resizableColumns(warhouse, isResizable) : [];
|
|
var resizableColPositions = filter$2(colPositions, function (_pos, i) {
|
|
return exists(resizableColBars, function (barIndex) {
|
|
return i === barIndex;
|
|
});
|
|
});
|
|
refreshCol(wire, resizableColPositions, position, getOuter$1(table));
|
|
};
|
|
var refresh = function (wire, table) {
|
|
destroy(wire);
|
|
if (wire.isResizable(table)) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var rows$1 = rows(warehouse);
|
|
var cols = columns(warehouse);
|
|
refreshGrid(warehouse, wire, table, rows$1, cols);
|
|
}
|
|
};
|
|
var each = function (wire, f) {
|
|
var bars = descendants(wire.parent(), '.' + resizeBar);
|
|
each$2(bars, f);
|
|
};
|
|
var hide = function (wire) {
|
|
each(wire, function (bar) {
|
|
set$1(bar, 'display', 'none');
|
|
});
|
|
};
|
|
var show = function (wire) {
|
|
each(wire, function (bar) {
|
|
set$1(bar, 'display', 'block');
|
|
});
|
|
};
|
|
var isRowBar = function (element) {
|
|
return has(element, resizeRowBar);
|
|
};
|
|
var isColBar = function (element) {
|
|
return has(element, resizeColBar);
|
|
};
|
|
|
|
var resizeBarDragging = resolve('resizer-bar-dragging');
|
|
var BarManager = function (wire) {
|
|
var mutation = BarMutation();
|
|
var resizing = transform$1(mutation, {});
|
|
var hoverTable = Optional.none();
|
|
var getResizer = function (element, type) {
|
|
return Optional.from(get$b(element, type));
|
|
};
|
|
mutation.events.drag.bind(function (event) {
|
|
getResizer(event.target, 'data-row').each(function (_dataRow) {
|
|
var currentRow = getCssValue(event.target, 'top');
|
|
set$1(event.target, 'top', currentRow + event.yDelta + 'px');
|
|
});
|
|
getResizer(event.target, 'data-column').each(function (_dataCol) {
|
|
var currentCol = getCssValue(event.target, 'left');
|
|
set$1(event.target, 'left', currentCol + event.xDelta + 'px');
|
|
});
|
|
});
|
|
var getDelta = function (target, dir) {
|
|
var newX = getCssValue(target, dir);
|
|
var oldX = getAttrValue(target, 'data-initial-' + dir, 0);
|
|
return newX - oldX;
|
|
};
|
|
resizing.events.stop.bind(function () {
|
|
mutation.get().each(function (target) {
|
|
hoverTable.each(function (table) {
|
|
getResizer(target, 'data-row').each(function (row) {
|
|
var delta = getDelta(target, 'top');
|
|
remove$7(target, 'data-initial-top');
|
|
events.trigger.adjustHeight(table, delta, parseInt(row, 10));
|
|
});
|
|
getResizer(target, 'data-column').each(function (column) {
|
|
var delta = getDelta(target, 'left');
|
|
remove$7(target, 'data-initial-left');
|
|
events.trigger.adjustWidth(table, delta, parseInt(column, 10));
|
|
});
|
|
refresh(wire, table);
|
|
});
|
|
});
|
|
});
|
|
var handler = function (target, dir) {
|
|
events.trigger.startAdjust();
|
|
mutation.assign(target);
|
|
set$2(target, 'data-initial-' + dir, getCssValue(target, dir));
|
|
add(target, resizeBarDragging);
|
|
set$1(target, 'opacity', '0.2');
|
|
resizing.go(wire.parent());
|
|
};
|
|
var mousedown = bind(wire.parent(), 'mousedown', function (event) {
|
|
if (isRowBar(event.target)) {
|
|
handler(event.target, 'top');
|
|
}
|
|
if (isColBar(event.target)) {
|
|
handler(event.target, 'left');
|
|
}
|
|
});
|
|
var isRoot = function (e) {
|
|
return eq$1(e, wire.view());
|
|
};
|
|
var findClosestEditableTable = function (target) {
|
|
return closest$1(target, 'table', isRoot).filter(isEditable$1);
|
|
};
|
|
var mouseover = bind(wire.view(), 'mouseover', function (event) {
|
|
findClosestEditableTable(event.target).fold(function () {
|
|
if (inBody(event.target)) {
|
|
destroy(wire);
|
|
}
|
|
}, function (table) {
|
|
hoverTable = Optional.some(table);
|
|
refresh(wire, table);
|
|
});
|
|
});
|
|
var destroy$1 = function () {
|
|
mousedown.unbind();
|
|
mouseover.unbind();
|
|
resizing.destroy();
|
|
destroy(wire);
|
|
};
|
|
var refresh$1 = function (tbl) {
|
|
refresh(wire, tbl);
|
|
};
|
|
var events = create$4({
|
|
adjustHeight: Event([
|
|
'table',
|
|
'delta',
|
|
'row'
|
|
]),
|
|
adjustWidth: Event([
|
|
'table',
|
|
'delta',
|
|
'column'
|
|
]),
|
|
startAdjust: Event([])
|
|
});
|
|
return {
|
|
destroy: destroy$1,
|
|
refresh: refresh$1,
|
|
on: resizing.on,
|
|
off: resizing.off,
|
|
hideBars: curry(hide, wire),
|
|
showBars: curry(show, wire),
|
|
events: events.registry
|
|
};
|
|
};
|
|
|
|
var create$3 = function (wire, resizing, lazySizing) {
|
|
var hdirection = height;
|
|
var vdirection = width;
|
|
var manager = BarManager(wire);
|
|
var events = create$4({
|
|
beforeResize: Event([
|
|
'table',
|
|
'type'
|
|
]),
|
|
afterResize: Event([
|
|
'table',
|
|
'type'
|
|
]),
|
|
startDrag: Event([])
|
|
});
|
|
manager.events.adjustHeight.bind(function (event) {
|
|
var table = event.table;
|
|
events.trigger.beforeResize(table, 'row');
|
|
var delta = hdirection.delta(event.delta, table);
|
|
adjustHeight(table, delta, event.row, hdirection);
|
|
events.trigger.afterResize(table, 'row');
|
|
});
|
|
manager.events.startAdjust.bind(function (_event) {
|
|
events.trigger.startDrag();
|
|
});
|
|
manager.events.adjustWidth.bind(function (event) {
|
|
var table = event.table;
|
|
events.trigger.beforeResize(table, 'col');
|
|
var delta = vdirection.delta(event.delta, table);
|
|
var tableSize = lazySizing(table);
|
|
adjustWidth(table, delta, event.column, resizing, tableSize);
|
|
events.trigger.afterResize(table, 'col');
|
|
});
|
|
return {
|
|
on: manager.on,
|
|
off: manager.off,
|
|
hideBars: manager.hideBars,
|
|
showBars: manager.showBars,
|
|
destroy: manager.destroy,
|
|
events: events.registry
|
|
};
|
|
};
|
|
var TableResize = { create: create$3 };
|
|
|
|
var fireNewRow = function (editor, row) {
|
|
return editor.fire('newrow', { node: row });
|
|
};
|
|
var fireNewCell = function (editor, cell) {
|
|
return editor.fire('newcell', { node: cell });
|
|
};
|
|
var fireObjectResizeStart = function (editor, target, width, height, origin) {
|
|
editor.fire('ObjectResizeStart', {
|
|
target: target,
|
|
width: width,
|
|
height: height,
|
|
origin: origin
|
|
});
|
|
};
|
|
var fireObjectResized = function (editor, target, width, height, origin) {
|
|
editor.fire('ObjectResized', {
|
|
target: target,
|
|
width: width,
|
|
height: height,
|
|
origin: origin
|
|
});
|
|
};
|
|
var fireTableSelectionChange = function (editor, cells, start, finish, otherCells) {
|
|
editor.fire('TableSelectionChange', {
|
|
cells: cells,
|
|
start: start,
|
|
finish: finish,
|
|
otherCells: otherCells
|
|
});
|
|
};
|
|
var fireTableSelectionClear = function (editor) {
|
|
editor.fire('TableSelectionClear');
|
|
};
|
|
var fireTableModified = function (editor, table, data) {
|
|
editor.fire('TableModified', __assign(__assign({}, data), { table: table }));
|
|
};
|
|
var styleModified = {
|
|
structure: false,
|
|
style: true
|
|
};
|
|
var structureModified = {
|
|
structure: true,
|
|
style: false
|
|
};
|
|
var styleAndStructureModified = {
|
|
structure: true,
|
|
style: true
|
|
};
|
|
|
|
var defaultTableToolbar = 'tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol';
|
|
var defaultStyles = {
|
|
'border-collapse': 'collapse',
|
|
'width': '100%'
|
|
};
|
|
var defaultCellBorderWidths = range$1(5, function (i) {
|
|
var size = i + 1 + 'px';
|
|
return {
|
|
title: size,
|
|
value: size
|
|
};
|
|
});
|
|
var defaultCellBorderStyles = map$1([
|
|
'Solid',
|
|
'Dotted',
|
|
'Dashed',
|
|
'Double',
|
|
'Groove',
|
|
'Ridge',
|
|
'Inset',
|
|
'Outset',
|
|
'None',
|
|
'Hidden'
|
|
], function (type) {
|
|
return {
|
|
title: type,
|
|
value: type.toLowerCase()
|
|
};
|
|
});
|
|
var determineDefaultStyles = function (editor) {
|
|
var _a;
|
|
if (isPixelsForced(editor)) {
|
|
var dom = editor.dom;
|
|
var parentBlock = (_a = dom.getParent(editor.selection.getStart(), dom.isBlock)) !== null && _a !== void 0 ? _a : editor.getBody();
|
|
var contentWidth = getInner(SugarElement.fromDom(parentBlock));
|
|
return __assign(__assign({}, defaultStyles), { width: contentWidth + 'px' });
|
|
} else if (isResponsiveForced(editor)) {
|
|
return filter$1(defaultStyles, function (_value, key) {
|
|
return key !== 'width';
|
|
});
|
|
} else {
|
|
return defaultStyles;
|
|
}
|
|
};
|
|
var defaultAttributes = { border: '1' };
|
|
var defaultColumnResizingBehaviour = 'preservetable';
|
|
var getTableSizingMode = function (editor) {
|
|
return editor.getParam('table_sizing_mode', 'auto');
|
|
};
|
|
var getTableResponseWidth = function (editor) {
|
|
return editor.getParam('table_responsive_width');
|
|
};
|
|
var getTableBorderWidths = function (editor) {
|
|
return editor.getParam('table_border_widths', defaultCellBorderWidths, 'array');
|
|
};
|
|
var getTableBorderStyles = function (editor) {
|
|
return editor.getParam('table_border_styles', defaultCellBorderStyles, 'array');
|
|
};
|
|
var getDefaultAttributes = function (editor) {
|
|
return editor.getParam('table_default_attributes', defaultAttributes, 'object');
|
|
};
|
|
var getDefaultStyles = function (editor) {
|
|
return editor.getParam('table_default_styles', determineDefaultStyles(editor), 'object');
|
|
};
|
|
var hasTableResizeBars = function (editor) {
|
|
return editor.getParam('table_resize_bars', true, 'boolean');
|
|
};
|
|
var hasTabNavigation = function (editor) {
|
|
return editor.getParam('table_tab_navigation', true, 'boolean');
|
|
};
|
|
var hasAdvancedCellTab = function (editor) {
|
|
return editor.getParam('table_cell_advtab', true, 'boolean');
|
|
};
|
|
var hasAdvancedRowTab = function (editor) {
|
|
return editor.getParam('table_row_advtab', true, 'boolean');
|
|
};
|
|
var hasAdvancedTableTab = function (editor) {
|
|
return editor.getParam('table_advtab', true, 'boolean');
|
|
};
|
|
var hasAppearanceOptions = function (editor) {
|
|
return editor.getParam('table_appearance_options', true, 'boolean');
|
|
};
|
|
var hasTableGrid = function (editor) {
|
|
return editor.getParam('table_grid', true, 'boolean');
|
|
};
|
|
var shouldStyleWithCss = function (editor) {
|
|
return editor.getParam('table_style_by_css', false, 'boolean');
|
|
};
|
|
var getCellClassList = function (editor) {
|
|
return editor.getParam('table_cell_class_list', [], 'array');
|
|
};
|
|
var getRowClassList = function (editor) {
|
|
return editor.getParam('table_row_class_list', [], 'array');
|
|
};
|
|
var getTableClassList = function (editor) {
|
|
return editor.getParam('table_class_list', [], 'array');
|
|
};
|
|
var isPercentagesForced = function (editor) {
|
|
return getTableSizingMode(editor) === 'relative' || getTableResponseWidth(editor) === true;
|
|
};
|
|
var isPixelsForced = function (editor) {
|
|
return getTableSizingMode(editor) === 'fixed' || getTableResponseWidth(editor) === false;
|
|
};
|
|
var isResponsiveForced = function (editor) {
|
|
return getTableSizingMode(editor) === 'responsive';
|
|
};
|
|
var getToolbar = function (editor) {
|
|
return editor.getParam('table_toolbar', defaultTableToolbar);
|
|
};
|
|
var useColumnGroup = function (editor) {
|
|
return editor.getParam('table_use_colgroups', false, 'boolean');
|
|
};
|
|
var getTableHeaderType = function (editor) {
|
|
var defaultValue = 'section';
|
|
var value = editor.getParam('table_header_type', defaultValue, 'string');
|
|
var validValues = [
|
|
'section',
|
|
'cells',
|
|
'sectionCells',
|
|
'auto'
|
|
];
|
|
if (!contains$2(validValues, value)) {
|
|
return defaultValue;
|
|
} else {
|
|
return value;
|
|
}
|
|
};
|
|
var getColumnResizingBehaviour = function (editor) {
|
|
var validModes = [
|
|
'preservetable',
|
|
'resizetable'
|
|
];
|
|
var givenMode = editor.getParam('table_column_resizing', defaultColumnResizingBehaviour, 'string');
|
|
return find$1(validModes, function (mode) {
|
|
return mode === givenMode;
|
|
}).getOr(defaultColumnResizingBehaviour);
|
|
};
|
|
var isPreserveTableColumnResizing = function (editor) {
|
|
return getColumnResizingBehaviour(editor) === 'preservetable';
|
|
};
|
|
var isResizeTableColumnResizing = function (editor) {
|
|
return getColumnResizingBehaviour(editor) === 'resizetable';
|
|
};
|
|
var getCloneElements = function (editor) {
|
|
var cloneElements = editor.getParam('table_clone_elements');
|
|
if (isString(cloneElements)) {
|
|
return Optional.some(cloneElements.split(/[ ,]/));
|
|
} else if (Array.isArray(cloneElements)) {
|
|
return Optional.some(cloneElements);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var hasObjectResizing = function (editor) {
|
|
var objectResizing = editor.getParam('object_resizing', true);
|
|
return isString(objectResizing) ? objectResizing === 'table' : objectResizing;
|
|
};
|
|
var getTableBackgroundColorMap = function (editor) {
|
|
return editor.getParam('table_background_color_map', [], 'array');
|
|
};
|
|
var getTableBorderColorMap = function (editor) {
|
|
return editor.getParam('table_border_color_map', [], 'array');
|
|
};
|
|
|
|
var get$4 = function (editor, table) {
|
|
if (isPercentagesForced(editor)) {
|
|
return TableSize.percentageSize(table);
|
|
} else if (isPixelsForced(editor)) {
|
|
return TableSize.pixelSize(table);
|
|
} else {
|
|
return TableSize.getTableSize(table);
|
|
}
|
|
};
|
|
|
|
var cleanupLegacyAttributes = function (element) {
|
|
remove$7(element, 'width');
|
|
};
|
|
var convertToPercentSize = function (table) {
|
|
var newWidth = getPercentTableWidth(table);
|
|
redistribute(table, Optional.some(newWidth), Optional.none());
|
|
cleanupLegacyAttributes(table);
|
|
};
|
|
var convertToPixelSize = function (table) {
|
|
var newWidth = getPixelTableWidth(table);
|
|
redistribute(table, Optional.some(newWidth), Optional.none());
|
|
cleanupLegacyAttributes(table);
|
|
};
|
|
var convertToNoneSize = function (table) {
|
|
remove$6(table, 'width');
|
|
var columns = columns$1(table);
|
|
var rowElements = columns.length > 0 ? columns : cells$1(table);
|
|
each$2(rowElements, function (cell) {
|
|
remove$6(cell, 'width');
|
|
cleanupLegacyAttributes(cell);
|
|
});
|
|
cleanupLegacyAttributes(table);
|
|
};
|
|
|
|
var enforcePercentage = convertToPercentSize;
|
|
var enforcePixels = convertToPixelSize;
|
|
var enforceNone = convertToNoneSize;
|
|
var syncPixels = function (table) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
if (!Warehouse.hasColumns(warehouse)) {
|
|
each$2(cells$1(table), function (cell) {
|
|
var computedWidth = get$a(cell, 'width');
|
|
set$1(cell, 'width', computedWidth);
|
|
remove$7(cell, 'width');
|
|
});
|
|
}
|
|
};
|
|
|
|
var createContainer = function () {
|
|
var container = SugarElement.fromTag('div');
|
|
setAll(container, {
|
|
position: 'static',
|
|
height: '0',
|
|
width: '0',
|
|
padding: '0',
|
|
margin: '0',
|
|
border: '0'
|
|
});
|
|
append$1(body$1(), container);
|
|
return container;
|
|
};
|
|
var get$3 = function (editor, isResizable) {
|
|
return editor.inline ? ResizeWire.body(getBody(editor), createContainer(), isResizable) : ResizeWire.only(SugarElement.fromDom(editor.getDoc()), isResizable);
|
|
};
|
|
var remove$1 = function (editor, wire) {
|
|
if (editor.inline) {
|
|
remove$5(wire.parent());
|
|
}
|
|
};
|
|
|
|
var barResizerPrefix = 'bar-';
|
|
var isResizable = function (elm) {
|
|
return get$b(elm, 'data-mce-resize') !== 'false';
|
|
};
|
|
var getResizeHandler = function (editor) {
|
|
var selectionRng = Optional.none();
|
|
var resize = Optional.none();
|
|
var wire = Optional.none();
|
|
var startW;
|
|
var startRawW;
|
|
var isTable = function (elm) {
|
|
return elm.nodeName === 'TABLE';
|
|
};
|
|
var lazyResize = function () {
|
|
return resize;
|
|
};
|
|
var lazyWire = function () {
|
|
return wire.getOr(ResizeWire.only(SugarElement.fromDom(editor.getBody()), isResizable));
|
|
};
|
|
var lazySizing = function (table) {
|
|
return get$4(editor, table);
|
|
};
|
|
var lazyResizingBehaviour = function () {
|
|
return isPreserveTableColumnResizing(editor) ? preserveTable() : resizeTable();
|
|
};
|
|
var getNumColumns = function (table) {
|
|
return getGridSize(table).columns;
|
|
};
|
|
var afterCornerResize = function (table, origin, width) {
|
|
var isRightEdgeResize = endsWith(origin, 'e');
|
|
if (startRawW === '') {
|
|
enforcePercentage(table);
|
|
}
|
|
if (width !== startW && startRawW !== '') {
|
|
set$1(table, 'width', startRawW);
|
|
var resizing = lazyResizingBehaviour();
|
|
var tableSize = lazySizing(table);
|
|
var col = isPreserveTableColumnResizing(editor) || isRightEdgeResize ? getNumColumns(table) - 1 : 0;
|
|
adjustWidth(table, width - startW, col, resizing, tableSize);
|
|
} else if (isPercentage$1(startRawW)) {
|
|
var percentW = parseFloat(startRawW.replace('%', ''));
|
|
var targetPercentW = width * percentW / startW;
|
|
set$1(table, 'width', targetPercentW + '%');
|
|
}
|
|
if (isPixel(startRawW)) {
|
|
syncPixels(table);
|
|
}
|
|
};
|
|
var destroy = function () {
|
|
resize.each(function (sz) {
|
|
sz.destroy();
|
|
});
|
|
wire.each(function (w) {
|
|
remove$1(editor, w);
|
|
});
|
|
};
|
|
editor.on('init', function () {
|
|
var rawWire = get$3(editor, isResizable);
|
|
wire = Optional.some(rawWire);
|
|
if (hasObjectResizing(editor) && hasTableResizeBars(editor)) {
|
|
var resizing = lazyResizingBehaviour();
|
|
var sz = TableResize.create(rawWire, resizing, lazySizing);
|
|
sz.on();
|
|
sz.events.startDrag.bind(function (_event) {
|
|
selectionRng = Optional.some(editor.selection.getRng());
|
|
});
|
|
sz.events.beforeResize.bind(function (event) {
|
|
var rawTable = event.table.dom;
|
|
fireObjectResizeStart(editor, rawTable, getPixelWidth(rawTable), getPixelHeight(rawTable), barResizerPrefix + event.type);
|
|
});
|
|
sz.events.afterResize.bind(function (event) {
|
|
var table = event.table;
|
|
var rawTable = table.dom;
|
|
removeDataStyle(table);
|
|
selectionRng.each(function (rng) {
|
|
editor.selection.setRng(rng);
|
|
editor.focus();
|
|
});
|
|
fireObjectResized(editor, rawTable, getPixelWidth(rawTable), getPixelHeight(rawTable), barResizerPrefix + event.type);
|
|
editor.undoManager.add();
|
|
});
|
|
resize = Optional.some(sz);
|
|
}
|
|
});
|
|
editor.on('ObjectResizeStart', function (e) {
|
|
var targetElm = e.target;
|
|
if (isTable(targetElm)) {
|
|
var table = SugarElement.fromDom(targetElm);
|
|
each$2(editor.dom.select('.mce-clonedresizable'), function (clone) {
|
|
editor.dom.addClass(clone, 'mce-' + getColumnResizingBehaviour(editor) + '-columns');
|
|
});
|
|
if (!isPixelSizing(table) && isPixelsForced(editor)) {
|
|
enforcePixels(table);
|
|
} else if (!isPercentSizing(table) && isPercentagesForced(editor)) {
|
|
enforcePercentage(table);
|
|
}
|
|
if (isNoneSizing(table) && startsWith(e.origin, barResizerPrefix)) {
|
|
enforcePercentage(table);
|
|
}
|
|
startW = e.width;
|
|
startRawW = isResponsiveForced(editor) ? '' : getRawWidth(editor, targetElm).getOr('');
|
|
}
|
|
});
|
|
editor.on('ObjectResized', function (e) {
|
|
var targetElm = e.target;
|
|
if (isTable(targetElm)) {
|
|
var table = SugarElement.fromDom(targetElm);
|
|
var origin_1 = e.origin;
|
|
if (startsWith(origin_1, 'corner-')) {
|
|
afterCornerResize(table, origin_1, e.width);
|
|
}
|
|
removeDataStyle(table);
|
|
fireTableModified(editor, table.dom, styleModified);
|
|
}
|
|
});
|
|
editor.on('SwitchMode', function () {
|
|
lazyResize().each(function (resize) {
|
|
if (editor.mode.isReadOnly()) {
|
|
resize.hideBars();
|
|
} else {
|
|
resize.showBars();
|
|
}
|
|
});
|
|
});
|
|
return {
|
|
lazyResize: lazyResize,
|
|
lazyWire: lazyWire,
|
|
destroy: destroy
|
|
};
|
|
};
|
|
|
|
var point = function (element, offset) {
|
|
return {
|
|
element: element,
|
|
offset: offset
|
|
};
|
|
};
|
|
|
|
var scan$1 = function (universe, element, direction) {
|
|
if (universe.property().isText(element) && universe.property().getText(element).trim().length === 0 || universe.property().isComment(element)) {
|
|
return direction(element).bind(function (elem) {
|
|
return scan$1(universe, elem, direction).orThunk(function () {
|
|
return Optional.some(elem);
|
|
});
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var toEnd = function (universe, element) {
|
|
if (universe.property().isText(element)) {
|
|
return universe.property().getText(element).length;
|
|
}
|
|
var children = universe.property().children(element);
|
|
return children.length;
|
|
};
|
|
var freefallRtl$2 = function (universe, element) {
|
|
var candidate = scan$1(universe, element, universe.query().prevSibling).getOr(element);
|
|
if (universe.property().isText(candidate)) {
|
|
return point(candidate, toEnd(universe, candidate));
|
|
}
|
|
var children = universe.property().children(candidate);
|
|
return children.length > 0 ? freefallRtl$2(universe, children[children.length - 1]) : point(candidate, toEnd(universe, candidate));
|
|
};
|
|
|
|
var freefallRtl$1 = freefallRtl$2;
|
|
|
|
var universe$2 = DomUniverse();
|
|
var freefallRtl = function (element) {
|
|
return freefallRtl$1(universe$2, element);
|
|
};
|
|
|
|
var halve = function (main, other) {
|
|
var colspan = getSpan(main, 'colspan');
|
|
if (colspan === 1) {
|
|
var width = getGenericWidth(main);
|
|
width.each(function (w) {
|
|
var newWidth = w.value / 2;
|
|
setGenericWidth(main, newWidth, w.unit);
|
|
setGenericWidth(other, newWidth, w.unit);
|
|
});
|
|
}
|
|
};
|
|
|
|
var isHeaderCell = isTag('th');
|
|
var isHeaderCells = function (cells) {
|
|
return forall(cells, function (cell) {
|
|
return isHeaderCell(cell.element);
|
|
});
|
|
};
|
|
var getRowHeaderType = function (isHeaderRow, isHeaderCells) {
|
|
if (isHeaderRow && isHeaderCells) {
|
|
return 'sectionCells';
|
|
} else if (isHeaderRow) {
|
|
return 'section';
|
|
} else {
|
|
return 'cells';
|
|
}
|
|
};
|
|
var getRowType$1 = function (row) {
|
|
var isHeaderRow = row.section === 'thead';
|
|
var isHeaderCells = is(findCommonCellType(row.cells), 'th');
|
|
if (isHeaderRow || isHeaderCells) {
|
|
return {
|
|
type: 'header',
|
|
subType: getRowHeaderType(isHeaderRow, isHeaderCells)
|
|
};
|
|
} else if (row.section === 'tfoot') {
|
|
return { type: 'footer' };
|
|
} else {
|
|
return { type: 'body' };
|
|
}
|
|
};
|
|
var findCommonCellType = function (cells) {
|
|
var headerCells = filter$2(cells, function (cell) {
|
|
return isHeaderCell(cell.element);
|
|
});
|
|
if (headerCells.length === 0) {
|
|
return Optional.some('td');
|
|
} else if (headerCells.length === cells.length) {
|
|
return Optional.some('th');
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var findCommonRowType = function (rows) {
|
|
var rowTypes = map$1(rows, function (row) {
|
|
return getRowType$1(row).type;
|
|
});
|
|
var hasHeader = contains$2(rowTypes, 'header');
|
|
var hasFooter = contains$2(rowTypes, 'footer');
|
|
if (!hasHeader && !hasFooter) {
|
|
return Optional.some('body');
|
|
} else {
|
|
var hasBody = contains$2(rowTypes, 'body');
|
|
if (hasHeader && !hasBody && !hasFooter) {
|
|
return Optional.some('header');
|
|
} else if (!hasHeader && !hasBody && hasFooter) {
|
|
return Optional.some('footer');
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
};
|
|
var findTableRowHeaderType = function (warehouse) {
|
|
return findMap(warehouse.all, function (row) {
|
|
var rowType = getRowType$1(row);
|
|
return rowType.type === 'header' ? Optional.from(rowType.subType) : Optional.none();
|
|
});
|
|
};
|
|
|
|
var transformCell = function (cell, comparator, substitution) {
|
|
return elementnew(substitution(cell.element, comparator), true, cell.isLocked);
|
|
};
|
|
var transformRow = function (row, section) {
|
|
return row.section !== section ? rowcells(row.element, row.cells, section, row.isNew) : row;
|
|
};
|
|
var section = function () {
|
|
return {
|
|
transformRow: transformRow,
|
|
transformCell: function (cell, comparator, substitution) {
|
|
var newCell = substitution(cell.element, comparator);
|
|
var fixedCell = name(newCell) !== 'td' ? mutate$1(newCell, 'td') : newCell;
|
|
return elementnew(fixedCell, cell.isNew, cell.isLocked);
|
|
}
|
|
};
|
|
};
|
|
var sectionCells = function () {
|
|
return {
|
|
transformRow: transformRow,
|
|
transformCell: transformCell
|
|
};
|
|
};
|
|
var cells = function () {
|
|
return {
|
|
transformRow: function (row, section) {
|
|
var newSection = section === 'thead' ? 'tbody' : section;
|
|
return transformRow(row, newSection);
|
|
},
|
|
transformCell: transformCell
|
|
};
|
|
};
|
|
var fallback = function () {
|
|
return {
|
|
transformRow: identity,
|
|
transformCell: transformCell
|
|
};
|
|
};
|
|
var getTableSectionType = function (table, fallback) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var type = findTableRowHeaderType(warehouse).getOr(fallback);
|
|
switch (type) {
|
|
case 'section':
|
|
return section();
|
|
case 'sectionCells':
|
|
return sectionCells();
|
|
case 'cells':
|
|
return cells();
|
|
}
|
|
};
|
|
var TableSection = {
|
|
getTableSectionType: getTableSectionType,
|
|
section: section,
|
|
sectionCells: sectionCells,
|
|
cells: cells,
|
|
fallback: fallback
|
|
};
|
|
|
|
var setIfNot = function (element, property, value, ignore) {
|
|
if (value === ignore) {
|
|
remove$7(element, property);
|
|
} else {
|
|
set$2(element, property, value);
|
|
}
|
|
};
|
|
var insert$1 = function (table, selector, element) {
|
|
last$2(children$1(table, selector)).fold(function () {
|
|
return prepend(table, element);
|
|
}, function (child) {
|
|
return after$5(child, element);
|
|
});
|
|
};
|
|
var generateSection = function (table, sectionName) {
|
|
var section = child$1(table, sectionName).getOrThunk(function () {
|
|
var newSection = SugarElement.fromTag(sectionName, owner(table).dom);
|
|
if (sectionName === 'thead') {
|
|
insert$1(table, 'caption,colgroup', newSection);
|
|
} else if (sectionName === 'colgroup') {
|
|
insert$1(table, 'caption', newSection);
|
|
} else {
|
|
append$1(table, newSection);
|
|
}
|
|
return newSection;
|
|
});
|
|
empty(section);
|
|
return section;
|
|
};
|
|
var render$1 = function (table, grid) {
|
|
var newRows = [];
|
|
var newCells = [];
|
|
var syncRows = function (gridSection) {
|
|
return map$1(gridSection, function (row) {
|
|
if (row.isNew) {
|
|
newRows.push(row.element);
|
|
}
|
|
var tr = row.element;
|
|
empty(tr);
|
|
each$2(row.cells, function (cell) {
|
|
if (cell.isNew) {
|
|
newCells.push(cell.element);
|
|
}
|
|
setIfNot(cell.element, 'colspan', cell.colspan, 1);
|
|
setIfNot(cell.element, 'rowspan', cell.rowspan, 1);
|
|
append$1(tr, cell.element);
|
|
});
|
|
return tr;
|
|
});
|
|
};
|
|
var syncColGroup = function (gridSection) {
|
|
return bind$2(gridSection, function (colGroup) {
|
|
return map$1(colGroup.cells, function (col) {
|
|
setIfNot(col.element, 'span', col.colspan, 1);
|
|
return col.element;
|
|
});
|
|
});
|
|
};
|
|
var renderSection = function (gridSection, sectionName) {
|
|
var section = generateSection(table, sectionName);
|
|
var sync = sectionName === 'colgroup' ? syncColGroup : syncRows;
|
|
var sectionElems = sync(gridSection);
|
|
append(section, sectionElems);
|
|
};
|
|
var removeSection = function (sectionName) {
|
|
child$1(table, sectionName).each(remove$5);
|
|
};
|
|
var renderOrRemoveSection = function (gridSection, sectionName) {
|
|
if (gridSection.length > 0) {
|
|
renderSection(gridSection, sectionName);
|
|
} else {
|
|
removeSection(sectionName);
|
|
}
|
|
};
|
|
var headSection = [];
|
|
var bodySection = [];
|
|
var footSection = [];
|
|
var columnGroupsSection = [];
|
|
each$2(grid, function (row) {
|
|
switch (row.section) {
|
|
case 'thead':
|
|
headSection.push(row);
|
|
break;
|
|
case 'tbody':
|
|
bodySection.push(row);
|
|
break;
|
|
case 'tfoot':
|
|
footSection.push(row);
|
|
break;
|
|
case 'colgroup':
|
|
columnGroupsSection.push(row);
|
|
break;
|
|
}
|
|
});
|
|
renderOrRemoveSection(columnGroupsSection, 'colgroup');
|
|
renderOrRemoveSection(headSection, 'thead');
|
|
renderOrRemoveSection(bodySection, 'tbody');
|
|
renderOrRemoveSection(footSection, 'tfoot');
|
|
return {
|
|
newRows: newRows,
|
|
newCells: newCells
|
|
};
|
|
};
|
|
var copy = function (grid) {
|
|
return map$1(grid, function (row) {
|
|
var tr = shallow(row.element);
|
|
each$2(row.cells, function (cell) {
|
|
var clonedCell = deep(cell.element);
|
|
setIfNot(clonedCell, 'colspan', cell.colspan, 1);
|
|
setIfNot(clonedCell, 'rowspan', cell.rowspan, 1);
|
|
append$1(tr, clonedCell);
|
|
});
|
|
return tr;
|
|
});
|
|
};
|
|
|
|
var getColumn = function (grid, index) {
|
|
return map$1(grid, function (row) {
|
|
return getCell(row, index);
|
|
});
|
|
};
|
|
var getRow = function (grid, index) {
|
|
return grid[index];
|
|
};
|
|
var findDiff = function (xs, comp) {
|
|
if (xs.length === 0) {
|
|
return 0;
|
|
}
|
|
var first = xs[0];
|
|
var index = findIndex(xs, function (x) {
|
|
return !comp(first.element, x.element);
|
|
});
|
|
return index.getOr(xs.length);
|
|
};
|
|
var subgrid = function (grid, row, column, comparator) {
|
|
var gridRow = getRow(grid, row);
|
|
var isColRow = gridRow.section === 'colgroup';
|
|
var colspan = findDiff(gridRow.cells.slice(column), comparator);
|
|
var rowspan = isColRow ? 1 : findDiff(getColumn(grid.slice(row), column), comparator);
|
|
return {
|
|
colspan: colspan,
|
|
rowspan: rowspan
|
|
};
|
|
};
|
|
|
|
var toDetails = function (grid, comparator) {
|
|
var seen = map$1(grid, function (row) {
|
|
return map$1(row.cells, never);
|
|
});
|
|
var updateSeen = function (rowIndex, columnIndex, rowspan, colspan) {
|
|
for (var row = rowIndex; row < rowIndex + rowspan; row++) {
|
|
for (var column = columnIndex; column < columnIndex + colspan; column++) {
|
|
seen[row][column] = true;
|
|
}
|
|
}
|
|
};
|
|
return map$1(grid, function (row, rowIndex) {
|
|
var details = bind$2(row.cells, function (cell, columnIndex) {
|
|
if (seen[rowIndex][columnIndex] === false) {
|
|
var result = subgrid(grid, rowIndex, columnIndex, comparator);
|
|
updateSeen(rowIndex, columnIndex, result.rowspan, result.colspan);
|
|
return [detailnew(cell.element, result.rowspan, result.colspan, cell.isNew)];
|
|
} else {
|
|
return [];
|
|
}
|
|
});
|
|
return rowdetailnew(row.element, details, row.section, row.isNew);
|
|
});
|
|
};
|
|
var toGrid = function (warehouse, generators, isNew) {
|
|
var grid = [];
|
|
each$2(warehouse.colgroups, function (colgroup) {
|
|
var colgroupCols = [];
|
|
for (var columnIndex = 0; columnIndex < warehouse.grid.columns; columnIndex++) {
|
|
var element = Warehouse.getColumnAt(warehouse, columnIndex).map(function (column) {
|
|
return elementnew(column.element, isNew, false);
|
|
}).getOrThunk(function () {
|
|
return elementnew(generators.colGap(), true, false);
|
|
});
|
|
colgroupCols.push(element);
|
|
}
|
|
grid.push(rowcells(colgroup.element, colgroupCols, 'colgroup', isNew));
|
|
});
|
|
for (var rowIndex = 0; rowIndex < warehouse.grid.rows; rowIndex++) {
|
|
var rowCells = [];
|
|
for (var columnIndex = 0; columnIndex < warehouse.grid.columns; columnIndex++) {
|
|
var element = Warehouse.getAt(warehouse, rowIndex, columnIndex).map(function (item) {
|
|
return elementnew(item.element, isNew, item.isLocked);
|
|
}).getOrThunk(function () {
|
|
return elementnew(generators.gap(), true, false);
|
|
});
|
|
rowCells.push(element);
|
|
}
|
|
var rowDetail = warehouse.all[rowIndex];
|
|
var row = rowcells(rowDetail.element, rowCells, rowDetail.section, isNew);
|
|
grid.push(row);
|
|
}
|
|
return grid;
|
|
};
|
|
|
|
var fromWarehouse = function (warehouse, generators) {
|
|
return toGrid(warehouse, generators, false);
|
|
};
|
|
var toDetailList = function (grid) {
|
|
return toDetails(grid, eq$1);
|
|
};
|
|
var findInWarehouse = function (warehouse, element) {
|
|
return findMap(warehouse.all, function (r) {
|
|
return find$1(r.cells, function (e) {
|
|
return eq$1(element, e.element);
|
|
});
|
|
});
|
|
};
|
|
var extractCells = function (warehouse, target, predicate) {
|
|
var details = map$1(target.selection, function (cell$1) {
|
|
return cell(cell$1).bind(function (lc) {
|
|
return findInWarehouse(warehouse, lc);
|
|
}).filter(predicate);
|
|
});
|
|
var cells = cat(details);
|
|
return someIf(cells.length > 0, cells);
|
|
};
|
|
var run = function (operation, extract, adjustment, postAction, genWrappers) {
|
|
return function (wire, table, target, generators, behaviours) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var tableSection = Optional.from(behaviours === null || behaviours === void 0 ? void 0 : behaviours.section).getOrThunk(TableSection.fallback);
|
|
var output = extract(warehouse, target).map(function (info) {
|
|
var model = fromWarehouse(warehouse, generators);
|
|
var result = operation(model, info, eq$1, genWrappers(generators), tableSection);
|
|
var lockedColumns = getLockedColumnsFromGrid(result.grid);
|
|
var grid = toDetailList(result.grid);
|
|
return {
|
|
info: info,
|
|
grid: grid,
|
|
cursor: result.cursor,
|
|
lockedColumns: lockedColumns
|
|
};
|
|
});
|
|
return output.bind(function (out) {
|
|
var newElements = render$1(table, out.grid);
|
|
var tableSizing = Optional.from(behaviours === null || behaviours === void 0 ? void 0 : behaviours.sizing).getOrThunk(function () {
|
|
return TableSize.getTableSize(table);
|
|
});
|
|
var resizing = Optional.from(behaviours === null || behaviours === void 0 ? void 0 : behaviours.resize).getOrThunk(preserveTable);
|
|
adjustment(table, out.grid, out.info, {
|
|
sizing: tableSizing,
|
|
resize: resizing,
|
|
section: tableSection
|
|
});
|
|
postAction(table);
|
|
refresh(wire, table);
|
|
remove$7(table, LOCKED_COL_ATTR);
|
|
if (out.lockedColumns.length > 0) {
|
|
set$2(table, LOCKED_COL_ATTR, out.lockedColumns.join(','));
|
|
}
|
|
return Optional.some({
|
|
cursor: out.cursor,
|
|
newRows: newElements.newRows,
|
|
newCells: newElements.newCells
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var onPaste = function (warehouse, target) {
|
|
return cell(target.element).bind(function (cell) {
|
|
return findInWarehouse(warehouse, cell).map(function (details) {
|
|
var value = __assign(__assign({}, details), {
|
|
generators: target.generators,
|
|
clipboard: target.clipboard
|
|
});
|
|
return value;
|
|
});
|
|
});
|
|
};
|
|
var onPasteByEditor = function (warehouse, target) {
|
|
return extractCells(warehouse, target, always).map(function (cells) {
|
|
return {
|
|
cells: cells,
|
|
generators: target.generators,
|
|
clipboard: target.clipboard
|
|
};
|
|
});
|
|
};
|
|
var onMergable = function (_warehouse, target) {
|
|
return target.mergable;
|
|
};
|
|
var onUnmergable = function (_warehouse, target) {
|
|
return target.unmergable;
|
|
};
|
|
var onCells = function (warehouse, target) {
|
|
return extractCells(warehouse, target, always);
|
|
};
|
|
var onUnlockedCells = function (warehouse, target) {
|
|
return extractCells(warehouse, target, function (detail) {
|
|
return !detail.isLocked;
|
|
});
|
|
};
|
|
var isUnlockedTableCell = function (warehouse, cell) {
|
|
return findInWarehouse(warehouse, cell).exists(function (detail) {
|
|
return !detail.isLocked;
|
|
});
|
|
};
|
|
var allUnlocked = function (warehouse, cells) {
|
|
return forall(cells, function (cell) {
|
|
return isUnlockedTableCell(warehouse, cell);
|
|
});
|
|
};
|
|
var onUnlockedMergable = function (warehouse, target) {
|
|
return onMergable(warehouse, target).filter(function (mergeable) {
|
|
return allUnlocked(warehouse, mergeable.cells);
|
|
});
|
|
};
|
|
var onUnlockedUnmergable = function (warehouse, target) {
|
|
return onUnmergable(warehouse, target).filter(function (cells) {
|
|
return allUnlocked(warehouse, cells);
|
|
});
|
|
};
|
|
|
|
var merge$2 = function (grid, bounds, comparator, substitution) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
if (rows.length === 0) {
|
|
return grid;
|
|
}
|
|
for (var i = bounds.startRow; i <= bounds.finishRow; i++) {
|
|
for (var j = bounds.startCol; j <= bounds.finishCol; j++) {
|
|
var row = rows[i];
|
|
var isLocked = getCell(row, j).isLocked;
|
|
mutateCell(row, j, elementnew(substitution(), false, isLocked));
|
|
}
|
|
}
|
|
return grid;
|
|
};
|
|
var unmerge = function (grid, target, comparator, substitution) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
var first = true;
|
|
for (var i = 0; i < rows.length; i++) {
|
|
for (var j = 0; j < cellLength(rows[0]); j++) {
|
|
var row = rows[i];
|
|
var currentCell = getCell(row, j);
|
|
var currentCellElm = currentCell.element;
|
|
var isToReplace = comparator(currentCellElm, target);
|
|
if (isToReplace === true && first === false) {
|
|
mutateCell(row, j, elementnew(substitution(), true, currentCell.isLocked));
|
|
} else if (isToReplace === true) {
|
|
first = false;
|
|
}
|
|
}
|
|
}
|
|
return grid;
|
|
};
|
|
var uniqueCells = function (row, comparator) {
|
|
return foldl(row, function (rest, cell) {
|
|
return exists(rest, function (currentCell) {
|
|
return comparator(currentCell.element, cell.element);
|
|
}) ? rest : rest.concat([cell]);
|
|
}, []);
|
|
};
|
|
var splitCols = function (grid, index, comparator, substitution) {
|
|
if (index > 0 && index < grid[0].cells.length) {
|
|
each$2(grid, function (row) {
|
|
var prevCell = row.cells[index - 1];
|
|
var current = row.cells[index];
|
|
var isToReplace = comparator(current.element, prevCell.element);
|
|
if (isToReplace) {
|
|
mutateCell(row, index, elementnew(substitution(), true, current.isLocked));
|
|
}
|
|
});
|
|
}
|
|
return grid;
|
|
};
|
|
var splitRows = function (grid, index, comparator, substitution) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
if (index > 0 && index < rows.length) {
|
|
var rowPrevCells = rows[index - 1].cells;
|
|
var cells = uniqueCells(rowPrevCells, comparator);
|
|
each$2(cells, function (cell) {
|
|
var replacement = Optional.none();
|
|
for (var i = index; i < rows.length; i++) {
|
|
var _loop_1 = function (j) {
|
|
var row = rows[i];
|
|
var current = getCell(row, j);
|
|
var isToReplace = comparator(current.element, cell.element);
|
|
if (isToReplace) {
|
|
if (replacement.isNone()) {
|
|
replacement = Optional.some(substitution());
|
|
}
|
|
replacement.each(function (sub) {
|
|
mutateCell(row, j, elementnew(sub, true, current.isLocked));
|
|
});
|
|
}
|
|
};
|
|
for (var j = 0; j < cellLength(rows[0]); j++) {
|
|
_loop_1(j);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return grid;
|
|
};
|
|
|
|
var value$1 = function (o) {
|
|
var or = function (_opt) {
|
|
return value$1(o);
|
|
};
|
|
var orThunk = function (_f) {
|
|
return value$1(o);
|
|
};
|
|
var map = function (f) {
|
|
return value$1(f(o));
|
|
};
|
|
var mapError = function (_f) {
|
|
return value$1(o);
|
|
};
|
|
var each = function (f) {
|
|
f(o);
|
|
};
|
|
var bind = function (f) {
|
|
return f(o);
|
|
};
|
|
var fold = function (_, onValue) {
|
|
return onValue(o);
|
|
};
|
|
var exists = function (f) {
|
|
return f(o);
|
|
};
|
|
var forall = function (f) {
|
|
return f(o);
|
|
};
|
|
var toOptional = function () {
|
|
return Optional.some(o);
|
|
};
|
|
return {
|
|
isValue: always,
|
|
isError: never,
|
|
getOr: constant(o),
|
|
getOrThunk: constant(o),
|
|
getOrDie: constant(o),
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: each,
|
|
bind: bind,
|
|
exists: exists,
|
|
forall: forall,
|
|
toOptional: toOptional
|
|
};
|
|
};
|
|
var error = function (message) {
|
|
var getOrThunk = function (f) {
|
|
return f();
|
|
};
|
|
var getOrDie = function () {
|
|
return die(String(message))();
|
|
};
|
|
var or = identity;
|
|
var orThunk = function (f) {
|
|
return f();
|
|
};
|
|
var map = function (_f) {
|
|
return error(message);
|
|
};
|
|
var mapError = function (f) {
|
|
return error(f(message));
|
|
};
|
|
var bind = function (_f) {
|
|
return error(message);
|
|
};
|
|
var fold = function (onError, _) {
|
|
return onError(message);
|
|
};
|
|
return {
|
|
isValue: never,
|
|
isError: always,
|
|
getOr: identity,
|
|
getOrThunk: getOrThunk,
|
|
getOrDie: getOrDie,
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: noop,
|
|
bind: bind,
|
|
exists: never,
|
|
forall: always,
|
|
toOptional: Optional.none
|
|
};
|
|
};
|
|
var fromOption = function (opt, err) {
|
|
return opt.fold(function () {
|
|
return error(err);
|
|
}, value$1);
|
|
};
|
|
var Result = {
|
|
value: value$1,
|
|
error: error,
|
|
fromOption: fromOption
|
|
};
|
|
|
|
var measure = function (startAddress, gridA, gridB) {
|
|
if (startAddress.row >= gridA.length || startAddress.column > cellLength(gridA[0])) {
|
|
return Result.error('invalid start address out of table bounds, row: ' + startAddress.row + ', column: ' + startAddress.column);
|
|
}
|
|
var rowRemainder = gridA.slice(startAddress.row);
|
|
var colRemainder = rowRemainder[0].cells.slice(startAddress.column);
|
|
var colRequired = cellLength(gridB[0]);
|
|
var rowRequired = gridB.length;
|
|
return Result.value({
|
|
rowDelta: rowRemainder.length - rowRequired,
|
|
colDelta: colRemainder.length - colRequired
|
|
});
|
|
};
|
|
var measureWidth = function (gridA, gridB) {
|
|
var colLengthA = cellLength(gridA[0]);
|
|
var colLengthB = cellLength(gridB[0]);
|
|
return {
|
|
rowDelta: 0,
|
|
colDelta: colLengthA - colLengthB
|
|
};
|
|
};
|
|
var measureHeight = function (gridA, gridB) {
|
|
var rowLengthA = gridA.length;
|
|
var rowLengthB = gridB.length;
|
|
return {
|
|
rowDelta: rowLengthA - rowLengthB,
|
|
colDelta: 0
|
|
};
|
|
};
|
|
var generateElements = function (amount, row, generators, isLocked) {
|
|
var generator = row.section === 'colgroup' ? generators.col : generators.cell;
|
|
return range$1(amount, function (idx) {
|
|
return elementnew(generator(), true, isLocked(idx));
|
|
});
|
|
};
|
|
var rowFill = function (grid, amount, generators, lockedColumns) {
|
|
var exampleRow = grid[grid.length - 1];
|
|
return grid.concat(range$1(amount, function () {
|
|
var generator = exampleRow.section === 'colgroup' ? generators.colgroup : generators.row;
|
|
var row = clone$1(exampleRow, generator, identity);
|
|
var elements = generateElements(row.cells.length, row, generators, function (idx) {
|
|
return has$1(lockedColumns, idx.toString());
|
|
});
|
|
return setCells(row, elements);
|
|
}));
|
|
};
|
|
var colFill = function (grid, amount, generators, startIndex) {
|
|
return map$1(grid, function (row) {
|
|
var newChildren = generateElements(amount, row, generators, never);
|
|
return addCells(row, startIndex, newChildren);
|
|
});
|
|
};
|
|
var lockedColFill = function (grid, generators, lockedColumns) {
|
|
return map$1(grid, function (row) {
|
|
return foldl(lockedColumns, function (acc, colNum) {
|
|
var newChild = generateElements(1, row, generators, always)[0];
|
|
return addCell(acc, colNum, newChild);
|
|
}, row);
|
|
});
|
|
};
|
|
var tailor = function (gridA, delta, generators) {
|
|
var fillCols = delta.colDelta < 0 ? colFill : identity;
|
|
var fillRows = delta.rowDelta < 0 ? rowFill : identity;
|
|
var lockedColumns = getLockedColumnsFromGrid(gridA);
|
|
var gridWidth = cellLength(gridA[0]);
|
|
var isLastColLocked = exists(lockedColumns, function (locked) {
|
|
return locked === gridWidth - 1;
|
|
});
|
|
var modifiedCols = fillCols(gridA, Math.abs(delta.colDelta), generators, isLastColLocked ? gridWidth - 1 : gridWidth);
|
|
var newLockedColumns = getLockedColumnsFromGrid(modifiedCols);
|
|
return fillRows(modifiedCols, Math.abs(delta.rowDelta), generators, mapToObject(newLockedColumns, always));
|
|
};
|
|
|
|
var isSpanning = function (grid, row, col, comparator) {
|
|
var candidate = getCell(grid[row], col);
|
|
var matching = curry(comparator, candidate.element);
|
|
var currentRow = grid[row];
|
|
return grid.length > 1 && cellLength(currentRow) > 1 && (col > 0 && matching(getCellElement(currentRow, col - 1)) || col < currentRow.cells.length - 1 && matching(getCellElement(currentRow, col + 1)) || row > 0 && matching(getCellElement(grid[row - 1], col)) || row < grid.length - 1 && matching(getCellElement(grid[row + 1], col)));
|
|
};
|
|
var mergeTables = function (startAddress, gridA, gridB, generator, comparator, lockedColumns) {
|
|
var startRow = startAddress.row;
|
|
var startCol = startAddress.column;
|
|
var mergeHeight = gridB.length;
|
|
var mergeWidth = cellLength(gridB[0]);
|
|
var endRow = startRow + mergeHeight;
|
|
var endCol = startCol + mergeWidth + lockedColumns.length;
|
|
var lockedColumnObj = mapToObject(lockedColumns, always);
|
|
for (var r = startRow; r < endRow; r++) {
|
|
var skippedCol = 0;
|
|
for (var c = startCol; c < endCol; c++) {
|
|
if (lockedColumnObj[c]) {
|
|
skippedCol++;
|
|
continue;
|
|
}
|
|
if (isSpanning(gridA, r, c, comparator)) {
|
|
unmerge(gridA, getCellElement(gridA[r], c), comparator, generator.cell);
|
|
}
|
|
var gridBColIndex = c - startCol - skippedCol;
|
|
var newCell = getCell(gridB[r - startRow], gridBColIndex);
|
|
var newCellElm = newCell.element;
|
|
var replacement = generator.replace(newCellElm);
|
|
mutateCell(gridA[r], c, elementnew(replacement, true, newCell.isLocked));
|
|
}
|
|
}
|
|
return gridA;
|
|
};
|
|
var getValidStartAddress = function (currentStartAddress, grid, lockedColumns) {
|
|
var gridColLength = cellLength(grid[0]);
|
|
var adjustedRowAddress = extractGridDetails(grid).cols.length + currentStartAddress.row;
|
|
var possibleColAddresses = range$1(gridColLength - currentStartAddress.column, function (num) {
|
|
return num + currentStartAddress.column;
|
|
});
|
|
var validColAddress = find$1(possibleColAddresses, function (num) {
|
|
return forall(lockedColumns, function (col) {
|
|
return col !== num;
|
|
});
|
|
}).getOr(gridColLength - 1);
|
|
return {
|
|
row: adjustedRowAddress,
|
|
column: validColAddress
|
|
};
|
|
};
|
|
var getLockedColumnsWithinBounds = function (startAddress, grid, lockedColumns) {
|
|
return filter$2(lockedColumns, function (colNum) {
|
|
return colNum >= startAddress.column && colNum <= cellLength(grid[0]) + startAddress.column;
|
|
});
|
|
};
|
|
var merge$1 = function (startAddress, gridA, gridB, generator, comparator) {
|
|
var lockedColumns = getLockedColumnsFromGrid(gridA);
|
|
var validStartAddress = getValidStartAddress(startAddress, gridA, lockedColumns);
|
|
var gridBRows = extractGridDetails(gridB).rows;
|
|
var lockedColumnsWithinBounds = getLockedColumnsWithinBounds(validStartAddress, gridBRows, lockedColumns);
|
|
var result = measure(validStartAddress, gridA, gridBRows);
|
|
return result.map(function (diff) {
|
|
var delta = __assign(__assign({}, diff), { colDelta: diff.colDelta - lockedColumnsWithinBounds.length });
|
|
var fittedGrid = tailor(gridA, delta, generator);
|
|
var newLockedColumns = getLockedColumnsFromGrid(fittedGrid);
|
|
var newLockedColumnsWithinBounds = getLockedColumnsWithinBounds(validStartAddress, gridBRows, newLockedColumns);
|
|
return mergeTables(validStartAddress, fittedGrid, gridBRows, generator, comparator, newLockedColumnsWithinBounds);
|
|
});
|
|
};
|
|
var insertCols = function (index, gridA, gridB, generator, comparator) {
|
|
splitCols(gridA, index, comparator, generator.cell);
|
|
var delta = measureHeight(gridB, gridA);
|
|
var fittedNewGrid = tailor(gridB, delta, generator);
|
|
var secondDelta = measureHeight(gridA, fittedNewGrid);
|
|
var fittedOldGrid = tailor(gridA, secondDelta, generator);
|
|
return map$1(fittedOldGrid, function (gridRow, i) {
|
|
return addCells(gridRow, index, fittedNewGrid[i].cells);
|
|
});
|
|
};
|
|
var insertRows = function (index, gridA, gridB, generator, comparator) {
|
|
splitRows(gridA, index, comparator, generator.cell);
|
|
var locked = getLockedColumnsFromGrid(gridA);
|
|
var diff = measureWidth(gridA, gridB);
|
|
var delta = __assign(__assign({}, diff), { colDelta: diff.colDelta - locked.length });
|
|
var fittedOldGrid = tailor(gridA, delta, generator);
|
|
var _a = extractGridDetails(fittedOldGrid), oldCols = _a.cols, oldRows = _a.rows;
|
|
var newLocked = getLockedColumnsFromGrid(fittedOldGrid);
|
|
var secondDiff = measureWidth(gridB, gridA);
|
|
var secondDelta = __assign(__assign({}, secondDiff), { colDelta: secondDiff.colDelta + newLocked.length });
|
|
var fittedGridB = lockedColFill(gridB, generator, newLocked);
|
|
var fittedNewGrid = tailor(fittedGridB, secondDelta, generator);
|
|
return oldCols.concat(oldRows.slice(0, index)).concat(fittedNewGrid).concat(oldRows.slice(index, oldRows.length));
|
|
};
|
|
|
|
var cloneRow = function (row, cloneCell, comparator, substitution) {
|
|
return clone$1(row, function (elem) {
|
|
return substitution(elem, comparator);
|
|
}, cloneCell);
|
|
};
|
|
var insertRowAt = function (grid, index, example, comparator, substitution) {
|
|
var _a = extractGridDetails(grid), rows = _a.rows, cols = _a.cols;
|
|
var before = rows.slice(0, index);
|
|
var after = rows.slice(index);
|
|
var newRow = cloneRow(rows[example], function (ex, c) {
|
|
var withinSpan = index > 0 && index < rows.length && comparator(getCellElement(rows[index - 1], c), getCellElement(rows[index], c));
|
|
var ret = withinSpan ? getCell(rows[index], c) : elementnew(substitution(ex.element, comparator), true, ex.isLocked);
|
|
return ret;
|
|
}, comparator, substitution);
|
|
return cols.concat(before).concat([newRow]).concat(after);
|
|
};
|
|
var getElementFor = function (row, column, section, withinSpan, example, comparator, substitution) {
|
|
if (section === 'colgroup' || !withinSpan) {
|
|
var cell = getCell(row, example);
|
|
return elementnew(substitution(cell.element, comparator), true, false);
|
|
} else {
|
|
return getCell(row, column);
|
|
}
|
|
};
|
|
var insertColumnAt = function (grid, index, example, comparator, substitution) {
|
|
return map$1(grid, function (row) {
|
|
var withinSpan = index > 0 && index < cellLength(row) && comparator(getCellElement(row, index - 1), getCellElement(row, index));
|
|
var sub = getElementFor(row, index, row.section, withinSpan, example, comparator, substitution);
|
|
return addCell(row, index, sub);
|
|
});
|
|
};
|
|
var deleteColumnsAt = function (grid, columns) {
|
|
return bind$2(grid, function (row) {
|
|
var existingCells = row.cells;
|
|
var cells = foldr(columns, function (acc, column) {
|
|
return column >= 0 && column < acc.length ? acc.slice(0, column).concat(acc.slice(column + 1)) : acc;
|
|
}, existingCells);
|
|
return cells.length > 0 ? [rowcells(row.element, cells, row.section, row.isNew)] : [];
|
|
});
|
|
};
|
|
var deleteRowsAt = function (grid, start, finish) {
|
|
var _a = extractGridDetails(grid), rows = _a.rows, cols = _a.cols;
|
|
return cols.concat(rows.slice(0, start)).concat(rows.slice(finish + 1));
|
|
};
|
|
|
|
var notInStartRow = function (grid, rowIndex, colIndex, comparator) {
|
|
return getCellElement(grid[rowIndex], colIndex) !== undefined && (rowIndex > 0 && comparator(getCellElement(grid[rowIndex - 1], colIndex), getCellElement(grid[rowIndex], colIndex)));
|
|
};
|
|
var notInStartColumn = function (row, index, comparator) {
|
|
return index > 0 && comparator(getCellElement(row, index - 1), getCellElement(row, index));
|
|
};
|
|
var isDuplicatedCell = function (grid, rowIndex, colIndex, comparator) {
|
|
return notInStartRow(grid, rowIndex, colIndex, comparator) || notInStartColumn(grid[rowIndex], colIndex, comparator);
|
|
};
|
|
var rowReplacerPredicate = function (targetRow, columnHeaders) {
|
|
var entireTableIsHeader = forall(columnHeaders, identity) && isHeaderCells(targetRow.cells);
|
|
return entireTableIsHeader ? always : function (cell, _rowIndex, colIndex) {
|
|
var type = name(cell.element);
|
|
return !(type === 'th' && columnHeaders[colIndex]);
|
|
};
|
|
};
|
|
var columnReplacePredicate = function (targetColumn, rowHeaders) {
|
|
var entireTableIsHeader = forall(rowHeaders, identity) && isHeaderCells(targetColumn);
|
|
return entireTableIsHeader ? always : function (cell, rowIndex, _colIndex) {
|
|
var type = name(cell.element);
|
|
return !(type === 'th' && rowHeaders[rowIndex]);
|
|
};
|
|
};
|
|
var determineScope = function (applyScope, element, newScope, isInHeader) {
|
|
var hasSpan = function (scope) {
|
|
return scope === 'row' ? hasRowspan(element) : hasColspan(element);
|
|
};
|
|
var getScope = function (scope) {
|
|
return hasSpan(scope) ? scope + 'group' : scope;
|
|
};
|
|
if (applyScope) {
|
|
return isHeaderCell(element) ? getScope(newScope) : null;
|
|
} else if (isInHeader && isHeaderCell(element)) {
|
|
var oppositeScope = newScope === 'row' ? 'col' : 'row';
|
|
return getScope(oppositeScope);
|
|
} else {
|
|
return null;
|
|
}
|
|
};
|
|
var rowScopeGenerator = function (applyScope, columnHeaders) {
|
|
return function (cell, rowIndex, columnIndex) {
|
|
return Optional.some(determineScope(applyScope, cell.element, 'col', columnHeaders[columnIndex]));
|
|
};
|
|
};
|
|
var columnScopeGenerator = function (applyScope, rowHeaders) {
|
|
return function (cell, rowIndex) {
|
|
return Optional.some(determineScope(applyScope, cell.element, 'row', rowHeaders[rowIndex]));
|
|
};
|
|
};
|
|
var replace = function (cell, comparator, substitute) {
|
|
return elementnew(substitute(cell.element, comparator), true, cell.isLocked);
|
|
};
|
|
var replaceIn = function (grid, targets, comparator, substitute, replacer, genScope, shouldReplace) {
|
|
var isTarget = function (cell) {
|
|
return exists(targets, function (target) {
|
|
return comparator(cell.element, target.element);
|
|
});
|
|
};
|
|
return map$1(grid, function (row, rowIndex) {
|
|
return mapCells(row, function (cell, colIndex) {
|
|
if (isTarget(cell)) {
|
|
var newCell_1 = shouldReplace(cell, rowIndex, colIndex) ? replacer(cell, comparator, substitute) : cell;
|
|
genScope(newCell_1, rowIndex, colIndex).each(function (scope) {
|
|
setOptions(newCell_1.element, { scope: Optional.from(scope) });
|
|
});
|
|
return newCell_1;
|
|
} else {
|
|
return cell;
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var getColumnCells = function (rows, columnIndex, comparator) {
|
|
return bind$2(rows, function (row, i) {
|
|
return isDuplicatedCell(rows, i, columnIndex, comparator) ? [] : [getCell(row, columnIndex)];
|
|
});
|
|
};
|
|
var getRowCells = function (rows, rowIndex, comparator) {
|
|
var targetRow = rows[rowIndex];
|
|
return bind$2(targetRow.cells, function (item, i) {
|
|
return isDuplicatedCell(rows, rowIndex, i, comparator) ? [] : [item];
|
|
});
|
|
};
|
|
var replaceColumns = function (grid, indexes, applyScope, comparator, substitution) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
var targets = bind$2(indexes, function (index) {
|
|
return getColumnCells(rows, index, comparator);
|
|
});
|
|
var rowHeaders = map$1(grid, function (row) {
|
|
return isHeaderCells(row.cells);
|
|
});
|
|
var shouldReplaceCell = columnReplacePredicate(targets, rowHeaders);
|
|
var scopeGenerator = columnScopeGenerator(applyScope, rowHeaders);
|
|
return replaceIn(grid, targets, comparator, substitution, replace, scopeGenerator, shouldReplaceCell);
|
|
};
|
|
var replaceRows = function (grid, indexes, section, applyScope, comparator, substitution, tableSection) {
|
|
var _a = extractGridDetails(grid), cols = _a.cols, rows = _a.rows;
|
|
var targetRow = rows[indexes[0]];
|
|
var targets = bind$2(indexes, function (index) {
|
|
return getRowCells(rows, index, comparator);
|
|
});
|
|
var columnHeaders = map$1(targetRow.cells, function (_cell, index) {
|
|
return isHeaderCells(getColumnCells(rows, index, comparator));
|
|
});
|
|
var newRows = __spreadArray([], rows, true);
|
|
each$2(indexes, function (index) {
|
|
newRows[index] = tableSection.transformRow(rows[index], section);
|
|
});
|
|
var newGrid = cols.concat(newRows);
|
|
var shouldReplaceCell = rowReplacerPredicate(targetRow, columnHeaders);
|
|
var scopeGenerator = rowScopeGenerator(applyScope, columnHeaders);
|
|
return replaceIn(newGrid, targets, comparator, substitution, tableSection.transformCell, scopeGenerator, shouldReplaceCell);
|
|
};
|
|
var replaceCells = function (grid, details, comparator, substitution) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
var targetCells = map$1(details, function (detail) {
|
|
return getCell(rows[detail.row], detail.column);
|
|
});
|
|
return replaceIn(grid, targetCells, comparator, substitution, replace, Optional.none, always);
|
|
};
|
|
|
|
var uniqueColumns = function (details) {
|
|
var uniqueCheck = function (rest, detail) {
|
|
var columnExists = exists(rest, function (currentDetail) {
|
|
return currentDetail.column === detail.column;
|
|
});
|
|
return columnExists ? rest : rest.concat([detail]);
|
|
};
|
|
return foldl(details, uniqueCheck, []).sort(function (detailA, detailB) {
|
|
return detailA.column - detailB.column;
|
|
});
|
|
};
|
|
|
|
var isCol = isTag('col');
|
|
var isColgroup = isTag('colgroup');
|
|
var isRow$1 = function (element) {
|
|
return name(element) === 'tr' || isColgroup(element);
|
|
};
|
|
var elementToData = function (element) {
|
|
var colspan = getAttrValue(element, 'colspan', 1);
|
|
var rowspan = getAttrValue(element, 'rowspan', 1);
|
|
return {
|
|
element: element,
|
|
colspan: colspan,
|
|
rowspan: rowspan
|
|
};
|
|
};
|
|
var modification = function (generators, toData) {
|
|
if (toData === void 0) {
|
|
toData = elementToData;
|
|
}
|
|
var nuCell = function (data) {
|
|
return isCol(data.element) ? generators.col(data) : generators.cell(data);
|
|
};
|
|
var nuRow = function (data) {
|
|
return isColgroup(data.element) ? generators.colgroup(data) : generators.row(data);
|
|
};
|
|
var add = function (element) {
|
|
if (isRow$1(element)) {
|
|
return nuRow({ element: element });
|
|
} else {
|
|
var replacement = nuCell(toData(element));
|
|
recent = Optional.some({
|
|
item: element,
|
|
replacement: replacement
|
|
});
|
|
return replacement;
|
|
}
|
|
};
|
|
var recent = Optional.none();
|
|
var getOrInit = function (element, comparator) {
|
|
return recent.fold(function () {
|
|
return add(element);
|
|
}, function (p) {
|
|
return comparator(element, p.item) ? p.replacement : add(element);
|
|
});
|
|
};
|
|
return { getOrInit: getOrInit };
|
|
};
|
|
var transform = function (tag) {
|
|
return function (generators) {
|
|
var list = [];
|
|
var find = function (element, comparator) {
|
|
return find$1(list, function (x) {
|
|
return comparator(x.item, element);
|
|
});
|
|
};
|
|
var makeNew = function (element) {
|
|
var attrs = tag === 'td' ? { scope: null } : {};
|
|
var cell = generators.replace(element, tag, attrs);
|
|
list.push({
|
|
item: element,
|
|
sub: cell
|
|
});
|
|
return cell;
|
|
};
|
|
var replaceOrInit = function (element, comparator) {
|
|
if (isRow$1(element) || isCol(element)) {
|
|
return element;
|
|
} else {
|
|
return find(element, comparator).fold(function () {
|
|
return makeNew(element);
|
|
}, function (p) {
|
|
return comparator(element, p.item) ? p.sub : makeNew(element);
|
|
});
|
|
}
|
|
};
|
|
return { replaceOrInit: replaceOrInit };
|
|
};
|
|
};
|
|
var getScopeAttribute = function (cell) {
|
|
return getOpt(cell, 'scope').map(function (attribute) {
|
|
return attribute.substr(0, 3);
|
|
});
|
|
};
|
|
var merging = function (generators) {
|
|
var unmerge = function (cell) {
|
|
var scope = getScopeAttribute(cell);
|
|
scope.each(function (attribute) {
|
|
return set$2(cell, 'scope', attribute);
|
|
});
|
|
return function () {
|
|
var raw = generators.cell({
|
|
element: cell,
|
|
colspan: 1,
|
|
rowspan: 1
|
|
});
|
|
remove$6(raw, 'width');
|
|
remove$6(cell, 'width');
|
|
scope.each(function (attribute) {
|
|
return set$2(raw, 'scope', attribute);
|
|
});
|
|
return raw;
|
|
};
|
|
};
|
|
var merge = function (cells) {
|
|
var getScopeProperty = function () {
|
|
var stringAttributes = cat(map$1(cells, getScopeAttribute));
|
|
if (stringAttributes.length === 0) {
|
|
return Optional.none();
|
|
} else {
|
|
var baseScope_1 = stringAttributes[0];
|
|
var scopes_1 = [
|
|
'row',
|
|
'col'
|
|
];
|
|
var isMixed = exists(stringAttributes, function (attribute) {
|
|
return attribute !== baseScope_1 && contains$2(scopes_1, attribute);
|
|
});
|
|
return isMixed ? Optional.none() : Optional.from(baseScope_1);
|
|
}
|
|
};
|
|
remove$6(cells[0], 'width');
|
|
getScopeProperty().fold(function () {
|
|
return remove$7(cells[0], 'scope');
|
|
}, function (attribute) {
|
|
return set$2(cells[0], 'scope', attribute + 'group');
|
|
});
|
|
return constant(cells[0]);
|
|
};
|
|
return {
|
|
unmerge: unmerge,
|
|
merge: merge
|
|
};
|
|
};
|
|
var Generators = {
|
|
modification: modification,
|
|
transform: transform,
|
|
merging: merging
|
|
};
|
|
|
|
var blockList = [
|
|
'body',
|
|
'p',
|
|
'div',
|
|
'article',
|
|
'aside',
|
|
'figcaption',
|
|
'figure',
|
|
'footer',
|
|
'header',
|
|
'nav',
|
|
'section',
|
|
'ol',
|
|
'ul',
|
|
'table',
|
|
'thead',
|
|
'tfoot',
|
|
'tbody',
|
|
'caption',
|
|
'tr',
|
|
'td',
|
|
'th',
|
|
'h1',
|
|
'h2',
|
|
'h3',
|
|
'h4',
|
|
'h5',
|
|
'h6',
|
|
'blockquote',
|
|
'pre',
|
|
'address'
|
|
];
|
|
var isList$1 = function (universe, item) {
|
|
var tagName = universe.property().name(item);
|
|
return contains$2([
|
|
'ol',
|
|
'ul'
|
|
], tagName);
|
|
};
|
|
var isBlock$1 = function (universe, item) {
|
|
var tagName = universe.property().name(item);
|
|
return contains$2(blockList, tagName);
|
|
};
|
|
var isEmptyTag$1 = function (universe, item) {
|
|
return contains$2([
|
|
'br',
|
|
'img',
|
|
'hr',
|
|
'input'
|
|
], universe.property().name(item));
|
|
};
|
|
|
|
var universe$1 = DomUniverse();
|
|
var isBlock = function (element) {
|
|
return isBlock$1(universe$1, element);
|
|
};
|
|
var isList = function (element) {
|
|
return isList$1(universe$1, element);
|
|
};
|
|
var isEmptyTag = function (element) {
|
|
return isEmptyTag$1(universe$1, element);
|
|
};
|
|
|
|
var merge = function (cells) {
|
|
var isBr = function (el) {
|
|
return name(el) === 'br';
|
|
};
|
|
var advancedBr = function (children) {
|
|
return forall(children, function (c) {
|
|
return isBr(c) || isText(c) && get$9(c).trim().length === 0;
|
|
});
|
|
};
|
|
var isListItem = function (el) {
|
|
return name(el) === 'li' || ancestor$2(el, isList).isSome();
|
|
};
|
|
var siblingIsBlock = function (el) {
|
|
return nextSibling(el).map(function (rightSibling) {
|
|
if (isBlock(rightSibling)) {
|
|
return true;
|
|
}
|
|
if (isEmptyTag(rightSibling)) {
|
|
return name(rightSibling) === 'img' ? false : true;
|
|
}
|
|
return false;
|
|
}).getOr(false);
|
|
};
|
|
var markCell = function (cell) {
|
|
return last$1(cell).bind(function (rightEdge) {
|
|
var rightSiblingIsBlock = siblingIsBlock(rightEdge);
|
|
return parent(rightEdge).map(function (parent) {
|
|
return rightSiblingIsBlock === true || isListItem(parent) || isBr(rightEdge) || isBlock(parent) && !eq$1(cell, parent) ? [] : [SugarElement.fromTag('br')];
|
|
});
|
|
}).getOr([]);
|
|
};
|
|
var markContent = function () {
|
|
var content = bind$2(cells, function (cell) {
|
|
var children = children$3(cell);
|
|
return advancedBr(children) ? [] : children.concat(markCell(cell));
|
|
});
|
|
return content.length === 0 ? [SugarElement.fromTag('br')] : content;
|
|
};
|
|
var contents = markContent();
|
|
empty(cells[0]);
|
|
append(cells[0], contents);
|
|
};
|
|
|
|
var isEditable = function (elem) {
|
|
return isEditable$1(elem, true);
|
|
};
|
|
var prune = function (table) {
|
|
var cells = cells$1(table);
|
|
if (cells.length === 0) {
|
|
remove$5(table);
|
|
}
|
|
};
|
|
var outcome = function (grid, cursor) {
|
|
return {
|
|
grid: grid,
|
|
cursor: cursor
|
|
};
|
|
};
|
|
var findEditableCursorPosition = function (rows) {
|
|
return findMap(rows, function (row) {
|
|
return findMap(row.cells, function (cell) {
|
|
var elem = cell.element;
|
|
return someIf(isEditable(elem), elem);
|
|
});
|
|
});
|
|
};
|
|
var elementFromGrid = function (grid, row, column) {
|
|
var _a, _b;
|
|
var rows = extractGridDetails(grid).rows;
|
|
return Optional.from((_b = (_a = rows[row]) === null || _a === void 0 ? void 0 : _a.cells[column]) === null || _b === void 0 ? void 0 : _b.element).filter(isEditable).orThunk(function () {
|
|
return findEditableCursorPosition(rows);
|
|
});
|
|
};
|
|
var bundle = function (grid, row, column) {
|
|
var cursorElement = elementFromGrid(grid, row, column);
|
|
return outcome(grid, cursorElement);
|
|
};
|
|
var uniqueRows = function (details) {
|
|
var rowCompilation = function (rest, detail) {
|
|
var rowExists = exists(rest, function (currentDetail) {
|
|
return currentDetail.row === detail.row;
|
|
});
|
|
return rowExists ? rest : rest.concat([detail]);
|
|
};
|
|
return foldl(details, rowCompilation, []).sort(function (detailA, detailB) {
|
|
return detailA.row - detailB.row;
|
|
});
|
|
};
|
|
var opInsertRowsBefore = function (grid, details, comparator, genWrappers) {
|
|
var targetIndex = details[0].row;
|
|
var rows = uniqueRows(details);
|
|
var newGrid = foldr(rows, function (acc, row) {
|
|
var newG = insertRowAt(acc.grid, targetIndex, row.row + acc.delta, comparator, genWrappers.getOrInit);
|
|
return {
|
|
grid: newG,
|
|
delta: acc.delta + 1
|
|
};
|
|
}, {
|
|
grid: grid,
|
|
delta: 0
|
|
}).grid;
|
|
return bundle(newGrid, targetIndex, details[0].column);
|
|
};
|
|
var opInsertRowsAfter = function (grid, details, comparator, genWrappers) {
|
|
var rows = uniqueRows(details);
|
|
var target = rows[rows.length - 1];
|
|
var targetIndex = target.row + target.rowspan;
|
|
var newGrid = foldr(rows, function (newG, row) {
|
|
return insertRowAt(newG, targetIndex, row.row, comparator, genWrappers.getOrInit);
|
|
}, grid);
|
|
return bundle(newGrid, targetIndex, details[0].column);
|
|
};
|
|
var opInsertColumnsBefore = function (grid, extractDetail, comparator, genWrappers) {
|
|
var details = extractDetail.details;
|
|
var columns = uniqueColumns(details);
|
|
var targetIndex = columns[0].column;
|
|
var newGrid = foldr(columns, function (acc, col) {
|
|
var newG = insertColumnAt(acc.grid, targetIndex, col.column + acc.delta, comparator, genWrappers.getOrInit);
|
|
return {
|
|
grid: newG,
|
|
delta: acc.delta + 1
|
|
};
|
|
}, {
|
|
grid: grid,
|
|
delta: 0
|
|
}).grid;
|
|
return bundle(newGrid, details[0].row, targetIndex);
|
|
};
|
|
var opInsertColumnsAfter = function (grid, extractDetail, comparator, genWrappers) {
|
|
var details = extractDetail.details;
|
|
var target = details[details.length - 1];
|
|
var targetIndex = target.column + target.colspan;
|
|
var columns = uniqueColumns(details);
|
|
var newGrid = foldr(columns, function (newG, col) {
|
|
return insertColumnAt(newG, targetIndex, col.column, comparator, genWrappers.getOrInit);
|
|
}, grid);
|
|
return bundle(newGrid, details[0].row, targetIndex);
|
|
};
|
|
var opMakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) {
|
|
var columns = uniqueColumns(details);
|
|
var columnIndexes = map$1(columns, function (detail) {
|
|
return detail.column;
|
|
});
|
|
var newGrid = replaceColumns(initialGrid, columnIndexes, true, comparator, genWrappers.replaceOrInit);
|
|
return bundle(newGrid, details[0].row, details[0].column);
|
|
};
|
|
var opMakeCellsHeader = function (initialGrid, details, comparator, genWrappers) {
|
|
var newGrid = replaceCells(initialGrid, details, comparator, genWrappers.replaceOrInit);
|
|
return bundle(newGrid, details[0].row, details[0].column);
|
|
};
|
|
var opUnmakeColumnsHeader = function (initialGrid, details, comparator, genWrappers) {
|
|
var columns = uniqueColumns(details);
|
|
var columnIndexes = map$1(columns, function (detail) {
|
|
return detail.column;
|
|
});
|
|
var newGrid = replaceColumns(initialGrid, columnIndexes, false, comparator, genWrappers.replaceOrInit);
|
|
return bundle(newGrid, details[0].row, details[0].column);
|
|
};
|
|
var opUnmakeCellsHeader = function (initialGrid, details, comparator, genWrappers) {
|
|
var newGrid = replaceCells(initialGrid, details, comparator, genWrappers.replaceOrInit);
|
|
return bundle(newGrid, details[0].row, details[0].column);
|
|
};
|
|
var makeRowsSection = function (section, applyScope) {
|
|
return function (initialGrid, details, comparator, genWrappers, tableSection) {
|
|
var rows = uniqueRows(details);
|
|
var rowIndexes = map$1(rows, function (detail) {
|
|
return detail.row;
|
|
});
|
|
var newGrid = replaceRows(initialGrid, rowIndexes, section, applyScope, comparator, genWrappers.replaceOrInit, tableSection);
|
|
return bundle(newGrid, details[0].row, details[0].column);
|
|
};
|
|
};
|
|
var opMakeRowsHeader = makeRowsSection('thead', true);
|
|
var opMakeRowsBody = makeRowsSection('tbody', false);
|
|
var opMakeRowsFooter = makeRowsSection('tfoot', false);
|
|
var opEraseColumns = function (grid, extractDetail, _comparator, _genWrappers) {
|
|
var columns = uniqueColumns(extractDetail.details);
|
|
var newGrid = deleteColumnsAt(grid, map$1(columns, function (column) {
|
|
return column.column;
|
|
}));
|
|
var maxColIndex = newGrid.length > 0 ? newGrid[0].cells.length - 1 : 0;
|
|
return bundle(newGrid, columns[0].row, Math.min(columns[0].column, maxColIndex));
|
|
};
|
|
var opEraseRows = function (grid, details, _comparator, _genWrappers) {
|
|
var rows = uniqueRows(details);
|
|
var newGrid = deleteRowsAt(grid, rows[0].row, rows[rows.length - 1].row);
|
|
var maxRowIndex = newGrid.length > 0 ? newGrid.length - 1 : 0;
|
|
return bundle(newGrid, Math.min(details[0].row, maxRowIndex), details[0].column);
|
|
};
|
|
var opMergeCells = function (grid, mergable, comparator, genWrappers) {
|
|
var cells = mergable.cells;
|
|
merge(cells);
|
|
var newGrid = merge$2(grid, mergable.bounds, comparator, genWrappers.merge(cells));
|
|
return outcome(newGrid, Optional.from(cells[0]));
|
|
};
|
|
var opUnmergeCells = function (grid, unmergable, comparator, genWrappers) {
|
|
var unmerge$1 = function (b, cell) {
|
|
return unmerge(b, cell, comparator, genWrappers.unmerge(cell));
|
|
};
|
|
var newGrid = foldr(unmergable, unmerge$1, grid);
|
|
return outcome(newGrid, Optional.from(unmergable[0]));
|
|
};
|
|
var opPasteCells = function (grid, pasteDetails, comparator, _genWrappers) {
|
|
var gridify = function (table, generators) {
|
|
var wh = Warehouse.fromTable(table);
|
|
return toGrid(wh, generators, true);
|
|
};
|
|
var gridB = gridify(pasteDetails.clipboard, pasteDetails.generators);
|
|
var startAddress = address(pasteDetails.row, pasteDetails.column);
|
|
var mergedGrid = merge$1(startAddress, grid, gridB, pasteDetails.generators, comparator);
|
|
return mergedGrid.fold(function () {
|
|
return outcome(grid, Optional.some(pasteDetails.element));
|
|
}, function (newGrid) {
|
|
return bundle(newGrid, pasteDetails.row, pasteDetails.column);
|
|
});
|
|
};
|
|
var gridifyRows = function (rows, generators, context) {
|
|
var pasteDetails = fromPastedRows(rows, context.section);
|
|
var wh = Warehouse.generate(pasteDetails);
|
|
return toGrid(wh, generators, true);
|
|
};
|
|
var opPasteColsBefore = function (grid, pasteDetails, comparator, _genWrappers) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
var index = pasteDetails.cells[0].column;
|
|
var context = rows[pasteDetails.cells[0].row];
|
|
var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
|
|
var mergedGrid = insertCols(index, grid, gridB, pasteDetails.generators, comparator);
|
|
return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column);
|
|
};
|
|
var opPasteColsAfter = function (grid, pasteDetails, comparator, _genWrappers) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
var index = pasteDetails.cells[pasteDetails.cells.length - 1].column + pasteDetails.cells[pasteDetails.cells.length - 1].colspan;
|
|
var context = rows[pasteDetails.cells[0].row];
|
|
var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
|
|
var mergedGrid = insertCols(index, grid, gridB, pasteDetails.generators, comparator);
|
|
return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column);
|
|
};
|
|
var opPasteRowsBefore = function (grid, pasteDetails, comparator, _genWrappers) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
var index = pasteDetails.cells[0].row;
|
|
var context = rows[index];
|
|
var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
|
|
var mergedGrid = insertRows(index, grid, gridB, pasteDetails.generators, comparator);
|
|
return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column);
|
|
};
|
|
var opPasteRowsAfter = function (grid, pasteDetails, comparator, _genWrappers) {
|
|
var rows = extractGridDetails(grid).rows;
|
|
var index = pasteDetails.cells[pasteDetails.cells.length - 1].row + pasteDetails.cells[pasteDetails.cells.length - 1].rowspan;
|
|
var context = rows[pasteDetails.cells[0].row];
|
|
var gridB = gridifyRows(pasteDetails.clipboard, pasteDetails.generators, context);
|
|
var mergedGrid = insertRows(index, grid, gridB, pasteDetails.generators, comparator);
|
|
return bundle(mergedGrid, pasteDetails.cells[0].row, pasteDetails.cells[0].column);
|
|
};
|
|
var opGetColumnsType = function (table, target) {
|
|
var house = Warehouse.fromTable(table);
|
|
var details = onCells(house, target);
|
|
return details.bind(function (selectedCells) {
|
|
var lastSelectedCell = selectedCells[selectedCells.length - 1];
|
|
var minColRange = selectedCells[0].column;
|
|
var maxColRange = lastSelectedCell.column + lastSelectedCell.colspan;
|
|
var selectedColumnCells = flatten$1(map$1(house.all, function (row) {
|
|
return filter$2(row.cells, function (cell) {
|
|
return cell.column >= minColRange && cell.column < maxColRange;
|
|
});
|
|
}));
|
|
return findCommonCellType(selectedColumnCells);
|
|
}).getOr('');
|
|
};
|
|
var opGetCellsType = function (table, target) {
|
|
var house = Warehouse.fromTable(table);
|
|
var details = onCells(house, target);
|
|
return details.bind(findCommonCellType).getOr('');
|
|
};
|
|
var opGetRowsType = function (table, target) {
|
|
var house = Warehouse.fromTable(table);
|
|
var details = onCells(house, target);
|
|
return details.bind(function (selectedCells) {
|
|
var lastSelectedCell = selectedCells[selectedCells.length - 1];
|
|
var minRowRange = selectedCells[0].row;
|
|
var maxRowRange = lastSelectedCell.row + lastSelectedCell.rowspan;
|
|
var selectedRows = house.all.slice(minRowRange, maxRowRange);
|
|
return findCommonRowType(selectedRows);
|
|
}).getOr('');
|
|
};
|
|
var resize = function (table, list, details, behaviours) {
|
|
return adjustWidthTo(table, list, details, behaviours.sizing);
|
|
};
|
|
var adjustAndRedistributeWidths = function (table, list, details, behaviours) {
|
|
return adjustAndRedistributeWidths$1(table, list, details, behaviours.sizing, behaviours.resize);
|
|
};
|
|
var firstColumnIsLocked = function (_warehouse, details) {
|
|
return exists(details, function (detail) {
|
|
return detail.column === 0 && detail.isLocked;
|
|
});
|
|
};
|
|
var lastColumnIsLocked = function (warehouse, details) {
|
|
return exists(details, function (detail) {
|
|
return detail.column + detail.colspan >= warehouse.grid.columns && detail.isLocked;
|
|
});
|
|
};
|
|
var getColumnsWidth = function (warehouse, details) {
|
|
var columns$1 = columns(warehouse);
|
|
var uniqueCols = uniqueColumns(details);
|
|
return foldl(uniqueCols, function (acc, detail) {
|
|
var column = columns$1[detail.column];
|
|
var colWidth = column.map(getOuter$2).getOr(0);
|
|
return acc + colWidth;
|
|
}, 0);
|
|
};
|
|
var insertColumnsExtractor = function (before) {
|
|
return function (warehouse, target) {
|
|
return onCells(warehouse, target).filter(function (details) {
|
|
var checkLocked = before ? firstColumnIsLocked : lastColumnIsLocked;
|
|
return !checkLocked(warehouse, details);
|
|
}).map(function (details) {
|
|
return {
|
|
details: details,
|
|
pixelDelta: getColumnsWidth(warehouse, details)
|
|
};
|
|
});
|
|
};
|
|
};
|
|
var eraseColumnsExtractor = function (warehouse, target) {
|
|
return onUnlockedCells(warehouse, target).map(function (details) {
|
|
return {
|
|
details: details,
|
|
pixelDelta: -getColumnsWidth(warehouse, details)
|
|
};
|
|
});
|
|
};
|
|
var pasteColumnsExtractor = function (before) {
|
|
return function (warehouse, target) {
|
|
return onPasteByEditor(warehouse, target).filter(function (details) {
|
|
var checkLocked = before ? firstColumnIsLocked : lastColumnIsLocked;
|
|
return !checkLocked(warehouse, details.cells);
|
|
});
|
|
};
|
|
};
|
|
var headerCellGenerator = Generators.transform('th');
|
|
var bodyCellGenerator = Generators.transform('td');
|
|
var insertRowsBefore = run(opInsertRowsBefore, onCells, noop, noop, Generators.modification);
|
|
var insertRowsAfter = run(opInsertRowsAfter, onCells, noop, noop, Generators.modification);
|
|
var insertColumnsBefore = run(opInsertColumnsBefore, insertColumnsExtractor(true), adjustAndRedistributeWidths, noop, Generators.modification);
|
|
var insertColumnsAfter = run(opInsertColumnsAfter, insertColumnsExtractor(false), adjustAndRedistributeWidths, noop, Generators.modification);
|
|
var eraseColumns = run(opEraseColumns, eraseColumnsExtractor, adjustAndRedistributeWidths, prune, Generators.modification);
|
|
var eraseRows = run(opEraseRows, onCells, noop, prune, Generators.modification);
|
|
var makeColumnsHeader = run(opMakeColumnsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
|
|
var unmakeColumnsHeader = run(opUnmakeColumnsHeader, onUnlockedCells, noop, noop, bodyCellGenerator);
|
|
var makeRowsHeader = run(opMakeRowsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
|
|
var makeRowsBody = run(opMakeRowsBody, onUnlockedCells, noop, noop, bodyCellGenerator);
|
|
var makeRowsFooter = run(opMakeRowsFooter, onUnlockedCells, noop, noop, bodyCellGenerator);
|
|
var makeCellsHeader = run(opMakeCellsHeader, onUnlockedCells, noop, noop, headerCellGenerator);
|
|
var unmakeCellsHeader = run(opUnmakeCellsHeader, onUnlockedCells, noop, noop, bodyCellGenerator);
|
|
var mergeCells = run(opMergeCells, onUnlockedMergable, resize, noop, Generators.merging);
|
|
var unmergeCells = run(opUnmergeCells, onUnlockedUnmergable, resize, noop, Generators.merging);
|
|
var pasteCells = run(opPasteCells, onPaste, resize, noop, Generators.modification);
|
|
var pasteColsBefore = run(opPasteColsBefore, pasteColumnsExtractor(true), noop, noop, Generators.modification);
|
|
var pasteColsAfter = run(opPasteColsAfter, pasteColumnsExtractor(false), noop, noop, Generators.modification);
|
|
var pasteRowsBefore = run(opPasteRowsBefore, onPasteByEditor, noop, noop, Generators.modification);
|
|
var pasteRowsAfter = run(opPasteRowsAfter, onPasteByEditor, noop, noop, Generators.modification);
|
|
var getColumnsType = opGetColumnsType;
|
|
var getCellsType = opGetCellsType;
|
|
var getRowsType = opGetRowsType;
|
|
|
|
var TableActions = function (editor, cellSelection, lazyWire) {
|
|
var isTableBody = function (editor) {
|
|
return name(getBody(editor)) === 'table';
|
|
};
|
|
var lastRowGuard = function (table) {
|
|
return isTableBody(editor) === false || getGridSize(table).rows > 1;
|
|
};
|
|
var lastColumnGuard = function (table) {
|
|
return isTableBody(editor) === false || getGridSize(table).columns > 1;
|
|
};
|
|
var cloneFormats = getCloneElements(editor);
|
|
var colMutationOp = isResizeTableColumnResizing(editor) ? noop : halve;
|
|
var getTableSectionType = function (table) {
|
|
switch (getTableHeaderType(editor)) {
|
|
case 'section':
|
|
return TableSection.section();
|
|
case 'sectionCells':
|
|
return TableSection.sectionCells();
|
|
case 'cells':
|
|
return TableSection.cells();
|
|
default:
|
|
return TableSection.getTableSectionType(table, 'section');
|
|
}
|
|
};
|
|
var setSelectionFromAction = function (table, result) {
|
|
return result.cursor.fold(function () {
|
|
var cells = cells$1(table);
|
|
return head(cells).filter(inBody).map(function (firstCell) {
|
|
cellSelection.clear(table);
|
|
var rng = editor.dom.createRng();
|
|
rng.selectNode(firstCell.dom);
|
|
editor.selection.setRng(rng);
|
|
set$2(firstCell, 'data-mce-selected', '1');
|
|
return rng;
|
|
});
|
|
}, function (cell) {
|
|
var des = freefallRtl(cell);
|
|
var rng = editor.dom.createRng();
|
|
rng.setStart(des.element.dom, des.offset);
|
|
rng.setEnd(des.element.dom, des.offset);
|
|
editor.selection.setRng(rng);
|
|
cellSelection.clear(table);
|
|
return Optional.some(rng);
|
|
});
|
|
};
|
|
var execute = function (operation, guard, mutate, lazyWire, effect) {
|
|
return function (table, target, noEvents) {
|
|
if (noEvents === void 0) {
|
|
noEvents = false;
|
|
}
|
|
removeDataStyle(table);
|
|
var wire = lazyWire();
|
|
var doc = SugarElement.fromDom(editor.getDoc());
|
|
var generators = cellOperations(mutate, doc, cloneFormats);
|
|
var behaviours = {
|
|
sizing: get$4(editor, table),
|
|
resize: isResizeTableColumnResizing(editor) ? resizeTable() : preserveTable(),
|
|
section: getTableSectionType(table)
|
|
};
|
|
return guard(table) ? operation(wire, table, target, generators, behaviours).bind(function (result) {
|
|
each$2(result.newRows, function (row) {
|
|
fireNewRow(editor, row.dom);
|
|
});
|
|
each$2(result.newCells, function (cell) {
|
|
fireNewCell(editor, cell.dom);
|
|
});
|
|
var range = setSelectionFromAction(table, result);
|
|
if (inBody(table)) {
|
|
removeDataStyle(table);
|
|
if (!noEvents) {
|
|
fireTableModified(editor, table.dom, effect);
|
|
}
|
|
}
|
|
return range.map(function (rng) {
|
|
return {
|
|
rng: rng,
|
|
effect: effect
|
|
};
|
|
});
|
|
}) : Optional.none();
|
|
};
|
|
};
|
|
var deleteRow = execute(eraseRows, lastRowGuard, noop, lazyWire, structureModified);
|
|
var deleteColumn = execute(eraseColumns, lastColumnGuard, noop, lazyWire, structureModified);
|
|
var insertRowsBefore$1 = execute(insertRowsBefore, always, noop, lazyWire, structureModified);
|
|
var insertRowsAfter$1 = execute(insertRowsAfter, always, noop, lazyWire, structureModified);
|
|
var insertColumnsBefore$1 = execute(insertColumnsBefore, always, colMutationOp, lazyWire, structureModified);
|
|
var insertColumnsAfter$1 = execute(insertColumnsAfter, always, colMutationOp, lazyWire, structureModified);
|
|
var mergeCells$1 = execute(mergeCells, always, noop, lazyWire, structureModified);
|
|
var unmergeCells$1 = execute(unmergeCells, always, noop, lazyWire, structureModified);
|
|
var pasteColsBefore$1 = execute(pasteColsBefore, always, noop, lazyWire, structureModified);
|
|
var pasteColsAfter$1 = execute(pasteColsAfter, always, noop, lazyWire, structureModified);
|
|
var pasteRowsBefore$1 = execute(pasteRowsBefore, always, noop, lazyWire, structureModified);
|
|
var pasteRowsAfter$1 = execute(pasteRowsAfter, always, noop, lazyWire, structureModified);
|
|
var pasteCells$1 = execute(pasteCells, always, noop, lazyWire, styleAndStructureModified);
|
|
var makeCellsHeader$1 = execute(makeCellsHeader, always, noop, lazyWire, structureModified);
|
|
var unmakeCellsHeader$1 = execute(unmakeCellsHeader, always, noop, lazyWire, structureModified);
|
|
var makeColumnsHeader$1 = execute(makeColumnsHeader, always, noop, lazyWire, structureModified);
|
|
var unmakeColumnsHeader$1 = execute(unmakeColumnsHeader, always, noop, lazyWire, structureModified);
|
|
var makeRowsHeader$1 = execute(makeRowsHeader, always, noop, lazyWire, structureModified);
|
|
var makeRowsBody$1 = execute(makeRowsBody, always, noop, lazyWire, structureModified);
|
|
var makeRowsFooter$1 = execute(makeRowsFooter, always, noop, lazyWire, structureModified);
|
|
var getTableCellType = getCellsType;
|
|
var getTableColType = getColumnsType;
|
|
var getTableRowType = getRowsType;
|
|
return {
|
|
deleteRow: deleteRow,
|
|
deleteColumn: deleteColumn,
|
|
insertRowsBefore: insertRowsBefore$1,
|
|
insertRowsAfter: insertRowsAfter$1,
|
|
insertColumnsBefore: insertColumnsBefore$1,
|
|
insertColumnsAfter: insertColumnsAfter$1,
|
|
mergeCells: mergeCells$1,
|
|
unmergeCells: unmergeCells$1,
|
|
pasteColsBefore: pasteColsBefore$1,
|
|
pasteColsAfter: pasteColsAfter$1,
|
|
pasteRowsBefore: pasteRowsBefore$1,
|
|
pasteRowsAfter: pasteRowsAfter$1,
|
|
pasteCells: pasteCells$1,
|
|
makeCellsHeader: makeCellsHeader$1,
|
|
unmakeCellsHeader: unmakeCellsHeader$1,
|
|
makeColumnsHeader: makeColumnsHeader$1,
|
|
unmakeColumnsHeader: unmakeColumnsHeader$1,
|
|
makeRowsHeader: makeRowsHeader$1,
|
|
makeRowsBody: makeRowsBody$1,
|
|
makeRowsFooter: makeRowsFooter$1,
|
|
getTableRowType: getTableRowType,
|
|
getTableCellType: getTableCellType,
|
|
getTableColType: getTableColType
|
|
};
|
|
};
|
|
|
|
var DefaultRenderOptions = {
|
|
styles: {
|
|
'border-collapse': 'collapse',
|
|
'width': '100%'
|
|
},
|
|
attributes: { border: '1' },
|
|
colGroups: false
|
|
};
|
|
var tableHeaderCell = function () {
|
|
return SugarElement.fromTag('th');
|
|
};
|
|
var tableCell = function () {
|
|
return SugarElement.fromTag('td');
|
|
};
|
|
var tableColumn = function () {
|
|
return SugarElement.fromTag('col');
|
|
};
|
|
var createRow = function (columns, rowHeaders, columnHeaders, rowIndex) {
|
|
var tr = SugarElement.fromTag('tr');
|
|
for (var j = 0; j < columns; j++) {
|
|
var td = rowIndex < rowHeaders || j < columnHeaders ? tableHeaderCell() : tableCell();
|
|
if (j < columnHeaders) {
|
|
set$2(td, 'scope', 'row');
|
|
}
|
|
if (rowIndex < rowHeaders) {
|
|
set$2(td, 'scope', 'col');
|
|
}
|
|
append$1(td, SugarElement.fromTag('br'));
|
|
append$1(tr, td);
|
|
}
|
|
return tr;
|
|
};
|
|
var createGroupRow = function (columns) {
|
|
var columnGroup = SugarElement.fromTag('colgroup');
|
|
range$1(columns, function () {
|
|
return append$1(columnGroup, tableColumn());
|
|
});
|
|
return columnGroup;
|
|
};
|
|
var createRows = function (rows, columns, rowHeaders, columnHeaders) {
|
|
return range$1(rows, function (r) {
|
|
return createRow(columns, rowHeaders, columnHeaders, r);
|
|
});
|
|
};
|
|
var render = function (rows, columns, rowHeaders, columnHeaders, headerType, renderOpts) {
|
|
if (renderOpts === void 0) {
|
|
renderOpts = DefaultRenderOptions;
|
|
}
|
|
var table = SugarElement.fromTag('table');
|
|
var rowHeadersGoInThead = headerType !== 'cells';
|
|
setAll(table, renderOpts.styles);
|
|
setAll$1(table, renderOpts.attributes);
|
|
if (renderOpts.colGroups) {
|
|
append$1(table, createGroupRow(columns));
|
|
}
|
|
var actualRowHeaders = Math.min(rows, rowHeaders);
|
|
if (rowHeadersGoInThead && rowHeaders > 0) {
|
|
var thead = SugarElement.fromTag('thead');
|
|
append$1(table, thead);
|
|
var theadRowHeaders = headerType === 'sectionCells' ? actualRowHeaders : 0;
|
|
var theadRows = createRows(rowHeaders, columns, theadRowHeaders, columnHeaders);
|
|
append(thead, theadRows);
|
|
}
|
|
var tbody = SugarElement.fromTag('tbody');
|
|
append$1(table, tbody);
|
|
var numRows = rowHeadersGoInThead ? rows - actualRowHeaders : rows;
|
|
var numRowHeaders = rowHeadersGoInThead ? 0 : rowHeaders;
|
|
var tbodyRows = createRows(numRows, columns, numRowHeaders, columnHeaders);
|
|
append(tbody, tbodyRows);
|
|
return table;
|
|
};
|
|
|
|
var get$2 = function (element) {
|
|
return element.dom.innerHTML;
|
|
};
|
|
var getOuter = function (element) {
|
|
var container = SugarElement.fromTag('div');
|
|
var clone = SugarElement.fromDom(element.dom.cloneNode(true));
|
|
append$1(container, clone);
|
|
return get$2(container);
|
|
};
|
|
|
|
var placeCaretInCell = function (editor, cell) {
|
|
editor.selection.select(cell.dom, true);
|
|
editor.selection.collapse(true);
|
|
};
|
|
var selectFirstCellInTable = function (editor, tableElm) {
|
|
descendant(tableElm, 'td,th').each(curry(placeCaretInCell, editor));
|
|
};
|
|
var fireEvents = function (editor, table) {
|
|
each$2(descendants(table, 'tr'), function (row) {
|
|
fireNewRow(editor, row.dom);
|
|
each$2(descendants(row, 'th,td'), function (cell) {
|
|
fireNewCell(editor, cell.dom);
|
|
});
|
|
});
|
|
};
|
|
var isPercentage = function (width) {
|
|
return isString(width) && width.indexOf('%') !== -1;
|
|
};
|
|
var insert = function (editor, columns, rows, colHeaders, rowHeaders) {
|
|
var defaultStyles = getDefaultStyles(editor);
|
|
var options = {
|
|
styles: defaultStyles,
|
|
attributes: getDefaultAttributes(editor),
|
|
colGroups: useColumnGroup(editor)
|
|
};
|
|
editor.undoManager.ignore(function () {
|
|
var table = render(rows, columns, rowHeaders, colHeaders, getTableHeaderType(editor), options);
|
|
set$2(table, 'data-mce-id', '__mce');
|
|
var html = getOuter(table);
|
|
editor.insertContent(html);
|
|
editor.addVisual();
|
|
});
|
|
return descendant(getBody(editor), 'table[data-mce-id="__mce"]').map(function (table) {
|
|
if (isPixelsForced(editor)) {
|
|
enforcePixels(table);
|
|
} else if (isResponsiveForced(editor)) {
|
|
enforceNone(table);
|
|
} else if (isPercentagesForced(editor) || isPercentage(defaultStyles.width)) {
|
|
enforcePercentage(table);
|
|
}
|
|
removeDataStyle(table);
|
|
remove$7(table, 'data-mce-id');
|
|
fireEvents(editor, table);
|
|
selectFirstCellInTable(editor, table);
|
|
return table.dom;
|
|
}).getOr(null);
|
|
};
|
|
var insertTableWithDataValidation = function (editor, rows, columns, options, errorMsg) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var checkInput = function (val) {
|
|
return isNumber(val) && val > 0;
|
|
};
|
|
if (checkInput(rows) && checkInput(columns)) {
|
|
var headerRows = options.headerRows || 0;
|
|
var headerColumns = options.headerColumns || 0;
|
|
return insert(editor, columns, rows, headerColumns, headerRows);
|
|
} else {
|
|
console.error(errorMsg);
|
|
return null;
|
|
}
|
|
};
|
|
|
|
var getClipboardElements = function (getClipboard) {
|
|
return function () {
|
|
return getClipboard().fold(function () {
|
|
return [];
|
|
}, function (elems) {
|
|
return map$1(elems, function (e) {
|
|
return e.dom;
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var setClipboardElements = function (setClipboard) {
|
|
return function (elems) {
|
|
var elmsOpt = elems.length > 0 ? Optional.some(fromDom(elems)) : Optional.none();
|
|
setClipboard(elmsOpt);
|
|
};
|
|
};
|
|
var insertTable = function (editor) {
|
|
return function (columns, rows, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var table = insertTableWithDataValidation(editor, rows, columns, options, 'Invalid values for insertTable - rows and columns values are required to insert a table.');
|
|
editor.undoManager.add();
|
|
return table;
|
|
};
|
|
};
|
|
var getApi = function (editor, clipboard, resizeHandler, selectionTargets) {
|
|
return {
|
|
insertTable: insertTable(editor),
|
|
setClipboardRows: setClipboardElements(clipboard.setRows),
|
|
getClipboardRows: getClipboardElements(clipboard.getRows),
|
|
setClipboardCols: setClipboardElements(clipboard.setColumns),
|
|
getClipboardCols: getClipboardElements(clipboard.getColumns),
|
|
resizeHandler: resizeHandler,
|
|
selectionTargets: selectionTargets
|
|
};
|
|
};
|
|
|
|
var constrainSpan = function (element, property, value) {
|
|
var currentColspan = getAttrValue(element, property, 1);
|
|
if (value === 1 || currentColspan <= 1) {
|
|
remove$7(element, property);
|
|
} else {
|
|
set$2(element, property, Math.min(value, currentColspan));
|
|
}
|
|
};
|
|
var generateColGroup = function (house, minColRange, maxColRange) {
|
|
if (Warehouse.hasColumns(house)) {
|
|
var colsToCopy = filter$2(Warehouse.justColumns(house), function (col) {
|
|
return col.column >= minColRange && col.column < maxColRange;
|
|
});
|
|
var copiedCols = map$1(colsToCopy, function (c) {
|
|
var clonedCol = deep(c.element);
|
|
constrainSpan(clonedCol, 'span', maxColRange - minColRange);
|
|
return clonedCol;
|
|
});
|
|
var fakeColgroup = SugarElement.fromTag('colgroup');
|
|
append(fakeColgroup, copiedCols);
|
|
return [fakeColgroup];
|
|
} else {
|
|
return [];
|
|
}
|
|
};
|
|
var generateRows = function (house, minColRange, maxColRange) {
|
|
return map$1(house.all, function (row) {
|
|
var cellsToCopy = filter$2(row.cells, function (cell) {
|
|
return cell.column >= minColRange && cell.column < maxColRange;
|
|
});
|
|
var copiedCells = map$1(cellsToCopy, function (cell) {
|
|
var clonedCell = deep(cell.element);
|
|
constrainSpan(clonedCell, 'colspan', maxColRange - minColRange);
|
|
return clonedCell;
|
|
});
|
|
var fakeTR = SugarElement.fromTag('tr');
|
|
append(fakeTR, copiedCells);
|
|
return fakeTR;
|
|
});
|
|
};
|
|
var copyCols = function (table, target) {
|
|
var house = Warehouse.fromTable(table);
|
|
var details = onUnlockedCells(house, target);
|
|
return details.map(function (selectedCells) {
|
|
var lastSelectedCell = selectedCells[selectedCells.length - 1];
|
|
var minColRange = selectedCells[0].column;
|
|
var maxColRange = lastSelectedCell.column + lastSelectedCell.colspan;
|
|
var fakeColGroups = generateColGroup(house, minColRange, maxColRange);
|
|
var fakeRows = generateRows(house, minColRange, maxColRange);
|
|
return __spreadArray(__spreadArray([], fakeColGroups, true), fakeRows, true);
|
|
});
|
|
};
|
|
|
|
var copyRows = function (table, target, generators) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var details = onCells(warehouse, target);
|
|
return details.bind(function (selectedCells) {
|
|
var grid = toGrid(warehouse, generators, false);
|
|
var rows = extractGridDetails(grid).rows;
|
|
var slicedGrid = rows.slice(selectedCells[0].row, selectedCells[selectedCells.length - 1].row + selectedCells[selectedCells.length - 1].rowspan);
|
|
var filteredGrid = bind$2(slicedGrid, function (row) {
|
|
var newCells = filter$2(row.cells, function (cell) {
|
|
return !cell.isLocked;
|
|
});
|
|
return newCells.length > 0 ? [__assign(__assign({}, row), { cells: newCells })] : [];
|
|
});
|
|
var slicedDetails = toDetailList(filteredGrid);
|
|
return someIf(slicedDetails.length > 0, slicedDetails);
|
|
}).map(function (slicedDetails) {
|
|
return copy(slicedDetails);
|
|
});
|
|
};
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getTDTHOverallStyle = function (dom, elm, name) {
|
|
var cells = dom.select('td,th', elm);
|
|
var firstChildStyle;
|
|
var checkChildren = function (firstChildStyle, elms) {
|
|
for (var i = 0; i < elms.length; i++) {
|
|
var currentStyle = dom.getStyle(elms[i], name);
|
|
if (typeof firstChildStyle === 'undefined') {
|
|
firstChildStyle = currentStyle;
|
|
}
|
|
if (firstChildStyle !== currentStyle) {
|
|
return '';
|
|
}
|
|
}
|
|
return firstChildStyle;
|
|
};
|
|
return checkChildren(firstChildStyle, cells);
|
|
};
|
|
var applyAlign = function (editor, elm, name) {
|
|
if (name) {
|
|
editor.formatter.apply('align' + name, {}, elm);
|
|
}
|
|
};
|
|
var applyVAlign = function (editor, elm, name) {
|
|
if (name) {
|
|
editor.formatter.apply('valign' + name, {}, elm);
|
|
}
|
|
};
|
|
var unApplyAlign = function (editor, elm) {
|
|
global$2.each('left center right'.split(' '), function (name) {
|
|
editor.formatter.remove('align' + name, {}, elm);
|
|
});
|
|
};
|
|
var unApplyVAlign = function (editor, elm) {
|
|
global$2.each('top middle bottom'.split(' '), function (name) {
|
|
editor.formatter.remove('valign' + name, {}, elm);
|
|
});
|
|
};
|
|
|
|
var verticalAlignValues = [
|
|
{
|
|
text: 'None',
|
|
value: ''
|
|
},
|
|
{
|
|
text: 'Top',
|
|
value: 'top'
|
|
},
|
|
{
|
|
text: 'Middle',
|
|
value: 'middle'
|
|
},
|
|
{
|
|
text: 'Bottom',
|
|
value: 'bottom'
|
|
}
|
|
];
|
|
|
|
var hexColour = function (value) {
|
|
return { value: value };
|
|
};
|
|
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
var longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i;
|
|
var isHexString = function (hex) {
|
|
return shorthandRegex.test(hex) || longformRegex.test(hex);
|
|
};
|
|
var normalizeHex = function (hex) {
|
|
return removeLeading(hex, '#').toUpperCase();
|
|
};
|
|
var fromString$1 = function (hex) {
|
|
return isHexString(hex) ? Optional.some({ value: normalizeHex(hex) }) : Optional.none();
|
|
};
|
|
var toHex = function (component) {
|
|
var hex = component.toString(16);
|
|
return (hex.length === 1 ? '0' + hex : hex).toUpperCase();
|
|
};
|
|
var fromRgba = function (rgbaColour) {
|
|
var value = toHex(rgbaColour.red) + toHex(rgbaColour.green) + toHex(rgbaColour.blue);
|
|
return hexColour(value);
|
|
};
|
|
|
|
var rgbRegex = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)/;
|
|
var rgbaRegex = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d?(?:\.\d+)?)\)/;
|
|
var rgbaColour = function (red, green, blue, alpha) {
|
|
return {
|
|
red: red,
|
|
green: green,
|
|
blue: blue,
|
|
alpha: alpha
|
|
};
|
|
};
|
|
var fromStringValues = function (red, green, blue, alpha) {
|
|
var r = parseInt(red, 10);
|
|
var g = parseInt(green, 10);
|
|
var b = parseInt(blue, 10);
|
|
var a = parseFloat(alpha);
|
|
return rgbaColour(r, g, b, a);
|
|
};
|
|
var fromString = function (rgbaString) {
|
|
if (rgbaString === 'transparent') {
|
|
return Optional.some(rgbaColour(0, 0, 0, 0));
|
|
}
|
|
var rgbMatch = rgbRegex.exec(rgbaString);
|
|
if (rgbMatch !== null) {
|
|
return Optional.some(fromStringValues(rgbMatch[1], rgbMatch[2], rgbMatch[3], '1'));
|
|
}
|
|
var rgbaMatch = rgbaRegex.exec(rgbaString);
|
|
if (rgbaMatch !== null) {
|
|
return Optional.some(fromStringValues(rgbaMatch[1], rgbaMatch[2], rgbaMatch[3], rgbaMatch[4]));
|
|
}
|
|
return Optional.none();
|
|
};
|
|
|
|
var anyToHex = function (color) {
|
|
return fromString$1(color).orThunk(function () {
|
|
return fromString(color).map(fromRgba);
|
|
}).getOrThunk(function () {
|
|
var canvas = document.createElement('canvas');
|
|
canvas.height = 1;
|
|
canvas.width = 1;
|
|
var canvasContext = canvas.getContext('2d');
|
|
canvasContext.clearRect(0, 0, canvas.width, canvas.height);
|
|
canvasContext.fillStyle = '#FFFFFF';
|
|
canvasContext.fillStyle = color;
|
|
canvasContext.fillRect(0, 0, 1, 1);
|
|
var rgba = canvasContext.getImageData(0, 0, 1, 1).data;
|
|
var r = rgba[0];
|
|
var g = rgba[1];
|
|
var b = rgba[2];
|
|
var a = rgba[3];
|
|
return fromRgba(rgbaColour(r, g, b, a));
|
|
});
|
|
};
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var singleton = function (doRevoke) {
|
|
var subject = Cell(Optional.none());
|
|
var revoke = function () {
|
|
return subject.get().each(doRevoke);
|
|
};
|
|
var clear = function () {
|
|
revoke();
|
|
subject.set(Optional.none());
|
|
};
|
|
var isSet = function () {
|
|
return subject.get().isSome();
|
|
};
|
|
var get = function () {
|
|
return subject.get();
|
|
};
|
|
var set = function (s) {
|
|
revoke();
|
|
subject.set(Optional.some(s));
|
|
};
|
|
return {
|
|
clear: clear,
|
|
isSet: isSet,
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
var unbindable = function () {
|
|
return singleton(function (s) {
|
|
return s.unbind();
|
|
});
|
|
};
|
|
var value = function () {
|
|
var subject = singleton(noop);
|
|
var on = function (f) {
|
|
return subject.get().each(f);
|
|
};
|
|
return __assign(__assign({}, subject), { on: on });
|
|
};
|
|
|
|
var onSetupToggle = function (editor, selections, formatName, formatValue) {
|
|
return function (api) {
|
|
var boundCallback = unbindable();
|
|
var isNone = isEmpty$1(formatValue);
|
|
var init = function () {
|
|
var selectedCells = getCellsFromSelection(selections);
|
|
var checkNode = function (cell) {
|
|
return editor.formatter.match(formatName, { value: formatValue }, cell.dom, isNone);
|
|
};
|
|
if (isNone) {
|
|
api.setActive(!exists(selectedCells, checkNode));
|
|
boundCallback.set(editor.formatter.formatChanged(formatName, function (match) {
|
|
return api.setActive(!match);
|
|
}, true));
|
|
} else {
|
|
api.setActive(forall(selectedCells, checkNode));
|
|
boundCallback.set(editor.formatter.formatChanged(formatName, api.setActive, false, { value: formatValue }));
|
|
}
|
|
};
|
|
editor.initialized ? init() : editor.on('init', init);
|
|
return boundCallback.clear;
|
|
};
|
|
};
|
|
var isListGroup = function (item) {
|
|
return hasNonNullableKey(item, 'menu');
|
|
};
|
|
var buildListItems = function (items) {
|
|
return map$1(items, function (item) {
|
|
var text = item.text || item.title;
|
|
if (isListGroup(item)) {
|
|
return {
|
|
text: text,
|
|
items: buildListItems(item.menu)
|
|
};
|
|
} else {
|
|
return {
|
|
text: text,
|
|
value: item.value
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var buildMenuItems = function (editor, selections, items, format, onAction) {
|
|
return map$1(items, function (item) {
|
|
var text = item.text || item.title;
|
|
if (isListGroup(item)) {
|
|
return {
|
|
type: 'nestedmenuitem',
|
|
text: text,
|
|
getSubmenuItems: function () {
|
|
return buildMenuItems(editor, selections, item.menu, format, onAction);
|
|
}
|
|
};
|
|
} else {
|
|
return {
|
|
text: text,
|
|
type: 'togglemenuitem',
|
|
onAction: function () {
|
|
return onAction(item.value);
|
|
},
|
|
onSetup: onSetupToggle(editor, selections, format, item.value)
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var applyTableCellStyle = function (editor, style) {
|
|
return function (value) {
|
|
var _a;
|
|
editor.execCommand('mceTableApplyCellStyle', false, (_a = {}, _a[style] = value, _a));
|
|
};
|
|
};
|
|
var filterNoneItem = function (list) {
|
|
return bind$2(list, function (item) {
|
|
if (isListGroup(item)) {
|
|
return [__assign(__assign({}, item), { menu: filterNoneItem(item.menu) })];
|
|
} else {
|
|
return isNotEmpty(item.value) ? [item] : [];
|
|
}
|
|
});
|
|
};
|
|
var generateMenuItemsCallback = function (editor, selections, items, format, onAction) {
|
|
return function (callback) {
|
|
return callback(buildMenuItems(editor, selections, items, format, onAction));
|
|
};
|
|
};
|
|
var buildColorMenu = function (editor, colorList, style) {
|
|
var colorMap = map$1(colorList, function (entry) {
|
|
return {
|
|
text: entry.title,
|
|
value: '#' + anyToHex(entry.value).value,
|
|
type: 'choiceitem'
|
|
};
|
|
});
|
|
return [{
|
|
type: 'fancymenuitem',
|
|
fancytype: 'colorswatch',
|
|
initData: {
|
|
colors: colorMap.length > 0 ? colorMap : undefined,
|
|
allowCustomColors: false
|
|
},
|
|
onAction: function (data) {
|
|
var _a;
|
|
var value = data.value === 'remove' ? '' : data.value;
|
|
editor.execCommand('mceTableApplyCellStyle', false, (_a = {}, _a[style] = value, _a));
|
|
}
|
|
}];
|
|
};
|
|
var changeRowHeader = function (editor) {
|
|
return function () {
|
|
var currentType = editor.queryCommandValue('mceTableRowType');
|
|
var newType = currentType === 'header' ? 'body' : 'header';
|
|
editor.execCommand('mceTableRowType', false, { type: newType });
|
|
};
|
|
};
|
|
var changeColumnHeader = function (editor) {
|
|
return function () {
|
|
var currentType = editor.queryCommandValue('mceTableColType');
|
|
var newType = currentType === 'th' ? 'td' : 'th';
|
|
editor.execCommand('mceTableColType', false, { type: newType });
|
|
};
|
|
};
|
|
|
|
var getClassList$1 = function (editor) {
|
|
var classes = buildListItems(getCellClassList(editor));
|
|
if (classes.length > 0) {
|
|
return Optional.some({
|
|
name: 'class',
|
|
type: 'listbox',
|
|
label: 'Class',
|
|
items: classes
|
|
});
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var children = [
|
|
{
|
|
name: 'width',
|
|
type: 'input',
|
|
label: 'Width'
|
|
},
|
|
{
|
|
name: 'height',
|
|
type: 'input',
|
|
label: 'Height'
|
|
},
|
|
{
|
|
name: 'celltype',
|
|
type: 'listbox',
|
|
label: 'Cell type',
|
|
items: [
|
|
{
|
|
text: 'Cell',
|
|
value: 'td'
|
|
},
|
|
{
|
|
text: 'Header cell',
|
|
value: 'th'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'scope',
|
|
type: 'listbox',
|
|
label: 'Scope',
|
|
items: [
|
|
{
|
|
text: 'None',
|
|
value: ''
|
|
},
|
|
{
|
|
text: 'Row',
|
|
value: 'row'
|
|
},
|
|
{
|
|
text: 'Column',
|
|
value: 'col'
|
|
},
|
|
{
|
|
text: 'Row group',
|
|
value: 'rowgroup'
|
|
},
|
|
{
|
|
text: 'Column group',
|
|
value: 'colgroup'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'halign',
|
|
type: 'listbox',
|
|
label: 'Horizontal align',
|
|
items: [
|
|
{
|
|
text: 'None',
|
|
value: ''
|
|
},
|
|
{
|
|
text: 'Left',
|
|
value: 'left'
|
|
},
|
|
{
|
|
text: 'Center',
|
|
value: 'center'
|
|
},
|
|
{
|
|
text: 'Right',
|
|
value: 'right'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
name: 'valign',
|
|
type: 'listbox',
|
|
label: 'Vertical align',
|
|
items: verticalAlignValues
|
|
}
|
|
];
|
|
var getItems$2 = function (editor) {
|
|
return children.concat(getClassList$1(editor).toArray());
|
|
};
|
|
|
|
var getAdvancedTab = function (editor, dialogName) {
|
|
var emptyBorderStyle = [{
|
|
text: 'Select...',
|
|
value: ''
|
|
}];
|
|
var advTabItems = [
|
|
{
|
|
name: 'borderstyle',
|
|
type: 'listbox',
|
|
label: 'Border style',
|
|
items: emptyBorderStyle.concat(buildListItems(getTableBorderStyles(editor)))
|
|
},
|
|
{
|
|
name: 'bordercolor',
|
|
type: 'colorinput',
|
|
label: 'Border color'
|
|
},
|
|
{
|
|
name: 'backgroundcolor',
|
|
type: 'colorinput',
|
|
label: 'Background color'
|
|
}
|
|
];
|
|
var borderWidth = {
|
|
name: 'borderwidth',
|
|
type: 'input',
|
|
label: 'Border width'
|
|
};
|
|
var items = dialogName === 'cell' ? [borderWidth].concat(advTabItems) : advTabItems;
|
|
return {
|
|
title: 'Advanced',
|
|
name: 'advanced',
|
|
items: items
|
|
};
|
|
};
|
|
|
|
var modifiers = function (testTruthy) {
|
|
return function (editor, node) {
|
|
var dom = editor.dom;
|
|
var setAttrib = function (attr, value) {
|
|
if (!testTruthy || value) {
|
|
dom.setAttrib(node, attr, value);
|
|
}
|
|
};
|
|
var setStyle = function (prop, value) {
|
|
if (!testTruthy || value) {
|
|
dom.setStyle(node, prop, value);
|
|
}
|
|
};
|
|
var setFormat = function (formatName, value) {
|
|
if (!testTruthy || value) {
|
|
if (value === '') {
|
|
editor.formatter.remove(formatName, { value: null }, node, true);
|
|
} else {
|
|
editor.formatter.apply(formatName, { value: value }, node);
|
|
}
|
|
}
|
|
};
|
|
return {
|
|
setAttrib: setAttrib,
|
|
setStyle: setStyle,
|
|
setFormat: setFormat
|
|
};
|
|
};
|
|
};
|
|
var DomModifier = {
|
|
normal: modifiers(false),
|
|
ifTruthy: modifiers(true)
|
|
};
|
|
|
|
var rgbToHex = function (dom) {
|
|
return function (value) {
|
|
return startsWith(value, 'rgb') ? dom.toHex(value) : value;
|
|
};
|
|
};
|
|
var extractAdvancedStyles = function (dom, elm) {
|
|
var element = SugarElement.fromDom(elm);
|
|
return {
|
|
borderwidth: getRaw$2(element, 'border-width').getOr(''),
|
|
borderstyle: getRaw$2(element, 'border-style').getOr(''),
|
|
bordercolor: getRaw$2(element, 'border-color').map(rgbToHex(dom)).getOr(''),
|
|
backgroundcolor: getRaw$2(element, 'background-color').map(rgbToHex(dom)).getOr('')
|
|
};
|
|
};
|
|
var getSharedValues = function (data) {
|
|
var baseData = data[0];
|
|
var comparisonData = data.slice(1);
|
|
each$2(comparisonData, function (items) {
|
|
each$2(keys(baseData), function (key) {
|
|
each$1(items, function (itemValue, itemKey) {
|
|
var comparisonValue = baseData[key];
|
|
if (comparisonValue !== '' && key === itemKey) {
|
|
if (comparisonValue !== itemValue) {
|
|
baseData[key] = '';
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
return baseData;
|
|
};
|
|
var getAlignment = function (formats, formatName, editor, elm) {
|
|
return find$1(formats, function (name) {
|
|
return !isUndefined(editor.formatter.matchNode(elm, formatName + name));
|
|
}).getOr('');
|
|
};
|
|
var getHAlignment = curry(getAlignment, [
|
|
'left',
|
|
'center',
|
|
'right'
|
|
], 'align');
|
|
var getVAlignment = curry(getAlignment, [
|
|
'top',
|
|
'middle',
|
|
'bottom'
|
|
], 'valign');
|
|
var extractDataFromSettings = function (editor, hasAdvTableTab) {
|
|
var style = getDefaultStyles(editor);
|
|
var attrs = getDefaultAttributes(editor);
|
|
var extractAdvancedStyleData = function (dom) {
|
|
return {
|
|
borderstyle: get$c(style, 'border-style').getOr(''),
|
|
bordercolor: rgbToHex(dom)(get$c(style, 'border-color').getOr('')),
|
|
backgroundcolor: rgbToHex(dom)(get$c(style, 'background-color').getOr(''))
|
|
};
|
|
};
|
|
var defaultData = {
|
|
height: '',
|
|
width: '100%',
|
|
cellspacing: '',
|
|
cellpadding: '',
|
|
caption: false,
|
|
class: '',
|
|
align: '',
|
|
border: ''
|
|
};
|
|
var getBorder = function () {
|
|
var borderWidth = style['border-width'];
|
|
if (shouldStyleWithCss(editor) && borderWidth) {
|
|
return { border: borderWidth };
|
|
}
|
|
return get$c(attrs, 'border').fold(function () {
|
|
return {};
|
|
}, function (border) {
|
|
return { border: border };
|
|
});
|
|
};
|
|
var advStyle = hasAdvTableTab ? extractAdvancedStyleData(editor.dom) : {};
|
|
var getCellPaddingCellSpacing = function () {
|
|
var spacing = get$c(style, 'border-spacing').or(get$c(attrs, 'cellspacing')).fold(function () {
|
|
return {};
|
|
}, function (cellspacing) {
|
|
return { cellspacing: cellspacing };
|
|
});
|
|
var padding = get$c(style, 'border-padding').or(get$c(attrs, 'cellpadding')).fold(function () {
|
|
return {};
|
|
}, function (cellpadding) {
|
|
return { cellpadding: cellpadding };
|
|
});
|
|
return __assign(__assign({}, spacing), padding);
|
|
};
|
|
var data = __assign(__assign(__assign(__assign(__assign(__assign({}, defaultData), style), attrs), advStyle), getBorder()), getCellPaddingCellSpacing());
|
|
return data;
|
|
};
|
|
var getRowType = function (elm) {
|
|
return table(SugarElement.fromDom(elm)).map(function (table) {
|
|
var target = { selection: fromDom(elm.cells) };
|
|
return getRowsType(table, target);
|
|
}).getOr('');
|
|
};
|
|
var extractDataFromTableElement = function (editor, elm, hasAdvTableTab) {
|
|
var getBorder = function (dom, elm) {
|
|
var optBorderWidth = getRaw$2(SugarElement.fromDom(elm), 'border-width');
|
|
if (shouldStyleWithCss(editor) && optBorderWidth.isSome()) {
|
|
return optBorderWidth.getOr('');
|
|
}
|
|
return dom.getAttrib(elm, 'border') || getTDTHOverallStyle(editor.dom, elm, 'border-width') || getTDTHOverallStyle(editor.dom, elm, 'border');
|
|
};
|
|
var dom = editor.dom;
|
|
var cellspacing = shouldStyleWithCss(editor) ? dom.getStyle(elm, 'border-spacing') || dom.getAttrib(elm, 'cellspacing') : dom.getAttrib(elm, 'cellspacing') || dom.getStyle(elm, 'border-spacing');
|
|
var cellpadding = shouldStyleWithCss(editor) ? getTDTHOverallStyle(dom, elm, 'padding') || dom.getAttrib(elm, 'cellpadding') : dom.getAttrib(elm, 'cellpadding') || getTDTHOverallStyle(dom, elm, 'padding');
|
|
return __assign({
|
|
width: dom.getStyle(elm, 'width') || dom.getAttrib(elm, 'width'),
|
|
height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
|
|
cellspacing: cellspacing,
|
|
cellpadding: cellpadding,
|
|
border: getBorder(dom, elm),
|
|
caption: !!dom.select('caption', elm)[0],
|
|
class: dom.getAttrib(elm, 'class', ''),
|
|
align: getHAlignment(editor, elm)
|
|
}, hasAdvTableTab ? extractAdvancedStyles(dom, elm) : {});
|
|
};
|
|
var extractDataFromRowElement = function (editor, elm, hasAdvancedRowTab) {
|
|
var dom = editor.dom;
|
|
return __assign({
|
|
height: dom.getStyle(elm, 'height') || dom.getAttrib(elm, 'height'),
|
|
class: dom.getAttrib(elm, 'class', ''),
|
|
type: getRowType(elm),
|
|
align: getHAlignment(editor, elm)
|
|
}, hasAdvancedRowTab ? extractAdvancedStyles(dom, elm) : {});
|
|
};
|
|
var extractDataFromCellElement = function (editor, cell, hasAdvancedCellTab, column) {
|
|
var dom = editor.dom;
|
|
var colElm = column.getOr(cell);
|
|
var getStyle = function (element, style) {
|
|
return dom.getStyle(element, style) || dom.getAttrib(element, style);
|
|
};
|
|
return __assign({
|
|
width: getStyle(colElm, 'width'),
|
|
height: getStyle(cell, 'height'),
|
|
scope: dom.getAttrib(cell, 'scope'),
|
|
celltype: getNodeName(cell),
|
|
class: dom.getAttrib(cell, 'class', ''),
|
|
halign: getHAlignment(editor, cell),
|
|
valign: getVAlignment(editor, cell)
|
|
}, hasAdvancedCellTab ? extractAdvancedStyles(dom, cell) : {});
|
|
};
|
|
|
|
var getSelectedCells = function (table, cells) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var allCells = Warehouse.justCells(warehouse);
|
|
var filtered = filter$2(allCells, function (cellA) {
|
|
return exists(cells, function (cellB) {
|
|
return eq$1(cellA.element, cellB);
|
|
});
|
|
});
|
|
return map$1(filtered, function (cell) {
|
|
return {
|
|
element: cell.element.dom,
|
|
column: Warehouse.getColumnAt(warehouse, cell.column).map(function (col) {
|
|
return col.element.dom;
|
|
})
|
|
};
|
|
});
|
|
};
|
|
var updateSimpleProps$1 = function (modifier, colModifier, data) {
|
|
modifier.setAttrib('scope', data.scope);
|
|
modifier.setAttrib('class', data.class);
|
|
modifier.setStyle('height', addPxSuffix(data.height));
|
|
colModifier.setStyle('width', addPxSuffix(data.width));
|
|
};
|
|
var updateAdvancedProps$1 = function (modifier, data) {
|
|
modifier.setFormat('tablecellbackgroundcolor', data.backgroundcolor);
|
|
modifier.setFormat('tablecellbordercolor', data.bordercolor);
|
|
modifier.setFormat('tablecellborderstyle', data.borderstyle);
|
|
modifier.setFormat('tablecellborderwidth', addPxSuffix(data.borderwidth));
|
|
};
|
|
var applyStyleData$1 = function (editor, cells, data) {
|
|
var isSingleCell = cells.length === 1;
|
|
each$2(cells, function (item) {
|
|
var cellElm = item.element;
|
|
var modifier = isSingleCell ? DomModifier.normal(editor, cellElm) : DomModifier.ifTruthy(editor, cellElm);
|
|
var colModifier = item.column.map(function (col) {
|
|
return isSingleCell ? DomModifier.normal(editor, col) : DomModifier.ifTruthy(editor, col);
|
|
}).getOr(modifier);
|
|
updateSimpleProps$1(modifier, colModifier, data);
|
|
if (hasAdvancedCellTab(editor)) {
|
|
updateAdvancedProps$1(modifier, data);
|
|
}
|
|
if (isSingleCell) {
|
|
unApplyAlign(editor, cellElm);
|
|
unApplyVAlign(editor, cellElm);
|
|
}
|
|
if (data.halign) {
|
|
applyAlign(editor, cellElm, data.halign);
|
|
}
|
|
if (data.valign) {
|
|
applyVAlign(editor, cellElm, data.valign);
|
|
}
|
|
});
|
|
};
|
|
var applyStructureData$1 = function (editor, data) {
|
|
editor.execCommand('mceTableCellType', false, {
|
|
type: data.celltype,
|
|
no_events: true
|
|
});
|
|
};
|
|
var applyCellData = function (editor, cells, oldData, data) {
|
|
var modifiedData = filter$1(data, function (value, key) {
|
|
return oldData[key] !== value;
|
|
});
|
|
if (size(modifiedData) > 0 && cells.length >= 1) {
|
|
table(cells[0]).each(function (table) {
|
|
var selectedCells = getSelectedCells(table, cells);
|
|
var styleModified = size(filter$1(modifiedData, function (_value, key) {
|
|
return key !== 'scope' && key !== 'celltype';
|
|
})) > 0;
|
|
var structureModified = has$1(modifiedData, 'celltype');
|
|
if (styleModified || has$1(modifiedData, 'scope')) {
|
|
applyStyleData$1(editor, selectedCells, data);
|
|
}
|
|
if (structureModified) {
|
|
applyStructureData$1(editor, data);
|
|
}
|
|
fireTableModified(editor, table.dom, {
|
|
structure: structureModified,
|
|
style: styleModified
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var onSubmitCellForm = function (editor, cells, oldData, api) {
|
|
var data = api.getData();
|
|
api.close();
|
|
editor.undoManager.transact(function () {
|
|
applyCellData(editor, cells, oldData, data);
|
|
editor.focus();
|
|
});
|
|
};
|
|
var getData = function (editor, cells) {
|
|
var cellsData = table(cells[0]).map(function (table) {
|
|
return map$1(getSelectedCells(table, cells), function (item) {
|
|
return extractDataFromCellElement(editor, item.element, hasAdvancedCellTab(editor), item.column);
|
|
});
|
|
});
|
|
return getSharedValues(cellsData.getOrDie());
|
|
};
|
|
var open$2 = function (editor, selections) {
|
|
var cells = getCellsFromSelection(selections);
|
|
if (cells.length === 0) {
|
|
return;
|
|
}
|
|
var data = getData(editor, cells);
|
|
var dialogTabPanel = {
|
|
type: 'tabpanel',
|
|
tabs: [
|
|
{
|
|
title: 'General',
|
|
name: 'general',
|
|
items: getItems$2(editor)
|
|
},
|
|
getAdvancedTab(editor, 'cell')
|
|
]
|
|
};
|
|
var dialogPanel = {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'grid',
|
|
columns: 2,
|
|
items: getItems$2(editor)
|
|
}]
|
|
};
|
|
editor.windowManager.open({
|
|
title: 'Cell Properties',
|
|
size: 'normal',
|
|
body: hasAdvancedCellTab(editor) ? dialogTabPanel : dialogPanel,
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: data,
|
|
onSubmit: curry(onSubmitCellForm, editor, cells, data)
|
|
});
|
|
};
|
|
|
|
var getClassList = function (editor) {
|
|
var classes = buildListItems(getRowClassList(editor));
|
|
if (classes.length > 0) {
|
|
return Optional.some({
|
|
name: 'class',
|
|
type: 'listbox',
|
|
label: 'Class',
|
|
items: classes
|
|
});
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var formChildren = [
|
|
{
|
|
type: 'listbox',
|
|
name: 'type',
|
|
label: 'Row type',
|
|
items: [
|
|
{
|
|
text: 'Header',
|
|
value: 'header'
|
|
},
|
|
{
|
|
text: 'Body',
|
|
value: 'body'
|
|
},
|
|
{
|
|
text: 'Footer',
|
|
value: 'footer'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
type: 'listbox',
|
|
name: 'align',
|
|
label: 'Alignment',
|
|
items: [
|
|
{
|
|
text: 'None',
|
|
value: ''
|
|
},
|
|
{
|
|
text: 'Left',
|
|
value: 'left'
|
|
},
|
|
{
|
|
text: 'Center',
|
|
value: 'center'
|
|
},
|
|
{
|
|
text: 'Right',
|
|
value: 'right'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
label: 'Height',
|
|
name: 'height',
|
|
type: 'input'
|
|
}
|
|
];
|
|
var getItems$1 = function (editor) {
|
|
return formChildren.concat(getClassList(editor).toArray());
|
|
};
|
|
|
|
var updateSimpleProps = function (modifier, data) {
|
|
modifier.setAttrib('class', data.class);
|
|
modifier.setStyle('height', addPxSuffix(data.height));
|
|
};
|
|
var updateAdvancedProps = function (modifier, data) {
|
|
modifier.setStyle('background-color', data.backgroundcolor);
|
|
modifier.setStyle('border-color', data.bordercolor);
|
|
modifier.setStyle('border-style', data.borderstyle);
|
|
};
|
|
var applyStyleData = function (editor, rows, data, oldData) {
|
|
var isSingleRow = rows.length === 1;
|
|
each$2(rows, function (rowElm) {
|
|
var modifier = isSingleRow ? DomModifier.normal(editor, rowElm) : DomModifier.ifTruthy(editor, rowElm);
|
|
updateSimpleProps(modifier, data);
|
|
if (hasAdvancedRowTab(editor)) {
|
|
updateAdvancedProps(modifier, data);
|
|
}
|
|
if (data.align !== oldData.align) {
|
|
unApplyAlign(editor, rowElm);
|
|
applyAlign(editor, rowElm, data.align);
|
|
}
|
|
});
|
|
};
|
|
var applyStructureData = function (editor, data) {
|
|
editor.execCommand('mceTableRowType', false, {
|
|
type: data.type,
|
|
no_events: true
|
|
});
|
|
};
|
|
var applyRowData = function (editor, rows, oldData, data) {
|
|
var modifiedData = filter$1(data, function (value, key) {
|
|
return oldData[key] !== value;
|
|
});
|
|
if (size(modifiedData) > 0) {
|
|
var typeModified_1 = has$1(modifiedData, 'type');
|
|
var styleModified_1 = typeModified_1 ? size(modifiedData) > 1 : true;
|
|
if (styleModified_1) {
|
|
applyStyleData(editor, rows, data, oldData);
|
|
}
|
|
if (typeModified_1) {
|
|
applyStructureData(editor, data);
|
|
}
|
|
table(SugarElement.fromDom(rows[0])).each(function (table) {
|
|
return fireTableModified(editor, table.dom, {
|
|
structure: typeModified_1,
|
|
style: styleModified_1
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var onSubmitRowForm = function (editor, rows, oldData, api) {
|
|
var data = api.getData();
|
|
api.close();
|
|
editor.undoManager.transact(function () {
|
|
applyRowData(editor, rows, oldData, data);
|
|
editor.focus();
|
|
});
|
|
};
|
|
var open$1 = function (editor) {
|
|
var rows = getRowsFromSelection(getSelectionStart(editor), ephemera.selected);
|
|
if (rows.length === 0) {
|
|
return;
|
|
}
|
|
var rowsData = map$1(rows, function (rowElm) {
|
|
return extractDataFromRowElement(editor, rowElm.dom, hasAdvancedRowTab(editor));
|
|
});
|
|
var data = getSharedValues(rowsData);
|
|
var dialogTabPanel = {
|
|
type: 'tabpanel',
|
|
tabs: [
|
|
{
|
|
title: 'General',
|
|
name: 'general',
|
|
items: getItems$1(editor)
|
|
},
|
|
getAdvancedTab(editor, 'row')
|
|
]
|
|
};
|
|
var dialogPanel = {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'grid',
|
|
columns: 2,
|
|
items: getItems$1(editor)
|
|
}]
|
|
};
|
|
editor.windowManager.open({
|
|
title: 'Row Properties',
|
|
size: 'normal',
|
|
body: hasAdvancedRowTab(editor) ? dialogTabPanel : dialogPanel,
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: data,
|
|
onSubmit: curry(onSubmitRowForm, editor, map$1(rows, function (r) {
|
|
return r.dom;
|
|
}), data)
|
|
});
|
|
};
|
|
|
|
var getItems = function (editor, classes, insertNewTable) {
|
|
var rowColCountItems = !insertNewTable ? [] : [
|
|
{
|
|
type: 'input',
|
|
name: 'cols',
|
|
label: 'Cols',
|
|
inputMode: 'numeric'
|
|
},
|
|
{
|
|
type: 'input',
|
|
name: 'rows',
|
|
label: 'Rows',
|
|
inputMode: 'numeric'
|
|
}
|
|
];
|
|
var alwaysItems = [
|
|
{
|
|
type: 'input',
|
|
name: 'width',
|
|
label: 'Width'
|
|
},
|
|
{
|
|
type: 'input',
|
|
name: 'height',
|
|
label: 'Height'
|
|
}
|
|
];
|
|
var appearanceItems = hasAppearanceOptions(editor) ? [
|
|
{
|
|
type: 'input',
|
|
name: 'cellspacing',
|
|
label: 'Cell spacing',
|
|
inputMode: 'numeric'
|
|
},
|
|
{
|
|
type: 'input',
|
|
name: 'cellpadding',
|
|
label: 'Cell padding',
|
|
inputMode: 'numeric'
|
|
},
|
|
{
|
|
type: 'input',
|
|
name: 'border',
|
|
label: 'Border width'
|
|
},
|
|
{
|
|
type: 'label',
|
|
label: 'Caption',
|
|
items: [{
|
|
type: 'checkbox',
|
|
name: 'caption',
|
|
label: 'Show caption'
|
|
}]
|
|
}
|
|
] : [];
|
|
var alignmentItem = [{
|
|
type: 'listbox',
|
|
name: 'align',
|
|
label: 'Alignment',
|
|
items: [
|
|
{
|
|
text: 'None',
|
|
value: ''
|
|
},
|
|
{
|
|
text: 'Left',
|
|
value: 'left'
|
|
},
|
|
{
|
|
text: 'Center',
|
|
value: 'center'
|
|
},
|
|
{
|
|
text: 'Right',
|
|
value: 'right'
|
|
}
|
|
]
|
|
}];
|
|
var classListItem = classes.length > 0 ? [{
|
|
type: 'listbox',
|
|
name: 'class',
|
|
label: 'Class',
|
|
items: classes
|
|
}] : [];
|
|
return rowColCountItems.concat(alwaysItems).concat(appearanceItems).concat(alignmentItem).concat(classListItem);
|
|
};
|
|
|
|
var styleTDTH = function (dom, elm, name, value) {
|
|
if (elm.tagName === 'TD' || elm.tagName === 'TH') {
|
|
if (isString(name)) {
|
|
dom.setStyle(elm, name, value);
|
|
} else {
|
|
dom.setStyle(elm, name);
|
|
}
|
|
} else {
|
|
if (elm.children) {
|
|
for (var i = 0; i < elm.children.length; i++) {
|
|
styleTDTH(dom, elm.children[i], name, value);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
var applyDataToElement = function (editor, tableElm, data) {
|
|
var dom = editor.dom;
|
|
var attrs = {};
|
|
var styles = {};
|
|
attrs.class = data.class;
|
|
styles.height = addPxSuffix(data.height);
|
|
if (dom.getAttrib(tableElm, 'width') && !shouldStyleWithCss(editor)) {
|
|
attrs.width = removePxSuffix(data.width);
|
|
} else {
|
|
styles.width = addPxSuffix(data.width);
|
|
}
|
|
if (shouldStyleWithCss(editor)) {
|
|
styles['border-width'] = addPxSuffix(data.border);
|
|
styles['border-spacing'] = addPxSuffix(data.cellspacing);
|
|
} else {
|
|
attrs.border = data.border;
|
|
attrs.cellpadding = data.cellpadding;
|
|
attrs.cellspacing = data.cellspacing;
|
|
}
|
|
if (shouldStyleWithCss(editor) && tableElm.children) {
|
|
for (var i = 0; i < tableElm.children.length; i++) {
|
|
styleTDTH(dom, tableElm.children[i], {
|
|
'border-width': addPxSuffix(data.border),
|
|
'padding': addPxSuffix(data.cellpadding)
|
|
});
|
|
if (hasAdvancedTableTab(editor)) {
|
|
styleTDTH(dom, tableElm.children[i], { 'border-color': data.bordercolor });
|
|
}
|
|
}
|
|
}
|
|
if (hasAdvancedTableTab(editor)) {
|
|
styles['background-color'] = data.backgroundcolor;
|
|
styles['border-color'] = data.bordercolor;
|
|
styles['border-style'] = data.borderstyle;
|
|
}
|
|
attrs.style = dom.serializeStyle(__assign(__assign({}, getDefaultStyles(editor)), styles));
|
|
dom.setAttribs(tableElm, __assign(__assign({}, getDefaultAttributes(editor)), attrs));
|
|
};
|
|
var onSubmitTableForm = function (editor, tableElm, oldData, api) {
|
|
var dom = editor.dom;
|
|
var data = api.getData();
|
|
var modifiedData = filter$1(data, function (value, key) {
|
|
return oldData[key] !== value;
|
|
});
|
|
api.close();
|
|
if (data.class === '') {
|
|
delete data.class;
|
|
}
|
|
editor.undoManager.transact(function () {
|
|
if (!tableElm) {
|
|
var cols = parseInt(data.cols, 10) || 1;
|
|
var rows = parseInt(data.rows, 10) || 1;
|
|
tableElm = insert(editor, cols, rows, 0, 0);
|
|
}
|
|
if (size(modifiedData) > 0) {
|
|
applyDataToElement(editor, tableElm, data);
|
|
var captionElm = dom.select('caption', tableElm)[0];
|
|
if (captionElm && !data.caption || !captionElm && data.caption) {
|
|
editor.execCommand('mceTableToggleCaption');
|
|
}
|
|
if (data.align === '') {
|
|
unApplyAlign(editor, tableElm);
|
|
} else {
|
|
applyAlign(editor, tableElm, data.align);
|
|
}
|
|
}
|
|
editor.focus();
|
|
editor.addVisual();
|
|
if (size(modifiedData) > 0) {
|
|
var captionModified = has$1(modifiedData, 'caption');
|
|
var styleModified = captionModified ? size(modifiedData) > 1 : true;
|
|
fireTableModified(editor, tableElm, {
|
|
structure: captionModified,
|
|
style: styleModified
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var open = function (editor, insertNewTable) {
|
|
var dom = editor.dom;
|
|
var tableElm;
|
|
var data = extractDataFromSettings(editor, hasAdvancedTableTab(editor));
|
|
if (insertNewTable === false) {
|
|
tableElm = dom.getParent(editor.selection.getStart(), 'table', editor.getBody());
|
|
if (tableElm) {
|
|
data = extractDataFromTableElement(editor, tableElm, hasAdvancedTableTab(editor));
|
|
} else {
|
|
if (hasAdvancedTableTab(editor)) {
|
|
data.borderstyle = '';
|
|
data.bordercolor = '';
|
|
data.backgroundcolor = '';
|
|
}
|
|
}
|
|
} else {
|
|
data.cols = '1';
|
|
data.rows = '1';
|
|
if (hasAdvancedTableTab(editor)) {
|
|
data.borderstyle = '';
|
|
data.bordercolor = '';
|
|
data.backgroundcolor = '';
|
|
}
|
|
}
|
|
var classes = buildListItems(getTableClassList(editor));
|
|
if (classes.length > 0) {
|
|
if (data.class) {
|
|
data.class = data.class.replace(/\s*mce\-item\-table\s*/g, '');
|
|
}
|
|
}
|
|
var generalPanel = {
|
|
type: 'grid',
|
|
columns: 2,
|
|
items: getItems(editor, classes, insertNewTable)
|
|
};
|
|
var nonAdvancedForm = function () {
|
|
return {
|
|
type: 'panel',
|
|
items: [generalPanel]
|
|
};
|
|
};
|
|
var advancedForm = function () {
|
|
return {
|
|
type: 'tabpanel',
|
|
tabs: [
|
|
{
|
|
title: 'General',
|
|
name: 'general',
|
|
items: [generalPanel]
|
|
},
|
|
getAdvancedTab(editor, 'table')
|
|
]
|
|
};
|
|
};
|
|
var dialogBody = hasAdvancedTableTab(editor) ? advancedForm() : nonAdvancedForm();
|
|
editor.windowManager.open({
|
|
title: 'Table Properties',
|
|
size: 'normal',
|
|
body: dialogBody,
|
|
onSubmit: curry(onSubmitTableForm, editor, tableElm, data),
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
initialData: data
|
|
});
|
|
};
|
|
|
|
var getSelectionStartCellOrCaption = function (editor) {
|
|
return getSelectionCellOrCaption(getSelectionStart(editor), getIsRoot(editor));
|
|
};
|
|
var getSelectionStartCell = function (editor) {
|
|
return getSelectionCell(getSelectionStart(editor), getIsRoot(editor));
|
|
};
|
|
var registerCommands = function (editor, actions, cellSelection, selections, clipboard) {
|
|
var isRoot = getIsRoot(editor);
|
|
var eraseTable = function () {
|
|
return getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) {
|
|
table(cellOrCaption, isRoot).filter(not(isRoot)).each(function (table) {
|
|
var cursor = SugarElement.fromText('');
|
|
after$5(table, cursor);
|
|
remove$5(table);
|
|
if (editor.dom.isEmpty(editor.getBody())) {
|
|
editor.setContent('');
|
|
editor.selection.setCursorLocation();
|
|
} else {
|
|
var rng = editor.dom.createRng();
|
|
rng.setStart(cursor.dom, 0);
|
|
rng.setEnd(cursor.dom, 0);
|
|
editor.selection.setRng(rng);
|
|
editor.nodeChanged();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var setSizingMode = function (sizing) {
|
|
return getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) {
|
|
var isForcedSizing = isResponsiveForced(editor) || isPixelsForced(editor) || isPercentagesForced(editor);
|
|
if (!isForcedSizing) {
|
|
table(cellOrCaption, isRoot).each(function (table) {
|
|
if (sizing === 'relative' && !isPercentSizing(table)) {
|
|
enforcePercentage(table);
|
|
} else if (sizing === 'fixed' && !isPixelSizing(table)) {
|
|
enforcePixels(table);
|
|
} else if (sizing === 'responsive' && !isNoneSizing(table)) {
|
|
enforceNone(table);
|
|
}
|
|
removeDataStyle(table);
|
|
fireTableModified(editor, table.dom, structureModified);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var getTableFromCell = function (cell) {
|
|
return table(cell, isRoot);
|
|
};
|
|
var performActionOnSelection = function (action) {
|
|
return getSelectionStartCell(editor).bind(function (cell) {
|
|
return getTableFromCell(cell).map(function (table) {
|
|
return action(table, cell);
|
|
});
|
|
});
|
|
};
|
|
var toggleTableClass = function (_ui, clazz) {
|
|
performActionOnSelection(function (table) {
|
|
editor.formatter.toggle('tableclass', { value: clazz }, table.dom);
|
|
fireTableModified(editor, table.dom, styleModified);
|
|
});
|
|
};
|
|
var toggleTableCellClass = function (_ui, clazz) {
|
|
performActionOnSelection(function (table) {
|
|
var selectedCells = getCellsFromSelection(selections);
|
|
var allHaveClass = forall(selectedCells, function (cell) {
|
|
return editor.formatter.match('tablecellclass', { value: clazz }, cell.dom);
|
|
});
|
|
var formatterAction = allHaveClass ? editor.formatter.remove : editor.formatter.apply;
|
|
each$2(selectedCells, function (cell) {
|
|
return formatterAction('tablecellclass', { value: clazz }, cell.dom);
|
|
});
|
|
fireTableModified(editor, table.dom, styleModified);
|
|
});
|
|
};
|
|
var toggleCaption = function () {
|
|
getSelectionStartCellOrCaption(editor).each(function (cellOrCaption) {
|
|
table(cellOrCaption, isRoot).each(function (table) {
|
|
child$1(table, 'caption').fold(function () {
|
|
var caption = SugarElement.fromTag('caption');
|
|
append$1(caption, SugarElement.fromText('Caption'));
|
|
appendAt(table, caption, 0);
|
|
editor.selection.setCursorLocation(caption.dom, 0);
|
|
}, function (caption) {
|
|
if (isTag('caption')(cellOrCaption)) {
|
|
one('td', table).each(function (td) {
|
|
return editor.selection.setCursorLocation(td.dom, 0);
|
|
});
|
|
}
|
|
remove$5(caption);
|
|
});
|
|
fireTableModified(editor, table.dom, structureModified);
|
|
});
|
|
});
|
|
};
|
|
var postExecute = function (_data) {
|
|
editor.focus();
|
|
};
|
|
var actOnSelection = function (execute, noEvents) {
|
|
if (noEvents === void 0) {
|
|
noEvents = false;
|
|
}
|
|
return performActionOnSelection(function (table, startCell) {
|
|
var targets = forMenu(selections, table, startCell);
|
|
execute(table, targets, noEvents).each(postExecute);
|
|
});
|
|
};
|
|
var copyRowSelection = function () {
|
|
return performActionOnSelection(function (table, startCell) {
|
|
var targets = forMenu(selections, table, startCell);
|
|
var generators = cellOperations(noop, SugarElement.fromDom(editor.getDoc()), Optional.none());
|
|
return copyRows(table, targets, generators);
|
|
});
|
|
};
|
|
var copyColSelection = function () {
|
|
return performActionOnSelection(function (table, startCell) {
|
|
var targets = forMenu(selections, table, startCell);
|
|
return copyCols(table, targets);
|
|
});
|
|
};
|
|
var pasteOnSelection = function (execute, getRows) {
|
|
return getRows().each(function (rows) {
|
|
var clonedRows = map$1(rows, function (row) {
|
|
return deep(row);
|
|
});
|
|
performActionOnSelection(function (table, startCell) {
|
|
var generators = paste$1(SugarElement.fromDom(editor.getDoc()));
|
|
var targets = pasteRows(selections, startCell, clonedRows, generators);
|
|
execute(table, targets).each(postExecute);
|
|
});
|
|
});
|
|
};
|
|
var actOnType = function (getAction) {
|
|
return function (_ui, args) {
|
|
return get$c(args, 'type').each(function (type) {
|
|
actOnSelection(getAction(type), args.no_events);
|
|
});
|
|
};
|
|
};
|
|
each$1({
|
|
mceTableSplitCells: function () {
|
|
return actOnSelection(actions.unmergeCells);
|
|
},
|
|
mceTableMergeCells: function () {
|
|
return actOnSelection(actions.mergeCells);
|
|
},
|
|
mceTableInsertRowBefore: function () {
|
|
return actOnSelection(actions.insertRowsBefore);
|
|
},
|
|
mceTableInsertRowAfter: function () {
|
|
return actOnSelection(actions.insertRowsAfter);
|
|
},
|
|
mceTableInsertColBefore: function () {
|
|
return actOnSelection(actions.insertColumnsBefore);
|
|
},
|
|
mceTableInsertColAfter: function () {
|
|
return actOnSelection(actions.insertColumnsAfter);
|
|
},
|
|
mceTableDeleteCol: function () {
|
|
return actOnSelection(actions.deleteColumn);
|
|
},
|
|
mceTableDeleteRow: function () {
|
|
return actOnSelection(actions.deleteRow);
|
|
},
|
|
mceTableCutCol: function () {
|
|
return copyColSelection().each(function (selection) {
|
|
clipboard.setColumns(selection);
|
|
actOnSelection(actions.deleteColumn);
|
|
});
|
|
},
|
|
mceTableCutRow: function () {
|
|
return copyRowSelection().each(function (selection) {
|
|
clipboard.setRows(selection);
|
|
actOnSelection(actions.deleteRow);
|
|
});
|
|
},
|
|
mceTableCopyCol: function () {
|
|
return copyColSelection().each(function (selection) {
|
|
return clipboard.setColumns(selection);
|
|
});
|
|
},
|
|
mceTableCopyRow: function () {
|
|
return copyRowSelection().each(function (selection) {
|
|
return clipboard.setRows(selection);
|
|
});
|
|
},
|
|
mceTablePasteColBefore: function () {
|
|
return pasteOnSelection(actions.pasteColsBefore, clipboard.getColumns);
|
|
},
|
|
mceTablePasteColAfter: function () {
|
|
return pasteOnSelection(actions.pasteColsAfter, clipboard.getColumns);
|
|
},
|
|
mceTablePasteRowBefore: function () {
|
|
return pasteOnSelection(actions.pasteRowsBefore, clipboard.getRows);
|
|
},
|
|
mceTablePasteRowAfter: function () {
|
|
return pasteOnSelection(actions.pasteRowsAfter, clipboard.getRows);
|
|
},
|
|
mceTableDelete: eraseTable,
|
|
mceTableCellToggleClass: toggleTableCellClass,
|
|
mceTableToggleClass: toggleTableClass,
|
|
mceTableToggleCaption: toggleCaption,
|
|
mceTableSizingMode: function (_ui, sizing) {
|
|
return setSizingMode(sizing);
|
|
},
|
|
mceTableCellType: actOnType(function (type) {
|
|
return type === 'th' ? actions.makeCellsHeader : actions.unmakeCellsHeader;
|
|
}),
|
|
mceTableColType: actOnType(function (type) {
|
|
return type === 'th' ? actions.makeColumnsHeader : actions.unmakeColumnsHeader;
|
|
}),
|
|
mceTableRowType: actOnType(function (type) {
|
|
switch (type) {
|
|
case 'header':
|
|
return actions.makeRowsHeader;
|
|
case 'footer':
|
|
return actions.makeRowsFooter;
|
|
default:
|
|
return actions.makeRowsBody;
|
|
}
|
|
})
|
|
}, function (func, name) {
|
|
return editor.addCommand(name, func);
|
|
});
|
|
each$1({
|
|
mceTableProps: curry(open, editor, false),
|
|
mceTableRowProps: curry(open$1, editor),
|
|
mceTableCellProps: curry(open$2, editor, selections)
|
|
}, function (func, name) {
|
|
return editor.addCommand(name, function () {
|
|
return func();
|
|
});
|
|
});
|
|
editor.addCommand('mceInsertTable', function (_ui, args) {
|
|
if (isObject(args) && keys(args).length > 0) {
|
|
insertTableWithDataValidation(editor, args.rows, args.columns, args.options, 'Invalid values for mceInsertTable - rows and columns values are required to insert a table.');
|
|
} else {
|
|
open(editor, true);
|
|
}
|
|
});
|
|
editor.addCommand('mceTableApplyCellStyle', function (_ui, args) {
|
|
var getFormatName = function (style) {
|
|
return 'tablecell' + style.toLowerCase().replace('-', '');
|
|
};
|
|
if (!isObject(args)) {
|
|
return;
|
|
}
|
|
var cells = getCellsFromSelection(selections);
|
|
if (cells.length === 0) {
|
|
return;
|
|
}
|
|
var validArgs = filter$1(args, function (value, style) {
|
|
return editor.formatter.has(getFormatName(style)) && isString(value);
|
|
});
|
|
if (isEmpty(validArgs)) {
|
|
return;
|
|
}
|
|
each$1(validArgs, function (value, style) {
|
|
each$2(cells, function (cell) {
|
|
DomModifier.normal(editor, cell.dom).setFormat(getFormatName(style), value);
|
|
});
|
|
});
|
|
getTableFromCell(cells[0]).each(function (table) {
|
|
return fireTableModified(editor, table.dom, styleModified);
|
|
});
|
|
});
|
|
};
|
|
|
|
var registerQueryCommands = function (editor, actions, selections) {
|
|
var isRoot = getIsRoot(editor);
|
|
var lookupOnSelection = function (action) {
|
|
return getSelectionCell(getSelectionStart(editor)).bind(function (cell) {
|
|
return table(cell, isRoot).map(function (table) {
|
|
var targets = forMenu(selections, table, cell);
|
|
return action(table, targets);
|
|
});
|
|
}).getOr('');
|
|
};
|
|
each$1({
|
|
mceTableRowType: function () {
|
|
return lookupOnSelection(actions.getTableRowType);
|
|
},
|
|
mceTableCellType: function () {
|
|
return lookupOnSelection(actions.getTableCellType);
|
|
},
|
|
mceTableColType: function () {
|
|
return lookupOnSelection(actions.getTableColType);
|
|
}
|
|
}, function (func, name) {
|
|
return editor.addQueryValueHandler(name, func);
|
|
});
|
|
};
|
|
|
|
var Clipboard = function () {
|
|
var rows = value();
|
|
var cols = value();
|
|
return {
|
|
getRows: rows.get,
|
|
setRows: function (r) {
|
|
r.fold(rows.clear, rows.set);
|
|
cols.clear();
|
|
},
|
|
clearRows: rows.clear,
|
|
getColumns: cols.get,
|
|
setColumns: function (c) {
|
|
c.fold(cols.clear, cols.set);
|
|
rows.clear();
|
|
},
|
|
clearColumns: cols.clear
|
|
};
|
|
};
|
|
|
|
var genericBase = {
|
|
remove_similar: true,
|
|
inherit: false
|
|
};
|
|
var cellBase = __assign({ selector: 'td,th' }, genericBase);
|
|
var cellFormats = {
|
|
tablecellbackgroundcolor: __assign({ styles: { backgroundColor: '%value' } }, cellBase),
|
|
tablecellverticalalign: __assign({ styles: { 'vertical-align': '%value' } }, cellBase),
|
|
tablecellbordercolor: __assign({ styles: { borderColor: '%value' } }, cellBase),
|
|
tablecellclass: __assign({ classes: ['%value'] }, cellBase),
|
|
tableclass: __assign({
|
|
selector: 'table',
|
|
classes: ['%value']
|
|
}, genericBase),
|
|
tablecellborderstyle: __assign({ styles: { borderStyle: '%value' } }, cellBase),
|
|
tablecellborderwidth: __assign({ styles: { borderWidth: '%value' } }, cellBase)
|
|
};
|
|
var registerFormats = function (editor) {
|
|
editor.formatter.register(cellFormats);
|
|
};
|
|
|
|
var adt$5 = Adt.generate([
|
|
{ none: ['current'] },
|
|
{ first: ['current'] },
|
|
{
|
|
middle: [
|
|
'current',
|
|
'target'
|
|
]
|
|
},
|
|
{ last: ['current'] }
|
|
]);
|
|
var none = function (current) {
|
|
if (current === void 0) {
|
|
current = undefined;
|
|
}
|
|
return adt$5.none(current);
|
|
};
|
|
var CellLocation = __assign(__assign({}, adt$5), { none: none });
|
|
|
|
var walk = function (all, current, index, direction, isEligible) {
|
|
if (isEligible === void 0) {
|
|
isEligible = always;
|
|
}
|
|
var forwards = direction === 1;
|
|
if (!forwards && index <= 0) {
|
|
return CellLocation.first(all[0]);
|
|
} else if (forwards && index >= all.length - 1) {
|
|
return CellLocation.last(all[all.length - 1]);
|
|
} else {
|
|
var newIndex = index + direction;
|
|
var elem = all[newIndex];
|
|
return isEligible(elem) ? CellLocation.middle(current, elem) : walk(all, current, newIndex, direction, isEligible);
|
|
}
|
|
};
|
|
var detect$1 = function (current, isRoot) {
|
|
return table(current, isRoot).bind(function (table) {
|
|
var all = cells$1(table);
|
|
var index = findIndex(all, function (x) {
|
|
return eq$1(current, x);
|
|
});
|
|
return index.map(function (index) {
|
|
return {
|
|
index: index,
|
|
all: all
|
|
};
|
|
});
|
|
});
|
|
};
|
|
var next = function (current, isEligible, isRoot) {
|
|
var detection = detect$1(current, isRoot);
|
|
return detection.fold(function () {
|
|
return CellLocation.none(current);
|
|
}, function (info) {
|
|
return walk(info.all, current, info.index, 1, isEligible);
|
|
});
|
|
};
|
|
var prev = function (current, isEligible, isRoot) {
|
|
var detection = detect$1(current, isRoot);
|
|
return detection.fold(function () {
|
|
return CellLocation.none();
|
|
}, function (info) {
|
|
return walk(info.all, current, info.index, -1, isEligible);
|
|
});
|
|
};
|
|
|
|
var create$2 = function (start, soffset, finish, foffset) {
|
|
return {
|
|
start: start,
|
|
soffset: soffset,
|
|
finish: finish,
|
|
foffset: foffset
|
|
};
|
|
};
|
|
var SimRange = { create: create$2 };
|
|
|
|
var adt$4 = Adt.generate([
|
|
{ before: ['element'] },
|
|
{
|
|
on: [
|
|
'element',
|
|
'offset'
|
|
]
|
|
},
|
|
{ after: ['element'] }
|
|
]);
|
|
var cata$1 = function (subject, onBefore, onOn, onAfter) {
|
|
return subject.fold(onBefore, onOn, onAfter);
|
|
};
|
|
var getStart$1 = function (situ) {
|
|
return situ.fold(identity, identity, identity);
|
|
};
|
|
var before$2 = adt$4.before;
|
|
var on = adt$4.on;
|
|
var after$3 = adt$4.after;
|
|
var Situ = {
|
|
before: before$2,
|
|
on: on,
|
|
after: after$3,
|
|
cata: cata$1,
|
|
getStart: getStart$1
|
|
};
|
|
|
|
var adt$3 = Adt.generate([
|
|
{ domRange: ['rng'] },
|
|
{
|
|
relative: [
|
|
'startSitu',
|
|
'finishSitu'
|
|
]
|
|
},
|
|
{
|
|
exact: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
}
|
|
]);
|
|
var exactFromRange = function (simRange) {
|
|
return adt$3.exact(simRange.start, simRange.soffset, simRange.finish, simRange.foffset);
|
|
};
|
|
var getStart = function (selection) {
|
|
return selection.match({
|
|
domRange: function (rng) {
|
|
return SugarElement.fromDom(rng.startContainer);
|
|
},
|
|
relative: function (startSitu, _finishSitu) {
|
|
return Situ.getStart(startSitu);
|
|
},
|
|
exact: function (start, _soffset, _finish, _foffset) {
|
|
return start;
|
|
}
|
|
});
|
|
};
|
|
var domRange = adt$3.domRange;
|
|
var relative = adt$3.relative;
|
|
var exact = adt$3.exact;
|
|
var getWin = function (selection) {
|
|
var start = getStart(selection);
|
|
return defaultView(start);
|
|
};
|
|
var range = SimRange.create;
|
|
var SimSelection = {
|
|
domRange: domRange,
|
|
relative: relative,
|
|
exact: exact,
|
|
exactFromRange: exactFromRange,
|
|
getWin: getWin,
|
|
range: range
|
|
};
|
|
|
|
var selectNode = function (win, element) {
|
|
var rng = win.document.createRange();
|
|
rng.selectNode(element.dom);
|
|
return rng;
|
|
};
|
|
var selectNodeContents = function (win, element) {
|
|
var rng = win.document.createRange();
|
|
selectNodeContentsUsing(rng, element);
|
|
return rng;
|
|
};
|
|
var selectNodeContentsUsing = function (rng, element) {
|
|
return rng.selectNodeContents(element.dom);
|
|
};
|
|
var setStart = function (rng, situ) {
|
|
situ.fold(function (e) {
|
|
rng.setStartBefore(e.dom);
|
|
}, function (e, o) {
|
|
rng.setStart(e.dom, o);
|
|
}, function (e) {
|
|
rng.setStartAfter(e.dom);
|
|
});
|
|
};
|
|
var setFinish = function (rng, situ) {
|
|
situ.fold(function (e) {
|
|
rng.setEndBefore(e.dom);
|
|
}, function (e, o) {
|
|
rng.setEnd(e.dom, o);
|
|
}, function (e) {
|
|
rng.setEndAfter(e.dom);
|
|
});
|
|
};
|
|
var relativeToNative = function (win, startSitu, finishSitu) {
|
|
var range = win.document.createRange();
|
|
setStart(range, startSitu);
|
|
setFinish(range, finishSitu);
|
|
return range;
|
|
};
|
|
var exactToNative = function (win, start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
};
|
|
var toRect = function (rect) {
|
|
return {
|
|
left: rect.left,
|
|
top: rect.top,
|
|
right: rect.right,
|
|
bottom: rect.bottom,
|
|
width: rect.width,
|
|
height: rect.height
|
|
};
|
|
};
|
|
var getFirstRect$1 = function (rng) {
|
|
var rects = rng.getClientRects();
|
|
var rect = rects.length > 0 ? rects[0] : rng.getBoundingClientRect();
|
|
return rect.width > 0 || rect.height > 0 ? Optional.some(rect).map(toRect) : Optional.none();
|
|
};
|
|
|
|
var adt$2 = Adt.generate([
|
|
{
|
|
ltr: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
},
|
|
{
|
|
rtl: [
|
|
'start',
|
|
'soffset',
|
|
'finish',
|
|
'foffset'
|
|
]
|
|
}
|
|
]);
|
|
var fromRange = function (win, type, range) {
|
|
return type(SugarElement.fromDom(range.startContainer), range.startOffset, SugarElement.fromDom(range.endContainer), range.endOffset);
|
|
};
|
|
var getRanges = function (win, selection) {
|
|
return selection.match({
|
|
domRange: function (rng) {
|
|
return {
|
|
ltr: constant(rng),
|
|
rtl: Optional.none
|
|
};
|
|
},
|
|
relative: function (startSitu, finishSitu) {
|
|
return {
|
|
ltr: cached(function () {
|
|
return relativeToNative(win, startSitu, finishSitu);
|
|
}),
|
|
rtl: cached(function () {
|
|
return Optional.some(relativeToNative(win, finishSitu, startSitu));
|
|
})
|
|
};
|
|
},
|
|
exact: function (start, soffset, finish, foffset) {
|
|
return {
|
|
ltr: cached(function () {
|
|
return exactToNative(win, start, soffset, finish, foffset);
|
|
}),
|
|
rtl: cached(function () {
|
|
return Optional.some(exactToNative(win, finish, foffset, start, soffset));
|
|
})
|
|
};
|
|
}
|
|
});
|
|
};
|
|
var doDiagnose = function (win, ranges) {
|
|
var rng = ranges.ltr();
|
|
if (rng.collapsed) {
|
|
var reversed = ranges.rtl().filter(function (rev) {
|
|
return rev.collapsed === false;
|
|
});
|
|
return reversed.map(function (rev) {
|
|
return adt$2.rtl(SugarElement.fromDom(rev.endContainer), rev.endOffset, SugarElement.fromDom(rev.startContainer), rev.startOffset);
|
|
}).getOrThunk(function () {
|
|
return fromRange(win, adt$2.ltr, rng);
|
|
});
|
|
} else {
|
|
return fromRange(win, adt$2.ltr, rng);
|
|
}
|
|
};
|
|
var diagnose = function (win, selection) {
|
|
var ranges = getRanges(win, selection);
|
|
return doDiagnose(win, ranges);
|
|
};
|
|
var asLtrRange = function (win, selection) {
|
|
var diagnosis = diagnose(win, selection);
|
|
return diagnosis.match({
|
|
ltr: function (start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
},
|
|
rtl: function (start, soffset, finish, foffset) {
|
|
var rng = win.document.createRange();
|
|
rng.setStart(finish.dom, foffset);
|
|
rng.setEnd(start.dom, soffset);
|
|
return rng;
|
|
}
|
|
});
|
|
};
|
|
adt$2.ltr;
|
|
adt$2.rtl;
|
|
|
|
var searchForPoint = function (rectForOffset, x, y, maxX, length) {
|
|
if (length === 0) {
|
|
return 0;
|
|
} else if (x === maxX) {
|
|
return length - 1;
|
|
}
|
|
var xDelta = maxX;
|
|
for (var i = 1; i < length; i++) {
|
|
var rect = rectForOffset(i);
|
|
var curDeltaX = Math.abs(x - rect.left);
|
|
if (y <= rect.bottom) {
|
|
if (y < rect.top || curDeltaX > xDelta) {
|
|
return i - 1;
|
|
} else {
|
|
xDelta = curDeltaX;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
};
|
|
var inRect = function (rect, x, y) {
|
|
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
|
};
|
|
|
|
var locateOffset = function (doc, textnode, x, y, rect) {
|
|
var rangeForOffset = function (o) {
|
|
var r = doc.dom.createRange();
|
|
r.setStart(textnode.dom, o);
|
|
r.collapse(true);
|
|
return r;
|
|
};
|
|
var rectForOffset = function (o) {
|
|
var r = rangeForOffset(o);
|
|
return r.getBoundingClientRect();
|
|
};
|
|
var length = get$9(textnode).length;
|
|
var offset = searchForPoint(rectForOffset, x, y, rect.right, length);
|
|
return rangeForOffset(offset);
|
|
};
|
|
var locate$1 = function (doc, node, x, y) {
|
|
var r = doc.dom.createRange();
|
|
r.selectNode(node.dom);
|
|
var rects = r.getClientRects();
|
|
var foundRect = findMap(rects, function (rect) {
|
|
return inRect(rect, x, y) ? Optional.some(rect) : Optional.none();
|
|
});
|
|
return foundRect.map(function (rect) {
|
|
return locateOffset(doc, node, x, y, rect);
|
|
});
|
|
};
|
|
|
|
var searchInChildren = function (doc, node, x, y) {
|
|
var r = doc.dom.createRange();
|
|
var nodes = children$3(node);
|
|
return findMap(nodes, function (n) {
|
|
r.selectNode(n.dom);
|
|
return inRect(r.getBoundingClientRect(), x, y) ? locateNode(doc, n, x, y) : Optional.none();
|
|
});
|
|
};
|
|
var locateNode = function (doc, node, x, y) {
|
|
return isText(node) ? locate$1(doc, node, x, y) : searchInChildren(doc, node, x, y);
|
|
};
|
|
var locate = function (doc, node, x, y) {
|
|
var r = doc.dom.createRange();
|
|
r.selectNode(node.dom);
|
|
var rect = r.getBoundingClientRect();
|
|
var boundedX = Math.max(rect.left, Math.min(rect.right, x));
|
|
var boundedY = Math.max(rect.top, Math.min(rect.bottom, y));
|
|
return locateNode(doc, node, boundedX, boundedY);
|
|
};
|
|
|
|
var COLLAPSE_TO_LEFT = true;
|
|
var COLLAPSE_TO_RIGHT = false;
|
|
var getCollapseDirection = function (rect, x) {
|
|
return x - rect.left < rect.right - x ? COLLAPSE_TO_LEFT : COLLAPSE_TO_RIGHT;
|
|
};
|
|
var createCollapsedNode = function (doc, target, collapseDirection) {
|
|
var r = doc.dom.createRange();
|
|
r.selectNode(target.dom);
|
|
r.collapse(collapseDirection);
|
|
return r;
|
|
};
|
|
var locateInElement = function (doc, node, x) {
|
|
var cursorRange = doc.dom.createRange();
|
|
cursorRange.selectNode(node.dom);
|
|
var rect = cursorRange.getBoundingClientRect();
|
|
var collapseDirection = getCollapseDirection(rect, x);
|
|
var f = collapseDirection === COLLAPSE_TO_LEFT ? first : last$1;
|
|
return f(node).map(function (target) {
|
|
return createCollapsedNode(doc, target, collapseDirection);
|
|
});
|
|
};
|
|
var locateInEmpty = function (doc, node, x) {
|
|
var rect = node.dom.getBoundingClientRect();
|
|
var collapseDirection = getCollapseDirection(rect, x);
|
|
return Optional.some(createCollapsedNode(doc, node, collapseDirection));
|
|
};
|
|
var search = function (doc, node, x) {
|
|
var f = children$3(node).length === 0 ? locateInEmpty : locateInElement;
|
|
return f(doc, node, x);
|
|
};
|
|
|
|
var caretPositionFromPoint = function (doc, x, y) {
|
|
var _a, _b;
|
|
return Optional.from((_b = (_a = doc.dom).caretPositionFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y)).bind(function (pos) {
|
|
if (pos.offsetNode === null) {
|
|
return Optional.none();
|
|
}
|
|
var r = doc.dom.createRange();
|
|
r.setStart(pos.offsetNode, pos.offset);
|
|
r.collapse();
|
|
return Optional.some(r);
|
|
});
|
|
};
|
|
var caretRangeFromPoint = function (doc, x, y) {
|
|
var _a, _b;
|
|
return Optional.from((_b = (_a = doc.dom).caretRangeFromPoint) === null || _b === void 0 ? void 0 : _b.call(_a, x, y));
|
|
};
|
|
var searchTextNodes = function (doc, node, x, y) {
|
|
var r = doc.dom.createRange();
|
|
r.selectNode(node.dom);
|
|
var rect = r.getBoundingClientRect();
|
|
var boundedX = Math.max(rect.left, Math.min(rect.right, x));
|
|
var boundedY = Math.max(rect.top, Math.min(rect.bottom, y));
|
|
return locate(doc, node, boundedX, boundedY);
|
|
};
|
|
var searchFromPoint = function (doc, x, y) {
|
|
return SugarElement.fromPoint(doc, x, y).bind(function (elem) {
|
|
var fallback = function () {
|
|
return search(doc, elem, x);
|
|
};
|
|
return children$3(elem).length === 0 ? fallback() : searchTextNodes(doc, elem, x, y).orThunk(fallback);
|
|
});
|
|
};
|
|
var availableSearch = function () {
|
|
if (document.caretPositionFromPoint) {
|
|
return caretPositionFromPoint;
|
|
} else if (document.caretRangeFromPoint) {
|
|
return caretRangeFromPoint;
|
|
} else {
|
|
return searchFromPoint;
|
|
}
|
|
}();
|
|
var fromPoint = function (win, x, y) {
|
|
var doc = SugarElement.fromDom(win.document);
|
|
return availableSearch(doc, x, y).map(function (rng) {
|
|
return SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset);
|
|
});
|
|
};
|
|
|
|
var beforeSpecial = function (element, offset) {
|
|
var name$1 = name(element);
|
|
if ('input' === name$1) {
|
|
return Situ.after(element);
|
|
} else if (!contains$2([
|
|
'br',
|
|
'img'
|
|
], name$1)) {
|
|
return Situ.on(element, offset);
|
|
} else {
|
|
return offset === 0 ? Situ.before(element) : Situ.after(element);
|
|
}
|
|
};
|
|
var preprocessRelative = function (startSitu, finishSitu) {
|
|
var start = startSitu.fold(Situ.before, beforeSpecial, Situ.after);
|
|
var finish = finishSitu.fold(Situ.before, beforeSpecial, Situ.after);
|
|
return SimSelection.relative(start, finish);
|
|
};
|
|
var preprocessExact = function (start, soffset, finish, foffset) {
|
|
var startSitu = beforeSpecial(start, soffset);
|
|
var finishSitu = beforeSpecial(finish, foffset);
|
|
return SimSelection.relative(startSitu, finishSitu);
|
|
};
|
|
var preprocess = function (selection) {
|
|
return selection.match({
|
|
domRange: function (rng) {
|
|
var start = SugarElement.fromDom(rng.startContainer);
|
|
var finish = SugarElement.fromDom(rng.endContainer);
|
|
return preprocessExact(start, rng.startOffset, finish, rng.endOffset);
|
|
},
|
|
relative: preprocessRelative,
|
|
exact: preprocessExact
|
|
});
|
|
};
|
|
|
|
var makeRange = function (start, soffset, finish, foffset) {
|
|
var doc = owner(start);
|
|
var rng = doc.dom.createRange();
|
|
rng.setStart(start.dom, soffset);
|
|
rng.setEnd(finish.dom, foffset);
|
|
return rng;
|
|
};
|
|
var after$2 = function (start, soffset, finish, foffset) {
|
|
var r = makeRange(start, soffset, finish, foffset);
|
|
var same = eq$1(start, finish) && soffset === foffset;
|
|
return r.collapsed && !same;
|
|
};
|
|
|
|
var getNativeSelection = function (win) {
|
|
return Optional.from(win.getSelection());
|
|
};
|
|
var doSetNativeRange = function (win, rng) {
|
|
getNativeSelection(win).each(function (selection) {
|
|
selection.removeAllRanges();
|
|
selection.addRange(rng);
|
|
});
|
|
};
|
|
var doSetRange = function (win, start, soffset, finish, foffset) {
|
|
var rng = exactToNative(win, start, soffset, finish, foffset);
|
|
doSetNativeRange(win, rng);
|
|
};
|
|
var setLegacyRtlRange = function (win, selection, start, soffset, finish, foffset) {
|
|
selection.collapse(start.dom, soffset);
|
|
selection.extend(finish.dom, foffset);
|
|
};
|
|
var setRangeFromRelative = function (win, relative) {
|
|
return diagnose(win, relative).match({
|
|
ltr: function (start, soffset, finish, foffset) {
|
|
doSetRange(win, start, soffset, finish, foffset);
|
|
},
|
|
rtl: function (start, soffset, finish, foffset) {
|
|
getNativeSelection(win).each(function (selection) {
|
|
if (selection.setBaseAndExtent) {
|
|
selection.setBaseAndExtent(start.dom, soffset, finish.dom, foffset);
|
|
} else if (selection.extend) {
|
|
try {
|
|
setLegacyRtlRange(win, selection, start, soffset, finish, foffset);
|
|
} catch (e) {
|
|
doSetRange(win, finish, foffset, start, soffset);
|
|
}
|
|
} else {
|
|
doSetRange(win, finish, foffset, start, soffset);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var setExact = function (win, start, soffset, finish, foffset) {
|
|
var relative = preprocessExact(start, soffset, finish, foffset);
|
|
setRangeFromRelative(win, relative);
|
|
};
|
|
var setRelative = function (win, startSitu, finishSitu) {
|
|
var relative = preprocessRelative(startSitu, finishSitu);
|
|
setRangeFromRelative(win, relative);
|
|
};
|
|
var toNative = function (selection) {
|
|
var win = SimSelection.getWin(selection).dom;
|
|
var getDomRange = function (start, soffset, finish, foffset) {
|
|
return exactToNative(win, start, soffset, finish, foffset);
|
|
};
|
|
var filtered = preprocess(selection);
|
|
return diagnose(win, filtered).match({
|
|
ltr: getDomRange,
|
|
rtl: getDomRange
|
|
});
|
|
};
|
|
var readRange = function (selection) {
|
|
if (selection.rangeCount > 0) {
|
|
var firstRng = selection.getRangeAt(0);
|
|
var lastRng = selection.getRangeAt(selection.rangeCount - 1);
|
|
return Optional.some(SimRange.create(SugarElement.fromDom(firstRng.startContainer), firstRng.startOffset, SugarElement.fromDom(lastRng.endContainer), lastRng.endOffset));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var doGetExact = function (selection) {
|
|
if (selection.anchorNode === null || selection.focusNode === null) {
|
|
return readRange(selection);
|
|
} else {
|
|
var anchor = SugarElement.fromDom(selection.anchorNode);
|
|
var focus_1 = SugarElement.fromDom(selection.focusNode);
|
|
return after$2(anchor, selection.anchorOffset, focus_1, selection.focusOffset) ? Optional.some(SimRange.create(anchor, selection.anchorOffset, focus_1, selection.focusOffset)) : readRange(selection);
|
|
}
|
|
};
|
|
var setToElement = function (win, element, selectNodeContents$1) {
|
|
if (selectNodeContents$1 === void 0) {
|
|
selectNodeContents$1 = true;
|
|
}
|
|
var rngGetter = selectNodeContents$1 ? selectNodeContents : selectNode;
|
|
var rng = rngGetter(win, element);
|
|
doSetNativeRange(win, rng);
|
|
};
|
|
var getExact = function (win) {
|
|
return getNativeSelection(win).filter(function (sel) {
|
|
return sel.rangeCount > 0;
|
|
}).bind(doGetExact);
|
|
};
|
|
var get$1 = function (win) {
|
|
return getExact(win).map(function (range) {
|
|
return SimSelection.exact(range.start, range.soffset, range.finish, range.foffset);
|
|
});
|
|
};
|
|
var getFirstRect = function (win, selection) {
|
|
var rng = asLtrRange(win, selection);
|
|
return getFirstRect$1(rng);
|
|
};
|
|
var getAtPoint = function (win, x, y) {
|
|
return fromPoint(win, x, y);
|
|
};
|
|
var clear = function (win) {
|
|
getNativeSelection(win).each(function (selection) {
|
|
return selection.removeAllRanges();
|
|
});
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var forward = function (editor, isRoot, cell) {
|
|
return go$1(editor, isRoot, next(cell, isEditable$1));
|
|
};
|
|
var backward = function (editor, isRoot, cell) {
|
|
return go$1(editor, isRoot, prev(cell, isEditable$1));
|
|
};
|
|
var getCellFirstCursorPosition = function (editor, cell) {
|
|
var selection = SimSelection.exact(cell, 0, cell, 0);
|
|
return toNative(selection);
|
|
};
|
|
var go$1 = function (editor, isRoot, cell) {
|
|
return cell.fold(Optional.none, Optional.none, function (current, next) {
|
|
return first(next).map(function (cell) {
|
|
return getCellFirstCursorPosition(editor, cell);
|
|
});
|
|
}, function (current) {
|
|
editor.execCommand('mceTableInsertRowAfter');
|
|
return forward(editor, isRoot, current);
|
|
});
|
|
};
|
|
var rootElements = [
|
|
'table',
|
|
'li',
|
|
'dl'
|
|
];
|
|
var handle$1 = function (event, editor, cellSelection) {
|
|
if (event.keyCode === global$1.TAB) {
|
|
var body_1 = getBody(editor);
|
|
var isRoot_1 = function (element) {
|
|
var name$1 = name(element);
|
|
return eq$1(element, body_1) || contains$2(rootElements, name$1);
|
|
};
|
|
var rng = editor.selection.getRng();
|
|
var container = SugarElement.fromDom(event.shiftKey ? rng.startContainer : rng.endContainer);
|
|
cell(container, isRoot_1).each(function (cell) {
|
|
event.preventDefault();
|
|
table(cell, isRoot_1).each(cellSelection.clear);
|
|
editor.selection.collapse(event.shiftKey);
|
|
var navigation = event.shiftKey ? backward : forward;
|
|
var rng = navigation(editor, isRoot_1, cell);
|
|
rng.each(function (range) {
|
|
editor.selection.setRng(range);
|
|
});
|
|
});
|
|
}
|
|
};
|
|
|
|
var create$1 = function (selection, kill) {
|
|
return {
|
|
selection: selection,
|
|
kill: kill
|
|
};
|
|
};
|
|
var Response = { create: create$1 };
|
|
|
|
var create = function (start, soffset, finish, foffset) {
|
|
return {
|
|
start: Situ.on(start, soffset),
|
|
finish: Situ.on(finish, foffset)
|
|
};
|
|
};
|
|
var Situs = { create: create };
|
|
|
|
var convertToRange = function (win, selection) {
|
|
var rng = asLtrRange(win, selection);
|
|
return SimRange.create(SugarElement.fromDom(rng.startContainer), rng.startOffset, SugarElement.fromDom(rng.endContainer), rng.endOffset);
|
|
};
|
|
var makeSitus = Situs.create;
|
|
|
|
var sync = function (container, isRoot, start, soffset, finish, foffset, selectRange) {
|
|
if (!(eq$1(start, finish) && soffset === foffset)) {
|
|
return closest$1(start, 'td,th', isRoot).bind(function (s) {
|
|
return closest$1(finish, 'td,th', isRoot).bind(function (f) {
|
|
return detect(container, isRoot, s, f, selectRange);
|
|
});
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var detect = function (container, isRoot, start, finish, selectRange) {
|
|
if (!eq$1(start, finish)) {
|
|
return identify(start, finish, isRoot).bind(function (cellSel) {
|
|
var boxes = cellSel.boxes.getOr([]);
|
|
if (boxes.length > 1) {
|
|
selectRange(container, boxes, cellSel.start, cellSel.finish);
|
|
return Optional.some(Response.create(Optional.some(makeSitus(start, 0, start, getEnd(start))), true));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var update = function (rows, columns, container, selected, annotations) {
|
|
var updateSelection = function (newSels) {
|
|
annotations.clearBeforeUpdate(container);
|
|
annotations.selectRange(container, newSels.boxes, newSels.start, newSels.finish);
|
|
return newSels.boxes;
|
|
};
|
|
return shiftSelection(selected, rows, columns, annotations.firstSelectedSelector, annotations.lastSelectedSelector).map(updateSelection);
|
|
};
|
|
|
|
var traverse = function (item, mode) {
|
|
return {
|
|
item: item,
|
|
mode: mode
|
|
};
|
|
};
|
|
var backtrack = function (universe, item, _direction, transition) {
|
|
if (transition === void 0) {
|
|
transition = sidestep;
|
|
}
|
|
return universe.property().parent(item).map(function (p) {
|
|
return traverse(p, transition);
|
|
});
|
|
};
|
|
var sidestep = function (universe, item, direction, transition) {
|
|
if (transition === void 0) {
|
|
transition = advance;
|
|
}
|
|
return direction.sibling(universe, item).map(function (p) {
|
|
return traverse(p, transition);
|
|
});
|
|
};
|
|
var advance = function (universe, item, direction, transition) {
|
|
if (transition === void 0) {
|
|
transition = advance;
|
|
}
|
|
var children = universe.property().children(item);
|
|
var result = direction.first(children);
|
|
return result.map(function (r) {
|
|
return traverse(r, transition);
|
|
});
|
|
};
|
|
var successors = [
|
|
{
|
|
current: backtrack,
|
|
next: sidestep,
|
|
fallback: Optional.none()
|
|
},
|
|
{
|
|
current: sidestep,
|
|
next: advance,
|
|
fallback: Optional.some(backtrack)
|
|
},
|
|
{
|
|
current: advance,
|
|
next: advance,
|
|
fallback: Optional.some(sidestep)
|
|
}
|
|
];
|
|
var go = function (universe, item, mode, direction, rules) {
|
|
if (rules === void 0) {
|
|
rules = successors;
|
|
}
|
|
var ruleOpt = find$1(rules, function (succ) {
|
|
return succ.current === mode;
|
|
});
|
|
return ruleOpt.bind(function (rule) {
|
|
return rule.current(universe, item, direction, rule.next).orThunk(function () {
|
|
return rule.fallback.bind(function (fb) {
|
|
return go(universe, item, fb, direction);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
|
|
var left$1 = function () {
|
|
var sibling = function (universe, item) {
|
|
return universe.query().prevSibling(item);
|
|
};
|
|
var first = function (children) {
|
|
return children.length > 0 ? Optional.some(children[children.length - 1]) : Optional.none();
|
|
};
|
|
return {
|
|
sibling: sibling,
|
|
first: first
|
|
};
|
|
};
|
|
var right$1 = function () {
|
|
var sibling = function (universe, item) {
|
|
return universe.query().nextSibling(item);
|
|
};
|
|
var first = function (children) {
|
|
return children.length > 0 ? Optional.some(children[0]) : Optional.none();
|
|
};
|
|
return {
|
|
sibling: sibling,
|
|
first: first
|
|
};
|
|
};
|
|
var Walkers = {
|
|
left: left$1,
|
|
right: right$1
|
|
};
|
|
|
|
var hone = function (universe, item, predicate, mode, direction, isRoot) {
|
|
var next = go(universe, item, mode, direction);
|
|
return next.bind(function (n) {
|
|
if (isRoot(n.item)) {
|
|
return Optional.none();
|
|
} else {
|
|
return predicate(n.item) ? Optional.some(n.item) : hone(universe, n.item, predicate, n.mode, direction, isRoot);
|
|
}
|
|
});
|
|
};
|
|
var left = function (universe, item, predicate, isRoot) {
|
|
return hone(universe, item, predicate, sidestep, Walkers.left(), isRoot);
|
|
};
|
|
var right = function (universe, item, predicate, isRoot) {
|
|
return hone(universe, item, predicate, sidestep, Walkers.right(), isRoot);
|
|
};
|
|
|
|
var isLeaf = function (universe) {
|
|
return function (element) {
|
|
return universe.property().children(element).length === 0;
|
|
};
|
|
};
|
|
var before$1 = function (universe, item, isRoot) {
|
|
return seekLeft$1(universe, item, isLeaf(universe), isRoot);
|
|
};
|
|
var after$1 = function (universe, item, isRoot) {
|
|
return seekRight$1(universe, item, isLeaf(universe), isRoot);
|
|
};
|
|
var seekLeft$1 = left;
|
|
var seekRight$1 = right;
|
|
|
|
var universe = DomUniverse();
|
|
var before = function (element, isRoot) {
|
|
return before$1(universe, element, isRoot);
|
|
};
|
|
var after = function (element, isRoot) {
|
|
return after$1(universe, element, isRoot);
|
|
};
|
|
var seekLeft = function (element, predicate, isRoot) {
|
|
return seekLeft$1(universe, element, predicate, isRoot);
|
|
};
|
|
var seekRight = function (element, predicate, isRoot) {
|
|
return seekRight$1(universe, element, predicate, isRoot);
|
|
};
|
|
|
|
var ancestor = function (scope, predicate, isRoot) {
|
|
return ancestor$2(scope, predicate, isRoot).isSome();
|
|
};
|
|
|
|
var adt$1 = Adt.generate([
|
|
{ none: ['message'] },
|
|
{ success: [] },
|
|
{ failedUp: ['cell'] },
|
|
{ failedDown: ['cell'] }
|
|
]);
|
|
var isOverlapping = function (bridge, before, after) {
|
|
var beforeBounds = bridge.getRect(before);
|
|
var afterBounds = bridge.getRect(after);
|
|
return afterBounds.right > beforeBounds.left && afterBounds.left < beforeBounds.right;
|
|
};
|
|
var isRow = function (elem) {
|
|
return closest$1(elem, 'tr');
|
|
};
|
|
var verify = function (bridge, before, beforeOffset, after, afterOffset, failure, isRoot) {
|
|
return closest$1(after, 'td,th', isRoot).bind(function (afterCell) {
|
|
return closest$1(before, 'td,th', isRoot).map(function (beforeCell) {
|
|
if (!eq$1(afterCell, beforeCell)) {
|
|
return sharedOne(isRow, [
|
|
afterCell,
|
|
beforeCell
|
|
]).fold(function () {
|
|
return isOverlapping(bridge, beforeCell, afterCell) ? adt$1.success() : failure(beforeCell);
|
|
}, function (_sharedRow) {
|
|
return failure(beforeCell);
|
|
});
|
|
} else {
|
|
return eq$1(after, afterCell) && getEnd(afterCell) === afterOffset ? failure(beforeCell) : adt$1.none('in same cell');
|
|
}
|
|
});
|
|
}).getOr(adt$1.none('default'));
|
|
};
|
|
var cata = function (subject, onNone, onSuccess, onFailedUp, onFailedDown) {
|
|
return subject.fold(onNone, onSuccess, onFailedUp, onFailedDown);
|
|
};
|
|
var BeforeAfter = __assign(__assign({}, adt$1), {
|
|
verify: verify,
|
|
cata: cata
|
|
});
|
|
|
|
var inParent = function (parent, children, element, index) {
|
|
return {
|
|
parent: parent,
|
|
children: children,
|
|
element: element,
|
|
index: index
|
|
};
|
|
};
|
|
var indexInParent = function (element) {
|
|
return parent(element).bind(function (parent) {
|
|
var children = children$3(parent);
|
|
return indexOf(children, element).map(function (index) {
|
|
return inParent(parent, children, element, index);
|
|
});
|
|
});
|
|
};
|
|
var indexOf = function (elements, element) {
|
|
return findIndex(elements, curry(eq$1, element));
|
|
};
|
|
|
|
var isBr = function (elem) {
|
|
return name(elem) === 'br';
|
|
};
|
|
var gatherer = function (cand, gather, isRoot) {
|
|
return gather(cand, isRoot).bind(function (target) {
|
|
return isText(target) && get$9(target).trim().length === 0 ? gatherer(target, gather, isRoot) : Optional.some(target);
|
|
});
|
|
};
|
|
var handleBr = function (isRoot, element, direction) {
|
|
return direction.traverse(element).orThunk(function () {
|
|
return gatherer(element, direction.gather, isRoot);
|
|
}).map(direction.relative);
|
|
};
|
|
var findBr = function (element, offset) {
|
|
return child$3(element, offset).filter(isBr).orThunk(function () {
|
|
return child$3(element, offset - 1).filter(isBr);
|
|
});
|
|
};
|
|
var handleParent = function (isRoot, element, offset, direction) {
|
|
return findBr(element, offset).bind(function (br) {
|
|
return direction.traverse(br).fold(function () {
|
|
return gatherer(br, direction.gather, isRoot).map(direction.relative);
|
|
}, function (adjacent) {
|
|
return indexInParent(adjacent).map(function (info) {
|
|
return Situ.on(info.parent, info.index);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var tryBr = function (isRoot, element, offset, direction) {
|
|
var target = isBr(element) ? handleBr(isRoot, element, direction) : handleParent(isRoot, element, offset, direction);
|
|
return target.map(function (tgt) {
|
|
return {
|
|
start: tgt,
|
|
finish: tgt
|
|
};
|
|
});
|
|
};
|
|
var process = function (analysis) {
|
|
return BeforeAfter.cata(analysis, function (_message) {
|
|
return Optional.none();
|
|
}, function () {
|
|
return Optional.none();
|
|
}, function (cell) {
|
|
return Optional.some(point(cell, 0));
|
|
}, function (cell) {
|
|
return Optional.some(point(cell, getEnd(cell)));
|
|
});
|
|
};
|
|
|
|
var moveDown = function (caret, amount) {
|
|
return {
|
|
left: caret.left,
|
|
top: caret.top + amount,
|
|
right: caret.right,
|
|
bottom: caret.bottom + amount
|
|
};
|
|
};
|
|
var moveUp = function (caret, amount) {
|
|
return {
|
|
left: caret.left,
|
|
top: caret.top - amount,
|
|
right: caret.right,
|
|
bottom: caret.bottom - amount
|
|
};
|
|
};
|
|
var translate = function (caret, xDelta, yDelta) {
|
|
return {
|
|
left: caret.left + xDelta,
|
|
top: caret.top + yDelta,
|
|
right: caret.right + xDelta,
|
|
bottom: caret.bottom + yDelta
|
|
};
|
|
};
|
|
var getTop = function (caret) {
|
|
return caret.top;
|
|
};
|
|
var getBottom = function (caret) {
|
|
return caret.bottom;
|
|
};
|
|
|
|
var getPartialBox = function (bridge, element, offset) {
|
|
if (offset >= 0 && offset < getEnd(element)) {
|
|
return bridge.getRangedRect(element, offset, element, offset + 1);
|
|
} else if (offset > 0) {
|
|
return bridge.getRangedRect(element, offset - 1, element, offset);
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var toCaret = function (rect) {
|
|
return {
|
|
left: rect.left,
|
|
top: rect.top,
|
|
right: rect.right,
|
|
bottom: rect.bottom
|
|
};
|
|
};
|
|
var getElemBox = function (bridge, element) {
|
|
return Optional.some(bridge.getRect(element));
|
|
};
|
|
var getBoxAt = function (bridge, element, offset) {
|
|
if (isElement(element)) {
|
|
return getElemBox(bridge, element).map(toCaret);
|
|
} else if (isText(element)) {
|
|
return getPartialBox(bridge, element, offset).map(toCaret);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var getEntireBox = function (bridge, element) {
|
|
if (isElement(element)) {
|
|
return getElemBox(bridge, element).map(toCaret);
|
|
} else if (isText(element)) {
|
|
return bridge.getRangedRect(element, 0, element, getEnd(element)).map(toCaret);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
|
|
var JUMP_SIZE = 5;
|
|
var NUM_RETRIES = 100;
|
|
var adt = Adt.generate([
|
|
{ none: [] },
|
|
{ retry: ['caret'] }
|
|
]);
|
|
var isOutside = function (caret, box) {
|
|
return caret.left < box.left || Math.abs(box.right - caret.left) < 1 || caret.left > box.right;
|
|
};
|
|
var inOutsideBlock = function (bridge, element, caret) {
|
|
return closest$2(element, isBlock).fold(never, function (cell) {
|
|
return getEntireBox(bridge, cell).exists(function (box) {
|
|
return isOutside(caret, box);
|
|
});
|
|
});
|
|
};
|
|
var adjustDown = function (bridge, element, guessBox, original, caret) {
|
|
var lowerCaret = moveDown(caret, JUMP_SIZE);
|
|
if (Math.abs(guessBox.bottom - original.bottom) < 1) {
|
|
return adt.retry(lowerCaret);
|
|
} else if (guessBox.top > caret.bottom) {
|
|
return adt.retry(lowerCaret);
|
|
} else if (guessBox.top === caret.bottom) {
|
|
return adt.retry(moveDown(caret, 1));
|
|
} else {
|
|
return inOutsideBlock(bridge, element, caret) ? adt.retry(translate(lowerCaret, JUMP_SIZE, 0)) : adt.none();
|
|
}
|
|
};
|
|
var adjustUp = function (bridge, element, guessBox, original, caret) {
|
|
var higherCaret = moveUp(caret, JUMP_SIZE);
|
|
if (Math.abs(guessBox.top - original.top) < 1) {
|
|
return adt.retry(higherCaret);
|
|
} else if (guessBox.bottom < caret.top) {
|
|
return adt.retry(higherCaret);
|
|
} else if (guessBox.bottom === caret.top) {
|
|
return adt.retry(moveUp(caret, 1));
|
|
} else {
|
|
return inOutsideBlock(bridge, element, caret) ? adt.retry(translate(higherCaret, JUMP_SIZE, 0)) : adt.none();
|
|
}
|
|
};
|
|
var upMovement = {
|
|
point: getTop,
|
|
adjuster: adjustUp,
|
|
move: moveUp,
|
|
gather: before
|
|
};
|
|
var downMovement = {
|
|
point: getBottom,
|
|
adjuster: adjustDown,
|
|
move: moveDown,
|
|
gather: after
|
|
};
|
|
var isAtTable = function (bridge, x, y) {
|
|
return bridge.elementFromPoint(x, y).filter(function (elm) {
|
|
return name(elm) === 'table';
|
|
}).isSome();
|
|
};
|
|
var adjustForTable = function (bridge, movement, original, caret, numRetries) {
|
|
return adjustTil(bridge, movement, original, movement.move(caret, JUMP_SIZE), numRetries);
|
|
};
|
|
var adjustTil = function (bridge, movement, original, caret, numRetries) {
|
|
if (numRetries === 0) {
|
|
return Optional.some(caret);
|
|
}
|
|
if (isAtTable(bridge, caret.left, movement.point(caret))) {
|
|
return adjustForTable(bridge, movement, original, caret, numRetries - 1);
|
|
}
|
|
return bridge.situsFromPoint(caret.left, movement.point(caret)).bind(function (guess) {
|
|
return guess.start.fold(Optional.none, function (element) {
|
|
return getEntireBox(bridge, element).bind(function (guessBox) {
|
|
return movement.adjuster(bridge, element, guessBox, original, caret).fold(Optional.none, function (newCaret) {
|
|
return adjustTil(bridge, movement, original, newCaret, numRetries - 1);
|
|
});
|
|
}).orThunk(function () {
|
|
return Optional.some(caret);
|
|
});
|
|
}, Optional.none);
|
|
});
|
|
};
|
|
var ieTryDown = function (bridge, caret) {
|
|
return bridge.situsFromPoint(caret.left, caret.bottom + JUMP_SIZE);
|
|
};
|
|
var ieTryUp = function (bridge, caret) {
|
|
return bridge.situsFromPoint(caret.left, caret.top - JUMP_SIZE);
|
|
};
|
|
var checkScroll = function (movement, adjusted, bridge) {
|
|
if (movement.point(adjusted) > bridge.getInnerHeight()) {
|
|
return Optional.some(movement.point(adjusted) - bridge.getInnerHeight());
|
|
} else if (movement.point(adjusted) < 0) {
|
|
return Optional.some(-movement.point(adjusted));
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var retry = function (movement, bridge, caret) {
|
|
var moved = movement.move(caret, JUMP_SIZE);
|
|
var adjusted = adjustTil(bridge, movement, caret, moved, NUM_RETRIES).getOr(moved);
|
|
return checkScroll(movement, adjusted, bridge).fold(function () {
|
|
return bridge.situsFromPoint(adjusted.left, movement.point(adjusted));
|
|
}, function (delta) {
|
|
bridge.scrollBy(0, delta);
|
|
return bridge.situsFromPoint(adjusted.left, movement.point(adjusted) - delta);
|
|
});
|
|
};
|
|
var Retries = {
|
|
tryUp: curry(retry, upMovement),
|
|
tryDown: curry(retry, downMovement),
|
|
ieTryUp: ieTryUp,
|
|
ieTryDown: ieTryDown,
|
|
getJumpSize: constant(JUMP_SIZE)
|
|
};
|
|
|
|
var MAX_RETRIES = 20;
|
|
var findSpot = function (bridge, isRoot, direction) {
|
|
return bridge.getSelection().bind(function (sel) {
|
|
return tryBr(isRoot, sel.finish, sel.foffset, direction).fold(function () {
|
|
return Optional.some(point(sel.finish, sel.foffset));
|
|
}, function (brNeighbour) {
|
|
var range = bridge.fromSitus(brNeighbour);
|
|
var analysis = BeforeAfter.verify(bridge, sel.finish, sel.foffset, range.finish, range.foffset, direction.failure, isRoot);
|
|
return process(analysis);
|
|
});
|
|
});
|
|
};
|
|
var scan = function (bridge, isRoot, element, offset, direction, numRetries) {
|
|
if (numRetries === 0) {
|
|
return Optional.none();
|
|
}
|
|
return tryCursor(bridge, isRoot, element, offset, direction).bind(function (situs) {
|
|
var range = bridge.fromSitus(situs);
|
|
var analysis = BeforeAfter.verify(bridge, element, offset, range.finish, range.foffset, direction.failure, isRoot);
|
|
return BeforeAfter.cata(analysis, function () {
|
|
return Optional.none();
|
|
}, function () {
|
|
return Optional.some(situs);
|
|
}, function (cell) {
|
|
if (eq$1(element, cell) && offset === 0) {
|
|
return tryAgain(bridge, element, offset, moveUp, direction);
|
|
} else {
|
|
return scan(bridge, isRoot, cell, 0, direction, numRetries - 1);
|
|
}
|
|
}, function (cell) {
|
|
if (eq$1(element, cell) && offset === getEnd(cell)) {
|
|
return tryAgain(bridge, element, offset, moveDown, direction);
|
|
} else {
|
|
return scan(bridge, isRoot, cell, getEnd(cell), direction, numRetries - 1);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var tryAgain = function (bridge, element, offset, move, direction) {
|
|
return getBoxAt(bridge, element, offset).bind(function (box) {
|
|
return tryAt(bridge, direction, move(box, Retries.getJumpSize()));
|
|
});
|
|
};
|
|
var tryAt = function (bridge, direction, box) {
|
|
var browser = detect$3().browser;
|
|
if (browser.isChrome() || browser.isSafari() || browser.isFirefox() || browser.isEdge()) {
|
|
return direction.otherRetry(bridge, box);
|
|
} else if (browser.isIE()) {
|
|
return direction.ieRetry(bridge, box);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
};
|
|
var tryCursor = function (bridge, isRoot, element, offset, direction) {
|
|
return getBoxAt(bridge, element, offset).bind(function (box) {
|
|
return tryAt(bridge, direction, box);
|
|
});
|
|
};
|
|
var handle = function (bridge, isRoot, direction) {
|
|
return findSpot(bridge, isRoot, direction).bind(function (spot) {
|
|
return scan(bridge, isRoot, spot.element, spot.offset, direction, MAX_RETRIES).map(bridge.fromSitus);
|
|
});
|
|
};
|
|
|
|
var inSameTable = function (elem, table) {
|
|
return ancestor(elem, function (e) {
|
|
return parent(e).exists(function (p) {
|
|
return eq$1(p, table);
|
|
});
|
|
});
|
|
};
|
|
var simulate = function (bridge, isRoot, direction, initial, anchor) {
|
|
return closest$1(initial, 'td,th', isRoot).bind(function (start) {
|
|
return closest$1(start, 'table', isRoot).bind(function (table) {
|
|
if (!inSameTable(anchor, table)) {
|
|
return Optional.none();
|
|
}
|
|
return handle(bridge, isRoot, direction).bind(function (range) {
|
|
return closest$1(range.finish, 'td,th', isRoot).map(function (finish) {
|
|
return {
|
|
start: start,
|
|
finish: finish,
|
|
range: range
|
|
};
|
|
});
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var navigate = function (bridge, isRoot, direction, initial, anchor, precheck) {
|
|
if (detect$3().browser.isIE()) {
|
|
return Optional.none();
|
|
} else {
|
|
return precheck(initial, isRoot).orThunk(function () {
|
|
return simulate(bridge, isRoot, direction, initial, anchor).map(function (info) {
|
|
var range = info.range;
|
|
return Response.create(Optional.some(makeSitus(range.start, range.soffset, range.finish, range.foffset)), true);
|
|
});
|
|
});
|
|
}
|
|
};
|
|
var firstUpCheck = function (initial, isRoot) {
|
|
return closest$1(initial, 'tr', isRoot).bind(function (startRow) {
|
|
return closest$1(startRow, 'table', isRoot).bind(function (table) {
|
|
var rows = descendants(table, 'tr');
|
|
if (eq$1(startRow, rows[0])) {
|
|
return seekLeft(table, function (element) {
|
|
return last$1(element).isSome();
|
|
}, isRoot).map(function (last) {
|
|
var lastOffset = getEnd(last);
|
|
return Response.create(Optional.some(makeSitus(last, lastOffset, last, lastOffset)), true);
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var lastDownCheck = function (initial, isRoot) {
|
|
return closest$1(initial, 'tr', isRoot).bind(function (startRow) {
|
|
return closest$1(startRow, 'table', isRoot).bind(function (table) {
|
|
var rows = descendants(table, 'tr');
|
|
if (eq$1(startRow, rows[rows.length - 1])) {
|
|
return seekRight(table, function (element) {
|
|
return first(element).isSome();
|
|
}, isRoot).map(function (first) {
|
|
return Response.create(Optional.some(makeSitus(first, 0, first, 0)), true);
|
|
});
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var select = function (bridge, container, isRoot, direction, initial, anchor, selectRange) {
|
|
return simulate(bridge, isRoot, direction, initial, anchor).bind(function (info) {
|
|
return detect(container, isRoot, info.start, info.finish, selectRange);
|
|
});
|
|
};
|
|
|
|
var findCell = function (target, isRoot) {
|
|
return closest$1(target, 'td,th', isRoot);
|
|
};
|
|
var MouseSelection = function (bridge, container, isRoot, annotations) {
|
|
var cursor = value();
|
|
var clearstate = cursor.clear;
|
|
var applySelection = function (event) {
|
|
cursor.on(function (start) {
|
|
annotations.clearBeforeUpdate(container);
|
|
findCell(event.target, isRoot).each(function (finish) {
|
|
identify(start, finish, isRoot).each(function (cellSel) {
|
|
var boxes = cellSel.boxes.getOr([]);
|
|
if (boxes.length === 1) {
|
|
var singleCell = boxes[0];
|
|
var isNonEditableCell = getRaw(singleCell) === 'false';
|
|
var isCellClosestContentEditable = is(closest(event.target), singleCell, eq$1);
|
|
if (isNonEditableCell && isCellClosestContentEditable) {
|
|
annotations.selectRange(container, boxes, singleCell, singleCell);
|
|
bridge.selectContents(singleCell);
|
|
}
|
|
} else if (boxes.length > 1) {
|
|
annotations.selectRange(container, boxes, cellSel.start, cellSel.finish);
|
|
bridge.selectContents(finish);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var mousedown = function (event) {
|
|
annotations.clear(container);
|
|
findCell(event.target, isRoot).each(cursor.set);
|
|
};
|
|
var mouseover = function (event) {
|
|
applySelection(event);
|
|
};
|
|
var mouseup = function (event) {
|
|
applySelection(event);
|
|
clearstate();
|
|
};
|
|
return {
|
|
clearstate: clearstate,
|
|
mousedown: mousedown,
|
|
mouseover: mouseover,
|
|
mouseup: mouseup
|
|
};
|
|
};
|
|
|
|
var down = {
|
|
traverse: nextSibling,
|
|
gather: after,
|
|
relative: Situ.before,
|
|
otherRetry: Retries.tryDown,
|
|
ieRetry: Retries.ieTryDown,
|
|
failure: BeforeAfter.failedDown
|
|
};
|
|
var up = {
|
|
traverse: prevSibling,
|
|
gather: before,
|
|
relative: Situ.before,
|
|
otherRetry: Retries.tryUp,
|
|
ieRetry: Retries.ieTryUp,
|
|
failure: BeforeAfter.failedUp
|
|
};
|
|
|
|
var isKey = function (key) {
|
|
return function (keycode) {
|
|
return keycode === key;
|
|
};
|
|
};
|
|
var isUp = isKey(38);
|
|
var isDown = isKey(40);
|
|
var isNavigation = function (keycode) {
|
|
return keycode >= 37 && keycode <= 40;
|
|
};
|
|
var ltr = {
|
|
isBackward: isKey(37),
|
|
isForward: isKey(39)
|
|
};
|
|
var rtl = {
|
|
isBackward: isKey(39),
|
|
isForward: isKey(37)
|
|
};
|
|
|
|
var get = function (_DOC) {
|
|
var doc = _DOC !== undefined ? _DOC.dom : document;
|
|
var x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
|
|
var y = doc.body.scrollTop || doc.documentElement.scrollTop;
|
|
return SugarPosition(x, y);
|
|
};
|
|
var by = function (x, y, _DOC) {
|
|
var doc = _DOC !== undefined ? _DOC.dom : document;
|
|
var win = doc.defaultView;
|
|
if (win) {
|
|
win.scrollBy(x, y);
|
|
}
|
|
};
|
|
|
|
var WindowBridge = function (win) {
|
|
var elementFromPoint = function (x, y) {
|
|
return SugarElement.fromPoint(SugarElement.fromDom(win.document), x, y);
|
|
};
|
|
var getRect = function (element) {
|
|
return element.dom.getBoundingClientRect();
|
|
};
|
|
var getRangedRect = function (start, soffset, finish, foffset) {
|
|
var sel = SimSelection.exact(start, soffset, finish, foffset);
|
|
return getFirstRect(win, sel);
|
|
};
|
|
var getSelection = function () {
|
|
return get$1(win).map(function (exactAdt) {
|
|
return convertToRange(win, exactAdt);
|
|
});
|
|
};
|
|
var fromSitus = function (situs) {
|
|
var relative = SimSelection.relative(situs.start, situs.finish);
|
|
return convertToRange(win, relative);
|
|
};
|
|
var situsFromPoint = function (x, y) {
|
|
return getAtPoint(win, x, y).map(function (exact) {
|
|
return Situs.create(exact.start, exact.soffset, exact.finish, exact.foffset);
|
|
});
|
|
};
|
|
var clearSelection = function () {
|
|
clear(win);
|
|
};
|
|
var collapseSelection = function (toStart) {
|
|
if (toStart === void 0) {
|
|
toStart = false;
|
|
}
|
|
get$1(win).each(function (sel) {
|
|
return sel.fold(function (rng) {
|
|
return rng.collapse(toStart);
|
|
}, function (startSitu, finishSitu) {
|
|
var situ = toStart ? startSitu : finishSitu;
|
|
setRelative(win, situ, situ);
|
|
}, function (start, soffset, finish, foffset) {
|
|
var node = toStart ? start : finish;
|
|
var offset = toStart ? soffset : foffset;
|
|
setExact(win, node, offset, node, offset);
|
|
});
|
|
});
|
|
};
|
|
var selectNode = function (element) {
|
|
setToElement(win, element, false);
|
|
};
|
|
var selectContents = function (element) {
|
|
setToElement(win, element);
|
|
};
|
|
var setSelection = function (sel) {
|
|
setExact(win, sel.start, sel.soffset, sel.finish, sel.foffset);
|
|
};
|
|
var setRelativeSelection = function (start, finish) {
|
|
setRelative(win, start, finish);
|
|
};
|
|
var getInnerHeight = function () {
|
|
return win.innerHeight;
|
|
};
|
|
var getScrollY = function () {
|
|
var pos = get(SugarElement.fromDom(win.document));
|
|
return pos.top;
|
|
};
|
|
var scrollBy = function (x, y) {
|
|
by(x, y, SugarElement.fromDom(win.document));
|
|
};
|
|
return {
|
|
elementFromPoint: elementFromPoint,
|
|
getRect: getRect,
|
|
getRangedRect: getRangedRect,
|
|
getSelection: getSelection,
|
|
fromSitus: fromSitus,
|
|
situsFromPoint: situsFromPoint,
|
|
clearSelection: clearSelection,
|
|
collapseSelection: collapseSelection,
|
|
setSelection: setSelection,
|
|
setRelativeSelection: setRelativeSelection,
|
|
selectNode: selectNode,
|
|
selectContents: selectContents,
|
|
getInnerHeight: getInnerHeight,
|
|
getScrollY: getScrollY,
|
|
scrollBy: scrollBy
|
|
};
|
|
};
|
|
|
|
var rc = function (rows, cols) {
|
|
return {
|
|
rows: rows,
|
|
cols: cols
|
|
};
|
|
};
|
|
var mouse = function (win, container, isRoot, annotations) {
|
|
var bridge = WindowBridge(win);
|
|
var handlers = MouseSelection(bridge, container, isRoot, annotations);
|
|
return {
|
|
clearstate: handlers.clearstate,
|
|
mousedown: handlers.mousedown,
|
|
mouseover: handlers.mouseover,
|
|
mouseup: handlers.mouseup
|
|
};
|
|
};
|
|
var keyboard = function (win, container, isRoot, annotations) {
|
|
var bridge = WindowBridge(win);
|
|
var clearToNavigate = function () {
|
|
annotations.clear(container);
|
|
return Optional.none();
|
|
};
|
|
var keydown = function (event, start, soffset, finish, foffset, direction) {
|
|
var realEvent = event.raw;
|
|
var keycode = realEvent.which;
|
|
var shiftKey = realEvent.shiftKey === true;
|
|
var handler = retrieve$1(container, annotations.selectedSelector).fold(function () {
|
|
if (isNavigation(keycode) && !shiftKey) {
|
|
annotations.clearBeforeUpdate(container);
|
|
}
|
|
if (isDown(keycode) && shiftKey) {
|
|
return curry(select, bridge, container, isRoot, down, finish, start, annotations.selectRange);
|
|
} else if (isUp(keycode) && shiftKey) {
|
|
return curry(select, bridge, container, isRoot, up, finish, start, annotations.selectRange);
|
|
} else if (isDown(keycode)) {
|
|
return curry(navigate, bridge, isRoot, down, finish, start, lastDownCheck);
|
|
} else if (isUp(keycode)) {
|
|
return curry(navigate, bridge, isRoot, up, finish, start, firstUpCheck);
|
|
} else {
|
|
return Optional.none;
|
|
}
|
|
}, function (selected) {
|
|
var update$1 = function (attempts) {
|
|
return function () {
|
|
var navigation = findMap(attempts, function (delta) {
|
|
return update(delta.rows, delta.cols, container, selected, annotations);
|
|
});
|
|
return navigation.fold(function () {
|
|
return getEdges(container, annotations.firstSelectedSelector, annotations.lastSelectedSelector).map(function (edges) {
|
|
var relative = isDown(keycode) || direction.isForward(keycode) ? Situ.after : Situ.before;
|
|
bridge.setRelativeSelection(Situ.on(edges.first, 0), relative(edges.table));
|
|
annotations.clear(container);
|
|
return Response.create(Optional.none(), true);
|
|
});
|
|
}, function (_) {
|
|
return Optional.some(Response.create(Optional.none(), true));
|
|
});
|
|
};
|
|
};
|
|
if (isDown(keycode) && shiftKey) {
|
|
return update$1([rc(+1, 0)]);
|
|
} else if (isUp(keycode) && shiftKey) {
|
|
return update$1([rc(-1, 0)]);
|
|
} else if (direction.isBackward(keycode) && shiftKey) {
|
|
return update$1([
|
|
rc(0, -1),
|
|
rc(-1, 0)
|
|
]);
|
|
} else if (direction.isForward(keycode) && shiftKey) {
|
|
return update$1([
|
|
rc(0, +1),
|
|
rc(+1, 0)
|
|
]);
|
|
} else if (isNavigation(keycode) && !shiftKey) {
|
|
return clearToNavigate;
|
|
} else {
|
|
return Optional.none;
|
|
}
|
|
});
|
|
return handler();
|
|
};
|
|
var keyup = function (event, start, soffset, finish, foffset) {
|
|
return retrieve$1(container, annotations.selectedSelector).fold(function () {
|
|
var realEvent = event.raw;
|
|
var keycode = realEvent.which;
|
|
var shiftKey = realEvent.shiftKey === true;
|
|
if (!shiftKey) {
|
|
return Optional.none();
|
|
}
|
|
if (isNavigation(keycode)) {
|
|
return sync(container, isRoot, start, soffset, finish, foffset, annotations.selectRange);
|
|
} else {
|
|
return Optional.none();
|
|
}
|
|
}, Optional.none);
|
|
};
|
|
return {
|
|
keydown: keydown,
|
|
keyup: keyup
|
|
};
|
|
};
|
|
var external = function (win, container, isRoot, annotations) {
|
|
var bridge = WindowBridge(win);
|
|
return function (start, finish) {
|
|
annotations.clearBeforeUpdate(container);
|
|
identify(start, finish, isRoot).each(function (cellSel) {
|
|
var boxes = cellSel.boxes.getOr([]);
|
|
annotations.selectRange(container, boxes, cellSel.start, cellSel.finish);
|
|
bridge.selectContents(finish);
|
|
bridge.collapseSelection();
|
|
});
|
|
};
|
|
};
|
|
|
|
var remove = function (element, classes) {
|
|
each$2(classes, function (x) {
|
|
remove$2(element, x);
|
|
});
|
|
};
|
|
|
|
var addClass = function (clazz) {
|
|
return function (element) {
|
|
add(element, clazz);
|
|
};
|
|
};
|
|
var removeClasses = function (classes) {
|
|
return function (element) {
|
|
remove(element, classes);
|
|
};
|
|
};
|
|
|
|
var byClass = function (ephemera) {
|
|
var addSelectionClass = addClass(ephemera.selected);
|
|
var removeSelectionClasses = removeClasses([
|
|
ephemera.selected,
|
|
ephemera.lastSelected,
|
|
ephemera.firstSelected
|
|
]);
|
|
var clear = function (container) {
|
|
var sels = descendants(container, ephemera.selectedSelector);
|
|
each$2(sels, removeSelectionClasses);
|
|
};
|
|
var selectRange = function (container, cells, start, finish) {
|
|
clear(container);
|
|
each$2(cells, addSelectionClass);
|
|
add(start, ephemera.firstSelected);
|
|
add(finish, ephemera.lastSelected);
|
|
};
|
|
return {
|
|
clearBeforeUpdate: clear,
|
|
clear: clear,
|
|
selectRange: selectRange,
|
|
selectedSelector: ephemera.selectedSelector,
|
|
firstSelectedSelector: ephemera.firstSelectedSelector,
|
|
lastSelectedSelector: ephemera.lastSelectedSelector
|
|
};
|
|
};
|
|
var byAttr = function (ephemera, onSelection, onClear) {
|
|
var removeSelectionAttributes = function (element) {
|
|
remove$7(element, ephemera.selected);
|
|
remove$7(element, ephemera.firstSelected);
|
|
remove$7(element, ephemera.lastSelected);
|
|
};
|
|
var addSelectionAttribute = function (element) {
|
|
set$2(element, ephemera.selected, '1');
|
|
};
|
|
var clear = function (container) {
|
|
clearBeforeUpdate(container);
|
|
onClear();
|
|
};
|
|
var clearBeforeUpdate = function (container) {
|
|
var sels = descendants(container, ephemera.selectedSelector + ',' + ephemera.firstSelectedSelector + ',' + ephemera.lastSelectedSelector);
|
|
each$2(sels, removeSelectionAttributes);
|
|
};
|
|
var selectRange = function (container, cells, start, finish) {
|
|
clear(container);
|
|
each$2(cells, addSelectionAttribute);
|
|
set$2(start, ephemera.firstSelected, '1');
|
|
set$2(finish, ephemera.lastSelected, '1');
|
|
onSelection(cells, start, finish);
|
|
};
|
|
return {
|
|
clearBeforeUpdate: clearBeforeUpdate,
|
|
clear: clear,
|
|
selectRange: selectRange,
|
|
selectedSelector: ephemera.selectedSelector,
|
|
firstSelectedSelector: ephemera.firstSelectedSelector,
|
|
lastSelectedSelector: ephemera.lastSelectedSelector
|
|
};
|
|
};
|
|
var SelectionAnnotation = {
|
|
byClass: byClass,
|
|
byAttr: byAttr
|
|
};
|
|
|
|
var getUpOrLeftCells = function (grid, selectedCells) {
|
|
var upGrid = grid.slice(0, selectedCells[selectedCells.length - 1].row + 1);
|
|
var upDetails = toDetailList(upGrid);
|
|
return bind$2(upDetails, function (detail) {
|
|
var slicedCells = detail.cells.slice(0, selectedCells[selectedCells.length - 1].column + 1);
|
|
return map$1(slicedCells, function (cell) {
|
|
return cell.element;
|
|
});
|
|
});
|
|
};
|
|
var getDownOrRightCells = function (grid, selectedCells) {
|
|
var downGrid = grid.slice(selectedCells[0].row + selectedCells[0].rowspan - 1, grid.length);
|
|
var downDetails = toDetailList(downGrid);
|
|
return bind$2(downDetails, function (detail) {
|
|
var slicedCells = detail.cells.slice(selectedCells[0].column + selectedCells[0].colspan - 1, detail.cells.length);
|
|
return map$1(slicedCells, function (cell) {
|
|
return cell.element;
|
|
});
|
|
});
|
|
};
|
|
var getOtherCells = function (table, target, generators) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var details = onCells(warehouse, target);
|
|
return details.map(function (selectedCells) {
|
|
var grid = toGrid(warehouse, generators, false);
|
|
var upOrLeftCells = getUpOrLeftCells(grid, selectedCells);
|
|
var downOrRightCells = getDownOrRightCells(grid, selectedCells);
|
|
return {
|
|
upOrLeftCells: upOrLeftCells,
|
|
downOrRightCells: downOrRightCells
|
|
};
|
|
});
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var hasInternalTarget = function (e) {
|
|
return has(SugarElement.fromDom(e.target), 'ephox-snooker-resizer-bar') === false;
|
|
};
|
|
function CellSelection (editor, lazyResize, selectionTargets) {
|
|
var onSelection = function (cells, start, finish) {
|
|
selectionTargets.targets().each(function (targets) {
|
|
var tableOpt = table(start);
|
|
tableOpt.each(function (table) {
|
|
var cloneFormats = getCloneElements(editor);
|
|
var generators = cellOperations(noop, SugarElement.fromDom(editor.getDoc()), cloneFormats);
|
|
var otherCells = getOtherCells(table, targets, generators);
|
|
fireTableSelectionChange(editor, cells, start, finish, otherCells);
|
|
});
|
|
});
|
|
};
|
|
var onClear = function () {
|
|
return fireTableSelectionClear(editor);
|
|
};
|
|
var annotations = SelectionAnnotation.byAttr(ephemera, onSelection, onClear);
|
|
editor.on('init', function (_e) {
|
|
var win = editor.getWin();
|
|
var body = getBody(editor);
|
|
var isRoot = getIsRoot(editor);
|
|
var syncSelection = function () {
|
|
var sel = editor.selection;
|
|
var start = SugarElement.fromDom(sel.getStart());
|
|
var end = SugarElement.fromDom(sel.getEnd());
|
|
var shared = sharedOne(table, [
|
|
start,
|
|
end
|
|
]);
|
|
shared.fold(function () {
|
|
return annotations.clear(body);
|
|
}, noop);
|
|
};
|
|
var mouseHandlers = mouse(win, body, isRoot, annotations);
|
|
var keyHandlers = keyboard(win, body, isRoot, annotations);
|
|
var external$1 = external(win, body, isRoot, annotations);
|
|
var hasShiftKey = function (event) {
|
|
return event.raw.shiftKey === true;
|
|
};
|
|
editor.on('TableSelectorChange', function (e) {
|
|
return external$1(e.start, e.finish);
|
|
});
|
|
var handleResponse = function (event, response) {
|
|
if (!hasShiftKey(event)) {
|
|
return;
|
|
}
|
|
if (response.kill) {
|
|
event.kill();
|
|
}
|
|
response.selection.each(function (ns) {
|
|
var relative = SimSelection.relative(ns.start, ns.finish);
|
|
var rng = asLtrRange(win, relative);
|
|
editor.selection.setRng(rng);
|
|
});
|
|
};
|
|
var keyup = function (event) {
|
|
var wrappedEvent = fromRawEvent(event);
|
|
if (wrappedEvent.raw.shiftKey && isNavigation(wrappedEvent.raw.which)) {
|
|
var rng = editor.selection.getRng();
|
|
var start = SugarElement.fromDom(rng.startContainer);
|
|
var end = SugarElement.fromDom(rng.endContainer);
|
|
keyHandlers.keyup(wrappedEvent, start, rng.startOffset, end, rng.endOffset).each(function (response) {
|
|
handleResponse(wrappedEvent, response);
|
|
});
|
|
}
|
|
};
|
|
var keydown = function (event) {
|
|
var wrappedEvent = fromRawEvent(event);
|
|
lazyResize().each(function (resize) {
|
|
return resize.hideBars();
|
|
});
|
|
var rng = editor.selection.getRng();
|
|
var start = SugarElement.fromDom(rng.startContainer);
|
|
var end = SugarElement.fromDom(rng.endContainer);
|
|
var direction = onDirection(ltr, rtl)(SugarElement.fromDom(editor.selection.getStart()));
|
|
keyHandlers.keydown(wrappedEvent, start, rng.startOffset, end, rng.endOffset, direction).each(function (response) {
|
|
handleResponse(wrappedEvent, response);
|
|
});
|
|
lazyResize().each(function (resize) {
|
|
return resize.showBars();
|
|
});
|
|
};
|
|
var isLeftMouse = function (raw) {
|
|
return raw.button === 0;
|
|
};
|
|
var isLeftButtonPressed = function (raw) {
|
|
if (raw.buttons === undefined) {
|
|
return true;
|
|
}
|
|
if (global.browser.isEdge() && raw.buttons === 0) {
|
|
return true;
|
|
}
|
|
return (raw.buttons & 1) !== 0;
|
|
};
|
|
var dragStart = function (_e) {
|
|
mouseHandlers.clearstate();
|
|
};
|
|
var mouseDown = function (e) {
|
|
if (isLeftMouse(e) && hasInternalTarget(e)) {
|
|
mouseHandlers.mousedown(fromRawEvent(e));
|
|
}
|
|
};
|
|
var mouseOver = function (e) {
|
|
if (isLeftButtonPressed(e) && hasInternalTarget(e)) {
|
|
mouseHandlers.mouseover(fromRawEvent(e));
|
|
}
|
|
};
|
|
var mouseUp = function (e) {
|
|
if (isLeftMouse(e) && hasInternalTarget(e)) {
|
|
mouseHandlers.mouseup(fromRawEvent(e));
|
|
}
|
|
};
|
|
var getDoubleTap = function () {
|
|
var lastTarget = Cell(SugarElement.fromDom(body));
|
|
var lastTimeStamp = Cell(0);
|
|
var touchEnd = function (t) {
|
|
var target = SugarElement.fromDom(t.target);
|
|
if (name(target) === 'td' || name(target) === 'th') {
|
|
var lT = lastTarget.get();
|
|
var lTS = lastTimeStamp.get();
|
|
if (eq$1(lT, target) && t.timeStamp - lTS < 300) {
|
|
t.preventDefault();
|
|
external$1(target, target);
|
|
}
|
|
}
|
|
lastTarget.set(target);
|
|
lastTimeStamp.set(t.timeStamp);
|
|
};
|
|
return { touchEnd: touchEnd };
|
|
};
|
|
var doubleTap = getDoubleTap();
|
|
editor.on('dragstart', dragStart);
|
|
editor.on('mousedown', mouseDown);
|
|
editor.on('mouseover', mouseOver);
|
|
editor.on('mouseup', mouseUp);
|
|
editor.on('touchend', doubleTap.touchEnd);
|
|
editor.on('keyup', keyup);
|
|
editor.on('keydown', keydown);
|
|
editor.on('NodeChange', syncSelection);
|
|
});
|
|
return { clear: annotations.clear };
|
|
}
|
|
|
|
var child = function (scope, selector) {
|
|
return child$1(scope, selector).isSome();
|
|
};
|
|
|
|
var getSelectionTargets = function (editor, selections) {
|
|
var targets = Cell(Optional.none());
|
|
var changeHandlers = Cell([]);
|
|
var selectionDetails = Optional.none();
|
|
var isCaption = isTag('caption');
|
|
var isDisabledForSelection = function (key) {
|
|
return selectionDetails.forall(function (details) {
|
|
return !details[key];
|
|
});
|
|
};
|
|
var getStart = function () {
|
|
return getSelectionCellOrCaption(getSelectionStart(editor), getIsRoot(editor));
|
|
};
|
|
var getEnd = function () {
|
|
return getSelectionCellOrCaption(getSelectionEnd(editor), getIsRoot(editor));
|
|
};
|
|
var findTargets = function () {
|
|
return getStart().bind(function (startCellOrCaption) {
|
|
return flatten(lift2(table(startCellOrCaption), getEnd().bind(table), function (startTable, endTable) {
|
|
if (eq$1(startTable, endTable)) {
|
|
if (isCaption(startCellOrCaption)) {
|
|
return Optional.some(noMenu(startCellOrCaption));
|
|
} else {
|
|
return Optional.some(forMenu(selections, startTable, startCellOrCaption));
|
|
}
|
|
}
|
|
return Optional.none();
|
|
}));
|
|
});
|
|
};
|
|
var getExtractedDetails = function (targets) {
|
|
var tableOpt = table(targets.element);
|
|
return tableOpt.map(function (table) {
|
|
var warehouse = Warehouse.fromTable(table);
|
|
var selectedCells = onCells(warehouse, targets).getOr([]);
|
|
var locked = foldl(selectedCells, function (acc, cell) {
|
|
if (cell.isLocked) {
|
|
acc.onAny = true;
|
|
if (cell.column === 0) {
|
|
acc.onFirst = true;
|
|
} else if (cell.column + cell.colspan >= warehouse.grid.columns) {
|
|
acc.onLast = true;
|
|
}
|
|
}
|
|
return acc;
|
|
}, {
|
|
onAny: false,
|
|
onFirst: false,
|
|
onLast: false
|
|
});
|
|
return {
|
|
mergeable: onUnlockedMergable(warehouse, targets).isSome(),
|
|
unmergeable: onUnlockedUnmergable(warehouse, targets).isSome(),
|
|
locked: locked
|
|
};
|
|
});
|
|
};
|
|
var resetTargets = function () {
|
|
targets.set(cached(findTargets)());
|
|
selectionDetails = targets.get().bind(getExtractedDetails);
|
|
each$2(changeHandlers.get(), function (handler) {
|
|
return handler();
|
|
});
|
|
};
|
|
var setupHandler = function (handler) {
|
|
handler();
|
|
changeHandlers.set(changeHandlers.get().concat([handler]));
|
|
return function () {
|
|
changeHandlers.set(filter$2(changeHandlers.get(), function (h) {
|
|
return h !== handler;
|
|
}));
|
|
};
|
|
};
|
|
var onSetup = function (api, isDisabled) {
|
|
return setupHandler(function () {
|
|
return targets.get().fold(function () {
|
|
api.setDisabled(true);
|
|
}, function (targets) {
|
|
api.setDisabled(isDisabled(targets));
|
|
});
|
|
});
|
|
};
|
|
var onSetupWithToggle = function (api, isDisabled, isActive) {
|
|
return setupHandler(function () {
|
|
return targets.get().fold(function () {
|
|
api.setDisabled(true);
|
|
api.setActive(false);
|
|
}, function (targets) {
|
|
api.setDisabled(isDisabled(targets));
|
|
api.setActive(isActive(targets));
|
|
});
|
|
});
|
|
};
|
|
var isDisabledFromLocked = function (lockedDisable) {
|
|
return selectionDetails.exists(function (details) {
|
|
return details.locked[lockedDisable];
|
|
});
|
|
};
|
|
var onSetupTable = function (api) {
|
|
return onSetup(api, function (_) {
|
|
return false;
|
|
});
|
|
};
|
|
var onSetupCellOrRow = function (api) {
|
|
return onSetup(api, function (targets) {
|
|
return isCaption(targets.element);
|
|
});
|
|
};
|
|
var onSetupColumn = function (lockedDisable) {
|
|
return function (api) {
|
|
return onSetup(api, function (targets) {
|
|
return isCaption(targets.element) || isDisabledFromLocked(lockedDisable);
|
|
});
|
|
};
|
|
};
|
|
var onSetupPasteable = function (getClipboardData) {
|
|
return function (api) {
|
|
return onSetup(api, function (targets) {
|
|
return isCaption(targets.element) || getClipboardData().isNone();
|
|
});
|
|
};
|
|
};
|
|
var onSetupPasteableColumn = function (getClipboardData, lockedDisable) {
|
|
return function (api) {
|
|
return onSetup(api, function (targets) {
|
|
return isCaption(targets.element) || getClipboardData().isNone() || isDisabledFromLocked(lockedDisable);
|
|
});
|
|
};
|
|
};
|
|
var onSetupMergeable = function (api) {
|
|
return onSetup(api, function (_targets) {
|
|
return isDisabledForSelection('mergeable');
|
|
});
|
|
};
|
|
var onSetupUnmergeable = function (api) {
|
|
return onSetup(api, function (_targets) {
|
|
return isDisabledForSelection('unmergeable');
|
|
});
|
|
};
|
|
var onSetupTableWithCaption = function (api) {
|
|
return onSetupWithToggle(api, never, function (targets) {
|
|
var tableOpt = table(targets.element, getIsRoot(editor));
|
|
return tableOpt.exists(function (table) {
|
|
return child(table, 'caption');
|
|
});
|
|
});
|
|
};
|
|
var onSetupTableHeaders = function (command, headerType) {
|
|
return function (api) {
|
|
return onSetupWithToggle(api, function (targets) {
|
|
return isCaption(targets.element);
|
|
}, function () {
|
|
return editor.queryCommandValue(command) === headerType;
|
|
});
|
|
};
|
|
};
|
|
var onSetupTableRowHeaders = onSetupTableHeaders('mceTableRowType', 'header');
|
|
var onSetupTableColumnHeaders = onSetupTableHeaders('mceTableColType', 'th');
|
|
editor.on('NodeChange ExecCommand TableSelectorChange', resetTargets);
|
|
return {
|
|
onSetupTable: onSetupTable,
|
|
onSetupCellOrRow: onSetupCellOrRow,
|
|
onSetupColumn: onSetupColumn,
|
|
onSetupPasteable: onSetupPasteable,
|
|
onSetupPasteableColumn: onSetupPasteableColumn,
|
|
onSetupMergeable: onSetupMergeable,
|
|
onSetupUnmergeable: onSetupUnmergeable,
|
|
resetTargets: resetTargets,
|
|
onSetupTableWithCaption: onSetupTableWithCaption,
|
|
onSetupTableRowHeaders: onSetupTableRowHeaders,
|
|
onSetupTableColumnHeaders: onSetupTableColumnHeaders,
|
|
targets: targets.get
|
|
};
|
|
};
|
|
|
|
var addButtons = function (editor, selections, selectionTargets, clipboard) {
|
|
editor.ui.registry.addMenuButton('table', {
|
|
tooltip: 'Table',
|
|
icon: 'table',
|
|
fetch: function (callback) {
|
|
return callback('inserttable | cell row column | advtablesort | tableprops deletetable');
|
|
}
|
|
});
|
|
var cmd = function (command) {
|
|
return function () {
|
|
return editor.execCommand(command);
|
|
};
|
|
};
|
|
editor.ui.registry.addButton('tableprops', {
|
|
tooltip: 'Table properties',
|
|
onAction: cmd('mceTableProps'),
|
|
icon: 'table',
|
|
onSetup: selectionTargets.onSetupTable
|
|
});
|
|
editor.ui.registry.addButton('tabledelete', {
|
|
tooltip: 'Delete table',
|
|
onAction: cmd('mceTableDelete'),
|
|
icon: 'table-delete-table',
|
|
onSetup: selectionTargets.onSetupTable
|
|
});
|
|
editor.ui.registry.addButton('tablecellprops', {
|
|
tooltip: 'Cell properties',
|
|
onAction: cmd('mceTableCellProps'),
|
|
icon: 'table-cell-properties',
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addButton('tablemergecells', {
|
|
tooltip: 'Merge cells',
|
|
onAction: cmd('mceTableMergeCells'),
|
|
icon: 'table-merge-cells',
|
|
onSetup: selectionTargets.onSetupMergeable
|
|
});
|
|
editor.ui.registry.addButton('tablesplitcells', {
|
|
tooltip: 'Split cell',
|
|
onAction: cmd('mceTableSplitCells'),
|
|
icon: 'table-split-cells',
|
|
onSetup: selectionTargets.onSetupUnmergeable
|
|
});
|
|
editor.ui.registry.addButton('tableinsertrowbefore', {
|
|
tooltip: 'Insert row before',
|
|
onAction: cmd('mceTableInsertRowBefore'),
|
|
icon: 'table-insert-row-above',
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addButton('tableinsertrowafter', {
|
|
tooltip: 'Insert row after',
|
|
onAction: cmd('mceTableInsertRowAfter'),
|
|
icon: 'table-insert-row-after',
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addButton('tabledeleterow', {
|
|
tooltip: 'Delete row',
|
|
onAction: cmd('mceTableDeleteRow'),
|
|
icon: 'table-delete-row',
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addButton('tablerowprops', {
|
|
tooltip: 'Row properties',
|
|
onAction: cmd('mceTableRowProps'),
|
|
icon: 'table-row-properties',
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addButton('tableinsertcolbefore', {
|
|
tooltip: 'Insert column before',
|
|
onAction: cmd('mceTableInsertColBefore'),
|
|
icon: 'table-insert-column-before',
|
|
onSetup: selectionTargets.onSetupColumn('onFirst')
|
|
});
|
|
editor.ui.registry.addButton('tableinsertcolafter', {
|
|
tooltip: 'Insert column after',
|
|
onAction: cmd('mceTableInsertColAfter'),
|
|
icon: 'table-insert-column-after',
|
|
onSetup: selectionTargets.onSetupColumn('onLast')
|
|
});
|
|
editor.ui.registry.addButton('tabledeletecol', {
|
|
tooltip: 'Delete column',
|
|
onAction: cmd('mceTableDeleteCol'),
|
|
icon: 'table-delete-column',
|
|
onSetup: selectionTargets.onSetupColumn('onAny')
|
|
});
|
|
editor.ui.registry.addButton('tablecutrow', {
|
|
tooltip: 'Cut row',
|
|
icon: 'cut-row',
|
|
onAction: cmd('mceTableCutRow'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addButton('tablecopyrow', {
|
|
tooltip: 'Copy row',
|
|
icon: 'duplicate-row',
|
|
onAction: cmd('mceTableCopyRow'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addButton('tablepasterowbefore', {
|
|
tooltip: 'Paste row before',
|
|
icon: 'paste-row-before',
|
|
onAction: cmd('mceTablePasteRowBefore'),
|
|
onSetup: selectionTargets.onSetupPasteable(clipboard.getRows)
|
|
});
|
|
editor.ui.registry.addButton('tablepasterowafter', {
|
|
tooltip: 'Paste row after',
|
|
icon: 'paste-row-after',
|
|
onAction: cmd('mceTablePasteRowAfter'),
|
|
onSetup: selectionTargets.onSetupPasteable(clipboard.getRows)
|
|
});
|
|
editor.ui.registry.addButton('tablecutcol', {
|
|
tooltip: 'Cut column',
|
|
icon: 'cut-column',
|
|
onAction: cmd('mceTableCutCol'),
|
|
onSetup: selectionTargets.onSetupColumn('onAny')
|
|
});
|
|
editor.ui.registry.addButton('tablecopycol', {
|
|
tooltip: 'Copy column',
|
|
icon: 'duplicate-column',
|
|
onAction: cmd('mceTableCopyCol'),
|
|
onSetup: selectionTargets.onSetupColumn('onAny')
|
|
});
|
|
editor.ui.registry.addButton('tablepastecolbefore', {
|
|
tooltip: 'Paste column before',
|
|
icon: 'paste-column-before',
|
|
onAction: cmd('mceTablePasteColBefore'),
|
|
onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onFirst')
|
|
});
|
|
editor.ui.registry.addButton('tablepastecolafter', {
|
|
tooltip: 'Paste column after',
|
|
icon: 'paste-column-after',
|
|
onAction: cmd('mceTablePasteColAfter'),
|
|
onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onLast')
|
|
});
|
|
editor.ui.registry.addButton('tableinsertdialog', {
|
|
tooltip: 'Insert table',
|
|
onAction: cmd('mceInsertTable'),
|
|
icon: 'table'
|
|
});
|
|
var tableClassList = filterNoneItem(getTableClassList(editor));
|
|
if (tableClassList.length !== 0) {
|
|
editor.ui.registry.addMenuButton('tableclass', {
|
|
icon: 'table-classes',
|
|
tooltip: 'Table styles',
|
|
fetch: generateMenuItemsCallback(editor, selections, tableClassList, 'tableclass', function (value) {
|
|
return editor.execCommand('mceTableToggleClass', false, value);
|
|
}),
|
|
onSetup: selectionTargets.onSetupTable
|
|
});
|
|
}
|
|
var tableCellClassList = filterNoneItem(getCellClassList(editor));
|
|
if (tableCellClassList.length !== 0) {
|
|
editor.ui.registry.addMenuButton('tablecellclass', {
|
|
icon: 'table-cell-classes',
|
|
tooltip: 'Cell styles',
|
|
fetch: generateMenuItemsCallback(editor, selections, tableCellClassList, 'tablecellclass', function (value) {
|
|
return editor.execCommand('mceTableCellToggleClass', false, value);
|
|
}),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
}
|
|
editor.ui.registry.addMenuButton('tablecellvalign', {
|
|
icon: 'vertical-align',
|
|
tooltip: 'Vertical align',
|
|
fetch: generateMenuItemsCallback(editor, selections, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align')),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuButton('tablecellborderwidth', {
|
|
icon: 'border-width',
|
|
tooltip: 'Border width',
|
|
fetch: generateMenuItemsCallback(editor, selections, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width')),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuButton('tablecellborderstyle', {
|
|
icon: 'border-style',
|
|
tooltip: 'Border style',
|
|
fetch: generateMenuItemsCallback(editor, selections, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style')),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addToggleButton('tablecaption', {
|
|
tooltip: 'Table caption',
|
|
onAction: cmd('mceTableToggleCaption'),
|
|
icon: 'table-caption',
|
|
onSetup: selectionTargets.onSetupTableWithCaption
|
|
});
|
|
editor.ui.registry.addMenuButton('tablecellbackgroundcolor', {
|
|
icon: 'cell-background-color',
|
|
tooltip: 'Background color',
|
|
fetch: function (callback) {
|
|
return callback(buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color'));
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuButton('tablecellbordercolor', {
|
|
icon: 'cell-border-color',
|
|
tooltip: 'Border color',
|
|
fetch: function (callback) {
|
|
return callback(buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color'));
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addToggleButton('tablerowheader', {
|
|
tooltip: 'Row header',
|
|
icon: 'table-top-header',
|
|
onAction: changeRowHeader(editor),
|
|
onSetup: selectionTargets.onSetupTableRowHeaders
|
|
});
|
|
editor.ui.registry.addToggleButton('tablecolheader', {
|
|
tooltip: 'Column header',
|
|
icon: 'table-left-header',
|
|
onAction: changeColumnHeader(editor),
|
|
onSetup: selectionTargets.onSetupTableColumnHeaders
|
|
});
|
|
};
|
|
var addToolbars = function (editor) {
|
|
var isTable = function (table) {
|
|
return editor.dom.is(table, 'table') && editor.getBody().contains(table);
|
|
};
|
|
var toolbar = getToolbar(editor);
|
|
if (toolbar.length > 0) {
|
|
editor.ui.registry.addContextToolbar('table', {
|
|
predicate: isTable,
|
|
items: toolbar,
|
|
scope: 'node',
|
|
position: 'node'
|
|
});
|
|
}
|
|
};
|
|
|
|
var addMenuItems = function (editor, selections, selectionTargets, clipboard) {
|
|
var cmd = function (command) {
|
|
return function () {
|
|
return editor.execCommand(command);
|
|
};
|
|
};
|
|
var insertTableAction = function (data) {
|
|
editor.execCommand('mceInsertTable', false, {
|
|
rows: data.numRows,
|
|
columns: data.numColumns
|
|
});
|
|
};
|
|
var tableProperties = {
|
|
text: 'Table properties',
|
|
onSetup: selectionTargets.onSetupTable,
|
|
onAction: cmd('mceTableProps')
|
|
};
|
|
var deleteTable = {
|
|
text: 'Delete table',
|
|
icon: 'table-delete-table',
|
|
onSetup: selectionTargets.onSetupTable,
|
|
onAction: cmd('mceTableDelete')
|
|
};
|
|
editor.ui.registry.addMenuItem('tableinsertrowbefore', {
|
|
text: 'Insert row before',
|
|
icon: 'table-insert-row-above',
|
|
onAction: cmd('mceTableInsertRowBefore'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuItem('tableinsertrowafter', {
|
|
text: 'Insert row after',
|
|
icon: 'table-insert-row-after',
|
|
onAction: cmd('mceTableInsertRowAfter'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuItem('tabledeleterow', {
|
|
text: 'Delete row',
|
|
icon: 'table-delete-row',
|
|
onAction: cmd('mceTableDeleteRow'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuItem('tablerowprops', {
|
|
text: 'Row properties',
|
|
icon: 'table-row-properties',
|
|
onAction: cmd('mceTableRowProps'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuItem('tablecutrow', {
|
|
text: 'Cut row',
|
|
icon: 'cut-row',
|
|
onAction: cmd('mceTableCutRow'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuItem('tablecopyrow', {
|
|
text: 'Copy row',
|
|
icon: 'duplicate-row',
|
|
onAction: cmd('mceTableCopyRow'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuItem('tablepasterowbefore', {
|
|
text: 'Paste row before',
|
|
icon: 'paste-row-before',
|
|
onAction: cmd('mceTablePasteRowBefore'),
|
|
onSetup: selectionTargets.onSetupPasteable(clipboard.getRows)
|
|
});
|
|
editor.ui.registry.addMenuItem('tablepasterowafter', {
|
|
text: 'Paste row after',
|
|
icon: 'paste-row-after',
|
|
onAction: cmd('mceTablePasteRowAfter'),
|
|
onSetup: selectionTargets.onSetupPasteable(clipboard.getRows)
|
|
});
|
|
var row = {
|
|
type: 'nestedmenuitem',
|
|
text: 'Row',
|
|
getSubmenuItems: constant('tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter')
|
|
};
|
|
editor.ui.registry.addMenuItem('tableinsertcolumnbefore', {
|
|
text: 'Insert column before',
|
|
icon: 'table-insert-column-before',
|
|
onAction: cmd('mceTableInsertColBefore'),
|
|
onSetup: selectionTargets.onSetupColumn('onFirst')
|
|
});
|
|
editor.ui.registry.addMenuItem('tableinsertcolumnafter', {
|
|
text: 'Insert column after',
|
|
icon: 'table-insert-column-after',
|
|
onAction: cmd('mceTableInsertColAfter'),
|
|
onSetup: selectionTargets.onSetupColumn('onLast')
|
|
});
|
|
editor.ui.registry.addMenuItem('tabledeletecolumn', {
|
|
text: 'Delete column',
|
|
icon: 'table-delete-column',
|
|
onAction: cmd('mceTableDeleteCol'),
|
|
onSetup: selectionTargets.onSetupColumn('onAny')
|
|
});
|
|
editor.ui.registry.addMenuItem('tablecutcolumn', {
|
|
text: 'Cut column',
|
|
icon: 'cut-column',
|
|
onAction: cmd('mceTableCutCol'),
|
|
onSetup: selectionTargets.onSetupColumn('onAny')
|
|
});
|
|
editor.ui.registry.addMenuItem('tablecopycolumn', {
|
|
text: 'Copy column',
|
|
icon: 'duplicate-column',
|
|
onAction: cmd('mceTableCopyCol'),
|
|
onSetup: selectionTargets.onSetupColumn('onAny')
|
|
});
|
|
editor.ui.registry.addMenuItem('tablepastecolumnbefore', {
|
|
text: 'Paste column before',
|
|
icon: 'paste-column-before',
|
|
onAction: cmd('mceTablePasteColBefore'),
|
|
onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onFirst')
|
|
});
|
|
editor.ui.registry.addMenuItem('tablepastecolumnafter', {
|
|
text: 'Paste column after',
|
|
icon: 'paste-column-after',
|
|
onAction: cmd('mceTablePasteColAfter'),
|
|
onSetup: selectionTargets.onSetupPasteableColumn(clipboard.getColumns, 'onLast')
|
|
});
|
|
var column = {
|
|
type: 'nestedmenuitem',
|
|
text: 'Column',
|
|
getSubmenuItems: constant('tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter')
|
|
};
|
|
editor.ui.registry.addMenuItem('tablecellprops', {
|
|
text: 'Cell properties',
|
|
icon: 'table-cell-properties',
|
|
onAction: cmd('mceTableCellProps'),
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addMenuItem('tablemergecells', {
|
|
text: 'Merge cells',
|
|
icon: 'table-merge-cells',
|
|
onAction: cmd('mceTableMergeCells'),
|
|
onSetup: selectionTargets.onSetupMergeable
|
|
});
|
|
editor.ui.registry.addMenuItem('tablesplitcells', {
|
|
text: 'Split cell',
|
|
icon: 'table-split-cells',
|
|
onAction: cmd('mceTableSplitCells'),
|
|
onSetup: selectionTargets.onSetupUnmergeable
|
|
});
|
|
var cell = {
|
|
type: 'nestedmenuitem',
|
|
text: 'Cell',
|
|
getSubmenuItems: constant('tablecellprops tablemergecells tablesplitcells')
|
|
};
|
|
if (hasTableGrid(editor) === false) {
|
|
editor.ui.registry.addMenuItem('inserttable', {
|
|
text: 'Table',
|
|
icon: 'table',
|
|
onAction: cmd('mceInsertTable')
|
|
});
|
|
} else {
|
|
editor.ui.registry.addNestedMenuItem('inserttable', {
|
|
text: 'Table',
|
|
icon: 'table',
|
|
getSubmenuItems: function () {
|
|
return [{
|
|
type: 'fancymenuitem',
|
|
fancytype: 'inserttable',
|
|
onAction: insertTableAction
|
|
}];
|
|
}
|
|
});
|
|
}
|
|
editor.ui.registry.addMenuItem('inserttabledialog', {
|
|
text: 'Insert table',
|
|
icon: 'table',
|
|
onAction: cmd('mceInsertTable')
|
|
});
|
|
editor.ui.registry.addMenuItem('tableprops', tableProperties);
|
|
editor.ui.registry.addMenuItem('deletetable', deleteTable);
|
|
editor.ui.registry.addNestedMenuItem('row', row);
|
|
editor.ui.registry.addNestedMenuItem('column', column);
|
|
editor.ui.registry.addNestedMenuItem('cell', cell);
|
|
editor.ui.registry.addContextMenu('table', {
|
|
update: function () {
|
|
selectionTargets.resetTargets();
|
|
return selectionTargets.targets().fold(constant(''), function (targets) {
|
|
if (name(targets.element) === 'caption') {
|
|
return 'tableprops deletetable';
|
|
} else {
|
|
return 'cell row column | advtablesort | tableprops deletetable';
|
|
}
|
|
});
|
|
}
|
|
});
|
|
var tableClassList = filterNoneItem(getTableClassList(editor));
|
|
if (tableClassList.length !== 0) {
|
|
editor.ui.registry.addNestedMenuItem('tableclass', {
|
|
icon: 'table-classes',
|
|
text: 'Table styles',
|
|
getSubmenuItems: function () {
|
|
return buildMenuItems(editor, selections, tableClassList, 'tableclass', function (value) {
|
|
return editor.execCommand('mceTableToggleClass', false, value);
|
|
});
|
|
},
|
|
onSetup: selectionTargets.onSetupTable
|
|
});
|
|
}
|
|
var tableCellClassList = filterNoneItem(getCellClassList(editor));
|
|
if (tableCellClassList.length !== 0) {
|
|
editor.ui.registry.addNestedMenuItem('tablecellclass', {
|
|
icon: 'table-cell-classes',
|
|
text: 'Cell styles',
|
|
getSubmenuItems: function () {
|
|
return buildMenuItems(editor, selections, tableCellClassList, 'tablecellclass', function (value) {
|
|
return editor.execCommand('mceTableCellToggleClass', false, value);
|
|
});
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
}
|
|
editor.ui.registry.addNestedMenuItem('tablecellvalign', {
|
|
icon: 'vertical-align',
|
|
text: 'Vertical align',
|
|
getSubmenuItems: function () {
|
|
return buildMenuItems(editor, selections, verticalAlignValues, 'tablecellverticalalign', applyTableCellStyle(editor, 'vertical-align'));
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addNestedMenuItem('tablecellborderwidth', {
|
|
icon: 'border-width',
|
|
text: 'Border width',
|
|
getSubmenuItems: function () {
|
|
return buildMenuItems(editor, selections, getTableBorderWidths(editor), 'tablecellborderwidth', applyTableCellStyle(editor, 'border-width'));
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addNestedMenuItem('tablecellborderstyle', {
|
|
icon: 'border-style',
|
|
text: 'Border style',
|
|
getSubmenuItems: function () {
|
|
return buildMenuItems(editor, selections, getTableBorderStyles(editor), 'tablecellborderstyle', applyTableCellStyle(editor, 'border-style'));
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addToggleMenuItem('tablecaption', {
|
|
icon: 'table-caption',
|
|
text: 'Table caption',
|
|
onAction: cmd('mceTableToggleCaption'),
|
|
onSetup: selectionTargets.onSetupTableWithCaption
|
|
});
|
|
editor.ui.registry.addNestedMenuItem('tablecellbackgroundcolor', {
|
|
icon: 'cell-background-color',
|
|
text: 'Background color',
|
|
getSubmenuItems: function () {
|
|
return buildColorMenu(editor, getTableBackgroundColorMap(editor), 'background-color');
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addNestedMenuItem('tablecellbordercolor', {
|
|
icon: 'cell-border-color',
|
|
text: 'Border color',
|
|
getSubmenuItems: function () {
|
|
return buildColorMenu(editor, getTableBorderColorMap(editor), 'border-color');
|
|
},
|
|
onSetup: selectionTargets.onSetupCellOrRow
|
|
});
|
|
editor.ui.registry.addToggleMenuItem('tablerowheader', {
|
|
text: 'Row header',
|
|
icon: 'table-top-header',
|
|
onAction: changeRowHeader(editor),
|
|
onSetup: selectionTargets.onSetupTableRowHeaders
|
|
});
|
|
editor.ui.registry.addToggleMenuItem('tablecolheader', {
|
|
text: 'Column header',
|
|
icon: 'table-left-header',
|
|
onAction: changeColumnHeader(editor),
|
|
onSetup: selectionTargets.onSetupTableColumnHeaders
|
|
});
|
|
};
|
|
|
|
var Plugin = function (editor) {
|
|
var selections = Selections(function () {
|
|
return getBody(editor);
|
|
}, function () {
|
|
return getSelectionCell(getSelectionStart(editor), getIsRoot(editor));
|
|
}, ephemera.selectedSelector);
|
|
var selectionTargets = getSelectionTargets(editor, selections);
|
|
var resizeHandler = getResizeHandler(editor);
|
|
var cellSelection = CellSelection(editor, resizeHandler.lazyResize, selectionTargets);
|
|
var actions = TableActions(editor, cellSelection, resizeHandler.lazyWire);
|
|
var clipboard = Clipboard();
|
|
registerCommands(editor, actions, cellSelection, selections, clipboard);
|
|
registerQueryCommands(editor, actions, selections);
|
|
registerEvents(editor, selections, actions);
|
|
addMenuItems(editor, selections, selectionTargets, clipboard);
|
|
addButtons(editor, selections, selectionTargets, clipboard);
|
|
addToolbars(editor);
|
|
editor.on('PreInit', function () {
|
|
editor.serializer.addTempAttr(ephemera.firstSelected);
|
|
editor.serializer.addTempAttr(ephemera.lastSelected);
|
|
registerFormats(editor);
|
|
});
|
|
if (hasTabNavigation(editor)) {
|
|
editor.on('keydown', function (e) {
|
|
handle$1(e, editor, cellSelection);
|
|
});
|
|
}
|
|
editor.on('remove', function () {
|
|
resizeHandler.destroy();
|
|
});
|
|
return getApi(editor, clipboard, resizeHandler, selectionTargets);
|
|
};
|
|
function Plugin$1 () {
|
|
global$3.add('table', Plugin);
|
|
}
|
|
|
|
Plugin$1();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isString = isType('string');
|
|
var isFunction = isSimpleType('function');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
function curry(fn) {
|
|
var initialArgs = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
initialArgs[_i - 1] = arguments[_i];
|
|
}
|
|
return function () {
|
|
var restArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
restArgs[_i] = arguments[_i];
|
|
}
|
|
var all = initialArgs.concat(restArgs);
|
|
return fn.apply(null, all);
|
|
};
|
|
}
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.XHR');
|
|
|
|
var getCreationDateClasses = function (editor) {
|
|
return editor.getParam('template_cdate_classes', 'cdate');
|
|
};
|
|
var getModificationDateClasses = function (editor) {
|
|
return editor.getParam('template_mdate_classes', 'mdate');
|
|
};
|
|
var getSelectedContentClasses = function (editor) {
|
|
return editor.getParam('template_selected_content_classes', 'selcontent');
|
|
};
|
|
var getPreviewReplaceValues = function (editor) {
|
|
return editor.getParam('template_preview_replace_values');
|
|
};
|
|
var getContentStyle = function (editor) {
|
|
return editor.getParam('content_style', '', 'string');
|
|
};
|
|
var shouldUseContentCssCors = function (editor) {
|
|
return editor.getParam('content_css_cors', false, 'boolean');
|
|
};
|
|
var getTemplateReplaceValues = function (editor) {
|
|
return editor.getParam('template_replace_values');
|
|
};
|
|
var getTemplates = function (editor) {
|
|
return editor.getParam('templates');
|
|
};
|
|
var getCdateFormat = function (editor) {
|
|
return editor.getParam('template_cdate_format', editor.translate('%Y-%m-%d'));
|
|
};
|
|
var getMdateFormat = function (editor) {
|
|
return editor.getParam('template_mdate_format', editor.translate('%Y-%m-%d'));
|
|
};
|
|
var getBodyClassFromHash = function (editor) {
|
|
var bodyClass = editor.getParam('body_class', '', 'hash');
|
|
return bodyClass[editor.id] || '';
|
|
};
|
|
var getBodyClass = function (editor) {
|
|
var bodyClass = editor.getParam('body_class', '', 'string');
|
|
if (bodyClass.indexOf('=') === -1) {
|
|
return bodyClass;
|
|
} else {
|
|
return getBodyClassFromHash(editor);
|
|
}
|
|
};
|
|
|
|
var addZeros = function (value, len) {
|
|
value = '' + value;
|
|
if (value.length < len) {
|
|
for (var i = 0; i < len - value.length; i++) {
|
|
value = '0' + value;
|
|
}
|
|
}
|
|
return value;
|
|
};
|
|
var getDateTime = function (editor, fmt, date) {
|
|
if (date === void 0) {
|
|
date = new Date();
|
|
}
|
|
var daysShort = 'Sun Mon Tue Wed Thu Fri Sat Sun'.split(' ');
|
|
var daysLong = 'Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday'.split(' ');
|
|
var monthsShort = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
|
|
var monthsLong = 'January February March April May June July August September October November December'.split(' ');
|
|
fmt = fmt.replace('%D', '%m/%d/%Y');
|
|
fmt = fmt.replace('%r', '%I:%M:%S %p');
|
|
fmt = fmt.replace('%Y', '' + date.getFullYear());
|
|
fmt = fmt.replace('%y', '' + date.getYear());
|
|
fmt = fmt.replace('%m', addZeros(date.getMonth() + 1, 2));
|
|
fmt = fmt.replace('%d', addZeros(date.getDate(), 2));
|
|
fmt = fmt.replace('%H', '' + addZeros(date.getHours(), 2));
|
|
fmt = fmt.replace('%M', '' + addZeros(date.getMinutes(), 2));
|
|
fmt = fmt.replace('%S', '' + addZeros(date.getSeconds(), 2));
|
|
fmt = fmt.replace('%I', '' + ((date.getHours() + 11) % 12 + 1));
|
|
fmt = fmt.replace('%p', '' + (date.getHours() < 12 ? 'AM' : 'PM'));
|
|
fmt = fmt.replace('%B', '' + editor.translate(monthsLong[date.getMonth()]));
|
|
fmt = fmt.replace('%b', '' + editor.translate(monthsShort[date.getMonth()]));
|
|
fmt = fmt.replace('%A', '' + editor.translate(daysLong[date.getDay()]));
|
|
fmt = fmt.replace('%a', '' + editor.translate(daysShort[date.getDay()]));
|
|
fmt = fmt.replace('%%', '%');
|
|
return fmt;
|
|
};
|
|
|
|
var createTemplateList = function (editor, callback) {
|
|
return function () {
|
|
var templateList = getTemplates(editor);
|
|
if (isFunction(templateList)) {
|
|
templateList(callback);
|
|
} else if (isString(templateList)) {
|
|
global$2.send({
|
|
url: templateList,
|
|
success: function (text) {
|
|
callback(JSON.parse(text));
|
|
}
|
|
});
|
|
} else {
|
|
callback(templateList);
|
|
}
|
|
};
|
|
};
|
|
var replaceTemplateValues = function (html, templateValues) {
|
|
global$3.each(templateValues, function (v, k) {
|
|
if (isFunction(v)) {
|
|
v = v(k);
|
|
}
|
|
html = html.replace(new RegExp('\\{\\$' + k + '\\}', 'g'), v);
|
|
});
|
|
return html;
|
|
};
|
|
var replaceVals = function (editor, scope) {
|
|
var dom = editor.dom, vl = getTemplateReplaceValues(editor);
|
|
global$3.each(dom.select('*', scope), function (e) {
|
|
global$3.each(vl, function (v, k) {
|
|
if (dom.hasClass(e, k)) {
|
|
if (isFunction(v)) {
|
|
v(e);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var hasClass = function (n, c) {
|
|
return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
|
|
};
|
|
var insertTemplate = function (editor, _ui, html) {
|
|
var dom = editor.dom;
|
|
var sel = editor.selection.getContent();
|
|
html = replaceTemplateValues(html, getTemplateReplaceValues(editor));
|
|
var el = dom.create('div', null, html);
|
|
var n = dom.select('.mceTmpl', el);
|
|
if (n && n.length > 0) {
|
|
el = dom.create('div', null);
|
|
el.appendChild(n[0].cloneNode(true));
|
|
}
|
|
global$3.each(dom.select('*', el), function (n) {
|
|
if (hasClass(n, getCreationDateClasses(editor).replace(/\s+/g, '|'))) {
|
|
n.innerHTML = getDateTime(editor, getCdateFormat(editor));
|
|
}
|
|
if (hasClass(n, getModificationDateClasses(editor).replace(/\s+/g, '|'))) {
|
|
n.innerHTML = getDateTime(editor, getMdateFormat(editor));
|
|
}
|
|
if (hasClass(n, getSelectedContentClasses(editor).replace(/\s+/g, '|'))) {
|
|
n.innerHTML = sel;
|
|
}
|
|
});
|
|
replaceVals(editor, el);
|
|
editor.execCommand('mceInsertContent', false, el.innerHTML);
|
|
editor.addVisual();
|
|
};
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.Env');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Promise');
|
|
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var get = function (obj, key) {
|
|
return has(obj, key) ? Optional.from(obj[key]) : Optional.none();
|
|
};
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
var entitiesAttr = {
|
|
'"': '"',
|
|
'<': '<',
|
|
'>': '>',
|
|
'&': '&',
|
|
'\'': '''
|
|
};
|
|
var htmlEscape = function (html) {
|
|
return html.replace(/["'<>&]/g, function (match) {
|
|
return get(entitiesAttr, match).getOr(match);
|
|
});
|
|
};
|
|
|
|
var getPreviewContent = function (editor, html) {
|
|
if (html.indexOf('<html>') === -1) {
|
|
var contentCssEntries_1 = '';
|
|
var contentStyle = getContentStyle(editor);
|
|
var cors_1 = shouldUseContentCssCors(editor) ? ' crossorigin="anonymous"' : '';
|
|
global$3.each(editor.contentCSS, function (url) {
|
|
contentCssEntries_1 += '<link type="text/css" rel="stylesheet" href="' + editor.documentBaseURI.toAbsolute(url) + '"' + cors_1 + '>';
|
|
});
|
|
if (contentStyle) {
|
|
contentCssEntries_1 += '<style type="text/css">' + contentStyle + '</style>';
|
|
}
|
|
var bodyClass = getBodyClass(editor);
|
|
var encode = editor.dom.encode;
|
|
var isMetaKeyPressed = global$1.mac ? 'e.metaKey' : 'e.ctrlKey && !e.altKey';
|
|
var preventClicksOnLinksScript = '<script>' + 'document.addEventListener && document.addEventListener("click", function(e) {' + 'for (var elm = e.target; elm; elm = elm.parentNode) {' + 'if (elm.nodeName === "A" && !(' + isMetaKeyPressed + ')) {' + 'e.preventDefault();' + '}' + '}' + '}, false);' + '</script> ';
|
|
var directionality = editor.getBody().dir;
|
|
var dirAttr = directionality ? ' dir="' + encode(directionality) + '"' : '';
|
|
html = '<!DOCTYPE html>' + '<html>' + '<head>' + '<base href="' + encode(editor.documentBaseURI.getURI()) + '">' + contentCssEntries_1 + preventClicksOnLinksScript + '</head>' + '<body class="' + encode(bodyClass) + '"' + dirAttr + '>' + html + '</body>' + '</html>';
|
|
}
|
|
return replaceTemplateValues(html, getPreviewReplaceValues(editor));
|
|
};
|
|
var open = function (editor, templateList) {
|
|
var createTemplates = function () {
|
|
if (!templateList || templateList.length === 0) {
|
|
var message = editor.translate('No templates defined.');
|
|
editor.notificationManager.open({
|
|
text: message,
|
|
type: 'info'
|
|
});
|
|
return Optional.none();
|
|
}
|
|
return Optional.from(global$3.map(templateList, function (template, index) {
|
|
var isUrlTemplate = function (t) {
|
|
return t.url !== undefined;
|
|
};
|
|
return {
|
|
selected: index === 0,
|
|
text: template.title,
|
|
value: {
|
|
url: isUrlTemplate(template) ? Optional.from(template.url) : Optional.none(),
|
|
content: !isUrlTemplate(template) ? Optional.from(template.content) : Optional.none(),
|
|
description: template.description
|
|
}
|
|
};
|
|
}));
|
|
};
|
|
var createSelectBoxItems = function (templates) {
|
|
return map(templates, function (t) {
|
|
return {
|
|
text: t.text,
|
|
value: t.text
|
|
};
|
|
});
|
|
};
|
|
var findTemplate = function (templates, templateTitle) {
|
|
return find(templates, function (t) {
|
|
return t.text === templateTitle;
|
|
});
|
|
};
|
|
var loadFailedAlert = function (api) {
|
|
editor.windowManager.alert('Could not load the specified template.', function () {
|
|
return api.focus('template');
|
|
});
|
|
};
|
|
var getTemplateContent = function (t) {
|
|
return new global(function (resolve, reject) {
|
|
t.value.url.fold(function () {
|
|
return resolve(t.value.content.getOr(''));
|
|
}, function (url) {
|
|
return global$2.send({
|
|
url: url,
|
|
success: function (html) {
|
|
resolve(html);
|
|
},
|
|
error: function (e) {
|
|
reject(e);
|
|
}
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var onChange = function (templates, updateDialog) {
|
|
return function (api, change) {
|
|
if (change.name === 'template') {
|
|
var newTemplateTitle = api.getData().template;
|
|
findTemplate(templates, newTemplateTitle).each(function (t) {
|
|
api.block('Loading...');
|
|
getTemplateContent(t).then(function (previewHtml) {
|
|
updateDialog(api, t, previewHtml);
|
|
}).catch(function () {
|
|
updateDialog(api, t, '');
|
|
api.disable('save');
|
|
loadFailedAlert(api);
|
|
});
|
|
});
|
|
}
|
|
};
|
|
};
|
|
var onSubmit = function (templates) {
|
|
return function (api) {
|
|
var data = api.getData();
|
|
findTemplate(templates, data.template).each(function (t) {
|
|
getTemplateContent(t).then(function (previewHtml) {
|
|
editor.execCommand('mceInsertTemplate', false, previewHtml);
|
|
api.close();
|
|
}).catch(function () {
|
|
api.disable('save');
|
|
loadFailedAlert(api);
|
|
});
|
|
});
|
|
};
|
|
};
|
|
var openDialog = function (templates) {
|
|
var selectBoxItems = createSelectBoxItems(templates);
|
|
var buildDialogSpec = function (bodyItems, initialData) {
|
|
return {
|
|
title: 'Insert Template',
|
|
size: 'large',
|
|
body: {
|
|
type: 'panel',
|
|
items: bodyItems
|
|
},
|
|
initialData: initialData,
|
|
buttons: [
|
|
{
|
|
type: 'cancel',
|
|
name: 'cancel',
|
|
text: 'Cancel'
|
|
},
|
|
{
|
|
type: 'submit',
|
|
name: 'save',
|
|
text: 'Save',
|
|
primary: true
|
|
}
|
|
],
|
|
onSubmit: onSubmit(templates),
|
|
onChange: onChange(templates, updateDialog)
|
|
};
|
|
};
|
|
var updateDialog = function (dialogApi, template, previewHtml) {
|
|
var content = getPreviewContent(editor, previewHtml);
|
|
var bodyItems = [
|
|
{
|
|
type: 'selectbox',
|
|
name: 'template',
|
|
label: 'Templates',
|
|
items: selectBoxItems
|
|
},
|
|
{
|
|
type: 'htmlpanel',
|
|
html: '<p aria-live="polite">' + htmlEscape(template.value.description) + '</p>'
|
|
},
|
|
{
|
|
label: 'Preview',
|
|
type: 'iframe',
|
|
name: 'preview',
|
|
sandboxed: false
|
|
}
|
|
];
|
|
var initialData = {
|
|
template: template.text,
|
|
preview: content
|
|
};
|
|
dialogApi.unblock();
|
|
dialogApi.redial(buildDialogSpec(bodyItems, initialData));
|
|
dialogApi.focus('template');
|
|
};
|
|
var dialogApi = editor.windowManager.open(buildDialogSpec([], {
|
|
template: '',
|
|
preview: ''
|
|
}));
|
|
dialogApi.block('Loading...');
|
|
getTemplateContent(templates[0]).then(function (previewHtml) {
|
|
updateDialog(dialogApi, templates[0], previewHtml);
|
|
}).catch(function () {
|
|
updateDialog(dialogApi, templates[0], '');
|
|
dialogApi.disable('save');
|
|
loadFailedAlert(dialogApi);
|
|
});
|
|
};
|
|
var optTemplates = createTemplates();
|
|
optTemplates.each(openDialog);
|
|
};
|
|
|
|
var showDialog = function (editor) {
|
|
return function (templates) {
|
|
open(editor, templates);
|
|
};
|
|
};
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceInsertTemplate', curry(insertTemplate, editor));
|
|
editor.addCommand('mceTemplate', createTemplateList(editor, showDialog(editor)));
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
editor.on('PreProcess', function (o) {
|
|
var dom = editor.dom, dateFormat = getMdateFormat(editor);
|
|
global$3.each(dom.select('div', o.node), function (e) {
|
|
if (dom.hasClass(e, 'mceTmpl')) {
|
|
global$3.each(dom.select('*', e), function (e) {
|
|
if (dom.hasClass(e, getModificationDateClasses(editor).replace(/\s+/g, '|'))) {
|
|
e.innerHTML = getDateTime(editor, dateFormat);
|
|
}
|
|
});
|
|
replaceVals(editor, e);
|
|
}
|
|
});
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceTemplate');
|
|
};
|
|
editor.ui.registry.addButton('template', {
|
|
icon: 'template',
|
|
tooltip: 'Insert template',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('template', {
|
|
icon: 'template',
|
|
text: 'Insert template...',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$4.add('template', function (editor) {
|
|
register(editor);
|
|
register$1(editor);
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
function Plugin () {
|
|
global.add('textcolor', function () {
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.util.I18n');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var getTocClass = function (editor) {
|
|
return editor.getParam('toc_class', 'mce-toc');
|
|
};
|
|
var getTocHeader = function (editor) {
|
|
var tagName = editor.getParam('toc_header', 'h2');
|
|
return /^h[1-6]$/.test(tagName) ? tagName : 'h2';
|
|
};
|
|
var getTocDepth = function (editor) {
|
|
var depth = parseInt(editor.getParam('toc_depth', '3'), 10);
|
|
return depth >= 1 && depth <= 9 ? depth : 3;
|
|
};
|
|
|
|
var create = function (prefix) {
|
|
var counter = 0;
|
|
return function () {
|
|
var guid = new Date().getTime().toString(32);
|
|
return prefix + guid + (counter++).toString(32);
|
|
};
|
|
};
|
|
|
|
var tocId = create('mcetoc_');
|
|
var generateSelector = function (depth) {
|
|
var i;
|
|
var selector = [];
|
|
for (i = 1; i <= depth; i++) {
|
|
selector.push('h' + i);
|
|
}
|
|
return selector.join(',');
|
|
};
|
|
var hasHeaders = function (editor) {
|
|
return readHeaders(editor).length > 0;
|
|
};
|
|
var readHeaders = function (editor) {
|
|
var tocClass = getTocClass(editor);
|
|
var headerTag = getTocHeader(editor);
|
|
var selector = generateSelector(getTocDepth(editor));
|
|
var headers = editor.$(selector);
|
|
if (headers.length && /^h[1-9]$/i.test(headerTag)) {
|
|
headers = headers.filter(function (i, el) {
|
|
return !editor.dom.hasClass(el.parentNode, tocClass);
|
|
});
|
|
}
|
|
return global.map(headers, function (h) {
|
|
var id = h.id;
|
|
return {
|
|
id: id ? id : tocId(),
|
|
level: parseInt(h.nodeName.replace(/^H/i, ''), 10),
|
|
title: editor.$.text(h),
|
|
element: h
|
|
};
|
|
});
|
|
};
|
|
var getMinLevel = function (headers) {
|
|
var minLevel = 9;
|
|
for (var i = 0; i < headers.length; i++) {
|
|
if (headers[i].level < minLevel) {
|
|
minLevel = headers[i].level;
|
|
}
|
|
if (minLevel === 1) {
|
|
return minLevel;
|
|
}
|
|
}
|
|
return minLevel;
|
|
};
|
|
var generateTitle = function (tag, title) {
|
|
var openTag = '<' + tag + ' contenteditable="true">';
|
|
var closeTag = '</' + tag + '>';
|
|
return openTag + global$2.DOM.encode(title) + closeTag;
|
|
};
|
|
var generateTocHtml = function (editor) {
|
|
var html = generateTocContentHtml(editor);
|
|
return '<div class="' + editor.dom.encode(getTocClass(editor)) + '" contenteditable="false">' + html + '</div>';
|
|
};
|
|
var generateTocContentHtml = function (editor) {
|
|
var html = '';
|
|
var headers = readHeaders(editor);
|
|
var prevLevel = getMinLevel(headers) - 1;
|
|
if (!headers.length) {
|
|
return '';
|
|
}
|
|
html += generateTitle(getTocHeader(editor), global$1.translate('Table of Contents'));
|
|
for (var i = 0; i < headers.length; i++) {
|
|
var h = headers[i];
|
|
h.element.id = h.id;
|
|
var nextLevel = headers[i + 1] && headers[i + 1].level;
|
|
if (prevLevel === h.level) {
|
|
html += '<li>';
|
|
} else {
|
|
for (var ii = prevLevel; ii < h.level; ii++) {
|
|
html += '<ul><li>';
|
|
}
|
|
}
|
|
html += '<a href="#' + h.id + '">' + h.title + '</a>';
|
|
if (nextLevel === h.level || !nextLevel) {
|
|
html += '</li>';
|
|
if (!nextLevel) {
|
|
html += '</ul>';
|
|
}
|
|
} else {
|
|
for (var ii = h.level; ii > nextLevel; ii--) {
|
|
if (ii === nextLevel + 1) {
|
|
html += '</li></ul><li>';
|
|
} else {
|
|
html += '</li></ul>';
|
|
}
|
|
}
|
|
}
|
|
prevLevel = h.level;
|
|
}
|
|
return html;
|
|
};
|
|
var isEmptyOrOffscreen = function (editor, nodes) {
|
|
return !nodes.length || editor.dom.getParents(nodes[0], '.mce-offscreen-selection').length > 0;
|
|
};
|
|
var insertToc = function (editor) {
|
|
var tocClass = getTocClass(editor);
|
|
var $tocElm = editor.$('.' + tocClass);
|
|
if (isEmptyOrOffscreen(editor, $tocElm)) {
|
|
editor.insertContent(generateTocHtml(editor));
|
|
} else {
|
|
updateToc(editor);
|
|
}
|
|
};
|
|
var updateToc = function (editor) {
|
|
var tocClass = getTocClass(editor);
|
|
var $tocElm = editor.$('.' + tocClass);
|
|
if ($tocElm.length) {
|
|
editor.undoManager.transact(function () {
|
|
$tocElm.html(generateTocContentHtml(editor));
|
|
});
|
|
}
|
|
};
|
|
|
|
var register$1 = function (editor) {
|
|
editor.addCommand('mceInsertToc', function () {
|
|
insertToc(editor);
|
|
});
|
|
editor.addCommand('mceUpdateToc', function () {
|
|
updateToc(editor);
|
|
});
|
|
};
|
|
|
|
var setup = function (editor) {
|
|
var $ = editor.$, tocClass = getTocClass(editor);
|
|
editor.on('PreProcess', function (e) {
|
|
var $tocElm = $('.' + tocClass, e.node);
|
|
if ($tocElm.length) {
|
|
$tocElm.removeAttr('contentEditable');
|
|
$tocElm.find('[contenteditable]').removeAttr('contentEditable');
|
|
}
|
|
});
|
|
editor.on('SetContent', function () {
|
|
var $tocElm = $('.' + tocClass);
|
|
if ($tocElm.length) {
|
|
$tocElm.attr('contentEditable', false);
|
|
$tocElm.children(':first-child').attr('contentEditable', true);
|
|
}
|
|
});
|
|
};
|
|
|
|
var toggleState = function (editor) {
|
|
return function (api) {
|
|
var toggleDisabledState = function () {
|
|
return api.setDisabled(editor.mode.isReadOnly() || !hasHeaders(editor));
|
|
};
|
|
toggleDisabledState();
|
|
editor.on('LoadContent SetContent change', toggleDisabledState);
|
|
return function () {
|
|
return editor.on('LoadContent SetContent change', toggleDisabledState);
|
|
};
|
|
};
|
|
};
|
|
var isToc = function (editor) {
|
|
return function (elm) {
|
|
return elm && editor.dom.is(elm, '.' + getTocClass(editor)) && editor.getBody().contains(elm);
|
|
};
|
|
};
|
|
var register = function (editor) {
|
|
var insertTocAction = function () {
|
|
return editor.execCommand('mceInsertToc');
|
|
};
|
|
editor.ui.registry.addButton('toc', {
|
|
icon: 'toc',
|
|
tooltip: 'Table of contents',
|
|
onAction: insertTocAction,
|
|
onSetup: toggleState(editor)
|
|
});
|
|
editor.ui.registry.addButton('tocupdate', {
|
|
icon: 'reload',
|
|
tooltip: 'Update',
|
|
onAction: function () {
|
|
return editor.execCommand('mceUpdateToc');
|
|
}
|
|
});
|
|
editor.ui.registry.addMenuItem('toc', {
|
|
icon: 'toc',
|
|
text: 'Table of contents',
|
|
onAction: insertTocAction,
|
|
onSetup: toggleState(editor)
|
|
});
|
|
editor.ui.registry.addContextToolbar('toc', {
|
|
items: 'tocupdate',
|
|
predicate: isToc(editor),
|
|
scope: 'node',
|
|
position: 'node'
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$3.add('toc', function (editor) {
|
|
register$1(editor);
|
|
register(editor);
|
|
setup(editor);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$5 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
function __spreadArray(to, from, pack) {
|
|
if (pack || arguments.length === 2)
|
|
for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
if (ar || !(i in from)) {
|
|
if (!ar)
|
|
ar = Array.prototype.slice.call(from, 0, i);
|
|
ar[i] = from[i];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
}
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isString = isType('string');
|
|
var isObject = isType('object');
|
|
var isArray = isType('array');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var die = function (msg) {
|
|
return function () {
|
|
throw new Error(msg);
|
|
};
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var nativeSlice = Array.prototype.slice;
|
|
var nativeIndexOf = Array.prototype.indexOf;
|
|
var rawIndexOf = function (ts, t) {
|
|
return nativeIndexOf.call(ts, t);
|
|
};
|
|
var contains = function (xs, x) {
|
|
return rawIndexOf(xs, x) > -1;
|
|
};
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var eachr = function (xs, f) {
|
|
for (var i = xs.length - 1; i >= 0; i--) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
var foldr = function (xs, f, acc) {
|
|
eachr(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var foldl = function (xs, f, acc) {
|
|
each(xs, function (x, i) {
|
|
acc = f(acc, x, i);
|
|
});
|
|
return acc;
|
|
};
|
|
var findUntil = function (xs, pred, until) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
return Optional.some(x);
|
|
} else if (until(x, i)) {
|
|
break;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
};
|
|
var find = function (xs, pred) {
|
|
return findUntil(xs, pred, never);
|
|
};
|
|
var forall = function (xs, pred) {
|
|
for (var i = 0, len = xs.length; i < len; ++i) {
|
|
var x = xs[i];
|
|
if (pred(x, i) !== true) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
var sort = function (xs, comparator) {
|
|
var copy = nativeSlice.call(xs, 0);
|
|
copy.sort(comparator);
|
|
return copy;
|
|
};
|
|
var get$1 = function (xs, i) {
|
|
return i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
|
|
};
|
|
var head = function (xs) {
|
|
return get$1(xs, 0);
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var hasOwnProperty = Object.hasOwnProperty;
|
|
var has = function (obj, key) {
|
|
return hasOwnProperty.call(obj, key);
|
|
};
|
|
|
|
var generate$1 = function (cases) {
|
|
if (!isArray(cases)) {
|
|
throw new Error('cases must be an array');
|
|
}
|
|
if (cases.length === 0) {
|
|
throw new Error('there must be at least one case');
|
|
}
|
|
var constructors = [];
|
|
var adt = {};
|
|
each(cases, function (acase, count) {
|
|
var keys$1 = keys(acase);
|
|
if (keys$1.length !== 1) {
|
|
throw new Error('one and only one name per case');
|
|
}
|
|
var key = keys$1[0];
|
|
var value = acase[key];
|
|
if (adt[key] !== undefined) {
|
|
throw new Error('duplicate key detected:' + key);
|
|
} else if (key === 'cata') {
|
|
throw new Error('cannot have a case named cata (sorry)');
|
|
} else if (!isArray(value)) {
|
|
throw new Error('case arguments must be an array');
|
|
}
|
|
constructors.push(key);
|
|
adt[key] = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var argLength = args.length;
|
|
if (argLength !== value.length) {
|
|
throw new Error('Wrong number of arguments to case ' + key + '. Expected ' + value.length + ' (' + value + '), got ' + argLength);
|
|
}
|
|
var match = function (branches) {
|
|
var branchKeys = keys(branches);
|
|
if (constructors.length !== branchKeys.length) {
|
|
throw new Error('Wrong number of arguments to match. Expected: ' + constructors.join(',') + '\nActual: ' + branchKeys.join(','));
|
|
}
|
|
var allReqd = forall(constructors, function (reqKey) {
|
|
return contains(branchKeys, reqKey);
|
|
});
|
|
if (!allReqd) {
|
|
throw new Error('Not all branches were specified when using match. Specified: ' + branchKeys.join(', ') + '\nRequired: ' + constructors.join(', '));
|
|
}
|
|
return branches[key].apply(null, args);
|
|
};
|
|
return {
|
|
fold: function () {
|
|
var foldArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
foldArgs[_i] = arguments[_i];
|
|
}
|
|
if (foldArgs.length !== cases.length) {
|
|
throw new Error('Wrong number of arguments to fold. Expected ' + cases.length + ', got ' + foldArgs.length);
|
|
}
|
|
var target = foldArgs[count];
|
|
return target.apply(null, args);
|
|
},
|
|
match: match,
|
|
log: function (label) {
|
|
console.log(label, {
|
|
constructors: constructors,
|
|
constructor: key,
|
|
params: args
|
|
});
|
|
}
|
|
};
|
|
};
|
|
});
|
|
return adt;
|
|
};
|
|
var Adt = { generate: generate$1 };
|
|
|
|
Adt.generate([
|
|
{
|
|
bothErrors: [
|
|
'error1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
firstError: [
|
|
'error1',
|
|
'value2'
|
|
]
|
|
},
|
|
{
|
|
secondError: [
|
|
'value1',
|
|
'error2'
|
|
]
|
|
},
|
|
{
|
|
bothValues: [
|
|
'value1',
|
|
'value2'
|
|
]
|
|
}
|
|
]);
|
|
var partition = function (results) {
|
|
var errors = [];
|
|
var values = [];
|
|
each(results, function (result) {
|
|
result.fold(function (err) {
|
|
errors.push(err);
|
|
}, function (value) {
|
|
values.push(value);
|
|
});
|
|
});
|
|
return {
|
|
errors: errors,
|
|
values: values
|
|
};
|
|
};
|
|
|
|
var value = function (o) {
|
|
var or = function (_opt) {
|
|
return value(o);
|
|
};
|
|
var orThunk = function (_f) {
|
|
return value(o);
|
|
};
|
|
var map = function (f) {
|
|
return value(f(o));
|
|
};
|
|
var mapError = function (_f) {
|
|
return value(o);
|
|
};
|
|
var each = function (f) {
|
|
f(o);
|
|
};
|
|
var bind = function (f) {
|
|
return f(o);
|
|
};
|
|
var fold = function (_, onValue) {
|
|
return onValue(o);
|
|
};
|
|
var exists = function (f) {
|
|
return f(o);
|
|
};
|
|
var forall = function (f) {
|
|
return f(o);
|
|
};
|
|
var toOptional = function () {
|
|
return Optional.some(o);
|
|
};
|
|
return {
|
|
isValue: always,
|
|
isError: never,
|
|
getOr: constant(o),
|
|
getOrThunk: constant(o),
|
|
getOrDie: constant(o),
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: each,
|
|
bind: bind,
|
|
exists: exists,
|
|
forall: forall,
|
|
toOptional: toOptional
|
|
};
|
|
};
|
|
var error$1 = function (message) {
|
|
var getOrThunk = function (f) {
|
|
return f();
|
|
};
|
|
var getOrDie = function () {
|
|
return die(String(message))();
|
|
};
|
|
var or = identity;
|
|
var orThunk = function (f) {
|
|
return f();
|
|
};
|
|
var map = function (_f) {
|
|
return error$1(message);
|
|
};
|
|
var mapError = function (f) {
|
|
return error$1(f(message));
|
|
};
|
|
var bind = function (_f) {
|
|
return error$1(message);
|
|
};
|
|
var fold = function (onError, _) {
|
|
return onError(message);
|
|
};
|
|
return {
|
|
isValue: never,
|
|
isError: always,
|
|
getOr: identity,
|
|
getOrThunk: getOrThunk,
|
|
getOrDie: getOrDie,
|
|
or: or,
|
|
orThunk: orThunk,
|
|
fold: fold,
|
|
map: map,
|
|
mapError: mapError,
|
|
each: noop,
|
|
bind: bind,
|
|
exists: never,
|
|
forall: always,
|
|
toOptional: Optional.none
|
|
};
|
|
};
|
|
var fromOption = function (opt, err) {
|
|
return opt.fold(function () {
|
|
return error$1(err);
|
|
}, value);
|
|
};
|
|
var Result = {
|
|
value: value,
|
|
error: error$1,
|
|
fromOption: fromOption
|
|
};
|
|
|
|
var isInlinePattern = function (pattern) {
|
|
return pattern.type === 'inline-command' || pattern.type === 'inline-format';
|
|
};
|
|
var isBlockPattern = function (pattern) {
|
|
return pattern.type === 'block-command' || pattern.type === 'block-format';
|
|
};
|
|
var sortPatterns = function (patterns) {
|
|
return sort(patterns, function (a, b) {
|
|
if (a.start.length === b.start.length) {
|
|
return 0;
|
|
}
|
|
return a.start.length > b.start.length ? -1 : 1;
|
|
});
|
|
};
|
|
var normalizePattern = function (pattern) {
|
|
var err = function (message) {
|
|
return Result.error({
|
|
message: message,
|
|
pattern: pattern
|
|
});
|
|
};
|
|
var formatOrCmd = function (name, onFormat, onCommand) {
|
|
if (pattern.format !== undefined) {
|
|
var formats = void 0;
|
|
if (isArray(pattern.format)) {
|
|
if (!forall(pattern.format, isString)) {
|
|
return err(name + ' pattern has non-string items in the `format` array');
|
|
}
|
|
formats = pattern.format;
|
|
} else if (isString(pattern.format)) {
|
|
formats = [pattern.format];
|
|
} else {
|
|
return err(name + ' pattern has non-string `format` parameter');
|
|
}
|
|
return Result.value(onFormat(formats));
|
|
} else if (pattern.cmd !== undefined) {
|
|
if (!isString(pattern.cmd)) {
|
|
return err(name + ' pattern has non-string `cmd` parameter');
|
|
}
|
|
return Result.value(onCommand(pattern.cmd, pattern.value));
|
|
} else {
|
|
return err(name + ' pattern is missing both `format` and `cmd` parameters');
|
|
}
|
|
};
|
|
if (!isObject(pattern)) {
|
|
return err('Raw pattern is not an object');
|
|
}
|
|
if (!isString(pattern.start)) {
|
|
return err('Raw pattern is missing `start` parameter');
|
|
}
|
|
if (pattern.end !== undefined) {
|
|
if (!isString(pattern.end)) {
|
|
return err('Inline pattern has non-string `end` parameter');
|
|
}
|
|
if (pattern.start.length === 0 && pattern.end.length === 0) {
|
|
return err('Inline pattern has empty `start` and `end` parameters');
|
|
}
|
|
var start_1 = pattern.start;
|
|
var end_1 = pattern.end;
|
|
if (end_1.length === 0) {
|
|
end_1 = start_1;
|
|
start_1 = '';
|
|
}
|
|
return formatOrCmd('Inline', function (format) {
|
|
return {
|
|
type: 'inline-format',
|
|
start: start_1,
|
|
end: end_1,
|
|
format: format
|
|
};
|
|
}, function (cmd, value) {
|
|
return {
|
|
type: 'inline-command',
|
|
start: start_1,
|
|
end: end_1,
|
|
cmd: cmd,
|
|
value: value
|
|
};
|
|
});
|
|
} else if (pattern.replacement !== undefined) {
|
|
if (!isString(pattern.replacement)) {
|
|
return err('Replacement pattern has non-string `replacement` parameter');
|
|
}
|
|
if (pattern.start.length === 0) {
|
|
return err('Replacement pattern has empty `start` parameter');
|
|
}
|
|
return Result.value({
|
|
type: 'inline-command',
|
|
start: '',
|
|
end: pattern.start,
|
|
cmd: 'mceInsertContent',
|
|
value: pattern.replacement
|
|
});
|
|
} else {
|
|
if (pattern.start.length === 0) {
|
|
return err('Block pattern has empty `start` parameter');
|
|
}
|
|
return formatOrCmd('Block', function (formats) {
|
|
return {
|
|
type: 'block-format',
|
|
start: pattern.start,
|
|
format: formats[0]
|
|
};
|
|
}, function (command, commandValue) {
|
|
return {
|
|
type: 'block-command',
|
|
start: pattern.start,
|
|
cmd: command,
|
|
value: commandValue
|
|
};
|
|
});
|
|
}
|
|
};
|
|
var denormalizePattern = function (pattern) {
|
|
if (pattern.type === 'block-command') {
|
|
return {
|
|
start: pattern.start,
|
|
cmd: pattern.cmd,
|
|
value: pattern.value
|
|
};
|
|
} else if (pattern.type === 'block-format') {
|
|
return {
|
|
start: pattern.start,
|
|
format: pattern.format
|
|
};
|
|
} else if (pattern.type === 'inline-command') {
|
|
if (pattern.cmd === 'mceInsertContent' && pattern.start === '') {
|
|
return {
|
|
start: pattern.end,
|
|
replacement: pattern.value
|
|
};
|
|
} else {
|
|
return {
|
|
start: pattern.start,
|
|
end: pattern.end,
|
|
cmd: pattern.cmd,
|
|
value: pattern.value
|
|
};
|
|
}
|
|
} else if (pattern.type === 'inline-format') {
|
|
return {
|
|
start: pattern.start,
|
|
end: pattern.end,
|
|
format: pattern.format.length === 1 ? pattern.format[0] : pattern.format
|
|
};
|
|
}
|
|
};
|
|
var createPatternSet = function (patterns) {
|
|
return {
|
|
inlinePatterns: filter(patterns, isInlinePattern),
|
|
blockPatterns: sortPatterns(filter(patterns, isBlockPattern))
|
|
};
|
|
};
|
|
|
|
var get = function (patternsState) {
|
|
var setPatterns = function (newPatterns) {
|
|
var normalized = partition(map(newPatterns, normalizePattern));
|
|
if (normalized.errors.length > 0) {
|
|
var firstError = normalized.errors[0];
|
|
throw new Error(firstError.message + ':\n' + JSON.stringify(firstError.pattern, null, 2));
|
|
}
|
|
patternsState.set(createPatternSet(normalized.values));
|
|
};
|
|
var getPatterns = function () {
|
|
return __spreadArray(__spreadArray([], map(patternsState.get().inlinePatterns, denormalizePattern), true), map(patternsState.get().blockPatterns, denormalizePattern), true);
|
|
};
|
|
return {
|
|
setPatterns: setPatterns,
|
|
getPatterns: getPatterns
|
|
};
|
|
};
|
|
|
|
var Global = typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var error = function () {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var console = Global.console;
|
|
if (console) {
|
|
if (console.error) {
|
|
console.error.apply(console, args);
|
|
} else {
|
|
console.log.apply(console, args);
|
|
}
|
|
}
|
|
};
|
|
var defaultPatterns = [
|
|
{
|
|
start: '*',
|
|
end: '*',
|
|
format: 'italic'
|
|
},
|
|
{
|
|
start: '**',
|
|
end: '**',
|
|
format: 'bold'
|
|
},
|
|
{
|
|
start: '#',
|
|
format: 'h1'
|
|
},
|
|
{
|
|
start: '##',
|
|
format: 'h2'
|
|
},
|
|
{
|
|
start: '###',
|
|
format: 'h3'
|
|
},
|
|
{
|
|
start: '####',
|
|
format: 'h4'
|
|
},
|
|
{
|
|
start: '#####',
|
|
format: 'h5'
|
|
},
|
|
{
|
|
start: '######',
|
|
format: 'h6'
|
|
},
|
|
{
|
|
start: '1. ',
|
|
cmd: 'InsertOrderedList'
|
|
},
|
|
{
|
|
start: '* ',
|
|
cmd: 'InsertUnorderedList'
|
|
},
|
|
{
|
|
start: '- ',
|
|
cmd: 'InsertUnorderedList'
|
|
}
|
|
];
|
|
var getPatternSet = function (editor) {
|
|
var patterns = editor.getParam('textpattern_patterns', defaultPatterns, 'array');
|
|
if (!isArray(patterns)) {
|
|
error('The setting textpattern_patterns should be an array');
|
|
return {
|
|
inlinePatterns: [],
|
|
blockPatterns: []
|
|
};
|
|
}
|
|
var normalized = partition(map(patterns, normalizePattern));
|
|
each(normalized.errors, function (err) {
|
|
return error(err.message, err.pattern);
|
|
});
|
|
return createPatternSet(normalized.values);
|
|
};
|
|
var getForcedRootBlock = function (editor) {
|
|
var block = editor.getParam('forced_root_block', 'p');
|
|
if (block === false) {
|
|
return '';
|
|
} else if (block === true) {
|
|
return 'p';
|
|
} else {
|
|
return block;
|
|
}
|
|
};
|
|
|
|
var global$4 = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var global$3 = tinymce.util.Tools.resolve('tinymce.util.VK');
|
|
|
|
var zeroWidth = '\uFEFF';
|
|
var nbsp = '\xA0';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.util.Tools');
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.DOMUtils');
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.dom.TextSeeker');
|
|
|
|
var point = function (container, offset) {
|
|
return {
|
|
container: container,
|
|
offset: offset
|
|
};
|
|
};
|
|
|
|
var isText = function (node) {
|
|
return node.nodeType === Node.TEXT_NODE;
|
|
};
|
|
var cleanEmptyNodes = function (dom, node, isRoot) {
|
|
if (node && dom.isEmpty(node) && !isRoot(node)) {
|
|
var parent_1 = node.parentNode;
|
|
dom.remove(node);
|
|
cleanEmptyNodes(dom, parent_1, isRoot);
|
|
}
|
|
};
|
|
var deleteRng = function (dom, rng, isRoot, clean) {
|
|
if (clean === void 0) {
|
|
clean = true;
|
|
}
|
|
var startParent = rng.startContainer.parentNode;
|
|
var endParent = rng.endContainer.parentNode;
|
|
rng.deleteContents();
|
|
if (clean && !isRoot(rng.startContainer)) {
|
|
if (isText(rng.startContainer) && rng.startContainer.data.length === 0) {
|
|
dom.remove(rng.startContainer);
|
|
}
|
|
if (isText(rng.endContainer) && rng.endContainer.data.length === 0) {
|
|
dom.remove(rng.endContainer);
|
|
}
|
|
cleanEmptyNodes(dom, startParent, isRoot);
|
|
if (startParent !== endParent) {
|
|
cleanEmptyNodes(dom, endParent, isRoot);
|
|
}
|
|
}
|
|
};
|
|
var isBlockFormatName = function (name, formatter) {
|
|
var formatSet = formatter.get(name);
|
|
return isArray(formatSet) && head(formatSet).exists(function (format) {
|
|
return has(format, 'block');
|
|
});
|
|
};
|
|
var isReplacementPattern = function (pattern) {
|
|
return pattern.start.length === 0;
|
|
};
|
|
var getParentBlock = function (editor, rng) {
|
|
var parentBlockOpt = Optional.from(editor.dom.getParent(rng.startContainer, editor.dom.isBlock));
|
|
if (getForcedRootBlock(editor) === '') {
|
|
return parentBlockOpt.orThunk(function () {
|
|
return Optional.some(editor.getBody());
|
|
});
|
|
} else {
|
|
return parentBlockOpt;
|
|
}
|
|
};
|
|
|
|
var DOM = global$1.DOM;
|
|
var alwaysNext = function (startNode) {
|
|
return function (node) {
|
|
return startNode === node ? -1 : 0;
|
|
};
|
|
};
|
|
var isBoundary = function (dom) {
|
|
return function (node) {
|
|
return dom.isBlock(node) || contains([
|
|
'BR',
|
|
'IMG',
|
|
'HR',
|
|
'INPUT'
|
|
], node.nodeName) || dom.getContentEditable(node) === 'false';
|
|
};
|
|
};
|
|
var textBefore = function (node, offset, rootNode) {
|
|
if (isText(node) && offset >= 0) {
|
|
return Optional.some(point(node, offset));
|
|
} else {
|
|
var textSeeker = global(DOM);
|
|
return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).map(function (prev) {
|
|
return point(prev.container, prev.container.data.length);
|
|
});
|
|
}
|
|
};
|
|
var textAfter = function (node, offset, rootNode) {
|
|
if (isText(node) && offset >= node.length) {
|
|
return Optional.some(point(node, offset));
|
|
} else {
|
|
var textSeeker = global(DOM);
|
|
return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).map(function (prev) {
|
|
return point(prev.container, 0);
|
|
});
|
|
}
|
|
};
|
|
var scanLeft = function (node, offset, rootNode) {
|
|
if (!isText(node)) {
|
|
return Optional.none();
|
|
}
|
|
var text = node.textContent;
|
|
if (offset >= 0 && offset <= text.length) {
|
|
return Optional.some(point(node, offset));
|
|
} else {
|
|
var textSeeker = global(DOM);
|
|
return Optional.from(textSeeker.backwards(node, offset, alwaysNext(node), rootNode)).bind(function (prev) {
|
|
var prevText = prev.container.data;
|
|
return scanLeft(prev.container, offset + prevText.length, rootNode);
|
|
});
|
|
}
|
|
};
|
|
var scanRight = function (node, offset, rootNode) {
|
|
if (!isText(node)) {
|
|
return Optional.none();
|
|
}
|
|
var text = node.textContent;
|
|
if (offset <= text.length) {
|
|
return Optional.some(point(node, offset));
|
|
} else {
|
|
var textSeeker = global(DOM);
|
|
return Optional.from(textSeeker.forwards(node, offset, alwaysNext(node), rootNode)).bind(function (next) {
|
|
return scanRight(next.container, offset - text.length, rootNode);
|
|
});
|
|
}
|
|
};
|
|
var repeatLeft = function (dom, node, offset, process, rootNode) {
|
|
var search = global(dom, isBoundary(dom));
|
|
return Optional.from(search.backwards(node, offset, process, rootNode));
|
|
};
|
|
|
|
var generatePath = function (root, node, offset) {
|
|
if (isText(node) && (offset < 0 || offset > node.data.length)) {
|
|
return [];
|
|
}
|
|
var p = [offset];
|
|
var current = node;
|
|
while (current !== root && current.parentNode) {
|
|
var parent_1 = current.parentNode;
|
|
for (var i = 0; i < parent_1.childNodes.length; i++) {
|
|
if (parent_1.childNodes[i] === current) {
|
|
p.push(i);
|
|
break;
|
|
}
|
|
}
|
|
current = parent_1;
|
|
}
|
|
return current === root ? p.reverse() : [];
|
|
};
|
|
var generatePathRange = function (root, startNode, startOffset, endNode, endOffset) {
|
|
var start = generatePath(root, startNode, startOffset);
|
|
var end = generatePath(root, endNode, endOffset);
|
|
return {
|
|
start: start,
|
|
end: end
|
|
};
|
|
};
|
|
var resolvePath = function (root, path) {
|
|
var nodePath = path.slice();
|
|
var offset = nodePath.pop();
|
|
var resolvedNode = foldl(nodePath, function (optNode, index) {
|
|
return optNode.bind(function (node) {
|
|
return Optional.from(node.childNodes[index]);
|
|
});
|
|
}, Optional.some(root));
|
|
return resolvedNode.bind(function (node) {
|
|
if (isText(node) && (offset < 0 || offset > node.data.length)) {
|
|
return Optional.none();
|
|
} else {
|
|
return Optional.some({
|
|
node: node,
|
|
offset: offset
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var resolvePathRange = function (root, range) {
|
|
return resolvePath(root, range.start).bind(function (_a) {
|
|
var startNode = _a.node, startOffset = _a.offset;
|
|
return resolvePath(root, range.end).map(function (_a) {
|
|
var endNode = _a.node, endOffset = _a.offset;
|
|
var rng = document.createRange();
|
|
rng.setStart(startNode, startOffset);
|
|
rng.setEnd(endNode, endOffset);
|
|
return rng;
|
|
});
|
|
});
|
|
};
|
|
var generatePathRangeFromRange = function (root, range) {
|
|
return generatePathRange(root, range.startContainer, range.startOffset, range.endContainer, range.endOffset);
|
|
};
|
|
|
|
var stripPattern = function (dom, block, pattern) {
|
|
var firstTextNode = textAfter(block, 0, block);
|
|
firstTextNode.each(function (spot) {
|
|
var node = spot.container;
|
|
scanRight(node, pattern.start.length, block).each(function (end) {
|
|
var rng = dom.createRng();
|
|
rng.setStart(node, 0);
|
|
rng.setEnd(end.container, end.offset);
|
|
deleteRng(dom, rng, function (e) {
|
|
return e === block;
|
|
});
|
|
});
|
|
});
|
|
};
|
|
var applyPattern$1 = function (editor, match) {
|
|
var dom = editor.dom;
|
|
var pattern = match.pattern;
|
|
var rng = resolvePathRange(dom.getRoot(), match.range).getOrDie('Unable to resolve path range');
|
|
getParentBlock(editor, rng).each(function (block) {
|
|
if (pattern.type === 'block-format') {
|
|
if (isBlockFormatName(pattern.format, editor.formatter)) {
|
|
editor.undoManager.transact(function () {
|
|
stripPattern(editor.dom, block, pattern);
|
|
editor.formatter.apply(pattern.format);
|
|
});
|
|
}
|
|
} else if (pattern.type === 'block-command') {
|
|
editor.undoManager.transact(function () {
|
|
stripPattern(editor.dom, block, pattern);
|
|
editor.execCommand(pattern.cmd, false, pattern.value);
|
|
});
|
|
}
|
|
});
|
|
return true;
|
|
};
|
|
var findPattern$1 = function (patterns, text) {
|
|
var nuText = text.replace(nbsp, ' ');
|
|
return find(patterns, function (pattern) {
|
|
return text.indexOf(pattern.start) === 0 || nuText.indexOf(pattern.start) === 0;
|
|
});
|
|
};
|
|
var findPatterns$1 = function (editor, patterns) {
|
|
var dom = editor.dom;
|
|
var rng = editor.selection.getRng();
|
|
return getParentBlock(editor, rng).filter(function (block) {
|
|
var forcedRootBlock = getForcedRootBlock(editor);
|
|
var matchesForcedRootBlock = forcedRootBlock === '' && dom.is(block, 'body') || dom.is(block, forcedRootBlock);
|
|
return block !== null && matchesForcedRootBlock;
|
|
}).bind(function (block) {
|
|
var blockText = block.textContent;
|
|
var matchedPattern = findPattern$1(patterns, blockText);
|
|
return matchedPattern.map(function (pattern) {
|
|
if (global$2.trim(blockText).length === pattern.start.length) {
|
|
return [];
|
|
}
|
|
return [{
|
|
pattern: pattern,
|
|
range: generatePathRange(dom.getRoot(), block, 0, block, 0)
|
|
}];
|
|
});
|
|
}).getOr([]);
|
|
};
|
|
var applyMatches$1 = function (editor, matches) {
|
|
if (matches.length === 0) {
|
|
return;
|
|
}
|
|
var bookmark = editor.selection.getBookmark();
|
|
each(matches, function (match) {
|
|
return applyPattern$1(editor, match);
|
|
});
|
|
editor.selection.moveToBookmark(bookmark);
|
|
};
|
|
|
|
var unique = 0;
|
|
var generate = function (prefix) {
|
|
var date = new Date();
|
|
var time = date.getTime();
|
|
var random = Math.floor(Math.random() * 1000000000);
|
|
unique++;
|
|
return prefix + '_' + random + unique + String(time);
|
|
};
|
|
|
|
var checkRange = function (str, substr, start) {
|
|
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
|
|
};
|
|
var endsWith = function (str, suffix) {
|
|
return checkRange(str, suffix, str.length - suffix.length);
|
|
};
|
|
|
|
var newMarker = function (dom, id) {
|
|
return dom.create('span', {
|
|
'data-mce-type': 'bookmark',
|
|
id: id
|
|
});
|
|
};
|
|
var rangeFromMarker = function (dom, marker) {
|
|
var rng = dom.createRng();
|
|
rng.setStartAfter(marker.start);
|
|
rng.setEndBefore(marker.end);
|
|
return rng;
|
|
};
|
|
var createMarker = function (dom, markerPrefix, pathRange) {
|
|
var rng = resolvePathRange(dom.getRoot(), pathRange).getOrDie('Unable to resolve path range');
|
|
var startNode = rng.startContainer;
|
|
var endNode = rng.endContainer;
|
|
var textEnd = rng.endOffset === 0 ? endNode : endNode.splitText(rng.endOffset);
|
|
var textStart = rng.startOffset === 0 ? startNode : startNode.splitText(rng.startOffset);
|
|
return {
|
|
prefix: markerPrefix,
|
|
end: textEnd.parentNode.insertBefore(newMarker(dom, markerPrefix + '-end'), textEnd),
|
|
start: textStart.parentNode.insertBefore(newMarker(dom, markerPrefix + '-start'), textStart)
|
|
};
|
|
};
|
|
var removeMarker = function (dom, marker, isRoot) {
|
|
cleanEmptyNodes(dom, dom.get(marker.prefix + '-end'), isRoot);
|
|
cleanEmptyNodes(dom, dom.get(marker.prefix + '-start'), isRoot);
|
|
};
|
|
|
|
var matchesPattern = function (dom, block, patternContent) {
|
|
return function (element, offset) {
|
|
var text = element.data;
|
|
var searchText = text.substring(0, offset);
|
|
var startEndIndex = searchText.lastIndexOf(patternContent.charAt(patternContent.length - 1));
|
|
var startIndex = searchText.lastIndexOf(patternContent);
|
|
if (startIndex !== -1) {
|
|
return startIndex + patternContent.length;
|
|
} else if (startEndIndex !== -1) {
|
|
return startEndIndex + 1;
|
|
} else {
|
|
return -1;
|
|
}
|
|
};
|
|
};
|
|
var findPatternStartFromSpot = function (dom, pattern, block, spot) {
|
|
var startPattern = pattern.start;
|
|
var startSpot = repeatLeft(dom, spot.container, spot.offset, matchesPattern(dom, block, startPattern), block);
|
|
return startSpot.bind(function (spot) {
|
|
if (spot.offset >= startPattern.length) {
|
|
var rng = dom.createRng();
|
|
rng.setStart(spot.container, spot.offset - startPattern.length);
|
|
rng.setEnd(spot.container, spot.offset);
|
|
return Optional.some(rng);
|
|
} else {
|
|
var offset = spot.offset - startPattern.length;
|
|
return scanLeft(spot.container, offset, block).map(function (nextSpot) {
|
|
var rng = dom.createRng();
|
|
rng.setStart(nextSpot.container, nextSpot.offset);
|
|
rng.setEnd(spot.container, spot.offset);
|
|
return rng;
|
|
}).filter(function (rng) {
|
|
return rng.toString() === startPattern;
|
|
}).orThunk(function () {
|
|
return findPatternStartFromSpot(dom, pattern, block, point(spot.container, 0));
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var findPatternStart = function (dom, pattern, node, offset, block, requireGap) {
|
|
if (requireGap === void 0) {
|
|
requireGap = false;
|
|
}
|
|
if (pattern.start.length === 0 && !requireGap) {
|
|
var rng = dom.createRng();
|
|
rng.setStart(node, offset);
|
|
rng.setEnd(node, offset);
|
|
return Optional.some(rng);
|
|
}
|
|
return textBefore(node, offset, block).bind(function (spot) {
|
|
var start = findPatternStartFromSpot(dom, pattern, block, spot);
|
|
return start.bind(function (startRange) {
|
|
if (requireGap) {
|
|
if (startRange.endContainer === spot.container && startRange.endOffset === spot.offset) {
|
|
return Optional.none();
|
|
} else if (spot.offset === 0 && startRange.endContainer.textContent.length === startRange.endOffset) {
|
|
return Optional.none();
|
|
}
|
|
}
|
|
return Optional.some(startRange);
|
|
});
|
|
});
|
|
};
|
|
var findPattern = function (editor, block, details) {
|
|
var dom = editor.dom;
|
|
var root = dom.getRoot();
|
|
var pattern = details.pattern;
|
|
var endNode = details.position.container;
|
|
var endOffset = details.position.offset;
|
|
return scanLeft(endNode, endOffset - details.pattern.end.length, block).bind(function (spot) {
|
|
var endPathRng = generatePathRange(root, spot.container, spot.offset, endNode, endOffset);
|
|
if (isReplacementPattern(pattern)) {
|
|
return Optional.some({
|
|
matches: [{
|
|
pattern: pattern,
|
|
startRng: endPathRng,
|
|
endRng: endPathRng
|
|
}],
|
|
position: spot
|
|
});
|
|
} else {
|
|
var resultsOpt = findPatternsRec(editor, details.remainingPatterns, spot.container, spot.offset, block);
|
|
var results_1 = resultsOpt.getOr({
|
|
matches: [],
|
|
position: spot
|
|
});
|
|
var pos = results_1.position;
|
|
var start = findPatternStart(dom, pattern, pos.container, pos.offset, block, resultsOpt.isNone());
|
|
return start.map(function (startRng) {
|
|
var startPathRng = generatePathRangeFromRange(root, startRng);
|
|
return {
|
|
matches: results_1.matches.concat([{
|
|
pattern: pattern,
|
|
startRng: startPathRng,
|
|
endRng: endPathRng
|
|
}]),
|
|
position: point(startRng.startContainer, startRng.startOffset)
|
|
};
|
|
});
|
|
}
|
|
});
|
|
};
|
|
var findPatternsRec = function (editor, patterns, node, offset, block) {
|
|
var dom = editor.dom;
|
|
return textBefore(node, offset, dom.getRoot()).bind(function (endSpot) {
|
|
var rng = dom.createRng();
|
|
rng.setStart(block, 0);
|
|
rng.setEnd(node, offset);
|
|
var text = rng.toString();
|
|
for (var i = 0; i < patterns.length; i++) {
|
|
var pattern = patterns[i];
|
|
if (!endsWith(text, pattern.end)) {
|
|
continue;
|
|
}
|
|
var patternsWithoutCurrent = patterns.slice();
|
|
patternsWithoutCurrent.splice(i, 1);
|
|
var result = findPattern(editor, block, {
|
|
pattern: pattern,
|
|
remainingPatterns: patternsWithoutCurrent,
|
|
position: endSpot
|
|
});
|
|
if (result.isSome()) {
|
|
return result;
|
|
}
|
|
}
|
|
return Optional.none();
|
|
});
|
|
};
|
|
var applyPattern = function (editor, pattern, patternRange) {
|
|
editor.selection.setRng(patternRange);
|
|
if (pattern.type === 'inline-format') {
|
|
each(pattern.format, function (format) {
|
|
editor.formatter.apply(format);
|
|
});
|
|
} else {
|
|
editor.execCommand(pattern.cmd, false, pattern.value);
|
|
}
|
|
};
|
|
var applyReplacementPattern = function (editor, pattern, marker, isRoot) {
|
|
var markerRange = rangeFromMarker(editor.dom, marker);
|
|
deleteRng(editor.dom, markerRange, isRoot);
|
|
applyPattern(editor, pattern, markerRange);
|
|
};
|
|
var applyPatternWithContent = function (editor, pattern, startMarker, endMarker, isRoot) {
|
|
var dom = editor.dom;
|
|
var markerEndRange = rangeFromMarker(dom, endMarker);
|
|
var markerStartRange = rangeFromMarker(dom, startMarker);
|
|
deleteRng(dom, markerStartRange, isRoot);
|
|
deleteRng(dom, markerEndRange, isRoot);
|
|
var patternMarker = {
|
|
prefix: startMarker.prefix,
|
|
start: startMarker.end,
|
|
end: endMarker.start
|
|
};
|
|
var patternRange = rangeFromMarker(dom, patternMarker);
|
|
applyPattern(editor, pattern, patternRange);
|
|
};
|
|
var addMarkers = function (dom, matches) {
|
|
var markerPrefix = generate('mce_textpattern');
|
|
var matchesWithEnds = foldr(matches, function (acc, match) {
|
|
var endMarker = createMarker(dom, markerPrefix + ('_end' + acc.length), match.endRng);
|
|
return acc.concat([__assign(__assign({}, match), { endMarker: endMarker })]);
|
|
}, []);
|
|
return foldr(matchesWithEnds, function (acc, match) {
|
|
var idx = matchesWithEnds.length - acc.length - 1;
|
|
var startMarker = isReplacementPattern(match.pattern) ? match.endMarker : createMarker(dom, markerPrefix + ('_start' + idx), match.startRng);
|
|
return acc.concat([__assign(__assign({}, match), { startMarker: startMarker })]);
|
|
}, []);
|
|
};
|
|
var findPatterns = function (editor, patterns, space) {
|
|
var rng = editor.selection.getRng();
|
|
if (rng.collapsed === false) {
|
|
return [];
|
|
}
|
|
return getParentBlock(editor, rng).bind(function (block) {
|
|
var offset = rng.startOffset - (space ? 1 : 0);
|
|
return findPatternsRec(editor, patterns, rng.startContainer, offset, block);
|
|
}).fold(function () {
|
|
return [];
|
|
}, function (result) {
|
|
return result.matches;
|
|
});
|
|
};
|
|
var applyMatches = function (editor, matches) {
|
|
if (matches.length === 0) {
|
|
return;
|
|
}
|
|
var dom = editor.dom;
|
|
var bookmark = editor.selection.getBookmark();
|
|
var matchesWithMarkers = addMarkers(dom, matches);
|
|
each(matchesWithMarkers, function (match) {
|
|
var block = dom.getParent(match.startMarker.start, dom.isBlock);
|
|
var isRoot = function (node) {
|
|
return node === block;
|
|
};
|
|
if (isReplacementPattern(match.pattern)) {
|
|
applyReplacementPattern(editor, match.pattern, match.endMarker, isRoot);
|
|
} else {
|
|
applyPatternWithContent(editor, match.pattern, match.startMarker, match.endMarker, isRoot);
|
|
}
|
|
removeMarker(dom, match.endMarker, isRoot);
|
|
removeMarker(dom, match.startMarker, isRoot);
|
|
});
|
|
editor.selection.moveToBookmark(bookmark);
|
|
};
|
|
|
|
var handleEnter = function (editor, patternSet) {
|
|
if (!editor.selection.isCollapsed()) {
|
|
return false;
|
|
}
|
|
var inlineMatches = findPatterns(editor, patternSet.inlinePatterns, false);
|
|
var blockMatches = findPatterns$1(editor, patternSet.blockPatterns);
|
|
if (blockMatches.length > 0 || inlineMatches.length > 0) {
|
|
editor.undoManager.add();
|
|
editor.undoManager.extra(function () {
|
|
editor.execCommand('mceInsertNewLine');
|
|
}, function () {
|
|
editor.insertContent(zeroWidth);
|
|
applyMatches(editor, inlineMatches);
|
|
applyMatches$1(editor, blockMatches);
|
|
var range = editor.selection.getRng();
|
|
var spot = textBefore(range.startContainer, range.startOffset, editor.dom.getRoot());
|
|
editor.execCommand('mceInsertNewLine');
|
|
spot.each(function (s) {
|
|
var node = s.container;
|
|
if (node.data.charAt(s.offset - 1) === zeroWidth) {
|
|
node.deleteData(s.offset - 1, 1);
|
|
cleanEmptyNodes(editor.dom, node.parentNode, function (e) {
|
|
return e === editor.dom.getRoot();
|
|
});
|
|
}
|
|
});
|
|
});
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
var handleInlineKey = function (editor, patternSet) {
|
|
var inlineMatches = findPatterns(editor, patternSet.inlinePatterns, true);
|
|
if (inlineMatches.length > 0) {
|
|
editor.undoManager.transact(function () {
|
|
applyMatches(editor, inlineMatches);
|
|
});
|
|
}
|
|
};
|
|
var checkKeyEvent = function (codes, event, predicate) {
|
|
for (var i = 0; i < codes.length; i++) {
|
|
if (predicate(codes[i], event)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var checkKeyCode = function (codes, event) {
|
|
return checkKeyEvent(codes, event, function (code, event) {
|
|
return code === event.keyCode && global$3.modifierPressed(event) === false;
|
|
});
|
|
};
|
|
var checkCharCode = function (chars, event) {
|
|
return checkKeyEvent(chars, event, function (chr, event) {
|
|
return chr.charCodeAt(0) === event.charCode;
|
|
});
|
|
};
|
|
|
|
var setup = function (editor, patternsState) {
|
|
var charCodes = [
|
|
',',
|
|
'.',
|
|
';',
|
|
':',
|
|
'!',
|
|
'?'
|
|
];
|
|
var keyCodes = [32];
|
|
editor.on('keydown', function (e) {
|
|
if (e.keyCode === 13 && !global$3.modifierPressed(e)) {
|
|
if (handleEnter(editor, patternsState.get())) {
|
|
e.preventDefault();
|
|
}
|
|
}
|
|
}, true);
|
|
editor.on('keyup', function (e) {
|
|
if (checkKeyCode(keyCodes, e)) {
|
|
handleInlineKey(editor, patternsState.get());
|
|
}
|
|
});
|
|
editor.on('keypress', function (e) {
|
|
if (checkCharCode(charCodes, e)) {
|
|
global$4.setEditorTimeout(editor, function () {
|
|
handleInlineKey(editor, patternsState.get());
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$5.add('textpattern', function (editor) {
|
|
var patternsState = Cell(getPatternSet(editor));
|
|
setup(editor, patternsState);
|
|
return get(patternsState);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var get$2 = function (toggleState) {
|
|
var isEnabled = function () {
|
|
return toggleState.get();
|
|
};
|
|
return { isEnabled: isEnabled };
|
|
};
|
|
|
|
var fireVisualChars = function (editor, state) {
|
|
return editor.fire('VisualChars', { state: state });
|
|
};
|
|
|
|
var typeOf = function (x) {
|
|
var t = typeof x;
|
|
if (x === null) {
|
|
return 'null';
|
|
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
|
|
return 'array';
|
|
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
|
|
return 'string';
|
|
} else {
|
|
return t;
|
|
}
|
|
};
|
|
var isType$1 = function (type) {
|
|
return function (value) {
|
|
return typeOf(value) === type;
|
|
};
|
|
};
|
|
var isSimpleType = function (type) {
|
|
return function (value) {
|
|
return typeof value === type;
|
|
};
|
|
};
|
|
var isString = isType$1('string');
|
|
var isBoolean = isSimpleType('boolean');
|
|
var isNumber = isSimpleType('number');
|
|
|
|
var noop = function () {
|
|
};
|
|
var constant = function (value) {
|
|
return function () {
|
|
return value;
|
|
};
|
|
};
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
var never = constant(false);
|
|
var always = constant(true);
|
|
|
|
var none = function () {
|
|
return NONE;
|
|
};
|
|
var NONE = function () {
|
|
var call = function (thunk) {
|
|
return thunk();
|
|
};
|
|
var id = identity;
|
|
var me = {
|
|
fold: function (n, _s) {
|
|
return n();
|
|
},
|
|
isSome: never,
|
|
isNone: always,
|
|
getOr: id,
|
|
getOrThunk: call,
|
|
getOrDie: function (msg) {
|
|
throw new Error(msg || 'error: getOrDie called on none.');
|
|
},
|
|
getOrNull: constant(null),
|
|
getOrUndefined: constant(undefined),
|
|
or: id,
|
|
orThunk: call,
|
|
map: none,
|
|
each: noop,
|
|
bind: none,
|
|
exists: never,
|
|
forall: always,
|
|
filter: function () {
|
|
return none();
|
|
},
|
|
toArray: function () {
|
|
return [];
|
|
},
|
|
toString: constant('none()')
|
|
};
|
|
return me;
|
|
}();
|
|
var some = function (a) {
|
|
var constant_a = constant(a);
|
|
var self = function () {
|
|
return me;
|
|
};
|
|
var bind = function (f) {
|
|
return f(a);
|
|
};
|
|
var me = {
|
|
fold: function (n, s) {
|
|
return s(a);
|
|
},
|
|
isSome: always,
|
|
isNone: never,
|
|
getOr: constant_a,
|
|
getOrThunk: constant_a,
|
|
getOrDie: constant_a,
|
|
getOrNull: constant_a,
|
|
getOrUndefined: constant_a,
|
|
or: self,
|
|
orThunk: self,
|
|
map: function (f) {
|
|
return some(f(a));
|
|
},
|
|
each: function (f) {
|
|
f(a);
|
|
},
|
|
bind: bind,
|
|
exists: bind,
|
|
forall: bind,
|
|
filter: function (f) {
|
|
return f(a) ? me : NONE;
|
|
},
|
|
toArray: function () {
|
|
return [a];
|
|
},
|
|
toString: function () {
|
|
return 'some(' + a + ')';
|
|
}
|
|
};
|
|
return me;
|
|
};
|
|
var from = function (value) {
|
|
return value === null || value === undefined ? NONE : some(value);
|
|
};
|
|
var Optional = {
|
|
some: some,
|
|
none: none,
|
|
from: from
|
|
};
|
|
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
var each$1 = function (xs, f) {
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
var filter = function (xs, pred) {
|
|
var r = [];
|
|
for (var i = 0, len = xs.length; i < len; i++) {
|
|
var x = xs[i];
|
|
if (pred(x, i)) {
|
|
r.push(x);
|
|
}
|
|
}
|
|
return r;
|
|
};
|
|
|
|
var keys = Object.keys;
|
|
var each = function (obj, f) {
|
|
var props = keys(obj);
|
|
for (var k = 0, len = props.length; k < len; k++) {
|
|
var i = props[k];
|
|
var x = obj[i];
|
|
f(x, i);
|
|
}
|
|
};
|
|
|
|
typeof window !== 'undefined' ? window : Function('return this;')();
|
|
|
|
var TEXT = 3;
|
|
|
|
var type = function (element) {
|
|
return element.dom.nodeType;
|
|
};
|
|
var value = function (element) {
|
|
return element.dom.nodeValue;
|
|
};
|
|
var isType = function (t) {
|
|
return function (element) {
|
|
return type(element) === t;
|
|
};
|
|
};
|
|
var isText = isType(TEXT);
|
|
|
|
var rawSet = function (dom, key, value) {
|
|
if (isString(value) || isBoolean(value) || isNumber(value)) {
|
|
dom.setAttribute(key, value + '');
|
|
} else {
|
|
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
|
|
throw new Error('Attribute value was not simple');
|
|
}
|
|
};
|
|
var set = function (element, key, value) {
|
|
rawSet(element.dom, key, value);
|
|
};
|
|
var get$1 = function (element, key) {
|
|
var v = element.dom.getAttribute(key);
|
|
return v === null ? undefined : v;
|
|
};
|
|
var remove$3 = function (element, key) {
|
|
element.dom.removeAttribute(key);
|
|
};
|
|
|
|
var read = function (element, attr) {
|
|
var value = get$1(element, attr);
|
|
return value === undefined || value === '' ? [] : value.split(' ');
|
|
};
|
|
var add$2 = function (element, attr, id) {
|
|
var old = read(element, attr);
|
|
var nu = old.concat([id]);
|
|
set(element, attr, nu.join(' '));
|
|
return true;
|
|
};
|
|
var remove$2 = function (element, attr, id) {
|
|
var nu = filter(read(element, attr), function (v) {
|
|
return v !== id;
|
|
});
|
|
if (nu.length > 0) {
|
|
set(element, attr, nu.join(' '));
|
|
} else {
|
|
remove$3(element, attr);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
var supports = function (element) {
|
|
return element.dom.classList !== undefined;
|
|
};
|
|
var get = function (element) {
|
|
return read(element, 'class');
|
|
};
|
|
var add$1 = function (element, clazz) {
|
|
return add$2(element, 'class', clazz);
|
|
};
|
|
var remove$1 = function (element, clazz) {
|
|
return remove$2(element, 'class', clazz);
|
|
};
|
|
|
|
var add = function (element, clazz) {
|
|
if (supports(element)) {
|
|
element.dom.classList.add(clazz);
|
|
} else {
|
|
add$1(element, clazz);
|
|
}
|
|
};
|
|
var cleanClass = function (element) {
|
|
var classList = supports(element) ? element.dom.classList : get(element);
|
|
if (classList.length === 0) {
|
|
remove$3(element, 'class');
|
|
}
|
|
};
|
|
var remove = function (element, clazz) {
|
|
if (supports(element)) {
|
|
var classList = element.dom.classList;
|
|
classList.remove(clazz);
|
|
} else {
|
|
remove$1(element, clazz);
|
|
}
|
|
cleanClass(element);
|
|
};
|
|
|
|
var fromHtml = function (html, scope) {
|
|
var doc = scope || document;
|
|
var div = doc.createElement('div');
|
|
div.innerHTML = html;
|
|
if (!div.hasChildNodes() || div.childNodes.length > 1) {
|
|
console.error('HTML does not have a single root node', html);
|
|
throw new Error('HTML must have a single root node');
|
|
}
|
|
return fromDom(div.childNodes[0]);
|
|
};
|
|
var fromTag = function (tag, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createElement(tag);
|
|
return fromDom(node);
|
|
};
|
|
var fromText = function (text, scope) {
|
|
var doc = scope || document;
|
|
var node = doc.createTextNode(text);
|
|
return fromDom(node);
|
|
};
|
|
var fromDom = function (node) {
|
|
if (node === null || node === undefined) {
|
|
throw new Error('Node cannot be null or undefined');
|
|
}
|
|
return { dom: node };
|
|
};
|
|
var fromPoint = function (docElm, x, y) {
|
|
return Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
|
|
};
|
|
var SugarElement = {
|
|
fromHtml: fromHtml,
|
|
fromTag: fromTag,
|
|
fromText: fromText,
|
|
fromDom: fromDom,
|
|
fromPoint: fromPoint
|
|
};
|
|
|
|
var charMap = {
|
|
'\xA0': 'nbsp',
|
|
'\xAD': 'shy'
|
|
};
|
|
var charMapToRegExp = function (charMap, global) {
|
|
var regExp = '';
|
|
each(charMap, function (_value, key) {
|
|
regExp += key;
|
|
});
|
|
return new RegExp('[' + regExp + ']', global ? 'g' : '');
|
|
};
|
|
var charMapToSelector = function (charMap) {
|
|
var selector = '';
|
|
each(charMap, function (value) {
|
|
if (selector) {
|
|
selector += ',';
|
|
}
|
|
selector += 'span.mce-' + value;
|
|
});
|
|
return selector;
|
|
};
|
|
var regExp = charMapToRegExp(charMap);
|
|
var regExpGlobal = charMapToRegExp(charMap, true);
|
|
var selector = charMapToSelector(charMap);
|
|
var nbspClass = 'mce-nbsp';
|
|
|
|
var wrapCharWithSpan = function (value) {
|
|
return '<span data-mce-bogus="1" class="mce-' + charMap[value] + '">' + value + '</span>';
|
|
};
|
|
|
|
var isMatch = function (n) {
|
|
var value$1 = value(n);
|
|
return isText(n) && value$1 !== undefined && regExp.test(value$1);
|
|
};
|
|
var filterDescendants = function (scope, predicate) {
|
|
var result = [];
|
|
var dom = scope.dom;
|
|
var children = map(dom.childNodes, SugarElement.fromDom);
|
|
each$1(children, function (x) {
|
|
if (predicate(x)) {
|
|
result = result.concat([x]);
|
|
}
|
|
result = result.concat(filterDescendants(x, predicate));
|
|
});
|
|
return result;
|
|
};
|
|
var findParentElm = function (elm, rootElm) {
|
|
while (elm.parentNode) {
|
|
if (elm.parentNode === rootElm) {
|
|
return elm;
|
|
}
|
|
elm = elm.parentNode;
|
|
}
|
|
};
|
|
var replaceWithSpans = function (text) {
|
|
return text.replace(regExpGlobal, wrapCharWithSpan);
|
|
};
|
|
|
|
var isWrappedNbsp = function (node) {
|
|
return node.nodeName.toLowerCase() === 'span' && node.classList.contains('mce-nbsp-wrap');
|
|
};
|
|
var show = function (editor, rootElm) {
|
|
var nodeList = filterDescendants(SugarElement.fromDom(rootElm), isMatch);
|
|
each$1(nodeList, function (n) {
|
|
var parent = n.dom.parentNode;
|
|
if (isWrappedNbsp(parent)) {
|
|
add(SugarElement.fromDom(parent), nbspClass);
|
|
} else {
|
|
var withSpans = replaceWithSpans(editor.dom.encode(value(n)));
|
|
var div = editor.dom.create('div', null, withSpans);
|
|
var node = void 0;
|
|
while (node = div.lastChild) {
|
|
editor.dom.insertAfter(node, n.dom);
|
|
}
|
|
editor.dom.remove(n.dom);
|
|
}
|
|
});
|
|
};
|
|
var hide = function (editor, rootElm) {
|
|
var nodeList = editor.dom.select(selector, rootElm);
|
|
each$1(nodeList, function (node) {
|
|
if (isWrappedNbsp(node)) {
|
|
remove(SugarElement.fromDom(node), nbspClass);
|
|
} else {
|
|
editor.dom.remove(node, true);
|
|
}
|
|
});
|
|
};
|
|
var toggle = function (editor) {
|
|
var body = editor.getBody();
|
|
var bookmark = editor.selection.getBookmark();
|
|
var parentNode = findParentElm(editor.selection.getNode(), body);
|
|
parentNode = parentNode !== undefined ? parentNode : body;
|
|
hide(editor, parentNode);
|
|
show(editor, parentNode);
|
|
editor.selection.moveToBookmark(bookmark);
|
|
};
|
|
|
|
var applyVisualChars = function (editor, toggleState) {
|
|
fireVisualChars(editor, toggleState.get());
|
|
var body = editor.getBody();
|
|
if (toggleState.get() === true) {
|
|
show(editor, body);
|
|
} else {
|
|
hide(editor, body);
|
|
}
|
|
};
|
|
var toggleVisualChars = function (editor, toggleState) {
|
|
toggleState.set(!toggleState.get());
|
|
var bookmark = editor.selection.getBookmark();
|
|
applyVisualChars(editor, toggleState);
|
|
editor.selection.moveToBookmark(bookmark);
|
|
};
|
|
|
|
var register$1 = function (editor, toggleState) {
|
|
editor.addCommand('mceVisualChars', function () {
|
|
toggleVisualChars(editor, toggleState);
|
|
});
|
|
};
|
|
|
|
var isEnabledByDefault = function (editor) {
|
|
return editor.getParam('visualchars_default_state', false);
|
|
};
|
|
var hasForcedRootBlock = function (editor) {
|
|
return editor.getParam('forced_root_block') !== false;
|
|
};
|
|
|
|
var setup$1 = function (editor, toggleState) {
|
|
editor.on('init', function () {
|
|
applyVisualChars(editor, toggleState);
|
|
});
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var setup = function (editor, toggleState) {
|
|
var debouncedToggle = global.debounce(function () {
|
|
toggle(editor);
|
|
}, 300);
|
|
if (hasForcedRootBlock(editor)) {
|
|
editor.on('keydown', function (e) {
|
|
if (toggleState.get() === true) {
|
|
e.keyCode === 13 ? toggle(editor) : debouncedToggle();
|
|
}
|
|
});
|
|
}
|
|
editor.on('remove', debouncedToggle.stop);
|
|
};
|
|
|
|
var toggleActiveState = function (editor, enabledStated) {
|
|
return function (api) {
|
|
api.setActive(enabledStated.get());
|
|
var editorEventCallback = function (e) {
|
|
return api.setActive(e.state);
|
|
};
|
|
editor.on('VisualChars', editorEventCallback);
|
|
return function () {
|
|
return editor.off('VisualChars', editorEventCallback);
|
|
};
|
|
};
|
|
};
|
|
var register = function (editor, toggleState) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceVisualChars');
|
|
};
|
|
editor.ui.registry.addToggleButton('visualchars', {
|
|
tooltip: 'Show invisible characters',
|
|
icon: 'visualchars',
|
|
onAction: onAction,
|
|
onSetup: toggleActiveState(editor, toggleState)
|
|
});
|
|
editor.ui.registry.addToggleMenuItem('visualchars', {
|
|
text: 'Show invisible characters',
|
|
icon: 'visualchars',
|
|
onAction: onAction,
|
|
onSetup: toggleActiveState(editor, toggleState)
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global$1.add('visualchars', function (editor) {
|
|
var toggleState = Cell(isEnabledByDefault(editor));
|
|
register$1(editor, toggleState);
|
|
register(editor, toggleState);
|
|
setup(editor, toggleState);
|
|
setup$1(editor, toggleState);
|
|
return get$2(toggleState);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var Cell = function (initial) {
|
|
var value = initial;
|
|
var get = function () {
|
|
return value;
|
|
};
|
|
var set = function (v) {
|
|
value = v;
|
|
};
|
|
return {
|
|
get: get,
|
|
set: set
|
|
};
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var fireVisualBlocks = function (editor, state) {
|
|
editor.fire('VisualBlocks', { state: state });
|
|
};
|
|
|
|
var toggleVisualBlocks = function (editor, pluginUrl, enabledState) {
|
|
var dom = editor.dom;
|
|
dom.toggleClass(editor.getBody(), 'mce-visualblocks');
|
|
enabledState.set(!enabledState.get());
|
|
fireVisualBlocks(editor, enabledState.get());
|
|
};
|
|
|
|
var register$1 = function (editor, pluginUrl, enabledState) {
|
|
editor.addCommand('mceVisualBlocks', function () {
|
|
toggleVisualBlocks(editor, pluginUrl, enabledState);
|
|
});
|
|
};
|
|
|
|
var isEnabledByDefault = function (editor) {
|
|
return editor.getParam('visualblocks_default_state', false, 'boolean');
|
|
};
|
|
|
|
var setup = function (editor, pluginUrl, enabledState) {
|
|
editor.on('PreviewFormats AfterPreviewFormats', function (e) {
|
|
if (enabledState.get()) {
|
|
editor.dom.toggleClass(editor.getBody(), 'mce-visualblocks', e.type === 'afterpreviewformats');
|
|
}
|
|
});
|
|
editor.on('init', function () {
|
|
if (isEnabledByDefault(editor)) {
|
|
toggleVisualBlocks(editor, pluginUrl, enabledState);
|
|
}
|
|
});
|
|
};
|
|
|
|
var toggleActiveState = function (editor, enabledState) {
|
|
return function (api) {
|
|
api.setActive(enabledState.get());
|
|
var editorEventCallback = function (e) {
|
|
return api.setActive(e.state);
|
|
};
|
|
editor.on('VisualBlocks', editorEventCallback);
|
|
return function () {
|
|
return editor.off('VisualBlocks', editorEventCallback);
|
|
};
|
|
};
|
|
};
|
|
var register = function (editor, enabledState) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceVisualBlocks');
|
|
};
|
|
editor.ui.registry.addToggleButton('visualblocks', {
|
|
icon: 'visualblocks',
|
|
tooltip: 'Show blocks',
|
|
onAction: onAction,
|
|
onSetup: toggleActiveState(editor, enabledState)
|
|
});
|
|
editor.ui.registry.addToggleMenuItem('visualblocks', {
|
|
text: 'Show blocks',
|
|
icon: 'visualblocks',
|
|
onAction: onAction,
|
|
onSetup: toggleActiveState(editor, enabledState)
|
|
});
|
|
};
|
|
|
|
function Plugin () {
|
|
global.add('visualblocks', function (editor, pluginUrl) {
|
|
var enabledState = Cell(false);
|
|
register$1(editor, pluginUrl, enabledState);
|
|
register(editor, enabledState);
|
|
setup(editor, pluginUrl, enabledState);
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|
|
|
|
/**
|
|
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
|
|
* Licensed under the LGPL or a commercial license.
|
|
* For LGPL see License.txt in the project root for license information.
|
|
* For commercial licenses see https://www.tiny.cloud/
|
|
*
|
|
* Version: 5.10.6 (2022-10-19)
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
var global$2 = tinymce.util.Tools.resolve('tinymce.PluginManager');
|
|
|
|
var identity = function (x) {
|
|
return x;
|
|
};
|
|
|
|
var __assign = function () {
|
|
__assign = Object.assign || function __assign(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s)
|
|
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
|
|
var zeroWidth = '\uFEFF';
|
|
var removeZwsp$1 = function (s) {
|
|
return s.replace(/\uFEFF/g, '');
|
|
};
|
|
|
|
var map = function (xs, f) {
|
|
var len = xs.length;
|
|
var r = new Array(len);
|
|
for (var i = 0; i < len; i++) {
|
|
var x = xs[i];
|
|
r[i] = f(x, i);
|
|
}
|
|
return r;
|
|
};
|
|
|
|
var punctuationStr = '[!-#%-*,-\\/:;?@\\[-\\]_{}\xA1\xAB\xB7\xBB\xBF;\xB7\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1361-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u3008\u3009\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30\u2E31\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uff3f\uFF5B\uFF5D\uFF5F-\uFF65]';
|
|
var regExps = {
|
|
aletter: '[A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05F3\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bc0-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u24B6-\u24E9\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005\u303b\u303c\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790\ua791\ua7a0-\ua7a9\ua7fa-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uffa0-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]',
|
|
midnumlet: '[-\'\\.\u2018\u2019\u2024\uFE52\uFF07\uFF0E]',
|
|
midletter: '[:\xB7\xB7\u05F4\u2027\uFE13\uFE55\uFF1A]',
|
|
midnum: '[\xB1+*/,;;\u0589\u060C\u060D\u066C\u07F8\u2044\uFE10\uFE14\uFE50\uFE54\uFF0C\uFF1B]',
|
|
numeric: '[0-9\u0660-\u0669\u066B\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\uaa50-\uaa59\uabf0-\uabf9]',
|
|
cr: '\\r',
|
|
lf: '\\n',
|
|
newline: '[\x0B\f\x85\u2028\u2029]',
|
|
extend: '[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065f\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u0900-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0c01-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c82\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d02\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f\u109a-\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b6-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u192b\u1930-\u193b\u19b0-\u19c0\u19c8\u19c9\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f\u1b00-\u1b04\u1b34-\u1b44\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1baa\u1be6-\u1bf3\u1c24-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2\u1dc0-\u1de6\u1dfc-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\uA672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa7b\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe3-\uabea\uabec\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]',
|
|
format: '[\xAD\u0600-\u0603\u06DD\u070F\u17b4\u17b5\u200E\u200F\u202A-\u202E\u2060-\u2064\u206A-\u206F\uFEFF\uFFF9-\uFFFB]',
|
|
katakana: '[\u3031-\u3035\u309B\u309C\u30A0-\u30fa\u30fc-\u30ff\u31f0-\u31ff\u32D0-\u32FE\u3300-\u3357\uff66-\uff9d]',
|
|
extendnumlet: '[=_\u203f\u2040\u2054\ufe33\ufe34\ufe4d-\ufe4f\uff3f\u2200-\u22FF<>]',
|
|
punctuation: punctuationStr
|
|
};
|
|
var characterIndices = {
|
|
ALETTER: 0,
|
|
MIDNUMLET: 1,
|
|
MIDLETTER: 2,
|
|
MIDNUM: 3,
|
|
NUMERIC: 4,
|
|
CR: 5,
|
|
LF: 6,
|
|
NEWLINE: 7,
|
|
EXTEND: 8,
|
|
FORMAT: 9,
|
|
KATAKANA: 10,
|
|
EXTENDNUMLET: 11,
|
|
AT: 12,
|
|
OTHER: 13
|
|
};
|
|
var SETS$1 = [
|
|
new RegExp(regExps.aletter),
|
|
new RegExp(regExps.midnumlet),
|
|
new RegExp(regExps.midletter),
|
|
new RegExp(regExps.midnum),
|
|
new RegExp(regExps.numeric),
|
|
new RegExp(regExps.cr),
|
|
new RegExp(regExps.lf),
|
|
new RegExp(regExps.newline),
|
|
new RegExp(regExps.extend),
|
|
new RegExp(regExps.format),
|
|
new RegExp(regExps.katakana),
|
|
new RegExp(regExps.extendnumlet),
|
|
new RegExp('@')
|
|
];
|
|
var EMPTY_STRING$1 = '';
|
|
var PUNCTUATION$1 = new RegExp('^' + regExps.punctuation + '$');
|
|
var WHITESPACE$1 = /^\s+$/;
|
|
|
|
var SETS = SETS$1;
|
|
var OTHER = characterIndices.OTHER;
|
|
var getType = function (char) {
|
|
var type = OTHER;
|
|
var setsLength = SETS.length;
|
|
for (var j = 0; j < setsLength; ++j) {
|
|
var set = SETS[j];
|
|
if (set && set.test(char)) {
|
|
type = j;
|
|
break;
|
|
}
|
|
}
|
|
return type;
|
|
};
|
|
var memoize = function (func) {
|
|
var cache = {};
|
|
return function (char) {
|
|
if (cache[char]) {
|
|
return cache[char];
|
|
} else {
|
|
var result = func(char);
|
|
cache[char] = result;
|
|
return result;
|
|
}
|
|
};
|
|
};
|
|
var classify = function (characters) {
|
|
var memoized = memoize(getType);
|
|
return map(characters, memoized);
|
|
};
|
|
|
|
var isWordBoundary = function (map, index) {
|
|
var type = map[index];
|
|
var nextType = map[index + 1];
|
|
if (index < 0 || index > map.length - 1 && index !== 0) {
|
|
return false;
|
|
}
|
|
if (type === characterIndices.ALETTER && nextType === characterIndices.ALETTER) {
|
|
return false;
|
|
}
|
|
var nextNextType = map[index + 2];
|
|
if (type === characterIndices.ALETTER && (nextType === characterIndices.MIDLETTER || nextType === characterIndices.MIDNUMLET || nextType === characterIndices.AT) && nextNextType === characterIndices.ALETTER) {
|
|
return false;
|
|
}
|
|
var prevType = map[index - 1];
|
|
if ((type === characterIndices.MIDLETTER || type === characterIndices.MIDNUMLET || nextType === characterIndices.AT) && nextType === characterIndices.ALETTER && prevType === characterIndices.ALETTER) {
|
|
return false;
|
|
}
|
|
if ((type === characterIndices.NUMERIC || type === characterIndices.ALETTER) && (nextType === characterIndices.NUMERIC || nextType === characterIndices.ALETTER)) {
|
|
return false;
|
|
}
|
|
if ((type === characterIndices.MIDNUM || type === characterIndices.MIDNUMLET) && nextType === characterIndices.NUMERIC && prevType === characterIndices.NUMERIC) {
|
|
return false;
|
|
}
|
|
if (type === characterIndices.NUMERIC && (nextType === characterIndices.MIDNUM || nextType === characterIndices.MIDNUMLET) && nextNextType === characterIndices.NUMERIC) {
|
|
return false;
|
|
}
|
|
if (type === characterIndices.EXTEND || type === characterIndices.FORMAT || prevType === characterIndices.EXTEND || prevType === characterIndices.FORMAT || nextType === characterIndices.EXTEND || nextType === characterIndices.FORMAT) {
|
|
return false;
|
|
}
|
|
if (type === characterIndices.CR && nextType === characterIndices.LF) {
|
|
return false;
|
|
}
|
|
if (type === characterIndices.NEWLINE || type === characterIndices.CR || type === characterIndices.LF) {
|
|
return true;
|
|
}
|
|
if (nextType === characterIndices.NEWLINE || nextType === characterIndices.CR || nextType === characterIndices.LF) {
|
|
return true;
|
|
}
|
|
if (type === characterIndices.KATAKANA && nextType === characterIndices.KATAKANA) {
|
|
return false;
|
|
}
|
|
if (nextType === characterIndices.EXTENDNUMLET && (type === characterIndices.ALETTER || type === characterIndices.NUMERIC || type === characterIndices.KATAKANA || type === characterIndices.EXTENDNUMLET)) {
|
|
return false;
|
|
}
|
|
if (type === characterIndices.EXTENDNUMLET && (nextType === characterIndices.ALETTER || nextType === characterIndices.NUMERIC || nextType === characterIndices.KATAKANA)) {
|
|
return false;
|
|
}
|
|
if (type === characterIndices.AT) {
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
|
|
var EMPTY_STRING = EMPTY_STRING$1;
|
|
var WHITESPACE = WHITESPACE$1;
|
|
var PUNCTUATION = PUNCTUATION$1;
|
|
var isProtocol = function (str) {
|
|
return str === 'http' || str === 'https';
|
|
};
|
|
var findWordEnd = function (characters, startIndex) {
|
|
var i;
|
|
for (i = startIndex; i < characters.length; i++) {
|
|
if (WHITESPACE.test(characters[i])) {
|
|
break;
|
|
}
|
|
}
|
|
return i;
|
|
};
|
|
var findUrlEnd = function (characters, startIndex) {
|
|
var endIndex = findWordEnd(characters, startIndex + 1);
|
|
var peakedWord = characters.slice(startIndex + 1, endIndex).join(EMPTY_STRING);
|
|
return peakedWord.substr(0, 3) === '://' ? endIndex : startIndex;
|
|
};
|
|
var findWords = function (chars, sChars, characterMap, options) {
|
|
var words = [];
|
|
var word = [];
|
|
for (var i = 0; i < characterMap.length; ++i) {
|
|
word.push(chars[i]);
|
|
if (isWordBoundary(characterMap, i)) {
|
|
var ch = sChars[i];
|
|
if ((options.includeWhitespace || !WHITESPACE.test(ch)) && (options.includePunctuation || !PUNCTUATION.test(ch))) {
|
|
var startOfWord = i - word.length + 1;
|
|
var endOfWord = i + 1;
|
|
var str = sChars.slice(startOfWord, endOfWord).join(EMPTY_STRING);
|
|
if (isProtocol(str)) {
|
|
var endOfUrl = findUrlEnd(sChars, i);
|
|
var url = chars.slice(endOfWord, endOfUrl);
|
|
Array.prototype.push.apply(word, url);
|
|
i = endOfUrl;
|
|
}
|
|
words.push(word);
|
|
}
|
|
word = [];
|
|
}
|
|
}
|
|
return words;
|
|
};
|
|
var getDefaultOptions = function () {
|
|
return {
|
|
includeWhitespace: false,
|
|
includePunctuation: false
|
|
};
|
|
};
|
|
var getWords$1 = function (chars, extract, options) {
|
|
options = __assign(__assign({}, getDefaultOptions()), options);
|
|
var filteredChars = [];
|
|
var extractedChars = [];
|
|
for (var i = 0; i < chars.length; i++) {
|
|
var ch = extract(chars[i]);
|
|
if (ch !== zeroWidth) {
|
|
filteredChars.push(chars[i]);
|
|
extractedChars.push(ch);
|
|
}
|
|
}
|
|
var characterMap = classify(extractedChars);
|
|
return findWords(filteredChars, extractedChars, characterMap, options);
|
|
};
|
|
|
|
var getWords = getWords$1;
|
|
|
|
var global$1 = tinymce.util.Tools.resolve('tinymce.dom.TreeWalker');
|
|
|
|
var getText = function (node, schema) {
|
|
var blockElements = schema.getBlockElements();
|
|
var shortEndedElements = schema.getShortEndedElements();
|
|
var isNewline = function (node) {
|
|
return blockElements[node.nodeName] || shortEndedElements[node.nodeName];
|
|
};
|
|
var textBlocks = [];
|
|
var txt = '';
|
|
var treeWalker = new global$1(node, node);
|
|
while (node = treeWalker.next()) {
|
|
if (node.nodeType === 3) {
|
|
txt += removeZwsp$1(node.data);
|
|
} else if (isNewline(node) && txt.length) {
|
|
textBlocks.push(txt);
|
|
txt = '';
|
|
}
|
|
}
|
|
if (txt.length) {
|
|
textBlocks.push(txt);
|
|
}
|
|
return textBlocks;
|
|
};
|
|
|
|
var removeZwsp = function (text) {
|
|
return text.replace(/\u200B/g, '');
|
|
};
|
|
var strLen = function (str) {
|
|
return str.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, '_').length;
|
|
};
|
|
var countWords = function (node, schema) {
|
|
var text = removeZwsp(getText(node, schema).join('\n'));
|
|
return getWords(text.split(''), identity).length;
|
|
};
|
|
var countCharacters = function (node, schema) {
|
|
var text = getText(node, schema).join('');
|
|
return strLen(text);
|
|
};
|
|
var countCharactersWithoutSpaces = function (node, schema) {
|
|
var text = getText(node, schema).join('').replace(/\s/g, '');
|
|
return strLen(text);
|
|
};
|
|
|
|
var createBodyCounter = function (editor, count) {
|
|
return function () {
|
|
return count(editor.getBody(), editor.schema);
|
|
};
|
|
};
|
|
var createSelectionCounter = function (editor, count) {
|
|
return function () {
|
|
return count(editor.selection.getRng().cloneContents(), editor.schema);
|
|
};
|
|
};
|
|
var createBodyWordCounter = function (editor) {
|
|
return createBodyCounter(editor, countWords);
|
|
};
|
|
var get = function (editor) {
|
|
return {
|
|
body: {
|
|
getWordCount: createBodyWordCounter(editor),
|
|
getCharacterCount: createBodyCounter(editor, countCharacters),
|
|
getCharacterCountWithoutSpaces: createBodyCounter(editor, countCharactersWithoutSpaces)
|
|
},
|
|
selection: {
|
|
getWordCount: createSelectionCounter(editor, countWords),
|
|
getCharacterCount: createSelectionCounter(editor, countCharacters),
|
|
getCharacterCountWithoutSpaces: createSelectionCounter(editor, countCharactersWithoutSpaces)
|
|
},
|
|
getCount: createBodyWordCounter(editor)
|
|
};
|
|
};
|
|
|
|
var open = function (editor, api) {
|
|
editor.windowManager.open({
|
|
title: 'Word Count',
|
|
body: {
|
|
type: 'panel',
|
|
items: [{
|
|
type: 'table',
|
|
header: [
|
|
'Count',
|
|
'Document',
|
|
'Selection'
|
|
],
|
|
cells: [
|
|
[
|
|
'Words',
|
|
String(api.body.getWordCount()),
|
|
String(api.selection.getWordCount())
|
|
],
|
|
[
|
|
'Characters (no spaces)',
|
|
String(api.body.getCharacterCountWithoutSpaces()),
|
|
String(api.selection.getCharacterCountWithoutSpaces())
|
|
],
|
|
[
|
|
'Characters',
|
|
String(api.body.getCharacterCount()),
|
|
String(api.selection.getCharacterCount())
|
|
]
|
|
]
|
|
}]
|
|
},
|
|
buttons: [{
|
|
type: 'cancel',
|
|
name: 'close',
|
|
text: 'Close',
|
|
primary: true
|
|
}]
|
|
});
|
|
};
|
|
|
|
var register$1 = function (editor, api) {
|
|
editor.addCommand('mceWordCount', function () {
|
|
return open(editor, api);
|
|
});
|
|
};
|
|
|
|
var global = tinymce.util.Tools.resolve('tinymce.util.Delay');
|
|
|
|
var fireWordCountUpdate = function (editor, api) {
|
|
editor.fire('wordCountUpdate', {
|
|
wordCount: {
|
|
words: api.body.getWordCount(),
|
|
characters: api.body.getCharacterCount(),
|
|
charactersWithoutSpaces: api.body.getCharacterCountWithoutSpaces()
|
|
}
|
|
});
|
|
};
|
|
|
|
var updateCount = function (editor, api) {
|
|
fireWordCountUpdate(editor, api);
|
|
};
|
|
var setup = function (editor, api, delay) {
|
|
var debouncedUpdate = global.debounce(function () {
|
|
return updateCount(editor, api);
|
|
}, delay);
|
|
editor.on('init', function () {
|
|
updateCount(editor, api);
|
|
global.setEditorTimeout(editor, function () {
|
|
editor.on('SetContent BeforeAddUndo Undo Redo ViewUpdate keyup', debouncedUpdate);
|
|
}, 0);
|
|
});
|
|
};
|
|
|
|
var register = function (editor) {
|
|
var onAction = function () {
|
|
return editor.execCommand('mceWordCount');
|
|
};
|
|
editor.ui.registry.addButton('wordcount', {
|
|
tooltip: 'Word count',
|
|
icon: 'character-count',
|
|
onAction: onAction
|
|
});
|
|
editor.ui.registry.addMenuItem('wordcount', {
|
|
text: 'Word count',
|
|
icon: 'character-count',
|
|
onAction: onAction
|
|
});
|
|
};
|
|
|
|
function Plugin (delay) {
|
|
if (delay === void 0) {
|
|
delay = 300;
|
|
}
|
|
global$2.add('wordcount', function (editor) {
|
|
var api = get(editor);
|
|
register$1(editor, api);
|
|
register(editor);
|
|
setup(editor, api, delay);
|
|
return api;
|
|
});
|
|
}
|
|
|
|
Plugin();
|
|
|
|
}());
|