Files
llm-in-text/.build-check/assets/cm-lang-markdown-Cm_J3uh_.js
T
ydy0615 838eec30a8 feat: add theme management with light and dark modes
- Implemented a new composable `useTheme` for managing theme state.
- Added functions to read and write theme preference to local storage.
- Applied theme styles to the DOM based on user preference.
- Introduced a toggle function to switch between light and dark themes.

refactor: enhance copilot plugin functionality

- Improved request handling with sequence and document versioning.
- Refactored ghost text handling to improve clarity and efficiency.
- Updated markdown insertion logic to handle parsed content more robustly.
- Enhanced error handling and logging for better debugging.

style: update global styles for light and dark themes

- Defined CSS variables for light and dark themes to streamline styling.
- Improved overall styling consistency and responsiveness.
- Added transitions for smoother theme changes and interactions.
2026-02-15 15:44:09 +08:00

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))return i={range:m};let s=m.from,a=e.lineAt(s),l=U(t.resolveInner(s,-1),e);for(;l.length&&l[l.length-1].from>s-a.from;)l.pop();if(!l.length)return i={range:m};let u=l[l.length-1];if(u.to-u.spaceAfter.length>s-a.from)return i={range:m};let d=s>=u.to-u.spaceAfter.length&&!/\S/.test(a.text.slice(u.to));if(u.item&&d){let p=u.node.firstChild,h=u.node.getChild("ListItem","ListItem");if(p.to>=s||h&&h.to<s||a.from>0&&!/[^\s>]/.test(e.lineAt(a.from-1).text)||r.nonTightLists===!1){let c=l.length>1?l[l.length-2]:null,C,B="";c&&c.item?(C=a.from+c.from,B=c.marker(e,1)):C=a.from+(c?c.to:0);let S=[{from:C,to:s,insert:B}];return u.node.name=="OrderedList"&&I(u.item,e,S,-2),c&&c.node.name=="OrderedList"&&I(c.item,e,S),{range:x.cursor(C+B.length),changes:S}}else{let c=q(l,n,a);return{range:x.cursor(s+c.length+1),changes:{from:a.from,insert:c+n.lineBreak}}}}if(u.node.name=="Blockquote"&&d&&a.from){let p=e.lineAt(a.from-1),h=/>\s*$/.exec(p.text);if(h&&h.index==u.from){let c=n.changes([{from:p.from+h.index,to:p.to},{from:a.from+u.from,to:a.to}]);return{range:m.map(c),changes:c}}}let g=[];u.node.name=="OrderedList"&&I(u.item,e,g);let M=u.item&&u.item.from<a.from,k="";if(!M||/^[\s\d.)\-+*>]*/.exec(a.text)[0].length>=u.to)for(let p=0,h=l.length-1;p<=h;p++)k+=p==h&&!M?l[p].marker(e,1):l[p].blank(p<h?w(a.text,4,l[p+1].from)-k.length:null);let L=s;for(;L>a.from&&/\s/.test(a.text.charAt(L-a.from-1));)L--;return k=T(k,n),we(u.node,n.doc)&&(k=q(l,n,a)+n.lineBreak+k),g.push({from:L,to:s,insert:n.lineBreak+k}),{range:x.cursor(L+k.length+1),changes:g}});return i?!1:(o(n.update(f,{scrollIntoView:!0,userEvent:"input"})),!0)},Le=xe();function O(r){return r.name=="QuoteMark"||r.name=="ListMark"}function we(r,n){if(r.name!="OrderedList"&&r.name!="BulletList")return!1;let o=r.firstChild,t=r.getChild("ListItem","ListItem");if(!t)return!1;let e=n.lineAt(o.to),i=n.lineAt(t.from),f=/^[\s>]*$/.test(e.text);return e.number+(f?0:1)<i.number}function q(r,n,o){let t="";for(let e=0,i=r.length-2;e<=i;e++)t+=r[e].blank(e<i?w(o.text,4,r[e+1].from)-t.length:null,e<i);return T(t,n)}function Ae(r,n){let o=r.resolveInner(n,-1),t=n;O(o)&&(t=o.from,o=o.parent);for(let e;e=o.childBefore(t);)if(O(e))t=e.from;else if(e.name=="OrderedList"||e.name=="BulletList")o=e.lastChild,t=o.to;else break;return o}const Ce=({state:r,dispatch:n})=>{let o=A(r),t=null,e=r.changeByRange(i=>{let f=i.from,{doc:m}=r;if(i.empty&&b.isActiveAt(r,i.from)){let s=m.lineAt(f),a=U(Ae(o,f),m);if(a.length){let l=a[a.length-1],u=l.to-l.spaceAfter.length+(l.spaceAfter?1:0);if(f-s.from>u&&!/\S/.test(s.text.slice(u,f-s.from)))return{range:x.cursor(s.from+u),changes:{from:s.from+u,to:f}};if(f-s.from==u&&(!l.item||s.from<=l.item.from||!/\S/.test(s.text.slice(0,l.to)))){let d=s.from+l.from;if(l.item&&l.node.from<l.item.from&&/\S/.test(s.text.slice(l.from,l.to))){let g=l.blank(w(s.text,4,l.to)-w(s.text,4,l.from));return d==s.from&&(g=T(g,r)),{range:x.cursor(d+g.length),changes:{from:d,to:s.from+l.to,insert:g}}}if(d<f)return{range:x.cursor(d),changes:{from:d,to:f}}}}}return t={range:i}});return t?!1:(n(r.update(e,{scrollIntoView:!0,userEvent:"delete"})),!0)},be=[{key:"Enter",run:Le},{key:"Backspace",run:Ce}],X=fe({matchClosingTags:!1});function Ke(r={}){let{codeLanguages:n,defaultCodeLanguage:o,addKeymap:t=!0,base:{parser:e}=he,completeHTMLTags:i=!0,pasteURLAsLink:f=!0,htmlTagLanguage:m=X}=r;if(!(e instanceof re))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let s=r.extensions?[r.extensions]:[],a=[m.support,de],l;f&&a.push(Ie),o instanceof N?(a.push(o.support),l=o.language):o&&(l=o);let u=n||l?ke(n,l):void 0;s.push(ne({codeParser:u,htmlParser:m.language.parser})),t&&a.push(z.high(_.of(be)));let d=E(e.configure(s));return i&&a.push(d.data.of({autocomplete:Be})),new N(d,a)}function Be(r){let{state:n,pos:o}=r,t=/<[:\-\.\w\u00b7-\uffff]*$/.exec(n.sliceDoc(o-25,o));if(!t)return null;let e=A(n).resolveInner(o,-1);for(;e&&!e.type.isTop;){if(e.name=="CodeBlock"||e.name=="FencedCode"||e.name=="ProcessingInstructionBlock"||e.name=="CommentBlock"||e.name=="Link"||e.name=="Image")return null;e=e.parent}return{from:o-t[0].length,to:o,options:Se(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let y=null;function Se(){if(y)return y;let r=me(new te(G.create({extensions:X}),0,!0));return y=r?r.options:[]}const ve=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Ie=K.domEventHandlers({paste:(r,n)=>{var o;let{main:t}=n.state.selection;if(t.empty)return!1;let e=(o=r.clipboardData)===null||o===void 0?void 0:o.getData("text/plain");if(!e||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(e)||(/^www\./.test(e)&&(e="https://"+e),!b.isActiveAt(n.state,t.from,1)))return!1;let i=A(n.state),f=!1;return i.iterate({from:t.from,to:t.to,enter:m=>{(m.from>t.from||ve.test(m.name))&&(f=!0)},leave:m=>{m.to<t.to&&(f=!0)}}),f?!1:(n.dispatch({changes:[{from:t.from,insert:"["},{from:t.to,insert:`](${e})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}});export{he as commonmarkLanguage,Ce as deleteMarkupBackward,Le as insertNewlineContinueMarkup,xe as insertNewlineContinueMarkupCommand,Ke as markdown,be as markdownKeymap,b as markdownLanguage,Ie as pasteURLAsLink};