fuck-tiny-cloud/plugins/advcode/plugin.min.js

10 lines
16 KiB
JavaScript
Raw Normal View History

2023-10-09 16:11:16 -04:00
/*!
* Tiny Advanced Code Editor plugin
*
* Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc.
* Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
*
* Version: 3.4.0-107
2023-10-09 16:11:16 -04:00
*/
!function(){"use strict";const e=e=>parseInt(e,10),t=(e,t)=>{const o=e-t;return 0===o?0:o>0?1:-1},o=(e,t,o)=>({major:e,minor:t,patch:o}),r=t=>{const r=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return r?o(e(r[1]),e(r[2]),e(r[3])):o(0,0,0)},n=e=>t=>typeof t===e,s=e=>"string"===(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=r=e,(n=String).prototype.isPrototypeOf(o)||(null===(s=r.constructor)||void 0===s?void 0:s.name)===n.name)?"string":t;var o,r,n,s})(e),i=n("boolean"),c=e=>!(e=>null==e)(e),a=n("function"),d=n("number");class l{constructor(e,t){this.tag=e,this.value=t}static some(e){return new l(!0,e)}static none(){return l.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?l.some(e(this.value)):l.none()}bind(e){return this.tag?e(this.value):l.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:l.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return c(e)?l.some(e):l.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}l.singletonNone=new l(!1);let u=0;const m=e=>{const t=(new Date).getTime(),o=Math.floor(1e9*Math.random());return u++,e+"_"+o+u+String(t)},g=e=>t=>t.options.get(e),p=g("codemirror_script"),h=g("codemirror_css"),v=g("codemirror_linewrapping"),f=g("codemirror_linenumbers"),y=g("codemirror_foldgutter"),b=g("codemirror_gutter"),w=g("codemirror_theme"),C=e=>"rtl"===e.getBody().dir?"rtl":"ltr",S=g("advcode_headless"),_=g("advcode_inline"),k=(e,t,o)=>({customEditorScriptUrl:t+"/customeditor.min.js",codeMirrorScriptUrl:p(e),codeMirrorCssUrl:h(e),lineWrapping:v(e),lineNumbers:f(e),foldGutter:y(e),theme:w(e),direction:C(e),gutter:b(e),editorId:e.id,advcodeInstanceId:m("advcode_instance"),currentAdvStatus:o}),x=()=>{},z=()=>!1,I=(e,t)=>{for(let o=0,r=e.length;o<r;o++)if(t(e[o],o))return!0;return!1},T=Object.hasOwnProperty,A=(e,t)=>T.call(e,t);"undefined"!=typeof window?window:Function("return this;")();const E=e=>t=>(e=>e.dom.nodeType)(t)===e,M=E(1),N=E(3),O=E(9),D=E(11),L=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},P=(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return L(o.childNodes[0])},V=(e,t)=>{const o=(t||document).createElement(e);return L(o)},F=L,j=e=>O(e)?e:F(e.dom.ownerDocument),B=(e,t)=>{e.dom.appendChild(t.dom)},R=e=>D(e)&&c(e.dom.host),$=a(Element.prototype.attachShadow)&&a(Node.prototype.getRootNode)?e=>F(e.dom.getRootNode()):j,W=e=>F(e.dom.host),U=e=>{const t=N(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=$(e);return R(t)?l.some(t):l.none()})(F(t)).fold((()=>o.body.contains(t)),(r=U,n=W,e=>r(n(e))));var r,n},G=()=>H(F(document)),H=e=>{const t=e.dom.body;if(null==t)throw new Error("Body is not available yet");return F(t)},q=(e,t,o)=>{let r=e.dom;const n=a(o)?o:z;for(;r.parentNode;){r=r.parentNode;const e=F(r);if(t(e))return l.some(e);if(n(e))break}return l.none()},K=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Q="\x3c!--mce_cursor--\x3e",J=(e,t)=>{const o=e.dom,r=e.selection,n=r.getBookmark(),s=(e=>A(e,"name"))(n)?o.select(n.name)[n.index]:o.select(`#${n.id}_start`)[0],i=l.from(s).map((t=>{const o=F(e.getBody());return((e,t)=>{const r=P(Q),n=F(e),s=((e,t,o)=>((e,t,o,r,n)=>r(o)?l.some(o):a(n)&&n(o)?l.none():t(o,r,n))(0,q,e,t,o))(n,(e=>((e,t)=>{const o=e.dom;return!(!o||!o.hasAttribute)&&o.hasAttribute("data-mce-bogus")})(e)),(e=>{retu