misp-modules/website/app/static/js/editor.js

1 line
542 KiB
JavaScript
Raw Normal View History

2024-02-07 14:39:19 +01:00
var Editor;(()=>{"use strict";var t={d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{EditorView:()=>Mr,basicSetup:()=>Vf,markdown:()=>gS});class i{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),r.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){let i=[];return this.decompose(t,e,i,0),r.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new l(this),r=new l(t);for(let t=e,s=e;;){if(n.next(t),r.next(t),t=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(t=1){return new l(this,t)}iterRange(t,e=this.length){return new a(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new h(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(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 n(t):r.from(n.split(t,[])):i.empty}}class n extends i{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let r=0;;r++){let s=this.text[r],o=n+s.length;if((e?i:o)>=t)return new c(n,o,i,s);n=o+1,i++}}decompose(t,e,i,r){let l=t<=0&&e>=this.length?this:new n(o(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&r){let t=i.pop(),e=s(l.text,t.text.slice(),0,l.length);if(e.length<=32)i.push(new n(e,t.length+l.length));else{let t=e.length>>1;i.push(new n(e.slice(0,t)),new n(e.slice(t)))}}else i.push(l)}replace(t,e,i){if(!(i instanceof n))return super.replace(t,e,i);let l=s(this.text,s(i.text,o(this.text,0,t)),e),a=this.length+i.length-(e-t);return l.length<=32?new n(l,a):r.from(n.split(l,[]),a)}sliceString(t,e=this.length,i="\n"){let n="";for(let r=0,s=0;r<=e&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;r>t&&s&&(n+=i),t<l&&e>r&&(n+=o.slice(Math.max(0,t-r),e-r)),r=l+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],r=-1;for(let s of t)i.push(s),r+=s.length+1,32==i.length&&(e.push(new n(i,r)),i=[],r=-1);return r>-1&&e.push(new n(i,r)),e}}class r extends i{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let r=0;;r++){let s=this.children[r],o=n+s.length,l=i+s.lines-1;if((e?l:o)>=t)return s.lineInner(t,e,i,n);n=o+1,i=l+1}}decompose(t,e,i,n){for(let r=0,s=0;s<=e&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(t<=l&&e>=s){let r=n&((s<=t?1:0)|(l>=e?2:0));s>=t&&l<=e&&!r?i.push(o):o.decompose(t-s,e-s,i,r)}s=l+1}}replace(t,e,i){if(i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.length;if(t>=s&&e<=l){let a=o.replace(t-s,e-s,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let s=this.children.slice();return s[n]=a,new r(s,this.length-(e-t)+i.length)}return super.replace(s,l,a)}s=l+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){let n="";for(let r=0,s=0;r<this.children.length&&s<=e;r++){let o=this.children[r],l=s+o.length