@uiw/react-codemirror 4.3.2 → 4.4.2
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 +14 -2
- package/cjs/index.js +4 -8
- package/cjs/index.js.map +2 -3
- package/cjs/useCodeMirror.js +22 -25
- package/cjs/useCodeMirror.js.map +8 -6
- package/dist/codemirror.js +8131 -0
- package/dist/codemirror.min.js +2 -0
- package/dist/codemirror.min.js.LICENSE.txt +14 -0
- package/esm/index.js +3 -8
- package/esm/index.js.map +2 -3
- package/esm/useCodeMirror.js +28 -35
- package/esm/useCodeMirror.js.map +8 -7
- package/package.json +17 -18
- package/src/__tests__/index.test.tsx +87 -0
- package/src/index.tsx +2 -7
- package/src/useCodeMirror.ts +29 -33
- package/src/react-app-env.d.ts +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
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.codemirror=t(require("react"),require("@codemirror/basic-setup"),require("@codemirror/state"),require("@codemirror/theme-one-dark"),require("@codemirror/view")):e.codemirror=t(e.React,e.CM["@codemirror/basic-setup"],e.CM["@codemirror/state"],e.CM["@codemirror/theme-one-dark"],e.CM["@codemirror/view"])}(self,(function(e,t,n,r,i){return function(){"use strict";var o={927:function(e,t,n){function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function i(e,t){if(e){if("string"===typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],s=!0,u=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(o.push(r.value),!t||o.length!==t);s=!0);}catch(a){u=!0,i=a}finally{try{s||null==n.return||n.return()}finally{if(u)throw i}}return o}}(e,t)||i(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.")}()}n.d(t,{U:function(){return We}});var s=n(787),u=n(573),a=n(242);function h(e,t){var n="undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=i(e))||t&&e&&"number"===typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return u=e.done,e},e:function(e){a=!0,s=e},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw s}}}}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function l(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}function c(){return c="undefined"!==typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=l(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},c.apply(this,arguments)}function d(e,t){return d=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},d(e,t)}function v(e,t){if("function"!==typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function g(e,t){if(t&&("object"===p(t)||"function"===typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function y(e){var t=function(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=f(e);if(t){var i=f(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return g(this,n)}}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function b(e,t,n){return t&&k(e.prototype,t),n&&k(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}for(var x="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((function(e){return e?parseInt(e,36):1})),w=1;w<x.length;w++)x[w]+=x[w-1];function S(e){for(var t=1;t<x.length;t+=2)if(x[t]>e)return x[t-1]<=e;return!1}function C(e){return e>=127462&&e<=127487}function _(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return(n?O:A)(e,t,r)}function O(e,t,n){if(t==e.length)return t;t&&j(e.charCodeAt(t))&&P(e.charCodeAt(t-1))&&t--;var r=E(e,t);for(t+=B(r);t<e.length;){var i=E(e,t);if(8205==r||8205==i||n&&S(i))t+=B(i),r=i;else{if(!C(i))break;for(var o=0,s=t-2;s>=0&&C(E(e,s));)o++,s-=2;if(o%2==0)break;t+=2}}return t}function A(e,t,n){for(;t>0;){var r=O(e,t-2,n);if(r<t)return r;t--}return 0}function j(e){return e>=56320&&e<57344}function P(e){return e>=55296&&e<56320}function E(e,t){var n=e.charCodeAt(t);if(!P(n)||t+1==e.length)return n;var r=e.charCodeAt(t+1);return j(r)?r-56320+(n-55296<<10)+65536:n}function B(e){return e<65536?1:2}function N(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,r=0,i=0;i<n;)9==e.charCodeAt(i)?(r+=t-r%t,i++):(r++,i=_(e,i));return r}var T=function(){function e(){m(this,e)}return b(e,[{key:"lineAt",value:function(e){if(e<0||e>this.length)throw new RangeError("Invalid position ".concat(e," in document of length ").concat(this.length));return this.lineInner(e,!1,1,0)}},{key:"line",value:function(e){if(e<1||e>this.lines)throw new RangeError("Invalid line number ".concat(e," in ").concat(this.lines,"-line document"));return this.lineInner(e,!0,1,0)}},{key:"replace",value:function(e,t,n){var r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),M.from(r,this.length-(t-e)+n.length)}},{key:"append",value:function(e){return this.replace(this.length,this.length,e)}},{key:"slice",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=[];return this.decompose(e,t,n,0),M.from(n,t-e)}},{key:"eq",value:function(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;for(var t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new q(this),i=new q(e),o=t,s=t;;){if(r.next(o),i.next(o),o=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(s+=r.value.length,r.done||s>=n)return!0}}},{key:"iter",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new q(this,e)}},{key:"iterRange",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return new L(this,e,t)}},{key:"iterLines",value:function(e,t){var n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);var r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new U(n)}},{key:"toString",value:function(){return this.sliceString(0)}},{key:"toJSON",value:function(){var e=[];return this.flatten(e),e}}],[{key:"of",value:function(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new I(t):M.from(I.split(t,[])):e.empty}}]),e}(),I=function(e){v(n,e);var t=y(n);function n(e){var r,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:R(e);return m(this,n),(r=t.call(this)).text=e,r.length=i,r}return b(n,[{key:"lines",get:function(){return this.text.length}},{key:"children",get:function(){return null}},{key:"lineInner",value:function(e,t,n,r){for(var i=0;;i++){var o=this.text[i],s=r+o.length;if((t?n:s)>=e)return new D(r,s,n,o);r=s+1,n++}}},{key:"decompose",value:function(e,t,r,i){var o=e<=0&&t>=this.length?this:new n(z(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&i){var s=r.pop(),u=W(o.text,s.text.slice(),0,o.length);if(u.length<=32)r.push(new n(u,s.length+o.length));else{var a=u.length>>1;r.push(new n(u.slice(0,a)),new n(u.slice(a)))}}else r.push(o)}},{key:"replace",value:function(e,t,r){if(!(r instanceof n))return c(f(n.prototype),"replace",this).call(this,e,t,r);var i=W(this.text,W(r.text,z(this.text,0,e)),t),o=this.length+r.length-(t-e);return i.length<=32?new n(i,o):M.from(n.split(i,[]),o)}},{key:"sliceString",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",r="",i=0,o=0;i<=t&&o<this.text.length;o++){var s=this.text[o],u=i+s.length;i>e&&o&&(r+=n),e<u&&t>i&&(r+=s.slice(Math.max(0,e-i),t-i)),i=u+1}return r}},{key:"flatten",value:function(e){var t,n=h(this.text);try{for(n.s();!(t=n.n()).done;){var r=t.value;e.push(r)}}catch(i){n.e(i)}finally{n.f()}}},{key:"scanIdentical",value:function(){return 0}}],[{key:"split",value:function(e,t){var r,i=[],o=-1,s=h(e);try{for(s.s();!(r=s.n()).done;){var u=r.value;i.push(u),o+=u.length+1,32==i.length&&(t.push(new n(i,o)),i=[],o=-1)}}catch(a){s.e(a)}finally{s.f()}return o>-1&&t.push(new n(i,o)),t}}]),n}(T),M=function(e){v(n,e);var t=y(n);function n(e,r){var i;m(this,n),(i=t.call(this)).children=e,i.length=r,i.lines=0;var o,s=h(e);try{for(s.s();!(o=s.n()).done;){var u=o.value;i.lines+=u.lines}}catch(a){s.e(a)}finally{s.f()}return i}return b(n,[{key:"lineInner",value:function(e,t,n,r){for(var i=0;;i++){var o=this.children[i],s=r+o.length,u=n+o.lines-1;if((t?u:s)>=e)return o.lineInner(e,t,n,r);r=s+1,n=u+1}}},{key:"decompose",value:function(e,t,n,r){for(var i=0,o=0;o<=t&&i<this.children.length;i++){var s=this.children[i],u=o+s.length;if(e<=u&&t>=o){var a=r&((o<=e?1:0)|(u>=t?2:0));o>=e&&u<=t&&!a?n.push(s):s.decompose(e-o,t-o,n,a)}o=u+1}}},{key:"replace",value:function(e,t,r){if(r.lines<this.lines)for(var i=0,o=0;i<this.children.length;i++){var s=this.children[i],u=o+s.length;if(e>=o&&t<=u){var a=s.replace(e-o,t-o,r),h=this.lines-s.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){var l=this.children.slice();return l[i]=a,new n(l,this.length-(t-e)+r.length)}return c(f(n.prototype),"replace",this).call(this,o,u,a)}o=u+1}return c(f(n.prototype),"replace",this).call(this,e,t,r)}},{key:"sliceString",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n",r="",i=0,o=0;i<this.children.length&&o<=t;i++){var s=this.children[i],u=o+s.length;o>e&&i&&(r+=n),e<u&&t>o&&(r+=s.sliceString(e-o,t-o,n)),o=u+1}return r}},{key:"flatten",value:function(e){var t,n=h(this.children);try{for(n.s();!(t=n.n()).done;){t.value.flatten(e)}}catch(r){n.e(r)}finally{n.f()}}},{key:"scanIdentical",value:function(e,t){if(!(e instanceof n))return 0;for(var r=0,i=o(t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1],4),s=i[0],u=i[1],a=i[2],h=i[3];;s+=t,u+=t){if(s==a||u==h)return r;var f=this.children[s],l=e.children[u];if(f!=l)return r+f.scanIdentical(l,t);r+=f.length+1}}}],[{key:"from",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.reduce((function(e,t){return e+t.length+1}),-1),i=0,o=h(e);try{for(o.s();!(t=o.n()).done;){var s=t.value;i+=s.lines}}catch(C){o.e(C)}finally{o.f()}if(i<32){var u,a=[],f=h(e);try{for(f.s();!(u=f.n()).done;){var l=u.value;l.flatten(a)}}catch(C){f.e(C)}finally{f.f()}return new I(a,r)}var c=Math.max(32,i>>5),d=c<<1,v=c>>1,p=[],g=0,y=-1,m=[];function k(e){var t;if(e.lines>d&&e instanceof n){var r,i=h(e.children);try{for(i.s();!(r=i.n()).done;){k(r.value)}}catch(C){i.e(C)}finally{i.f()}}else e.lines>v&&(g>v||!g)?(b(),p.push(e)):e instanceof I&&g&&(t=m[m.length-1])instanceof I&&e.lines+t.lines<=32?(g+=e.lines,y+=e.length+1,m[m.length-1]=new I(t.text.concat(e.text),t.length+1+e.length)):(g+e.lines>c&&b(),g+=e.lines,y+=e.length+1,m.push(e))}function b(){0!=g&&(p.push(1==m.length?m[0]:n.from(m,y)),y=-1,g=m.length=0)}var x,w=h(e);try{for(w.s();!(x=w.n()).done;){var S=x.value;k(S)}}catch(C){w.e(C)}finally{w.f()}return b(),1==p.length?p[0]:new n(p,r)}}]),n}(T);function R(e){var t,n=-1,r=h(e);try{for(r.s();!(t=r.n()).done;){n+=t.value.length+1}}catch(i){r.e(i)}finally{r.f()}return n}function W(e,t){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e9,i=0,o=0,s=!0;o<e.length&&i<=r;o++){var u=e[o],a=i+u.length;a>=n&&(a>r&&(u=u.slice(0,r-i)),i<n&&(u=u.slice(n-i)),s?(t[t.length-1]+=u,s=!1):t.push(u)),i=a+1}return t}function z(e,t,n){return W(e,[""],t,n)}T.empty=new I([""],0);var q=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;m(this,e),this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[n>0?1:(t instanceof I?t.text.length:t.children.length)<<1]}return b(e,[{key:"nextInner",value:function(e,t){for(this.done=this.lineBreak=!1;;){var n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof I?r.text.length:r.children.length;if(o==(t>0?s:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&i)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(r instanceof I){var u=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,u.length>Math.max(0,e))return this.value=0==e?u:t>0?u.slice(e):u.slice(0,u.length-e),this;e-=u.length}else{var a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof I?a.text.length:a.children.length)<<1))}}}},{key:"next",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}]),e}(),L=function(){function e(t,n,r){m(this,e),this.value="",this.done=!1,this.cursor=new q(t,n>r?-1:1),this.pos=n>r?t.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}return b(e,[{key:"nextInner",value:function(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);var n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;var r=this.cursor.next(e).value;return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}},{key:"next",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}},{key:"lineBreak",get:function(){return this.cursor.lineBreak&&""!=this.value}}]),e}(),U=function(){function e(t){m(this,e),this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}return b(e,[{key:"next",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=this.inner.next(e),n=t.done,r=t.lineBreak,i=t.value;return n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}},{key:"lineBreak",get:function(){return!1}}]),e}();"undefined"!=typeof Symbol&&(T.prototype[Symbol.iterator]=function(){return this.iter()},q.prototype[Symbol.iterator]=L.prototype[Symbol.iterator]=U.prototype[Symbol.iterator]=function(){return this});var D=function(){function e(t,n,r,i){m(this,e),this.from=t,this.to=n,this.number=r,this.text=i}return b(e,[{key:"length",get:function(){return this.to-this.from}}]),e}(),H=n(105),V=0,F=b((function e(t,n){m(this,e),this.from=t,this.to=n})),J=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};m(this,e),this.id=V++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||function(){throw new Error("This node type doesn't define a deserialize function")}}return b(e,[{key:"add",value:function(e){var t=this;if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=$.match(e)),function(n){var r=e(n);return void 0===r?null:[t,r]}}}]),e}();J.closedBy=new J({deserialize:function(e){return e.split(" ")}}),J.openedBy=new J({deserialize:function(e){return e.split(" ")}}),J.group=new J({deserialize:function(e){return e.split(" ")}}),J.contextHash=new J({perNode:!0}),J.lookAhead=new J({perNode:!0}),J.mounted=new J({perNode:!0});var Z=Object.create(null),$=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;m(this,e),this.name=t,this.props=n,this.id=r,this.flags=i}return b(e,[{key:"prop",value:function(e){return this.props[e.id]}},{key:"isTop",get:function(){return(1&this.flags)>0}},{key:"isSkipped",get:function(){return(2&this.flags)>0}},{key:"isError",get:function(){return(4&this.flags)>0}},{key:"isAnonymous",get:function(){return(8&this.flags)>0}},{key:"is",value:function(e){if("string"==typeof e){if(this.name==e)return!0;var t=this.prop(J.group);return!!t&&t.indexOf(e)>-1}return this.id==e}}],[{key:"define",value:function(t){var n=t.props&&t.props.length?Object.create(null):Z,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),i=new e(t.name||"",n,t.id,r);if(t.props){var o,s=h(t.props);try{for(s.s();!(o=s.n()).done;){var u=o.value;if(Array.isArray(u)||(u=u(i)),u){if(u[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[u[0].id]=u[1]}}}catch(a){s.e(a)}finally{s.f()}}return i}},{key:"match",value:function(e){var t=Object.create(null);for(var n in e){var r,i=h(n.split(" "));try{for(i.s();!(r=i.n()).done;){var o=r.value;t[o]=e[n]}}catch(s){i.e(s)}finally{i.f()}}return function(e){for(var n=e.prop(J.group),r=-1;r<(n?n.length:0);r++){var i=t[r<0?e.name:n[r]];if(i)return i}}}}]),e}();$.none=new $("",Object.create(null),0,8);var Y=new WeakMap,G=new WeakMap,K=function(){function e(t,n,r,i,s){if(m(this,e),this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);var u,a=h(s);try{for(a.s();!(u=a.n()).done;){var f=o(u.value,2),l=f[0],c=f[1];this.props["number"==typeof l?l:l.id]=c}}catch(d){a.e(d)}finally{a.f()}}}return b(e,[{key:"toString",value:function(){var e=this.prop(J.mounted);if(e&&!e.overlay)return e.tree.toString();var t,n="",r=h(this.children);try{for(r.s();!(t=r.n()).done;){var i=t.value.toString();i&&(n&&(n+=","),n+=i)}}catch(o){r.e(o)}finally{r.f()}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}},{key:"cursor",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=null!=e&&Y.get(this)||this.topNode,r=new ue(n);return null!=e&&(r.moveTo(e,t),Y.set(this,r._tree)),r}},{key:"fullCursor",value:function(){return new ue(this.topNode,1)}},{key:"topNode",get:function(){return new re(this,0,0,null)}},{key:"resolve",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=ne(Y.get(this)||this.topNode,e,t,!1);return Y.set(this,n),n}},{key:"resolveInner",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=ne(G.get(this)||this.topNode,e,t,!0);return G.set(this,n),n}},{key:"iterate",value:function(e){for(var t=e.enter,n=e.leave,r=e.from,i=void 0===r?0:r,o=e.to,s=void 0===o?this.length:o,u=this.cursor(),a=function(){return u.node};;){var h=!1;if(u.from<=s&&u.to>=i&&(u.type.isAnonymous||!1!==t(u.type,u.from,u.to,a))){if(u.firstChild())continue;u.type.isAnonymous||(h=!0)}for(;h&&n&&n(u.type,u.from,u.to,a),h=u.type.isAnonymous,!u.nextSibling();){if(!u.parent())return;h=!0}}}},{key:"prop",value:function(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}},{key:"propValues",get:function(){var e=[];if(this.props)for(var t in this.props)e.push([+t,this.props[t]]);return e}},{key:"balance",value:function(){var t=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.children.length<=8?this:ce($.none,this.children,this.positions,0,this.children.length,0,this.length,(function(n,r,i){return new e(t.type,n,r,i,t.propValues)}),n.makeTree||function(t,n,r){return new e($.none,t,n,r)})}}],[{key:"build",value:function(e){return he(e)}}]),e}();K.empty=new K($.none,[],[],0);var Q=function(){function e(t,n){m(this,e),this.buffer=t,this.index=n}return b(e,[{key:"id",get:function(){return this.buffer[this.index-4]}},{key:"start",get:function(){return this.buffer[this.index-3]}},{key:"end",get:function(){return this.buffer[this.index-2]}},{key:"size",get:function(){return this.buffer[this.index-1]}},{key:"pos",get:function(){return this.index}},{key:"next",value:function(){this.index-=4}},{key:"fork",value:function(){return new e(this.buffer,this.index)}}]),e}(),X=function(){function e(t,n,r){m(this,e),this.buffer=t,this.length=n,this.set=r}return b(e,[{key:"type",get:function(){return $.none}},{key:"toString",value:function(){for(var e=[],t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}},{key:"childString",value:function(e){var t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),n==(e+=4))return i;for(var o=[];e<n;)o.push(this.childString(e)),e=this.buffer[e+3];return i+"("+o.join(",")+")"}},{key:"findChild",value:function(e,t,n,r,i){for(var o=this.buffer,s=-1,u=e;u!=t&&!(ee(i,r,o[u+1],o[u+2])&&(s=u,n>0));u=o[u+3]);return s}},{key:"slice",value:function(t,n,r,i){for(var o=this.buffer,s=new Uint16Array(n-t),u=t,a=0;u<n;)s[a++]=o[u++],s[a++]=o[u++]-r,s[a++]=o[u++]-r,s[a++]=o[u++]-t;return new e(s,i-r,this.set)}}]),e}();function ee(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function te(e,t){for(var n=e.childBefore(t);n;){var r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(e=n,n=r.prevSibling):n=r}return e}function ne(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){var o=!r&&e instanceof re&&e.index<0?null:e.parent;if(!o)return e;e=o}if(r)for(var s=e,u=s.parent;u;u=(s=u).parent)s instanceof re&&s.index<0&&(null===(i=u.enter(t,n,!0))||void 0===i?void 0:i.from)!=s.from&&(e=u);for(;;){var a=e.enter(t,n,r);if(!a)return e;e=a}}var re=function(){function e(t,n,r,i){m(this,e),this.node=t,this._from=n,this.index=r,this._parent=i}return b(e,[{key:"type",get:function(){return this.node.type}},{key:"name",get:function(){return this.node.type.name}},{key:"from",get:function(){return this._from}},{key:"to",get:function(){return this._from+this.node.length}},{key:"nextChild",value:function(t,n,r,i){for(var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=this;;){for(var u=s.node,a=u.children,h=u.positions,f=n>0?a.length:-1;t!=f;t+=n){var l=a[t],c=h[t]+s._from;if(ee(i,r,c,c+l.length))if(l instanceof X){if(2&o)continue;var d=l.findChild(0,l.buffer.length,n,r-c,i);if(d>-1)return new se(new oe(s,l,t,c),null,d)}else if(1&o||!l.type.isAnonymous||ae(l)){var v=void 0;if(!(1&o)&&l.props&&(v=l.prop(J.mounted))&&!v.overlay)return new e(v.tree,c,t,s);var p=new e(l,c,t,s);return 1&o||!p.type.isAnonymous?p:p.nextChild(n<0?l.children.length-1:0,n,r,i)}}if(1&o||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+n:n<0?-1:s._parent.node.children.length,!(s=s._parent))return null}}},{key:"firstChild",get:function(){return this.nextChild(0,1,0,4)}},{key:"lastChild",get:function(){return this.nextChild(this.node.children.length-1,-1,0,4)}},{key:"childAfter",value:function(e){return this.nextChild(0,1,e,2)}},{key:"childBefore",value:function(e){return this.nextChild(this.node.children.length-1,-1,e,-2)}},{key:"enter",value:function(t,n){var r,i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(i&&(r=this.node.prop(J.mounted))&&r.overlay){var s,u=t-this.from,a=h(r.overlay);try{for(a.s();!(s=a.n()).done;){var f=s.value,l=f.from,c=f.to;if((n>0?l<=u:l<u)&&(n<0?c>=u:c>u))return new e(r.tree,r.overlay[0].from+this.from,-1,this)}}catch(d){a.e(d)}finally{a.f()}}return this.nextChild(0,1,t,n,o?0:2)}},{key:"nextSignificantParent",value:function(){for(var e=this;e.type.isAnonymous&&e._parent;)e=e._parent;return e}},{key:"parent",get:function(){return this._parent?this._parent.nextSignificantParent():null}},{key:"nextSibling",get:function(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}},{key:"prevSibling",get:function(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}},{key:"cursor",get:function(){return new ue(this)}},{key:"tree",get:function(){return this.node}},{key:"toTree",value:function(){return this.node}},{key:"resolve",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ne(this,e,t,!1)}},{key:"resolveInner",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ne(this,e,t,!0)}},{key:"enterUnfinishedNodesBefore",value:function(e){return te(this,e)}},{key:"getChild",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=ie(this,e,t,n);return r.length?r[0]:null}},{key:"getChildren",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return ie(this,e,t,n)}},{key:"toString",value:function(){return this.node.toString()}}]),e}();function ie(e,t,n,r){var i=e.cursor,o=[];if(!i.firstChild())return o;if(null!=n)for(;!i.type.is(n);)if(!i.nextSibling())return o;for(;;){if(null!=r&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return null==r?o:[]}}var oe=b((function e(t,n,r,i){m(this,e),this.parent=t,this.buffer=n,this.index=r,this.start=i})),se=function(){function e(t,n,r){m(this,e),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}return b(e,[{key:"name",get:function(){return this.type.name}},{key:"from",get:function(){return this.context.start+this.context.buffer.buffer[this.index+1]}},{key:"to",get:function(){return this.context.start+this.context.buffer.buffer[this.index+2]}},{key:"child",value:function(t,n,r){var i=this.context.buffer,o=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return o<0?null:new e(this.context,this,o)}},{key:"firstChild",get:function(){return this.child(1,0,4)}},{key:"lastChild",get:function(){return this.child(-1,0,4)}},{key:"childAfter",value:function(e){return this.child(1,e,2)}},{key:"childBefore",value:function(e){return this.child(-1,e,-2)}},{key:"enter",value:function(t,n,r){var i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(!i)return null;var o=this.context.buffer,s=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return s<0?null:new e(this.context,this,s)}},{key:"parent",get:function(){return this._parent||this.context.parent.nextSignificantParent()}},{key:"externalSibling",value:function(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}},{key:"nextSibling",get:function(){var t=this.context.buffer,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}},{key:"prevSibling",get:function(){var t=this.context.buffer,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}},{key:"cursor",get:function(){return new ue(this)}},{key:"tree",get:function(){return null}},{key:"toTree",value:function(){var e=[],t=[],n=this.context.buffer,r=this.index+4,i=n.buffer[this.index+3];if(i>r){var o=n.buffer[this.index+1],s=n.buffer[this.index+2];e.push(n.slice(r,i,o,s)),t.push(0)}return new K(this.type,e,t,this.to-this.from)}},{key:"resolve",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ne(this,e,t,!1)}},{key:"resolveInner",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return ne(this,e,t,!0)}},{key:"enterUnfinishedNodesBefore",value:function(e){return te(this,e)}},{key:"toString",value:function(){return this.context.buffer.childString(this.index)}},{key:"getChild",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=ie(this,e,t,n);return r.length?r[0]:null}},{key:"getChildren",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return ie(this,e,t,n)}}]),e}(),ue=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(m(this,e),this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof re)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(var r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}}return b(e,[{key:"name",get:function(){return this.type.name}},{key:"yieldNode",value:function(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}},{key:"yieldBuf",value:function(e,t){this.index=e;var n=this.buffer,r=n.start,i=n.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}},{key:"yield",value:function(e){return!!e&&(e instanceof re?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}},{key:"toString",value:function(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}},{key:"enterChild",value:function(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree.node.children.length-1:0,e,t,n,this.mode));var r=this.buffer.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return!(i<0)&&(this.stack.push(this.index),this.yieldBuf(i))}},{key:"firstChild",value:function(){return this.enterChild(1,0,4)}},{key:"lastChild",value:function(){return this.enterChild(-1,0,4)}},{key:"childAfter",value:function(e){return this.enterChild(1,e,2)}},{key:"childBefore",value:function(e){return this.enterChild(-1,e,-2)}},{key:"enter",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return this.buffer?!!r&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n&&!(1&this.mode),r))}},{key:"parent",value:function(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());var e=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}},{key:"sibling",value:function(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));var t=this.buffer.buffer,n=this.stack.length-1;if(e<0){var r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{var i=t.buffer[this.index+3];if(i<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(i)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}},{key:"nextSibling",value:function(){return this.sibling(1)}},{key:"prevSibling",value:function(){return this.sibling(-1)}},{key:"atLastNode",value:function(e){var t,n,r=this.buffer;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(var i=0;i<this.index;i++)if(r.buffer.buffer[i+3]<this.index)return!1;t=r.index,n=r.parent}else{var o=this._tree;t=o.index,n=o._parent}for(;n;t=(s=n).index,n=s._parent,s){var s;if(t>-1)for(var u=t+e,a=e<0?-1:n.node.children.length;u!=a;u+=e){var h=n.node.children[u];if(1&this.mode||h instanceof X||!h.type.isAnonymous||ae(h))return!1}}return!0}},{key:"move",value:function(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}}},{key:"next",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(1,e)}},{key:"prev",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.move(-1,e)}},{key:"moveTo",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;(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}},{key:"node",get:function(){if(!this.buffer)return this._tree;var e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(var r=this.index,i=this.stack.length;i>=0;){for(var o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(var s=n;s<this.stack.length;s++)t=new se(this.buffer,t,this.stack[s]);return this.bufferNode=new se(this.buffer,t,this.index)}},{key:"tree",get:function(){return this.buffer?null:this._tree.node}}]),e}();function ae(e){return e.children.some((function(e){return e instanceof X||!e.type.isAnonymous||ae(e)}))}function he(e){var t,n=e.buffer,r=e.nodeSet,i=e.maxBufferLength,o=void 0===i?1024:i,s=e.reused,u=void 0===s?[]:s,a=e.minRepeatType,h=void 0===a?r.types.length:a,f=Array.isArray(n)?new Q(n,n.length):n,l=r.types,c=0,d=0;function v(e,t,n,i,s){for(var a=f.id,m=f.start,k=f.end,b=f.size,x=d;b<0;){if(f.next(),-1==b){var w=u[a];return n.push(w),void i.push(m-e)}if(-3==b)return void(c=a);if(-4==b)return void(d=a);throw new RangeError("Unrecognized record size: ".concat(b))}var S,C,_=l[a],O=m-e;if(k-m<=o&&(C=function(e,t){var n=f.fork(),r=0,i=0,s=0,u=n.end-o,a={size:0,start:0,skip:0};e:for(var l=n.pos-e;n.pos>l;){var c=n.size;if(n.id==t&&c>=0)a.size=r,a.start=i,a.skip=s,s+=4,r+=4,n.next();else{var d=n.pos-c;if(c<0||d<l||n.start<u)break;var v=n.id>=h?4:0,p=n.start;for(n.next();n.pos>d;){if(n.size<0){if(-3!=n.size)break e;v+=4}else n.id>=h&&(v+=4);n.next()}i=p,r+=c,s+=v}}(t<0||r==e)&&(a.size=r,a.start=i,a.skip=s);return a.size>4?a:void 0}(f.pos-t,s))){for(var A=new Uint16Array(C.size-C.skip),j=f.pos-C.size,P=A.length;f.pos>j;)P=y(C.start,A,P);S=new X(A,k-C.start,r),O=C.start-e}else{var E=f.pos-b;f.next();for(var B=[],N=[],T=a>=h?a:-1,I=0,M=k;f.pos>E;)T>=0&&f.id==T&&f.size>=0?(f.end<=M-o&&(p(B,N,m,I,f.end,M,T,x),I=B.length,M=f.end),f.next()):v(m,E,B,N,T);if(T>=0&&I>0&&I<B.length&&p(B,N,m,I,m,M,T,x),B.reverse(),N.reverse(),T>-1&&I>0){var R=function(e){return function(t,n,r){var i,o,s=0,u=t.length-1;if(u>=0&&(i=t[u])instanceof K){if(!u&&i.type==e&&i.length==r)return i;(o=i.prop(J.lookAhead))&&(s=n[u]+i.length+o)}return g(e,t,n,r,s)}}(_);S=ce(_,B,N,0,B.length,0,k-m,R,R)}else S=g(_,B,N,k-m,x-k)}n.push(S),i.push(O)}function p(e,t,n,i,o,s,u,a){for(var h=[],f=[];e.length>i;)h.push(e.pop()),f.push(t.pop()+n-o);e.push(g(r.types[u],h,f,s-o,a-s)),t.push(o-n)}function g(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5?arguments[5]:void 0;if(c){var s=[J.contextHash,c];o=o?[s].concat(o):[s]}if(i>25){var u=[J.lookAhead,i];o=o?[u].concat(o):[u]}return new K(e,t,n,r,o)}function y(e,t,n){var r=f.id,i=f.start,o=f.end,s=f.size;if(f.next(),s>=0&&r<h){var u=n;if(s>4)for(var a=f.pos-(s-4);f.pos>a;)n=y(e,t,n);t[--n]=u,t[--n]=o-e,t[--n]=i-e,t[--n]=r}else-3==s?c=r:-4==s&&(d=r);return n}for(var m=[],k=[];f.pos>0;)v(e.start||0,e.bufferStart||0,m,k,-1);var b=null!==(t=e.length)&&void 0!==t?t:m.length?k[0]+m[0].length:0;return new K(l[e.topID],m.reverse(),k.reverse(),b)}var fe=new WeakMap;function le(e,t){if(!e.isAnonymous||t instanceof X||t.type!=e)return 1;var n=fe.get(t);if(null==n){n=1;var r,i=h(t.children);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o.type!=e||!(o instanceof K)){n=1;break}n+=le(e,o)}}catch(s){i.e(s)}finally{i.f()}fe.set(t,n)}return n}function ce(e,t,n,r,i,o,s,u,a){for(var h=0,f=r;f<i;f++)h+=le(e,t[f]);var l=Math.ceil(1.5*h/8),c=[],d=[];return function t(n,r,i,s,u){for(var h=i;h<s;){var f=h,v=r[h],p=le(e,n[h]);for(h++;h<s;h++){var g=le(e,n[h]);if(p+g>=l)break;p+=g}if(h==f+1){if(p>l){var y=n[f];t(y.children,y.positions,0,y.children.length,r[f]+u);continue}c.push(n[f])}else{var m=r[h-1]+n[h-1].length-v;c.push(ce(e,n,r,f,h,v,m,null,a))}d.push(v+u-o)}}(t,n,r,i,0),(u||a)(c,d,s)}var de=function(){function e(t,n,r,i){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];m(this,e),this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(o?1:0)|(s?2:0)}return b(e,[{key:"openStart",get:function(){return(1&this.open)>0}},{key:"openEnd",get:function(){return(2&this.open)>0}}],[{key:"addTree",value:function(t){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=[new e(0,t.length,t,0,!1,i)],s=h(r);try{for(s.s();!(n=s.n()).done;){var u=n.value;u.to>t.length&&o.push(u)}}catch(a){s.e(a)}finally{s.f()}return o}},{key:"applyChanges",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:128;if(!n.length)return t;for(var i=[],o=1,s=t.length?t[0]:null,u=0,a=0,h=0;;u++){var f=u<n.length?n[u]:null,l=f?f.fromA:1e9;if(l-a>=r)for(;s&&s.from<l;){var c=s;if(a>=c.from||l<=c.to||h){var d=Math.max(c.from,a)-h,v=Math.min(c.to,l)-h;c=d>=v?null:new e(d,v,c.tree,c.offset+h,u>0,!!f)}if(c&&i.push(c),s.to>l)break;s=o<t.length?t[o++]:null}if(!f)break;a=f.toA,h=f.toA-f.toB}return i}}]),e}(),ve=function(){function e(){m(this,e)}return b(e,[{key:"startParse",value:function(e,t,n){return"string"==typeof e&&(e=new pe(e)),n=n?n.length?n.map((function(e){return new F(e.from,e.to)})):[new F(0,0)]:[new F(0,e.length)],this.createParse(e,t||[],n)}},{key:"parse",value:function(e,t,n){for(var r=this.startParse(e,t,n);;){var i=r.advance();if(i)return i}}}]),e}(),pe=function(){function e(t){m(this,e),this.string=t}return b(e,[{key:"length",get:function(){return this.string.length}},{key:"chunk",value:function(e){return this.string.slice(e)}},{key:"lineChunks",get:function(){return!1}},{key:"read",value:function(e,t){return this.string.slice(e,t)}}]),e}();new J({perNode:!0});var ge=new J;var ye=function(){function e(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[];m(this,e),this.data=t,this.topNode=r,a.EditorState.prototype.hasOwnProperty("tree")||Object.defineProperty(a.EditorState.prototype,"tree",{get:function(){return ke(this)}}),this.parser=n,this.extension=[Ae.of(this),a.EditorState.languageData.of((function(e,t,n){return e.facet(me(e,t,n))}))].concat(i)}return b(e,[{key:"isActiveAt",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;return me(e,t,n)==this.data}},{key:"findRegions",value:function(e){var t=this,n=e.facet(Ae);if((null===n||void 0===n?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];var r=[];return function e(n,i){if(n.prop(ge)!=t.data){var o=n.prop(J.mounted);if(o){if(o.tree.prop(ge)==t.data){if(o.overlay){var s,u=h(o.overlay);try{for(u.s();!(s=u.n()).done;){var a=s.value;r.push({from:a.from+i,to:a.to+i})}}catch(d){u.e(d)}finally{u.f()}}else r.push({from:i,to:i+n.length});return}if(o.overlay){var f=r.length;if(e(o.tree,o.overlay[0].from+i),r.length>f)return}}for(var l=0;l<n.children.length;l++){var c=n.children[l];c instanceof K&&e(c,n.positions[l]+i)}}else r.push({from:i,to:i+n.length})}(ke(e),0),r}},{key:"allowsNesting",get:function(){return!0}}]),e}();function me(e,t,n){var r=e.facet(Ae);if(!r)return null;var i=r.data;if(r.allowsNesting)for(var o=ke(e).topNode;o;o=o.enter(t,n,!0,!1))i=o.type.prop(ge)||i;return i}ye.setState=a.StateEffect.define();function ke(e){var t=e.field(ye.state,!1);return t?t.tree:K.empty}var be=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.length;m(this,e),this.doc=t,this.length=n,this.cursorPos=0,this.string="",this.cursor=t.iter()}return b(e,[{key:"syncTo",value:function(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}},{key:"chunk",value:function(e){return this.syncTo(e),this.string}},{key:"lineChunks",get:function(){return!0}},{key:"read",value:function(e,t){var n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}]),e}(),xe=null,we=function(){function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,a=arguments.length>7?arguments[7]:void 0;m(this,e),this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=u,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}return b(e,[{key:"startParse",value:function(){return this.parser.startParse(new be(this.state.doc),this.fragments)}},{key:"work",value:function(e,t){var n=this;return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=K.empty&&this.isDone(null!==t&&void 0!==t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((function(){var r,i=Date.now()+e;for(n.parse||(n.parse=n.startParse()),null!=t&&(null==n.parse.stoppedAt||n.parse.stoppedAt>t)&&t<n.state.doc.length&&n.parse.stopAt(t);;){var o=n.parse.advance();if(o){if(n.fragments=n.withoutTempSkipped(de.addTree(o,n.fragments,null!=n.parse.stoppedAt)),n.treeLen=null!==(r=n.parse.stoppedAt)&&void 0!==r?r:n.state.doc.length,n.tree=o,n.parse=null,!(n.treeLen<(null!==t&&void 0!==t?t:n.state.doc.length)))return!0;n.parse=n.startParse()}if(Date.now()>i)return!1}}))}},{key:"takeTree",value:function(){var e,t,n=this;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((function(){for(;!(t=n.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(de.addTree(this.tree,this.fragments,!0)),this.parse=null)}},{key:"withContext",value:function(e){var t=xe;xe=this;try{return e()}finally{xe=t}}},{key:"withoutTempSkipped",value:function(e){for(var t;t=this.tempSkipped.pop();)e=Se(e,t.from,t.to);return e}},{key:"changes",value:function(t,n){var r=this.fragments,i=this.tree,o=this.treeLen,s=this.viewport,u=this.skipped;if(this.takeTree(),!t.empty){var a=[];if(t.iterChangedRanges((function(e,t,n,r){return a.push({fromA:e,toA:t,fromB:n,toB:r})})),r=de.applyChanges(r,a),i=K.empty,o=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){u=[];var f,l=h(this.skipped);try{for(l.s();!(f=l.n()).done;){var c=f.value,d=t.mapPos(c.from,1),v=t.mapPos(c.to,-1);d<v&&u.push({from:d,to:v})}}catch(p){l.e(p)}finally{l.f()}}}return new e(this.parser,n,r,i,o,s,u,this.scheduleOn)}},{key:"updateViewport",value:function(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;for(var t=this.skipped.length,n=0;n<this.skipped.length;n++){var r=this.skipped[n],i=r.from,o=r.to;i<e.to&&o>e.from&&(this.fragments=Se(this.fragments,i,o),this.skipped.splice(n--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}},{key:"reset",value:function(){this.parse&&(this.takeTree(),this.parse=null)}},{key:"skipUntilInView",value:function(e,t){this.skipped.push({from:e,to:t})}},{key:"isDone",value:function(e){e=Math.min(e,this.state.doc.length);var t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}}],[{key:"getSkippingParser",value:function(e){return new(function(t){v(r,t);var n=y(r);function r(){return m(this,r),n.apply(this,arguments)}return b(r,[{key:"createParse",value:function(t,n,r){var i=r[0].from,o=r[r.length-1].to;return{parsedPos:i,advance:function(){var t=xe;if(t){var n,s=h(r);try{for(s.s();!(n=s.n()).done;){var u=n.value;t.tempSkipped.push(u)}}catch(a){s.e(a)}finally{s.f()}e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=o,new K($.none,[],[],o-i)},stoppedAt:null,stopAt:function(){}}}}]),r}(ve))}},{key:"get",value:function(){return xe}}]),e}();function Se(e,t,n){return de.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Ce=function(){function e(t){m(this,e),this.context=t,this.tree=t.tree}return b(e,[{key:"apply",value:function(t){if(!t.docChanged)return this;var n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}}],[{key:"init",value:function(t){var n=Math.min(3e3,t.doc.length),r=new we(t.facet(Ae).parser,t,[],K.empty,0,{from:0,to:n},[],null);return r.work(20,n)||r.takeTree(),new e(r)}}]),e}();ye.state=a.StateField.define({create:Ce.init,update:function(e,t){var n,r=h(t.effects);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.is(ye.setState))return i.value}}catch(o){r.e(o)}finally{r.f()}return t.startState.facet(Ae)!=t.state.facet(Ae)?Ce.init(t.state):e.apply(t)}});var _e=function(e){var t=setTimeout((function(){return e()}),500);return function(){return clearTimeout(t)}};"undefined"!=typeof requestIdleCallback&&(_e=function(e){var t=-1,n=setTimeout((function(){t=requestIdleCallback(e,{timeout:400})}),100);return function(){return t<0?clearTimeout(n):cancelIdleCallback(t)}});var Oe=H.ViewPlugin.fromClass(function(){function e(t){m(this,e),this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}return b(e,[{key:"update",value:function(e){var t=this.view.state.field(ye.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)}},{key:"scheduleWork",value:function(){if(!this.working){var e=this.view.state,t=e.field(ye.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=_e(this.work))}}},{key:"work",value:function(e){this.working=null;var t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),!(this.chunkBudget<=0)){var n=this.view,r=n.state,i=n.viewport.to,o=r.field(ye.state);if(o.tree!=o.context.tree||!o.context.isDone(i+1e5)){var s=Math.min(this.chunkBudget,100,e?Math.max(25,e.timeRemaining()-5):1e9),u=o.context.treeLen<i&&r.doc.length>i+1e3,a=o.context.work(s,i+(u?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ye.setState.of(new Ce(o.context))})),this.chunkBudget>0&&(!a||u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}}}},{key:"checkAsyncSchedule",value:function(e){var t=this;e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((function(){return t.scheduleWork()})).catch((function(e){return(0,H.logException)(t.view.state,e)})).then((function(){return t.workScheduled--})),e.scheduleOn=null)}},{key:"destroy",value:function(){this.working&&this.working()}},{key:"isWorking",value:function(){return this.working||this.workScheduled>0}}]),e}(),{eventHandlers:{focus:function(){this.scheduleWork()}}}),Ae=a.Facet.define({combine:function(e){return e.length?e[0]:null},enables:[ye.state,Oe]}),je=a.Facet.define({combine:function(e){if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function Pe(e){var t=e.facet(je);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function Ee(e,t){var n="",r=e.tabSize;if(9==e.facet(je).charCodeAt(0))for(;t>=r;)n+="\t",t-=r;for(var i=0;i<t;i++)n+=" ";return n}function Be(e,t){var n=-1;return e.changeByRange((function(r){for(var i=[],o=r.from;o<=r.to;){var s=e.doc.lineAt(o);s.number>n&&(r.empty||r.to>s.from)&&(t(s,i,r),n=s.number),o=s.to+1}var u=e.changes(i);return{changes:i,range:a.EditorSelection.range(u.mapPos(r.anchor,1),u.mapPos(r.head,1))}}))}var Ne=function(e){var t=e.state,n=e.dispatch;return!t.readOnly&&(n(t.update(Be(t,(function(e,n){n.push({from:e.from,insert:t.facet(je)})})),{userEvent:"input.indent"})),!0)},Te=function(e){var t=e.state,n=e.dispatch;return!t.readOnly&&(n(t.update(Be(t,(function(e,n){var r=/^\s*/.exec(e.text)[0];if(r){for(var i=N(r,t.tabSize),o=0,s=Ee(t,Math.max(0,i-Pe(t)));o<r.length&&o<s.length&&r.charCodeAt(o)==s.charCodeAt(o);)o++;n.push({from:e.from+o,to:e.from+r.length,insert:s.slice(o)})}})),{userEvent:"delete.dedent"})),!0)},Ie={key:"Tab",run:Ne,shift:Te},Me=n(362),Re=H.EditorView.theme({"&":{backgroundColor:"#fff"}},{dark:!1});function We(e){var t=e.value,n=e.selection,r=e.onChange,i=e.onUpdate,h=e.extensions,f=void 0===h?[]:h,l=e.autoFocus,c=e.theme,d=void 0===c?"light":c,v=e.height,p=void 0===v?"":v,g=e.minHeight,y=void 0===g?"":g,m=e.maxHeight,k=void 0===m?"":m,b=e.placeholder,x=void 0===b?"":b,w=e.width,S=void 0===w?"":w,C=e.minWidth,_=void 0===C?"":C,O=e.maxWidth,A=void 0===O?"":O,j=e.editable,P=void 0===j||j,E=e.indentWithTab,B=void 0===E||E,N=e.basicSetup,T=void 0===N||N,I=e.root,M=o((0,s.useState)(e.container),2),R=M[0],W=M[1],z=o((0,s.useState)(),2),q=z[0],L=z[1],U=o((0,s.useState)(),2),D=U[0],V=U[1],F=H.EditorView.theme({"&":{height:p,minHeight:y,maxHeight:k,width:S,minWidth:_,maxWidth:A}}),J=[H.EditorView.updateListener.of((function(e){if(e.docChanged&&"function"===typeof r){var t=e.state.doc.toString();r(t,e)}})),F];switch(B&&J.unshift(H.keymap.of([Ie])),T&&J.unshift(u.basicSetup),x&&J.unshift((0,H.placeholder)(x)),d){case"light":J.push(Re);break;case"dark":J.push(Me.oneDark);break;default:J.push(d)}return!1===P&&J.push(H.EditorView.editable.of(!1)),i&&"function"===typeof i&&J.push(H.EditorView.updateListener.of(i)),J=J.concat(f),(0,s.useEffect)((function(){if(R&&!D){var e=a.EditorState.create({doc:t,selection:n,extensions:J});if(V(e),!q){var r=new H.EditorView({state:e,parent:R,root:I});L(r)}}}),[R,D]),(0,s.useEffect)((function(){return function(){q&&(q.destroy(),L(void 0))}}),[q]),(0,s.useEffect)((function(){return l&&q&&q.focus()}),[l,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:a.StateEffect.reconfigure.of(J)})}),[d,f,p,y,k,S,x,_,A,P,B,T]),{state:D,setState:V,view:q,setView:L,container:R,setContainer:W}}},13:function(e){var t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;function i(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(i){return!1}}()?Object.assign:function(e,o){for(var s,u,a=i(e),h=1;h<arguments.length;h++){for(var f in s=Object(arguments[h]))n.call(s,f)&&(a[f]=s[f]);if(t){u=t(s);for(var l=0;l<u.length;l++)r.call(s,u[l])&&(a[u[l]]=s[u[l]])}}return a}},829:function(e,t,n){n(13);var r=n(787),i=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var o=Symbol.for;i=o("react.element"),o("react.fragment")}var s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u=Object.prototype.hasOwnProperty,a={key:!0,ref:!0,__self:!0,__source:!0};function h(e,t,n){var r,o={},h=null,f=null;for(r in void 0!==n&&(h=""+n),void 0!==t.key&&(h=""+t.key),void 0!==t.ref&&(f=t.ref),t)u.call(t,r)&&!a.hasOwnProperty(r)&&(o[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===o[r]&&(o[r]=t[r]);return{$$typeof:i,type:e,key:h,ref:f,props:o,_owner:s.current}}t.jsx=h},364:function(e,t,n){e.exports=n(829)},787:function(t){t.exports=e},573:function(e){e.exports=t},242:function(e){e.exports=n},362:function(e){e.exports=r},105:function(e){e.exports=i},462:function(e,t,n){function r(){return r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r.apply(this,arguments)}n.d(t,{Z:function(){return r}})},366:function(e,t,n){function r(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}n.d(t,{Z:function(){return r}})}},s={};function u(e){var t=s[e];if(void 0!==t)return t.exports;var n=s[e]={exports:{}};return o[e](n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return function(){u.r(a),u.d(a,{useCodeMirror:function(){return i.U}});var e=u(462),t=u(366),n=u(787),r=u.n(n),i=u(927),o=u(364),s=u(105),h={};for(var f in s)"default"!==f&&(h[f]=function(e){return s[e]}.bind(0,f));u.d(a,h);var l=u(573);h={};for(var f in l)"default"!==f&&(h[f]=function(e){return l[e]}.bind(0,f));u.d(a,h);var c=u(242);h={};for(var f in c)"default"!==f&&(h[f]=function(e){return c[e]}.bind(0,f));u.d(a,h);var d=["className","value","selection","extensions","onChange","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","root"],v=r().forwardRef((function(r,s){var u=r.className,a=r.value,h=void 0===a?"":a,f=r.selection,l=r.extensions,c=void 0===l?[]:l,v=r.onChange,p=r.onUpdate,g=r.autoFocus,y=r.theme,m=void 0===y?"light":y,k=r.height,b=r.minHeight,x=r.maxHeight,w=r.width,S=r.minWidth,C=r.maxWidth,_=r.basicSetup,O=r.placeholder,A=r.indentWithTab,j=r.editable,P=r.root,E=(0,t.Z)(r,d),B=(0,n.useRef)(null),N=(0,i.U)({container:B.current,root:P,value:h,autoFocus:g,theme:m,height:k,minHeight:b,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:_,placeholder:O,indentWithTab:A,editable:j,selection:f,onChange:v,onUpdate:p,extensions:c}),T=N.state,I=N.view,M=N.container,R=N.setContainer;if((0,n.useImperativeHandle)(s,(function(){return{editor:M,state:T,view:I}}),[M,T,I]),(0,n.useEffect)((function(){R(B.current)}),[]),"string"!==typeof h)throw new Error("value must be typeof string but got "+typeof h);var W="string"===typeof m?"cm-theme-"+m:"cm-theme";return(0,o.jsx)("div",(0,e.Z)({ref:B,className:W+(u?" "+u:"")},E))}));v.displayName="CodeMirror",a.default=v}(),a}()}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** @license React v17.0.2
|
|
8
|
+
* react-jsx-runtime.production.min.js
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/
|
package/esm/index.js
CHANGED
|
@@ -11,7 +11,7 @@ export * from './useCodeMirror';
|
|
|
11
11
|
var ReactCodeMirror = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
12
12
|
var {
|
|
13
13
|
className,
|
|
14
|
-
value,
|
|
14
|
+
value = '',
|
|
15
15
|
selection,
|
|
16
16
|
extensions = [],
|
|
17
17
|
onChange,
|
|
@@ -63,14 +63,9 @@ var ReactCodeMirror = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
63
63
|
editor: container,
|
|
64
64
|
state,
|
|
65
65
|
view
|
|
66
|
-
}));
|
|
66
|
+
}), [container, state, view]);
|
|
67
67
|
useEffect(() => {
|
|
68
|
-
setContainer(editor.current);
|
|
69
|
-
return () => {
|
|
70
|
-
if (view) {
|
|
71
|
-
view.destroy();
|
|
72
|
-
}
|
|
73
|
-
}; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
+
setContainer(editor.current); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
69
|
}, []); // check type of value
|
|
75
70
|
|
|
76
71
|
if (typeof value !== 'string') {
|
package/esm/index.js.map
CHANGED
|
@@ -39,13 +39,12 @@
|
|
|
39
39
|
"container",
|
|
40
40
|
"setContainer",
|
|
41
41
|
"current",
|
|
42
|
-
"destroy",
|
|
43
42
|
"Error",
|
|
44
43
|
"defaultClassNames",
|
|
45
44
|
"displayName"
|
|
46
45
|
],
|
|
47
|
-
"mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,mBAAnC,QAA8D,OAA9D;AAGA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,cAAc,kBAAd;AACA,cAAc,yBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AA6DA,IAAMC,eAAe,gBAAGL,KAAK,CAACM,UAAN,CAA2D,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACjG,MAAM;AACJC,IAAAA,SADI;AAEJC,IAAAA,
|
|
46
|
+
"mappings": ";;;AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,MAA3B,EAAmCC,mBAAnC,QAA8D,OAA9D;AAGA,SAASC,aAAT,QAA8B,iBAA9B;;AAEA,cAAc,kBAAd;AACA,cAAc,yBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AA6DA,IAAMC,eAAe,gBAAGL,KAAK,CAACM,UAAN,CAA2D,CAACC,KAAD,EAAQC,GAAR,KAAgB;AACjG,MAAM;AACJC,IAAAA,SADI;AAEJC,IAAAA,KAAK,GAAG,EAFJ;AAGJC,IAAAA,SAHI;AAIJC,IAAAA,UAAU,GAAG,EAJT;AAKJC,IAAAA,QALI;AAMJC,IAAAA,QANI;AAOJC,IAAAA,SAPI;AAQJC,IAAAA,KAAK,GAAG,OARJ;AASJC,IAAAA,MATI;AAUJC,IAAAA,SAVI;AAWJC,IAAAA,SAXI;AAYJC,IAAAA,KAZI;AAaJC,IAAAA,QAbI;AAcJC,IAAAA,QAdI;AAeJC,IAAAA,UAfI;AAgBJC,IAAAA,WAhBI;AAiBJC,IAAAA,aAjBI;AAkBJC,IAAAA,QAlBI;AAmBJC,IAAAA;AAnBI,MAqBFpB,KArBJ;AAAA,MAoBKqB,KApBL,iCAqBIrB,KArBJ;;AAsBA,MAAMsB,MAAM,GAAG3B,MAAM,CAAiB,IAAjB,CAArB;AACA,MAAM;AAAE4B,IAAAA,KAAF;AAASC,IAAAA,IAAT;AAAeC,IAAAA,SAAf;AAA0BC,IAAAA;AAA1B,MAA2C7B,aAAa,CAAC;AAC7D4B,IAAAA,SAAS,EAAEH,MAAM,CAACK,OAD2C;AAE7DP,IAAAA,IAF6D;AAG7DjB,IAAAA,KAH6D;AAI7DK,IAAAA,SAJ6D;AAK7DC,IAAAA,KAL6D;AAM7DC,IAAAA,MAN6D;AAO7DC,IAAAA,SAP6D;AAQ7DC,IAAAA,SAR6D;AAS7DC,IAAAA,KAT6D;AAU7DC,IAAAA,QAV6D;AAW7DC,IAAAA,QAX6D;AAY7DC,IAAAA,UAZ6D;AAa7DC,IAAAA,WAb6D;AAc7DC,IAAAA,aAd6D;AAe7DC,IAAAA,QAf6D;AAgB7Df,IAAAA,SAhB6D;AAiB7DE,IAAAA,QAjB6D;AAkB7DC,IAAAA,QAlB6D;AAmB7DF,IAAAA;AAnB6D,GAAD,CAA9D;AAqBAT,EAAAA,mBAAmB,CAACK,GAAD,EAAM,OAAO;AAAEqB,IAAAA,MAAM,EAAEG,SAAV;AAAqBF,IAAAA,KAArB;AAA4BC,IAAAA;AAA5B,GAAP,CAAN,EAAkD,CAACC,SAAD,EAAYF,KAAZ,EAAmBC,IAAnB,CAAlD,CAAnB;AACA9B,EAAAA,SAAS,CAAC,MAAM;AACdgC,IAAAA,YAAY,CAACJ,MAAM,CAACK,OAAR,CAAZ,CADc,CAEd;AACD,GAHQ,EAGN,EAHM,CAAT,CA9CiG,CAmDjG;;AACA,MAAI,OAAOxB,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IAAIyB,KAAJ,0CAAiD,OAAOzB,KAAxD,CAAN;AACD;;AAED,MAAM0B,iBAAiB,GAAG,OAAOpB,KAAP,KAAiB,QAAjB,iBAAwCA,KAAxC,GAAkD,UAA5E;AACA,sBAAO;AAAK,IAAA,GAAG,EAAEa,MAAV;AAAkB,IAAA,SAAS,OAAKO,iBAAL,IAAyB3B,SAAS,SAAOA,SAAP,GAAqB,EAAvD;AAA3B,KAA4FmB,KAA5F,EAAP;AACD,CA1DuB,CAAxB;AA4DAvB,eAAe,CAACgC,WAAhB,GAA8B,YAA9B;AAEA,eAAehC,eAAf",
|
|
48
47
|
"sourcesContent": [
|
|
49
|
-
"import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value,\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }));\n useEffect(() => {\n setContainer(editor.current);\n
|
|
48
|
+
"import React, { useEffect, useRef, useImperativeHandle } from 'react';\nimport { EditorState, EditorStateConfig, Extension } from '@codemirror/state';\nimport { EditorView, ViewUpdate } from '@codemirror/view';\nimport { useCodeMirror } from './useCodeMirror';\n\nexport * from '@codemirror/view';\nexport * from '@codemirror/basic-setup';\nexport * from '@codemirror/state';\nexport * from './useCodeMirror';\n\nexport interface ReactCodeMirrorProps\n extends Omit<EditorStateConfig, 'doc' | 'extensions'>,\n Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'placeholder'> {\n /** value of the auto created model in the editor. */\n value?: string;\n height?: string;\n minHeight?: string;\n maxHeight?: string;\n width?: string;\n minWidth?: string;\n maxWidth?: string;\n /** focus on the editor. */\n autoFocus?: boolean;\n /** Enables a placeholder—a piece of example content to show when the editor is empty. */\n placeholder?: string | HTMLElement;\n /**\n * `light` / `dark` / `Extension` Defaults to `light`.\n * @default light\n */\n theme?: 'light' | 'dark' | Extension;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n basicSetup?: boolean;\n /**\n * This disables editing of the editor content by the user.\n * @default true\n */\n editable?: boolean;\n /**\n * Whether to optional basicSetup by default\n * @default true\n */\n indentWithTab?: boolean;\n /** Fired whenever a change occurs to the document. */\n onChange?(value: string, viewUpdate: ViewUpdate): void;\n /** Fired whenever a change occurs to the document. There is a certain difference with `onChange`. */\n onUpdate?(viewUpdate: ViewUpdate): void;\n /**\n * Extension values can be [provided](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions) when creating a state to attach various kinds of configuration and behavior information.\n * They can either be built-in extension-providing objects,\n * such as [state fields](https://codemirror.net/6/docs/ref/#state.StateField) or [facet providers](https://codemirror.net/6/docs/ref/#state.Facet.of),\n * or objects with an extension in its `extension` property. Extensions can be nested in arrays arbitrarily deep—they will be flattened when processed.\n */\n extensions?: Extension[];\n /**\n * If the view is going to be mounted in a shadow root or document other than the one held by the global variable document (the default), you should pass it here.\n * Originally from the [config of EditorView](https://codemirror.net/6/docs/ref/#view.EditorView.constructor%5Econfig.root)\n */\n root?: ShadowRoot | Document;\n}\n\nexport interface ReactCodeMirrorRef {\n editor?: HTMLDivElement | null;\n state?: EditorState;\n view?: EditorView;\n}\n\nconst ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {\n const {\n className,\n value = '',\n selection,\n extensions = [],\n onChange,\n onUpdate,\n autoFocus,\n theme = 'light',\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n root,\n ...other\n } = props;\n const editor = useRef<HTMLDivElement>(null);\n const { state, view, container, setContainer } = useCodeMirror({\n container: editor.current,\n root,\n value,\n autoFocus,\n theme,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n basicSetup,\n placeholder,\n indentWithTab,\n editable,\n selection,\n onChange,\n onUpdate,\n extensions,\n });\n useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);\n useEffect(() => {\n setContainer(editor.current);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // check type of value\n if (typeof value !== 'string') {\n throw new Error(`value must be typeof string but got ${typeof value}`);\n }\n\n const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';\n return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;\n});\n\nReactCodeMirror.displayName = 'CodeMirror';\n\nexport default ReactCodeMirror;\n"
|
|
50
49
|
]
|
|
51
50
|
}
|
package/esm/useCodeMirror.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
import { basicSetup
|
|
2
|
+
import { basicSetup } from '@codemirror/basic-setup';
|
|
3
3
|
import { EditorState, StateEffect } from '@codemirror/state';
|
|
4
|
-
import { indentWithTab
|
|
5
|
-
import { EditorView, keymap, placeholder
|
|
4
|
+
import { indentWithTab } from '@codemirror/commands';
|
|
5
|
+
import { EditorView, keymap, placeholder } from '@codemirror/view';
|
|
6
6
|
import { oneDark } from '@codemirror/theme-one-dark';
|
|
7
7
|
import { defaultLightThemeOption } from './theme/light';
|
|
8
8
|
export function useCodeMirror(props) {
|
|
@@ -17,13 +17,13 @@ export function useCodeMirror(props) {
|
|
|
17
17
|
height = '',
|
|
18
18
|
minHeight = '',
|
|
19
19
|
maxHeight = '',
|
|
20
|
-
placeholder = '',
|
|
20
|
+
placeholder: placeholderStr = '',
|
|
21
21
|
width = '',
|
|
22
22
|
minWidth = '',
|
|
23
23
|
maxWidth = '',
|
|
24
24
|
editable = true,
|
|
25
|
-
indentWithTab = true,
|
|
26
|
-
basicSetup = true,
|
|
25
|
+
indentWithTab: defaultIndentWithTab = true,
|
|
26
|
+
basicSetup: defaultBasicSetup = true,
|
|
27
27
|
root
|
|
28
28
|
} = props;
|
|
29
29
|
var [container, setContainer] = useState(props.container);
|
|
@@ -50,16 +50,16 @@ export function useCodeMirror(props) {
|
|
|
50
50
|
});
|
|
51
51
|
var getExtensions = [updateListener, defaultThemeOption];
|
|
52
52
|
|
|
53
|
-
if (
|
|
54
|
-
getExtensions.unshift(keymap.of([
|
|
53
|
+
if (defaultIndentWithTab) {
|
|
54
|
+
getExtensions.unshift(keymap.of([indentWithTab]));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
if (
|
|
58
|
-
getExtensions.unshift(
|
|
57
|
+
if (defaultBasicSetup) {
|
|
58
|
+
getExtensions.unshift(basicSetup);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (
|
|
62
|
-
getExtensions.unshift(
|
|
61
|
+
if (placeholderStr) {
|
|
62
|
+
getExtensions.unshift(placeholder(placeholderStr));
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
switch (theme) {
|
|
@@ -105,26 +105,24 @@ export function useCodeMirror(props) {
|
|
|
105
105
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
106
|
|
|
107
107
|
}, [container, state]);
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
};
|
|
108
|
+
useEffect(() => () => {
|
|
109
|
+
if (view) {
|
|
110
|
+
view.destroy();
|
|
111
|
+
setView(undefined);
|
|
112
|
+
}
|
|
114
113
|
}, [view]);
|
|
114
|
+
useEffect(() => autoFocus && view && view.focus(), [autoFocus, view]);
|
|
115
115
|
useEffect(() => {
|
|
116
|
-
|
|
117
|
-
var currentValue = view.state.doc.toString();
|
|
116
|
+
var currentValue = view ? view.state.doc.toString() : '';
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
118
|
+
if (view && value !== currentValue) {
|
|
119
|
+
view.dispatch({
|
|
120
|
+
changes: {
|
|
121
|
+
from: 0,
|
|
122
|
+
to: currentValue.length,
|
|
123
|
+
insert: value || ''
|
|
124
|
+
}
|
|
125
|
+
});
|
|
128
126
|
}
|
|
129
127
|
}, [value, view]);
|
|
130
128
|
useEffect(() => {
|
|
@@ -134,12 +132,7 @@ export function useCodeMirror(props) {
|
|
|
134
132
|
});
|
|
135
133
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
136
134
|
|
|
137
|
-
}, [theme, extensions,
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
if (autoFocus && view) {
|
|
140
|
-
view.focus();
|
|
141
|
-
}
|
|
142
|
-
}, [autoFocus, view]);
|
|
135
|
+
}, [theme, extensions, height, minHeight, maxHeight, width, placeholderStr, minWidth, maxWidth, editable, defaultIndentWithTab, defaultBasicSetup]);
|
|
143
136
|
return {
|
|
144
137
|
state,
|
|
145
138
|
setState,
|
package/esm/useCodeMirror.js.map
CHANGED
|
@@ -7,15 +7,12 @@
|
|
|
7
7
|
"useEffect",
|
|
8
8
|
"useState",
|
|
9
9
|
"basicSetup",
|
|
10
|
-
"defaultBasicSetup",
|
|
11
10
|
"EditorState",
|
|
12
11
|
"StateEffect",
|
|
13
12
|
"indentWithTab",
|
|
14
|
-
"defaultIndentWithTab",
|
|
15
13
|
"EditorView",
|
|
16
14
|
"keymap",
|
|
17
15
|
"placeholder",
|
|
18
|
-
"extendPlaceholder",
|
|
19
16
|
"oneDark",
|
|
20
17
|
"defaultLightThemeOption",
|
|
21
18
|
"useCodeMirror",
|
|
@@ -30,10 +27,13 @@
|
|
|
30
27
|
"height",
|
|
31
28
|
"minHeight",
|
|
32
29
|
"maxHeight",
|
|
30
|
+
"placeholderStr",
|
|
33
31
|
"width",
|
|
34
32
|
"minWidth",
|
|
35
33
|
"maxWidth",
|
|
36
34
|
"editable",
|
|
35
|
+
"defaultIndentWithTab",
|
|
36
|
+
"defaultBasicSetup",
|
|
37
37
|
"root",
|
|
38
38
|
"container",
|
|
39
39
|
"setContainer",
|
|
@@ -57,6 +57,8 @@
|
|
|
57
57
|
"viewCurrent",
|
|
58
58
|
"parent",
|
|
59
59
|
"destroy",
|
|
60
|
+
"undefined",
|
|
61
|
+
"focus",
|
|
60
62
|
"currentValue",
|
|
61
63
|
"dispatch",
|
|
62
64
|
"changes",
|
|
@@ -65,11 +67,10 @@
|
|
|
65
67
|
"length",
|
|
66
68
|
"insert",
|
|
67
69
|
"effects",
|
|
68
|
-
"reconfigure"
|
|
69
|
-
"focus"
|
|
70
|
+
"reconfigure"
|
|
70
71
|
],
|
|
71
|
-
"mappings": "AAAA,SAASA,SAAT,EAAoBC,QAApB,QAAoC,OAApC;AACA,SAASC,
|
|
72
|
+
"mappings": "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",
|
|
72
73
|
"sourcesContent": [
|
|
73
|
-
"import { useEffect, useState } from 'react';\nimport { basicSetup
|
|
74
|
+
"import { useEffect, useState } from 'react';\nimport { basicSetup } from '@codemirror/basic-setup';\nimport { EditorState, StateEffect } from '@codemirror/state';\nimport { indentWithTab } from '@codemirror/commands';\nimport { EditorView, keymap, ViewUpdate, placeholder } from '@codemirror/view';\nimport { oneDark } from '@codemirror/theme-one-dark';\nimport { ReactCodeMirrorProps } from './';\nimport { defaultLightThemeOption } from './theme/light';\n\nexport interface UseCodeMirror extends ReactCodeMirrorProps {\n container?: HTMLDivElement | null;\n}\n\nexport function useCodeMirror(props: UseCodeMirror) {\n const {\n value,\n selection,\n onChange,\n onUpdate,\n extensions = [],\n autoFocus,\n theme = 'light',\n height = '',\n minHeight = '',\n maxHeight = '',\n placeholder: placeholderStr = '',\n width = '',\n minWidth = '',\n maxWidth = '',\n editable = true,\n indentWithTab: defaultIndentWithTab = true,\n basicSetup: defaultBasicSetup = true,\n root,\n } = props;\n const [container, setContainer] = useState(props.container);\n const [view, setView] = useState<EditorView>();\n const [state, setState] = useState<EditorState>();\n const defaultThemeOption = EditorView.theme({\n '&': {\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n },\n });\n const updateListener = EditorView.updateListener.of((vu: ViewUpdate) => {\n if (vu.docChanged && typeof onChange === 'function') {\n const doc = vu.state.doc;\n const value = doc.toString();\n onChange(value, vu);\n }\n });\n let getExtensions = [updateListener, defaultThemeOption];\n if (defaultIndentWithTab) {\n getExtensions.unshift(keymap.of([indentWithTab]));\n }\n if (defaultBasicSetup) {\n getExtensions.unshift(basicSetup);\n }\n\n if (placeholderStr) {\n getExtensions.unshift(placeholder(placeholderStr));\n }\n\n switch (theme) {\n case 'light':\n getExtensions.push(defaultLightThemeOption);\n break;\n case 'dark':\n getExtensions.push(oneDark);\n break;\n default:\n getExtensions.push(theme);\n break;\n }\n\n if (editable === false) {\n getExtensions.push(EditorView.editable.of(false));\n }\n\n if (onUpdate && typeof onUpdate === 'function') {\n getExtensions.push(EditorView.updateListener.of(onUpdate));\n }\n getExtensions = getExtensions.concat(extensions);\n\n useEffect(() => {\n if (container && !state) {\n const stateCurrent = EditorState.create({\n doc: value,\n selection,\n extensions: getExtensions,\n });\n setState(stateCurrent);\n if (!view) {\n const viewCurrent = new EditorView({\n state: stateCurrent,\n parent: container,\n root,\n });\n setView(viewCurrent);\n }\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [container, state]);\n\n useEffect(\n () => () => {\n if (view) {\n view.destroy();\n setView(undefined);\n }\n },\n [view],\n );\n\n useEffect(() => autoFocus && view && (view.focus() as any), [autoFocus, view]);\n\n useEffect(() => {\n const currentValue = view ? view.state.doc.toString() : '';\n if (view && value !== currentValue) {\n view.dispatch({\n changes: { from: 0, to: currentValue.length, insert: value || '' },\n });\n }\n }, [value, view]);\n\n useEffect(() => {\n if (view) {\n view.dispatch({ effects: StateEffect.reconfigure.of(getExtensions) });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n theme,\n extensions,\n height,\n minHeight,\n maxHeight,\n width,\n placeholderStr,\n minWidth,\n maxWidth,\n editable,\n defaultIndentWithTab,\n defaultBasicSetup,\n ]);\n\n return { state, setState, view, setView, container, setContainer };\n}\n"
|
|
74
75
|
]
|
|
75
76
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-codemirror",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"description": "CodeMirror component for React.",
|
|
5
5
|
"homepage": "https://uiwjs.github.io/react-codemirror",
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
"prepare": "husky install && npm run build",
|
|
14
14
|
"watch": "tsbb watch",
|
|
15
15
|
"build": "tsbb build",
|
|
16
|
+
"bundle": "kkt build --bundle",
|
|
17
|
+
"bundle:min": "kkt build --bundle --mini --no-emptyDir",
|
|
16
18
|
"test": "tsbb test --env=jsdom",
|
|
17
|
-
"coverage": "tsbb test --coverage",
|
|
19
|
+
"coverage": "tsbb test --coverage --bail",
|
|
18
20
|
"doc": "kkt build --app-src ./website",
|
|
19
21
|
"start": "kkt start --app-src ./website",
|
|
20
22
|
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,html,less,md,json}'"
|
|
@@ -34,6 +36,7 @@
|
|
|
34
36
|
"code"
|
|
35
37
|
],
|
|
36
38
|
"files": [
|
|
39
|
+
"dist",
|
|
37
40
|
"src",
|
|
38
41
|
"esm",
|
|
39
42
|
"cjs"
|
|
@@ -52,11 +55,6 @@
|
|
|
52
55
|
"react-app/jest"
|
|
53
56
|
]
|
|
54
57
|
},
|
|
55
|
-
"lint-staged": {
|
|
56
|
-
"*.{js,jsx,ts,tsx,html,less,md,json}": [
|
|
57
|
-
"prettier --write"
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
58
|
"peerDependencies": {
|
|
61
59
|
"@babel/runtime": ">=7.11.0",
|
|
62
60
|
"react": ">=16.8.0",
|
|
@@ -73,36 +71,37 @@
|
|
|
73
71
|
"@codemirror/lang-cpp": "0.19.1",
|
|
74
72
|
"@codemirror/lang-html": "0.19.4",
|
|
75
73
|
"@codemirror/lang-java": "0.19.1",
|
|
76
|
-
"@codemirror/lang-javascript": "0.19.
|
|
74
|
+
"@codemirror/lang-javascript": "0.19.7",
|
|
77
75
|
"@codemirror/lang-json": "0.19.1",
|
|
78
76
|
"@codemirror/lang-lezer": "0.19.1",
|
|
79
|
-
"@codemirror/lang-markdown": "0.19.
|
|
77
|
+
"@codemirror/lang-markdown": "0.19.6",
|
|
80
78
|
"@codemirror/lang-php": "0.19.1",
|
|
81
|
-
"@codemirror/lang-python": "0.19.
|
|
79
|
+
"@codemirror/lang-python": "0.19.4",
|
|
82
80
|
"@codemirror/lang-rust": "0.19.1",
|
|
83
81
|
"@codemirror/lang-sql": "0.19.4",
|
|
84
82
|
"@codemirror/lang-xml": "0.19.2",
|
|
85
83
|
"@codemirror/legacy-modes": "0.19.0",
|
|
86
|
-
"@codemirror/stream-parser": "0.19.
|
|
87
|
-
"@kkt/less-modules": "7.0
|
|
88
|
-
"@kkt/raw-modules": "7.0
|
|
89
|
-
"@kkt/
|
|
84
|
+
"@codemirror/stream-parser": "0.19.5",
|
|
85
|
+
"@kkt/less-modules": "7.1.0",
|
|
86
|
+
"@kkt/raw-modules": "7.1.0",
|
|
87
|
+
"@kkt/react-library": "7.1.0",
|
|
88
|
+
"@kkt/scope-plugin-options": "7.1.0",
|
|
90
89
|
"@types/react": "17.0.38",
|
|
91
90
|
"@types/react-dom": "17.0.11",
|
|
92
91
|
"@types/react-test-renderer": "17.0.1",
|
|
93
92
|
"@uiw/react-github-corners": "1.5.3",
|
|
94
|
-
"@uiw/react-markdown-preview": "3.4.
|
|
93
|
+
"@uiw/react-markdown-preview": "3.4.7",
|
|
95
94
|
"@uiw/react-shields": "1.1.2",
|
|
96
95
|
"@uiw/reset.css": "1.0.5",
|
|
97
96
|
"code-example": "3.3.1",
|
|
98
97
|
"husky": "7.0.4",
|
|
99
|
-
"kkt": "7.0
|
|
100
|
-
"lint-staged": "12.
|
|
98
|
+
"kkt": "7.1.0",
|
|
99
|
+
"lint-staged": "12.3.4",
|
|
101
100
|
"prettier": "2.5.1",
|
|
102
101
|
"react": "17.0.2",
|
|
103
102
|
"react-dom": "17.0.2",
|
|
104
103
|
"react-test-renderer": "17.0.2",
|
|
105
|
-
"tsbb": "3.5.
|
|
104
|
+
"tsbb": "3.5.6"
|
|
106
105
|
},
|
|
107
106
|
"browserslist": {
|
|
108
107
|
"production": [
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
/* eslint-disable jest/no-conditional-expect */
|
|
5
|
+
import React, { useEffect, useRef } from 'react';
|
|
6
|
+
import renderer from 'react-test-renderer';
|
|
7
|
+
import { render, fireEvent, screen } from '@testing-library/react';
|
|
8
|
+
// import userEvent from '@testing-library/user-event';
|
|
9
|
+
// import '@testing-library/jest-dom';
|
|
10
|
+
import CodeMirror, { ReactCodeMirrorRef } from '..';
|
|
11
|
+
|
|
12
|
+
it('CodeMirror', async () => {
|
|
13
|
+
const component = renderer.create(<CodeMirror />);
|
|
14
|
+
let tree = component.toJSON();
|
|
15
|
+
if (tree && !Array.isArray(tree)) {
|
|
16
|
+
expect(tree.type).toEqual('div');
|
|
17
|
+
expect(tree.props.className).toEqual('cm-theme-light');
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('CodeMirror onChange', async () => {
|
|
22
|
+
const handleChange = jest.fn((value) => {
|
|
23
|
+
expect(value).toEqual('# title');
|
|
24
|
+
return Array.isArray(value) ? value.join() : value;
|
|
25
|
+
});
|
|
26
|
+
render(<CodeMirror autoFocus value="console.log('Hello world!')" onChange={handleChange} />);
|
|
27
|
+
const input = await screen.findByRole<HTMLInputElement>('textbox'); // findByRole('textbox');
|
|
28
|
+
fireEvent.change(input, { target: { textContent: '# title' } });
|
|
29
|
+
const elm = screen.queryByText('# title');
|
|
30
|
+
expect((elm as any).cmView.dom.innerHTML).toEqual('# title');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('CodeMirror onUpdate', async () => {
|
|
34
|
+
render(
|
|
35
|
+
<CodeMirror
|
|
36
|
+
value="console.log('Hello world!')"
|
|
37
|
+
autoFocus
|
|
38
|
+
onUpdate={(viewUpdate) => {
|
|
39
|
+
expect(viewUpdate.state.doc.length).toEqual(27);
|
|
40
|
+
}}
|
|
41
|
+
/>,
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('CodeMirror ref', async () => {
|
|
46
|
+
function Demo() {
|
|
47
|
+
const ref = useRef<ReactCodeMirrorRef>(null);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
expect(Object.keys(ref.current!)).toEqual(['editor', 'state', 'view']);
|
|
50
|
+
}, [ref]);
|
|
51
|
+
|
|
52
|
+
return <CodeMirror ref={ref} value="console.log('Hello world!')" />;
|
|
53
|
+
}
|
|
54
|
+
render(<Demo />);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('CodeMirror theme', async () => {
|
|
58
|
+
const component = renderer.create(<CodeMirror theme="dark" />);
|
|
59
|
+
let tree = component.toJSON();
|
|
60
|
+
if (tree && !Array.isArray(tree)) {
|
|
61
|
+
expect(tree.type).toEqual('div');
|
|
62
|
+
expect(tree.props.className).toEqual('cm-theme-dark');
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('CodeMirror className', async () => {
|
|
67
|
+
const component = renderer.create(<CodeMirror className="test" />);
|
|
68
|
+
let tree = component.toJSON();
|
|
69
|
+
if (tree && !Array.isArray(tree)) {
|
|
70
|
+
expect(tree.type).toEqual('div');
|
|
71
|
+
expect(tree.props.className).toEqual('cm-theme-light test');
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('CodeMirror placeholder', async () => {
|
|
76
|
+
render(<CodeMirror placeholder="Hello World" className="test" />);
|
|
77
|
+
const elm = screen.queryByText('Hello World');
|
|
78
|
+
expect(elm!.style['pointerEvents']).toEqual('none');
|
|
79
|
+
expect(elm!.className).toEqual('cm-placeholder');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('CodeMirror editable', async () => {
|
|
83
|
+
render(<CodeMirror editable={false} className="test" />);
|
|
84
|
+
const text = screen.getByRole('textbox');
|
|
85
|
+
expect(text.className).toEqual('cm-content');
|
|
86
|
+
expect(text.tagName).toEqual('DIV');
|
|
87
|
+
});
|
package/src/index.tsx
CHANGED
|
@@ -70,7 +70,7 @@ export interface ReactCodeMirrorRef {
|
|
|
70
70
|
const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProps>((props, ref) => {
|
|
71
71
|
const {
|
|
72
72
|
className,
|
|
73
|
-
value,
|
|
73
|
+
value = '',
|
|
74
74
|
selection,
|
|
75
75
|
extensions = [],
|
|
76
76
|
onChange,
|
|
@@ -112,14 +112,9 @@ const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProp
|
|
|
112
112
|
onUpdate,
|
|
113
113
|
extensions,
|
|
114
114
|
});
|
|
115
|
-
useImperativeHandle(ref, () => ({ editor: container, state, view }));
|
|
115
|
+
useImperativeHandle(ref, () => ({ editor: container, state, view }), [container, state, view]);
|
|
116
116
|
useEffect(() => {
|
|
117
117
|
setContainer(editor.current);
|
|
118
|
-
return () => {
|
|
119
|
-
if (view) {
|
|
120
|
-
view.destroy();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
118
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
119
|
}, []);
|
|
125
120
|
|