agenda-libre-ruby/public/assets/tinymce/plugins/quickbars/plugin-73bb91124a46245b64b07a5e95e89c6403e7ba61eb2ccd557ea7bc861d745e0d.js
2019-09-15 14:18:27 +02:00

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.15 (2019-09-02)
*/
!function(t){"use strict";var e,n,r,o,i=tinymce.util.Tools.resolve("tinymce.PluginManager"),a=0,u=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)}))},s=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()}))},c=tinymce.util.Tools.resolve("tinymce.util.Promise"),f=function(r){return new c(function(e){var n=new t.FileReader;n.onloadend=function(){e(n.result.split(",")[1])},n.readAsDataURL(r)})},d=function(){return new c(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)})},l=function(r){r.ui.registry.addButton("quickimage",{icon:"image",tooltip:"Insert image",onAction:function(){d().then(function(e){var n=e[0];f(n).then(function(e){s(r,e,n)})})}}),r.ui.registry.addButton("quicktable",{icon:"table",tooltip:"Insert table",onAction:function(){u(r,2,2)}})},v=function(e){return function(){return e}},m=v(!1),g=v(!0),h=m,p=g,N=function(){return O},O=(o={fold:function(e,n){return e()},is:h,isSome:h,isNone:p,getOr:r=function(e){return e},getOrThunk:n=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:r,orThunk:n,map:N,ap:N,each:function(){},bind:N,flatten:N,exists:h,forall:p,filter:N,equals:e=function(e){return e.isNone()},equals_:e,toArray:function(){return[]},toString:v("none()")},Object.freeze&&Object.freeze(o),o),b=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:p,isNone:h,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:n,orThunk:n,map:function(e){return b(e(r))},ap:function(e){return e.fold(N,function(e){return b(e(r))})},each:function(e){e(r)},bind:t,flatten:e,exists:t,forall:t,filter:function(e){return e(r)?o:O},equals:function(e){return e.is(r)},equals_:function(e,n){return e.fold(h,function(e){return n(r,e)})},toArray:function(){return[r]},toString:function(){return"some("+r+")"}};return o},E={some:b,none:N,from:function(e){return null===e||e===undefined?O:b(e)}},w=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:v(e)}},T={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 w(r.childNodes[0])},fromTag:function(e,n){var r=(n||t.document).createElement(e);return w(r)},fromText:function(e,n){var r=(n||t.document).createTextNode(e);return w(r)},fromDom:w,fromPoint:function(e,n,r){var t=e.dom();return E.from(t.elementFromPoint(n,r)).map(w)}},S=(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),y=(t.Node.TEXT_NODE,t.Node.PROCESSING_INSTRUCTION_NODE,t.Node.ENTITY_REFERENCE_NODE,t.Node.ENTITY_NODE,t.Node.NOTATION_NODE,"undefined"!=typeof t.window?t.window:Function("return this;")(),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}}),x=y("string"),k=y("object"),D=y("array"),_=y("boolean"),C=y("undefined"),A=y("function"),R=Array.prototype.slice;A(Array.from)&&Array.from;function I(e,n,r,t,o){return e(r,t)?E.some(r):A(o)&&o(r)?E.none():n(r,t,o)}var M,q,L,P,F=function(e,n,r){return 0!=(e.compareDocumentPosition(n)&r)},U=function(e,n){return F(e,n,t.Node.DOCUMENT_POSITION_CONTAINED_BY)},B=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 H(t(1),t(2))},j=function(){return H(0,0)},H=function(e,n){return{major:e,minor:n}},X={nu:H,detect:function(e,n){var r=String(n).toLowerCase();return 0===e.length?j():B(e,r)},unknown:j},z="Firefox",G=function(e,n){return function(){return n===e}},W=function(e){var n=e.current;return{current:n,version:e.version,isEdge:G("Edge",n),isChrome:G("Chrome",n),isIE:G("IE",n),isOpera:G("Opera",n),isFirefox:G(z,n),isSafari:G("Safari",n)}},Y={unknown:function(){return W({current:undefined,version:X.unknown()})},nu:W,edge:v("Edge"),chrome:v("Chrome"),ie:v("IE"),opera:v("Opera"),firefox:v(z),safari:v("Safari")},$="Windows",V="Android",J="Solaris",K="FreeBSD",Q=function(e,n){return function(){return n===e}},Z=function(e){var n=e.current;return{current:n,version:e.version,isWindows:Q($,n),isiOS:Q("iOS",n),isAndroid:Q(V,n),isOSX:Q("OSX",n),isLinux:Q("Linux",n),isSolaris:Q(J,n),isFreeBSD:Q(K,n)}},ee={unknown:function(){return Z({current:undefined,version:X.unknown()})},nu:Z,windows:v($),ios:v("iOS"),android:v(V),linux:v("Linux"),osx:v("OSX"),solaris:v(J),freebsd:v(K)},ne=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 E.some(o)}return E.none()}(e,function(e){return e.search(r)})},re=function(e,r){return ne(e,r).map(function(e){var n=X.detect(e.versionRegexes,r);return{current:e.name,version:n}})},te=function(e,r){return ne(e,r).map(function(e){var n=X.detect(e.versionRegexes,r);return{current:e.name,version:n}})},oe=function(e,n){return-1!==e.indexOf(n)},ie=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,ue=function(n){return function(e){return oe(e,n)}},ae=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return oe(e,"edge/")&&oe(e,"chrome")&&oe(e,"safari")&&oe(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ie],search:function(e){return oe(e,"chrome")&&!oe(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return oe(e,"msie")||oe(e,"trident")}},{name:"Opera",versionRegexes:[ie,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:ue("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:ue("firefox")},{name:"Safari",versionRegexes:[ie,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(oe(e,"safari")||oe(e,"mobile/"))&&oe(e,"applewebkit")}}],se=[{name:"Windows",search:ue("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return oe(e,"iphone")||oe(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:ue("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:ue("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:ue("linux"),versionRegexes:[]},{name:"Solaris",search:ue("sunos"),versionRegexes:[]},{name:"FreeBSD",search:ue("freebsd"),versionRegexes:[]}],ce={browsers:v(ae),oses:v(se)},fe=function(e){var n,r,t,o,i,u,a,s,c,f,d,l=ce.browsers(),m=ce.oses(),g=re(l,e).fold(Y.unknown,Y.nu),h=te(m,e).fold(ee.unknown,ee.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)})}},de=(L=!(M=function(){var e=t.navigator.userAgent;return fe(e)}),function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return L||(L=!0,q=M.apply(null,e)),q}),le=S,me=function(e,n){var r=e.dom();if(r.nodeType!==le)return!1;var t=r;if(t.matches!==undefined)return t.matches(n);if(t.msMatchesSelector!==undefined)return t.msMatchesSelector(n);if(t.webkitMatchesSelector!==undefined)return t.webkitMatchesSelector(n);if(t.mozMatchesSelector!==undefined)return t.mozMatchesSelector(n);throw new Error("Browser lacks native selectors")},ge=({detect:de}.detect().browser.isIE(),function(e,n,r){for(var t=e.dom(),o=A(r)?r:v(!1);t.parentNode;){t=t.parentNode;var i=T.fromDom(t);if(n(i))return E.some(i);if(o(i))break}return E.none()}),he=function(e,n,r){return ge(e,function(e){return me(e,n)},r)},ve={getToolbarItemsOr:(P=x,function(e,n,r){return function(e,n){if(!n(e))throw new Error("Default value doesn't match requested type.")}(r,P),function(e,n){if(D(e)||k(e))throw new Error("expected a string but found: "+e);return C(e)?n:_(e)?!1===e?"":n:e}(e.getParam(n,r),r)})},pe=function(e){return ve.getToolbarItemsOr(e,"quickbars_selection_toolbar","bold italic | quicklink h2 h3 blockquote")},Ne=function(e){return ve.getToolbarItemsOr(e,"quickbars_insert_toolbar","quickimage quicktable")},Oe=function(a){var e=Ne(a);0<e.trim().length&&a.ui.registry.addContextToolbar("quickblock",{predicate:function(e){var n,r,t,o=T.fromDom(e),i=a.schema.getTextBlockElements(),u=function(e){return e.dom()===a.getBody()};return(n=o,r="table",t=u,I(me,he,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,I(function(e,n){return n(e)},ge,e,n,r)).isSome();var e,n,r},function(){return!1})},items:e,position:"line",scope:"editor"})},be=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=pe(n);0<e.trim().length&&n.ui.registry.addContextToolbar("textselection",{predicate:function(e){return!n.selection.isCollapsed()},items:e,position:"selection"})};!function Ee(){i.add("quickbars",function(e){l(e),Oe(e),be(e)})}()}(window);