@uiw/react-codemirror 4.7.0 → 4.9.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/README.md +67 -8
- package/cjs/basicSetup.d.ts +65 -0
- package/cjs/basicSetup.js +119 -0
- package/cjs/basicSetup.js.map +49 -0
- package/cjs/index.d.ts +7 -4
- package/cjs/index.js +9 -37
- package/cjs/index.js.map +10 -6
- package/cjs/theme/light.js.map +5 -5
- package/cjs/useCodeMirror.d.ts +1 -2
- package/cjs/useCodeMirror.js +19 -9
- package/cjs/useCodeMirror.js.map +12 -8
- package/dist/{codemirror.js → mdeditor.js} +4019 -359
- package/dist/mdeditor.min.js +2 -0
- package/dist/{codemirror.min.js.LICENSE.txt → mdeditor.min.js.LICENSE.txt} +0 -0
- package/esm/basicSetup.d.ts +65 -0
- package/esm/basicSetup.js +103 -0
- package/esm/basicSetup.js.map +49 -0
- package/esm/index.d.ts +7 -4
- package/esm/index.js +1 -3
- package/esm/index.js.map +6 -6
- package/esm/theme/light.js.map +5 -5
- package/esm/useCodeMirror.d.ts +1 -2
- package/esm/useCodeMirror.js +13 -3
- package/esm/useCodeMirror.js.map +10 -8
- package/package.json +25 -90
- package/src/basicSetup.ts +136 -0
- package/src/index.tsx +7 -4
- package/src/useCodeMirror.ts +18 -4
- package/LICENSE +0 -21
- package/cjs/theme/light.d.ts +0 -1
- package/dist/codemirror.min.js +0 -2
- package/esm/theme/light.d.ts +0 -1
- package/src/tsconfig.json +0 -7
package/dist/codemirror.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see codemirror.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):"function"===typeof define&&define.amd?define(["react",,,,],t):"object"===typeof exports?exports["@uiw/codemirror"]=t(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e["@uiw/codemirror"]=t(e.React,e.CM["@codemirror/basic-setup"],e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,((e,t,r,n,i)=>(()=>{"use strict";var s={963:(e,t,r)=>{function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,s=[],o=!0,l=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(s.push(n.value),!t||s.length!==t);o=!0);}catch(a){l=!0,i=a}finally{try{o||null==r.return||r.return()}finally{if(l)throw i}}return s}}(e,t)||function(e,t){if(e){if("string"===typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}r.d(t,{U:()=>tt});var s=r(787),o=r(573),l=r(242),a=r(105);const h=1024;let u=0;class f{constructor(e,t){this.from=e,this.to=t}}class c{constructor(e={}){this.id=u++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=p.match(e)),t=>{let r=e(t);return void 0===r?null:[this,r]}}}c.closedBy=new c({deserialize:e=>e.split(" ")}),c.openedBy=new c({deserialize:e=>e.split(" ")}),c.group=new c({deserialize:e=>e.split(" ")}),c.contextHash=new c({perNode:!0}),c.lookAhead=new c({perNode:!0}),c.mounted=new c({perNode:!0});const d=Object.create(null);class p{constructor(e,t,r,n=0){this.name=e,this.props=t,this.id=r,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):d,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new p(e.name||"",t,e.id,r);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(c.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let r in e)for(let n of r.split(" "))t[n]=e[r];return e=>{for(let r=e.prop(c.group),n=-1;n<(r?r.length:0);n++){let i=t[n<0?e.name:r[n]];if(i)return i}}}}p.none=new p("",Object.create(null),0,8);const g=new WeakMap,m=new WeakMap;var y;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(y||(y={}));class b{constructor(e,t,r,n,i){if(this.type=e,this.children=t,this.positions=r,this.length=n,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props["number"==typeof e?e:e.id]=t}}toString(){let e=this.prop(c.mounted);if(e&&!e.overlay)return e.tree.toString();let t="";for(let r of this.children){let e=r.toString();e&&(t&&(t+=","),t+=e)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new E(this.topNode,e)}cursorAt(e,t=0,r=0){let n=g.get(this)||this.topNode,i=new E(n);return i.moveTo(e,t),g.set(this,i._tree),i}get topNode(){return new O(this,0,0,null)}resolve(e,t=0){let r=S(g.get(this)||this.topNode,e,t,!1);return g.set(this,r),r}resolveInner(e,t=0){let r=S(m.get(this)||this.topNode,e,t,!0);return m.set(this,r),r}iterate(e){let{enter:t,leave:r,from:n=0,to:i=this.length}=e;for(let s=this.cursor((e.mode||0)|y.IncludeAnonymous);;){let e=!1;if(s.from<=i&&s.to>=n&&(s.type.isAnonymous||!1!==t(s))){if(s.firstChild())continue;e=!0}for(;e&&r&&!s.type.isAnonymous&&r(s),!s.nextSibling();){if(!s.parent())return;e=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:I(p.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,r)=>new b(this.type,e,t,r,this.propValues)),e.makeTree||((e,t,r)=>new b(p.none,e,t,r)))}static build(e){return function(e){var t;let{buffer:r,nodeSet:n,maxBufferLength:i=h,reused:s=[],minRepeatType:o=n.types.length}=e,l=Array.isArray(r)?new v(r,r.length):r,a=n.types,u=0,f=0;function d(e,t,r,h,c){let{id:b,start:v,end:k,size:S}=l,O=f;for(;S<0;){if(l.next(),-1==S){let t=s[b];return r.push(t),void h.push(v-e)}if(-3==S)return void(u=b);if(-4==S)return void(f=b);throw new RangeError(`Unrecognized record size: ${S}`)}let A,C,N=a[b],_=v-e;if(k-v<=i&&(C=y(l.pos-t,c))){let t=new Uint16Array(C.size-C.skip),r=l.pos-C.size,i=t.length;for(;l.pos>r;)i=x(C.start,t,i);A=new w(t,k-C.start,n),_=C.start-e}else{let e=l.pos-S;l.next();let t=[],r=[],n=b>=o?b:-1,s=0,a=k;for(;l.pos>e;)n>=0&&l.id==n&&l.size>=0?(l.end<=a-i&&(g(t,r,v,s,l.end,a,n,O),s=t.length,a=l.end),l.next()):d(v,e,t,r,n);if(n>=0&&s>0&&s<t.length&&g(t,r,v,s,v,a,n,O),t.reverse(),r.reverse(),n>-1&&s>0){let e=p(N);A=I(N,t,r,0,t.length,0,k-v,e,e)}else A=m(N,t,r,k-v,O-k)}r.push(A),h.push(_)}function p(e){return(t,r,n)=>{let i,s,o=0,l=t.length-1;if(l>=0&&(i=t[l])instanceof b){if(!l&&i.type==e&&i.length==n)return i;(s=i.prop(c.lookAhead))&&(o=r[l]+i.length+s)}return m(e,t,r,n,o)}}function g(e,t,r,i,s,o,l,a){let h=[],u=[];for(;e.length>i;)h.push(e.pop()),u.push(t.pop()+r-s);e.push(m(n.types[l],h,u,o-s,a-o)),t.push(s-r)}function m(e,t,r,n,i=0,s){if(u){let e=[c.contextHash,u];s=s?[e].concat(s):[e]}if(i>25){let e=[c.lookAhead,i];s=s?[e].concat(s):[e]}return new b(e,t,r,n,s)}function y(e,t){let r=l.fork(),n=0,s=0,a=0,h=r.end-i,u={size:0,start:0,skip:0};e:for(let i=r.pos-e;r.pos>i;){let e=r.size;if(r.id==t&&e>=0){u.size=n,u.start=s,u.skip=a,a+=4,n+=4,r.next();continue}let l=r.pos-e;if(e<0||l<i||r.start<h)break;let f=r.id>=o?4:0,c=r.start;for(r.next();r.pos>l;){if(r.size<0){if(-3!=r.size)break e;f+=4}else r.id>=o&&(f+=4);r.next()}s=c,n+=e,a+=f}return(t<0||n==e)&&(u.size=n,u.start=s,u.skip=a),u.size>4?u:void 0}function x(e,t,r){let{id:n,start:i,end:s,size:a}=l;if(l.next(),a>=0&&n<o){let o=r;if(a>4){let n=l.pos-(a-4);for(;l.pos>n;)r=x(e,t,r)}t[--r]=o,t[--r]=s-e,t[--r]=i-e,t[--r]=n}else-3==a?u=n:-4==a&&(f=n);return r}let k=[],S=[];for(;l.pos>0;)d(e.start||0,e.bufferStart||0,k,S,-1);let O=null!==(t=e.length)&&void 0!==t?t:k.length?S[0]+k[0].length:0;return new b(a[e.topID],k.reverse(),S.reverse(),O)}(e)}}b.empty=new b(p.none,[],[],0);class v{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new v(this.buffer,this.index)}}class w{constructor(e,t,r){this.buffer=e,this.length=t,this.set=r}get type(){return p.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],r=this.buffer[e+3],n=this.set.types[t],i=n.name;if(/\W/.test(i)&&!n.isError&&(i=JSON.stringify(i)),r==(e+=4))return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,t,r,n,i){let{buffer:s}=this,o=-1;for(let l=e;l!=t&&!(x(i,n,s[l+1],s[l+2])&&(o=l,r>0));l=s[l+3]);return o}slice(e,t,r,n){let i=this.buffer,s=new Uint16Array(t-e);for(let o=e,l=0;o<t;)s[l++]=i[o++],s[l++]=i[o++]-r,s[l++]=i[o++]-r,s[l++]=i[o++]-e;return new w(s,n-r,this.set)}}function x(e,t,r,n){switch(e){case-2:return r<t;case-1:return n>=t&&r<t;case 0:return r<t&&n>t;case 1:return r<=t&&n>t;case 2:return n>t;case 4:return!0}}function k(e,t){let r=e.childBefore(t);for(;r;){let t=r.lastChild;if(!t||t.to!=r.to)break;t.type.isError&&t.from==t.to?(e=r,r=t.prevSibling):r=t}return e}function S(e,t,r,n){for(var i;e.from==e.to||(r<1?e.from>=t:e.from>t)||(r>-1?e.to<=t:e.to<t);){let t=!n&&e instanceof O&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=n?0:y.IgnoreOverlays;if(n)for(let o=e,l=o.parent;l;o=l,l=o.parent)o instanceof O&&o.index<0&&(null===(i=l.enter(t,r,s))||void 0===i?void 0:i.from)!=o.from&&(e=l);for(;;){let n=e.enter(t,r,s);if(!n)return e;e=n}}class O{constructor(e,t,r,n){this._tree=e,this.from=t,this.index=r,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,r,n,i=0){for(let s=this;;){for(let{children:o,positions:l}=s._tree,a=t>0?o.length:-1;e!=a;e+=t){let a=o[e],h=l[e]+s.from;if(x(n,r,h,h+a.length))if(a instanceof w){if(i&y.ExcludeBuffers)continue;let o=a.findChild(0,a.buffer.length,t,r-h,n);if(o>-1)return new _(new N(s,a,e,h),null,o)}else if(i&y.IncludeAnonymous||!a.type.isAnonymous||P(a)){let o;if(!(i&y.IgnoreMounts)&&a.props&&(o=a.prop(c.mounted))&&!o.overlay)return new O(o.tree,h,e,s);let l=new O(a,h,e,s);return i&y.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(t<0?a.children.length-1:0,t,r,n)}}if(i&y.IncludeAnonymous||!s.type.isAnonymous)return null;if(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,s=s._parent,!s)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,r=0){let n;if(!(r&y.IgnoreOverlays)&&(n=this._tree.prop(c.mounted))&&n.overlay){let r=e-this.from;for(let{from:e,to:i}of n.overlay)if((t>0?e<=r:e<r)&&(t<0?i>=r:i>r))return new O(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new E(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return S(this,e,t,!1)}resolveInner(e,t=0){return S(this,e,t,!0)}enterUnfinishedNodesBefore(e){return k(this,e)}getChild(e,t=null,r=null){let n=A(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return A(this,e,t,r)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return C(this,e)}}function A(e,t,r,n){let i=e.cursor(),s=[];if(!i.firstChild())return s;if(null!=r)for(;!i.type.is(r);)if(!i.nextSibling())return s;for(;;){if(null!=n&&i.type.is(n))return s;if(i.type.is(t)&&s.push(i.node),!i.nextSibling())return null==n?s:[]}}function C(e,t,r=t.length-1){for(let n=e.parent;r>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(t[r]&&t[r]!=n.name)return!1;r--}}return!0}class N{constructor(e,t,r,n){this.parent=e,this.buffer=t,this.index=r,this.start=n}}class _{constructor(e,t,r){this.context=e,this._parent=t,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(e,t,r){let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,r);return i<0?null:new _(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,r=0){if(r&y.ExcludeBuffers)return null;let{buffer:n}=this.context,i=n.findChild(this.index+4,n.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return i<0?null:new _(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new _(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new _(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new E(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:r}=this.context,n=this.index+4,i=r.buffer[this.index+3];if(i>n){let s=r.buffer[this.index+1],o=r.buffer[this.index+2];e.push(r.slice(n,i,s,o)),t.push(0)}return new b(this.type,e,t,this.to-this.from)}resolve(e,t=0){return S(this,e,t,!1)}resolveInner(e,t=0){return S(this,e,t,!0)}enterUnfinishedNodesBefore(e){return k(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,r=null){let n=A(this,e,t,r);return n.length?n[0]:null}getChildren(e,t=null,r=null){return A(this,e,t,r)}get node(){return this}matchContext(e){return C(this,e)}}class E{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof O)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:r,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=r+n.buffer[e+1],this.to=r+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof O?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,r,this.mode));let{buffer:n}=this.buffer,i=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,r);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,r=this.mode){return this.buffer?!(r&y.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&y.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&y.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,r=this.stack.length-1;if(e<0){let e=r<0?0:this.stack[r]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(r<0?t.buffer.length:t.buffer[this.stack[r]+3]))return this.yieldBuf(e)}return r<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,r,{buffer:n}=this;if(n){if(e>0){if(this.index<n.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(n.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:r}=n)}else({index:t,_parent:r}=this._tree);for(;r;({index:t,_parent:r}=r))if(t>-1)for(let n=t+e,i=e<0?-1:r._tree.children.length;n!=i;n+=e){let e=r._tree.children[n];if(this.mode&y.IncludeAnonymous||e instanceof w||!e.type.isAnonymous||P(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,r=0;if(e&&e.context==this.buffer)e:for(let n=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==n){if(n==this.index)return s;t=s,r=i+1;break e}n=this.stack[--i]}for(let n=r;n<this.stack.length;n++)t=new _(this.buffer,t,this.stack[n]);return this.bufferNode=new _(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let r=0;;){let n=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){r++;continue}this.type.isAnonymous||(n=!0)}for(;n&&t&&t(this),n=this.type.isAnonymous,!this.nextSibling();){if(!r)return;this.parent(),r--,n=!0}}}matchContext(e){if(!this.buffer)return C(this.node,e);let{buffer:t}=this.buffer,{types:r}=t.set;for(let n=e.length-1,i=this.stack.length-1;n>=0;i--){if(i<0)return C(this.node,e,n);let s=r[t.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[n]&&e[n]!=s.name)return!1;n--}}return!0}}function P(e){return e.children.some((e=>e instanceof w||!e.type.isAnonymous||P(e)))}const T=new WeakMap;function j(e,t){if(!e.isAnonymous||t instanceof w||t.type!=e)return 1;let r=T.get(t);if(null==r){r=1;for(let n of t.children){if(n.type!=e||!(n instanceof b)){r=1;break}r+=j(e,n)}T.set(t,r)}return r}function I(e,t,r,n,i,s,o,l,a){let h=0;for(let d=n;d<i;d++)h+=j(e,t[d]);let u=Math.ceil(1.5*h/8),f=[],c=[];return function t(r,n,i,o,l){for(let h=i;h<o;){let i=h,d=n[h],p=j(e,r[h]);for(h++;h<o;h++){let t=j(e,r[h]);if(p+t>=u)break;p+=t}if(h==i+1){if(p>u){let e=r[i];t(e.children,e.positions,0,e.children.length,n[i]+l);continue}f.push(r[i])}else{let t=n[h-1]+r[h-1].length-d;f.push(I(e,r,n,i,h,d,t,null,a))}c.push(d+l-s)}}(t,r,n,i,0),(l||a)(f,c,o)}class B{constructor(e,t,r,n,i=!1,s=!1){this.from=e,this.to=t,this.tree=r,this.offset=n,this.open=(i?1:0)|(s?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],r=!1){let n=[new B(0,e.length,e,0,!1,r)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,r=128){if(!t.length)return e;let n=[],i=1,s=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,u=h?h.fromA:1e9;if(u-l>=r)for(;s&&s.from<u;){let t=s;if(l>=t.from||u<=t.to||a){let e=Math.max(t.from,l)-a,r=Math.min(t.to,u)-a;t=e>=r?null:new B(e,r,t.tree,t.offset+a,o>0,!!h)}if(t&&n.push(t),s.to>u)break;s=i<e.length?e[i++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class M{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new c({perNode:!0});let W=0;class R{constructor(e,t,r){this.set=e,this.base=t,this.modified=r,this.id=W++}static define(e){if(null===e||void 0===e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new R([],null,[]);if(t.set.push(t),e)for(let r of e.set)t.set.push(r);return t}static defineModifier(){let e=new D;return t=>t.modified.indexOf(e)>-1?t:D.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let z=0;class D{constructor(){this.instances=[],this.id=z++}static get(e,t){if(!t.length)return e;let r=t[0].instances.find((r=>{return r.base==e&&(n=t,i=r.modified,n.length==i.length&&n.every(((e,t)=>e==i[t])));var n,i}));if(r)return r;let n=[],i=new R(n,e,t);for(let o of t)o.instances.push(i);let s=L(t);for(let o of e.set)for(let e of s)n.push(D.get(o,e));return i}}function L(e){let t=[e];for(let r=0;r<e.length;r++)for(let n of L(e.slice(0,r).concat(e.slice(r+1))))t.push(n);return t}function U(e){let t=Object.create(null);for(let r in e){let n=e[r];Array.isArray(n)||(n=[n]);for(let e of r.split(" "))if(e){let r=[],i=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){i=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!n)throw new RangeError("Invalid path: "+e);if(r.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),t+=n[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){i=0;break}if("/"!=o)throw new RangeError("Invalid path: "+e);s=e.slice(t)}let o=r.length-1,l=r[o];if(!l)throw new RangeError("Invalid path: "+e);let a=new V(n,i,o>0?r.slice(0,o):null);t[l]=a.sort(t[l])}}return q.add(t)}const q=new c;class V{constructor(e,t,r,n){this.tags=e,this.mode=t,this.context=r,this.next=n}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}function H(e,t){let r=Object.create(null);for(let s of e)if(Array.isArray(s.tag))for(let e of s.tag)r[e.id]=s.class;else r[s.tag.id]=s.class;let{scope:n,all:i=null}=t||{};return{style:e=>{let t=i;for(let n of e)for(let e of n.set){let n=r[e.id];if(n){t=t?t+" "+n:n;break}}return t},scope:n}}const J=R.define,F=J(),$=J(),Z=J($),K=J($),Y=J(),G=J(Y),Q=J(Y),X=J(),ee=J(X),te=J(),re=J(),ne=J(),ie=J(ne),se=J(),oe={comment:F,lineComment:J(F),blockComment:J(F),docComment:J(F),name:$,variableName:J($),typeName:Z,tagName:J(Z),propertyName:K,attributeName:J(K),className:J($),labelName:J($),namespace:J($),macroName:J($),literal:Y,string:G,docString:J(G),character:J(G),attributeValue:J(G),number:Q,integer:J(Q),float:J(Q),bool:J(Y),regexp:J(Y),escape:J(Y),color:J(Y),url:J(Y),keyword:te,self:J(te),null:J(te),atom:J(te),unit:J(te),modifier:J(te),operatorKeyword:J(te),controlKeyword:J(te),definitionKeyword:J(te),moduleKeyword:J(te),operator:re,derefOperator:J(re),arithmeticOperator:J(re),logicOperator:J(re),bitwiseOperator:J(re),compareOperator:J(re),updateOperator:J(re),definitionOperator:J(re),typeOperator:J(re),controlOperator:J(re),punctuation:ne,separator:J(ne),bracket:ie,angleBracket:J(ie),squareBracket:J(ie),paren:J(ie),brace:J(ie),content:X,heading:ee,heading1:J(ee),heading2:J(ee),heading3:J(ee),heading4:J(ee),heading5:J(ee),heading6:J(ee),contentSeparator:J(X),list:J(X),quote:J(X),emphasis:J(X),strong:J(X),link:J(X),monospace:J(X),strikethrough:J(X),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:se,documentMeta:J(se),annotation:J(se),processingInstruction:J(se),definition:R.defineModifier(),constant:R.defineModifier(),function:R.defineModifier(),standard:R.defineModifier(),local:R.defineModifier(),special:R.defineModifier()},le=(H([{tag:oe.link,class:"tok-link"},{tag:oe.heading,class:"tok-heading"},{tag:oe.emphasis,class:"tok-emphasis"},{tag:oe.strong,class:"tok-strong"},{tag:oe.keyword,class:"tok-keyword"},{tag:oe.atom,class:"tok-atom"},{tag:oe.bool,class:"tok-bool"},{tag:oe.url,class:"tok-url"},{tag:oe.labelName,class:"tok-labelName"},{tag:oe.inserted,class:"tok-inserted"},{tag:oe.deleted,class:"tok-deleted"},{tag:oe.literal,class:"tok-literal"},{tag:oe.string,class:"tok-string"},{tag:oe.number,class:"tok-number"},{tag:[oe.regexp,oe.escape,oe.special(oe.string)],class:"tok-string2"},{tag:oe.variableName,class:"tok-variableName"},{tag:oe.local(oe.variableName),class:"tok-variableName tok-local"},{tag:oe.definition(oe.variableName),class:"tok-variableName tok-definition"},{tag:oe.special(oe.variableName),class:"tok-variableName2"},{tag:oe.definition(oe.propertyName),class:"tok-propertyName tok-definition"},{tag:oe.typeName,class:"tok-typeName"},{tag:oe.namespace,class:"tok-namespace"},{tag:oe.className,class:"tok-className"},{tag:oe.macroName,class:"tok-macroName"},{tag:oe.propertyName,class:"tok-propertyName"},{tag:oe.operator,class:"tok-operator"},{tag:oe.comment,class:"tok-comment"},{tag:oe.meta,class:"tok-meta"},{tag:oe.invalid,class:"tok-invalid"},{tag:oe.punctuation,class:"tok-punctuation"}]),"undefined"==typeof Symbol?"__\u037c":Symbol.for("\u037c")),ae="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),he="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class ue{constructor(e,t){this.rules=[];let{finish:r}=t||{};function n(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,s,o){let l=[],a=/^@(\w+)\b/.exec(e[0]),h=a&&"keyframes"==a[1];if(a&&null==t)return s.push(e[0]+";");for(let r in t){let o=t[r];if(/&/.test(r))i(r.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),o,s);else if(o&&"object"==typeof o){if(!a)throw new RangeError("The value of a property ("+r+") should be a primitive value.");i(n(r),o,l,h)}else null!=o&&l.push(r.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+o+";")}(l.length||h)&&s.push((!r||a||o?e:e.map(r)).join(", ")+" {"+l.join(" ")+"}")}for(let s in e)i(n(s),e[s],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=he[le]||1;return he[le]=e+1,"\u037c"+e.toString(36)}static mount(e,t){(e[ae]||new ce(e)).mount(Array.isArray(t)?t:[t])}}let fe=null;class ce{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(fe)return e.adoptedStyleSheets=[fe.sheet].concat(e.adoptedStyleSheets),e[ae]=fe;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[ae]=this}mount(e){let t=this.sheet,r=0,n=0;for(let i=0;i<e.length;i++){let s=e[i],o=this.modules.indexOf(s);if(o<n&&o>-1&&(this.modules.splice(o,1),-1),-1==o){if(this.modules.splice(n++,0,s),t)for(let e=0;e<s.rules.length;e++)t.insertRule(s.rules[e],r++)}else{for(;n<o;)this.modules[n++].rules.length;s.rules.length}}if(!t){let e="";for(let t=0;t<this.modules.length;t++)this.modules[t].getRules()+"\n";this.styleTag.textContent=e}}}var de;const pe=new c;class ge{constructor(e,t,r=[]){this.data=e,l.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(l.EditorState.prototype,"tree",{get(){return ye(this)}}),this.parser=t,this.extension=[Ce.of(this),l.EditorState.languageData.of(((e,t,r)=>e.facet(me(e,t,r))))].concat(r)}isActiveAt(e,t,r=-1){return me(e,t,r)==this.data}findRegions(e){let t=e.facet(Ce);if((null===t||void 0===t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let r=[],n=(e,t)=>{if(e.prop(pe)==this.data)return void r.push({from:t,to:t+e.length});let i=e.prop(c.mounted);if(i){if(i.tree.prop(pe)==this.data){if(i.overlay)for(let e of i.overlay)r.push({from:e.from+t,to:e.to+t});else r.push({from:t,to:t+e.length});return}if(i.overlay){let e=r.length;if(n(i.tree,i.overlay[0].from+t),r.length>e)return}}for(let r=0;r<e.children.length;r++){let i=e.children[r];i instanceof b&&n(i,e.positions[r]+t)}};return n(ye(e),0),r}get allowsNesting(){return!0}}function me(e,t,r){let n=e.facet(Ce);if(!n)return null;let i=n.data;if(n.allowsNesting)for(let s=ye(e).topNode;s;s=s.enter(t,r,y.ExcludeBuffers))i=s.type.prop(pe)||i;return i}ge.setState=l.StateEffect.define();function ye(e){let t=e.field(ge.state,!1);return t?t.tree:b.empty}class be{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let r=this.cursorPos-this.string.length;return e<r||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-r,t-r)}}let ve=null;class we{constructor(e,t,r=[],n,i,s,o,l){this.parser=e,this.state=t,this.fragments=r,this.tree=n,this.treeLen=i,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new be(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=b.empty&&this.isDone(null!==t&&void 0!==t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var r;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(B.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(r=this.parse.stoppedAt)&&void 0!==r?r:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!==t&&void 0!==t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}}))}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(B.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ve;ve=this;try{return e()}finally{ve=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=xe(e,t.from,t.to);return e}changes(e,t){let{fragments:r,tree:n,treeLen:i,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,r,n,i)=>t.push({fromA:e,toA:r,fromB:n,toB:i}))),r=B.applyChanges(r,t),n=b.empty,i=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){o=[];for(let t of this.skipped){let r=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);r<n&&o.push({from:r,to:n})}}}return new we(this.parser,t,r,n,i,s,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:t,to:n}=this.skipped[r];t<e.to&&n>e.from&&(this.fragments=xe(this.fragments,t,n),this.skipped.splice(r--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends class{startParse(e,t,r){return"string"==typeof e&&(e=new M(e)),r=r?r.length?r.map((e=>new f(e.from,e.to))):[new f(0,0)]:[new f(0,e.length)],this.createParse(e,t||[],r)}parse(e,t,r){let n=this.startParse(e,t,r);for(;;){let e=n.advance();if(e)return e}}}{createParse(t,r,n){let i=n[0].from,s=n[n.length-1].to;return{parsedPos:i,advance(){let t=ve;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new b(p.none,[],[],s-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return ve}}function xe(e,t,r){return B.applyChanges(e,[{fromA:t,toA:r,fromB:t,toB:r}])}class ke{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,r)||t.takeTree(),new ke(t)}static init(e){let t=Math.min(3e3,e.doc.length),r=new we(e.facet(Ce).parser,e,[],b.empty,0,{from:0,to:t},[],null);return r.work(20,t)||r.takeTree(),new ke(r)}}ge.state=l.StateField.define({create:ke.init,update(e,t){for(let r of t.effects)if(r.is(ge.setState))return r.value;return t.startState.facet(Ce)!=t.state.facet(Ce)?ke.init(t.state):e.apply(t)}});let Se=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Se=e=>{let t=-1,r=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(r):cancelIdleCallback(t)});const Oe="undefined"!=typeof navigator&&(null===(de=navigator.scheduling)||void 0===de?void 0:de.isInputPending)?()=>navigator.scheduling.isInputPending():null,Ae=a.ViewPlugin.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(ge.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(ge.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Se(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:r,viewport:{to:n}}=this.view,i=r.field(ge.state);if(i.tree==i.context.tree&&i.context.isDone(n+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Oe?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<n&&r.doc.length>n+1e3,l=i.context.work((()=>Oe&&Oe()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:ge.setState.of(new ke(i.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>(0,a.logException)(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ce=l.Facet.define({combine:e=>e.length?e[0]:null,enables:[ge.state,Ae]});const Ne=l.Facet.define({combine:e=>{if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function _e(e){let t=e.facet(Ne);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function Ee(e,t){let r="",n=e.tabSize;if(9==e.facet(Ne).charCodeAt(0))for(;t>=n;)r+="\t",t-=n;for(let i=0;i<t;i++)r+=" ";return r}class Pe{constructor(e,t){let r;function n(e){let t=ue.newName();return(r||Object.create(null))["."+t]=e,t}const i=t.scope;this.scope=i instanceof ge?e=>e.prop(pe)==i.data:i?e=>e==i:void 0,this.style=H(e.map((e=>({tag:e.tag,class:e.class||n(Object.assign({},e,{tag:null}))}))),{all:"string"==typeof t.all?t.all:t.all?n(t.all):void 0}).style,this.module=r?new ue(r):null,this.themeType=t.themeType}static define(e,t){return new Pe(e,t||{})}}oe.meta,oe.link,oe.heading,oe.emphasis,oe.strong,oe.strikethrough,oe.keyword,oe.atom,oe.bool,oe.url,oe.contentSeparator,oe.labelName,oe.literal,oe.inserted,oe.string,oe.deleted,oe.regexp,oe.escape,oe.string,oe.variableName,oe.variableName,oe.typeName,oe.namespace,oe.className,oe.variableName,oe.macroName,oe.propertyName,oe.comment,oe.invalid;const Te=Object.create(null),je=[p.none],Ie=[],Be=Object.create(null);for(let[rt,nt]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","typeName"],["attribute","propertyName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Be[rt]=We(Te,nt);function Me(e,t){Ie.indexOf(e)>-1||(Ie.push(e),console.warn(t))}function We(e,t){let r=null;for(let s of t.split(".")){let t=e[s]||oe[s];t?"function"==typeof t?r?r=t(r):Me(s,`Modifier ${s} used at start of tag`):r?Me(s,`Tag ${s} used as modifier`):r=t:Me(s,`Unknown highlighting tag ${s}`)}if(!r)return 0;let n=t.replace(/ /g,"_"),i=p.define({id:je.length,name:n,props:[U({[n]:r})]});return je.push(i),i.id}const Re=l.Annotation.define(),ze=l.Facet.define();class De{constructor(e,t,r,n,i){this.changes=e,this.effects=t,this.mapped=r,this.startSelection=n,this.selectionsAfter=i}setSelAfter(e){return new De(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,r;return{changes:null===(e=this.changes)||void 0===e?void 0:e.toJSON(),mapped:null===(t=this.mapped)||void 0===t?void 0:t.toJSON(),startSelection:null===(r=this.startSelection)||void 0===r?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map((e=>e.toJSON()))}}static fromJSON(e){return new De(e.changes&&l.ChangeSet.fromJSON(e.changes),[],e.mapped&&l.ChangeDesc.fromJSON(e.mapped),e.startSelection&&l.EditorSelection.fromJSON(e.startSelection),e.selectionsAfter.map(l.EditorSelection.fromJSON))}static fromTransaction(e,t){let r=qe;for(let n of e.startState.facet(ze)){let t=n(e);t.length&&(r=r.concat(t))}return!r.length&&e.changes.empty?null:new De(e.changes.invert(e.startState.doc),r,void 0,t||e.startState.selection,qe)}static selection(e){return new De(void 0,qe,void 0,void 0,e)}}function Le(e,t,r,n){let i=t+1>r+20?t-r-1:0,s=e.slice(i,t);return s.push(n),s}function Ue(e,t){return e.length?t.length?e.concat(t):e:t}const qe=[];function Ve(e,t){if(e.length){let r=e[e.length-1],n=r.selectionsAfter.slice(Math.max(0,r.selectionsAfter.length-200));return n.length&&n[n.length-1].eq(t)?e:(n.push(t),Le(e,e.length-1,1e9,r.setSelAfter(n)))}return[De.selection([t])]}function He(e){let t=e[e.length-1],r=e.slice();return r[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),r}function Je(e,t){if(!e.length)return e;let r=e.length,n=qe;for(;r;){let i=Fe(e[r-1],t,n);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,r);return t[r-1]=i,t}t=i.mapped,r--,n=i.selectionsAfter}return n.length?[De.selection(n)]:qe}function Fe(e,t,r){let n=Ue(e.selectionsAfter.length?e.selectionsAfter.map((e=>e.map(t))):qe,r);if(!e.changes)return De.selection(n);let i=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new De(i,l.StateEffect.mapEffects(e.effects,t),o,e.startSelection.map(s),n)}const $e=/^(input\.type|delete)($|\.)/;class Ze{constructor(e,t,r=0,n){this.done=e,this.undone=t,this.prevTime=r,this.prevUserEvent=n}isolate(){return this.prevTime?new Ze(this.done,this.undone):this}addChanges(e,t,r,n,i){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&e.changes&&(!r||$e.test(r))&&(!o.selectionsAfter.length&&t-this.prevTime<n&&function(e,t){let r=[],n=!1;return e.iterChangedRanges(((e,t)=>r.push(e,t))),t.iterChangedRanges(((e,t,i,s)=>{for(let o=0;o<r.length;){let e=r[o++],t=r[o++];s>=e&&i<=t&&(n=!0)}})),n}(o.changes,e.changes)||"input.type.compose"==r)?Le(s,s.length-1,i,new De(e.changes.compose(o.changes),Ue(e.effects,o.effects),o.mapped,o.startSelection,qe)):Le(s,s.length,i,e),new Ze(s,qe,t,r)}addSelection(e,t,r,n){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:qe;return i.length>0&&t-this.prevTime<n&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&(s=i[i.length-1],o=e,s.ranges.length==o.ranges.length&&0===s.ranges.filter(((e,t)=>e.empty!=o.ranges[t].empty)).length)?this:new Ze(Ve(this.done,e),this.undone,t,r);var s,o}addMapping(e){return new Ze(Je(this.done,e),Je(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,r){let n=0==e?this.done:this.undone;if(0==n.length)return null;let i=n[n.length-1];if(r&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Re.of({side:e,rest:He(n)}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let r=1==n.length?qe:n.slice(0,n.length-1);return i.mapped&&(r=Je(r,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Re.of({side:e,rest:r}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}return null}}Ze.empty=new Ze(qe,qe);function Ke(e,t){let r=-1;return e.changeByRange((n=>{let i=[];for(let o=n.from;o<=n.to;){let s=e.doc.lineAt(o);s.number>r&&(n.empty||n.to>s.from)&&(t(s,i,n),r=s.number),o=s.to+1}let s=e.changes(i);return{changes:i,range:l.EditorSelection.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const Ye=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Ke(e,((t,r)=>{r.push({from:t.from,insert:e.facet(Ne)})})),{userEvent:"input.indent"})),!0),Ge=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Ke(e,((t,r)=>{let n=/^\s*/.exec(t.text)[0];if(!n)return;let i=(0,l.countColumn)(n,e.tabSize),s=0,o=Ee(e,Math.max(0,i-_e(e)));for(;s<n.length&&s<o.length&&n.charCodeAt(s)==o.charCodeAt(s);)s++;r.push({from:t.from+s,to:t.from+n.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0),Qe={key:"Tab",run:Ye,shift:Ge};var Xe=r(362),et=a.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function tt(e){var t=e.value,r=e.selection,n=e.onChange,h=e.onUpdate,u=e.extensions,f=void 0===u?[]:u,c=e.autoFocus,d=e.theme,p=void 0===d?"light":d,g=e.height,m=void 0===g?"":g,y=e.minHeight,b=void 0===y?"":y,v=e.maxHeight,w=void 0===v?"":v,x=e.placeholder,k=void 0===x?"":x,S=e.width,O=void 0===S?"":S,A=e.minWidth,C=void 0===A?"":A,N=e.maxWidth,_=void 0===N?"":N,E=e.editable,P=void 0===E||E,T=e.readOnly,j=void 0!==T&&T,I=e.indentWithTab,B=void 0===I||I,M=e.basicSetup,W=void 0===M||M,R=e.root,z=i((0,s.useState)(e.container),2),D=z[0],L=z[1],U=i((0,s.useState)(),2),q=U[0],V=U[1],H=i((0,s.useState)(),2),J=H[0],F=H[1],$=a.EditorView.theme({"&":{height:m,minHeight:b,maxHeight:w,width:O,minWidth:C,maxWidth:_}}),Z=[a.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof n){var t=e.state.doc.toString();n(t,e)}})),$];switch(B&&Z.unshift(a.keymap.of([Qe])),W&&Z.unshift(o.basicSetup),k&&Z.unshift((0,a.placeholder)(k)),p){case"light":Z.push(et);break;case"dark":Z.push(Xe.oneDark);break;default:Z.push(p)}return!1===P&&Z.push(a.EditorView.editable.of(!1)),j&&Z.push(l.EditorState.readOnly.of(!0)),h&&"function"===typeof h&&Z.push(a.EditorView.updateListener.of(h)),Z=Z.concat(f),(0,s.useEffect)((function(){if(D&&!J){var e=l.EditorState.create({doc:t,selection:r,extensions:Z});if(F(e),!q){var n=new a.EditorView({state:e,parent:D,root:R});V(n)}}return function(){q&&V(void 0)}}),[D,J]),(0,s.useEffect)((function(){return function(){q&&(q.destroy(),V(void 0))}}),[q]),(0,s.useEffect)((function(){c&&q&&q.focus()}),[c,q]),(0,s.useEffect)((function(){var e=q?q.state.doc.toString():"";q&&t!==e&&q.dispatch({changes:{from:0,to:e.length,insert:t||""}})}),[t,q]),(0,s.useEffect)((function(){q&&q.dispatch({effects:l.StateEffect.reconfigure.of(Z)})}),[p,f,m,b,w,O,k,C,_,P,B,W]),{state:J,setState:F,view:q,setView:V,container:D,setContainer:L}}},638:(e,t,r)=>{var n=r(787),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function h(e,t,r){var n,s={},h=null,u=null;for(n in void 0!==r&&(h=""+r),void 0!==t.key&&(h=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!a.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:i,type:e,key:h,ref:u,props:s,_owner:l.current}}t.jsx=h},724:(e,t,r)=>{e.exports=r(638)},787:t=>{t.exports=e},573:e=>{e.exports=t},242:e=>{e.exports=r},362:e=>{e.exports=n},105:e=>{e.exports=i},683:(e,t,r)=>{function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r.d(t,{Z:()=>s})},925:(e,t,r)=>{function n(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n<s.length;n++)r=s[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}r.d(t,{Z:()=>n})}},o={};function l(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return s[e](r,r.exports,l),r.exports}l.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return l.d(t,{a:t}),t},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{l.r(a),l.d(a,{default:()=>p,useCodeMirror:()=>i.U});var e=l(683),t=l(925),r=l(787),n=l.n(r),i=l(963),s=l(724),o=l(105),h={};for(const l in o)"default"!==l&&(h[l]=()=>o[l]);l.d(a,h);var u=l(573);h={};for(const l in u)"default"!==l&&(h[l]=()=>u[l]);l.d(a,h);var f=l(242);h={};for(const l in f)"default"!==l&&(h[l]=()=>f[l]);l.d(a,h);var c=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root"],d=n().forwardRef((function(n,o){var l=n.className,a=n.value,h=void 0===a?"":a,u=n.selection,f=n.extensions,d=void 0===f?[]:f,p=n.onChange,g=n.onUpdate,m=n.autoFocus,y=n.theme,b=void 0===y?"light":y,v=n.height,w=n.minHeight,x=n.maxHeight,k=n.width,S=n.minWidth,O=n.maxWidth,A=n.basicSetup,C=n.placeholder,N=n.indentWithTab,_=n.editable,E=n.readOnly,P=n.root,T=(0,t.Z)(n,c),j=(0,r.useRef)(null),I=(0,i.U)({container:j.current,root:P,value:h,autoFocus:m,theme:b,height:v,minHeight:w,maxHeight:x,width:k,minWidth:S,maxWidth:O,basicSetup:A,placeholder:C,indentWithTab:N,editable:_,readOnly:E,selection:u,onChange:p,onUpdate:g,extensions:d}),B=I.state,M=I.view,W=I.container,R=I.setContainer;if((0,r.useImperativeHandle)(o,(function(){return{editor:W,state:B,view:M}}),[W,B,M]),(0,r.useEffect)((function(){R(j.current)}),[]),"string"!==typeof h)throw new Error("value must be typeof string but got ".concat(typeof h));var z="string"===typeof b?"cm-theme-".concat(b):"cm-theme";return(0,s.jsx)("div",(0,e.Z)({ref:j,className:"".concat(z).concat(l?" ".concat(l):"")},T))}));d.displayName="CodeMirror";const p=d})(),a})()));
|
package/esm/theme/light.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const defaultLightThemeOption: import("@codemirror/state").Extension;
|