diff --git a/django_prose_editor/static/django_prose_editor/editor.css b/django_prose_editor/static/django_prose_editor/editor.css index 0b72bda..752d763 100644 --- a/django_prose_editor/static/django_prose_editor/editor.css +++ b/django_prose_editor/static/django_prose_editor/editor.css @@ -1 +1 @@ -.ProseMirror{color:#000!important;padding:1rem 1.75rem;outline:none!important;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;margin:0!important}.ProseMirror *{color:#000!important}.ProseMirror p{font-size:16px!important}.ProseMirror h1{display:block!important;font-size:2em!important;margin-block-start:.67em!important;margin-block-end:.67em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important}.ProseMirror h2{padding:0;display:block!important;font-size:1.5em!important;margin-block-start:.83em!important;margin-block-end:.83em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;background:white!important}.ProseMirror h3{display:block!important;font-size:1.17em!important;margin-block-start:1em!important;margin-block-end:1em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;padding:0!important}.ProseMirror>*+*{margin-top:.75em!important}.ProseMirror p.is-editor-empty:first-child:before{content:attr(data-placeholder);float:left;color:#a8a8a8;pointer-events:none;height:0}.ProseMirror ol{padding-left:0!important;list-style-type:decimal!important}.ProseMirror ol li::marker{font-size:16px!important}.ProseMirror ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-latin!important}.ProseMirror ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-roman!important}.ProseMirror ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-latin!important}.ProseMirror ol>li>ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-roman!important}.ProseMirror ul{list-style-type:disc!important;margin-block-start:0!important;margin-block-end:0!important;margin-inline-start:0px!important;margin-inline-end:0px!important}.ProseMirror ul li{list-style:disc!important}.ProseMirror ul>li>ul{padding-left:10px!important;margin-left:10px!important;list-style-type:disc!important}.ProseMirror{margin:1rem 0}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;text-transform:none;padding:0}.ProseMirror pre{background:#0d0d0d!important;color:#fff!important;font-family:JetBrainsMono,monospace!important;padding:.75rem 1rem!important;border-radius:.5rem!important}.ProseMirror pre code{color:#fff!important;padding:0!important;background:none!important;font-size:.8rem!important}.ProseMirror img{max-width:100%;height:auto}.ProseMirror blockquote{padding-left:1rem;border-left:2px solid rgba(13,13,13,.1)}.ProseMirror hr{border:none;border-top:2px solid rgba(13,13,13,.1);margin:2rem 0}.ProseMirror a{text-decoration:underline}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:0;overflow:hidden}.ProseMirror table td,.ProseMirror table th,.ProseMirror table[show_borders=false]:hover td,.ProseMirror table[show_borders=false]:hover th{min-width:1em;border:2px solid #ced4da;padding:3px 5px;vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror table[show_borders=false] td,.ProseMirror table[show_borders=false] th{border:none;box-sizing:border-box}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{font-weight:700;text-align:left;background-color:#f1f3f5}.ProseMirror tr{background-color:#fff!important}.ProseMirror table .selectedCell:after{z-index:2;position:absolute;content:"";inset:0;background:rgba(200,200,255,.4);pointer-events:none}.ProseMirror table .column-resize-handle{position:absolute;right:-2px;top:0;bottom:-2px;width:4px;background-color:#adf;pointer-events:none}.tableWrapper{overflow-x:auto}.resize-cursor{cursor:ew-resize;cursor:col-resize}:root{--tw-editor-font-size: 16px;--tw-menubar-font-size: 16px}.ProseMirror{padding:4px;border:1px solid var(--border-color);border-radius:4px}.tw-editor *,.tw-editor *:before,.tw-editor *:after{box-sizing:inherit}.tw-editor{font-size:var(--tw-editor-font-size);box-sizing:border-box;position:relative;flex-grow:1}.tw-editor+textarea,.tw-hide{display:none}.tw-sr-only{border:0!important;clip:rect(1px,1px,1px,1px)!important;-webkit-clip-path:inset(50%)!important;clip-path:inset(50%)!important;height:1px!important;overflow:hidden!important;margin:-1px!important;padding:0!important;position:absolute!important;width:1px!important;white-space:nowrap!important}.tw-menubar{font-size:var(--tw-menubar-font-size);position:sticky;top:var(--tw-menubar-top);background:white;z-index:10;display:inline-flex;flex-wrap:wrap;box-shadow:var(--tw-box-shadow);border-radius:.5em;margin-bottom:.25rem}.tw-menubar__group{display:flex;gap:2px}.tw-menubar__group:not(:last-child):after{content:"";background-color:var(--tw-secondary-color);width:2px;height:2em;margin:.25em}.tw-menubar__button{color:var(--tw-primary-color);cursor:pointer;padding:.25em;min-width:2em;transition:all .25s;border:1px solid;border-radius:.25em;text-align:center}.tw-menubar__button:hover{background-color:var(--tw-secondary-color);filter:brightness(110%)}.tw-menubar__button.active{background-color:var(--tw-secondary-color)}.tw-menubar__button.disabled{background-color:#acc0cc;filter:brightness(100%);cursor:not-allowed;opacity:.3}.tw-menubar__button--history-undo,.tw-menubar__button--history-redo{background-image:url(./history-arrow-HHQ2TDW5.svg);background-repeat:no-repeat;background-size:1.25em;background-position:center}.tw-menubar__button--history-redo{transform:scaleX(-1)}.ProseMirror{position:relative}.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{-webkit-user-select:text;-moz-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important} +.ProseMirror{color:#000!important;padding:1rem 1.75rem;outline:none!important;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif;margin:0!important}.ProseMirror *{color:#000!important}.ProseMirror p{font-size:16px!important}.ProseMirror h1{display:block!important;font-size:2em!important;margin-block-start:.67em!important;margin-block-end:.67em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important}.ProseMirror h2{padding:0;display:block!important;font-size:1.5em!important;margin-block-start:.83em!important;margin-block-end:.83em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;background:white!important}.ProseMirror h3{display:block!important;font-size:1.17em!important;margin-block-start:1em!important;margin-block-end:1em!important;margin-inline-start:0px!important;margin-inline-end:0px!important;font-weight:700!important;padding:0!important}.ProseMirror>*+*{margin-top:.75em!important}.ProseMirror p.is-editor-empty:first-child:before{content:attr(data-placeholder);float:left;color:#a8a8a8;pointer-events:none;height:0}.ProseMirror ol{padding-left:0!important;list-style-type:decimal!important}.ProseMirror ol li::marker{font-size:16px!important}.ProseMirror ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-latin!important}.ProseMirror ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:lower-roman!important}.ProseMirror ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-latin!important}.ProseMirror ol>li>ol>li>ol>li>ol>li>ol{padding-left:10px!important;margin-left:10px!important;list-style-type:upper-roman!important}.ProseMirror ul{list-style-type:disc!important;margin-block-start:0!important;margin-block-end:0!important;margin-inline-start:0px!important;margin-inline-end:0px!important}.ProseMirror ul li{list-style:disc!important}.ProseMirror ul>li>ul{padding-left:10px!important;margin-left:10px!important;list-style-type:disc!important}.ProseMirror{margin:1rem 0}.ProseMirror h1,.ProseMirror h2,.ProseMirror h3,.ProseMirror h4,.ProseMirror h5,.ProseMirror h6{line-height:1.1;text-transform:none;padding:0}.ProseMirror pre{background:#0d0d0d!important;color:#fff!important;font-family:JetBrainsMono,monospace!important;padding:.75rem 1rem!important;border-radius:.5rem!important}.ProseMirror pre code{color:#fff!important;padding:0!important;background:none!important;font-size:.8rem!important}.ProseMirror img{max-width:100%;height:auto}.ProseMirror blockquote{padding-left:1rem;border-left:2px solid rgba(13,13,13,.1)}.ProseMirror hr{border:none;border-top:2px solid rgba(13,13,13,.1);margin:2rem 0}.ProseMirror a{text-decoration:underline}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:0;overflow:hidden}.ProseMirror table td,.ProseMirror table th,.ProseMirror table[show_borders=false]:hover td,.ProseMirror table[show_borders=false]:hover th{min-width:1em;border:2px solid #ced4da;padding:3px 5px;vertical-align:top;box-sizing:border-box;position:relative}.ProseMirror table[show_borders=false] td,.ProseMirror table[show_borders=false] th{border:none;box-sizing:border-box}.ProseMirror table td>*,.ProseMirror table th>*{margin-bottom:0}.ProseMirror table th{font-weight:700;text-align:left;background-color:#f1f3f5}.ProseMirror tr{background-color:#fff!important}.ProseMirror table .selectedCell:after{z-index:2;position:absolute;content:"";inset:0;background:rgba(200,200,255,.4);pointer-events:none}.ProseMirror table .column-resize-handle{position:absolute;right:-2px;top:0;bottom:-2px;width:4px;background-color:#adf;pointer-events:none}.tableWrapper{overflow-x:auto}.resize-cursor{cursor:ew-resize;cursor:col-resize}:root{--prose-editor-font-size: 14px;--prose-menubar-font-size: 14px}.ProseMirror{padding:0 6px;border:1px solid var(--border-color);border-radius:4px}.prose-editor *,.prose-editor *:before,.prose-editor *:after{box-sizing:inherit}.prose-editor{font-size:var(--prose-editor-font-size);box-sizing:border-box;position:relative;flex-grow:1}.prose-editor+textarea{display:none}.prose-menubar{font-size:var(--prose-menubar-font-size);background:white;display:inline-flex;gap:8px;flex-wrap:wrap;margin-bottom:2px}.prose-menubar__group{display:flex;gap:2px}.prose-menubar__button{cursor:pointer;padding:0 .25em;min-width:2em;transition:all .25s;border:1px solid;border-radius:.25em;text-align:center}.prose-menubar__button:hover{filter:brightness(110%)}.prose-menubar__button.active{background-color:var(--primary)}.prose-menubar__button.disabled{background-color:#acc0cc;filter:brightness(100%);cursor:not-allowed;opacity:.3}.prose-menubar__button--history-undo,.prose-menubar__button--history-redo{background-image:url(./history-arrow-HHQ2TDW5.svg);background-repeat:no-repeat;background-size:1.25em;background-position:center}.prose-menubar__button--history-redo{transform:scaleX(-1)}.ProseMirror{position:relative}.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{-webkit-user-select:text;-moz-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important} diff --git a/django_prose_editor/static/django_prose_editor/editor.js b/django_prose_editor/static/django_prose_editor/editor.js index fc0d1b8..ddca1a3 100644 --- a/django_prose_editor/static/django_prose_editor/editor.js +++ b/django_prose_editor/static/django_prose_editor/editor.js @@ -6,7 +6,7 @@ var DjangoProseEditor=(()=>{var Ht=Object.defineProperty;var Ao=Object.getOwnPro `),c&&p==u.nodeValue.length)for(let d=u,m;d;d=d.parentNode){if(m=d.nextSibling){m.nodeName=="BR"&&(l=a={node:m.parentNode,offset:J(m)+1});break}let y=d.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let d=u.childNodes[p-1];c=d&&(d.nodeName=="BR"||d.contentEditable=="false")}}if(ie&&f.focusNode&&f.focusNode!=a.node&&f.focusNode.nodeType==1){let u=f.focusNode.childNodes[f.focusOffset];u&&u.contentEditable=="false"&&(i=!0)}if(!(i||c&&q)&&tt(l.node,l.offset,f.anchorNode,f.anchorOffset)&&tt(a.node,a.offset,f.focusNode,f.focusOffset))return;let h=!1;if((f.extend||e==t)&&!c){f.collapse(l.node,l.offset);try{e!=t&&f.extend(a.node,a.offset),h=!0}catch(u){}}if(!h){if(e>t){let p=l;l=a,a=p}let u=document.createRange();u.setEnd(a.node,a.offset),u.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(u)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i=n:en){let l=n+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==n||t==o?Xe:Wi,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ge:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Xe:ge}n=o}this.dirty=Xe}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Xe:Wi;t.dirty{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Z&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},rr=class extends nt{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ne=class extends nt{constructor(e,t,n,i){super(e,[],n,i),this.mark=t}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=j.renderSpec(document,t.type.spec.toDOM(t,n))),new Ne(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&ge||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ge&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Z){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(s=ar(s,0,e,n));for(let l=0;l{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,i),c=f&&f.dom,h=f&&f.contentDOM;if(t.isText){if(!c)c=document.createTextNode(t.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:h}=j.renderSpec(document,t.type.spec.toDOM(t)));!h&&!t.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return c=Ms(c,n,t),f?a=new ir(e,t,n,i,c,h||null,u,f,s,o+1):t.isText?new gt(e,t,n,i,c,u,s):new de(e,t,n,i,c,h||null,u,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>g.empty)}return e}matchesNode(e,t,n){return this.dirty==Z&&e.eq(this.node)&&or(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new lr(this,o&&o.node,e);ba(this.node,this.innerDeco,(f,c,h)=>{f.spec.marks?a.syncToMarks(f.spec.marks,n,e):f.type.side>=0&&!h&&a.syncToMarks(c==this.node.childCount?C.none:this.node.child(c).marks,n,e),a.placeWidget(f,e,i)},(f,c,h,u)=>{a.syncToMarks(f.marks,n,e);let p;a.findNodeMatch(f,c,h,u)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(f,c,h,p,e)||a.updateNextNode(f,c,h,e,u,i)||a.addNode(f,c,h,e,i),i+=f.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Xe)&&(o&&this.protectLocalComposition(e,o),xs(this.contentDOM,this.children,e),mt&&ka(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof O)||nt+this.node.content.size)return null;let s=e.domSelectionRange(),o=xa(s.focusNode,s.focusOffset);if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let l=o.nodeValue,a=Sa(this.node.content,l,n-t,i-t);return a<0?null:{node:o,pos:a,text:l}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new rr(this,s,t,i);e.input.compositionNodes.push(o),this.children=ar(this.children,n,n+i.length,e,o)}update(e,t,n,i){return this.dirty==ge||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Z}updateOuterDeco(e){if(or(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Ss(this.dom,this.nodeDOM,sr(this.outerDeco,this.node,t),sr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}};function qi(r,e,t,n,i){Ms(n,e,r);let s=new de(void 0,r,e,t,n,n,n,i,0);return s.contentDOM&&s.updateChildren(i,0),s}var gt=class extends de{constructor(e,t,n,i,s,o,l){super(e,t,n,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==ge||this.dirty!=Z&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Z||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Z,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new gt(this.parent,i,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ge)}get domAtom(){return!1}},cn=class extends nt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Z&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},ir=class extends de{constructor(e,t,n,i,s,o,l,a,f,c){super(e,t,n,i,s,o,l,f,c),this.spec=a}update(e,t,n,i){if(this.dirty==ge)return!1;if(this.spec.update){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function xs(r,e,t){let n=r.firstChild,i=!1;for(let s=0;s>1,o=Math.min(s,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Ne.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(n){let f=t.children[n-1];if(f instanceof Ne)t=f,n=f.children.length;else{l=f,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(!!a){if(a!=r.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function ya(r,e){return r.type.side-e.type.side}function ba(r,e,t,n){let i=e.locals(r),s=0;if(i.length==0){for(let f=0;fs;)l.push(i[o++]);let d=s+u.nodeSize;if(u.isText){let y=d;o!y.inline):l.slice();n(u,m,e.forChild(s,u),p),s=d}}function ka(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function xa(r,e){for(;;){if(r.nodeType==3)return r;if(r.nodeType==1&&e>0){if(r.childNodes.length>e&&r.childNodes[e].nodeType==3)return r.childNodes[e];r=r.childNodes[e-1],e=he(r)}else if(r.nodeType==1&&e=t){if(s>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let f=l=0&&f+e.length+l>=t)return l+f;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function ar(r,e,t,n,i){let s=[];for(let o=0,l=0;o=t||c<=e?s.push(a):(ft&&s.push(a.slice(t-f,a.size,n)))}return s}function kr(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=n.resolve(o),a,f;if(gn(t)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&x.isSelectable(c)&&i.parent&&!(c.isInline&&_l(t.focusNode,t.focusOffset,i.dom))){let h=i.posBefore;f=new x(o==h?l:n.resolve(h))}}else{let c=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null;a=n.resolve(c)}if(!f){let c=e=="pointer"||r.state.selection.head{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!Cs(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ca(r){let e=r.domSelection(),t=document.createRange(),n=r.cursorWrapper.dom,i=n.nodeName=="IMG";i?t.setEnd(n.parentNode,J(n)+1):t.setEnd(n,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!r.state.selection.visible&&U&&Be<=11&&(n.disabled=!0,n.disabled=!1)}function Os(r,e){if(e instanceof x){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(Ui(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else Ui(r)}function Ui(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function xr(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||O.between(e,t,n)}function _i(r){return r.editable&&!r.hasFocus()?!1:ws(r)}function ws(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Oa(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return tt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function fr(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),s=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return s&&S.findFrom(s,e)}function Pe(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function Yi(r,e,t){let n=r.state.selection;if(n instanceof O)if(t.indexOf("s")>-1){let{$head:i}=n,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=r.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Pe(r,new O(n.$anchor,o))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=fr(r.state,e);return i&&i instanceof x?Pe(r,i):!1}else if(!(Q&&t.indexOf("m")>-1)){let i=n.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=r.docView.descAt(l))&&!o.contentDOM?x.isSelectable(s)?Pe(r,new x(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):Lt?Pe(r,new O(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(n instanceof x&&n.node.isInline)return Pe(r,new O(e>0?n.$to:n.$from));{let i=fr(r.state,e);return i?Pe(r,i):!1}}}function hn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function vt(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function ut(r,e){return e<0?wa(r):Na(r)}function wa(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(ie&&t.nodeType==1&&n0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(vt(l,-1))i=t,s=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(Ns(t))break;{let l=t.previousSibling;for(;l&&vt(l,-1);)i=t.parentNode,s=J(l),l=l.previousSibling;if(l)t=l,n=hn(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?cr(r,t,n):i&&cr(r,i,s)}function Na(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=hn(t),s,o;for(;;)if(n{r.state==i&&we(r)},50)}function Gi(r,e){let t=r.state.doc.resolve(e);if(!(V||Ql)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o1)return s.lefti.top&&o1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function Xi(r,e,t){let n=r.state.selection;if(n instanceof O&&!n.empty||t.indexOf("s")>-1||Q&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=fr(r.state,e);if(o&&o instanceof x)return Pe(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof P?S.near(o,e):S.findFrom(o,e);return l?Pe(r,l):!1}return!1}function Qi(r,e){if(!(r.state.selection instanceof O))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=r.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),r.dispatch(o),!0}return!1}function Zi(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function Ea(r){if(!q||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Zi(r,n,"true"),setTimeout(()=>Zi(r,n,"false"),20)}return!1}function Ia(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function Aa(r,e){let t=e.keyCode,n=Ia(e);if(t==8||Q&&t==72&&n=="c")return Qi(r,-1)||ut(r,-1);if(t==46&&!e.shiftKey||Q&&t==68&&n=="c")return Qi(r,1)||ut(r,1);if(t==13||t==27)return!0;if(t==37||Q&&t==66&&n=="c"){let i=t==37?Gi(r,r.state.selection.from)=="ltr"?-1:1:-1;return Yi(r,i,n)||ut(r,i)}else if(t==39||Q&&t==70&&n=="c"){let i=t==39?Gi(r,r.state.selection.from)=="ltr"?1:-1:1;return Yi(r,i,n)||ut(r,i)}else{if(t==38||Q&&t==80&&n=="c")return Xi(r,-1,n)||ut(r,-1);if(t==40||Q&&t==78&&n=="c")return Ea(r)||Xi(r,1,n)||ut(r,1);if(n==(Q?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ts(r,e){r.someProp("transformCopied",p=>{e=p(e,r)});let t=[],{content:n,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,s--;let p=n.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),n=p.content}let o=r.someProp("clipboardSerializer")||j.fromSchema(r.state.schema),l=vs(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let f=a.firstChild,c,h=0;for(;f&&f.nodeType==1&&(c=Rs[f.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let d=l.createElement(c[p]);for(;a.firstChild;)d.appendChild(a.firstChild);a.appendChild(d),h++}f=a.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(t)}`);let u=r.someProp("clipboardTextSerializer",p=>p(e,r))||e.content.textBetween(0,e.content.size,` `);return{dom:a,text:u}}function Ds(r,e,t,n,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(n||s||!t);if(a){if(r.someProp("transformPastedText",u=>{e=u(e,s||n,r)}),s)return e?new b(g.from(r.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):b.empty;let h=r.someProp("clipboardTextParser",u=>u(e,i,n,r));if(h)l=h;else{let u=i.marks(),{schema:p}=r.state,d=j.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let y=o.appendChild(document.createElement("p"));m&&y.appendChild(d.serializeNode(p.text(m,u)))})}}else r.someProp("transformPastedHTML",h=>{t=h(t,r)}),o=Pa(t),Lt&&za(o);let f=o&&o.querySelector("[data-pm-slice]"),c=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let h=+c[3];h>0;h--){let u=o.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||ae.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Ra.test(u.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Ba(es(l,+c[1],+c[2]),c[4]);else if(l=b.maxOpen(va(l.content,i),!0),l.openStart||l.openEnd){let h=0,u=0;for(let p=l.content.firstChild;h{l=h(l,r)}),l}var Ra=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function va(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),f;if(!a)return o=null;if(f=o.length&&s.length&&Is(a,s,l,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=As(o[o.length-1],s.length));let c=Es(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return g.from(o)}return r}function Es(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,g.from(r));return r}function Is(r,e,t,n,i){if(i1&&(s=0),i=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(g.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function es(r,e,t){return e]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=vs().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&Rs[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"").reverse().join("")),t.innerHTML=r,i)for(let s=0;s=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=g.from(a.create(n[l+1],i)),s++,o++}return new b(i,s,o)}var K={},$={},Fa={touchstart:!0,touchmove:!0},ur=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Va(r){for(let e in K){let t=K[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Ja(r,n)&&!Sr(r,n)&&(r.editable||!(n.type in $))&&t(r,n)},Fa[e]?{passive:!0}:void 0)}q&&r.dom.addEventListener("input",()=>null),dr(r)}function ze(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function La(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function dr(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Sr(r,n))})}function Sr(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Ja(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Wa(r,e){!Sr(r,e)&&K[e.type]&&(r.editable||!(e.type in $))&&K[e.type](r,e)}$.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!zs(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(re&&V&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),mt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,Ge(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||Aa(r,t)?t.preventDefault():ze(r,"key")};$.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};$.keypress=(r,e)=>{let t=e;if(zs(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||Q&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof O)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i))&&r.dispatch(r.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function yn(r){return{left:r.clientX,top:r.clientY}}function qa(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Mr(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,l=>o>s.depth?l(r,t,s.nodeAfter,s.before(o),i,!0):l(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function pt(r,e,t){r.focused||r.focus();let n=r.state.tr.setSelection(e);t=="pointer"&&n.setMeta("pointer",!0),r.dispatch(n)}function Ka(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&x.isSelectable(n)?(pt(r,new x(t),"pointer"),!0):!1}function $a(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof x&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(x.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(pt(r,x.create(r.state.doc,i),"pointer"),!0):!1}function ja(r,e,t,n,i){return Mr(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?$a(r,t):Ka(r,t))}function Ha(r,e,t,n){return Mr(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function Ua(r,e,t,n){return Mr(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||_a(r,t,n)}function _a(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(pt(r,O.create(n,0,n.content.size),"pointer"),!0):!1;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)pt(r,O.create(n,l+1,l+1+o.content.size),"pointer");else if(x.isSelectable(o))pt(r,x.create(n,l),"pointer");else continue;return!0}}function Cr(r){return un(r)}var Ps=Q?"metaKey":"ctrlKey";K.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Cr(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&qa(t,r.input.lastClick)&&!t[Ps]&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=r.posAtCoords(yn(t));!o||(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new pr(r,o,t,!!n)):(s=="doubleClick"?Ha:Ua)(r,o.pos,o.inside,t)?t.preventDefault():ze(r,"pointer"))};var pr=class{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Ps],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}let l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:f}=e.state;(n.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||f instanceof x&&f.from<=o&&f.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ie&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ze(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>we(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yn(e))),this.updateAllowDefault(e),this.allowDefault||!t?ze(this.view,"pointer"):ja(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||q&&this.mightDrag&&!this.mightDrag.node.isAtom||V&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(pt(this.view,S.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):ze(this.view,"pointer")}move(e){this.updateAllowDefault(e),ze(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};K.touchstart=r=>{r.input.lastTouch=Date.now(),Cr(r),ze(r,"pointer")};K.touchmove=r=>{r.input.lastTouch=Date.now(),ze(r,"pointer")};K.contextmenu=r=>Cr(r);function zs(r,e){return r.composing?!0:q&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}var Ya=re?5e3:-1;$.compositionstart=$.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),un(r,!0),r.markCursor=null;else if(un(r),ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){r.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}Bs(r,Ya)};$.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,Bs(r,20))};function Bs(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>un(r),e))}function Fs(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Ga());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Ga(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function un(r,e=!1){if(!(re&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),Fs(r),e||r.docView&&r.docView.dirty){let t=kr(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):r.updateState(r.state),!0}return!1}}function Xa(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}var zt=U&&Be<15||mt&&Zl<604;K.copy=$.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=zt?null:t.clipboardData,o=n.content(),{dom:l,text:a}=Ts(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Xa(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Qa(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Za(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?Bt(r,n.value,null,i,e):Bt(r,n.textContent,n.innerHTML,i,e)},50)}function Bt(r,e,t,n,i){let s=Ds(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||b.empty)))return!0;if(!s)return!1;let o=Qa(s),l=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Vs(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$.paste=(r,e)=>{let t=e;if(r.composing&&!re)return;let n=zt?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Bt(r,Vs(n),n.getData("text/html"),i,t)?t.preventDefault():Za(r,t)};var dn=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Ls=Q?"altKey":"ctrlKey";K.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords(yn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof x?i.to-1:i.to))){if(n&&n.mightDrag)o=x.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let c=r.docView.nearestDesc(t.target,!0);c&&c.node.type.spec.draggable&&c!=r.docView&&(o=x.create(r.state.doc,c.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:f}=Ts(r,l);t.dataTransfer.clearData(),t.dataTransfer.setData(zt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",zt||t.dataTransfer.setData("text/plain",f),r.dragging=new dn(l,!t[Ls],o)};K.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};$.dragover=$.dragenter=(r,e)=>e.preventDefault();$.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords(yn(t));if(!i)return;let s=r.state.doc.resolve(i.pos),o=n&&n.slice;o?r.someProp("transformPasted",d=>{o=d(o,r)}):o=Ds(r,Vs(t.dataTransfer),zt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&!t[Ls]);if(r.someProp("handleDrop",d=>d(r,t,o||b.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?nn(r.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let f=r.state.tr;if(l){let{node:d}=n;d?d.replace(f):f.deleteSelection()}let c=f.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=f.doc;if(h?f.replaceRangeWith(c,c,o.content.firstChild):f.replaceRange(c,c,o),f.doc.eq(u))return;let p=f.doc.resolve(c);if(h&&x.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))f.setSelection(new x(p));else{let d=f.mapping.map(a);f.mapping.maps[f.mapping.maps.length-1].forEach((m,y,k,I)=>d=I),f.setSelection(xr(r,p,f.doc.resolve(d)))}r.focus(),r.dispatch(f.setMeta("uiEvent","drop"))};K.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&we(r)},20))};K.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};K.beforeinput=(r,e)=>{if(V&&re&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,Ge(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in $)K[r]=$[r];function Ft(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}var yt=class{constructor(e,t){this.toDOM=e,this.spec=t||Ze,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new W(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof yt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ft(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},pe=class{constructor(e,t){this.attrs=e,this.spec=t||Ze}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new W(s,o,this)}valid(e,t){return t.from=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,i+l,s)}}map(e,t,n){return this==F||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Ze)}mapInner(e,t,n,i,s){let o;for(let l=0;l{let f=a+n,c;if(!!(c=Ws(t,l,f))){for(i||(i=this.children.slice());sl&&h.to=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;ls&&a.type instanceof pe){let f=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;fi.map(e,t,Ze));return ue.from(n)}forChild(e,t){if(t.isLeaf)return E.empty;let n=[];for(let i=0;it instanceof E)?e:e.reduce((t,n)=>t.concat(n instanceof E?n:n.members),[]))}}};function ef(r,e,t,n,i,s,o){let l=r.slice();for(let f=0,c=s;f{let y=m-d-(p-u);for(let k=0;kI+c-h)continue;let se=l[k]+c-h;p>=se?l[k+1]=u<=se?-2:-1:u>=c&&y&&(l[k]+=y,l[k+1]+=y)}h+=y}),c=t.maps[f].map(c,-1)}let a=!1;for(let f=0;f=n.content.size){a=!0;continue}let u=t.map(r[f+1]+s,-1),p=u-i,{index:d,offset:m}=n.content.findIndex(h),y=n.maybeChild(d);if(y&&m==h&&m+y.nodeSize==p){let k=l[f+2].mapInner(t,y,c+1,r[f]+s+1,o);k!=F?(l[f]=h,l[f+1]=p,l[f+2]=k):(l[f+1]=-2,a=!0)}else a=!0}if(a){let f=tf(l,r,e,t,i,s,o),c=pn(f,n,0,o);e=c.local;for(let h=0;ht&&o.to{let f=Ws(r,l,a+t);if(f){s=!0;let c=pn(f,l,t+a+1,n);c!=F&&i.push(a,a+l.nodeSize,c)}});let o=Js(s?qs(r):r,-t).sort(et);for(let l=0;l0;)e++;r.splice(e,0,t)}function Qn(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=F&&e.push(n)}),r.cursorWrapper&&e.push(E.create(r.state.doc,[r.cursorWrapper.deco])),ue.from(e)}var nf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rf=U&&Be<=11,mr=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},gr=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),rf&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,nf)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(!!_i(this.view)){if(this.suppressingSelectionUpdates)return we(this.view);if(U&&Be<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&tt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let s=e.focusNode;s;s=Pt(s))t.add(s);for(let s=e.anchorNode;s;s=Pt(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&_i(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c1){let c=a.filter(h=>h.nodeName=="BR");if(c.length==2){let h=c[0],u=c[1];h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}}let f=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(s>-1&&(e.docView.markDirty(s,o),sf(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||we(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;ci;y--){let k=n.childNodes[y-1],I=k.pmViewDesc;if(k.nodeName=="BR"&&!I){s=y;break}if(!I||I.size)break}let h=r.state.doc,u=r.someProp("domParser")||ae.fromSchema(r.state.schema),p=h.resolve(o),d=null,m=u.parse(n,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:af,context:p});if(f&&f[0].pos!=null){let y=f[0].pos,k=f[1]&&f[1].pos;k==null&&(k=y),d={anchor:y+o,head:k+o}}return{doc:m,sel:d,from:o,to:l}}function af(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(q&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||q&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}var ff=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function cf(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let M=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,Ee=kr(r,M);if(Ee&&!r.state.selection.eq(Ee)){if(V&&re&&r.input.lastKeyCode===13&&Date.now()-100Io(r,Ge(13,"Enter"))))return;let jt=r.state.tr.setSelection(Ee);M=="pointer"?jt.setMeta("pointer",!0):M=="key"&&jt.scrollIntoView(),s&&jt.setMeta("composition",s),r.dispatch(jt)}return}let o=r.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,f=lf(r,e,t),c=r.state.doc,h=c.slice(f.from,f.to),u,p;r.input.lastKeyCode===8&&Date.now()-100Date.now()-225||re)&&i.some(M=>M.nodeType==1&&!ff.test(M.nodeName))&&(!d||d.endA>=d.endB)&&r.someProp("handleKeyDown",M=>M(r,Ge(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!d)if(n&&a instanceof O&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))d={start:a.from,endA:a.to,endB:a.to};else{if(f.sel){let M=ss(r,r.state.doc,f.sel);if(M&&!M.eq(r.state.selection)){let Ee=r.state.tr.setSelection(M);s&&Ee.setMeta("composition",s),r.dispatch(Ee)}}return}if(V&&r.cursorWrapper&&f.sel&&f.sel.anchor==r.cursorWrapper.deco.from&&f.sel.head==f.sel.anchor){let M=d.endB-d.start;f.sel={anchor:f.sel.anchor+M,head:f.sel.anchor+M}}r.input.domChangeCount++,r.state.selection.fromr.state.selection.from&&d.start<=r.state.selection.from+2&&r.state.selection.from>=f.from?d.start=r.state.selection.from:d.endA=r.state.selection.to-2&&r.state.selection.to<=f.to&&(d.endB+=r.state.selection.to-d.endA,d.endA=r.state.selection.to)),U&&Be<=11&&d.endB==d.start+1&&d.endA==d.start&&d.start>f.from&&f.doc.textBetween(d.start-f.from-1,d.start-f.from+1)==" \xA0"&&(d.start--,d.endA--,d.endB--);let m=f.doc.resolveNoCache(d.start-f.from),y=f.doc.resolveNoCache(d.endB-f.from),k=c.resolve(d.start),I=m.sameParent(y)&&m.parent.inlineContent&&k.end()>=d.endA,se;if((mt&&r.input.lastIOSEnter>Date.now()-225&&(!I||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!I&&m.posM(r,Ge(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>d.start&&uf(c,d.start,d.endA,m,y)&&r.someProp("handleKeyDown",M=>M(r,Ge(8,"Backspace")))){re&&V&&r.domObserver.suppressSelectionUpdates();return}V&&re&&d.endB==d.start&&(r.input.lastAndroidDelete=Date.now()),re&&!I&&m.start()!=y.start()&&y.parentOffset==0&&m.depth==y.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==d.endA&&(d.endB-=2,y=f.doc.resolveNoCache(d.endB-f.from),setTimeout(()=>{r.someProp("handleKeyDown",function(M){return M(r,Ge(13,"Enter"))})},20));let oe=d.start,te=d.endA,w,G,le;if(I){if(m.pos==y.pos)U&&Be<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>we(r),20)),w=r.state.tr.delete(oe,te),G=c.resolve(d.start).marksAcross(c.resolve(d.endA));else if(d.endA==d.endB&&(le=hf(m.parent.content.cut(m.parentOffset,y.parentOffset),k.parent.content.cut(k.parentOffset,d.endA-k.start()))))w=r.state.tr,le.type=="add"?w.addMark(oe,te,le.mark):w.removeMark(oe,te,le.mark);else if(m.parent.child(m.index()).isText&&m.index()==y.index()-(y.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,y.parentOffset);if(r.someProp("handleTextInput",Ee=>Ee(r,oe,te,M)))return;w=r.state.tr.insertText(M,oe,te)}}if(w||(w=r.state.tr.replace(oe,te,f.doc.slice(d.start-f.from,d.endB-f.from))),f.sel){let M=ss(r,w.doc,f.sel);M&&!(V&&re&&r.composing&&M.empty&&(d.start!=d.endB||r.input.lastAndroidDeletee.content.size?null:xr(r,e.resolve(t.anchor),e.resolve(t.head))}function hf(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let c=0;cc.mark(l.addToSet(c.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let f=[];for(let c=0;ct||Zn(o,!0,!1)0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function df(r,e,t,n,i){let s=r.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,s&&s=l?s-n:0;s-=a,s&&s=56320&&e<=57343&&t>=55296&&t<=56319}var mn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ur,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(us),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=cs(this),fs(this),this.nodeViews=hs(this),this.docView=qi(this.state.doc,as(this),Qn(this),this.dom,this),this.domObserver=new gr(this,(n,i,s,o)=>cf(this,n,i,s,o)),this.domObserver.start(),Va(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&dr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(us),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Fs(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=hs(this);mf(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&dr(this),this.editable=cs(this),fs(this);let a=Qn(this),f=as(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,f,a);(h||!e.selection.eq(i.selection))&&(o=!0);let u=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&na(this);if(o){this.domObserver.stop();let p=h&&(U||V)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&pf(i.selection,e.selection);if(h){let d=V?this.trackWrites=this.domSelectionRange().focusNode:null;(s||!this.docView.update(e.doc,f,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=qi(e.doc,f,a,this.dom,this)),d&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Oa(this))?we(this,p):(Os(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),((n=this.dragging)===null||n===void 0?void 0:n.node)&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&ra(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof x){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Bi(this,t.getBoundingClientRect(),e)}else Bi(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new dn(e.slice,e.move,i<0?void 0:x.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;ot.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return fa(this,e)}coordsAtPos(e,t=1){return bs(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return pa(this,t||this.state,e)}pasteHTML(e,t){return Bt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Bt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){!this.docView||(La(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Wa(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return q&&this.root.nodeType===11&&Yl(this.dom.ownerDocument)==this.dom?of(this):this.domSelection()}domSelection(){return this.root.getSelection()}};function as(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[W.node(0,r.state.doc.content.size,e)]}function fs(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:W.widget(r.state.selection.head,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function cs(r){return!r.someProp("editable",e=>e(r.state)===!1)}function pf(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function hs(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function mf(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function us(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var N=class extends S{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return N.valid(n)?new N(n):S.near(n)}content(){return b.empty}eq(e){return e instanceof N&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new N(e.resolve(t.pos))}getBookmark(){return new Jt(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!gf(e)||!yf(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&N.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(N.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!x.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),n=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(N.valid(l))return l}return null}}};N.prototype.visible=!1;N.findFrom=N.findGapCursorFrom;S.jsonID("gapcursor",N);var Jt=class{constructor(e){this.pos=e}map(e){return new Jt(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return N.valid(t)?new N(t):S.near(t)}};function gf(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function yf(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Ks(){return new H({props:{decorations:Sf,createSelectionBetween(r,e,t){return e.pos==t.pos&&N.valid(t)?new N(t):null},handleClick:kf,handleKeyDown:bf,handleDOMEvents:{beforeinput:xf}}})}var bf=Yn({ArrowLeft:bn("horiz",-1),ArrowRight:bn("horiz",1),ArrowUp:bn("vert",-1),ArrowDown:bn("vert",1)});function bn(r,e){let t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,s){let o=n.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof O){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let f=N.findGapCursorFrom(l,e,a);return f?(i&&i(n.tr.setSelection(new N(f))),!0):!1}}function kf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!N.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&x.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new N(n))),!0)}function xf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof N))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=g.empty;for(let o=n.length-1;o>=0;o--)i=g.from(n[o].createAndFill(null,i));let s=r.state.tr.replace(t.pos,t.pos,new b(i,0,0));return s.setSelection(O.near(s.doc.resolve(t.pos+1))),r.dispatch(s),!1}function Sf(r){if(!(r.selection instanceof N))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",E.create(r.doc,[W.widget(r.selection.head,e,{key:"gapcursor"})])}var kn=200,z=function(){};z.prototype.append=function(e){return e.length?(e=z.from(e),!this.length&&e||e.length=t?z.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};z.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};z.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};z.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,n),i};z.from=function(e){return e instanceof z?e:e&&e.length?new $s(e):z.empty};var $s=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=kn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=kn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(z);z.empty=new $s([]);var Mf=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return nl&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(s,l)-l,o+l)===!1||s=s?this.right.slice(n-s,i-s):this.left.slice(n,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(z),wr=z;var Cf=500,Y=class{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,s;t&&(i=this.remapping(n,this.items.length),s=i.maps.length);let o=e.tr,l,a,f=[],c=[];return this.items.forEach((h,u)=>{if(!h.step){i||(i=this.remapping(n,u+1),s=i.maps.length),s--,c.push(h);return}if(i){c.push(new ee(h.map));let p=h.step.map(i.slice(s)),d;p&&o.maybeStep(p).doc&&(d=o.mapping.maps[o.mapping.maps.length-1],f.push(new ee(d,void 0,void 0,f.length+c.length))),s--,d&&i.appendMap(d,s)}else o.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(s)):h.selection,a=new Y(this.items.slice(0,n).append(c.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,n,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let c=0;cwf&&(l=Of(l,f),o-=f),new Y(l.append(s),o)}remapping(e,t){let n=new ke;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,o)},e,t),n}addMaps(e){return this.eventCount==0?this:new Y(this.items.append(e.map(t=>new ee(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},i);let a=t;this.items.forEach(u=>{let p=s.getMirror(--a);if(p==null)return;o=Math.min(o,p);let d=s.maps[p];if(u.step){let m=e.steps[p].invert(e.docs[p]),y=u.selection&&u.selection.map(s.slice(a+1,p));y&&l++,n.push(new ee(d,m,y))}else n.push(new ee(d))},i);let f=[];for(let u=t;uCf&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(n)),f=a&&a.getMap();if(n--,f&&t.appendMap(f,n),a){let c=o.selection&&o.selection.map(t.slice(n));c&&s++;let h=new ee(f.invert(),a,c),u,p=i.length-1;(u=i.length&&i[p].merge(h))?i[p]=u:i.push(h)}}else o.map&&n--},this.items.length,0),new Y(wr.from(i.reverse()),s)}};Y.empty=new Y(wr.empty,0);function Of(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}var ee=class{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new ee(t.getMap().invert(),t,this.selection)}}},ye=class{constructor(e,t,n,i,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=s}},wf=20;function Nf(r,e,t,n){let i=t.getMeta(Ve),s;if(i)return i.historyState;t.getMeta(Df)&&(r=new ye(r.done,r.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(o&&o.getMeta(Ve))return o.getMeta(Ve).redo?new ye(r.done.addTransform(t,void 0,n,xn(e)),r.undone,js(t.mapping.maps[t.steps.length-1]),r.prevTime,r.prevComposition):new ye(r.done,r.undone.addTransform(t,void 0,n,xn(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!o&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!Tf(t,r.prevRanges)),f=o?Nr(r.prevRanges,t.mapping):js(t.mapping.maps[t.steps.length-1]);return new ye(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,xn(e)),Y.empty,f,t.time,l==null?r.prevComposition:l)}else return(s=t.getMeta("rebased"))?new ye(r.done.rebased(t,s),r.undone.rebased(t,s),Nr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new ye(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Nr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function Tf(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let s=0;s=e[s]&&(t=!0)}),t}function js(r){let e=[];return r.forEach((t,n,i,s)=>e.push(i,s)),e}function Nr(r,e){if(!r)return null;let t=[];for(let n=0;n{let t=Ve.getState(r);return!t||t.done.eventCount==0?!1:(e&&Us(t,r,e,!1),!0)},bt=(r,e)=>{let t=Ve.getState(r);return!t||t.undone.eventCount==0?!1:(e&&Us(t,r,e,!0),!0)};var Ef=["p",0],If=["blockquote",0],Af=["hr"],Rf=["pre",["code",0]],vf=["br"],Te={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Ef}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return If}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Af}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Rf}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title"),alt:r.getAttribute("alt")}}}],toDOM(r){let{src:e,alt:t,title:n}=r.attrs;return["img",{src:e,alt:t,title:n}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return vf}}},Pf=["em",0],zf=["strong",0],Bf=["code",0],qt={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(r){return{href:r.getAttribute("href"),title:r.getAttribute("title")}}}],toDOM(r){let{href:e,title:t}=r.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:r=>r.type.name=="em"}],toDOM(){return Pf}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name=="strong"},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}],toDOM(){return zf}},code:{parseDOM:[{tag:"code"}],toDOM(){return Bf}}},Mh=new Ue({nodes:Te,marks:qt});var Ff=["ol",0],Vf=["ul",0],Lf=["li",0],Jf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(r){return{order:r.hasAttribute("start")?+r.getAttribute("start"):1}}}],toDOM(r){return r.attrs.order==1?Ff:["ol",{start:r.attrs.order},0]}},Wf={parseDOM:[{tag:"ul"}],toDOM(){return Vf}},qf={parseDOM:[{tag:"li"}],toDOM(){return Lf},defining:!0};function Dr(r,e){let t={};for(let n in r)t[n]=r[n];for(let n in e)t[n]=e[n];return t}function Ys(r,e,t){return r.append({ordered_list:Dr(Jf,{content:"list_item+",group:t}),bullet_list:Dr(Wf,{content:"list_item+",group:t}),list_item:Dr(qf,{content:e})})}function kt(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(r)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let c=t.doc.resolve(o.start-2);a=new je(c,c,o.depth),o.endIndex=0;c--)s=g.from(t[c].type.create(t[c].attrs,s));r.step(new D(e.start-(n?2:0),e.end,e.start,e.end,new b(s,0,0),t.length,!0));let o=0;for(let c=0;c=i.depth-3;k--)h=g.from(i.node(k).copy(h));let p=i.indexAfter(-1){if(y>-1)return!1;k.isTextblock&&k.content.size==0&&(y=I+1)}),y>-1&&m.setSelection(S.near(m.doc.resolve(y))),n(m.scrollIntoView())}return!0}let a=s.pos==i.end()?l.contentMatchAt(0).defaultType:null,f=t.tr.delete(i.pos,s.pos),c=a?[e?{type:r,attrs:e}:null,{type:a}]:void 0;return Re(f.doc,i.pos,2,c)?(n&&n(f.split(i.pos,2,c).scrollIntoView()),!0):!1}}function Xs(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,o=>o.childCount>0&&o.firstChild.type==r);return s?t?n.node(s.depth-1).type==r?$f(e,t,r,s):jf(e,t,s):!0:!1}}function $f(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);sm;d--)p-=i.child(d).nodeSize,n.delete(p-1,p+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,f=s.node(-1),c=s.index(-1);if(!f.canReplace(c+(l?0:1),c+1,o.content.append(a?g.empty:g.from(i))))return!1;let h=s.pos,u=h+o.nodeSize;return n.step(new D(h-(l?1:0),u+(a?1:0),h+1,u-1,new b((l?g.empty:g.from(i.copy(g.empty))).append(a?g.empty:g.from(i.copy(g.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function Qs(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,f=>f.childCount>0&&f.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=r)return!1;if(t){let f=a.lastChild&&a.lastChild.type==l.type,c=g.from(f?r.create():null),h=new b(g.from(r.create(null,g.from(l.type.create(null,c)))),f?3:1,0),u=s.start,p=s.end;t(e.tr.step(new D(u-(f?3:1),p,u,p,h,1,!0)).scrollIntoView())}return!0}}var Le=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Hf(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1}};function Hf(r){return function(e,t,n,i){let s=r;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),n+=o;let l=n-i;l>0&&(s=t[0].slice(o-l,o)+s,n=i)}return e.tr.insertText(s,n,i)}}var Zs=(r,e)=>{let t=r.plugins;for(let n=0;n=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1},Dh=new Le(/--$/,"\u2014"),Eh=new Le(/\.\.\.$/,"\u2026"),Ih=new Le(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C"),Ah=new Le(/"$/,"\u201D"),Rh=new Le(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018"),vh=new Le(/'$/,"\u2019");var eo=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1,to=r=>(e,t)=>{r[e]=t};function no(r){let e={},t,n=to(e);if(n("Mod-z",Wt),n("Shift-Mod-z",bt),n("Backspace",Zs),eo||n("Mod-y",bt),t=r.nodes.hard_break){let i=t,s=It($n,(o,l)=>(l&&l(o.tr.replaceSelectionWith(i.create()).scrollIntoView()),!0));n("Mod-Enter",s),n("Shift-Enter",s),eo&&n("Ctrl-Enter",s)}return(t=r.nodes.bullet_list)&&n("Shift-Ctrl-8",kt(t)),(t=r.nodes.ordered_list)&&n("Shift-Ctrl-9",kt(t)),(t=r.nodes.blockquote)&&n("Ctrl->",on(t)),(t=r.nodes.list_item)&&(n("Enter",Gs(t)),n("Mod-[",Xs(t)),n("Mod-]",Qs(t))),e}function ro(r){let e={},t,n=to(e);return(t=r.marks.strong)&&(n("Mod-b",ne(t)),n("Mod-B",ne(t))),(t=r.marks.em)&&(n("Mod-i",ne(t)),n("Mod-I",ne(t))),(t=r.marks.underline)&&(n("Mod-Shift-u",ne(t)),n("Mod-Shift-U",ne(t))),(t=r.marks.strikethrough)&&(n("Mod-Shift-s",ne(t)),n("Mod-Shift-S",ne(t))),e}function Uf(r,e){let t=Object.keys(e);return t.length?!!t.filter(n=>e[n]===r[n]).length:!0}function Er(r,e,t={}){return r.find(n=>n.type===e&&Uf(n.attrs,t))}function _f(r,e,t={}){return!!Er(r,e,t)}function Ir(r,e,t={}){if(!r||!e)return;let n=r.parent.childAfter(r.parentOffset);if(!n.node)return;let i=Er(n.node.marks,e,t);if(!i)return;let s=r.index(),o=r.start()+n.offset,l=s+1,a=o+n.node.nodeSize;for(Er(n.node.marks,e,t);s>0&&i.isInSet(r.parent.child(s-1).marks);)s-=1,o-=r.parent.child(s).nodeSize;for(;l=e||G<0||h&&le>=s}function k(){var w=Mn();if(y(w))return I(w);l=setTimeout(k,m(w))}function I(w){return l=void 0,u&&n?p(w):(n=i=void 0,o)}function se(){l!==void 0&&clearTimeout(l),f=0,n=a=i=l=void 0}function oe(){return l===void 0?o:I(Mn())}function te(){var w=Mn(),G=y(w);if(n=arguments,i=this,a=w,G){if(l===void 0)return d(a);if(h)return clearTimeout(l),l=setTimeout(k,e),p(a)}return l===void 0&&(l=setTimeout(k,e)),o}return te.cancel=se,te.flush=oe,te}var go=wc;var De=(r,e=null)=>{let t=document.createElement(r);if(e)for(let[n,i]of Object.entries(e))/^data-|^aria-|^role/.test(n)?t.setAttribute(n,i):t[n]=i;return t};function yo(r,e){let t=document.createElement("article");return t.innerHTML=e,ae.fromSchema(r).parse(t)}var bo=(r,e,t)=>{let n=j.fromSchema(r),i=function(){let o=De("article");return o.appendChild(n.serializeFragment(e.state.doc.content)),o.innerHTML};return go(()=>{let o=i();t.value!==o&&(t.value=o,t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0})))},250)};var ko=r=>{let{$from:e,$to:t}=r,n=e.pos,i=t.pos,s=e.nodeAfter,o=t.nodeBefore,l=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,a=o&&o.isText?/\s*$/.exec(o.text)[0].length:0;return n+l({command:jn(r.nodes.heading,{level:t}),dom:Je(`H${t}`),active(n){return n.selection.$from.parent.hasMarkup(r.nodes.heading,{level:t})}});return[e(1),e(2),e(3),{command:jn(r.nodes.paragraph),dom:Je("P"),active(t){return t.selection.$from.parent.hasMarkup(r.nodes.paragraph)}}]}function Oo(r){return[{command:kt(r.nodes.bullet_list),dom:Je("ul"),active(e){return!1}},{command:kt(r.nodes.ordered_list),dom:Je("ol"),active(e){return!1}},{command:on(r.nodes.blockquote),dom:Je("\u201D"),active(e){return!1}}]}function wo(r){let e=(i,s,o)=>({command:ne(i),dom:Je(s,o),active:l=>Mo(l,i)}),t=e(r.marks.sub,"sub","");t.dom.innerHTML="x";let n=e(r.marks.sup,"sup","");return n.dom.innerHTML="x",[e(r.marks.strong,"B","font-weight:bold"),e(r.marks.em,"I","font-style:italic"),e(r.marks.underline,"U","text-decoration:underline"),e(r.marks.strikethrough,"S","text-decoration:line-through"),t,n]}var Nc=r=>new Promise(e=>{let t=document.createElement("div");t.innerHTML=` +`))),0,0):b.empty;let h=r.someProp("clipboardTextParser",u=>u(e,i,n,r));if(h)l=h;else{let u=i.marks(),{schema:p}=r.state,d=j.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let y=o.appendChild(document.createElement("p"));m&&y.appendChild(d.serializeNode(p.text(m,u)))})}}else r.someProp("transformPastedHTML",h=>{t=h(t,r)}),o=Pa(t),Lt&&za(o);let f=o&&o.querySelector("[data-pm-slice]"),c=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let h=+c[3];h>0;h--){let u=o.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;o=u}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||ae.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Ra.test(u.parentNode.nodeName)?{ignore:!0}:null}})),c)l=Ba(es(l,+c[1],+c[2]),c[4]);else if(l=b.maxOpen(va(l.content,i),!0),l.openStart||l.openEnd){let h=0,u=0;for(let p=l.content.firstChild;h{l=h(l,r)}),l}var Ra=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function va(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),f;if(!a)return o=null;if(f=o.length&&s.length&&Is(a,s,l,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=As(o[o.length-1],s.length));let c=Es(l,a);o.push(c),i=i.matchType(c.type),s=a}}),o)return g.from(o)}return r}function Es(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,g.from(r));return r}function Is(r,e,t,n,i){if(i1&&(s=0),i=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(g.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function es(r,e,t){return e]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=vs().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&Rs[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"").reverse().join("")),t.innerHTML=r,i)for(let s=0;s=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=g.from(a.create(n[l+1],i)),s++,o++}return new b(i,s,o)}var K={},$={},Fa={touchstart:!0,touchmove:!0},ur=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Va(r){for(let e in K){let t=K[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Ja(r,n)&&!Sr(r,n)&&(r.editable||!(n.type in $))&&t(r,n)},Fa[e]?{passive:!0}:void 0)}q&&r.dom.addEventListener("input",()=>null),dr(r)}function ze(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function La(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function dr(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Sr(r,n))})}function Sr(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Ja(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Wa(r,e){!Sr(r,e)&&K[e.type]&&(r.editable||!(e.type in $))&&K[e.type](r,e)}$.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!zs(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(re&&V&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),mt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,Ge(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||Aa(r,t)?t.preventDefault():ze(r,"key")};$.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};$.keypress=(r,e)=>{let t=e;if(zs(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||Q&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof O)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i))&&r.dispatch(r.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function yn(r){return{left:r.clientX,top:r.clientY}}function qa(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Mr(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,l=>o>s.depth?l(r,t,s.nodeAfter,s.before(o),i,!0):l(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function pt(r,e,t){r.focused||r.focus();let n=r.state.tr.setSelection(e);t=="pointer"&&n.setMeta("pointer",!0),r.dispatch(n)}function Ka(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&x.isSelectable(n)?(pt(r,new x(t),"pointer"),!0):!1}function $a(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof x&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(x.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(pt(r,x.create(r.state.doc,i),"pointer"),!0):!1}function ja(r,e,t,n,i){return Mr(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?$a(r,t):Ka(r,t))}function Ha(r,e,t,n){return Mr(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function Ua(r,e,t,n){return Mr(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||_a(r,t,n)}function _a(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(pt(r,O.create(n,0,n.content.size),"pointer"),!0):!1;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)pt(r,O.create(n,l+1,l+1+o.content.size),"pointer");else if(x.isSelectable(o))pt(r,x.create(n,l),"pointer");else continue;return!0}}function Cr(r){return un(r)}var Ps=Q?"metaKey":"ctrlKey";K.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Cr(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&qa(t,r.input.lastClick)&&!t[Ps]&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=r.posAtCoords(yn(t));!o||(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new pr(r,o,t,!!n)):(s=="doubleClick"?Ha:Ua)(r,o.pos,o.inside,t)?t.preventDefault():ze(r,"pointer"))};var pr=class{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Ps],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let c=e.state.doc.resolve(t.pos);s=c.parent,o=c.depth?c.before():0}let l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:f}=e.state;(n.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||f instanceof x&&f.from<=o&&f.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ie&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ze(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>we(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yn(e))),this.updateAllowDefault(e),this.allowDefault||!t?ze(this.view,"pointer"):ja(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||q&&this.mightDrag&&!this.mightDrag.node.isAtom||V&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(pt(this.view,S.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):ze(this.view,"pointer")}move(e){this.updateAllowDefault(e),ze(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};K.touchstart=r=>{r.input.lastTouch=Date.now(),Cr(r),ze(r,"pointer")};K.touchmove=r=>{r.input.lastTouch=Date.now(),ze(r,"pointer")};K.contextmenu=r=>Cr(r);function zs(r,e){return r.composing?!0:q&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}var Ya=re?5e3:-1;$.compositionstart=$.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),un(r,!0),r.markCursor=null;else if(un(r),ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){r.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}Bs(r,Ya)};$.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,Bs(r,20))};function Bs(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>un(r),e))}function Fs(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Ga());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Ga(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function un(r,e=!1){if(!(re&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),Fs(r),e||r.docView&&r.docView.dirty){let t=kr(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):r.updateState(r.state),!0}return!1}}function Xa(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}var zt=U&&Be<15||mt&&Zl<604;K.copy=$.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=zt?null:t.clipboardData,o=n.content(),{dom:l,text:a}=Ts(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Xa(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Qa(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Za(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?Bt(r,n.value,null,i,e):Bt(r,n.textContent,n.innerHTML,i,e)},50)}function Bt(r,e,t,n,i){let s=Ds(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||b.empty)))return!0;if(!s)return!1;let o=Qa(s),l=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Vs(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}$.paste=(r,e)=>{let t=e;if(r.composing&&!re)return;let n=zt?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Bt(r,Vs(n),n.getData("text/html"),i,t)?t.preventDefault():Za(r,t)};var dn=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Ls=Q?"altKey":"ctrlKey";K.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords(yn(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof x?i.to-1:i.to))){if(n&&n.mightDrag)o=x.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let c=r.docView.nearestDesc(t.target,!0);c&&c.node.type.spec.draggable&&c!=r.docView&&(o=x.create(r.state.doc,c.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:f}=Ts(r,l);t.dataTransfer.clearData(),t.dataTransfer.setData(zt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",zt||t.dataTransfer.setData("text/plain",f),r.dragging=new dn(l,!t[Ls],o)};K.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};$.dragover=$.dragenter=(r,e)=>e.preventDefault();$.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords(yn(t));if(!i)return;let s=r.state.doc.resolve(i.pos),o=n&&n.slice;o?r.someProp("transformPasted",d=>{o=d(o,r)}):o=Ds(r,Vs(t.dataTransfer),zt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&!t[Ls]);if(r.someProp("handleDrop",d=>d(r,t,o||b.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?nn(r.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let f=r.state.tr;if(l){let{node:d}=n;d?d.replace(f):f.deleteSelection()}let c=f.mapping.map(a),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=f.doc;if(h?f.replaceRangeWith(c,c,o.content.firstChild):f.replaceRange(c,c,o),f.doc.eq(u))return;let p=f.doc.resolve(c);if(h&&x.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))f.setSelection(new x(p));else{let d=f.mapping.map(a);f.mapping.maps[f.mapping.maps.length-1].forEach((m,y,k,I)=>d=I),f.setSelection(xr(r,p,f.doc.resolve(d)))}r.focus(),r.dispatch(f.setMeta("uiEvent","drop"))};K.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&we(r)},20))};K.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};K.beforeinput=(r,e)=>{if(V&&re&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,Ge(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in $)K[r]=$[r];function Ft(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}var yt=class{constructor(e,t){this.toDOM=e,this.spec=t||Ze,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new W(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof yt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ft(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},pe=class{constructor(e,t){this.attrs=e,this.spec=t||Ze}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new W(s,o,this)}valid(e,t){return t.from=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;oe){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,i+l,s)}}map(e,t,n){return this==F||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Ze)}mapInner(e,t,n,i,s){let o;for(let l=0;l{let f=a+n,c;if(!!(c=Ws(t,l,f))){for(i||(i=this.children.slice());sl&&h.to=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;ls&&a.type instanceof pe){let f=Math.max(s,a.from)-s,c=Math.min(o,a.to)-s;fi.map(e,t,Ze));return ue.from(n)}forChild(e,t){if(t.isLeaf)return E.empty;let n=[];for(let i=0;it instanceof E)?e:e.reduce((t,n)=>t.concat(n instanceof E?n:n.members),[]))}}};function ef(r,e,t,n,i,s,o){let l=r.slice();for(let f=0,c=s;f{let y=m-d-(p-u);for(let k=0;kI+c-h)continue;let se=l[k]+c-h;p>=se?l[k+1]=u<=se?-2:-1:u>=c&&y&&(l[k]+=y,l[k+1]+=y)}h+=y}),c=t.maps[f].map(c,-1)}let a=!1;for(let f=0;f=n.content.size){a=!0;continue}let u=t.map(r[f+1]+s,-1),p=u-i,{index:d,offset:m}=n.content.findIndex(h),y=n.maybeChild(d);if(y&&m==h&&m+y.nodeSize==p){let k=l[f+2].mapInner(t,y,c+1,r[f]+s+1,o);k!=F?(l[f]=h,l[f+1]=p,l[f+2]=k):(l[f+1]=-2,a=!0)}else a=!0}if(a){let f=tf(l,r,e,t,i,s,o),c=pn(f,n,0,o);e=c.local;for(let h=0;ht&&o.to{let f=Ws(r,l,a+t);if(f){s=!0;let c=pn(f,l,t+a+1,n);c!=F&&i.push(a,a+l.nodeSize,c)}});let o=Js(s?qs(r):r,-t).sort(et);for(let l=0;l0;)e++;r.splice(e,0,t)}function Qn(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=F&&e.push(n)}),r.cursorWrapper&&e.push(E.create(r.state.doc,[r.cursorWrapper.deco])),ue.from(e)}var nf={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},rf=U&&Be<=11,mr=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},gr=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mr,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),rf&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,nf)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(!!_i(this.view)){if(this.suppressingSelectionUpdates)return we(this.view);if(U&&Be<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&tt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let s=e.focusNode;s;s=Pt(s))t.add(s);for(let s=e.anchorNode;s;s=Pt(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&_i(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let c=0;c1){let c=a.filter(h=>h.nodeName=="BR");if(c.length==2){let h=c[0],u=c[1];h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}}let f=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(s>-1&&(e.docView.markDirty(s,o),sf(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||we(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;ci;y--){let k=n.childNodes[y-1],I=k.pmViewDesc;if(k.nodeName=="BR"&&!I){s=y;break}if(!I||I.size)break}let h=r.state.doc,u=r.someProp("domParser")||ae.fromSchema(r.state.schema),p=h.resolve(o),d=null,m=u.parse(n,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:af,context:p});if(f&&f[0].pos!=null){let y=f[0].pos,k=f[1]&&f[1].pos;k==null&&(k=y),d={anchor:y+o,head:k+o}}return{doc:m,sel:d,from:o,to:l}}function af(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(q&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||q&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}var ff=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function cf(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let M=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,Ee=kr(r,M);if(Ee&&!r.state.selection.eq(Ee)){if(V&&re&&r.input.lastKeyCode===13&&Date.now()-100Io(r,Ge(13,"Enter"))))return;let jt=r.state.tr.setSelection(Ee);M=="pointer"?jt.setMeta("pointer",!0):M=="key"&&jt.scrollIntoView(),s&&jt.setMeta("composition",s),r.dispatch(jt)}return}let o=r.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,f=lf(r,e,t),c=r.state.doc,h=c.slice(f.from,f.to),u,p;r.input.lastKeyCode===8&&Date.now()-100Date.now()-225||re)&&i.some(M=>M.nodeType==1&&!ff.test(M.nodeName))&&(!d||d.endA>=d.endB)&&r.someProp("handleKeyDown",M=>M(r,Ge(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!d)if(n&&a instanceof O&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))d={start:a.from,endA:a.to,endB:a.to};else{if(f.sel){let M=ss(r,r.state.doc,f.sel);if(M&&!M.eq(r.state.selection)){let Ee=r.state.tr.setSelection(M);s&&Ee.setMeta("composition",s),r.dispatch(Ee)}}return}if(V&&r.cursorWrapper&&f.sel&&f.sel.anchor==r.cursorWrapper.deco.from&&f.sel.head==f.sel.anchor){let M=d.endB-d.start;f.sel={anchor:f.sel.anchor+M,head:f.sel.anchor+M}}r.input.domChangeCount++,r.state.selection.fromr.state.selection.from&&d.start<=r.state.selection.from+2&&r.state.selection.from>=f.from?d.start=r.state.selection.from:d.endA=r.state.selection.to-2&&r.state.selection.to<=f.to&&(d.endB+=r.state.selection.to-d.endA,d.endA=r.state.selection.to)),U&&Be<=11&&d.endB==d.start+1&&d.endA==d.start&&d.start>f.from&&f.doc.textBetween(d.start-f.from-1,d.start-f.from+1)==" \xA0"&&(d.start--,d.endA--,d.endB--);let m=f.doc.resolveNoCache(d.start-f.from),y=f.doc.resolveNoCache(d.endB-f.from),k=c.resolve(d.start),I=m.sameParent(y)&&m.parent.inlineContent&&k.end()>=d.endA,se;if((mt&&r.input.lastIOSEnter>Date.now()-225&&(!I||i.some(M=>M.nodeName=="DIV"||M.nodeName=="P"))||!I&&m.posM(r,Ge(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>d.start&&uf(c,d.start,d.endA,m,y)&&r.someProp("handleKeyDown",M=>M(r,Ge(8,"Backspace")))){re&&V&&r.domObserver.suppressSelectionUpdates();return}V&&re&&d.endB==d.start&&(r.input.lastAndroidDelete=Date.now()),re&&!I&&m.start()!=y.start()&&y.parentOffset==0&&m.depth==y.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==d.endA&&(d.endB-=2,y=f.doc.resolveNoCache(d.endB-f.from),setTimeout(()=>{r.someProp("handleKeyDown",function(M){return M(r,Ge(13,"Enter"))})},20));let oe=d.start,te=d.endA,w,G,le;if(I){if(m.pos==y.pos)U&&Be<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>we(r),20)),w=r.state.tr.delete(oe,te),G=c.resolve(d.start).marksAcross(c.resolve(d.endA));else if(d.endA==d.endB&&(le=hf(m.parent.content.cut(m.parentOffset,y.parentOffset),k.parent.content.cut(k.parentOffset,d.endA-k.start()))))w=r.state.tr,le.type=="add"?w.addMark(oe,te,le.mark):w.removeMark(oe,te,le.mark);else if(m.parent.child(m.index()).isText&&m.index()==y.index()-(y.textOffset?0:1)){let M=m.parent.textBetween(m.parentOffset,y.parentOffset);if(r.someProp("handleTextInput",Ee=>Ee(r,oe,te,M)))return;w=r.state.tr.insertText(M,oe,te)}}if(w||(w=r.state.tr.replace(oe,te,f.doc.slice(d.start-f.from,d.endB-f.from))),f.sel){let M=ss(r,w.doc,f.sel);M&&!(V&&re&&r.composing&&M.empty&&(d.start!=d.endB||r.input.lastAndroidDeletee.content.size?null:xr(r,e.resolve(t.anchor),e.resolve(t.head))}function hf(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let c=0;cc.mark(l.addToSet(c.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let f=[];for(let c=0;ct||Zn(o,!0,!1)0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function df(r,e,t,n,i){let s=r.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,s&&s=l?s-n:0;s-=a,s&&s=56320&&e<=57343&&t>=55296&&t<=56319}var mn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ur,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(us),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=cs(this),fs(this),this.nodeViews=hs(this),this.docView=qi(this.state.doc,as(this),Qn(this),this.dom,this),this.domObserver=new gr(this,(n,i,s,o)=>cf(this,n,i,s,o)),this.domObserver.start(),Va(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&dr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(us),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Fs(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=hs(this);mf(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&dr(this),this.editable=cs(this),fs(this);let a=Qn(this),f=as(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,f,a);(h||!e.selection.eq(i.selection))&&(o=!0);let u=c=="preserve"&&o&&this.dom.style.overflowAnchor==null&&na(this);if(o){this.domObserver.stop();let p=h&&(U||V)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&pf(i.selection,e.selection);if(h){let d=V?this.trackWrites=this.domSelectionRange().focusNode:null;(s||!this.docView.update(e.doc,f,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=qi(e.doc,f,a,this.dom,this)),d&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Oa(this))?we(this,p):(Os(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),((n=this.dragging)===null||n===void 0?void 0:n.node)&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():u&&ra(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof x){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Bi(this,t.getBoundingClientRect(),e)}else Bi(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new dn(e.slice,e.move,i<0?void 0:x.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;ot.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return fa(this,e)}coordsAtPos(e,t=1){return bs(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return pa(this,t||this.state,e)}pasteHTML(e,t){return Bt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Bt(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){!this.docView||(La(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Wa(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return q&&this.root.nodeType===11&&Yl(this.dom.ownerDocument)==this.dom?of(this):this.domSelection()}domSelection(){return this.root.getSelection()}};function as(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[W.node(0,r.state.doc.content.size,e)]}function fs(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:W.widget(r.state.selection.head,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function cs(r){return!r.someProp("editable",e=>e(r.state)===!1)}function pf(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function hs(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function mf(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function us(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var N=class extends S{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return N.valid(n)?new N(n):S.near(n)}content(){return b.empty}eq(e){return e instanceof N&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new N(e.resolve(t.pos))}getBookmark(){return new Jt(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!gf(e)||!yf(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&N.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(N.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!x.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),n=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(N.valid(l))return l}return null}}};N.prototype.visible=!1;N.findFrom=N.findGapCursorFrom;S.jsonID("gapcursor",N);var Jt=class{constructor(e){this.pos=e}map(e){return new Jt(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return N.valid(t)?new N(t):S.near(t)}};function gf(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function yf(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Ks(){return new H({props:{decorations:Sf,createSelectionBetween(r,e,t){return e.pos==t.pos&&N.valid(t)?new N(t):null},handleClick:kf,handleKeyDown:bf,handleDOMEvents:{beforeinput:xf}}})}var bf=Yn({ArrowLeft:bn("horiz",-1),ArrowRight:bn("horiz",1),ArrowUp:bn("vert",-1),ArrowDown:bn("vert",1)});function bn(r,e){let t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,s){let o=n.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof O){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let f=N.findGapCursorFrom(l,e,a);return f?(i&&i(n.tr.setSelection(new N(f))),!0):!1}}function kf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!N.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&x.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new N(n))),!0)}function xf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof N))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=g.empty;for(let o=n.length-1;o>=0;o--)i=g.from(n[o].createAndFill(null,i));let s=r.state.tr.replace(t.pos,t.pos,new b(i,0,0));return s.setSelection(O.near(s.doc.resolve(t.pos+1))),r.dispatch(s),!1}function Sf(r){if(!(r.selection instanceof N))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",E.create(r.doc,[W.widget(r.selection.head,e,{key:"gapcursor"})])}var kn=200,z=function(){};z.prototype.append=function(e){return e.length?(e=z.from(e),!this.length&&e||e.length=t?z.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};z.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};z.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};z.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,n),i};z.from=function(e){return e instanceof z?e:e&&e.length?new $s(e):z.empty};var $s=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=kn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=kn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(z);z.empty=new $s([]);var Mf=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return nl&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(s,l)-l,o+l)===!1||s=s?this.right.slice(n-s,i-s):this.left.slice(n,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(z),wr=z;var Cf=500,Y=class{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,s;t&&(i=this.remapping(n,this.items.length),s=i.maps.length);let o=e.tr,l,a,f=[],c=[];return this.items.forEach((h,u)=>{if(!h.step){i||(i=this.remapping(n,u+1),s=i.maps.length),s--,c.push(h);return}if(i){c.push(new ee(h.map));let p=h.step.map(i.slice(s)),d;p&&o.maybeStep(p).doc&&(d=o.mapping.maps[o.mapping.maps.length-1],f.push(new ee(d,void 0,void 0,f.length+c.length))),s--,d&&i.appendMap(d,s)}else o.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(s)):h.selection,a=new Y(this.items.slice(0,n).append(c.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,n,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let c=0;cwf&&(l=Of(l,f),o-=f),new Y(l.append(s),o)}remapping(e,t){let n=new ke;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,o)},e,t),n}addMaps(e){return this.eventCount==0?this:new Y(this.items.append(e.map(t=>new ee(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},i);let a=t;this.items.forEach(u=>{let p=s.getMirror(--a);if(p==null)return;o=Math.min(o,p);let d=s.maps[p];if(u.step){let m=e.steps[p].invert(e.docs[p]),y=u.selection&&u.selection.map(s.slice(a+1,p));y&&l++,n.push(new ee(d,m,y))}else n.push(new ee(d))},i);let f=[];for(let u=t;uCf&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(n)),f=a&&a.getMap();if(n--,f&&t.appendMap(f,n),a){let c=o.selection&&o.selection.map(t.slice(n));c&&s++;let h=new ee(f.invert(),a,c),u,p=i.length-1;(u=i.length&&i[p].merge(h))?i[p]=u:i.push(h)}}else o.map&&n--},this.items.length,0),new Y(wr.from(i.reverse()),s)}};Y.empty=new Y(wr.empty,0);function Of(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}var ee=class{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new ee(t.getMap().invert(),t,this.selection)}}},ye=class{constructor(e,t,n,i,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=s}},wf=20;function Nf(r,e,t,n){let i=t.getMeta(Ve),s;if(i)return i.historyState;t.getMeta(Df)&&(r=new ye(r.done,r.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(o&&o.getMeta(Ve))return o.getMeta(Ve).redo?new ye(r.done.addTransform(t,void 0,n,xn(e)),r.undone,js(t.mapping.maps[t.steps.length-1]),r.prevTime,r.prevComposition):new ye(r.done,r.undone.addTransform(t,void 0,n,xn(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!o&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!Tf(t,r.prevRanges)),f=o?Nr(r.prevRanges,t.mapping):js(t.mapping.maps[t.steps.length-1]);return new ye(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,xn(e)),Y.empty,f,t.time,l==null?r.prevComposition:l)}else return(s=t.getMeta("rebased"))?new ye(r.done.rebased(t,s),r.undone.rebased(t,s),Nr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new ye(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Nr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function Tf(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let s=0;s=e[s]&&(t=!0)}),t}function js(r){let e=[];return r.forEach((t,n,i,s)=>e.push(i,s)),e}function Nr(r,e){if(!r)return null;let t=[];for(let n=0;n{let t=Ve.getState(r);return!t||t.done.eventCount==0?!1:(e&&Us(t,r,e,!1),!0)},bt=(r,e)=>{let t=Ve.getState(r);return!t||t.undone.eventCount==0?!1:(e&&Us(t,r,e,!0),!0)};var Ef=["p",0],If=["blockquote",0],Af=["hr"],Rf=["pre",["code",0]],vf=["br"],Te={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Ef}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return If}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Af}},heading:{attrs:{level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Rf}},text:{group:"inline"},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title"),alt:r.getAttribute("alt")}}}],toDOM(r){let{src:e,alt:t,title:n}=r.attrs;return["img",{src:e,alt:t,title:n}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return vf}}},Pf=["em",0],zf=["strong",0],Bf=["code",0],qt={link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(r){return{href:r.getAttribute("href"),title:r.getAttribute("title")}}}],toDOM(r){let{href:e,title:t}=r.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:r=>r.type.name=="em"}],toDOM(){return Pf}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name=="strong"},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}],toDOM(){return zf}},code:{parseDOM:[{tag:"code"}],toDOM(){return Bf}}},Mh=new Ue({nodes:Te,marks:qt});var Ff=["ol",0],Vf=["ul",0],Lf=["li",0],Jf={attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs(r){return{order:r.hasAttribute("start")?+r.getAttribute("start"):1}}}],toDOM(r){return r.attrs.order==1?Ff:["ol",{start:r.attrs.order},0]}},Wf={parseDOM:[{tag:"ul"}],toDOM(){return Vf}},qf={parseDOM:[{tag:"li"}],toDOM(){return Lf},defining:!0};function Dr(r,e){let t={};for(let n in r)t[n]=r[n];for(let n in e)t[n]=e[n];return t}function Ys(r,e,t){return r.append({ordered_list:Dr(Jf,{content:"list_item+",group:t}),bullet_list:Dr(Wf,{content:"list_item+",group:t}),list_item:Dr(qf,{content:e})})}function kt(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(r)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let c=t.doc.resolve(o.start-2);a=new je(c,c,o.depth),o.endIndex=0;c--)s=g.from(t[c].type.create(t[c].attrs,s));r.step(new D(e.start-(n?2:0),e.end,e.start,e.end,new b(s,0,0),t.length,!0));let o=0;for(let c=0;c=i.depth-3;k--)h=g.from(i.node(k).copy(h));let p=i.indexAfter(-1){if(y>-1)return!1;k.isTextblock&&k.content.size==0&&(y=I+1)}),y>-1&&m.setSelection(S.near(m.doc.resolve(y))),n(m.scrollIntoView())}return!0}let a=s.pos==i.end()?l.contentMatchAt(0).defaultType:null,f=t.tr.delete(i.pos,s.pos),c=a?[e?{type:r,attrs:e}:null,{type:a}]:void 0;return Re(f.doc,i.pos,2,c)?(n&&n(f.split(i.pos,2,c).scrollIntoView()),!0):!1}}function Xs(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,o=>o.childCount>0&&o.firstChild.type==r);return s?t?n.node(s.depth-1).type==r?$f(e,t,r,s):jf(e,t,s):!0:!1}}function $f(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);sm;d--)p-=i.child(d).nodeSize,n.delete(p-1,p+1);let s=n.doc.resolve(t.start),o=s.nodeAfter;if(n.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,f=s.node(-1),c=s.index(-1);if(!f.canReplace(c+(l?0:1),c+1,o.content.append(a?g.empty:g.from(i))))return!1;let h=s.pos,u=h+o.nodeSize;return n.step(new D(h-(l?1:0),u+(a?1:0),h+1,u-1,new b((l?g.empty:g.from(i.copy(g.empty))).append(a?g.empty:g.from(i.copy(g.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function Qs(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,f=>f.childCount>0&&f.firstChild.type==r);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=r)return!1;if(t){let f=a.lastChild&&a.lastChild.type==l.type,c=g.from(f?r.create():null),h=new b(g.from(r.create(null,g.from(l.type.create(null,c)))),f?3:1,0),u=s.start,p=s.end;t(e.tr.step(new D(u-(f?3:1),p,u,p,h,1,!0)).scrollIntoView())}return!0}}var Le=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Hf(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1}};function Hf(r){return function(e,t,n,i){let s=r;if(t[1]){let o=t[0].lastIndexOf(t[1]);s+=t[0].slice(o+t[1].length),n+=o;let l=n-i;l>0&&(s=t[0].slice(o-l,o)+s,n=i)}return e.tr.insertText(s,n,i)}}var Zs=(r,e)=>{let t=r.plugins;for(let n=0;n=0;a--)o.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,r.schema.text(s.text,a))}else o.delete(s.from,s.to);e(o)}return!0}}return!1},Dh=new Le(/--$/,"\u2014"),Eh=new Le(/\.\.\.$/,"\u2026"),Ih=new Le(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C"),Ah=new Le(/"$/,"\u201D"),Rh=new Le(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018"),vh=new Le(/'$/,"\u2019");var eo=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1,to=r=>(e,t)=>{r[e]=t};function no(r){let e={},t,n=to(e);if(n("Mod-z",Wt),n("Shift-Mod-z",bt),n("Backspace",Zs),eo||n("Mod-y",bt),t=r.nodes.hard_break){let i=t,s=It($n,(o,l)=>(l&&l(o.tr.replaceSelectionWith(i.create()).scrollIntoView()),!0));n("Mod-Enter",s),n("Shift-Enter",s),eo&&n("Ctrl-Enter",s)}return(t=r.nodes.bullet_list)&&n("Shift-Ctrl-8",kt(t)),(t=r.nodes.ordered_list)&&n("Shift-Ctrl-9",kt(t)),(t=r.nodes.blockquote)&&n("Ctrl->",on(t)),(t=r.nodes.list_item)&&(n("Enter",Gs(t)),n("Mod-[",Xs(t)),n("Mod-]",Qs(t))),e}function ro(r){let e={},t,n=to(e);return(t=r.marks.strong)&&(n("Mod-b",ne(t)),n("Mod-B",ne(t))),(t=r.marks.em)&&(n("Mod-i",ne(t)),n("Mod-I",ne(t))),(t=r.marks.underline)&&(n("Mod-Shift-u",ne(t)),n("Mod-Shift-U",ne(t))),(t=r.marks.strikethrough)&&(n("Mod-Shift-s",ne(t)),n("Mod-Shift-S",ne(t))),e}function Uf(r,e){let t=Object.keys(e);return t.length?!!t.filter(n=>e[n]===r[n]).length:!0}function Er(r,e,t={}){return r.find(n=>n.type===e&&Uf(n.attrs,t))}function _f(r,e,t={}){return!!Er(r,e,t)}function Ir(r,e,t={}){if(!r||!e)return;let n=r.parent.childAfter(r.parentOffset);if(!n.node)return;let i=Er(n.node.marks,e,t);if(!i)return;let s=r.index(),o=r.start()+n.offset,l=s+1,a=o+n.node.nodeSize;for(Er(n.node.marks,e,t);s>0&&i.isInSet(r.parent.child(s-1).marks);)s-=1,o-=r.parent.child(s).nodeSize;for(;l=e||G<0||h&&le>=s}function k(){var w=Mn();if(y(w))return I(w);l=setTimeout(k,m(w))}function I(w){return l=void 0,u&&n?p(w):(n=i=void 0,o)}function se(){l!==void 0&&clearTimeout(l),f=0,n=a=i=l=void 0}function oe(){return l===void 0?o:I(Mn())}function te(){var w=Mn(),G=y(w);if(n=arguments,i=this,a=w,G){if(l===void 0)return d(a);if(h)return clearTimeout(l),l=setTimeout(k,e),p(a)}return l===void 0&&(l=setTimeout(k,e)),o}return te.cancel=se,te.flush=oe,te}var go=wc;var De=(r,e=null)=>{let t=document.createElement(r);if(e)for(let[n,i]of Object.entries(e))/^data-|^aria-|^role/.test(n)?t.setAttribute(n,i):t[n]=i;return t};function yo(r,e){let t=document.createElement("article");return t.innerHTML=e,ae.fromSchema(r).parse(t)}var bo=(r,e,t)=>{let n=j.fromSchema(r),i=function(){let o=De("article");return o.appendChild(n.serializeFragment(e.state.doc.content)),o.innerHTML};return go(()=>{let o=i();t.value!==o&&(t.value=o,t.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0})))},250)};var ko=r=>{let{$from:e,$to:t}=r,n=e.pos,i=t.pos,s=e.nodeAfter,o=t.nodeBefore,l=s&&s.isText?/^\s*/.exec(s.text)[0].length:0,a=o&&o.isText?/\s*$/.exec(o.text)[0].length:0;return n+l({command:jn(r.nodes.heading,{level:t}),dom:Je(`H${t}`),active(n){return n.selection.$from.parent.hasMarkup(r.nodes.heading,{level:t})}});return[e(1),e(2),e(3),{command:jn(r.nodes.paragraph),dom:Je("P"),active(t){return t.selection.$from.parent.hasMarkup(r.nodes.paragraph)}}]}function Oo(r){return[{command:kt(r.nodes.bullet_list),dom:Je("ul"),active(e){return!1}},{command:kt(r.nodes.ordered_list),dom:Je("ol"),active(e){return!1}},{command:on(r.nodes.blockquote),dom:Je("\u201D"),active(e){return!1}}]}function wo(r){let e=(i,s,o)=>({command:ne(i),dom:Je(s,o),active:l=>Mo(l,i)}),t=e(r.marks.sub,"sub","");t.dom.innerHTML="x";let n=e(r.marks.sup,"sup","");return n.dom.innerHTML="x",[e(r.marks.strong,"B","font-weight:bold"),e(r.marks.em,"I","font-style:italic"),e(r.marks.underline,"U","text-decoration:underline"),e(r.marks.strikethrough,"S","text-decoration:line-through"),t,n]}var Nc=r=>new Promise(e=>{let t=document.createElement("div");t.innerHTML=`

@@ -15,4 +15,4 @@ var DjangoProseEditor=(()=>{var Ht=Object.defineProperty;var Ao=Object.getOwnPro
- `,document.body.append(t);let n=t.querySelector("dialog"),i=t.querySelector("form");i.href.value=r.href,i.title.value=r.title,n.addEventListener("close",()=>{t.remove(),e(null)}),t.querySelector("button[type=submit]").addEventListener("click",s=>{s.preventDefault(),t.remove(),e({href:i.href.value,title:i.title.value})}),n.showModal()}),xo=(r,e)=>{let{$from:t,empty:n}=r.selection,i=r.schema.marks.link;if(n&&!i.isInSet(t.marks()))return!1;if(e){let s=t.marks().find(o=>o.type===i);Nc((s==null?void 0:s.attrs)||{}).then(o=>{if(console.debug(o),o){let l;if(n)l=Ir(t,i),e(r.tr.removeMark(l.from,l.to,i).addMark(l.from,l.to,i.create(o)));else{let{from:a,to:f}=ko(r.selection);e(r.tr.addMark(a,f,i.create(o)))}}})}return!0},Tc=(r,e)=>{let t=r.schema.marks.link,{$from:n,from:i,to:s}=r.selection,o=Ir(n,t);return o&&o.from<=i&&o.to>=s?(e&&e(r.tr.removeMark(o.from,o.to,t)),!0):!1};function No(r){return[{command:xo,dom:Je("link"),active:xo},{command:Tc,dom:Je("unlink"),active:e=>Mo(e,r.marks.link)}]}function To(){return[{command:Wt,dom:De("span",{className:"tw-menubar__button tw-menubar__button--history-undo"}),active(r){return!1}},{command:bt,dom:De("span",{className:"tw-menubar__button tw-menubar__button--history-redo"}),active(r){return!1}}]}var Rr=class{constructor(e,t){this.items=e.flatMap(n=>n),this.editorView=t,this.dom=De("div",{className:"tw-menubar"}),e.filter(n=>n.length).forEach(n=>{let i=De("div",{className:"tw-menubar__group"});this.dom.append(i),n.forEach(({dom:s})=>i.append(s))}),this.update(),this.dom.addEventListener("mousedown",n=>{n.preventDefault(),t.focus(),this.items.forEach(({command:i,dom:s})=>{s.contains(n.target)&&i(t.state,t.dispatch,t)})})}update(){this.items.forEach(({command:e,dom:t,active:n})=>{let i=e(this.editorView.state,null,this.editorView);t.classList.toggle("disabled",!i),t.classList.toggle("active",n(this.editorView.state)||!1)})}destroy(){this.dom.remove()}};function Do(){return new H({view(r){return new vr(r)}})}var vr=class{constructor(e){this.editorView=e,this.editorView.dom.setAttribute("spellcheck","false")}update(){}destroy(){this.editorView.dom.removeAttribute("spellcheck")}};var Dc=["u",0],Ec=["s",0],Ic=["sub",0],Ac=["sup",0];function Eo(r){let e={nodes:{doc:Te.doc,paragraph:Te.paragraph,heading:Te.heading,blockquote:Te.blockquote,horizontal_rule:Te.horizontal_rule,text:Te.text,hard_break:Te.hard_break},marks:{link:qt.link,strong:qt.strong,em:qt.em,underline:{parseDOM:[{tag:"u"},{style:"text-decoration:underline"}],toDOM(){return Dc}},strikethrough:{parseDOM:[{tag:"s"},{style:"text-decoration:line-through"}],toDOM(){return Ec}},sub:{parseDOM:[{tag:"sub"}],toDOM(){return Ic}},sup:{parseDOM:[{tag:"sup"}],toDOM(){return Ac}}}},t=new Ue(e);t=new Ue({nodes:Ys(t.spec.nodes,"paragraph block*","block"),marks:t.spec.marks});let n=Cn(Cn({},no(t)),ro(t)),i=[_n(n),_n(Ii),Ai(),Ks(),_s(),So([Co(t),Oo(t),No(t),wo(t),To()]),Do()],s=De("div",{className:"tw-editor"});r.insertAdjacentElement("beforebegin",s);let o=new mn(s,{state:xe.create({doc:yo(t,r.value),plugins:i}),dispatchTransaction:a=>{o.updateState(o.state.apply(a)),l()}}),l=bo(t,o,r);return()=>{try{o.destroy()}catch(a){}s.remove()}}return Bo(Rc);})(); + `,document.body.append(t);let n=t.querySelector("dialog"),i=t.querySelector("form");i.href.value=r.href||"",i.title.value=r.title||"",n.addEventListener("close",()=>{t.remove(),e(null)}),t.querySelector("button[type=submit]").addEventListener("click",s=>{s.preventDefault(),t.remove(),e(i.href.value?{href:i.href.value,title:i.title.value}:null)}),n.showModal()}),xo=(r,e)=>{let{$from:t,empty:n}=r.selection,i=r.schema.marks.link;if(n&&!i.isInSet(t.marks()))return!1;if(e){let s=t.marks().find(o=>o.type===i);Nc((s==null?void 0:s.attrs)||{}).then(o=>{if(console.debug(o),o){let l;if(n)l=Ir(t,i),e(r.tr.removeMark(l.from,l.to,i).addMark(l.from,l.to,i.create(o)));else{let{from:a,to:f}=ko(r.selection);e(r.tr.addMark(a,f,i.create(o)))}}})}return!0},Tc=(r,e)=>{let t=r.schema.marks.link,{$from:n,from:i,to:s}=r.selection,o=Ir(n,t);return o&&o.from<=i&&o.to>=s?(e&&e(r.tr.removeMark(o.from,o.to,t)),!0):!1};function No(r){return[{command:xo,dom:Je("link"),active:xo},{command:Tc,dom:Je("unlink"),active:e=>Mo(e,r.marks.link)}]}function To(){return[{command:Wt,dom:De("span",{className:"prose-menubar__button prose-menubar__button--history-undo"}),active(r){return!1}},{command:bt,dom:De("span",{className:"prose-menubar__button prose-menubar__button--history-redo"}),active(r){return!1}}]}var Rr=class{constructor(e,t){this.items=e.flatMap(n=>n),this.editorView=t,this.dom=De("div",{className:"prose-menubar"}),e.filter(n=>n.length).forEach(n=>{let i=De("div",{className:"prose-menubar__group"});this.dom.append(i),n.forEach(({dom:s})=>i.append(s))}),this.update(),this.dom.addEventListener("mousedown",n=>{n.preventDefault(),t.focus(),this.items.forEach(({command:i,dom:s})=>{s.contains(n.target)&&i(t.state,t.dispatch,t)})})}update(){this.items.forEach(({command:e,dom:t,active:n})=>{let i=e(this.editorView.state,null,this.editorView);t.classList.toggle("disabled",!i),t.classList.toggle("active",n(this.editorView.state)||!1)})}destroy(){this.dom.remove()}};function Do(){return new H({view(r){return new vr(r)}})}var vr=class{constructor(e){this.editorView=e,this.editorView.dom.setAttribute("spellcheck","false")}update(){}destroy(){this.editorView.dom.removeAttribute("spellcheck")}};var Dc=["u",0],Ec=["s",0],Ic=["sub",0],Ac=["sup",0];function Eo(r){let e={nodes:{doc:Te.doc,paragraph:Te.paragraph,heading:Te.heading,blockquote:Te.blockquote,horizontal_rule:Te.horizontal_rule,text:Te.text,hard_break:Te.hard_break},marks:{link:qt.link,strong:qt.strong,em:qt.em,underline:{parseDOM:[{tag:"u"},{style:"text-decoration:underline"}],toDOM(){return Dc}},strikethrough:{parseDOM:[{tag:"s"},{style:"text-decoration:line-through"}],toDOM(){return Ec}},sub:{parseDOM:[{tag:"sub"}],toDOM(){return Ic}},sup:{parseDOM:[{tag:"sup"}],toDOM(){return Ac}}}},t=new Ue(e);t=new Ue({nodes:Ys(t.spec.nodes,"paragraph block*","block"),marks:t.spec.marks});let n=Cn(Cn({},no(t)),ro(t)),i=[_n(n),_n(Ii),Ai(),Ks(),_s(),So([Co(t),Oo(t),No(t),wo(t),To()]),Do()],s=De("div",{className:"prose-editor"});r.insertAdjacentElement("beforebegin",s);let o=new mn(s,{state:xe.create({doc:yo(t,r.value),plugins:i}),dispatchTransaction:a=>{o.updateState(o.state.apply(a)),l()}}),l=bo(t,o,r);return()=>{try{o.destroy()}catch(a){}s.remove()}}return Bo(Rc);})(); diff --git a/src/editor.css b/src/editor.css index dee9d64..3b3a849 100644 --- a/src/editor.css +++ b/src/editor.css @@ -1,78 +1,49 @@ :root { - --tw-editor-font-size: 16px; - --tw-menubar-font-size: 16px; + --prose-editor-font-size: 14px; + --prose-menubar-font-size: 14px; } .ProseMirror { - padding: 4px; + padding: 0 6px; border: 1px solid var(--border-color); border-radius: 4px; } -.tw-editor *, -.tw-editor *::before, -.tw-editor *::after { +.prose-editor *, +.prose-editor *::before, +.prose-editor *::after { box-sizing: inherit; } -.tw-editor { - font-size: var(--tw-editor-font-size); +.prose-editor { + font-size: var(--prose-editor-font-size); box-sizing: border-box; position: relative; flex-grow: 1; } -.tw-editor + textarea, -.tw-hide { +.prose-editor + textarea { display: none; } -/* https://kittygiraudel.com/snippets/sr-only-class/ */ -.tw-sr-only { - border: 0 !important; - clip: rect(1px, 1px, 1px, 1px) !important; - -webkit-clip-path: inset(50%) !important; - clip-path: inset(50%) !important; - height: 1px !important; - overflow: hidden !important; - margin: -1px !important; - padding: 0 !important; - position: absolute !important; - width: 1px !important; - white-space: nowrap !important; -} - -.tw-menubar { - font-size: var(--tw-menubar-font-size); - position: sticky; - top: var(--tw-menubar-top); +.prose-menubar { + font-size: var(--prose-menubar-font-size); background: white; - z-index: 10; display: inline-flex; + gap: 8px; flex-wrap: wrap; - box-shadow: var(--tw-box-shadow); - border-radius: 0.5em; - margin-bottom: 0.25rem; + margin-bottom: 2px; } -.tw-menubar__group { +.prose-menubar__group { display: flex; gap: 2px; } -.tw-menubar__group:not(:last-child)::after { - content: ""; - background-color: var(--tw-secondary-color); - width: 2px; - height: 2em; - margin: 0.25em; -} - -.tw-menubar__button { - color: var(--tw-primary-color); +.prose-menubar__button { cursor: pointer; - padding: 0.25em; + padding: 0 0.25em; min-width: 2em; transition: all 0.25s; border: 1px solid; @@ -80,16 +51,15 @@ text-align: center; } -.tw-menubar__button:hover { - background-color: var(--tw-secondary-color); +.prose-menubar__button:hover { filter: brightness(110%); } -.tw-menubar__button.active { - background-color: var(--tw-secondary-color); +.prose-menubar__button.active { + background-color: var(--primary); } -.tw-menubar__button.disabled { +.prose-menubar__button.disabled { background-color: #acc0cc; filter: brightness(100%); cursor: not-allowed; @@ -97,14 +67,14 @@ } /* history */ -.tw-menubar__button--history-undo, -.tw-menubar__button--history-redo { +.prose-menubar__button--history-undo, +.prose-menubar__button--history-redo { background-image: url(./images/history-arrow.svg); background-repeat: no-repeat; background-size: 1.25em; background-position: center; } -.tw-menubar__button--history-redo { +.prose-menubar__button--history-redo { transform: scaleX(-1); } diff --git a/src/editor.js b/src/editor.js index 7633ebb..797f521 100644 --- a/src/editor.js +++ b/src/editor.js @@ -100,7 +100,7 @@ export function createEditor(textarea) { noSpellCheck(), ] - const editor = crel("div", { className: "tw-editor" }) + const editor = crel("div", { className: "prose-editor" }) textarea.insertAdjacentElement("beforebegin", editor) const editorViewInstance = new EditorView(editor, { diff --git a/src/menu.js b/src/menu.js index 976aea1..41f9918 100644 --- a/src/menu.js +++ b/src/menu.js @@ -24,7 +24,11 @@ function markActive(state, type) { } function menuButtonDOM(textContent, style = "") { - return crel("span", { className: "tw-menubar__button", style, textContent }) + return crel("span", { + className: "prose-menubar__button", + style, + textContent, + }) } export function blockTypeMenuItems(schema) { @@ -116,8 +120,8 @@ const linkDialog = (attrs) => { document.body.append(div) const dialog = div.querySelector("dialog") const form = div.querySelector("form") - form.href.value = attrs.href - form.title.value = attrs.title + form.href.value = attrs.href || "" + form.title.value = attrs.title || "" dialog.addEventListener("close", () => { div.remove() @@ -126,7 +130,11 @@ const linkDialog = (attrs) => { div.querySelector("button[type=submit]").addEventListener("click", (e) => { e.preventDefault() div.remove() - resolve({ href: form.href.value, title: form.title.value }) + resolve( + form.href.value + ? { href: form.href.value, title: form.title.value } + : null + ) }) dialog.showModal() }) @@ -194,7 +202,7 @@ export function historyMenuItems() { { command: undo, dom: crel("span", { - className: "tw-menubar__button tw-menubar__button--history-undo", + className: "prose-menubar__button prose-menubar__button--history-undo", }), active(_state) { return false @@ -203,7 +211,7 @@ export function historyMenuItems() { { command: redo, dom: crel("span", { - className: "tw-menubar__button tw-menubar__button--history-redo", + className: "prose-menubar__button prose-menubar__button--history-redo", }), active(_state) { return false @@ -217,12 +225,12 @@ class MenuView { this.items = itemGroups.flatMap((group) => group) this.editorView = editorView - this.dom = crel("div", { className: "tw-menubar" }) + this.dom = crel("div", { className: "prose-menubar" }) itemGroups .filter((group) => group.length) .forEach((group) => { - const groupDOM = crel("div", { className: "tw-menubar__group" }) + const groupDOM = crel("div", { className: "prose-menubar__group" }) this.dom.append(groupDOM) group.forEach(({ dom }) => groupDOM.append(dom)) })