Files
cms-gov/public/assets/js/tinymce/plugins/link/plugin.min.js

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