2 lines
9.1 KiB
JavaScript
2 lines
9.1 KiB
JavaScript
|
|
import{E as x,h as w,P as z,l as G}from"./cm-state-X9WpHEQO.js";import{E as K,k as _}from"./cm-view-CiSFjroV.js";import{p as j,o as Q,s as A,q as J,c as N,i as Y,f as F,d as Z,r as W,t as D,P as ee}from"./cm-language-CDsY7zq0.js";import{C as te}from"./cm-autocomplete-t9rzw_D0.js";import{M as re,p as ne,a as oe,G as ie,S as le,b as se,E as ae}from"./vendor-lezer-markdown-DG8DLr3V.js";import{html as fe,htmlCompletionSource as me}from"./cm-lang-html-BwlfE-a6.js";import{N as ue}from"./vendor-lezer-common-tVQBIsvN.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-Bs6eFhZE.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-DuEf3ZFH.js";import"./vendor-lezer-html-D-6QB8dd.js";import"./vendor-lezer-lr-eZ5kYecM.js";import"./cm-lang-css-NVaY7c0M.js";import"./vendor-lezer-css-BMlSRxbI.js";import"./cm-lang-javascript-E0JyLAes.js";import"./vendor-lezer-javascript-BsA5KTFy.js";const R=Q({commentTokens:{block:{open:"<!--",close:"-->"}}}),$=new ue,H=oe.configure({props:[F.add(r=>!r.is("Block")||r.is("Document")||P(r)!=null||ce(r)?void 0:(n,o)=>({from:o.doc.lineAt(n.from).to,to:n.to})),$.add(P),Z.add({Document:()=>null}),W.add({Document:R})]});function P(r){let n=/^(?:ATX|Setext)Heading(\d)$/.exec(r.name);return n?+n[1]:void 0}function ce(r){return r.name=="OrderedList"||r.name=="BulletList"}function pe(r,n){let o=r;for(;;){let t=o.nextSibling,e;if(!t||(e=P(t.type))!=null&&e<=n)break;o=t}return o.to}const de=J.of((r,n,o)=>{for(let t=A(r).resolveInner(o,-1);t&&!(t.from<n);t=t.parent){let e=t.type.prop($);if(e==null)continue;let i=pe(t,e);if(i>o)return{from:o,to:i}}return null});function E(r){return new j(R,r,[],"markdown")}const he=E(H),ge=H.configure([ie,le,se,ae,{props:[F.add({Table:(r,n)=>({from:n.doc.lineAt(r.from).to,to:r.to})})]}]),b=E(ge);function ke(r,n){return o=>{if(o&&r){let t=null;if(o=/\S*/.exec(o)[0],typeof r=="function"?t=r(o):t=D.matchLanguageName(r,o,!0),t instanceof D)return t.support?t.support.language.parser:ee.getSkippingParser(t.load());if(t)return t.parser}return n?n.parser:null}}class v{constructor(n,o,t,e,i,f,m){this.node=n,this.from=o,this.to=t,this.spaceBefore=e,this.spaceAfter=i,this.type=f,this.item=m}blank(n,o=!0){let t=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(n!=null){for(;t.length<n;)t+=" ";return t}else{for(let e=this.to-this.from-t.length-this.spaceAfter.length;e>0;e--)t+=" ";return t+(o?this.spaceAfter:"")}}marker(n,o){let t=this.node.name=="OrderedList"?String(+V(this.item,n)[2]+o):"";return this.spaceBefore+t+this.type+this.spaceAfter}}function U(r,n){let o=[],t=[];for(let e=r;e;e=e.parent){if(e.name=="FencedCode")return t;(e.name=="ListItem"||e.name=="Blockquote")&&o.push(e)}for(let e=o.length-1;e>=0;e--){let i=o[e],f,m=n.lineAt(i.from),s=i.from-m.from;if(i.name=="Blockquote"&&(f=/^ *>( ?)/.exec(m.text.slice(s))))t.push(new v(i,s,s+f[0].length,"",f[1],">",null));else if(i.name=="ListItem"&&i.parent.name=="OrderedList"&&(f=/^( *)\d+([.)])( *)/.exec(m.text.slice(s)))){let a=f[3],l=f[0].length;a.length>=4&&(a=a.slice(0,a.length-4),l-=4),t.push(new v(i.parent,s,s+l,f[1],a,f[2],i))}else if(i.name=="ListItem"&&i.parent.name=="BulletList"&&(f=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(m.text.slice(s)))){let a=f[4],l=f[0].length;a.length>4&&(a=a.slice(0,a.length-4),l-=4);let u=f[2];f[3]&&(u+=f[3].replace(/[xX]/," ")),t.push(new v(i.parent,s,s+l,f[1],a,u,i))}}return t}function V(r,n){return/^(\s*)(\d+)(?=[.)])/.exec(n.sliceString(r.from,r.from+10))}function I(r,n,o,t=0){for(let e=-1,i=r;;){if(i.name=="ListItem"){let m=V(i,n),s=+m[2];if(e>=0){if(s!=e+1)return;o.push({from:i.from+m[1].length,to:i.from+m[0].length,insert:String(e+2+t)})}e=s}let f=i.nextSibling;if(!f)break;i=f}}function T(r,n){let o=/^[ \t]*/.exec(r)[0].length;if(!o||n.facet(Y)!=" ")return r;let t=w(r,4,o),e="";for(let i=t;i>0;)i>=4?(e+=" ",i-=4):(e+=" ",i--);return e+r.slice(o)}const xe=(r={})=>({state:n,dispatch:o})=>{let t=A(n),{doc:e}=n,i=null,f=n.changeByRange(m=>{if(!m.empty||!b.isActiveAt(n,m.from,-1)&&!b.isActiveAt(n,m.from,1))r
|