Files

1 line
17 KiB
JavaScript
Raw Permalink Normal View History

!function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(r=o=e,(a=String).prototype.isPrototypeOf(r)||o.constructor?.name===a.name)?"string":t;var r,o,a})(t)===e,r=t("string"),o=t("object"),a=t("array"),s=e=>!(e=>null==e)(e),i=e=>"function"==typeof e;class n{tag;value;static singletonNone=new n(!1);constructor(e,t){this.tag=e,this.value=t}static some(e){return new n(!0,e)}static none(){return n.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?n.some(e(this.value)):n.none()}bind(e){return this.tag?e(this.value):n.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:n.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(e??"Called getOrDie on None")}static from(e){return s(e)?n.some(e):n.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()"}}Array.prototype.slice;const c=Array.prototype.push,l=(e,t)=>{for(let r=0,o=e.length;r<o;r++)t(e[r],r)},m=e=>{const t=[];for(let r=0,o=e.length;r<o;++r){if(!a(e[r]))throw new Error("Arr.flatten item "+r+" was not an array, input: "+e);c.apply(t,e[r])}return t};i(Array.from)&&Array.from;const u=Object.keys,d=Object.hasOwnProperty,h=(e,t)=>p(e,t)?n.from(e[t]):n.none(),p=(e,t)=>d.call(e,t),g=e=>t=>t.options.get(e),b=g("audio_template_callback"),w=g("video_template_callback"),f=g("iframe_template_callback"),y=g("media_live_embeds"),v=g("media_filter_html"),x=g("media_url_resolver"),_=g("media_alt_source"),k=g("media_poster"),j=g("media_dimensions");var A=tinymce.util.Tools.resolve("tinymce.util.Tools"),O=tinymce.util.Tools.resolve("tinymce.dom.DOMUtils"),S=tinymce.util.Tools.resolve("tinymce.html.DomParser");const $=O.DOM,C=e=>e.replace(/px$/,""),T=e=>{const t=e.attr("style"),r=t?$.parseStyle(t):{};return{type:"ephox-embed-iri",source:e.attr("data-ephox-embed-iri"),altsource:"",poster:"",width:h(r,"max-width").map(C).getOr(""),height:h(r,"max-height").map(C).getOr("")}},z=(e,t)=>{let r={};for(let o=S({validate:!1,forced_root_block:!1},t).parse(e);o;o=o.walk())if(1===o.type){const e=o.name;if(o.attr("data-ephox-embed-iri")){r=T(o);break}r.source||"param"!==e||(r.source=o.attr("movie")),"iframe"!==e&&"object"!==e&&"embed"!==e&&"video"!==e&&"audio"!==e||(r.type||(r.type=e),r=A.extend(o.attributes.map,r)),"source"===e&&(r.source?r.altsource||(r.altsource=o.attr("src")):r.source=o.attr("src")),"img"!==e||r.poster||(r.poster=o.attr("src"))}return r.source=r.source||r.src||"",r.altsource=r.altsource||"",r.poster=r.poster||"",r},D=e=>{const t=e.toLowerCase().split(".").pop()??"";return h({mp3:"audio/mpeg",m4a:"audio/x-m4a",wav:"audio/wav",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",swf:"application/x-shockwave-flash"},t).getOr("")};var F=tinymce.util.Tools.resolve("tinymce.html.Node"),M=tinymce.util.Tools.resolve("tinymce.html.Serializer");const N=(e,t={})=>S({forced_root_block:!1,validate:!1,allow_conditional_comments:!0,...t},e),P=O.DOM,R=e=>/^[0-9.]+$/.test(e)?e+"px":e,E=(e,t)=>{const r=t.attr("style"),o=r?P.parseStyle(r):{};s(e.width)&&(o["max-width"]=R(e.width)),s(e.height)&&(o["max-height"]=R(e.height)),t.attr("style",P.serializeStyle(o))},U=["source","altsource"],L=(e,t,r,o)=>{let a=0,s=0;const i=N(o);i.addNodeFilter("source",(e=>a=e.length));const n=i.parse(e);for(let e=n;e;e=e.walk())if(1===e.type){const o=e.name;if(e.attr("data-ephox-embed-iri")){E(t,e);break}switch(o){case"video":case"object":case"embed":case"img":case"iframe":void 0!==t.height&&void 0!==t.width&&(e.attr("width",t.width),e.attr("height",t.height))}if(r)switch(o){case"video":e.attr("poster",t.poster)