1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
|
|
!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&&(n=o=e,(r=String).prototype.isPrototypeOf(n)||(null===(l=o.constructor)||void 0===l?void 0:l.name)===r.name)?"string":t;var n,o,r,l})(t)===e,n=e=>t=>typeof t===e,o=t("string"),r=t("object"),l=t("array"),s=e=>null===e;const a=n("boolean"),i=e=>!(e=>null==e)(e),c=n("function"),u=(e,t)=>{if(l(e)){for(let n=0,o=e.length;n<o;++n)if(!t(e[n]))return!1;return!0}return!1},g=()=>{},d=(e,t)=>e===t;class m{constructor(e,t){this.tag=e,this.value=t}static some(e){return new m(!0,e)}static none(){return m.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?m.some(e(this.value)):m.none()}bind(e){return this.tag?e(this.value):m.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:m.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 i(e)?m.some(e):m.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()"}}m.singletonNone=new m(!1),Array.prototype.slice;const h=Array.prototype.indexOf,p=Array.prototype.push,f=e=>{const t=[];for(let n=0,o=e.length;n<o;++n){if(!l(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);p.apply(t,e[n])}return t};c(Array.from)&&Array.from;const k=(e,t)=>{for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o.isSome())return o}return m.none()},v=Object.keys,y=Object.hasOwnProperty,b=(e,t)=>y.call(e,t),x=(e,t,n=d)=>e.exists((e=>n(e,t))),_=e=>{const t=[],n=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(n);return t},w=(e,t)=>e?m.some(t):m.none(),C=e=>t=>t.options.get(e),A=C("link_assume_external_targets"),O=C("link_context_toolbar"),S=C("link_list"),N=C("link_default_target"),E=C("link_default_protocol"),R=C("link_target_list"),T=C("link_rel_list"),L=C("link_class_list"),P=C("link_title"),M=C("allow_unsafe_link_target"),D=C("link_quicklink"),B=C("link_attributes_postprocess");var I=tinymce.util.Tools.resolve("tinymce.util.URI"),K=tinymce.util.Tools.resolve("tinymce.dom.TreeWalker"),j=tinymce.util.Tools.resolve("tinymce.util.Tools");const U=e=>i(e)&&"a"===e.nodeName.toLowerCase(),q=e=>U(e)&&!!$(e),F=(e,t)=>{if(e.collapsed)return[];{const n=e.cloneContents(),o=n.firstChild,r=new K(o,n),l=[];let s=o;do{t(s)&&l.push(s)}while(s=r.next());return l}},V=e=>/^\w+:/i.test(e),$=e=>{var t,n;return null!==(n=null!==(t=e.getAttribute("data-mce-href"))&&void 0!==t?t:e.getAttribute("href"))&&void 0!==n?n:""},z=(e,t)=>{const n=["noopener"],o=e?e.split(/\s+/):[],r=e=>e.filter((e=>-1===j.inArray(n,e))),l=t?(e=>(e=r(e)).length>0?e.concat(n):n)(o):r(o);return l.length>0?(e=>j.trim(e.sort().join(" ")))(l):""},G=(e,t)=>(t=t||W(e.selection.getRng())[0]||e.selection.getNode(),Z(t)?m.from(e.dom.select("a[href]",t)[0]):m.from(e.dom.getParent(t,"a[href]"))),H=(e,t)=>G(e,t).isSome(),J=(e,t)=>t.fold((()=>e.getContent({format:"text"})),(e=>e.innerText||e.textContent||"")).replace(/\uFEFF/g,""),W=e=>F(e,q),Q=e=>j.grep(e,q),X=e=>Q(e).length>0,Y=e=>{const t=e.schema.getTextInlineElements();if(G(e).exists((e=>e.hasAttribute("data-mce-block"))))return!1;const n=e.selection.getRng();return!!n.collapsed||0===F(n,(e=>1===e.nodeType&&!U(e)&&!b(t,e.nodeName.toLowerCase()))).length},Z=e=>i(e)&&"FIGURE"===e.nodeName&&/\bimage\b/i.test(e.className),ee=(e,t,n)=>{const o=e.selection.getNode(),r=G(e,o),l=((e,t)=>{const n={...t};if(0===T(e).length&&!M(e)){const e=z(n.rel,"_blank"===n.target);n.rel=e||null}return m.from(n.target).isNone()&&!1===R(e)&&(n.target=N(e)),n.href=((e,t)=>"http"!==t&&"https"!==t||V(e)?e:t+":
|