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

10 lines
9.7 KiB
JavaScript
Raw Normal View History

2023-11-01 22:54:59 -04:00
/*!
* Tiny Mentions plugin
*
* Copyright (c) 2023 Ephox Corporation DBA Tiny Technologies, Inc.
* Licensed under the Tiny commercial license. See https://www.tiny.cloud/legal/
*
2024-03-21 17:16:22 -04:00
* Version: 7.0.0-22
2023-11-01 22:54:59 -04:00
*/
2024-03-21 17:16:22 -04:00
!function(){"use strict";const e=e=>parseInt(e,10),t=(e,t)=>{const n=e-t;return 0===n?0:n>0?1:-1},n=(e,t,n)=>({major:e,minor:t,patch:n}),o=t=>{const o=/([0-9]+)\.([0-9]+)\.([0-9]+)(?:(\-.+)?)/.exec(t);return o?n(e(o[1]),e(o[2]),e(o[3])):n(0,0,0)},r=e=>t=>typeof t===e,s=("string",e=>"string"===(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===(s=o.constructor)||void 0===s?void 0:s.name)===r.name)?"string":t;var n,o,r,s})(e));const i=r("boolean"),a=r("function"),c=r("number"),l=()=>{},m=(e,t)=>e===t,u=()=>!1;class d{constructor(e,t){this.tag=e,this.value=t}static some(e){return new d(!0,e)}static none(){return d.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?d.some(e(this.value)):d.none()}bind(e){return this.tag?e(this.value):d.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:d.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 null==e?d.none():d.some(e)}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()"}}d.singletonNone=new d(!1);const h=(e,t)=>{const n=e.length,o=new Array(n);for(let r=0;r<n;r++){const n=e[r];o[r]=t(n,r)}return o},p=(e,t)=>{for(let n=0,o=e.length;n<o;n++)t(e[n],n)},g=e=>t=>t.options.get(e),v=g("mentions_menu_hover"),f=g("mentions_fetch"),y=g("mentions_menu_complete"),_=g("mentions_menu_cancel"),b=g("mentions_select"),x=g("mentions_selector"),w=g("mentions_css_url"),T=g("mentions_item_type"),E=g("mentions_min_chars"),O=Object.hasOwnProperty,S=(e,t)=>A(e,t)?d.from(e[t]):d.none(),A=(e,t)=>O.call(e,t);"undefined"!=typeof window?window:Function("return this;")();const C=(e,t,n)=>{((e,t,n)=>{if(!(s(n)||i(n)||c(n)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")})(e.dom,t,n)},M=(e,t)=>{e.dom.removeAttribute(t)},N=(e,t)=>{(e=>void 0!==e.dom.classList)(e)?e.dom.classList.add(t):((e,t)=>{((e,t,n)=>{const o=((e,t)=>{const n=((e,t)=>{const n=e.dom.getAttribute(t);return null===n?void 0:n})(e,t);return void 0===n||""===n?[]:n.split(" ")})(e,t),r=o.concat([n]);C(e,t,r.join(" "))})(e,"class",t)})(e,t)},L=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},R=(e,t)=>{const n=(t||document).createElement(e);return L(n)},P=L,j=(e,t)=>{const n=e.dom;if(1!==n.nodeType)return!1;{const e=n;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},D=(e,t,n)=>((e,n,o)=>{let r=e.dom;const s=a(o)?o:u;for(;r.parentNode;){r=r.parentNode;const e=P(r);if(j(e,t))return d.some(e);if(s(e))break}return d.none()})(e,0,n),k=(e,t,n)=>((e,t,n,o,r)=>e(n,o)?d.some(n):a(r)&&r(n)?d.none():t(n,o,r))(((e,t)=>j(e,t)),D,e,t,n),V=(e,t)=>e.dom.is(t,z(e)),z=x,B="data-mce-mentions-id",H=e=>{console.error(e)},I=e=>e&&"string"==typeof e.id&&"string"==typeof e.name,W=e=>{I(e)||H("mentions_fetch didn't produce a valid list of users.")},q=(e,t)=>{e.dom.appendChild(t.dom)},F=(e,t)=>{e.dom.textContent=t},K=e=>t=>{var n;t instanceof window.HTMLElement?e(t):(n=t,"profile"===n.type?d.some((e=>{var t;const n=R("div");N(n,"tox"),N(n,"tox-mentions__card"),d.from(e.image).each((e=>{const t=R("img");C(t,"src",e),N(t,"tox-mentions__avatar"),q(n,t)}));const o=R("div");N(o,"tox-mentions__container"),q(n,o);const r=R("div");return N(r,"tox-mentions__username"),F(r,nul