11 lines
11 KiB
JavaScript
11 lines
11 KiB
JavaScript
/**
|
|
* 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.0.12 (2019-07-18)
|
|
*/
|
|
|
|
!function(t){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=0,n=function(e,n,r){var t,o,i;e.plugins.table?e.plugins.table.insertTable(n,r):(o=n,i=r,(t=e).undoManager.transact(function(){var e,n;t.insertContent(function(e,n){var r,t,o;for(o='<table data-mce-id="mce" style="width: 100%">',o+="<tbody>",t=0;t<n;t++){for(o+="<tr>",r=0;r<e;r++)o+="<td><br></td>";o+="</tr>"}return o+="</tbody>",o+="</table>"}(o,i)),(e=t.dom.select("*[data-mce-id]")[0]).removeAttribute("data-mce-id"),n=t.dom.select("td,th",e),t.selection.setCursorLocation(n[0],0)}))},o=function(e,n,r){var t,o,i,u;o=(t=e.editorUpload.blobCache).create((i="mceu",u=(new Date).getTime(),i+"_"+Math.floor(1e9*Math.random())+ ++a+String(u)),r,n),t.add(o),e.insertContent(e.dom.createHTML("img",{src:o.blobUri()}))},i="undefined"!=typeof t.window?t.window:Function("return this;")(),u=function(e,n){return function(e,n){for(var r=n!==undefined&&null!==n?n:i,t=0;t<e.length&&r!==undefined&&null!==r;++t)r=r[e[t]];return r}(e.split("."),n)},s=function(e,n){var r=u(e,n);if(r===undefined||null===r)throw new Error(e+" not available on this browser");return r};var r,c,f,d,l=tinymce.util.Tools.resolve("tinymce.util.Promise"),m=function(t){return new l(function(e){var n=function r(){return new(s("FileReader"))}();n.onloadend=function(){e(n.result.split(",")[1])},n.readAsDataURL(t)})},g=function(){return new l(function(n){var e;(e=t.document.createElement("input")).type="file",e.style.position="fixed",e.style.left=0,e.style.top=0,e.style.opacity=.001,t.document.body.appendChild(e),e.onchange=function(e){n(Array.prototype.slice.call(e.target.files))},e.click(),e.parentNode.removeChild(e)})},h=function(r){r.ui.registry.addButton("quickimage",{icon:"image",tooltip:"Insert image",onAction:function(){g().then(function(e){var n=e[0];m(n).then(function(e){o(r,e,n)})})}}),r.ui.registry.addButton("quicktable",{icon:"table",tooltip:"Insert table",onAction:function(){n(r,2,2)}})},v=function(e){return function(){return e}},p=v(!1),N=v(!0),O=p,b=N,E=function(){return w},w=(d={fold:function(e,n){return e()},is:O,isSome:O,isNone:b,getOr:f=function(e){return e},getOrThunk:c=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:f,orThunk:c,map:E,ap:E,each:function(){},bind:E,flatten:E,exists:O,forall:b,filter:E,equals:r=function(e){return e.isNone()},equals_:r,toArray:function(){return[]},toString:v("none()")},Object.freeze&&Object.freeze(d),d),T=function(r){var e=function(){return r},n=function(){return o},t=function(e){return e(r)},o={fold:function(e,n){return n(r)},is:function(e){return r===e},isSome:b,isNone:O,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:n,orThunk:n,map:function(e){return T(e(r))},ap:function(e){return e.fold(E,function(e){return T(e(r))})},each:function(e){e(r)},bind:t,flatten:e,exists:t,forall:t,filter:function(e){return e(r)?o:w},equals:function(e){return e.is(r)},equals_:function(e,n){return e.fold(O,function(e){return n(r,e)})},toArray:function(){return[r]},toString:function(){return"some("+r+")"}};return o},S={some:T,none:E,from:function(e){return null===e||e===undefined?w:T(e)}},y=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:v(e)}},x={fromHtml:function(e,n){var r=(n||t.document).createElement("div");if(r.innerHTML=e,!r.hasChildNodes()||1<r.childNodes.length)throw t.console.error("HTML does not have a single root node",e),new Error("HTML must have a single root node");return y(r.childNodes[0])},fromTag:function(e,n){var r=(n||t.document).createElement(e);return y(r)},fromText:function(e,n){var r=(n||t.document).createTextNode(e);return y(r)},fromDom:y,fromPoint:function(e,n,r){var t=e.dom();return S.from(t.elementFromPoint(n,r)).map(y)}},k=(t.Node.ATTRIBUTE_NODE,t.Node.CDATA_SECTION_NODE,t.Node.COMMENT_NODE,t.Node.DOCUMENT_NODE,t.Node.DOCUMENT_TYPE_NODE,t.Node.DOCUMENT_FRAGMENT_NODE,t.Node.ELEMENT_NODE),D=(t.Node.TEXT_NODE,t.Node.PROCESSING_INSTRUCTION_NODE,t.Node.ENTITY_REFERENCE_NODE,t.Node.ENTITY_NODE,t.Node.NOTATION_NODE,function(n){return function(e){return function(e){if(null===e)return"null";var n=typeof e;return"object"===n&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===n&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":n}(e)===n}}),_=D("string"),C=D("object"),A=D("array"),R=D("boolean"),I=D("undefined"),M=D("function"),q=Array.prototype.slice;M(Array.from)&&Array.from;function L(e,n,r,t,o){return e(r,t)?S.some(r):M(o)&&o(r)?S.none():n(r,t,o)}var P,F,U,B,j=function(){return s("Node")},H=function(e,n,r){return 0!=(e.compareDocumentPosition(n)&r)},X=function(e,n){return H(e,n,j().DOCUMENT_POSITION_CONTAINED_BY)},z=function(e,n){var r=function(e,n){for(var r=0;r<e.length;r++){var t=e[r];if(t.test(n))return t}return undefined}(e,n);if(!r)return{major:0,minor:0};var t=function(e){return Number(n.replace(r,"$"+e))};return W(t(1),t(2))},G=function(){return W(0,0)},W=function(e,n){return{major:e,minor:n}},Y={nu:W,detect:function(e,n){var r=String(n).toLowerCase();return 0===e.length?G():z(e,r)},unknown:G},$="Firefox",V=function(e,n){return function(){return n===e}},J=function(e){var n=e.current;return{current:n,version:e.version,isEdge:V("Edge",n),isChrome:V("Chrome",n),isIE:V("IE",n),isOpera:V("Opera",n),isFirefox:V($,n),isSafari:V("Safari",n)}},K={unknown:function(){return J({current:undefined,version:Y.unknown()})},nu:J,edge:v("Edge"),chrome:v("Chrome"),ie:v("IE"),opera:v("Opera"),firefox:v($),safari:v("Safari")},Q="Windows",Z="Android",ee="Solaris",ne="FreeBSD",re=function(e,n){return function(){return n===e}},te=function(e){var n=e.current;return{current:n,version:e.version,isWindows:re(Q,n),isiOS:re("iOS",n),isAndroid:re(Z,n),isOSX:re("OSX",n),isLinux:re("Linux",n),isSolaris:re(ee,n),isFreeBSD:re(ne,n)}},oe={unknown:function(){return te({current:undefined,version:Y.unknown()})},nu:te,windows:v(Q),ios:v("iOS"),android:v(Z),linux:v("Linux"),osx:v("OSX"),solaris:v(ee),freebsd:v(ne)},ie=function(e,n){var r=String(n).toLowerCase();return function(e,n){for(var r=0,t=e.length;r<t;r++){var o=e[r];if(n(o,r,e))return S.some(o)}return S.none()}(e,function(e){return e.search(r)})},ue=function(e,r){return ie(e,r).map(function(e){var n=Y.detect(e.versionRegexes,r);return{current:e.name,version:n}})},ae=function(e,r){return ie(e,r).map(function(e){var n=Y.detect(e.versionRegexes,r);return{current:e.name,version:n}})},se=function(e,n){return-1!==e.indexOf(n)},ce=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,fe=function(n){return function(e){return se(e,n)}},de=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return se(e,"edge/")&&se(e,"chrome")&&se(e,"safari")&&se(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ce],search:function(e){return se(e,"chrome")&&!se(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return se(e,"msie")||se(e,"trident")}},{name:"Opera",versionRegexes:[ce,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:fe("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:fe("firefox")},{name:"Safari",versionRegexes:[ce,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(se(e,"safari")||se(e,"mobile/"))&&se(e,"applewebkit")}}],le=[{name:"Windows",search:fe("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return se(e,"iphone")||se(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:fe("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:fe("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:fe("linux"),versionRegexes:[]},{name:"Solaris",search:fe("sunos"),versionRegexes:[]},{name:"FreeBSD",search:fe("freebsd"),versionRegexes:[]}],me={browsers:v(de),oses:v(le)},ge=function(e){var n,r,t,o,i,u,a,s,c,f,d,l=me.browsers(),m=me.oses(),g=ue(l,e).fold(K.unknown,K.nu),h=ae(m,e).fold(oe.unknown,oe.nu);return{browser:g,os:h,deviceType:(r=g,t=e,o=(n=h).isiOS()&&!0===/ipad/i.test(t),i=n.isiOS()&&!o,u=n.isAndroid()&&3===n.version.major,a=n.isAndroid()&&4===n.version.major,s=o||u||a&&!0===/mobile/i.test(t),c=n.isiOS()||n.isAndroid(),f=c&&!s,d=r.isSafari()&&n.isiOS()&&!1===/safari/i.test(t),{isiPad:v(o),isiPhone:v(i),isTablet:v(s),isPhone:v(f),isTouch:v(c),isAndroid:n.isAndroid,isiOS:n.isiOS,isWebView:v(d)})}},he=(U=!(P=function(){var e=t.navigator.userAgent;return ge(e)}),function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return U||(U=!0,F=P.apply(null,e)),F}),ve=k,pe=function(e,n){var r=e.dom();if(r.nodeType!==ve)return!1;if(r.matches!==undefined)return r.matches(n);if(r.msMatchesSelector!==undefined)return r.msMatchesSelector(n);if(r.webkitMatchesSelector!==undefined)return r.webkitMatchesSelector(n);if(r.mozMatchesSelector!==undefined)return r.mozMatchesSelector(n);throw new Error("Browser lacks native selectors")},Ne=({detect:he}.detect().browser.isIE(),function(e,n,r){for(var t=e.dom(),o=M(r)?r:v(!1);t.parentNode;){t=t.parentNode;var i=x.fromDom(t);if(n(i))return S.some(i);if(o(i))break}return S.none()}),Oe=function(e,n,r){return Ne(e,function(e){return pe(e,n)},r)},be={getToolbarItemsOr:(B=_,function(e,n,r){return function(e,n){if(!n(e))throw new Error("Default value doesn't match requested type.")}(r,B),function(e,n){if(A(e)||C(e))throw new Error("expected a string but found: "+e);return I(e)?n:R(e)?!1===e?"":n:e}(e.getParam(n,r),r)})},Ee=function(e){return be.getToolbarItemsOr(e,"quickbars_selection_toolbar","bold italic | quicklink h2 h3 blockquote")},we=function(e){return be.getToolbarItemsOr(e,"quickbars_insert_toolbar","quickimage quicktable")},Te=function(a){var e=we(a);0<e.trim().length&&a.ui.registry.addContextToolbar("quickblock",{predicate:function(e){var n,r,t,o=x.fromDom(e),i=a.schema.getTextBlockElements(),u=function(e){return e.dom()===a.getBody()};return(n=o,r="table",t=u,L(pe,Oe,n,r,t)).fold(function(){return(e=o,n=function(e){return e.dom().nodeName.toLowerCase()in i&&a.dom.isEmpty(e.dom())},r=u,L(function(e){return n(e)},Ne,e,n,r)).isSome();var e,n,r},function(){return!1})},items:e,position:"line",scope:"editor"})},Se=function(n){n.ui.registry.addContextToolbar("imageselection",{predicate:function(e){return"IMG"===e.nodeName||"FIGURE"===e.nodeName&&/image/i.test(e.className)},items:"alignleft aligncenter alignright",position:"node"});var e=Ee(n);0<e.trim().length&&n.ui.registry.addContextToolbar("textselection",{predicate:function(e){return!n.selection.isCollapsed()},items:e,position:"selection"})};!function ye(){e.add("quickbars",function(e){h(e),Te(e),Se(e)})}()}(window);
|