UNPKG

@thebase/ui

Version:

CDN-installable Owl and Bootstrap 5 UI component library.

2 lines (1 loc) • 2.56 kB
import{b as E,d as F,e as I}from"./chunk-MAWHENWJ.js";import{a as _}from"./chunk-K2ROPYIW.js";import{n as N,t as T}from"./chunk-R43NMSZO.js";import{P as O,T as H,U as A,ea as B,la as M}from"./chunk-XNCXGIZE.js";import{f as s,g as a,h as i}from"./chunk-23NN352E.js";function D(o){let t=T({},`${o}_SLASH_SPEC`),e=N(m=>{let h=m.get(t.key);return new H({key:new A(`${o}_SLASH`),...h})}),n=[t,e];return n.key=t.key,n.pluginKey=e.key,t.meta={package:"@milkdown/plugin-slash",displayName:`Ctx<slashSpec>|${o}`},e.meta={package:"@milkdown/plugin-slash",displayName:`Prose<slash>|${o}`},n}var c,f,u,p,g,r,y,l,S,x,k,R,G=(R=class{constructor(o){a(this,c);a(this,f);a(this,u);a(this,p);a(this,g);a(this,r);a(this,y);a(this,l);a(this,S);a(this,x);a(this,k);i(this,c,!1),this.onShow=()=>{},this.onHide=()=>{},i(this,x,(t,e)=>{let{state:n,composing:m}=t,{selection:h,doc:w}=n,{ranges:$}=h,P=Math.min(...$.map(d=>d.$from.pos)),C=Math.max(...$.map(d=>d.$to.pos)),b=e&&e.doc.eq(w)&&e.selection.eq(h);if(s(this,c)||((s(this,p)??t.dom.parentElement??document.body).appendChild(this.element),i(this,c,!0)),!(m||b)){if(!s(this,y).call(this,t,e)){this.hide();return}I({getBoundingClientRect:()=>B(t,P,C)},this.element,{placement:"bottom-start",middleware:[F(),E(s(this,S)),...s(this,f)],...s(this,u)}).then(({x:d,y:U})=>{Object.assign(this.element.style,{left:`${d}px`,top:`${U}px`})}).catch(console.error),this.show()}}),i(this,k,t=>{let e=this.getContent(t);if(!e)return!1;let n=e.at(-1);return n?Array.isArray(s(this,r))?s(this,r).includes(n):s(this,r)===n:!1}),this.update=(t,e)=>{s(this,l).call(this,t,e)},this.getContent=(t,e=n=>n.type.name==="paragraph")=>{let{selection:n}=t.state,{empty:m,$from:h}=n,w=t.state.selection instanceof O;if(typeof document>"u")return;let $=this.element.contains(document.activeElement),P=!t.hasFocus()&&!$,C=!t.editable,b=!M(e)(t.state.selection);if(!(P||C||!m||!w||b))return h.parent.textBetween(Math.max(0,h.parentOffset-500),h.parentOffset,void 0,"\uFFFC")},this.destroy=()=>{s(this,l).cancel()},this.show=()=>{this.element.dataset.show="true",this.onShow()},this.hide=()=>{this.element.dataset.show="false",this.onHide()},this.element=o.content,i(this,g,o.debounce??200),i(this,y,o.shouldShow??s(this,k)),i(this,r,o.trigger??"/"),i(this,S,o.offset),i(this,f,o.middleware??[]),i(this,u,o.floatingUIOptions??{}),i(this,p,o.root),i(this,l,_(s(this,x),s(this,g)))}},c=new WeakMap,f=new WeakMap,u=new WeakMap,p=new WeakMap,g=new WeakMap,r=new WeakMap,y=new WeakMap,l=new WeakMap,S=new WeakMap,x=new WeakMap,k=new WeakMap,R);export{D as a,G as b};