snow-cms 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-browser.es.js +1 -1
- package/dist/index-browser.es2.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es2.js +1 -1
- package/dist/index.js +43 -41
- package/dist/milkdown.js +44 -0
- package/package.json +7 -13
- package/dist/index2.js +0 -44
- package/dist/index3.js +0 -1
- package/dist/index4.js +0 -3
- package/dist/index5.js +0 -1
- package/dist/index6.js +0 -1
package/dist/index3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{P as Y,c as Z,I as ee,S as te,s as ne,a as re,p as se,E as ie}from"./index2.js";import{c as I,g as oe}from"./index.js";var N,z;function ae(){if(z)return N;z=1;var s="Expected a function",t=NaN,o="[object Symbol]",w=/^\s+|\s+$/g,u=/^[-+]0x[0-9a-f]+$/i,y=/^0b[01]+$/i,h=/^0o[0-7]+$/i,M=parseInt,n=typeof I=="object"&&I&&I.Object===Object&&I,d=typeof self=="object"&&self&&self.Object===Object&&self,P=n||d||Function("return this")(),f=Object.prototype,m=f.toString,S=Math.max,x=Math.min,U=function(){return P.Date.now()};function G(e,i,c){var b,L,j,g,a,p,E=0,D=!1,v=!1,C=!0;if(typeof e!="function")throw new TypeError(s);i=q(i)||0,O(c)&&(D=!!c.leading,v="maxWait"in c,j=v?S(q(c.maxWait)||0,i):j,C="trailing"in c?!!c.trailing:C);function R(r){var l=b,k=L;return b=L=void 0,E=r,g=e.apply(k,l),g}function V(r){return E=r,a=setTimeout(T,i),D?R(r):g}function X(r){var l=r-p,k=r-E,$=i-l;return v?x($,j-k):$}function W(r){var l=r-p,k=r-E;return p===void 0||l>=i||l<0||v&&k>=j}function T(){var r=U();if(W(r))return F(r);a=setTimeout(T,X(r))}function F(r){return a=void 0,C&&b?R(r):(b=L=void 0,g)}function J(){a!==void 0&&clearTimeout(a),E=0,b=p=L=a=void 0}function Q(){return a===void 0?g:F(U())}function _(){var r=U(),l=W(r);if(b=arguments,L=this,p=r,l){if(a===void 0)return V(p);if(v)return a=setTimeout(T,i),R(p)}return a===void 0&&(a=setTimeout(T,i)),g}return _.cancel=J,_.flush=Q,_}function O(e){var i=typeof e;return!!e&&(i=="object"||i=="function")}function H(e){return!!e&&typeof e=="object"}function K(e){return typeof e=="symbol"||H(e)&&m.call(e)==o}function q(e){if(typeof e=="number")return e;if(K(e))return t;if(O(e)){var i=typeof e.valueOf=="function"?e.valueOf():e;e=O(i)?i+"":i}if(typeof e!="string")return e===0?e:+e;e=e.replace(w,"");var c=y.test(e);return c||h.test(e)?M(e.slice(2),c?2:8):u.test(e)?t:+e}return N=G,N}var ue=ae();const de=oe(ue);class B{constructor(){this.beforeMountedListeners=[],this.mountedListeners=[],this.updatedListeners=[],this.selectionUpdatedListeners=[],this.markdownUpdatedListeners=[],this.blurListeners=[],this.focusListeners=[],this.destroyListeners=[],this.beforeMount=t=>(this.beforeMountedListeners.push(t),this),this.mounted=t=>(this.mountedListeners.push(t),this),this.updated=t=>(this.updatedListeners.push(t),this)}get listeners(){return{beforeMount:this.beforeMountedListeners,mounted:this.mountedListeners,updated:this.updatedListeners,markdownUpdated:this.markdownUpdatedListeners,blur:this.blurListeners,focus:this.focusListeners,destroy:this.destroyListeners,selectionUpdated:this.selectionUpdatedListeners}}markdownUpdated(t){return this.markdownUpdatedListeners.push(t),this}blur(t){return this.blurListeners.push(t),this}focus(t){return this.focusListeners.push(t),this}destroy(t){return this.destroyListeners.push(t),this}selectionUpdated(t){return this.selectionUpdatedListeners.push(t),this}}const A=Z(new B,"listener"),fe=new Y("MILKDOWN_LISTENER"),ce=s=>(s.inject(A,new B),async()=>{await s.wait(ee);const t=s.get(A),{listeners:o}=t;o.beforeMount.forEach(n=>n(s)),await s.wait(te);const w=s.get(ne);let u=null,y=null,h=null;const M=new re({key:fe,view:()=>({destroy:()=>{o.destroy.forEach(n=>n(s))}}),props:{handleDOMEvents:{focus:()=>(o.focus.forEach(n=>n(s)),!1),blur:()=>(o.blur.forEach(n=>n(s)),!1)}},state:{init:(n,d)=>{u=d.doc,y=w(d.doc)},apply:n=>{const d=n.selection;return(!h&&d||h&&!d.eq(h))&&(o.selectionUpdated.forEach(f=>{f(s,d,h)}),h=d),!n.docChanged||n.getMeta("addToHistory")===!1?void 0:de(()=>{const{doc:f}=n;if(o.updated.length>0&&u&&!u.eq(f)&&o.updated.forEach(m=>{m(s,f,u)}),o.markdownUpdated.length>0&&u&&!u.eq(f)){const m=w(f);o.markdownUpdated.forEach(S=>{S(s,m,y)}),y=m}u=f},200)()}}});s.update(se,n=>n.concat(M)),await s.wait(ie),o.mounted.forEach(n=>n(s))});ce.meta={package:"@milkdown/plugin-listener",displayName:"Listener"};export{B as ListenerManager,fe as key,ce as listener,A as listenerCtx};
|
package/dist/index4.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{$nodeAttr as I,$useKeymap as C,$nodeSchema as b,$command as g,$node as ot,$ctx as st,$markAttr as J,$markSchema as Q,$inputRule as M,$prose as $,$remark as T}from"./index6.js";import{F as N,b as X,R as re,d as ae,e as Kt,N as Dt,l as _t,f as Pt,v as q,g as tt,h,r as lt,t as ne,m as Y,i as R,T as oe,j as it,k as E,n as dt,w as se,o as le,q as Et,u as ct,P as W,a as F,D as rt,x as at,y as $t,A as qt,z as Wt}from"./index2.js";import"./index.js";function Ft(t,e){return function(r,a){let{$from:n,$to:s,node:l}=r.selection;if(l&&l.isBlock||n.depth<2||!n.sameParent(s))return!1;let i=n.node(-1);if(i.type!=t)return!1;if(n.parent.content.size==0&&n.node(-1).childCount==n.indexAfter(-1)){if(n.depth==3||n.node(-3).type!=t||n.index(-2)!=n.node(-2).childCount-1)return!1;if(a){let u=N.empty,m=n.index(-1)?1:n.index(-2)?2:3;for(let A=n.depth-m;A>=n.depth-3;A--)u=N.from(n.node(A).copy(u));let f=n.indexAfter(-1)<n.node(-2).childCount?1:n.indexAfter(-2)<n.node(-3).childCount?2:3;u=u.append(N.from(t.createAndFill()));let y=n.before(n.depth-(m-1)),k=r.tr.replace(y,n.after(-f),new X(u,4-m,0)),w=-1;k.doc.nodesBetween(y,k.doc.content.size,(A,te)=>{if(w>-1)return!1;A.isTextblock&&A.content.size==0&&(w=te+1)}),w>-1&&k.setSelection(ae.near(k.doc.resolve(w))),a(k.scrollIntoView())}return!0}let d=s.pos==n.end()?i.contentMatchAt(0).defaultType:null,c=r.tr.delete(n.pos,s.pos),p=d?[null,{type:d}]:void 0;return Kt(c.doc,n.pos,2,p)?(a&&a(c.split(n.pos,2,p).scrollIntoView()),!0):!1}}function pt(t){return function(e,r){let{$from:a,$to:n}=e.selection,s=a.blockRange(n,l=>l.childCount>0&&l.firstChild.type==t);return s?r?a.node(s.depth-1).type==t?Vt(e,r,t,s):zt(e,r,s):!0:!1}}function Vt(t,e,r,a){let n=t.tr,s=a.end,l=a.$to.end(a.depth);s<l&&(n.step(new re(s-1,l,s,l,new X(N.from(r.create(null,a.parent.copy())),1,0),1,!0)),a=new Dt(n.doc.resolve(a.$from.pos),n.doc.resolve(l),a.depth));const i=_t(a);if(i==null)return!1;n.lift(a,i);let d=n.doc.resolve(n.mapping.map(s,-1)-1);return Pt(n.doc,d.pos)&&d.nodeBefore.type==d.nodeAfter.type&&n.join(d.pos),e(n.scrollIntoView()),!0}function zt(t,e,r){let a=t.tr,n=r.parent;for(let f=r.end,y=r.endIndex-1,k=r.startIndex;y>k;y--)f-=n.child(y).nodeSize,a.delete(f-1,f+1);let s=a.doc.resolve(r.start),l=s.nodeAfter;if(a.mapping.map(r.end)!=r.start+s.nodeAfter.nodeSize)return!1;let i=r.startIndex==0,d=r.endIndex==n.childCount,c=s.node(-1),p=s.index(-1);if(!c.canReplace(p+(i?0:1),p+1,l.content.append(d?N.empty:N.from(n))))return!1;let u=s.pos,m=u+l.nodeSize;return a.step(new re(u-(i?1:0),m+(d?1:0),u+1,m-1,new X((i?N.empty:N.from(n.copy(N.empty))).append(d?N.empty:N.from(n.copy(N.empty))),i?0:1,d?0:1),i?0:1)),e(a.scrollIntoView()),!0}function Ut(t){return function(e,r){let{$from:a,$to:n}=e.selection,s=a.blockRange(n,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let l=s.startIndex;if(l==0)return!1;let i=s.parent,d=i.child(l-1);if(d.type!=t)return!1;if(r){let c=d.lastChild&&d.lastChild.type==i.type,p=N.from(c?t.create():null),u=new X(N.from(t.create(null,N.from(i.type.create(null,p)))),c?3:1,0),m=s.start,f=s.end;r(e.tr.step(new re(m-(c?3:1),f,m,f,u,1,!0)).scrollIntoView())}return!0}}function jt(t){const e=new Map;if(!t||!t.type)throw new Error("mdast-util-definitions expected node");return q(t,"definition",function(a){const n=nt(a.identifier);n&&!e.get(n)&&e.set(n,a)}),r;function r(a){const n=nt(a);return e.get(n)}}function nt(t){return String(t||"").toUpperCase()}function Gt(){return function(t){const e=jt(t);q(t,function(r,a,n){if(r.type==="definition"&&n!==void 0&&typeof a=="number")return n.children.splice(a,1),[tt,a];if(r.type==="imageReference"||r.type==="linkReference"){const s=e(r.identifier);if(s&&n&&typeof a=="number")return n.children[a]=r.type==="imageReference"?{type:"image",url:s.url,title:s.title,alt:r.alt}:{type:"link",url:s.url,title:s.title,children:r.children},[tt,a]}})}}function ut(t,e){var r;if(!(e.childCount>=1&&((r=e.lastChild)==null?void 0:r.type.name)==="hardbreak")){t.next(e.content);return}const n=[];e.content.forEach((s,l,i)=>{i!==e.childCount-1&&n.push(s)}),t.next(N.fromArray(n))}function o(t,e){return Object.assign(t,{meta:{package:"@milkdown/preset-commonmark",...e}}),t}const ie=J("emphasis");o(ie,{displayName:"Attr<emphasis>",group:"Emphasis"});const K=Q("emphasis",t=>({attrs:{marker:{default:t.get(lt).emphasis||"*",validate:"string"}},parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style",getAttrs:e=>e==="italic"}],toDOM:e=>["em",t.get(ie.key)(e)],parseMarkdown:{match:e=>e.type==="emphasis",runner:(e,r,a)=>{e.openMark(a,{marker:r.marker}),e.next(r.children),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="emphasis",runner:(e,r)=>{e.withMark(r,"emphasis",void 0,{marker:r.attrs.marker})}}}));o(K.mark,{displayName:"MarkSchema<emphasis>",group:"Emphasis"});o(K.ctx,{displayName:"MarkSchemaCtx<emphasis>",group:"Emphasis"});const de=g("ToggleEmphasis",t=>()=>ne(K.type(t)));o(de,{displayName:"Command<toggleEmphasisCommand>",group:"Emphasis"});const mt=M(t=>Y(/(?:^|[^*])\*([^*]+)\*$/,K.type(t),{getAttr:()=>({marker:"*"}),updateCaptured:({fullMatch:e,start:r})=>e.startsWith("*")?{}:{fullMatch:e.slice(1),start:r+1}}));o(mt,{displayName:"InputRule<emphasis>|Star",group:"Emphasis"});const gt=M(t=>Y(/(?:^|[^_])_([^_]+)_$/,K.type(t),{getAttr:()=>({marker:"_"}),updateCaptured:({fullMatch:e,start:r})=>e.startsWith("_")?{}:{fullMatch:e.slice(1),start:r+1}}));o(gt,{displayName:"InputRule<emphasis>|Underscore",group:"Emphasis"});const ce=C("emphasisKeymap",{ToggleEmphasis:{shortcuts:"Mod-i",command:t=>{const e=t.get(h);return()=>e.call(de.key)}}});o(ce.ctx,{displayName:"KeymapCtx<emphasis>",group:"Emphasis"});o(ce.shortcuts,{displayName:"Keymap<emphasis>",group:"Emphasis"});const pe=J("strong");o(pe,{displayName:"Attr<strong>",group:"Strong"});const V=Q("strong",t=>({attrs:{marker:{default:t.get(lt).strong||"*",validate:"string"}},parseDOM:[{tag:"b",getAttrs:e=>e.style.fontWeight!="normal"&&null},{tag:"strong"},{style:"font-style",getAttrs:e=>e==="bold"},{style:"font-weight=400",clearMark:e=>e.type.name=="strong"},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:e=>["strong",t.get(pe.key)(e)],parseMarkdown:{match:e=>e.type==="strong",runner:(e,r,a)=>{e.openMark(a,{marker:r.marker}),e.next(r.children),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="strong",runner:(e,r)=>{e.withMark(r,"strong",void 0,{marker:r.attrs.marker})}}}));o(V.mark,{displayName:"MarkSchema<strong>",group:"Strong"});o(V.ctx,{displayName:"MarkSchemaCtx<strong>",group:"Strong"});const ue=g("ToggleStrong",t=>()=>ne(V.type(t)));o(ue,{displayName:"Command<toggleStrongCommand>",group:"Strong"});const yt=M(t=>Y(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/,V.type(t),{getAttr:e=>({marker:e[0].startsWith("*")?"*":"_"})}));o(yt,{displayName:"InputRule<strong>",group:"Strong"});const me=C("strongKeymap",{ToggleBold:{shortcuts:["Mod-b"],command:t=>{const e=t.get(h);return()=>e.call(ue.key)}}});o(me.ctx,{displayName:"KeymapCtx<strong>",group:"Strong"});o(me.shortcuts,{displayName:"Keymap<strong>",group:"Strong"});const ge=J("inlineCode");o(ge,{displayName:"Attr<inlineCode>",group:"InlineCode"});const x=Q("inlineCode",t=>({priority:100,code:!0,parseDOM:[{tag:"code"}],toDOM:e=>["code",t.get(ge.key)(e)],parseMarkdown:{match:e=>e.type==="inlineCode",runner:(e,r,a)=>{e.openMark(a),e.addText(r.value),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="inlineCode",runner:(e,r,a)=>{e.withMark(r,"inlineCode",a.text||"")}}}));o(x.mark,{displayName:"MarkSchema<inlineCode>",group:"InlineCode"});o(x.ctx,{displayName:"MarkSchemaCtx<inlineCode>",group:"InlineCode"});const ye=g("ToggleInlineCode",t=>()=>(e,r)=>{const{selection:a,tr:n}=e;if(a.empty)return!1;const{from:s,to:l}=a;return e.doc.rangeHasMark(s,l,x.type(t))?(r==null||r(n.removeMark(s,l,x.type(t))),!0):(Object.keys(e.schema.marks).filter(c=>c!==x.type.name).map(c=>e.schema.marks[c]).forEach(c=>{n.removeMark(s,l,c)}),r==null||r(n.addMark(s,l,x.type(t).create())),!0)});o(ye,{displayName:"Command<toggleInlineCodeCommand>",group:"InlineCode"});const ht=M(t=>Y(/(?:`)([^`]+)(?:`)$/,x.type(t)));o(ht,{displayName:"InputRule<inlineCodeInputRule>",group:"InlineCode"});const he=C("inlineCodeKeymap",{ToggleInlineCode:{shortcuts:"Mod-e",command:t=>{const e=t.get(h);return()=>e.call(ye.key)}}});o(he.ctx,{displayName:"KeymapCtx<inlineCode>",group:"InlineCode"});o(he.shortcuts,{displayName:"Keymap<inlineCode>",group:"InlineCode"});const fe=J("link");o(fe,{displayName:"Attr<link>",group:"Link"});const O=Q("link",t=>({attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},parseDOM:[{tag:"a[href]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw R(e);return{href:e.getAttribute("href"),title:e.getAttribute("title")}}}],toDOM:e=>["a",{...t.get(fe.key)(e),...e.attrs}],parseMarkdown:{match:e=>e.type==="link",runner:(e,r,a)=>{const n=r.url,s=r.title;e.openMark(a,{href:n,title:s}),e.next(r.children),e.closeMark(a)}},toMarkdown:{match:e=>e.type.name==="link",runner:(e,r)=>{e.withMark(r,"link",void 0,{title:r.attrs.title,url:r.attrs.href})}}}));o(O.mark,{displayName:"MarkSchema<link>",group:"Link"});const ft=g("ToggleLink",t=>(e={})=>ne(O.type(t),e));o(ft,{displayName:"Command<toggleLinkCommand>",group:"Link"});const kt=g("UpdateLink",t=>(e={})=>(r,a)=>{if(!a)return!1;let n,s=-1;const{selection:l}=r,{from:i,to:d}=l;if(r.doc.nodesBetween(i,i===d?d+1:d,(y,k)=>{if(O.type(t).isInSet(y.marks))return n=y,s=k,!1}),!n)return!1;const c=n.marks.find(({type:y})=>y===O.type(t));if(!c)return!1;const p=s,u=s+n.nodeSize,{tr:m}=r,f=O.type(t).create({...c.attrs,...e});return f?(a(m.removeMark(p,u,c).addMark(p,u,f).setSelection(new oe(m.selection.$anchor)).scrollIntoView()),!0):!1});o(kt,{displayName:"Command<updateLinkCommand>",group:"Link"});const Nt=ot("doc",()=>({content:"block+",parseMarkdown:{match:({type:t})=>t==="root",runner:(t,e,r)=>{t.injectRoot(e,r)}},toMarkdown:{match:t=>t.type.name==="doc",runner:(t,e)=>{t.openNode("root"),t.next(e.content)}}}));o(Nt,{displayName:"NodeSchema<doc>",group:"Doc"});function Jt(t){return Wt(t,e=>{var r;return e.type==="html"&&["<br />","<br>","<br >","<br/>"].includes((r=e.value)==null?void 0:r.trim())},(e,r)=>{if(!r.length)return;const a=r[r.length-1];if(!a)return;const n=a.children.indexOf(e);n!==-1&&a.children.splice(n,1)},!0)}const Z=T("remark-preserve-empty-line",()=>()=>Jt);o(Z.plugin,{displayName:"Remark<remarkPreserveEmptyLine>",group:"Remark"});o(Z.options,{displayName:"RemarkConfig<remarkPreserveEmptyLine>",group:"Remark"});const ke=I("paragraph");o(ke,{displayName:"Attr<paragraph>",group:"Paragraph"});const B=b("paragraph",t=>({content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:e=>["p",t.get(ke.key)(e),0],parseMarkdown:{match:e=>e.type==="paragraph",runner:(e,r,a)=>{e.openNode(a),r.children?e.next(r.children):e.addText(r.value||""),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="paragraph",runner:(e,r)=>{var a;const s=(a=t.get(it).state)==null?void 0:a.doc.lastChild;e.openNode("paragraph"),(!r.content||r.content.size===0)&&r!==s&&Qt(t)?e.addNode("html",void 0,"<br />"):ut(e,r),e.closeNode()}}}));function Qt(t){let e=!1;try{t.get(Z.id),e=!0}catch{e=!1}return e}o(B.node,{displayName:"NodeSchema<paragraph>",group:"Paragraph"});o(B.ctx,{displayName:"NodeSchemaCtx<paragraph>",group:"Paragraph"});const Ne=g("TurnIntoText",t=>()=>E(B.type(t)));o(Ne,{displayName:"Command<turnIntoTextCommand>",group:"Paragraph"});const Ie=C("paragraphKeymap",{TurnIntoText:{shortcuts:"Mod-Alt-0",command:t=>{const e=t.get(h);return()=>e.call(Ne.key)}}});o(Ie.ctx,{displayName:"KeymapCtx<paragraph>",group:"Paragraph"});o(Ie.shortcuts,{displayName:"Keymap<paragraph>",group:"Paragraph"});const Xt=Array(6).fill(0).map((t,e)=>e+1);function Yt(t){return t.textContent.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-")}const ee=st(Yt,"headingIdGenerator");o(ee,{displayName:"Ctx<HeadingIdGenerator>",group:"Heading"});const Ce=I("heading");o(Ce,{displayName:"Attr<heading>",group:"Heading"});const H=b("heading",t=>{const e=t.get(ee.key);return{content:"inline*",group:"block",defining:!0,attrs:{id:{default:"",validate:"string"},level:{default:1,validate:"number"}},parseDOM:Xt.map(r=>({tag:`h${r}`,getAttrs:a=>{if(!(a instanceof HTMLElement))throw R(a);return{level:r,id:a.id}}})),toDOM:r=>[`h${r.attrs.level}`,{...t.get(Ce.key)(r),id:r.attrs.id||e(r)},0],parseMarkdown:{match:({type:r})=>r==="heading",runner:(r,a,n)=>{const s=a.depth;r.openNode(n,{level:s}),r.next(a.children),r.closeNode()}},toMarkdown:{match:r=>r.type.name==="heading",runner:(r,a)=>{r.openNode("heading",void 0,{depth:a.attrs.level}),ut(r,a),r.closeNode()}}}});o(H.node,{displayName:"NodeSchema<heading>",group:"Heading"});o(H.ctx,{displayName:"NodeSchemaCtx<heading>",group:"Heading"});const It=M(t=>dt(/^(?<hashes>#+)\s$/,H.type(t),e=>{var r,a;const n=((a=(r=e.groups)==null?void 0:r.hashes)==null?void 0:a.length)||0,s=t.get(it),{$from:l}=s.state.selection,i=l.node();if(i.type.name==="heading"){let d=Number(i.attrs.level)+Number(n);return d>6&&(d=6),{level:d}}return{level:n}}));o(It,{displayName:"InputRule<wrapInHeadingInputRule>",group:"Heading"});const v=g("WrapInHeading",t=>e=>(e??(e=1),e<1?E(B.type(t)):E(H.type(t),{level:e})));o(v,{displayName:"Command<wrapInHeadingCommand>",group:"Heading"});const be=g("DowngradeHeading",t=>()=>(e,r,a)=>{const{$from:n}=e.selection,s=n.node();if(s.type!==H.type(t)||!e.selection.empty||n.parentOffset!==0)return!1;const l=s.attrs.level-1;return l?(r==null||r(e.tr.setNodeMarkup(e.selection.$from.before(),void 0,{...s.attrs,level:l})),!0):E(B.type(t))(e,r,a)});o(be,{displayName:"Command<downgradeHeadingCommand>",group:"Heading"});const Me=C("headingKeymap",{TurnIntoH1:{shortcuts:"Mod-Alt-1",command:t=>{const e=t.get(h);return()=>e.call(v.key,1)}},TurnIntoH2:{shortcuts:"Mod-Alt-2",command:t=>{const e=t.get(h);return()=>e.call(v.key,2)}},TurnIntoH3:{shortcuts:"Mod-Alt-3",command:t=>{const e=t.get(h);return()=>e.call(v.key,3)}},TurnIntoH4:{shortcuts:"Mod-Alt-4",command:t=>{const e=t.get(h);return()=>e.call(v.key,4)}},TurnIntoH5:{shortcuts:"Mod-Alt-5",command:t=>{const e=t.get(h);return()=>e.call(v.key,5)}},TurnIntoH6:{shortcuts:"Mod-Alt-6",command:t=>{const e=t.get(h);return()=>e.call(v.key,6)}},DowngradeHeading:{shortcuts:["Delete","Backspace"],command:t=>{const e=t.get(h);return()=>e.call(be.key)}}});o(Me.ctx,{displayName:"KeymapCtx<heading>",group:"Heading"});o(Me.shortcuts,{displayName:"Keymap<heading>",group:"Heading"});const Le=I("blockquote");o(Le,{displayName:"Attr<blockquote>",group:"Blockquote"});const z=b("blockquote",t=>({content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:e=>["blockquote",t.get(Le.key)(e),0],parseMarkdown:{match:({type:e})=>e==="blockquote",runner:(e,r,a)=>{e.openNode(a).next(r.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="blockquote",runner:(e,r)=>{e.openNode("blockquote").next(r.content).closeNode()}}}));o(z.node,{displayName:"NodeSchema<blockquote>",group:"Blockquote"});o(z.ctx,{displayName:"NodeSchemaCtx<blockquote>",group:"Blockquote"});const Ct=M(t=>se(/^\s*>\s$/,z.type(t)));o(Ct,{displayName:"InputRule<wrapInBlockquoteInputRule>",group:"Blockquote"});const ve=g("WrapInBlockquote",t=>()=>le(z.type(t)));o(ve,{displayName:"Command<wrapInBlockquoteCommand>",group:"Blockquote"});const xe=C("blockquoteKeymap",{WrapInBlockquote:{shortcuts:"Mod-Shift-b",command:t=>{const e=t.get(h);return()=>e.call(ve.key)}}});o(xe.ctx,{displayName:"KeymapCtx<blockquote>",group:"Blockquote"});o(xe.shortcuts,{displayName:"Keymap<blockquote>",group:"Blockquote"});const we=I("codeBlock",()=>({pre:{},code:{}}));o(we,{displayName:"Attr<codeBlock>",group:"CodeBlock"});const U=b("code_block",t=>({content:"text*",group:"block",marks:"",defining:!0,code:!0,attrs:{language:{default:"",validate:"string"}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{if(!(e instanceof HTMLElement))throw R(e);return{language:e.dataset.language}}}],toDOM:e=>{const r=t.get(we.key)(e),a=e.attrs.language,n=a&&a.length>0?{"data-language":a}:void 0;return["pre",{...r.pre,...n},["code",r.code,0]]},parseMarkdown:{match:({type:e})=>e==="code",runner:(e,r,a)=>{const n=r.lang??"",s=r.value;e.openNode(a,{language:n}),s&&e.addText(s),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="code_block",runner:(e,r)=>{var a;e.addNode("code",void 0,((a=r.content.firstChild)==null?void 0:a.text)||"",{lang:r.attrs.language})}}}));o(U.node,{displayName:"NodeSchema<codeBlock>",group:"CodeBlock"});o(U.ctx,{displayName:"NodeSchemaCtx<codeBlock>",group:"CodeBlock"});const bt=M(t=>dt(/^```(?<language>[a-z]*)?[\s\n]$/,U.type(t),e=>{var r;return{language:((r=e.groups)==null?void 0:r.language)??""}}));o(bt,{displayName:"InputRule<createCodeBlockInputRule>",group:"CodeBlock"});const Ae=g("CreateCodeBlock",t=>(e="")=>E(U.type(t),{language:e}));o(Ae,{displayName:"Command<createCodeBlockCommand>",group:"CodeBlock"});const Zt=g("UpdateCodeBlockLanguage",()=>({pos:t,language:e}={pos:-1,language:""})=>(r,a)=>t>=0?(a==null||a(r.tr.setNodeAttribute(t,"language",e)),!0):!1);o(Zt,{displayName:"Command<updateCodeBlockLanguageCommand>",group:"CodeBlock"});const Se=C("codeBlockKeymap",{CreateCodeBlock:{shortcuts:"Mod-Alt-c",command:t=>{const e=t.get(h);return()=>e.call(Ae.key)}}});o(Se.ctx,{displayName:"KeymapCtx<codeBlock>",group:"CodeBlock"});o(Se.shortcuts,{displayName:"Keymap<codeBlock>",group:"CodeBlock"});const Re=I("image");o(Re,{displayName:"Attr<image>",group:"Image"});const D=b("image",t=>({inline:!0,group:"inline",selectable:!0,draggable:!0,marks:"",atom:!0,defining:!0,isolating:!0,attrs:{src:{default:"",validate:"string"},alt:{default:"",validate:"string"},title:{default:"",validate:"string"}},parseDOM:[{tag:"img[src]",getAttrs:e=>{if(!(e instanceof HTMLElement))throw R(e);return{src:e.getAttribute("src")||"",alt:e.getAttribute("alt")||"",title:e.getAttribute("title")||e.getAttribute("alt")||""}}}],toDOM:e=>["img",{...t.get(Re.key)(e),...e.attrs}],parseMarkdown:{match:({type:e})=>e==="image",runner:(e,r,a)=>{const n=r.url,s=r.alt,l=r.title;e.addNode(a,{src:n,alt:s,title:l})}},toMarkdown:{match:e=>e.type.name==="image",runner:(e,r)=>{e.addNode("image",void 0,void 0,{title:r.attrs.title,url:r.attrs.src,alt:r.attrs.alt})}}}));o(D.node,{displayName:"NodeSchema<image>",group:"Image"});o(D.ctx,{displayName:"NodeSchemaCtx<image>",group:"Image"});const Mt=g("InsertImage",t=>(e={})=>(r,a)=>{if(!a)return!0;const{src:n="",alt:s="",title:l=""}=e,i=D.type(t).create({src:n,alt:s,title:l});return i&&a(r.tr.replaceSelectionWith(i).scrollIntoView()),!0});o(Mt,{displayName:"Command<insertImageCommand>",group:"Image"});const Lt=g("UpdateImage",t=>(e={})=>(r,a)=>{const n=Et(r.selection,D.type(t));if(!n)return!1;const{node:s,pos:l}=n,i={...s.attrs},{src:d,alt:c,title:p}=e;return d!==void 0&&(i.src=d),c!==void 0&&(i.alt=c),p!==void 0&&(i.title=p),a==null||a(r.tr.setNodeMarkup(l,void 0,i).scrollIntoView()),!0});o(Lt,{displayName:"Command<updateImageCommand>",group:"Image"});const er=M(t=>new ct(/!\[(?<alt>.*?)]\((?<filename>.*?)\s*(?="|\))"?(?<title>[^"]+)?"?\)/,(e,r,a,n)=>{const[s,l,i="",d]=r;return s?e.tr.replaceWith(a,n,D.type(t).create({src:i,alt:l,title:d})):null}));o(er,{displayName:"InputRule<insertImageInputRule>",group:"Image"});const G=I("hardbreak",t=>({"data-type":"hardbreak","data-is-inline":t.attrs.isInline}));o(G,{displayName:"Attr<hardbreak>",group:"Hardbreak"});const S=b("hardbreak",t=>({inline:!0,group:"inline",attrs:{isInline:{default:!1,validate:"boolean"}},selectable:!1,parseDOM:[{tag:"br"},{tag:'span[data-type="hardbreak"]',getAttrs:()=>({isInline:!0})}],toDOM:e=>e.attrs.isInline?["span",t.get(G.key)(e)," "]:["br",t.get(G.key)(e)],parseMarkdown:{match:({type:e})=>e==="break",runner:(e,r,a)=>{var n;e.addNode(a,{isInline:!!((n=r.data)!=null&&n.isInline)})}},leafText:()=>`
|
|
2
|
-
`,toMarkdown:{match:e=>e.type.name==="hardbreak",runner:(e,r)=>{r.attrs.isInline?e.addNode("text",void 0,`
|
|
3
|
-
`):e.addNode("break")}}}));o(S.node,{displayName:"NodeSchema<hardbreak>",group:"Hardbreak"});o(S.ctx,{displayName:"NodeSchemaCtx<hardbreak>",group:"Hardbreak"});const Be=g("InsertHardbreak",t=>()=>(e,r)=>{var a;const{selection:n,tr:s}=e;if(!(n instanceof oe))return!1;if(n.empty){const l=n.$from.node();if(l.childCount>0&&((a=l.lastChild)==null?void 0:a.type.name)==="hardbreak")return r==null||r(s.replaceRangeWith(n.to-1,n.to,e.schema.node("paragraph")).setSelection(ae.near(s.doc.resolve(n.to))).scrollIntoView()),!0}return r==null||r(s.setMeta("hardbreak",!0).replaceSelectionWith(S.type(t).create()).scrollIntoView()),!0});o(Be,{displayName:"Command<insertHardbreakCommand>",group:"Hardbreak"});const He=C("hardbreakKeymap",{InsertHardbreak:{shortcuts:"Shift-Enter",command:t=>{const e=t.get(h);return()=>e.call(Be.key)}}});o(He.ctx,{displayName:"KeymapCtx<hardbreak>",group:"Hardbreak"});o(He.shortcuts,{displayName:"Keymap<hardbreak>",group:"Hardbreak"});const Oe=I("hr");o(Oe,{displayName:"Attr<hr>",group:"Hr"});const j=b("hr",t=>({group:"block",parseDOM:[{tag:"hr"}],toDOM:e=>["hr",t.get(Oe.key)(e)],parseMarkdown:{match:({type:e})=>e==="thematicBreak",runner:(e,r,a)=>{e.addNode(a)}},toMarkdown:{match:e=>e.type.name==="hr",runner:e=>{e.addNode("thematicBreak")}}}));o(j.node,{displayName:"NodeSchema<hr>",group:"Hr"});o(j.ctx,{displayName:"NodeSchemaCtx<hr>",group:"Hr"});const vt=M(t=>new ct(/^(?:---|___\s|\*\*\*\s)$/,(e,r,a,n)=>{const{tr:s}=e;return r[0]&&s.replaceWith(a-1,n,j.type(t).create()),s}));o(vt,{displayName:"InputRule<insertHrInputRule>",group:"Hr"});const xt=g("InsertHr",t=>()=>(e,r)=>{if(!r)return!0;const a=B.node.type(t).create(),{tr:n,selection:s}=e,{from:l}=s,i=j.type(t).create();if(!i)return!0;const d=n.replaceSelectionWith(i).insert(l,a),c=ae.findFrom(d.doc.resolve(l),1,!0);return c&&r(d.setSelection(c).scrollIntoView()),!0});o(xt,{displayName:"Command<insertHrCommand>",group:"Hr"});const Te=I("bulletList");o(Te,{displayName:"Attr<bulletList>",group:"BulletList"});const _=b("bullet_list",t=>({content:"listItem+",group:"block",attrs:{spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ul",getAttrs:e=>{if(!(e instanceof HTMLElement))throw R(e);return{spread:e.dataset.spread==="true"}}}],toDOM:e=>["ul",{...t.get(Te.key)(e),"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:r})=>e==="list"&&!r,runner:(e,r,a)=>{const n=r.spread!=null?`${r.spread}`:"false";e.openNode(a,{spread:n}).next(r.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="bullet_list",runner:(e,r)=>{e.openNode("list",void 0,{ordered:!1,spread:r.attrs.spread}).next(r.content).closeNode()}}}));o(_.node,{displayName:"NodeSchema<bulletList>",group:"BulletList"});o(_.ctx,{displayName:"NodeSchemaCtx<bulletList>",group:"BulletList"});const wt=M(t=>se(/^\s*([-+*])\s$/,_.type(t)));o(wt,{displayName:"InputRule<wrapInBulletListInputRule>",group:"BulletList"});const Ke=g("WrapInBulletList",t=>()=>le(_.type(t)));o(Ke,{displayName:"Command<wrapInBulletListCommand>",group:"BulletList"});const De=C("bulletListKeymap",{WrapInBulletList:{shortcuts:"Mod-Alt-8",command:t=>{const e=t.get(h);return()=>e.call(Ke.key)}}});o(De.ctx,{displayName:"KeymapCtx<bulletListKeymap>",group:"BulletList"});o(De.shortcuts,{displayName:"Keymap<bulletListKeymap>",group:"BulletList"});const _e=I("orderedList");o(_e,{displayName:"Attr<orderedList>",group:"OrderedList"});const P=b("ordered_list",t=>({content:"listItem+",group:"block",attrs:{order:{default:1,validate:"number"},spread:{default:!1,validate:"boolean"}},parseDOM:[{tag:"ol",getAttrs:e=>{if(!(e instanceof HTMLElement))throw R(e);return{spread:e.dataset.spread,order:e.hasAttribute("start")?Number(e.getAttribute("start")):1}}}],toDOM:e=>["ol",{...t.get(_e.key)(e),...e.attrs.order===1?{}:e.attrs.order,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e,ordered:r})=>e==="list"&&!!r,runner:(e,r,a)=>{const n=r.spread!=null?`${r.spread}`:"true";e.openNode(a,{spread:n}).next(r.children).closeNode()}},toMarkdown:{match:e=>e.type.name==="ordered_list",runner:(e,r)=>{e.openNode("list",void 0,{ordered:!0,start:1,spread:r.attrs.spread==="true"}),e.next(r.content),e.closeNode()}}}));o(P.node,{displayName:"NodeSchema<orderedList>",group:"OrderedList"});o(P.ctx,{displayName:"NodeSchemaCtx<orderedList>",group:"OrderedList"});const At=M(t=>se(/^\s*(\d+)\.\s$/,P.type(t),e=>({order:Number(e[1])}),(e,r)=>r.childCount+r.attrs.order===Number(e[1])));o(At,{displayName:"InputRule<wrapInOrderedListInputRule>",group:"OrderedList"});const Pe=g("WrapInOrderedList",t=>()=>le(P.type(t)));o(Pe,{displayName:"Command<wrapInOrderedListCommand>",group:"OrderedList"});const Ee=C("orderedListKeymap",{WrapInOrderedList:{shortcuts:"Mod-Alt-7",command:t=>{const e=t.get(h);return()=>e.call(Pe.key)}}});o(Ee.ctx,{displayName:"KeymapCtx<orderedList>",group:"OrderedList"});o(Ee.shortcuts,{displayName:"Keymap<orderedList>",group:"OrderedList"});const $e=I("listItem");o($e,{displayName:"Attr<listItem>",group:"ListItem"});const L=b("list_item",t=>({group:"listItem",content:"paragraph block*",attrs:{label:{default:"•",validate:"string"},listType:{default:"bullet",validate:"string"},spread:{default:!0,validate:"boolean"}},defining:!0,parseDOM:[{tag:"li",getAttrs:e=>{if(!(e instanceof HTMLElement))throw R(e);return{label:e.dataset.label,listType:e.dataset.listType,spread:e.dataset.spread==="true"}}}],toDOM:e=>["li",{...t.get($e.key)(e),"data-label":e.attrs.label,"data-list-type":e.attrs.listType,"data-spread":e.attrs.spread},0],parseMarkdown:{match:({type:e})=>e==="listItem",runner:(e,r,a)=>{const n=r.label!=null?`${r.label}.`:"•",s=r.label!=null?"ordered":"bullet",l=r.spread!=null?`${r.spread}`:"true";e.openNode(a,{label:n,listType:s,spread:l}),e.next(r.children),e.closeNode()}},toMarkdown:{match:e=>e.type.name==="list_item",runner:(e,r)=>{e.openNode("listItem",void 0,{spread:r.attrs.spread}),e.next(r.content),e.closeNode()}}}));o(L.node,{displayName:"NodeSchema<listItem>",group:"ListItem"});o(L.ctx,{displayName:"NodeSchemaCtx<listItem>",group:"ListItem"});const qe=g("SinkListItem",t=>()=>Ut(L.type(t)));o(qe,{displayName:"Command<sinkListItemCommand>",group:"ListItem"});const We=g("LiftListItem",t=>()=>pt(L.type(t)));o(We,{displayName:"Command<liftListItemCommand>",group:"ListItem"});const Fe=g("SplitListItem",t=>()=>Ft(L.type(t)));o(Fe,{displayName:"Command<splitListItemCommand>",group:"ListItem"});function tr(t){return(e,r,a)=>{const{selection:n}=e;if(!(n instanceof oe))return!1;const{empty:s,$from:l}=n;if(!s||l.parentOffset!==0)return!1;const i=l.node(-1);return i.type!==L.type(t)||i.firstChild!==l.node()||l.node(-2).childCount>1?!1:pt(L.type(t))(e,r,a)}}const Ve=g("LiftFirstListItem",t=>()=>tr(t));o(Ve,{displayName:"Command<liftFirstListItemCommand>",group:"ListItem"});const ze=C("listItemKeymap",{NextListItem:{shortcuts:"Enter",command:t=>{const e=t.get(h);return()=>e.call(Fe.key)}},SinkListItem:{shortcuts:["Tab","Mod-]"],command:t=>{const e=t.get(h);return()=>e.call(qe.key)}},LiftListItem:{shortcuts:["Shift-Tab","Mod-["],command:t=>{const e=t.get(h);return()=>e.call(We.key)}},LiftFirstListItem:{shortcuts:["Backspace","Delete"],command:t=>{const e=t.get(h);return()=>e.call(Ve.key)}}});o(ze.ctx,{displayName:"KeymapCtx<listItem>",group:"ListItem"});o(ze.shortcuts,{displayName:"Keymap<listItem>",group:"ListItem"});const St=ot("text",()=>({group:"inline",parseMarkdown:{match:({type:t})=>t==="text",runner:(t,e)=>{t.addText(e.value)}},toMarkdown:{match:t=>t.type.name==="text",runner:(t,e)=>{t.addNode("text",void 0,e.text)}}}));o(St,{displayName:"NodeSchema<text>",group:"Text"});const Ue=I("html");o(Ue,{displayName:"Attr<html>",group:"Html"});const je=b("html",t=>({atom:!0,group:"inline",inline:!0,attrs:{value:{default:"",validate:"string"}},toDOM:e=>{const r=document.createElement("span"),a={...t.get(Ue.key)(e),"data-value":e.attrs.value,"data-type":"html"};return r.textContent=e.attrs.value,["span",a,e.attrs.value]},parseDOM:[{tag:'span[data-type="html"]',getAttrs:e=>({value:e.dataset.value??""})}],parseMarkdown:{match:({type:e})=>e==="html",runner:(e,r,a)=>{e.addNode(a,{value:r.value})}},toMarkdown:{match:e=>e.type.name==="html",runner:(e,r)=>{e.addNode("html",void 0,r.attrs.value)}}}));o(je.node,{displayName:"NodeSchema<html>",group:"Html"});o(je.ctx,{displayName:"NodeSchemaCtx<html>",group:"Html"});const rr=[Nt,ke,B,ee,Ce,H,G,S,Le,z,we,U,Oe,j,Re,D,Te,_,_e,P,$e,L,ie,K,pe,V,ge,x,fe,O,Ue,je,St].flat(),ar=[Ct,wt,At,bt,vt,It].flat(),nr=[mt,gt,ht,yt],or=[Ne,ve,v,be,Ae,Be,xt,Mt,Lt,Pe,Ke,qe,Fe,We,Ve,de,ye,ue,ft,kt],sr=[xe,Se,He,Me,ze,Ee,De,Ie,ce,he,me].flat(),Ge=T("remarkAddOrderInList",()=>()=>t=>{q(t,"list",e=>{if(e.ordered){const r=e.start??1;e.children.forEach((a,n)=>{a.label=n+r})}})});o(Ge.plugin,{displayName:"Remark<remarkAddOrderInListPlugin>",group:"Remark"});o(Ge.options,{displayName:"RemarkConfig<remarkAddOrderInListPlugin>",group:"Remark"});const Je=T("remarkLineBreak",()=>()=>t=>{const e=/[\t ]*(?:\r?\n|\r)/g;q(t,"text",(r,a,n)=>{if(!r.value||typeof r.value!="string")return;const s=[];let l=0;e.lastIndex=0;let i=e.exec(r.value);for(;i;){const c=i.index;l!==c&&s.push({type:"text",value:r.value.slice(l,c)}),s.push({type:"break",data:{isInline:!0}}),l=c+i[0].length,i=e.exec(r.value)}if(s.length>0&&n&&typeof a=="number")return l<r.value.length&&s.push({type:"text",value:r.value.slice(l)}),n.children.splice(a,1,...s),a+s.length})});o(Je.plugin,{displayName:"Remark<remarkLineBreak>",group:"Remark"});o(Je.options,{displayName:"RemarkConfig<remarkLineBreak>",group:"Remark"});const Qe=T("remarkInlineLink",()=>Gt);o(Qe.plugin,{displayName:"Remark<remarkInlineLinkPlugin>",group:"Remark"});o(Qe.options,{displayName:"RemarkConfig<remarkInlineLinkPlugin>",group:"Remark"});const lr=t=>!!t.children,ir=t=>t.type==="html";function dr(t,e){return r(t,0,null)[0];function r(a,n,s){if(lr(a)){const l=[];for(let i=0,d=a.children.length;i<d;i++){const c=a.children[i];if(c){const p=r(c,i,a);if(p)for(let u=0,m=p.length;u<m;u++){const f=p[u];f&&l.push(f)}}}a.children=l}return e(a,n,s)}}const Xe=T("remarkHTMLTransformer",()=>()=>t=>{dr(t,(e,r,a)=>ir(e)?((a==null?void 0:a.type)==="root"&&(e.children=[{...e}],delete e.value,e.type="paragraph"),[e]):[e])});o(Xe.plugin,{displayName:"Remark<remarkHtmlTransformer>",group:"Remark"});o(Xe.options,{displayName:"RemarkConfig<remarkHtmlTransformer>",group:"Remark"});const Ye=T("remarkMarker",()=>()=>(t,e)=>{const r=a=>e.value.charAt(a.position.start.offset);q(t,a=>["strong","emphasis"].includes(a.type),a=>{a.marker=r(a)})});o(Ye.plugin,{displayName:"Remark<remarkMarker>",group:"Remark"});o(Ye.options,{displayName:"RemarkConfig<remarkMarker>",group:"Remark"});const Rt=$(()=>{let t=!1;const e=new W("MILKDOWN_INLINE_NODES_CURSOR"),r=new F({key:e,state:{init(){return!1},apply(a){if(!a.selection.empty)return!1;const n=a.selection.$from,s=n.nodeBefore,l=n.nodeAfter;return!!(s&&l&&s.isInline&&!s.isText&&l.isInline&&!l.isText)}},props:{handleDOMEvents:{compositionend:(a,n)=>t?(t=!1,requestAnimationFrame(()=>{if(r.getState(a.state)){const l=a.state.selection.from;n.preventDefault(),a.dispatch(a.state.tr.insertText(n.data||"",l))}}),!0):!1,compositionstart:a=>(r.getState(a.state)&&(t=!0),!1),beforeinput:(a,n)=>{if(r.getState(a.state)&&n instanceof InputEvent&&n.data&&!t){const l=a.state.selection.from;return n.preventDefault(),a.dispatch(a.state.tr.insertText(n.data||"",l)),!0}return!1}},decorations(a){if(r.getState(a)){const l=a.selection.$from.pos,i=document.createElement("span"),d=rt.widget(l,i,{side:-1}),c=document.createElement("span"),p=rt.widget(l,c);return setTimeout(()=>{i.contentEditable="true",c.contentEditable="true"}),at.create(a.doc,[d,p])}return at.empty}}});return r});o(Rt,{displayName:"Prose<inlineNodesCursorPlugin>",group:"Prose"});const Bt=$(t=>new F({key:new W("MILKDOWN_HARDBREAK_MARKS"),appendTransaction:(e,r,a)=>{if(!e.length)return;const[n]=e;if(!n)return;const[s]=n.steps;if(n.getMeta("hardbreak")){if(!(s instanceof $t))return;const{from:d}=s;return a.tr.setNodeMarkup(d,S.type(t),void 0,[])}if(s instanceof qt){let d=a.tr;const{from:c,to:p}=s;return a.doc.nodesBetween(c,p,(u,m)=>{u.type===S.type(t)&&(d=d.setNodeMarkup(m,S.type(t),void 0,[]))}),d}}}));o(Bt,{displayName:"Prose<hardbreakClearMarkPlugin>",group:"Prose"});const Ze=st(["table","code_block"],"hardbreakFilterNodes");o(Ze,{displayName:"Ctx<hardbreakFilterNodes>",group:"Prose"});const Ht=$(t=>{const e=t.get(Ze.key);return new F({key:new W("MILKDOWN_HARDBREAK_FILTER"),filterTransaction:(r,a)=>{const n=r.getMeta("hardbreak"),[s]=r.steps;if(n&&s){const{from:l}=s,i=a.doc.resolve(l);let d=i.depth,c=!0;for(;d>0;)e.includes(i.node(d).type.name)&&(c=!1),d--;return c}return!0}})});o(Ht,{displayName:"Prose<hardbreakFilterPlugin>",group:"Prose"});const Ot=$(t=>{const e=new W("MILKDOWN_HEADING_ID"),r=a=>{if(a.composing)return;const n=t.get(ee.key),s=a.state.tr.setMeta("addToHistory",!1);let l=!1;const i={};a.state.doc.descendants((d,c)=>{if(d.type===H.type(t)){if(d.textContent.trim().length===0)return;const p=d.attrs;let u=n(d);i[u]?(i[u]+=1,u+=`-#${i[u]}`):i[u]=1,p.id!==u&&(l=!0,s.setMeta(e,!0).setNodeMarkup(c,void 0,{...p,id:u}))}}),l&&a.dispatch(s)};return new F({key:e,view:a=>(r(a),{update:(n,s)=>{n.state.doc.eq(s.doc)||r(n)}})})});o(Ot,{displayName:"Prose<syncHeadingIdPlugin>",group:"Prose"});const Tt=$(t=>{const e=r=>{if(r.composing||!r.editable)return;const a=P.type(t),n=_.type(t),s=L.type(t),l=r.state,i=(p,u)=>{let m=!1;const f=`${u+1}.`;return p.label!==f&&(p.label=f,m=!0),m};let d=l.tr,c=!1;l.doc.descendants((p,u,m,f)=>{if(p.type===n){const y=p.maybeChild(0);(y==null?void 0:y.type)===s&&y.attrs.listType==="ordered"&&(c=!0,d.setNodeMarkup(u,a,{spread:"true"}),p.descendants((k,w,A,te)=>{if(k.type===s){const et={...k.attrs};i(et,te)&&(d=d.setNodeMarkup(w,void 0,et))}return!1}))}else if(p.type===s&&(m==null?void 0:m.type)===a){const y={...p.attrs};let k=!1;y.listType!=="ordered"&&(y.listType="ordered",k=!0),(m==null?void 0:m.maybeChild(0))&&(k=i(y,f)),k&&(d=d.setNodeMarkup(u,void 0,y),c=!0)}}),c&&r.dispatch(d.setMeta("addToHistory",!1))};return new F({key:new W("MILKDOWN_KEEP_LIST_ORDER"),view:r=>(e(r),{update:a=>{e(a)}})})});o(Tt,{displayName:"Prose<syncListOrderPlugin>",group:"Prose"});const cr=[Bt,Ze,Ht,Rt,Ge,Qe,Je,Xe,Ye,Z,Ot,Tt].flat(),yr=[rr,ar,nr,or,sr,cr].flat();export{Le as blockquoteAttr,xe as blockquoteKeymap,z as blockquoteSchema,Te as bulletListAttr,De as bulletListKeymap,_ as bulletListSchema,we as codeBlockAttr,Se as codeBlockKeymap,U as codeBlockSchema,or as commands,yr as commonmark,Ae as createCodeBlockCommand,bt as createCodeBlockInputRule,Nt as docSchema,be as downgradeHeadingCommand,ie as emphasisAttr,ce as emphasisKeymap,K as emphasisSchema,mt as emphasisStarInputRule,gt as emphasisUnderscoreInputRule,G as hardbreakAttr,Bt as hardbreakClearMarkPlugin,Ze as hardbreakFilterNodes,Ht as hardbreakFilterPlugin,He as hardbreakKeymap,S as hardbreakSchema,Ce as headingAttr,ee as headingIdGenerator,Me as headingKeymap,H as headingSchema,Oe as hrAttr,j as hrSchema,Ue as htmlAttr,je as htmlSchema,Re as imageAttr,D as imageSchema,ge as inlineCodeAttr,ht as inlineCodeInputRule,he as inlineCodeKeymap,x as inlineCodeSchema,Rt as inlineNodesCursorPlugin,ar as inputRules,Be as insertHardbreakCommand,xt as insertHrCommand,vt as insertHrInputRule,Mt as insertImageCommand,er as insertImageInputRule,sr as keymap,Ve as liftFirstListItemCommand,We as liftListItemCommand,fe as linkAttr,O as linkSchema,$e as listItemAttr,ze as listItemKeymap,L as listItemSchema,nr as markInputRules,_e as orderedListAttr,Ee as orderedListKeymap,P as orderedListSchema,ke as paragraphAttr,Ie as paragraphKeymap,B as paragraphSchema,cr as plugins,Ge as remarkAddOrderInListPlugin,Xe as remarkHtmlTransformer,Qe as remarkInlineLinkPlugin,Je as remarkLineBreak,Ye as remarkMarker,Z as remarkPreserveEmptyLinePlugin,rr as schema,qe as sinkListItemCommand,Fe as splitListItemCommand,pe as strongAttr,yt as strongInputRule,me as strongKeymap,V as strongSchema,Ot as syncHeadingIdPlugin,Tt as syncListOrderPlugin,St as textSchema,de as toggleEmphasisCommand,ye as toggleInlineCodeCommand,ft as toggleLinkCommand,ue as toggleStrongCommand,Ne as turnIntoTextCommand,Zt as updateCodeBlockLanguageCommand,Lt as updateImageCommand,kt as updateLinkCommand,ve as wrapInBlockquoteCommand,Ct as wrapInBlockquoteInputRule,Ke as wrapInBulletListCommand,wt as wrapInBulletListInputRule,v as wrapInHeadingCommand,It as wrapInHeadingInputRule,Pe as wrapInOrderedListCommand,At as wrapInOrderedListInputRule};
|
package/dist/index5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{B as e}from"./index2.js";import"./index.js";function i(r){var n,o,t="";if(typeof r=="string"||typeof r=="number")t+=r;else if(typeof r=="object")if(Array.isArray(r)){var s=r.length;for(n=0;n<s;n++)r[n]&&(o=i(r[n]))&&(t&&(t+=" "),t+=o)}else for(o in r)r[o]&&(t&&(t+=" "),t+=o);return t}function a(){for(var r,n,o=0,t="",s=arguments.length;o<s;o++)(r=arguments[o])&&(n=i(r))&&(t&&(t+=" "),t+=n);return t}function l(r){r.update(e,n=>{const o=n.attributes;return{...n,attributes:t=>{const s=typeof o=="function"?o(t):o;return{...s,class:a("prose dark:prose-invert",(s==null?void 0:s.class)||"","milkdown-theme-nord")}}}})}export{l as nord};
|
package/dist/index6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as D,C as k,G as y,H as M,J as S,K as P,L as H,h as f,j as h,M as R,s as L,O as b,b as j,Q as N,U,V as F,p as m,W,X as E,Y as K,Z as p,_ as C,I as G,$ as O,a0 as V,a1 as A,a2 as z,a3 as $,a4 as v,a5 as T,a6 as J,a7 as Q}from"./index2.js";import"./index.js";let X=n=>crypto.getRandomValues(new Uint8Array(n)),Y=(n,s,r)=>{let e=(2<<Math.log2(n.length-1))-1,t=-~(1.6*e*s/n.length);return(a=s)=>{let o="";for(;;){let i=r(t),u=t|0;for(;u--;)if(o+=n[i[u]&e]||"",o.length>=a)return o}}},Z=(n,s=21)=>Y(n,s|0,X);const _=Z("abcedfghicklmn",10);function g(n,s,r){const e=H(r||_());let t=!1;const a=o=>(o.record(e),o.update(s,i=>i.concat(e)),async()=>{const u=await n(o,a,()=>{o.done(e),t=!0});return t||o.done(e),()=>{if(o.update(s,c=>c.filter(l=>l!==e)),o.clearTimer(e),u){const c=u();c&&"then"in c&&c.catch(console.error)}}});return a.timer=e,a}function ne(n,s){const r=E(n),e=t=>async()=>{e.key=r,await t.wait(K);const a=s(t);return t.get(f).create(r,a),e.run=o=>t.get(f).call(n,o),()=>{t.get(f).remove(r)}};return e}function re(n,s,r){const e=E(n);return g(async(t,a)=>{await t.wait(K);const o=await s(t);return t.get(f).create(e,o),a.run=i=>t.get(f).call(n,i),a.key=e,()=>{t.get(f).remove(e)}},J,r)}function ae(n){const s=r=>async()=>{await r.wait(p);const e=n(r);return r.update(C,t=>[...t,e]),s.inputRule=e,()=>{r.update(C,t=>t.filter(a=>a!==e))}};return s}function se(n,s){return g(async(r,e)=>{await r.wait(p);const t=await n(r);return r.update(C,a=>[...a,t]),e.inputRule=t,()=>{r.update(C,a=>a.filter(o=>o!==t))}},A,s)}function q(n,s){const r=e=>async()=>{const t=s(e);return e.update(S,a=>[...a.filter(o=>o[0]!==n),[n,t]]),r.id=n,r.schema=t,()=>{e.update(S,a=>a.filter(([o])=>o!==n))}};return r.type=e=>{const t=e.get(y).marks[n];if(!t)throw P(n);return t},r}function oe(n,s,r){const e=g(async(t,a,o)=>{const i=await s(t);return t.update(S,u=>[...u.filter(c=>c[0]!==n),[n,i]]),a.id=n,a.schema=i,o(),()=>{t.update(S,u=>u.filter(([c])=>c!==n))}},V,r);return e.type=t=>{const a=t.get(y).marks[n];if(!a)throw P(n);return a},e}function B(n,s){const r=e=>async()=>{const t=s(e);return e.update(k,a=>[...a.filter(o=>o[0]!==n),[n,t]]),r.id=n,r.schema=t,()=>{e.update(k,a=>a.filter(([o])=>o!==n))}};return r.type=e=>{const t=e.get(y).nodes[n];if(!t)throw M(n);return t},r}function ie(n,s,r){const e=g(async(t,a,o)=>{const i=await s(t);return t.update(k,u=>[...u.filter(c=>c[0]!==n),[n,i]]),a.id=n,a.schema=i,o(),()=>{t.update(k,u=>u.filter(([c])=>c!==n))}},V,r);return e.type=t=>{const a=t.get(y).nodes[n];if(!a)throw M(n);return a},e}function ce(n){let s;const r=e=>async()=>(await e.wait(p),s=n(e),e.update(m,t=>[...t,s]),()=>{e.update(m,t=>t.filter(a=>a!==s))});return r.plugin=()=>s,r.key=()=>s.spec.key,r}function ue(n,s){let r;const e=g(async t=>(await t.wait(p),r=await n(t),t.update(m,a=>[...a,r]),()=>{t.update(m,a=>a.filter(o=>o!==r))}),A,s);return e.plugin=()=>r,e.key=()=>r.spec.key,e}function x(n){const s=r=>async()=>{await r.wait(p);const e=n(r),t=z(e);return r.update(m,a=>[...a,t]),s.keymap=e,()=>{r.update(m,a=>a.filter(o=>o!==t))}};return s}function le(n,s){return g(async(r,e)=>{await r.wait(p);const t=await n(r),a=z(t);return r.update(m,o=>[...o,a]),e.keymap=t,()=>{r.update(m,o=>o.filter(i=>i!==a))}},A,s)}function me(n,s){const r=e=>async()=>{await e.wait(p);const t=s(e);return n.type(e)instanceof $?e.update(v,a=>[...a,[n.id,t]]):e.update(T,a=>[...a,[n.id,t]]),r.view=t,r.type=n,()=>{n.type(e)instanceof $?e.update(v,a=>a.filter(o=>o[0]!==n.id)):e.update(T,a=>a.filter(o=>o[0]!==n.id))}};return r}function pe(n,s,r){return g(async(e,t)=>{await e.wait(p);const a=await s(e);return n.type(e)instanceof $?e.update(v,o=>[...o,[n.id,a]]):e.update(T,o=>[...o,[n.id,a]]),t.view=a,t.type=n,()=>{n.type(e)instanceof $?e.update(v,o=>o.filter(i=>i[0]!==n.id)):e.update(T,o=>o.filter(i=>i[0]!==n.id))}},Q,r)}function w(n,s){const r=D(n,s),e=t=>(t.inject(r),()=>()=>{t.remove(r)});return e.key=r,e}function de(n,s){const r=w(s,n),e=B(n,a=>a.get(r.key)(a)),t=[r,e];return t.id=e.id,t.node=e,t.type=a=>e.type(a),t.schema=e.schema,t.ctx=r,t.key=r.key,t.extendSchema=a=>o=>()=>{const i=o.get(r.key),c=a(i)(o);o.update(k,l=>[...l.filter(d=>d[0]!==n),[n,c]]),t.schema=c},t}function fe(n,s){const r=w(s,n),e=q(n,a=>a.get(r.key)(a)),t=[r,e];return t.id=e.id,t.mark=e,t.type=e.type,t.schema=e.schema,t.ctx=r,t.key=r.key,t.extendSchema=a=>o=>()=>{const i=o.get(r.key),c=a(i)(o);o.update(S,l=>[...l.filter(d=>d[0]!==n),[n,c]]),t.schema=c},t}function ye(n,s){const r=Object.fromEntries(Object.entries(s).map(([o,{shortcuts:i}])=>[o,i])),e=w(r,`${n}Keymap`),t=x(o=>{const i=o.get(e.key),u=Object.entries(s).flatMap(([c,{command:l}])=>[i[c]].flat().map(I=>[I,l(o)]));return Object.fromEntries(u)}),a=[e,t];return a.ctx=e,a.shortcuts=t,a.key=e.key,a.keymap=t.keymap,a}const he=(n,s=()=>({}))=>w(s,`${n}Attr`),ge=(n,s=()=>({}))=>w(s,`${n}Attr`);function we(n,s,r){const e=w(r??{},n),t=o=>async()=>{await o.wait(G);const u={plugin:s(o),options:o.get(e.key)};return o.update(O,c=>[...c,u]),()=>{o.update(O,c=>c.filter(l=>l!==u))}},a=[e,t];return a.id=n,a.plugin=t,a.options=e,a}function ke(n,s){return r=>r.get(f).call(n,s)}function Se(){return n=>{const s=n.get(h),{tr:r}=s.state,e=Object.assign(Object.create(r),r).setTime(Date.now());return s.dispatch(e)}}function Ce(){return n=>{const s=document.createElement("div"),r=n.get(y),e=n.get(h),t=R.fromSchema(r).serializeFragment(e.state.doc.content);return s.appendChild(t),s.innerHTML}}function $e(){return n=>{const s=n.get(h);return n.get(L)(s.state.doc)}}function ve(n,s=!1){return r=>{const e=r.get(h),a=r.get(b)(n);if(!a)return;if(!s){const d=e.state.selection.content();return e.dispatch(e.state.tr.replaceSelection(new j(a.content,d.openStart,d.openEnd)).scrollIntoView())}const o=r.get(y),i=R.fromSchema(o).serializeFragment(a.content),c=N.fromSchema(o).parseSlice(i),l=U(c);if(l){e.dispatch(e.state.tr.replaceSelectionWith(l,!0));return}e.dispatch(e.state.tr.replaceSelection(c))}}function Te(){return n=>{const s=n.get(h),r=[];return s.state.doc.descendants(t=>{t.type.name==="heading"&&t.attrs.level&&r.push({text:t.textContent,level:t.attrs.level,id:t.attrs.id})}),r}}function Ae(n,s=!1){return r=>{const e=r.get(h),a=r.get(b)(n);if(!a)return;if(!s){const{state:l}=e;return e.dispatch(l.tr.replace(0,l.doc.content.size,new j(a.content,0,0)))}const o=r.get(y),i=r.get(F),u=r.get(m),c=W.create({schema:o,doc:a,plugins:u,...i});e.updateState(c)}}function Oe(n,s){return r=>{const e=r.get(h),{tr:t}=e.state,a=t.doc.nodeAt(n);if(!a)return;const o=s(a.attrs);return e.dispatch(t.setNodeMarkup(n,void 0,o))}}const Me=(...n)=>{const s=n.length;let r=s;for(;r--;)if(typeof n[r]!="function")throw new TypeError("Expected a function");return(...e)=>{let t=0,a=s?n[t](...e):e[0];for(;++t<s;)a=n[t](a);return a}};export{ne as $command,re as $commandAsync,w as $ctx,ae as $inputRule,se as $inputRuleAsync,q as $mark,oe as $markAsync,ge as $markAttr,fe as $markSchema,B as $node,ie as $nodeAsync,he as $nodeAttr,de as $nodeSchema,ce as $prose,ue as $proseAsync,we as $remark,x as $shortcut,le as $shortcutAsync,ye as $useKeymap,me as $view,pe as $viewAsync,g as addTimer,ke as callCommand,Se as forceUpdate,Ce as getHTML,$e as getMarkdown,ve as insert,_ as nanoid,Te as outline,Me as pipe,Ae as replaceAll,Oe as setAttr};
|