| 1 |
var E=(e,s,a)=>{if(!s.has(e))throw TypeError("Cannot "+a)};var l=(e,s,a)=>(E(e,s,"read from private field"),a?a.call(e):s.get(e)),I=(e,s,a)=>{if(s.has(e))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(e):s.set(e,a)},T=(e,s,a,t)=>(E(e,s,"write to private field"),t?t.call(e,a):s.set(e,a),a);import{d as O}from"./index6.js?ver=2.8.0";import{b3 as z,bV as H,b7 as P,b4 as S,b8 as b,az as B}from"./vendor.js?ver=2.8.0";import{j as D,k as G,s as M,d as V,l as K}from"./todoList.js?ver=2.8.0";import{y as U,R as _,z as q,A as J,B as A,L as C,C as v,D as Q,E as W,G as X,I as Y,K as R,M as Z,N as x}from"./milkdown.js?ver=2.8.0";import"./vue.js?ver=2.8.0";import"./dayjs.js?ver=2.8.0";import"./lodash.js?ver=2.8.0";const F=({ctx:e,hide:s,show:a,config:t})=>{var h,p,y,k,w;const c=H();P(()=>{c()},[a]);const n=o=>m=>{m.preventDefault(),e&&o(e),c()},i=o=>{if(!e)return!1;const m=e.get(C),{state:{doc:u,selection:$}}=m;return u.rangeHasMark($.from,$.to,o)};return S`<host> |
| 2 |
<button |
| 3 |
class=${b("toolbar-item",e&&i(U.type(e))&&"active")} |
| 4 |
onmousedown=${n(o=>{o.get(v).call(Q.key)})} |
| 5 |
> |
| 6 |
${((h=t==null?void 0:t.boldIcon)==null?void 0:h.call(t))??D} |
| 7 |
</button> |
| 8 |
<button |
| 9 |
class=${b("toolbar-item",e&&i(_.type(e))&&"active")} |
| 10 |
onmousedown=${n(o=>{o.get(v).call(W.key)})} |
| 11 |
> |
| 12 |
${((p=t==null?void 0:t.italicIcon)==null?void 0:p.call(t))??G} |
| 13 |
</button> |
| 14 |
<button |
| 15 |
class=${b("toolbar-item",e&&i(q.type(e))&&"active")} |
| 16 |
onmousedown=${n(o=>{o.get(v).call(X.key)})} |
| 17 |
> |
| 18 |
${((y=t==null?void 0:t.strikethroughIcon)==null?void 0:y.call(t))??M} |
| 19 |
</button> |
| 20 |
<div class="divider"></div> |
| 21 |
<button |
| 22 |
class=${b("toolbar-item",e&&i(J.type(e))&&"active")} |
| 23 |
onmousedown=${n(o=>{o.get(v).call(Y.key)})} |
| 24 |
> |
| 25 |
${((k=t==null?void 0:t.codeIcon)==null?void 0:k.call(t))??V} |
| 26 |
</button> |
| 27 |
<button |
| 28 |
class=${b("toolbar-item",e&&i(A.type(e))&&"active")} |
| 29 |
onmousedown=${n(o=>{const m=o.get(C),{selection:u}=m.state;if(i(A.type(o))){o.get(R.key).removeLink(u.from,u.to);return}o.get(R.key).addLink(u.from,u.to),s==null||s()})} |
| 30 |
> |
| 31 |
${((w=t==null?void 0:t.linkIcon)==null?void 0:w.call(t))??K} |
| 32 |
</button> |
| 33 |
</host>`};F.props={ctx:Object,hide:Function,show:Boolean,config:Object};const L=z(F),j=Z("CREPE_TOOLBAR");var d,r;class f{constructor(s,a,t){I(this,d,void 0);I(this,r,void 0);this.update=(n,i)=>{l(this,d).update(n,i)},this.destroy=()=>{l(this,d).destroy(),l(this,r).remove()},this.hide=()=>{l(this,d).hide()};const c=new L;T(this,r,c),l(this,r).ctx=s,l(this,r).hide=this.hide,l(this,r).config=t,T(this,d,new x({content:l(this,r),debounce:20,offset:10,shouldShow(n){const{doc:i,selection:h}=n.state,{empty:p,from:y,to:k}=h,w=!i.textBetween(y,k).length&&h instanceof B,o=!(h instanceof B),m=n.dom.getRootNode().activeElement,u=c.contains(m),$=!n.hasFocus()&&!u,N=!n.editable;return!($||o||p||w||N)}})),l(this,d).onShow=()=>{l(this,r).show=!0,setTimeout(()=>{let n=l(this,r).style.left;n=parseInt(n),n<0?l(this,r).style.left=0:n>350&&(l(this,r).style.left="350px")},0)},l(this,d).onHide=()=>{l(this,r).show=!1},this.update(a)}}d=new WeakMap,r=new WeakMap;O("milkdown-toolbar",L);const rt=(e,s)=>{e.config(a=>{a.set(j.key,{view:t=>new f(a,t,s)})}).use(j)};export{rt as defineFeature}; |
| 34 |
|