@sqx717/element-tiptap-vue3-fixed
Version:
🌸A modern WYSIWYG rich-text editor using tiptap and Element Plus for Vue3
4 lines • 883 kB
JavaScript
(function(q,s){typeof exports=="object"&&typeof module!="undefined"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(q=typeof globalThis!="undefined"?globalThis:q||self,s(q.ElementTiptapVue3Fixed={},q.vue))})(this,function(q,s){"use strict";function st(t){this.content=t}st.prototype={constructor:st,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var o=n&&n!=t?this.remove(n):this,r=o.find(t),i=o.content.slice();return r==-1?i.push(n||t,e):(i[r+1]=e,n&&(i[r]=n)),new st(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new st(n)},addToStart:function(t,e){return new st([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new st(n)},addBefore:function(t,e,n){var o=this.remove(e),r=o.content.slice(),i=o.find(t);return r.splice(i==-1?r.length:i,0,e,n),new st(r)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=st.from(t),t.size?new st(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=st.from(t),t.size?new st(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=st.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}},st.from=function(t){if(t instanceof st)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new st(e)};function dp(t,e,n){for(let o=0;;o++){if(o==t.childCount||o==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(o),i=e.child(o);if(r==i){n+=r.nodeSize;continue}if(!r.sameMarkup(i))return n;if(r.isText&&r.text!=i.text){for(let l=0;r.text[l]==i.text[l];l++)n++;return n}if(r.content.size||i.content.size){let l=dp(r.content,i.content,n+1);if(l!=null)return l}n+=r.nodeSize}}function fp(t,e,n,o){for(let r=t.childCount,i=e.childCount;;){if(r==0||i==0)return r==i?null:{a:n,b:o};let l=t.child(--r),a=e.child(--i),c=l.nodeSize;if(l==a){n-=c,o-=c;continue}if(!l.sameMarkup(a))return{a:n,b:o};if(l.isText&&l.text!=a.text){let u=0,d=Math.min(l.text.length,a.text.length);for(;u<d&&l.text[l.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,o--;return{a:n,b:o}}if(l.content.size||a.content.size){let u=fp(l.content,a.content,n-1,o-1);if(u)return u}n-=c,o-=c}}class N{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,n,o,r=0,i){for(let l=0,a=0;a<n;l++){let c=this.content[l],u=a+c.nodeSize;if(u>e&&o(c,r+a,i||null,l)!==!1&&c.content.size){let d=a+1;c.nodesBetween(Math.max(0,e-d),Math.min(c.content.size,n-d),o,r+d)}a=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,o,r){let i="",l=!0;return this.nodesBetween(e,n,(a,c)=>{let u=a.isText?a.text.slice(Math.max(e,c)-c,n-c):a.isLeaf?r?typeof r=="function"?r(a):r:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&o&&(l?l=!1:i+=o),i+=u},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,o=e.firstChild,r=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(o)&&(r[r.length-1]=n.withText(n.text+o.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new N(r,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let o=[],r=0;if(n>e)for(let i=0,l=0;l<n;i++){let a=this.content[i],c=l+a.nodeSize;c>e&&((l<e||c>n)&&(a.isText?a=a.cut(Math.max(0,e-l),Math.min(a.text.length,n-l)):a=a.cut(Math.max(0,e-l-1),Math.min(a.content.size,n-l-1))),o.push(a),r+=a.nodeSize),l=c}return new N(o,r)}cutByIndex(e,n){return e==n?N.empty:e==0&&n==this.content.length?this:new N(this.content.slice(e,n))}replaceChild(e,n){let o=this.content[e];if(o==n)return this;let r=this.content.slice(),i=this.size+n.nodeSize-o.nodeSize;return r[e]=n,new N(r,i)}addToStart(e){return new N([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new N(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,o=0;n<this.content.length;n++){let r=this.content[n];e(r,o,n),o+=r.nodeSize}}findDiffStart(e,n=0){return dp(this,e,n)}findDiffEnd(e,n=this.size,o=e.size){return fp(this,e,n,o)}findIndex(e,n=-1){if(e==0)return Ds(0,e);if(e==this.size)return Ds(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let o=0,r=0;;o++){let i=this.child(o),l=r+i.nodeSize;if(l>=e)return l==e||n>0?Ds(o+1,l):Ds(o,r);r=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return N.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new N(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return N.empty;let n,o=0;for(let r=0;r<e.length;r++){let i=e[r];o+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(n||(n=e.slice(0,r)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new N(n||e,o)}static from(e){if(!e)return N.empty;if(e instanceof N)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new N([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}N.empty=new N([],0);const hc={index:0,offset:0};function Ds(t,e){return hc.index=t,hc.offset=e,hc}function Ms(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let o=0;o<t.length;o++)if(!Ms(t[o],e[o]))return!1}else{for(let o in t)if(!(o in e)||!Ms(t[o],e[o]))return!1;for(let o in e)if(!(o in t))return!1}return!0}class ke{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,o=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!o&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,r)),n.push(this),o=!0),n&&n.push(i)}}return n||(n=e.slice()),o||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Ms(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let o=e.marks[n.type];if(!o)throw new RangeError(`There is no mark type ${n.type} in this schema`);let r=o.create(n.attrs);return o.checkAttrs(r.attrs),r}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(n[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return ke.none;if(e instanceof ke)return[e];let n=e.slice();return n.sort((o,r)=>o.type.rank-r.type.rank),n}}ke.none=[];class Os extends Error{}class V{constructor(e,n,o){this.content=e,this.openStart=n,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let o=hp(this.content,e+this.openStart,n);return o&&new V(o,this.openStart,this.openEnd)}removeBetween(e,n){return new V(pp(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return V.empty;let o=n.openStart||0,r=n.openEnd||0;if(typeof o!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new V(N.fromJSON(e,n.content),o,r)}static maxOpen(e,n=!0){let o=0,r=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)o++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)r++;return new V(e,o,r)}}V.empty=new V(N.empty,0,0);function pp(t,e,n){let{index:o,offset:r}=t.findIndex(e),i=t.maybeChild(o),{index:l,offset:a}=t.findIndex(n);if(r==e||i.isText){if(a!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(o!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(o,i.copy(pp(i.content,e-r-1,n-r-1)))}function hp(t,e,n,o){let{index:r,offset:i}=t.findIndex(e),l=t.maybeChild(r);if(i==e||l.isText)return o&&!o.canReplace(r,r,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=hp(l.content,e-i-1,n);return a&&t.replaceChild(r,l.copy(a))}function q2(t,e,n){if(n.openStart>t.depth)throw new Os("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Os("Inconsistent open depths");return mp(t,e,n,0)}function mp(t,e,n,o){let r=t.index(o),i=t.node(o);if(r==e.index(o)&&o<t.depth-n.openStart){let l=mp(t,e,n,o+1);return i.copy(i.content.replaceChild(r,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==o&&e.depth==o){let l=t.parent,a=l.content;return Do(l,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:l,end:a}=K2(n,t);return Do(i,bp(t,l,a,e,o))}else return Do(i,Bs(t,e,o))}function gp(t,e){if(!e.type.compatibleContent(t.type))throw new Os("Cannot join "+e.type.name+" onto "+t.type.name)}function mc(t,e,n){let o=t.node(n);return gp(o,e.node(n)),o}function _o(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function di(t,e,n,o){let r=(e||t).node(n),i=0,l=e?e.index(n):r.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(_o(t.nodeAfter,o),i++));for(let a=i;a<l;a++)_o(r.child(a),o);e&&e.depth==n&&e.textOffset&&_o(e.nodeBefore,o)}function Do(t,e){return t.type.checkContent(e),t.copy(e)}function bp(t,e,n,o,r){let i=t.depth>r&&mc(t,e,r+1),l=o.depth>r&&mc(n,o,r+1),a=[];return di(null,t,r,a),i&&l&&e.index(r)==n.index(r)?(gp(i,l),_o(Do(i,bp(t,e,n,o,r+1)),a)):(i&&_o(Do(i,Bs(t,e,r+1)),a),di(e,n,r,a),l&&_o(Do(l,Bs(n,o,r+1)),a)),di(o,null,r,a),new N(a)}function Bs(t,e,n){let o=[];if(di(null,t,n,o),t.depth>n){let r=mc(t,e,n+1);_o(Do(r,Bs(t,e,n+1)),o)}return di(e,null,n,o),new N(o)}function K2(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)r=e.node(i).copy(N.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}class fi{constructor(e,n,o){this.pos=e,this.path=n,this.parentOffset=o,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],r=e.child(n);return o?e.child(n).cut(o):r}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let o=this.path[n*3],r=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)r+=o.child(i).nodeSize;return r}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ke.none;if(this.textOffset)return e.child(n).marks;let o=e.maybeChild(n-1),r=e.maybeChild(n);if(!o){let a=o;o=r,r=a}let i=o.marks;for(var l=0;l<i.length;l++)i[l].type.spec.inclusive===!1&&(!r||!i[l].isInSet(r.marks))&&(i=i[l--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let o=n.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!r||!o[i].isInSet(r.marks))&&(o=o[i--].removeFromSet(o));return o}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!n||n(this.node(o))))return new Ns(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let o=[],r=0,i=n;for(let l=e;;){let{index:a,offset:c}=l.content.findIndex(i),u=i-c;if(o.push(l,a,r+c),!u||(l=l.child(a),l.isText))break;i=u-1,r+=c+1}return new fi(n,o,i)}static resolveCached(e,n){let o=yp.get(e);if(o)for(let i=0;i<o.elts.length;i++){let l=o.elts[i];if(l.pos==n)return l}else yp.set(e,o=new G2);let r=o.elts[o.i]=fi.resolve(e,n);return o.i=(o.i+1)%J2,r}}class G2{constructor(){this.elts=[],this.i=0}}const J2=12,yp=new WeakMap;class Ns{constructor(e,n,o){this.$from=e,this.$to=n,this.depth=o}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Y2=Object.create(null);class tn{constructor(e,n,o,r=ke.none){this.type=e,this.attrs=n,this.marks=r,this.content=o||N.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,o,r=0){this.content.nodesBetween(e,n,o,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,o,r){return this.content.textBetween(e,n,o,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,o){return this.type==e&&Ms(this.attrs,n||e.defaultAttrs||Y2)&&ke.sameSet(this.marks,o||ke.none)}copy(e=null){return e==this.content?this:new tn(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new tn(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,o=!1){if(e==n)return V.empty;let r=this.resolve(e),i=this.resolve(n),l=o?0:r.sharedDepth(n),a=r.start(l),u=r.node(l).content.cut(r.pos-a,i.pos-a);return new V(u,r.depth-l,i.depth-l)}replace(e,n,o){return q2(this.resolve(e),this.resolve(n),o)}nodeAt(e){for(let n=this;;){let{index:o,offset:r}=n.content.findIndex(e);if(n=n.maybeChild(o),!n)return null;if(r==e||n.isText)return n;e-=r+1}}childAfter(e){let{index:n,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(n),index:n,offset:o};let r=this.content.child(n-1);return{node:r,index:n-1,offset:o-r.nodeSize}}resolve(e){return fi.resolveCached(this,e)}resolveNoCache(e){return fi.resolve(this,e)}rangeHasMark(e,n,o){let r=!1;return n>e&&this.nodesBetween(e,n,i=>(o.isInSet(i.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Cp(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,o=N.empty,r=0,i=o.childCount){let l=this.contentMatchAt(e).matchFragment(o,r,i),a=l&&l.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let c=r;c<i;c++)if(!this.type.allowsMarks(o.child(c).marks))return!1;return!0}canReplaceWith(e,n,o,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(o),l=i&&i.matchFragment(this.content,n);return l?l.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ke.none;for(let n=0;n<this.marks.length;n++){let o=this.marks[n];o.type.checkAttrs(o.attrs),e=o.addToSet(e)}if(!ke.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let o;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,o)}let r=N.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,r,o);return i.type.checkAttrs(i.attrs),i}}tn.prototype.text=void 0;class Is extends tn{constructor(e,n,o,r){if(super(e,n,null,r),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Cp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Is(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Is(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Cp(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Mo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let o=new X2(e,n);if(o.next==null)return Mo.empty;let r=wp(o);o.next&&o.err("Unexpected trailing text");let i=rC(oC(r));return iC(i,o),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,o=e.childCount){let r=this;for(let i=n;r&&i<o;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let o=0;o<e.next.length;o++)if(this.next[n].type==e.next[o].type)return!0;return!1}fillBefore(e,n=!1,o=0){let r=[this];function i(l,a){let c=l.matchFragment(e,o);if(c&&(!n||c.validEnd))return N.from(a.map(u=>u.createAndFill()));for(let u=0;u<l.next.length;u++){let{type:d,next:f}=l.next[u];if(!(d.isText||d.hasRequiredAttrs())&&r.indexOf(f)==-1){r.push(f);let p=i(f,a.concat(d));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let r=o.shift(),i=r.match;if(i.matchType(e)){let l=[];for(let a=r;a.type;a=a.via)l.push(a.type);return l.reverse()}for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!r.type||c.validEnd)&&(o.push({match:a.contentMatch,type:a,via:r}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(o){e.push(o);for(let r=0;r<o.next.length;r++)e.indexOf(o.next[r].next)==-1&&n(o.next[r].next)}return n(this),e.map((o,r)=>{let i=r+(o.validEnd?"*":" ")+" ";for(let l=0;l<o.next.length;l++)i+=(l?", ":"")+o.next[l].type.name+"->"+e.indexOf(o.next[l].next);return i}).join(`
`)}}Mo.empty=new Mo(!0);class X2{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function wp(t){let e=[];do e.push(Z2(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Z2(t){let e=[];do e.push(Q2(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Q2(t){let e=nC(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=eC(t,e);else break;return e}function vp(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function eC(t,e){let n=vp(t),o=n;return t.eat(",")&&(t.next!="}"?o=vp(t):o=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:e}}function tC(t,e){let n=t.nodeTypes,o=n[e];if(o)return[o];let r=[];for(let i in n){let l=n[i];l.isInGroup(e)&&r.push(l)}return r.length==0&&t.err("No node type or group '"+e+"' found"),r}function nC(t){if(t.eat("(")){let e=wp(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=tC(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function oC(t){let e=[[]];return r(i(t,0),n()),e;function n(){return e.push([])-1}function o(l,a,c){let u={term:c,to:a};return e[l].push(u),u}function r(l,a){l.forEach(c=>c.to=a)}function i(l,a){if(l.type=="choice")return l.exprs.reduce((c,u)=>c.concat(i(u,a)),[]);if(l.type=="seq")for(let c=0;;c++){let u=i(l.exprs[c],a);if(c==l.exprs.length-1)return u;r(u,a=n())}else if(l.type=="star"){let c=n();return o(a,c),r(i(l.expr,c),c),[o(c)]}else if(l.type=="plus"){let c=n();return r(i(l.expr,a),c),r(i(l.expr,c),c),[o(c)]}else{if(l.type=="opt")return[o(a)].concat(i(l.expr,a));if(l.type=="range"){let c=a;for(let u=0;u<l.min;u++){let d=n();r(i(l.expr,c),d),c=d}if(l.max==-1)r(i(l.expr,c),c);else for(let u=l.min;u<l.max;u++){let d=n();o(c,d),r(i(l.expr,c),d),c=d}return[o(c)]}else{if(l.type=="name")return[o(a,void 0,l.value)];throw new Error("Unknown expr type")}}}}function Ep(t,e){return e-t}function kp(t,e){let n=[];return o(e),n.sort(Ep);function o(r){let i=t[r];if(i.length==1&&!i[0].term)return o(i[0].to);n.push(r);for(let l=0;l<i.length;l++){let{term:a,to:c}=i[l];!a&&n.indexOf(c)==-1&&o(c)}}}function rC(t){let e=Object.create(null);return n(kp(t,0));function n(o){let r=[];o.forEach(l=>{t[l].forEach(({term:a,to:c})=>{if(!a)return;let u;for(let d=0;d<r.length;d++)r[d][0]==a&&(u=r[d][1]);kp(t,c).forEach(d=>{u||r.push([a,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let i=e[o.join(",")]=new Mo(o.indexOf(t.length-1)>-1);for(let l=0;l<r.length;l++){let a=r[l][1].sort(Ep);i.next.push({type:r[l][0],next:e[a.join(",")]||n(a)})}return i}}function iC(t,e){for(let n=0,o=[t];n<o.length;n++){let r=o[n],i=!r.validEnd,l=[];for(let a=0;a<r.next.length;a++){let{type:c,next:u}=r.next[a];l.push(c.name),i&&!(c.isText||c.hasRequiredAttrs())&&(i=!1),o.indexOf(u)==-1&&o.push(u)}i&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Sp(t){let e=Object.create(null);for(let n in t){let o=t[n];if(!o.hasDefault)return null;e[n]=o.default}return e}function Ap(t,e){let n=Object.create(null);for(let o in t){let r=e&&e[o];if(r===void 0){let i=t[o];if(i.hasDefault)r=i.default;else throw new RangeError("No value supplied for attribute "+o)}n[o]=r}return n}function Tp(t,e,n,o){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let r in t){let i=t[r];i.validate&&i.validate(e[r])}}function xp(t,e){let n=Object.create(null);if(e)for(let o in e)n[o]=new lC(t,o,e[o]);return n}class Ls{constructor(e,n,o){this.name=e,this.schema=n,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=xp(e,o.attrs),this.defaultAttrs=Sp(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Mo.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ap(this.attrs,e)}create(e=null,n,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new tn(this,this.computeAttrs(e),N.from(n),ke.setFrom(o))}createChecked(e=null,n,o){return n=N.from(n),this.checkContent(n),new tn(this,this.computeAttrs(e),n,ke.setFrom(o))}createAndFill(e=null,n,o){if(e=this.computeAttrs(e),n=N.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let r=this.contentMatch.matchFragment(n),i=r&&r.fillBefore(N.empty,!0);return i?new tn(this,e,n.append(i),ke.setFrom(o)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Tp(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?n&&n.push(e[o]):n||(n=e.slice(0,o));return n?n.length?n:ke.none:e}static compile(e,n){let o=Object.create(null);e.forEach((i,l)=>o[i]=new Ls(i,n,l));let r=n.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let i in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}}function sC(t,e,n){let o=n.split("|");return r=>{let i=r===null?"null":typeof r;if(o.indexOf(i)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${t}, got ${i}`)}}class lC{constructor(e,n,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?sC(e,n,o.validate):o.validate}get isRequired(){return!this.hasDefault}}class Rs{constructor(e,n,o,r){this.name=e,this.rank=n,this.schema=o,this.spec=r,this.attrs=xp(e,r.attrs),this.excluded=null;let i=Sp(this.attrs);this.instance=i?new ke(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ke(this,Ap(this.attrs,e))}static compile(e,n){let o=Object.create(null),r=0;return e.forEach((i,l)=>o[i]=new Rs(i,r++,n,l)),o}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Tp(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class _p{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let r in e)n[r]=e[r];n.nodes=st.from(e.nodes),n.marks=st.from(e.marks||{}),this.nodes=Ls.compile(this.spec.nodes,this),this.marks=Rs.compile(this.spec.marks,this);let o=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let i=this.nodes[r],l=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=o[l]||(o[l]=Mo.parse(l,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?Dp(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let r in this.marks){let i=this.marks[r],l=i.spec.excludes;i.excluded=l==null?[i]:l==""?[]:Dp(this,l.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,o,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ls){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,o,r)}text(e,n){let o=this.nodes.text;return new Is(o,o.defaultAttrs,e,ke.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return tn.fromJSON(this,e)}markFromJSON(e){return ke.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Dp(t,e){let n=[];for(let o=0;o<e.length;o++){let r=e[o],i=t.marks[r],l=i;if(i)n.push(i);else for(let a in t.marks){let c=t.marks[a];(r=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(r)>-1)&&n.push(l=c)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return n}function aC(t){return t.tag!=null}function cC(t){return t.style!=null}class Zn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let o=this.matchedStyles=[];n.forEach(r=>{if(aC(r))this.tags.push(r);else if(cC(r)){let i=/[^=]*/.exec(r.style)[0];o.indexOf(i)<0&&o.push(i),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let o=new Np(this,n,!1);return o.addAll(e,ke.none,n.from,n.to),o.finish()}parseSlice(e,n={}){let o=new Np(this,n,!0);return o.addAll(e,ke.none,n.from,n.to),V.maxOpen(o.finish())}matchTag(e,n,o){for(let r=o?this.tags.indexOf(o)+1:0;r<this.tags.length;r++){let i=this.tags[r];if(fC(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let l=i.getAttrs(e);if(l===!1)continue;i.attrs=l||void 0}return i}}}matchStyle(e,n,o,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let l=this.styles[i],a=l.style;if(!(a.indexOf(e)!=0||l.context&&!o.matchesContext(l.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(l.getAttrs){let c=l.getAttrs(n);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(e){let n=[];function o(r){let i=r.priority==null?50:r.priority,l=0;for(;l<n.length;l++){let a=n[l];if((a.priority==null?50:a.priority)<i)break}n.splice(l,0,r)}for(let r in e.marks){let i=e.marks[r].spec.parseDOM;i&&i.forEach(l=>{o(l=Ip(l)),l.mark||l.ignore||l.clearMark||(l.mark=r)})}for(let r in e.nodes){let i=e.nodes[r].spec.parseDOM;i&&i.forEach(l=>{o(l=Ip(l)),l.node||l.ignore||l.mark||(l.node=r)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Zn(e,Zn.schemaRules(e)))}}const Mp={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},uC={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Op={ol:!0,ul:!0},pi=1,gc=2,hi=4;function Bp(t,e,n){return e!=null?(e?pi:0)|(e==="full"?gc:0):t&&t.whitespace=="pre"?pi|gc:n&~hi}class Ps{constructor(e,n,o,r,i,l){this.type=e,this.attrs=n,this.marks=o,this.solid=r,this.options=l,this.content=[],this.activeMarks=ke.none,this.match=i||(l&hi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(N.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let o=this.type.contentMatch,r;return(r=o.findWrapping(e.type))?(this.match=o,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&pi)){let o=this.content[this.content.length-1],r;if(o&&o.isText&&(r=/[ \t\r\n\u000c]+$/.exec(o.text))){let i=o;o.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-r[0].length))}}let n=N.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(N.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Mp.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Np{constructor(e,n,o){this.parser=e,this.options=n,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let r=n.topNode,i,l=Bp(null,n.preserveWhitespace,0)|(o?hi:0);r?i=new Ps(r.type,r.attrs,ke.none,!0,n.topMatch||r.type.contentMatch,l):o?i=new Ps(null,null,ke.none,!0,null,l):i=new Ps(e.schema.topNodeType,null,ke.none,!0,null,l),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let o=e.nodeValue,r=this.top,i=r.options&gc?"full":this.localPreserveWS||(r.options&pi)>0;if(i==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(i)i!=="full"?o=o.replace(/\r?\n|\r/g," "):o=o.replace(/\r\n?/g,`
`);else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let l=r.content[r.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(o=o.slice(1))}o&&this.insertNode(this.parser.schema.text(o),n,!/\S/.test(o)),this.findInText(e)}else this.findInside(e)}addElement(e,n,o){let r=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let l=e.nodeName.toLowerCase(),a;Op.hasOwnProperty(l)&&this.parser.normalizeLists&&dC(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,o));e:if(c?c.ignore:uC.hasOwnProperty(l))this.findInside(e),this.ignoreFallback(e,n);else if(!c||c.skip||c.closeParent){c&&c.closeParent?this.open=Math.max(0,this.open-1):c&&c.skip.nodeType&&(e=c.skip);let u,d=this.needsBlock;if(Mp.hasOwnProperty(l))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),u=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(i),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?a:void 0)}this.localPreserveWS=r}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let o=e.style;if(o&&o.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let i=this.parser.matchedStyles[r],l=o.getPropertyValue(i);if(l)for(let a=void 0;;){let c=this.parser.matchStyle(i,l,this,a);if(!c)break;if(c.ignore)return null;if(c.clearMark?n=n.filter(u=>!c.clearMark(u)):n=n.concat(this.parser.schema.marks[c.mark].create(c.attrs)),c.consuming===!1)a=c;else break}}return n}addElementByRule(e,n,o,r){let i,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),o,e.nodeName=="BR")||this.leafFallback(e,o);else{let c=this.enter(l,n.attrs||null,o,n.preserveWhitespace);c&&(i=!0,o=c)}else{let c=this.parser.schema.marks[n.mark];o=o.concat(c.create(n.attrs))}let a=this.top;if(l&&l.isLeaf)this.findInside(e);else if(r)this.addElement(e,o,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(c=>this.insertNode(c,o,!1));else{let c=e;typeof n.contentElement=="string"?c=e.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(e):n.contentElement&&(c=n.contentElement),this.findAround(e,c,!0),this.addAll(c,o),this.findAround(e,c,!1)}i&&this.sync(a)&&this.open--}addAll(e,n,o,r){let i=o||0;for(let l=o?e.childNodes[o]:e.firstChild,a=r==null?null:e.childNodes[r];l!=a;l=l.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(l,n);this.findAtPoint(e,i)}findPlace(e,n,o){let r,i;for(let l=this.open,a=0;l>=0;l--){let c=this.nodes[l],u=c.findWrapping(e);if(u&&(!r||r.length>u.length+a)&&(r=u,i=c,!u.length))break;if(c.solid){if(o)break;a+=2}}if(!r)return null;this.sync(i);for(let l=0;l<r.length;l++)n=this.enterInner(r[l],null,n,!1);return n}insertNode(e,n,o){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let r=this.findPlace(e,n,o);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let l=ke.none;for(let a of r.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):Lp(a.type,e.type))&&(l=a.addToSet(l));return i.content.push(e.mark(l)),!0}return!1}enter(e,n,o,r){let i=this.findPlace(e.create(n),o,!1);return i&&(i=this.enterInner(e,n,o,!0,r)),i}enterInner(e,n,o,r=!1,i){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(e);let a=Bp(e,i,l.options);l.options&hi&&l.content.length==0&&(a|=hi);let c=ke.none;return o=o.filter(u=>(l.type?l.type.allowsMarkType(u.type):Lp(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new Ps(e,n,c,r,null,a)),this.open++,o}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=pi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let o=this.nodes[n].content;for(let r=o.length-1;r>=0;r--)e+=o[r].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==n&&(this.find[o].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,o){if(e!=n&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&n.compareDocumentPosition(this.find[r].node)&(o?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),o=this.options.context,r=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),i=-(o?o.depth+1:0)+(r?0:1),l=(a,c)=>{for(;a>=0;a--){let u=n[a];if(u==""){if(a==n.length-1||a==0)continue;for(;c>=i;c--)if(l(a-1,c))return!0;return!1}else{let d=c>0||c==0&&r?this.nodes[c].type:o&&c>=i?o.node(c-i).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let n in this.parser.schema.nodes){let o=this.parser.schema.nodes[n];if(o.isTextblock&&o.defaultAttrs)return o}}}function dC(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Op.hasOwnProperty(o)&&n?(n.appendChild(e),e=n):o=="li"?n=e:o&&(n=null)}}function fC(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ip(t){let e={};for(let n in t)e[n]=t[n];return e}function Lp(t,e){let n=e.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(t))continue;let i=[],l=a=>{i.push(a);for(let c=0;c<a.edgeCount;c++){let{type:u,next:d}=a.edge(c);if(u==e||i.indexOf(d)<0&&l(d))return!0}};if(l(r.contentMatch))return!0}}class Oo{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},o){o||(o=bc(n).createDocumentFragment());let r=o,i=[];return e.forEach(l=>{if(i.length||l.marks.length){let a=0,c=0;for(;a<i.length&&c<l.marks.length;){let u=l.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(i[a][0])||u.type.spec.spanning===!1)break;a++,c++}for(;a<i.length;)r=i.pop()[1];for(;c<l.marks.length;){let u=l.marks[c++],d=this.serializeMark(u,l.isInline,n);d&&(i.push([u,r]),r.appendChild(d.dom),r=d.contentDOM||d.dom)}}r.appendChild(this.serializeNodeInner(l,n))}),o}serializeNodeInner(e,n){let{dom:o,contentDOM:r}=$s(bc(n),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,r)}return o}serializeNode(e,n={}){let o=this.serializeNodeInner(e,n);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(o),o=i.dom)}return o}serializeMark(e,n,o={}){let r=this.marks[e.type.name];return r&&$s(bc(o),r(e,n),null,e.attrs)}static renderSpec(e,n,o=null,r){return $s(e,n,o,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Oo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Rp(e.nodes);return n.text||(n.text=o=>o.text),n}static marksFromSchema(e){return Rp(e.marks)}}function Rp(t){let e={};for(let n in t){let o=t[n].spec.toDOM;o&&(e[n]=o)}return e}function bc(t){return t.document||window.document}const Pp=new WeakMap;function pC(t){let e=Pp.get(t);return e===void 0&&Pp.set(t,e=hC(t)),e}function hC(t){let e=null;function n(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let r=0;r<o.length;r++)n(o[r]);else for(let r in o)n(o[r])}return n(t),e}function $s(t,e,n,o){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],i;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(i=pC(o))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=r.indexOf(" ");l>0&&(n=r.slice(0,l),r=r.slice(l+1));let a,c=n?t.createElementNS(n,r):t.createElement(r),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),u[f]):c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:h}=$s(t,p,n,o);if(c.appendChild(m),h){if(a)throw new RangeError("Multiple content holes");a=h}}}return{dom:c,contentDOM:a}}const $p=65535,Fp=Math.pow(2,16);function mC(t,e){return t+e*Fp}function zp(t){return t&$p}function gC(t){return(t-(t&$p))/Fp}const Vp=1,Hp=2,Fs=4,jp=8;class yc{constructor(e,n,o){this.pos=e,this.delInfo=n,this.recover=o}get deleted(){return(this.delInfo&jp)>0}get deletedBefore(){return(this.delInfo&(Vp|Fs))>0}get deletedAfter(){return(this.delInfo&(Hp|Fs))>0}get deletedAcross(){return(this.delInfo&Fs)>0}}class Ot{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ot.empty)return Ot.empty}recover(e){let n=0,o=zp(e);if(!this.inverted)for(let r=0;r<o;r++)n+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[o*3]+n+gC(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,o){let r=0,i=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>e)break;let u=this.ranges[a+i],d=this.ranges[a+l],f=c+u;if(e<=f){let p=u?e==c?-1:e==f?1:n:n,m=c+r+(p<0?0:d);if(o)return m;let h=e==(n<0?c:f)?null:mC(a/3,e-c),g=e==c?Hp:e==f?Vp:Fs;return(n<0?e!=c:e!=f)&&(g|=jp),new yc(m,g,h)}r+=d-u}return o?e+r:new yc(e+r,0,null)}touches(e,n){let o=0,r=zp(n),i=this.inverted?2:1,l=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?o:0);if(c>e)break;let u=this.ranges[a+i],d=c+u;if(e<=d&&a==r*3)return!0;o+=this.ranges[a+l]-u}return!1}forEach(e){let n=this.inverted?2:1,o=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let l=this.ranges[r],a=l-(this.inverted?i:0),c=l+(this.inverted?0:i),u=this.ranges[r+n],d=this.ranges[r+o];e(a,a+u,c,c+d),i+=d-u}}invert(){return new Ot(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ot.empty:new Ot(e<0?[0,-e,0]:[0,0,e])}}Ot.empty=new Ot([]);class mi{constructor(e,n,o=0,r=e?e.length:0){this.mirror=n,this.from=o,this.to=r,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new mi(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,o=this._maps.length;n<e._maps.length;n++){let r=e.getMirror(n);this.appendMap(e._maps[n],r!=null&&r<n?o+r:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,o=this._maps.length+e._maps.length;n>=0;n--){let r=e.getMirror(n);this.appendMap(e._maps[n].invert(),r!=null&&r>n?o-r-1:void 0)}}invert(){let e=new mi;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let o=this.from;o<this.to;o++)e=this._maps[o].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,o){let r=0;for(let i=this.from;i<this.to;i++){let l=this._maps[i],a=l.mapResult(e,n);if(a.recover!=null){let c=this.getMirror(i);if(c!=null&&c>i&&c<this.to){i=c,e=this._maps[c].recover(a.recover);continue}}r|=a.delInfo,e=a.pos}return o?e:new yc(e,r,null)}}const Cc=Object.create(null);class ut{getMap(){return Ot.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=Cc[n.stepType];if(!o)throw new RangeError(`No step type ${n.stepType} defined`);return o.fromJSON(e,n)}static jsonID(e,n){if(e in Cc)throw new RangeError("Duplicate use of step JSON ID "+e);return Cc[e]=n,n.prototype.jsonID=e,n}}class Ue{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ue(e,null)}static fail(e){return new Ue(null,e)}static fromReplace(e,n,o,r){try{return Ue.ok(e.replace(n,o,r))}catch(i){if(i instanceof Os)return Ue.fail(i.message);throw i}}}function wc(t,e,n){let o=[];for(let r=0;r<t.childCount;r++){let i=t.child(r);i.content.size&&(i=i.copy(wc(i.content,e,i