fuck-tiny-cloud/plugins/advcode/customeditor.js

10 lines
2.2 KiB
JavaScript

/*!
* Tiny Enhanced 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: 8.3.0-112
*/
!function(){"use strict";const t=()=>{};class e{tag;value;static singletonNone=new e(!1);constructor(t,e){this.tag=t,this.value=e}static some(t){return new e(!0,t)}static none(){return e.singletonNone}fold(t,e){return this.tag?e(this.value):t()}isSome(){return this.tag}isNone(){return!this.tag}map(t){return this.tag?e.some(t(this.value)):e.none()}bind(t){return this.tag?t(this.value):e.none()}exists(t){return this.tag&&t(this.value)}forall(t){return!this.tag||t(this.value)}filter(t){return!this.tag||t(this.value)?this:e.none()}getOr(t){return this.tag?this.value:t}or(t){return this.tag?this:t}getOrThunk(t){return this.tag?this.value:t()}orThunk(t){return this.tag?this:t()}getOrDie(t){if(this.tag)return this.value;throw new Error(t??"Called getOrDie on None")}static from(t){return null==t?e.none():e.some(t)}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(t){this.tag&&t(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}const r=Object.hasOwnProperty,n=t=>{return(n=tinymce,((t,e)=>r.call(t,e))(n,"get")?e.from(n.get):e.none()).bind((r=>e.from(r.call(tinymce,t))));var n};tinymce.Resource.add("tinymce.plugins.advcode.customeditor",((r,s)=>new Promise((i=>{i((async t=>{var e;return(await(e=t,tinymce.Resource.load("tinymce.plugins.advcode.CodeMirror",e)))()})(s.codeMirrorScriptUrl).then((i=>{const{setValue:a,getValue:o,copyCode:u,formatCode:h,setDarkMode:l,changeFontSize:c,setFontSize:g,destroy:d}=i(r,s,"",s.currentAdvStatus),v={getValue:o,setValue:a,destroy:d};var m,y;return(m=s.editorId,y=s.advcodeInstanceId,n(m).bind((t=>e.from(t.plugins.advcode))).map((r=>(r[y]||(r[y]=(()=>{const r=(t=>{const r=(t=>{let e=t;return{get:()=>e,set:t=>{e=t}}})(e.none()),n=()=>r.get().each(t);return{clear:()=>{n(),r.set(e.none())},isSet:()=>r.get().isSome(),get:()=>r.get(),set:t=>{n(),r.set(e.some(t))}}})(t);return{...r,on:t=>r.get().each(t)}})()),r[y])))).each((t=>t.set({copyCode:u,formatCode:h,changeFontSize:c,setFontSize:g,setDarkMode:l}))),v})))}))))}();