PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.5.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.5.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
fluent-community / assets / index2.js

index2.js in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.5.0, at assets/index2.js

24 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var W=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var h=(t,e,r)=>(W(t,e,"read from private field"),r?r.call(t):e.get(t)),C=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},x=(t,e,r,u)=>(W(t,e,"write to private field"),u?u.call(t,r):e.set(t,r),r);import{d as K,i as _,a as X}from"./index6.js?ver=2.5.0";import{bR as Y,b3 as Z,ba as j,b9 as f,b6 as g,b5 as ee,bS as G,b7 as Q,b4 as O}from"./vendor.js?ver=2.5.0";import{t as te,h as se,a as re,b as ne,q as ae,d as ue,f as oe,o as le,i as de}from"./todoList.js?ver=2.5.0";import{L as w,i as me,j as q,q as pe,k as he,n as ce,T as ie,o as ye,J as Ie,p as be,Q as xe,t as ve}from"./milkdown.js?ver=2.5.0";import"./vue.js?ver=2.5.0";import"./dayjs.js?ver=2.5.0";import"./lodash.js?ver=2.5.0";function U(t){const{$from:e,$to:r}=t.selection,{pos:u}=e,{pos:d}=r;return t=t.deleteRange(u-e.node().content.size,d),t}function we(t,e,r=null){const{from:u,to:d}=t.selection;return t.setBlockType(u,d,e,r)}function Me(t,e,r=null){const{$from:u,$to:d}=t.selection,o=u.blockRange(d),c=o&&Y(o,e,r);return c?t.wrap(o,c):null}function ke(t,e,r=null){const u=e.createAndFill(r);return u?t.replaceSelectionWith(u):null}function D(t,e=null){return(r,u)=>{if(u){const d=we(U(r.tr),t,e);u(d.scrollIntoView())}return!0}}function P(t,e=null){return(r,u)=>{const d=Me(U(r.tr),t,e);return d?(u&&u(d.scrollIntoView()),!0):!1}}function V(t,e=null){return(r,u)=>{const d=ke(U(r.tr),t,e);return d?(u&&u(d.scrollIntoView()),!0):!1}}var L,A;class Le{constructor(){C(this,L,void 0);C(this,A,void 0);x(this,L,[]),this.clear=()=>(x(this,L,[]),this),x(this,A,e=>{const r={group:e,addItem:(u,d)=>{const o={key:u,...d};return e.items.push(o),r},clear:()=>(e.items=[],r)};return r}),this.addGroup=(e,r)=>{const d={key:e,label:r,items:[]};return h(this,L).push(d),h(this,A).call(this,d)},this.getGroup=e=>{const r=h(this,L).find(u=>u.key===e);if(!r)throw new Error(`Group with key ${e} not found`);return h(this,A).call(this,r)},this.build=()=>h(this,L)}}L=new WeakMap,A=new WeakMap;function b(t){return window.fluentComAdmin.i18n[t]||t}typeof crypto<"u"&&!crypto.randomUUID&&(crypto.randomUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})});function $e(t,e){var o,c,y,M,H,T,E,S,k,B;const r=new Le;r.addGroup("text",(e==null?void 0:e.slashMenuTextGroupLabel)??b("Text")).addItem("text",{label:(e==null?void 0:e.slashMenuTextGroupLabel)??b("Text"),icon:((o=e==null?void 0:e.slashMenuTextIcon)==null?void 0:o.call(e))??te,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;D(me.type(a))(n,p)}}).addItem("h2",{label:(e==null?void 0:e.slashMenuH2Label)??b("Heading 2"),icon:((c=e==null?void 0:e.slashMenuH2Icon)==null?void 0:c.call(e))??se,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;D(q.type(a),{level:2})(n,p)}}).addItem("h3",{label:(e==null?void 0:e.slashMenuH3Label)??b("Heading 3"),icon:((y=e==null?void 0:e.slashMenuH3Icon)==null?void 0:y.call(e))??re,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;D(q.type(a),{level:3})(n,p)}}).addItem("h4",{label:(e==null?void 0:e.slashMenuH4Label)??b("Heading 4"),icon:((M=e==null?void 0:e.slashMenuH4Icon)==null?void 0:M.call(e))??ne,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;D(q.type(a),{level:4})(n,p)}}).addItem("quote",{label:(e==null?void 0:e.slashMenuQuoteLabel)??b("Quote"),icon:((H=e==null?void 0:e.slashMenuQuoteIcon)==null?void 0:H.call(e))??ae,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;P(pe.type(a))(n,p)}}).addItem("code",{label:(e==null?void 0:e.slashMenuCodeBlockLabel)??b("Code"),icon:((T=e==null?void 0:e.slashMenuCodeBlockIcon)==null?void 0:T.call(e))??ue,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;V(he.type(a))(n,p)}}),r.addGroup("list",(e==null?void 0:e.slashMenuListGroupLabel)??b("List")).addItem("bullet-list",{label:(e==null?void 0:e.slashMenuBulletListLabel)??b("Bullet List"),icon:((E=e==null?void 0:e.slashMenuBulletListIcon)==null?void 0:E.call(e))??oe,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;P(ce.type(a))(n,p)}}).addItem("ordered-list",{label:(e==null?void 0:e.slashMenuOrderedListLabel)??b("Ordered List"),icon:((S=e==null?void 0:e.slashMenuOrderedListIcon)==null?void 0:S.call(e))??le,onRun:a=>{const l=a.get(w),{dispatch:p,state:n}=l;P(ie.type(a))(n,p)}}),(e==null?void 0:e.hasImageBlock)!==!1&&r.addGroup("media",(e==null?void 0:e.slashMenuMediaGroupLabel)??b("Media")).addItem("image",{label:(e==null?void 0:e.slashMenuImageLabel)??b("Image"),icon:((k=e==null?void 0:e.slashMenuImageIcon)==null?void 0:k.call(e))??de,onRun:a=>{if(e!=null&&e.canAddImage&&!e.canAddImage())return;const l=a.get(w),{dispatch:p,state:n}=l;V(ye.type(a))(n,p)}}),(B=e==null?void 0:e.buildMenu)==null||B.call(e,r);let u=r.build();t&&(u=u.map(a=>{const l=a.items.filter(p=>p.label.toLowerCase().includes(t.toLowerCase()));return{...a,items:l}}).filter(a=>a.items.length>0));const d=u.flatMap(a=>a.items);return d.forEach((a,l)=>{Object.assign(a,{index:l})}),u.reduce((a,l)=>{const p=a+l.items.length;return Object.assign(l,{range:[a,p]}),p},0),{groups:u,size:d.length}}const z=({show:t,hide:e,ctx:r,filter:u,config:d})=>{const{groups:o,size:c}=j(()=>$e(u,d),[u]),y=f(),[M,H]=g(0),T=j(()=>y.current.getRootNode(),[y]),E=ee({x:-999,y:-999}),S=G(n=>{const s=E.current;if(!s)return;const{x:m,y:I}=n;s.x=m,s.y=I},[]);Q(()=>{c===0&&t&&(e==null||e())},[c,t]);const k=G((n,s)=>{H(m=>{const I=typeof n=="function"?n(m):n;return s==null||s(I),I})},[]),B=G(n=>{const s=y.current.querySelector(`[data-index="${n}"]`),m=y.current.querySelector(".menu-groups");!s||!m||(m.scrollTop=s.offsetTop-m.offsetTop)},[]),a=G(n=>{const s=o.flatMap(m=>m.items).at(n);s&&r&&s.onRun(r),e==null||e()},[o]),l=G(n=>{if(n.key==="Escape"){n.preventDefault(),e==null||e();return}if(n.key==="ArrowDown")return n.preventDefault(),k(s=>s<c-1?s+1:s,B);if(n.key==="ArrowUp")return n.preventDefault(),k(s=>s<=0?s:s-1,B);if(n.key==="ArrowLeft")return n.preventDefault(),k(s=>{const m=o.find(R=>R.range[0]<=s&&R.range[1]>s);if(!m)return s;const I=o[o.indexOf(m)-1];return I?I.range[1]-1:s},B);if(n.key==="ArrowRight")return n.preventDefault(),k(s=>{const m=o.find(R=>R.range[0]<=s&&R.range[1]>s);if(!m)return s;const I=o[o.indexOf(m)+1];return I?I.range[0]:s},B);n.key==="Enter"&&(n.preventDefault(),a(M))},[e,o,M]),p=G(n=>s=>{const m=E.current;if(!m)return;const{x:I,y:R}=s;I===m.x&&R===m.y||k(n)},[]);return Q(()=>(t?T.addEventListener("keydown",l,{capture:!0}):T.removeEventListener("keydown",l,{capture:!0}),()=>{T.removeEventListener("keydown",l,{capture:!0})}),[t,l]),O`
2 <host onmousedown=${n=>n.preventDefault()}>
3 <div class="menu-groups" onmousemove=${S}>
4 ${o.map(n=>O`
5 <div key=${n.key} class="menu-group">
6 <ul>
7 ${n.items.map(s=>O`<li
8 key=${s.key}
9 data-index=${s.index}
10 class=${M===s.index?"hover":""}
11 onmouseenter=${p(s.index)}
12 onmousedown=${()=>{var m;(m=y.current.querySelector(`[data-index="${s.index}"]`))==null||m.classList.add("active")}}
13 onmouseup=${()=>{var m;(m=y.current.querySelector(`[data-index="${s.index}"]`))==null||m.classList.remove("active"),a(s.index)}}
14 >
15 ${s.icon}
16 <span>${s.label}</span>
17 </li>`)}
18 </ul>
19 </div>
20 `)}
21 </div>
22 </host>
23 `};z.props={ctx:Object,config:Object,show:Boolean,filter:String,hide:Function};const F=Z(z),N=Ie("CREPE_MENU"),J=be({show:()=>{},hide:()=>{}},"menuAPICtx");K("milkdown-slash-menu",F);function Be(t,e){t.set(N.key,{view:r=>new Re(t,r,e)})}var i,v,$;class Re{constructor(e,r,u){C(this,i,void 0);C(this,v,void 0);C(this,$,void 0);x(this,$,null),this.update=o=>{h(this,v).update(o)},this.show=o=>{x(this,$,o),h(this,i).filter="",h(this,v).show()},this.hide=()=>{x(this,$,null),h(this,v).hide()},this.destroy=()=>{h(this,v).destroy(),h(this,i).remove()},x(this,i,new F),h(this,i).hide=this.hide,h(this,i).ctx=e,h(this,i).config=u;const d=this;x(this,v,new xe({content:h(this,i),debounce:20,shouldShow(o){if(_(o.state.selection)||X(o.state.selection))return!1;const c=this.getContent(o,M=>["paragraph","heading"].includes(M.type.name));if(c==null)return!1;const y=h(d,$);return h(d,i).filter=c.startsWith("/")?c.slice(1):c,typeof y=="number"?o.state.doc.resolve(y).node()!==o.state.doc.resolve(o.state.selection.from).node()?(x(d,$,null),!1):!0:!!c.startsWith("/")},offset:10})),h(this,v).onShow=()=>{h(this,i).show=!0},h(this,v).onHide=()=>{h(this,i).show=!1},this.update(r),e.set(J.key,{show:o=>this.show(o),hide:()=>this.hide()})}}i=new WeakMap,v=new WeakMap,$=new WeakMap;const Oe=(t,e)=>{t.config(r=>Be(r,e)).use(J).use(ve).use(N)};export{Oe as defineFeature};
24