reactjs-tiptap-editor 0.3.19 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{ActionMenuButton-BPq-R8E7.cjs → ActionMenuButton-BTFBZyG2.cjs} +1 -1
- package/lib/{ActionMenuButton-DCACoSG3.js → ActionMenuButton-DXwnYZhJ.js} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.d.cts +28 -28
- package/lib/Attachment.d.ts +28 -28
- package/lib/Attachment.js +3 -3
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.d.cts +28 -28
- package/lib/Blockquote.d.ts +28 -28
- package/lib/Blockquote.js +2 -2
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.d.cts +28 -28
- package/lib/Bold.d.ts +28 -28
- package/lib/Bold.js +2 -2
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.d.cts +28 -28
- package/lib/BulletList.d.ts +28 -28
- package/lib/BulletList.js +2 -2
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.d.cts +28 -28
- package/lib/Clear.d.ts +28 -28
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.d.cts +28 -28
- package/lib/Code.d.ts +28 -28
- package/lib/Code.js +2 -2
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.d.cts +28 -28
- package/lib/CodeBlock.d.ts +28 -28
- package/lib/CodeBlock.js +3 -3
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.d.cts +28 -28
- package/lib/CodeView.d.ts +28 -28
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.d.cts +28 -28
- package/lib/Color.d.ts +28 -28
- package/lib/Color.js +3 -3
- package/lib/Document.cjs +1 -1
- package/lib/Document.d.cts +28 -28
- package/lib/Document.d.ts +28 -28
- package/lib/Document.js +1 -1
- package/lib/{Drawer-Dwx9V0Xb.cjs → Drawer-BrHHs2E9.cjs} +1 -1
- package/lib/{Drawer-Qh1zEBl3.js → Drawer-CVuwyG50.js} +3 -3
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.d.cts +28 -28
- package/lib/Drawer.d.ts +28 -28
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.d.cts +28 -28
- package/lib/Emoji.d.ts +28 -28
- package/lib/Emoji.js +4 -4
- package/lib/{Excalidraw-BP_-zWZH.cjs → Excalidraw-Be_GDV4Q.cjs} +1 -1
- package/lib/{Excalidraw-DD3P3ClH.js → Excalidraw-frMX4K62.js} +3 -3
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.d.cts +28 -28
- package/lib/Excalidraw.d.ts +28 -28
- package/lib/Excalidraw.js +3 -3
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.d.cts +28 -28
- package/lib/ExportPdf.d.ts +28 -28
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.d.cts +28 -28
- package/lib/ExportWord.d.ts +28 -28
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.d.cts +28 -28
- package/lib/FontFamily.d.ts +28 -28
- package/lib/FontFamily.js +4 -4
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.d.cts +28 -28
- package/lib/FontSize.d.ts +28 -28
- package/lib/FontSize.js +3 -3
- package/lib/FormatPainter.cjs +1 -1
- package/lib/FormatPainter.d.cts +28 -28
- package/lib/FormatPainter.d.ts +28 -28
- package/lib/FormatPainter.js +2 -2
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.d.cts +28 -28
- package/lib/Heading.d.ts +28 -28
- package/lib/Heading.js +3 -3
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.d.cts +28 -28
- package/lib/Highlight.d.ts +28 -28
- package/lib/Highlight.js +2 -2
- package/lib/History.cjs +1 -1
- package/lib/History.d.cts +28 -28
- package/lib/History.d.ts +28 -28
- package/lib/History.js +2 -2
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.d.cts +28 -28
- package/lib/HorizontalRule.d.ts +28 -28
- package/lib/HorizontalRule.js +2 -2
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.d.cts +28 -28
- package/lib/Iframe.d.ts +28 -28
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.d.cts +28 -28
- package/lib/Image.d.ts +28 -28
- package/lib/Image.js +3 -3
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.d.cts +28 -28
- package/lib/ImageGif.d.ts +28 -28
- package/lib/ImageGif.js +3 -3
- package/lib/ImportWord.cjs +74 -74
- package/lib/ImportWord.d.cts +28 -28
- package/lib/ImportWord.d.ts +28 -28
- package/lib/ImportWord.js +5015 -4998
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.d.cts +28 -28
- package/lib/Indent.d.ts +28 -28
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.d.cts +28 -28
- package/lib/Italic.d.ts +28 -28
- package/lib/Italic.js +2 -2
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.d.cts +28 -28
- package/lib/Katex.d.ts +28 -28
- package/lib/Katex.js +4 -4
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.d.cts +28 -28
- package/lib/LineHeight.d.ts +28 -28
- package/lib/LineHeight.js +2 -2
- package/lib/Link.cjs +1 -1
- package/lib/Link.d.cts +28 -28
- package/lib/Link.d.ts +28 -28
- package/lib/Link.js +2 -2
- package/lib/ListItem.cjs +1 -1
- package/lib/ListItem.d.cts +28 -28
- package/lib/ListItem.d.ts +28 -28
- package/lib/ListItem.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.d.cts +28 -28
- package/lib/Mention.d.ts +28 -28
- package/lib/Mention.js +123 -91
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.d.cts +28 -28
- package/lib/Mermaid.d.ts +28 -28
- package/lib/Mermaid.js +4 -4
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.d.cts +28 -28
- package/lib/MoreMark.d.ts +28 -28
- package/lib/MoreMark.js +3 -3
- package/lib/MultiColumn.cjs +1 -1
- package/lib/MultiColumn.d.cts +28 -28
- package/lib/MultiColumn.d.ts +28 -28
- package/lib/MultiColumn.js +2 -2
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.d.cts +28 -28
- package/lib/OrderedList.d.ts +28 -28
- package/lib/OrderedList.js +2 -2
- package/lib/RichTextEditor-CAxwVWUE.cjs +137 -0
- package/lib/{RichTextEditor-DIvPROxl.js → RichTextEditor-DjTnd5Uu.js} +1607 -1603
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.d.cts +28 -28
- package/lib/SearchAndReplace.d.ts +28 -28
- package/lib/SearchAndReplace.js +2 -2
- package/lib/Selection.cjs +1 -1
- package/lib/Selection.d.cts +28 -28
- package/lib/Selection.d.ts +28 -28
- package/lib/Selection.js +1 -1
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.d.cts +28 -28
- package/lib/SlashCommand.d.ts +28 -28
- package/lib/SlashCommand.js +4 -4
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.d.cts +28 -28
- package/lib/Strike.d.ts +28 -28
- package/lib/Strike.js +2 -2
- package/lib/SubAndSuperScript.cjs +1 -1
- package/lib/SubAndSuperScript.d.cts +28 -28
- package/lib/SubAndSuperScript.d.ts +28 -28
- package/lib/SubAndSuperScript.js +3 -3
- package/lib/Table.cjs +1 -1
- package/lib/Table.d.cts +28 -28
- package/lib/Table.d.ts +28 -28
- package/lib/Table.js +2 -2
- package/lib/TableOfContent.cjs +1 -1
- package/lib/TableOfContent.d.cts +28 -28
- package/lib/TableOfContent.d.ts +28 -28
- package/lib/TableOfContent.js +3 -3
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.d.cts +28 -28
- package/lib/TaskList.d.ts +28 -28
- package/lib/TaskList.js +37 -33
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.d.cts +28 -28
- package/lib/TextAlign.d.ts +28 -28
- package/lib/TextAlign.js +2 -2
- package/lib/TextBubble.cjs +1 -1
- package/lib/TextBubble.d.cts +28 -28
- package/lib/TextBubble.d.ts +28 -28
- package/lib/TextBubble.js +2 -2
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.d.cts +28 -28
- package/lib/TextDirection.d.ts +28 -28
- package/lib/TextDirection.js +2 -2
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.d.cts +28 -28
- package/lib/TextUnderline.d.ts +28 -28
- package/lib/TextUnderline.js +2 -2
- package/lib/TrailingNode.cjs +1 -1
- package/lib/TrailingNode.d.cts +28 -28
- package/lib/TrailingNode.d.ts +28 -28
- package/lib/TrailingNode.js +1 -1
- package/lib/{Twitter-Bl5HyIX0.cjs → Twitter-V0OzBT_E.cjs} +1 -1
- package/lib/{Twitter-raSi7ATg.js → Twitter-dRxbZOad.js} +3 -3
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.d.cts +28 -28
- package/lib/Twitter.d.ts +28 -28
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.d.cts +28 -28
- package/lib/Video.d.ts +28 -28
- package/lib/Video.js +2 -2
- package/lib/bubble-extra.cjs +2 -2
- package/lib/bubble-extra.d.cts +28 -28
- package/lib/bubble-extra.d.ts +28 -28
- package/lib/bubble-extra.js +25 -25
- package/lib/{dom-dataset-Cuy-pIfj.cjs → dom-dataset-Byuf1YmW.cjs} +5 -5
- package/lib/{dom-dataset-CHDbKz5J.js → dom-dataset-Di3tIRrR.js} +94 -83
- package/lib/index-BI-IcZcN.cjs +1 -0
- package/lib/{index-CSvnpArE.cjs → index-ByRfqzMr.cjs} +2 -2
- package/lib/{index-DIPntess.js → index-C1fzuXpN.js} +1 -1
- package/lib/index-CbQQFj2T.js +133 -0
- package/lib/{index-BWx1Mchx.js → index-DI9T3iLd.js} +243 -243
- package/lib/{index-CrxasX7b.cjs → index-DclQSrIx.cjs} +1 -1
- package/lib/{index-DEFQHExY.js → index-LUL9mqY4.js} +1 -1
- package/lib/{index-h9_SDuwc.cjs → index-Z4b9rzn-.cjs} +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.cts +28 -28
- package/lib/index.d.ts +28 -28
- package/lib/index.js +5 -5
- package/lib/locale-bundle.d.cts +28 -28
- package/lib/locale-bundle.d.ts +28 -28
- package/lib/{textarea-DnBlTntN.js → textarea-6c8drwXJ.js} +1 -1
- package/lib/{textarea-DgXP0XRK.cjs → textarea-BsJTSgT-.cjs} +1 -1
- package/package.json +67 -67
- package/lib/RichTextEditor-DszaQdvS.cjs +0 -141
- package/lib/index-Cyh1yoFk.cjs +0 -1
- package/lib/index-oQutU45z.js +0 -129
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
`);return{dom:a,text:u,slice:e}}function Ss(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 k(b.from(r.state.schema.text(e.replace(/\r\n?/g,`
|
|
9
9
|
`))),0,0):k.empty;let d=r.someProp("clipboardTextParser",u=>u(e,i,n,r));if(d)l=d;else{let u=i.marks(),{schema:h}=r.state,p=We.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=o.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,u)))})}}else r.someProp("transformPastedHTML",d=>{t=d(t,r)}),o=ea(t),Mt&&ta(o);let c=o&&o.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let d=+f[3];d>0;d--){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")||Se.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!Xl.test(u.parentNode.nodeName)?{ignore:!0}:null}})),f)l=na(ri(l,+f[1],+f[2]),f[4]);else if(l=k.maxOpen(Zl(l.content,i),!0),l.openStart||l.openEnd){let d=0,u=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;u<l.openEnd&&!h.type.spec.isolating;u++,h=h.lastChild);l=ri(l,d,u)}return r.someProp("transformPasted",d=>{l=d(l,r)}),l}const Xl=/^(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 Zl(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),c;if(!a)return o=null;if(c=o.length&&s.length&&Cs(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ws(o[o.length-1],s.length));let f=Ms(l,a);o.push(f),i=i.matchType(f.type),s=a}}),o)return b.from(o)}return r}function Ms(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,b.from(r));return r}function Cs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=Cs(r,e,t,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(b.from(Ms(t,r,i+1))))}}function ws(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,ws(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(b.empty,!0);return r.copy(t.append(n))}function Kn(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return r.childCount>1&&(s=0),i<n-1&&(l=Kn(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function ri(r,e,t){return e<r.openStart&&(r=new k(Kn(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new k(Kn(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const Os={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ii=null;function Ns(){return ii||(ii=document.implementation.createHTMLDocument("title"))}let Cn=null;function Ql(r){let e=window.trustedTypes;return e?(Cn||(Cn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Cn.createHTML(r)):r}function ea(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=Ns().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&Os[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Ql(r),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function ta(r){let e=r.querySelectorAll(W?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function na(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:s,openEnd:o}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=b.from(a.create(n[l+1],i)),s++,o++}return new k(i,s,o)}const K={},H={},ra={touchstart:!0,touchmove:!0};class ia{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.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,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 sa(r){for(let e in K){let t=K[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{la(r,n)&&!sr(r,n)&&(r.editable||!(n.type in H))&&t(r,n)},ra[e]?{passive:!0}:void 0)}q&&r.dom.addEventListener("input",()=>null),Hn(r)}function xe(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function oa(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 Hn(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 la(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 aa(r,e){!sr(r,e)&&K[e.type]&&(r.editable||!(e.type in H))&&K[e.type](r,e)}H.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!Es(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(ce&&W&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),Qe&&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,Ae(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||_l(r,t)?t.preventDefault():xe(r,"key")};H.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};H.keypress=(r,e)=>{let t=e;if(Es(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||X&&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 en(r){return{left:r.clientX,top:r.clientY}}function ca(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function or(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 _e(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function fa(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&S.isSelectable(n)?(_e(r,new S(t)),!0):!1}function da(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof S&&(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(S.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?(_e(r,S.create(r.state.doc,i)),!0):!1}function ua(r,e,t,n,i){return or(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?da(r,t):fa(r,t))}function ha(r,e,t,n){return or(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function pa(r,e,t,n){return or(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||ma(r,t,n)}function ma(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(_e(r,O.create(n,0,n.content.size)),!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)_e(r,O.create(n,l+1,l+1+o.content.size));else if(S.isSelectable(o))_e(r,S.create(n,l));else continue;return!0}}function lr(r){return Wt(r)}const Ts=X?"metaKey":"ctrlKey";K.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=lr(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&ca(t,r.input.lastClick)&&!t[Ts]&&(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(en(t));o&&(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new ga(r,o,t,!!n)):(s=="doubleClick"?ha:pa)(r,o.pos,o.inside,t)?t.preventDefault():xe(r,"pointer"))};class ga{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[Ts],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let f=e.state.doc.resolve(t.pos);s=f.parent,o=f.depth?f.before():0}const l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(n.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof S&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ne&&!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)),xe(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(()=>he(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(en(e))),this.updateAllowDefault(e),this.allowDefault||!t?xe(this.view,"pointer"):ua(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||q&&this.mightDrag&&!this.mightDrag.node.isAtom||W&&!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)?(_e(this.view,N.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):xe(this.view,"pointer")}move(e){this.updateAllowDefault(e),xe(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(),lr(r),xe(r,"pointer")};K.touchmove=r=>{r.input.lastTouch=Date.now(),xe(r,"pointer")};K.contextmenu=r=>lr(r);function Es(r,e){return r.composing?!0:q&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const ya=ce?5e3:-1;H.compositionstart=H.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof O&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),Wt(r,!0),r.markCursor=null;else if(Wt(r,!e.selection.empty),ne&&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){let l=r.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}Ds(r,ya)};H.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.compositionNode=null,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,Ds(r,20))};function Ds(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>Wt(r),e))}function As(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=ka());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function ba(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=fl(e.focusNode,e.focusOffset),n=dl(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,s=r.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function ka(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function Wt(r,e=!1){if(!(ce&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),As(r),e||r.docView&&r.docView.dirty){let t=nr(r);return t&&!t.eq(r.state.selection)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!r.state.selection.empty?r.dispatch(r.state.tr.deleteSelection()):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)}const mt=Y&&Me<15||Qe&&gl<604;K.copy=H.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=mt?null:t.clipboardData,o=n.content(),{dom:l,text:a}=ir(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 Sa(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Ma(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?gt(r,n.value,null,i,e):gt(r,n.textContent,n.innerHTML,i,e)},50)}function gt(r,e,t,n,i){let s=Ss(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||k.empty)))return!0;if(!s)return!1;let o=Sa(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 Is(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," "):""}H.paste=(r,e)=>{let t=e;if(r.composing&&!ce)return;let n=mt?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&>(r,Is(n),n.getData("text/html"),i,t)?t.preventDefault():Ma(r,t)};class Rs{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const vs=X?"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(en(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof S?i.to-1:i.to))){if(n&&n.mightDrag)o=S.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=r.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=r.docView&&(o=S.create(r.state.doc,d.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:c,slice:f}=ir(r,l);(!t.dataTransfer.files.length||!W||is>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(mt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",mt||t.dataTransfer.setData("text/plain",c),r.dragging=new Rs(f,!t[vs],o)};K.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};H.dragover=H.dragenter=(r,e)=>e.preventDefault();H.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords(en(t));if(!i)return;let s=r.state.doc.resolve(i.pos),o=n&&n.slice;o?r.someProp("transformPasted",p=>{o=p(o,r)}):o=Ss(r,Is(t.dataTransfer),mt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&!t[vs]);if(r.someProp("handleDrop",p=>p(r,t,o||k.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?Yi(r.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=r.state.tr;if(l){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let f=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,u=c.doc;if(d?c.replaceRangeWith(f,f,o.content.firstChild):c.replaceRange(f,f,o),c.doc.eq(u))return;let h=c.doc.resolve(f);if(d&&S.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new S(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,M)=>p=M),c.setSelection(rr(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.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())&&he(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(W&&ce&&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,Ae(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 H)K[r]=H[r];function yt(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}class Jt{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 Q(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Jt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&yt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class we{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 Q(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof we&&yt(this.attrs,e.attrs)&&yt(this.spec,e.spec)}static is(e){return e.type instanceof we}destroy(){}}class ar{constructor(e,t){this.attrs=e,this.spec=t||ze}map(e,t,n,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Q(s.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(n)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof ar&&yt(this.attrs,e.attrs)&&yt(this.spec,e.spec)}destroy(){}}class Q{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Q(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Q(e,e,new Jt(t,n))}static inline(e,t,n,i){return new Q(e,t,new we(n,i))}static node(e,t,n,i){return new Q(e,t,new ar(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof we}get widget(){return this.type instanceof Jt}}const Ke=[],ze={};class v{constructor(e,t){this.local=e.length?e:Ke,this.children=t.length?t:Ke}static create(e,t){return t.length?jt(t,e,0,ze):$}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){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==$||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<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Ca(this.children,o||[],e,t,n,i,s):o?new v(o.sort(Fe),Ke):$}add(e,t){return t.length?this==$?v.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,s=0;e.forEach((l,a)=>{let c=a+n,f;if(f=Bs(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,f,c+1):i.splice(s,0,a,a+l.nodeSize,jt(f,l,c+1,ze)),s+=3}});let o=Ps(s?zs(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new v(o.length?this.local.concat(o).sort(Fe):this.local,i||this.children)}remove(e){return e.length==0||this==$?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let s=0;s<n.length;s+=3){let o,l=n[s]+t,a=n[s+1]+t;for(let f=0,d;f<e.length;f++)(d=e[f])&&d.from>l&&d.to<a&&(e[f]=null,(o||(o=[])).push(d));if(!o)continue;n==this.children&&(n=this.children.slice());let c=n[s+2].removeInner(o,l+1);c!=$?n[s+2]=c:(n.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new v(i,n):$}forChild(e,t){if(this==$)return this;if(t.isLeaf)return v.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof we){let c=Math.max(s,a.from)-s,f=Math.min(o,a.to)-s;c<f&&(i||(i=[])).push(a.copy(c,f))}}if(i){let l=new v(i.sort(Fe),Ke);return n?new ye([l,n]):l}return n||$}eq(e){if(this==e)return!0;if(!(e instanceof v)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return cr(this.localsInner(e))}localsInner(e){if(this==$)return Ke;if(e.inlineContent||!this.local.some(we.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof we||t.push(this.local[n]);return t}forEachSet(e){e(this)}}v.empty=new v([],[]);v.removeOverlap=cr;const $=v.empty;class ye{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,ze));return ye.from(n)}forChild(e,t){if(t.isLeaf)return v.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=$&&(s instanceof ye?n=n.concat(s.members):n.push(s))}return ye.from(n)}eq(e){if(!(e instanceof ye)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?cr(n?t:t.sort(Fe)):Ke}static from(e){switch(e.length){case 0:return $;case 1:return e[0];default:return new ye(e.every(t=>t instanceof v)?e:e.reduce((t,n)=>t.concat(n instanceof v?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Ca(r,e,t,n,i,s,o){let l=r.slice();for(let c=0,f=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((u,h,p,m)=>{let g=m-p-(h-u);for(let y=0;y<l.length;y+=3){let M=l[y+1];if(M<0||u>M+f-d)continue;let C=l[y]+f-d;h>=C?l[y+1]=u<=C?-2:-1:u>=f&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let f=t.map(r[c]+s),d=f-i;if(d<0||d>=n.content.size){a=!0;continue}let u=t.map(r[c+1]+s,-1),h=u-i,{index:p,offset:m}=n.content.findIndex(d),g=n.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,f+1,r[c]+s+1,o);y!=$?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=wa(l,r,e,t,i,s,o),f=jt(c,n,0,o);e=f.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,u=0;d<f.children.length;d+=3){let h=f.children[d];for(;u<l.length&&l[u]<h;)u+=3;l.splice(u,0,f.children[d],f.children[d+1],f.children[d+2])}}return new v(e.sort(Fe),l)}function Ps(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new Q(i.from+e,i.to+e,i.type))}return t}function wa(r,e,t,n,i,s,o){function l(a,c){for(let f=0;f<a.local.length;f++){let d=a.local[f].map(n,i,c);d?t.push(d):o.onRemove&&o.onRemove(a.local[f].spec)}for(let f=0;f<a.children.length;f+=3)l(a.children[f+2],a.children[f]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+s+1);return t}function Bs(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let s=0,o;s<r.length;s++)(o=r[s])&&o.from>t&&o.to<n&&((i||(i=[])).push(o),r[s]=null);return i}function zs(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function jt(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let c=Bs(r,l,a+t);if(c){s=!0;let f=jt(c,l,t+a+1,n);f!=$&&i.push(a,a+l.nodeSize,f)}});let o=Ps(s?zs(r):r,-t).sort(Fe);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(n.onRemove&&n.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new v(o,i):$}function Fe(r,e){return r.from-e.from||r.to-e.to}function cr(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==n.from){s.to!=n.to&&(e==r&&(e=r.slice()),e[i]=s.copy(s.from,n.to),si(e,i+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,s.from),si(e,i,n.copy(s.from,n.to)));break}}}return e}function si(r,e,t){for(;e<r.length&&Fe(t,r[e])>0;)e++;r.splice(e,0,t)}function wn(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=$&&e.push(n)}),r.cursorWrapper&&e.push(v.create(r.state.doc,[r.cursorWrapper.deco])),ye.from(e)}const Oa={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Na=Y&&Me<=11;class Ta{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}}class Ea{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ta,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);Y&&Me<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Na&&(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,Oa)),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;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.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(Xr(this.view)){if(this.suppressingSelectionUpdates)return he(this.view);if(Y&&Me<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Le(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)&&Xr(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let f=0;f<t.length;f++){let d=this.registerMutation(t[f],a);d&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(ne&&a.length){let f=a.filter(d=>d.nodeName=="BR");if(f.length==2){let[d,u]=f;d.parentNode&&d.parentNode.parentNode==u.parentNode?u.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let u of f){let h=u.parentNode;h&&h.nodeName=="LI"&&(!d||Ia(e,d)!=h)&&u.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Zt(n)&&(c=nr(e))&&c.eq(N.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,he(e),this.currentSelection.set(n)):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Da(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||he(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 f=0;f<e.addedNodes.length;f++){let d=e.addedNodes[f];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Y&&Me<=11&&e.addedNodes.length)for(let f=0;f<e.addedNodes.length;f++){let{previousSibling:d,nextSibling:u}=e.addedNodes[f];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u)}let o=i&&i.parentNode==e.target?V(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?V(s):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let oi=new WeakMap,li=!1;function Da(r){if(!oi.has(r)&&(oi.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=ne,li)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),li=!0}}function ai(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.domAtPos(r.state.selection.anchor);return Le(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function Aa(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return ai(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?ai(r,t):null}function Ia(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Ra(r,e,t){let{node:n,fromOffset:i,toOffset:s,from:o,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,f=a.anchorNode;if(f&&r.dom.contains(f.nodeType==1?f:f.parentNode)&&(c=[{node:f,offset:a.anchorOffset}],Zt(a)||c.push({node:a.focusNode,offset:a.focusOffset})),W&&r.input.lastKeyCode===8)for(let g=s;g>i;g--){let y=n.childNodes[g-1],M=y.pmViewDesc;if(y.nodeName=="BR"&&!M){s=g;break}if(!M||M.size)break}let d=r.state.doc,u=r.someProp("domParser")||Se.fromSchema(r.state.schema),h=d.resolve(o),p=null,m=u.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:va,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+o,head:y+o}}return{doc:m,sel:p,from:o,to:l}}function va(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}const Pa=/^(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 Ba(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let T=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,pe=nr(r,T);if(pe&&!r.state.selection.eq(pe)){if(W&&ce&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",ho=>ho(r,Ae(13,"Enter"))))return;let wt=r.state.tr.setSelection(pe);T=="pointer"?wt.setMeta("pointer",!0):T=="key"&&wt.scrollIntoView(),s&&wt.setMeta("composition",s),r.dispatch(wt)}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,c=Ra(r,e,t),f=r.state.doc,d=f.slice(c.from,c.to),u,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(u=r.state.selection.to,h="end"):(u=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=Va(d.content,c.doc.content,c.from,u,h);if(p&&r.input.domChangeCount++,(Qe&&r.input.lastIOSEnter>Date.now()-225||ce)&&i.some(T=>T.nodeType==1&&!Pa.test(T.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",T=>T(r,Ae(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof O&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=ci(r,r.state.doc,c.sel);if(T&&!T.eq(r.state.selection)){let pe=r.state.tr.setSelection(T);s&&pe.setMeta("composition",s),r.dispatch(pe)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof O&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),Y&&Me<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=f.resolve(p.start),M=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,C;if((Qe&&r.input.lastIOSEnter>Date.now()-225&&(!M||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!M&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(C=N.findFrom(c.doc.resolve(m.pos+1),1,!0))&&C.head==g.pos)&&r.someProp("handleKeyDown",T=>T(r,Ae(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&Fa(f,p.start,p.endA,m,g)&&r.someProp("handleKeyDown",T=>T(r,Ae(8,"Backspace")))){ce&&W&&r.domObserver.suppressSelectionUpdates();return}W&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),ce&&!M&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(T){return T(r,Ae(13,"Enter"))})},20));let D=p.start,E=p.endA,A,U,j;if(M){if(m.pos==g.pos)Y&&Me<=11&&m.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>he(r),20)),A=r.state.tr.delete(D,E),U=f.resolve(p.start).marksAcross(f.resolve(p.endA));else if(p.endA==p.endB&&(j=za(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))A=r.state.tr,j.type=="add"?A.addMark(D,E,j.mark):A.removeMark(D,E,j.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(r.someProp("handleTextInput",pe=>pe(r,D,E,T)))return;A=r.state.tr.insertText(T,D,E)}}if(A||(A=r.state.tr.replace(D,E,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=ci(r,A.doc,c.sel);T&&!(W&&r.composing&&T.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(T.head==D||T.head==A.mapping.map(E)-1)||Y&&T.empty&&T.head==D)&&A.setSelection(T)}U&&A.ensureMarks(U),s&&A.setMeta("composition",s),r.dispatch(A.scrollIntoView())}function ci(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:rr(r,e.resolve(t.anchor),e.resolve(t.head))}function za(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let f=0;f<n.length;f++)i=n[f].removeFromSet(i);for(let f=0;f<t.length;f++)s=t[f].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=f=>f.mark(l.addToSet(f.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;f<e.childCount;f++)c.push(a(e.child(f)));if(b.from(c).eq(r))return{mark:l,type:o}}function Fa(r,e,t,n,i){if(t-e<=i.pos-n.pos||On(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(!n.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(On(s,!0,!0));return!o.parent.isTextblock||o.pos>t||On(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function On(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>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 Va(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<s&&r.size<e.size){let a=n<=s&&n>=o?s-n:0;s-=a,s&&s<e.size&&fi(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,s&&s<r.size&&fi(r.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function fi(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class La{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 ia,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(mi),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=hi(this),ui(this),this.nodeViews=pi(this),this.docView=Kr(this.state.doc,di(this),wn(this),this.dom,this),this.domObserver=new Ea(this,(n,i,s,o)=>Ba(this,n,i,s,o)),this.domObserver.start(),sa(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&&Hn(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(mi),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&&(As(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 h=pi(this);Wa(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Hn(this),this.editable=hi(this),ui(this);let a=wn(this),c=di(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let u=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&kl(this);if(o){this.domObserver.stop();let h=d&&(Y||W)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&$a(i.selection,e.selection);if(d){let p=W?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ba(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Kr(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&jl(this))?he(this,h):(bs(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():u&&xl(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof S){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Lr(this,t.getBoundingClientRect(),e)}else Lr(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;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new Rs(e.slice,e.move,i<0?void 0:S.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;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(Y){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Sl(this.dom),he(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Nl(this,e)}coordsAtPos(e,t=1){return fs(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 Il(this,t||this.state,e)}pasteHTML(e,t){return gt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return gt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ir(this,e)}destroy(){this.docView&&(oa(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,al())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return aa(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?q&&this.root.nodeType===11&&hl(this.dom.ownerDocument)==this.dom&&Aa(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function di(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"),[Q.node(0,r.state.doc.content.size,e)]}function ui(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:Q.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function hi(r){return!r.someProp("editable",e=>e(r.state)===!1)}function $a(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 pi(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 Wa(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 mi(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 Oe={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},qt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ja=typeof navigator<"u"&&/Mac/.test(navigator.platform),ja=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var L=0;L<10;L++)Oe[48+L]=Oe[96+L]=String(L);for(var L=1;L<=24;L++)Oe[L+111]="F"+L;for(var L=65;L<=90;L++)Oe[L]=String.fromCharCode(L+32),qt[L]=String.fromCharCode(L);for(var Nn in Oe)qt.hasOwnProperty(Nn)||(qt[Nn]=Oe[Nn]);function qa(r){var e=Ja&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||ja&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?qt:Oe)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Ka=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ha(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Ka?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Ua(r){let e=Object.create(null);for(let t in r)e[Ha(t)]=r[t];return e}function Tn(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Ga(r){return new re({props:{handleKeyDown:Fs(r)}})}function Fs(r){let e=Ua(r);return function(t,n){let i=qa(n),s,o=e[Tn(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[Tn(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||i.charCodeAt(0)>127)&&(s=Oe[n.keyCode])&&s!=i){let l=e[Tn(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const tn=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Vs(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Ls=(r,e,t)=>{let n=Vs(r,t);if(!n)return!1;let i=fr(n);if(!i){let o=n.blockRange(),l=o&&tt(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(Gs(r,i,e,-1))return!0;if(n.parent.content.size==0&&(et(s,"end")||S.isSelectable(s)))for(let o=n.depth;;o--){let l=_t(r.doc,n.before(o),n.after(o),k.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(et(s,"end")?N.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):S.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Ya=(r,e,t)=>{let n=Vs(r,t);if(!n)return!1;let i=fr(n);return i?$s(r,i,e):!1},_a=(r,e,t)=>{let n=Js(r,t);if(!n)return!1;let i=dr(n);return i?$s(r,i,e):!1};function $s(r,e,t){let n=e.nodeBefore,i=n,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let f=i.lastChild;if(!f)return!1;i=f}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let f=l.firstChild;if(!f)return!1;l=f}let c=_t(r.doc,s,a,k.empty);if(!c||c.from!=s||c instanceof P&&c.slice.size>=a-s)return!1;if(t){let f=r.tr.step(c);f.setSelection(O.create(f.doc,s)),t(f.scrollIntoView())}return!0}function et(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const Ws=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=fr(n)}let o=s&&s.nodeBefore;return!o||!S.isSelectable(o)?!1:(e&&e(r.tr.setSelection(S.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function fr(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Js(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const js=(r,e,t)=>{let n=Js(r,t);if(!n)return!1;let i=dr(n);if(!i)return!1;let s=i.nodeAfter;if(Gs(r,i,e,1))return!0;if(n.parent.content.size==0&&(et(s,"start")||S.isSelectable(s))){let o=_t(r.doc,n.before(),n.after(),k.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(et(s,"start")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):S.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},qs=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=dr(n)}let o=s&&s.nodeAfter;return!o||!S.isSelectable(o)?!1:(e&&e(r.tr.setSelection(S.create(r.doc,s.pos)).scrollIntoView()),!0)};function dr(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Xa=(r,e)=>{let t=r.selection,n=t instanceof S,i;if(n){if(t.node.isTextblock||!Ne(r.doc,t.from))return!1;i=t.from}else if(i=Yt(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(S.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Za=(r,e)=>{let t=r.selection,n;if(t instanceof S){if(t.node.isTextblock||!Ne(r.doc,t.to))return!1;n=t.to}else if(n=Yt(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Qa=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&tt(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},Ks=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
10
10
|
`).scrollIntoView()),!0)};function ur(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const ec=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=ur(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Hs=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof G||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=ur(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(O.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Us=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(ue(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&tt(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function tc(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof S&&e.selection.node.isBlock)return!n.parentOffset||!ue(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=ur(n.node(h-1).contentMatchAt(n.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),o=h;break}else{if(h==1)return!1;s.unshift(null)}let f=e.tr;(e.selection instanceof O||e.selection instanceof G)&&f.deleteSelection();let d=f.mapping.map(n.pos),u=ue(f.doc,d,s.length,s);if(u||(s[0]=l?{type:l}:null,u=ue(f.doc,d,s.length,s)),f.split(d,s.length,s),!a&&c&&n.node(o).type!=l){let h=f.mapping.map(n.before(o)),p=f.doc.resolve(h);l&&n.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&f.setNodeMarkup(f.mapping.map(n.before(o)),l)}return t&&t(f.scrollIntoView()),!0}}const nc=tc(),rc=(r,e)=>{let{$from:t,to:n}=r.selection,i,s=t.sharedDepth(n);return s==0?!1:(i=t.before(s),e&&e(r.tr.setSelection(S.create(r.doc,i))),!0)};function ic(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Ne(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function Gs(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&ic(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=b.empty;for(let y=o.length-1;y>=0;y--)p=b.from(o[y].create(null,p));p=b.from(i.copy(p));let m=r.tr.step(new B(e.pos-1,h,e.pos,h,new k(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ne(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||n>0&&a?null:N.findFrom(e,1),d=f&&f.$from.blockRange(f.$to),u=d&&tt(d);if(u!=null&&u>=e.depth)return t&&t(r.tr.lift(d,u).scrollIntoView()),!0;if(c&&et(s,"start",!0)&&et(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=b.empty;for(let C=p.length-1;C>=0;C--)y=b.from(p[C].copy(y));let M=r.tr.step(new B(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new k(y,p.length,0),0,!0));t(M.scrollIntoView())}return!0}}return!1}function Ys(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(O.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const sc=Ys(-1),oc=Ys(1);function lc(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&Zn(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function gi(r,e=null){return function(t,n){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(r,e)))if(a.type==r)i=!0;else{let f=t.doc.resolve(c),d=f.index();i=f.parent.canReplaceWith(d,d+1,r)}})}if(!i)return!1;if(n){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,r,e)}n(s.scrollIntoView())}return!0}}function hr(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}hr(tn,Ls,Ws);hr(tn,js,qs);hr(Ks,Hs,Us,nc);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function ac(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s);if(!o)return!1;let l=n?t.tr:null;return cc(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function cc(r,e,t,n=null){let i=!1,s=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);s=new dt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new dt(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=Zn(s,t,n,e);return l?(r&&fc(r,e,l,i,t),!0):!1}function fc(r,e,t,n,i){let s=b.empty;for(let f=t.length-1;f>=0;f--)s=b.from(t[f].type.create(t[f].attrs,s));r.step(new B(e.start-(n?2:0),e.end,e.start,e.end,new k(s,0,0),t.length,!0));let o=0;for(let f=0;f<t.length;f++)t[f].type==i&&(o=f+1);let l=t.length-o,a=e.start+t.length-(n?2:0),c=e.parent;for(let f=e.startIndex,d=e.endIndex,u=!0;f<d;f++,u=!1)!u&&ue(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return r}function dc(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?uc(e,t,r,s):hc(e,t,s):!0:!1}}function uc(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new B(s-1,o,s,o,new k(b.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new dt(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=tt(n);if(l==null)return!1;i.lift(n,l);let a=i.mapping.map(s,-1)-1;return Ne(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function hc(r,e,t){let n=r.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=i.child(p).nodeSize,n.delete(h-1,h+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,c=s.node(-1),f=s.index(-1);if(!c.canReplace(f+(l?0:1),f+1,o.content.append(a?b.empty:b.from(i))))return!1;let d=s.pos,u=d+o.nodeSize;return n.step(new B(d-(l?1:0),u+(a?1:0),d+1,u-1,new k((l?b.empty:b.from(i.copy(b.empty))).append(a?b.empty:b.from(i.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function pc(r){return function(e,t){let{$from:n,$to:i}=e.selection,s=n.blockRange(i,c=>c.childCount>0&&c.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 c=a.lastChild&&a.lastChild.type==l.type,f=b.from(c?r.create():null),d=new k(b.from(r.create(null,b.from(l.type.create(null,f)))),c?3:1,0),u=s.start,h=s.end;t(e.tr.step(new B(u-(c?3:1),h,u,h,d,1,!0)).scrollIntoView())}return!0}}function nn(r){const{state:e,transaction:t}=r;let{selection:n}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return n},get doc(){return i},get tr(){return n=t.selection,i=t.doc,s=t.storedMarks,t}}}class rn{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...f)=>{const d=a(...f)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,f=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,h])=>[u,(...m)=>{const g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),d}])),run:f};return d}createCan(e){const{rawCommands:t,state:n}=this,i=!1,s=e||n.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...f)=>c(...f)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:n,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:nn({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([a,c])=>[a,(...f)=>c(...f)(l)]))}};return l}}class mc{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const n=this.callbacks[e];return n&&n.forEach(i=>i.apply(this,t)),this}off(e,t){const n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const n=(...i)=>{this.off(e,n),t.apply(this,i)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}}function x(r,e,t){return r.config[e]===void 0&&r.parent?x(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?x(r.parent,e,t):null}):r.config[e]}function sn(r){const e=r.filter(i=>i.type==="extension"),t=r.filter(i=>i.type==="node"),n=r.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:n}}function _s(r){const e=[],{nodeExtensions:t,markExtensions:n}=sn(r),i=[...t,...n],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return r.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:i},a=x(o,"addGlobalAttributes",l);if(!a)return;a().forEach(f=>{f.types.forEach(d=>{Object.entries(f.attributes).forEach(([u,h])=>{e.push({type:d,name:u,attribute:{...s,...h}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=x(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([f,d])=>{const u={...s,...d};typeof(u==null?void 0:u.default)=="function"&&(u.default=u.default()),u!=null&&u.isRequired&&(u==null?void 0:u.default)===void 0&&delete u.default,e.push({type:o.name,name:f,attribute:u})})}),e}function z(r,e){if(typeof r=="string"){if(!e.nodes[r])throw Error(`There is no node type named '${r}'. Maybe you forgot to add the extension?`);return e.nodes[r]}return r}function Xs(...r){return r.filter(e=>!!e).reduce((e,t)=>{const n={...e};return Object.entries(t).forEach(([i,s])=>{if(!n[i]){n[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],a=n[i]?n[i].split(" "):[],c=l.filter(f=>!a.includes(f));n[i]=[...a,...c].join(" ")}else if(i==="style"){const l=s?s.split(";").map(f=>f.trim()).filter(Boolean):[],a=n[i]?n[i].split(";").map(f=>f.trim()).filter(Boolean):[],c=new Map;a.forEach(f=>{const[d,u]=f.split(":").map(h=>h.trim());c.set(d,u)}),l.forEach(f=>{const[d,u]=f.split(":").map(h=>h.trim());c.set(d,u)}),n[i]=Array.from(c.entries()).map(([f,d])=>`${f}: ${d}`).join("; ")}else n[i]=s}),n},{})}function Kt(r,e){return e.filter(t=>t.type===r.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(r.attrs)||{}:{[t.name]:r.attrs[t.name]}).reduce((t,n)=>Xs(t,n),{})}function Zs(r){return typeof r=="function"}function w(r,e=void 0,...t){return Zs(r)?e?r.bind(e)(...t):r(...t):r}function gc(r={}){return Object.keys(r).length===0&&r.constructor===Object}function yc(r){return typeof r!="string"?r:r.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(r):r==="true"?!0:r==="false"?!1:r}function yi(r,e){return"style"in r?r:{...r,getAttrs:t=>{const n=r.getAttrs?r.getAttrs(t):r.attrs;if(n===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):yc(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...n,...i}}}}function bi(r){return Object.fromEntries(Object.entries(r).filter(([e,t])=>e==="attrs"&&gc(t)?!1:t!=null))}function bc(r,e){var t;const n=_s(r),{nodeExtensions:i,markExtensions:s}=sn(r),o=(t=i.find(c=>x(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(i.map(c=>{const f=n.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},u=r.reduce((y,M)=>{const C=x(M,"extendNodeSchema",d);return{...y,...C?C(c):{}}},{}),h=bi({...u,content:w(x(c,"content",d)),marks:w(x(c,"marks",d)),group:w(x(c,"group",d)),inline:w(x(c,"inline",d)),atom:w(x(c,"atom",d)),selectable:w(x(c,"selectable",d)),draggable:w(x(c,"draggable",d)),code:w(x(c,"code",d)),whitespace:w(x(c,"whitespace",d)),linebreakReplacement:w(x(c,"linebreakReplacement",d)),defining:w(x(c,"defining",d)),isolating:w(x(c,"isolating",d)),attrs:Object.fromEntries(f.map(y=>{var M;return[y.name,{default:(M=y==null?void 0:y.attribute)===null||M===void 0?void 0:M.default}]}))}),p=w(x(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>yi(y,f)));const m=x(c,"renderHTML",d);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:Kt(y,f)}));const g=x(c,"renderText",d);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(s.map(c=>{const f=n.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},u=r.reduce((g,y)=>{const M=x(y,"extendMarkSchema",d);return{...g,...M?M(c):{}}},{}),h=bi({...u,inclusive:w(x(c,"inclusive",d)),excludes:w(x(c,"excludes",d)),group:w(x(c,"group",d)),spanning:w(x(c,"spanning",d)),code:w(x(c,"code",d)),attrs:Object.fromEntries(f.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))}),p=w(x(c,"parseHTML",d));p&&(h.parseDOM=p.map(g=>yi(g,f)));const m=x(c,"renderHTML",d);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:Kt(g,f)})),[c.name,h]}));return new Vi({topNode:o,nodes:l,marks:a})}function En(r,e){return e.nodes[r]||e.marks[r]||null}function ki(r,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===r.name):e}function pr(r,e){const t=We.fromSchema(e).serializeFragment(r),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const kc=(r,e=500)=>{let t="";const n=r.parentOffset;return r.parent.nodesBetween(Math.max(0,n-e),n,(i,s,o,l)=>{var a,c;const f=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?f:f.slice(0,Math.max(0,n-s))}),t};function mr(r){return Object.prototype.toString.call(r)==="[object RegExp]"}class on{constructor(e){this.find=e.find,this.handler=e.handler}}const xc=(r,e)=>{if(mr(e))return e.exec(r);const t=e(r);if(!t)return null;const n=[t.text];return n.index=t.index,n.input=r,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),n.push(t.replaceWith)),n};function Et(r){var e;const{editor:t,from:n,to:i,text:s,rules:o,plugin:l}=r,{view:a}=t;if(a.composing)return!1;const c=a.state.doc.resolve(n);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(u=>u.type.spec.code))return!1;let f=!1;const d=kc(c)+s;return o.forEach(u=>{if(f)return;const h=xc(d,u.find);if(!h)return;const p=a.state.tr,m=nn({state:a.state,transaction:p}),g={from:n-(h[0].length-s.length),to:i},{commands:y,chain:M,can:C}=new rn({editor:t,state:m});u.handler({state:m,range:g,match:h,commands:y,chain:M,can:C})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:n,to:i,text:s}),a.dispatch(p),f=!0)}),f}function Sc(r){const{editor:e,rules:t}=r,n=new re({state:{init(){return null},apply(i,s,o){const l=i.getMeta(n);if(l)return l;const a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:f}=a;typeof f=="string"?f=f:f=pr(b.from(f),o.schema);const{from:d}=a,u=d+f.length;Et({editor:e,from:d,to:u,text:f,rules:t,plugin:n})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Et({editor:e,from:s,to:o,text:l,rules:t,plugin:n})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Et({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:n})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Et({editor:e,from:o.pos,to:o.pos,text:`
|
|
11
|
-
`,rules:t,plugin:n}):!1}},isInputRules:!0});return n}function Mc(r){return Object.prototype.toString.call(r).slice(8,-1)}function Dt(r){return Mc(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function ln(r,e){const t={...r};return Dt(r)&&Dt(e)&&Object.keys(e).forEach(n=>{Dt(e[n])&&Dt(r[n])?t[n]=ln(r[n],e[n]):t[n]=e[n]}),t}class bt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new bt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>ln(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new bt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&n.removeStoredMark(a),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}function Qs(r){return typeof r=="number"}class eo{constructor(e){this.find=e.find,this.handler=e.handler}}const Cc=(r,e,t)=>{if(mr(e))return[...r.matchAll(e)];const n=e(r,t);return n?n.map(i=>{const s=[i.text];return s.index=i.index,s.input=r,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function wc(r){const{editor:e,state:t,from:n,to:i,rule:s,pasteEvent:o,dropEvent:l}=r,{commands:a,chain:c,can:f}=new rn({editor:e,state:t}),d=[];return t.doc.nodesBetween(n,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(n,p),g=Math.min(i,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"");Cc(y,s.find,o).forEach(C=>{if(C.index===void 0)return;const D=m+C.index+1,E=D+C[0].length,A={from:t.tr.mapping.map(D),to:t.tr.mapping.map(E)},U=s.handler({state:t,range:A,match:C,commands:a,chain:c,can:f,pasteEvent:o,dropEvent:l});d.push(U)})}),d.every(h=>h!==null)}let At=null;const Oc=r=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",r),t};function Nc(r){const{editor:e,rules:t}=r;let n=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:f,from:d,to:u,rule:h,pasteEvt:p})=>{const m=f.tr,g=nn({state:f,transaction:m});if(!(!wc({editor:e,state:g,from:Math.max(d-1,0),to:u.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(f=>new re({view(d){const u=p=>{var m;n=!((m=d.dom.parentElement)===null||m===void 0)&&m.contains(p.target)?d.dom.parentElement:null,n&&(At=e)},h=()=>{At&&(At=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,u)=>{if(s=n===d.dom.parentElement,l=u,!s){const h=At;h&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,u)=>{var h;const p=(h=u.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=u,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,u,h)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),M=!!y;if(!m&&!g&&!M)return;if(M){let{text:E}=y;typeof E=="string"?E=E:E=pr(b.from(E),h.schema);const{from:A}=y,U=A+E.length,j=Oc(E);return a({rule:f,state:h,from:A,to:{b:U},pasteEvt:j})}const C=u.doc.content.findDiffStart(h.doc.content),D=u.doc.content.findDiffEnd(h.doc.content);if(!(!Qs(C)||!D||C===D.b))return a({rule:f,state:h,from:C,to:D,pasteEvt:o})}}))}function Tc(r){const e=r.filter((t,n)=>r.indexOf(t)!==n);return Array.from(new Set(e))}class Ue{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Ue.resolve(e),this.schema=bc(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Ue.sort(Ue.flatten(e)),n=Tc(t.map(i=>i.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const n={name:t.name,options:t.options,storage:t.storage},i=x(t,"addExtensions",n);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((n,i)=>{const s=x(n,"priority")||100,o=x(i,"priority")||100;return s>o?-1:s<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:En(t.name,this.schema)},i=x(t,"addCommands",n);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Ue.sort([...this.extensions].reverse()),n=[],i=[],s=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:En(o.name,this.schema)},a=[],c=x(o,"addKeyboardShortcuts",l);let f={};if(o.type==="mark"&&x(o,"exitable",l)&&(f.ArrowRight=()=>bt.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));f={...f,...m}}const d=Ga(f);a.push(d);const u=x(o,"addInputRules",l);ki(o,e.options.enableInputRules)&&u&&n.push(...u());const h=x(o,"addPasteRules",l);ki(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=x(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[Sc({editor:e,rules:n}),...Nc({editor:e,rules:i}),...s]}get attributes(){return _s(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=sn(this.extensions);return Object.fromEntries(t.filter(n=>!!x(n,"addNodeView")).map(n=>{const i=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:e,type:z(n.name,this.schema)},o=x(n,"addNodeView",s);if(!o)return[];const l=(a,c,f,d,u)=>{const h=Kt(a,i);return o()({node:a,view:c,getPos:f,decorations:d,innerDecorations:u,editor:e,extension:n,HTMLAttributes:h})};return[n.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:En(e.name,this.schema)};e.type==="mark"&&(!((t=w(x(e,"keepOnSplit",n)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=x(e,"onBeforeCreate",n),s=x(e,"onCreate",n),o=x(e,"onUpdate",n),l=x(e,"onSelectionUpdate",n),a=x(e,"onTransaction",n),c=x(e,"onFocus",n),f=x(e,"onBlur",n),d=x(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),f&&this.editor.on("blur",f),d&&this.editor.on("destroy",d)})}}class te{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new te(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>ln(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new te({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}}function to(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
11
|
+
`,rules:t,plugin:n}):!1}},isInputRules:!0});return n}function Mc(r){return Object.prototype.toString.call(r).slice(8,-1)}function Dt(r){return Mc(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}function ln(r,e){const t={...r};return Dt(r)&&Dt(e)&&Object.keys(e).forEach(n=>{Dt(e[n])&&Dt(r[n])?t[n]=ln(r[n],e[n]):t[n]=e[n]}),t}class bt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new bt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>ln(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new bt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&n.removeStoredMark(a),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}function Qs(r){return typeof r=="number"}class eo{constructor(e){this.find=e.find,this.handler=e.handler}}const Cc=(r,e,t)=>{if(mr(e))return[...r.matchAll(e)];const n=e(r,t);return n?n.map(i=>{const s=[i.text];return s.index=i.index,s.input=r,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function wc(r){const{editor:e,state:t,from:n,to:i,rule:s,pasteEvent:o,dropEvent:l}=r,{commands:a,chain:c,can:f}=new rn({editor:e,state:t}),d=[];return t.doc.nodesBetween(n,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const m=Math.max(n,p),g=Math.min(i,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"");Cc(y,s.find,o).forEach(C=>{if(C.index===void 0)return;const D=m+C.index+1,E=D+C[0].length,A={from:t.tr.mapping.map(D),to:t.tr.mapping.map(E)},U=s.handler({state:t,range:A,match:C,commands:a,chain:c,can:f,pasteEvent:o,dropEvent:l});d.push(U)})}),d.every(h=>h!==null)}let At=null;const Oc=r=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",r),t};function Nc(r){const{editor:e,rules:t}=r;let n=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:f,from:d,to:u,rule:h,pasteEvt:p})=>{const m=f.tr,g=nn({state:f,transaction:m});if(!(!wc({editor:e,state:g,from:Math.max(d-1,0),to:u.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(f=>new re({view(d){const u=p=>{var m;n=!((m=d.dom.parentElement)===null||m===void 0)&&m.contains(p.target)?d.dom.parentElement:null,n&&(At=e)},h=()=>{At&&(At=null)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",u),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,u)=>{if(s=n===d.dom.parentElement,l=u,!s){const h=At;h!=null&&h.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,u)=>{var h;const p=(h=u.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=u,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,u,h)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!i,g=p.getMeta("uiEvent")==="drop"&&!s,y=p.getMeta("applyPasteRules"),M=!!y;if(!m&&!g&&!M)return;if(M){let{text:E}=y;typeof E=="string"?E=E:E=pr(b.from(E),h.schema);const{from:A}=y,U=A+E.length,j=Oc(E);return a({rule:f,state:h,from:A,to:{b:U},pasteEvt:j})}const C=u.doc.content.findDiffStart(h.doc.content),D=u.doc.content.findDiffEnd(h.doc.content);if(!(!Qs(C)||!D||C===D.b))return a({rule:f,state:h,from:C,to:D,pasteEvt:o})}}))}function Tc(r){const e=r.filter((t,n)=>r.indexOf(t)!==n);return Array.from(new Set(e))}class Ue{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Ue.resolve(e),this.schema=bc(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Ue.sort(Ue.flatten(e)),n=Tc(t.map(i=>i.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const n={name:t.name,options:t.options,storage:t.storage},i=x(t,"addExtensions",n);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((n,i)=>{const s=x(n,"priority")||100,o=x(i,"priority")||100;return s>o?-1:s<o?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:En(t.name,this.schema)},i=x(t,"addCommands",n);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Ue.sort([...this.extensions].reverse()),n=[],i=[],s=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:En(o.name,this.schema)},a=[],c=x(o,"addKeyboardShortcuts",l);let f={};if(o.type==="mark"&&x(o,"exitable",l)&&(f.ArrowRight=()=>bt.handleExit({editor:e,mark:o})),c){const m=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));f={...f,...m}}const d=Ga(f);a.push(d);const u=x(o,"addInputRules",l);ki(o,e.options.enableInputRules)&&u&&n.push(...u());const h=x(o,"addPasteRules",l);ki(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=x(o,"addProseMirrorPlugins",l);if(p){const m=p();a.push(...m)}return a}).flat();return[Sc({editor:e,rules:n}),...Nc({editor:e,rules:i}),...s]}get attributes(){return _s(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=sn(this.extensions);return Object.fromEntries(t.filter(n=>!!x(n,"addNodeView")).map(n=>{const i=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:n.storage,editor:e,type:z(n.name,this.schema)},o=x(n,"addNodeView",s);if(!o)return[];const l=(a,c,f,d,u)=>{const h=Kt(a,i);return o()({node:a,view:c,getPos:f,decorations:d,innerDecorations:u,editor:e,extension:n,HTMLAttributes:h})};return[n.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:En(e.name,this.schema)};e.type==="mark"&&(!((t=w(x(e,"keepOnSplit",n)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=x(e,"onBeforeCreate",n),s=x(e,"onCreate",n),o=x(e,"onUpdate",n),l=x(e,"onSelectionUpdate",n),a=x(e,"onTransaction",n),c=x(e,"onFocus",n),f=x(e,"onBlur",n),d=x(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),f&&this.editor.on("blur",f),d&&this.editor.on("destroy",d)})}}class te{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=w(x(this,"addOptions",{name:this.name}))),this.storage=w(x(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new te(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>ln(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new te({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=w(x(t,"addOptions",{name:t.name})),t.storage=w(x(t,"addStorage",{name:t.name,options:t.options})),t}}function to(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
12
12
|
|
|
13
|
-
`,textSerializers:o={}}=t||{};let l="";return r.nodesBetween(n,i,(a,c,f,d)=>{var u;a.isBlock&&c>n&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return f&&(l+=h({node:a,pos:c,parent:f,index:d,range:e})),!1;a.isText&&(l+=(u=a==null?void 0:a.text)===null||u===void 0?void 0:u.slice(Math.max(n,c)-c,i-c))}),l}function no(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Ec=te.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new re({key:new Te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:r}=this,{state:e,schema:t}=r,{doc:n,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(f=>f.$from.pos)),l=Math.max(...s.map(f=>f.$to.pos)),a=no(t);return to(n,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Dc=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Ac=(r=!1)=>({commands:e})=>e.setContent("",r),Ic=()=>({state:r,tr:e,dispatch:t})=>{const{selection:n}=e,{ranges:i}=n;return t&&i.forEach(({$from:s,$to:o})=>{r.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:f}=e,d=c.resolve(f.map(a)),u=c.resolve(f.map(a+l.nodeSize)),h=d.blockRange(u);if(!h)return;const p=tt(h);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Rc=r=>e=>r(e),vc=()=>({state:r,dispatch:e})=>Hs(r,e),Pc=(r,e)=>({editor:t,tr:n})=>{const{state:i}=t,s=i.doc.slice(r.from,r.to);n.deleteRange(r.from,r.to);const o=n.mapping.map(e);return n.insert(o,s.content),n.setSelection(new O(n.doc.resolve(o-1))),!0},Bc=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,n=t.$anchor.node();if(n.content.size>0)return!1;const i=r.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===n.type){if(e){const l=i.before(s),a=i.after(s);r.delete(l,a).scrollIntoView()}return!0}return!1},zc=r=>({tr:e,state:t,dispatch:n})=>{const i=z(r,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(n){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Fc=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},Vc=()=>({state:r,dispatch:e})=>tn(r,e),Lc=()=>({commands:r})=>r.keyboardShortcut("Enter"),$c=()=>({state:r,dispatch:e})=>ec(r,e);function Ht(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:mr(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function ro(r,e,t={}){return r.find(n=>n.type===e&&Ht(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function xi(r,e,t={}){return!!ro(r,e,t)}function an(r,e,t){var n;if(!r||!e)return;let i=r.parent.childAfter(r.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=r.parent.childBefore(r.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(t=t||((n=i.node.marks[0])===null||n===void 0?void 0:n.attrs),!ro([...i.node.marks],e,t)))return;let o=i.index,l=r.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&xi([...r.parent.child(o-1).marks],e,t);)o-=1,l-=r.parent.child(o).nodeSize;for(;a<r.parent.childCount&&xi([...r.parent.child(a).marks],e,t);)c+=r.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function De(r,e){if(typeof r=="string"){if(!e.marks[r])throw Error(`There is no mark type named '${r}'. Maybe you forgot to add the extension?`);return e.marks[r]}return r}const Wc=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=De(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){const d=an(a,s,e);if(d&&d.from<=c&&d.to>=f){const u=O.create(o,d.from,d.to);t.setSelection(u)}}return!0},Jc=r=>e=>{const t=typeof r=="function"?r(e):r;for(let n=0;n<t.length;n+=1)if(t[n](e))return!0;return!1};function gr(r){return r instanceof O}function fe(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function io(r,e=null){if(!e)return null;const t=N.atStart(r),n=N.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?O.create(r,fe(0,i,s),fe(r.content.size,i,s)):O.create(r,fe(e,i,s),fe(e,i,s))}function so(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function cn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const jc=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(cn()||so())&&n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!gr(t.state.selection))return o(),!0;const l=io(i.doc,r)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},qc=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),Kc=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),oo=r=>{const e=r.childNodes;for(let t=e.length-1;t>=0;t-=1){const n=e[t];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?r.removeChild(n):n.nodeType===1&&oo(n)}return r};function It(r){const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return oo(t)}function kt(r,e,t){if(r instanceof de||r instanceof b)return r;t={slice:!0,parseOptions:{},...t};const n=typeof r=="object"&&r!==null,i=typeof r=="string";if(n)try{if(Array.isArray(r)&&r.length>0)return b.fromArray(r.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(r);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",s),kt("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Vi({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Se.fromSchema(a).parseSlice(It(r),t.parseOptions):Se.fromSchema(a).parse(It(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Se.fromSchema(e);return t.slice?s.parseSlice(It(r),t.parseOptions).content:s.parse(It(r),t.parseOptions)}return kt("",e,t)}function Hc(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof P||i instanceof B))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,f)=>{o===0&&(o=f)}),r.setSelection(N.near(r.doc.resolve(o),t))}const Uc=r=>!("type"in r),Gc=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{kt(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=kt(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:f,to:d}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},u=!0,h=!0;if((Uc(l)?l:[l]).forEach(g=>{g.check(),u=u?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),f===d&&h){const{parent:g}=n.doc.resolve(f);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(f-=1,d+=1)}let m;if(u){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof b){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;n.insertText(m,f,d)}else m=l,n.replaceWith(f,d,m);t.updateSelection&&Hc(n,n.steps.length-1,-1),t.applyInputRules&&n.setMeta("applyInputRules",{from:f,text:m}),t.applyPasteRules&&n.setMeta("applyPasteRules",{from:f,text:m})}return!0},Yc=()=>({state:r,dispatch:e})=>Xa(r,e),_c=()=>({state:r,dispatch:e})=>Za(r,e),Xc=()=>({state:r,dispatch:e})=>Ls(r,e),Zc=()=>({state:r,dispatch:e})=>js(r,e),Qc=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Yt(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},ef=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Yt(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},tf=()=>({state:r,dispatch:e})=>Ya(r,e),nf=()=>({state:r,dispatch:e})=>_a(r,e);function lo(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function rf(r){const e=r.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))cn()||lo()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return n&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const sf=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=rf(r).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const f=c.map(n.mapping);f&&i&&n.maybeStep(f)}),!0};function xt(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?z(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(d,u)=>{if(d.isText)return;const h=Math.max(n,u),p=Math.min(i,u+d.nodeSize);l.push({node:d,from:h,to:p})});const a=i-n,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Ht(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,u)=>d+u.to-u.from,0)>=a}const of=(r,e={})=>({state:t,dispatch:n})=>{const i=z(r,t.schema);return xt(t,i,e)?Qa(t,n):!1},lf=()=>({state:r,dispatch:e})=>Us(r,e),af=r=>({state:e,dispatch:t})=>{const n=z(r,e.schema);return dc(n)(e,t)},cf=()=>({state:r,dispatch:e})=>Ks(r,e);function fn(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function Si(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}const ff=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=fn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=z(r,n.schema)),l==="mark"&&(o=De(r,n.schema)),i&&t.selection.ranges.forEach(a=>{n.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,f)=>{s&&s===c.type&&t.setNodeMarkup(f,void 0,Si(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(f,f+c.nodeSize,o.create(Si(d.attrs,e)))})})}),!0):!1},df=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),uf=()=>({tr:r,dispatch:e})=>{if(e){const t=new G(r.doc);r.setSelection(t)}return!0},hf=()=>({state:r,dispatch:e})=>Ws(r,e),pf=()=>({state:r,dispatch:e})=>qs(r,e),mf=()=>({state:r,dispatch:e})=>rc(r,e),gf=()=>({state:r,dispatch:e})=>oc(r,e),yf=()=>({state:r,dispatch:e})=>sc(r,e);function Un(r,e,t={},n={}){return kt(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}const bf=(r,e=!1,t={},n={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{var a,c;const{doc:f}=s;if(t.preserveWhitespace!=="full"){const d=Un(r,i.schema,t,{errorOnInvalidContent:(a=n.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return o&&s.replaceWith(0,f.content.size,d).setMeta("preventUpdate",!e),!0}return o&&s.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:f.content.size},r,{parseOptions:t,errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function ao(r,e){const t=De(e,r.schema),{from:n,to:i,empty:s}=r.selection,o=[];s?(r.storedMarks&&o.push(...r.storedMarks),o.push(...r.selection.$head.marks())):r.doc.nodesBetween(n,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function kf(r,e){const t=new Qn(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function xf(r){for(let e=0;e<r.edgeCount;e+=1){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Sf(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function co(r,e){for(let t=r.depth;t>0;t-=1){const n=r.node(t);if(e(n))return{pos:t>0?r.before(t):0,start:r.start(t),depth:t,node:n}}}function dn(r){return e=>co(e.$from,r)}function Mf(r,e){const t={from:0,to:r.content.size};return to(r,t,e)}function Cf(r,e){const t=z(e,r.schema),{from:n,to:i}=r.selection,s=[];r.doc.nodesBetween(n,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function fo(r,e){const t=fn(typeof e=="string"?e:e.name,r.schema);return t==="node"?Cf(r,e):t==="mark"?ao(r,e):{}}function wf(r,e=JSON.stringify){const t={};return r.filter(n=>{const i=e(n);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Of(r){const e=wf(r);return e.length===1?e:e.filter((t,n)=>!e.filter((s,o)=>o!==n).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Nf(r){const{mapping:e,steps:t}=r,n=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),f=e.slice(s).map(a),d=e.invert().map(c,-1),u=e.invert().map(f);n.push({oldRange:{from:d,to:u},newRange:{from:c,to:f}})})}),Of(n)}function yr(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=an(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}function Pt(r,e,t){return Object.fromEntries(Object.entries(t).filter(([n])=>{const i=r.find(s=>s.type===e&&s.name===n);return i?i.attribute.keepOnSplit:!1}))}function Gn(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?De(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Ht(d.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:u})=>{const h=d.pos,p=u.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),M=Math.min(p,g+m.nodeSize),C=M-y;o+=C,l.push(...m.marks.map(D=>({mark:D,from:y,to:M})))})}),o===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Ht(d.mark.attrs,t,{strict:!1})).reduce((d,u)=>d+u.to-u.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,u)=>d+u.to-u.from,0);return(a>0?a+c:a)>=o}function uo(r,e,t={}){if(!e)return xt(r,null,t)||Gn(r,null,t);const n=fn(e,r.schema);return n==="node"?xt(r,e,t):n==="mark"?Gn(r,e,t):!1}function Yn(r,e){const{nodeExtensions:t}=sn(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=w(x(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function un(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return/^\s*$/m.test((n=r.text)!==null&&n!==void 0?n:"")}if(r.isText)return!r.text;if(r.isAtom||r.isLeaf)return!1;if(r.content.childCount===0)return!0;if(e){let i=!0;return r.content.forEach(s=>{i!==!1&&(un(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Tf(r){return r instanceof S}function Ef(r,e,t){const i=r.state.doc.content.size,s=fe(e,0,i),o=fe(t,0,i),l=r.coordsAtPos(s),a=r.coordsAtPos(o,-1),c=Math.min(l.top,a.top),f=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),u=Math.max(l.right,a.right),h=u-d,p=f-c,y={top:c,bottom:f,left:d,right:u,width:h,height:p,x:d,y:c};return{...y,toJSON:()=>y}}function Df(r,e,t){var n;const{selection:i}=e;let s=null;if(gr(i)&&(s=i.$cursor),s){const l=(n=r.storedMarks)!==null&&n!==void 0?n:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?r.doc.inlineContent&&r.doc.type.allowsMarkType(t):!1;return r.doc.nodesBetween(l.pos,a.pos,(f,d,u)=>{if(c)return!1;if(f.isInline){const h=!u||u.type.allowsMarkType(t),p=!!t.isInSet(f.marks)||!f.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const Af=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=De(r,n.schema);if(i)if(o){const c=ao(n,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const f=c.$from.pos,d=c.$to.pos;n.doc.nodesBetween(f,d,(u,h)=>{const p=Math.max(h,f),m=Math.min(h+u.nodeSize,d);u.marks.find(y=>y.type===a)?u.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return Df(n,t,a)},If=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),Rf=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=z(r,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>gi(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>gi(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},vf=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=fe(r,0,n.content.size),s=S.create(n,i);e.setSelection(s)}return!0},Pf=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=O.atStart(n).from,l=O.atEnd(n).to,a=fe(i,o,l),c=fe(s,o,l),f=O.create(n,a,c);e.setSelection(f)}return!0},Bf=r=>({state:e,dispatch:t})=>{const n=z(r,e.schema);return pc(n)(e,t)};function Mi(r,e){const t=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();if(t){const n=t.filter(i=>e==null?void 0:e.includes(i.type.name));r.tr.ensureMarks(n)}}const zf=({keepMarks:r=!0}={})=>({tr:e,state:t,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,f=Pt(c,l.node().type.name,l.node().attrs);if(s instanceof S&&s.node.isBlock)return!l.parentOffset||!ue(o,l.pos)?!1:(n&&(r&&Mi(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,u=l.depth===0?void 0:xf(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&u?[{type:u,attrs:f}]:void 0,p=ue(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&ue(e.doc,e.mapping.map(l.pos),1,u?[{type:u}]:void 0)&&(p=!0,h=u?[{type:u,attrs:f}]:void 0),n){if(p&&(s instanceof O&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),u&&!d&&!l.parentOffset&&l.parent.type!==u)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,u)&&e.setNodeMarkup(e.mapping.map(l.before()),u)}r&&Mi(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},Ff=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const l=z(r,n.schema),{$from:a,$to:c}=n.selection,f=n.selection.node;if(f&&f.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const u=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=b.empty;const M=a.index(-1)?1:a.index(-2)?2:3;for(let j=a.depth-M;j>=a.depth-3;j-=1)y=b.from(a.node(j).copy(y));const C=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,D={...Pt(u,a.node().type.name,a.node().attrs),...e},E=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(D))||void 0;y=y.append(b.from(l.createAndFill(null,E)||void 0));const A=a.before(a.depth-(M-1));t.replace(A,a.after(-C),new k(y,4-M,0));let U=-1;t.doc.nodesBetween(A,t.doc.content.size,(j,T)=>{if(U>-1)return!1;j.isTextblock&&j.content.size===0&&(U=T+1)}),U>-1&&t.setSelection(O.near(t.doc.resolve(U))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Pt(u,d.type.name,d.attrs),...e},m={...Pt(u,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!ue(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:M}=n,{splittableMarks:C}=s.extensionManager,D=M||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!D||!i)return!0;const E=D.filter(A=>C.includes(A.type.name));t.ensureMarks(E)}return!0},Dn=(r,e)=>{const t=dn(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Ne(r.doc,t.pos)&&r.join(t.pos),!0},An=(r,e)=>{const t=dn(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(t.start).after(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Ne(r.doc,n)&&r.join(n),!0},Vf=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:f})=>{const{extensions:d,splittableMarks:u}=i.extensionManager,h=z(r,o.schema),p=z(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:M}=m,C=y.blockRange(M),D=g||m.$to.parentOffset&&m.$from.marks();if(!C)return!1;const E=dn(A=>Yn(A.type.name,d))(m);if(C.depth>=1&&E&&C.depth-E.depth<=1){if(E.node.type===h)return c.liftListItem(p);if(Yn(E.node.type.name,d)&&h.validContent(E.node.content)&&l)return a().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>Dn(s,h)).command(()=>An(s,h)).run()}return!t||!D||!l?a().command(()=>f().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>Dn(s,h)).command(()=>An(s,h)).run():a().command(()=>{const A=f().wrapInList(h,n),U=D.filter(j=>u.includes(j.type.name));return s.ensureMarks(U),A?!0:c.clearNodes()}).wrapInList(h,n).command(()=>Dn(s,h)).command(()=>An(s,h)).run()},Lf=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=De(r,n.schema);return Gn(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},$f=(r,e,t={})=>({state:n,commands:i})=>{const s=z(r,n.schema),o=z(e,n.schema),l=xt(n,s,t);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},Wf=(r,e={})=>({state:t,commands:n})=>{const i=z(r,t.schema);return xt(t,i,e)?n.lift(i):n.wrapIn(i,e)},Jf=()=>({state:r,dispatch:e})=>{const t=r.plugins;for(let n=0;n<t.length;n+=1){const i=t[n];let s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){const o=r.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const 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)}return!0}}return!1},jf=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,{empty:n,ranges:i}=t;return n||e&&i.forEach(s=>{r.removeMark(s.$from.pos,s.$to.pos)}),!0},qf=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=De(r,n.schema),{$from:c,empty:f,ranges:d}=l;if(!i)return!0;if(f&&o){let{from:u,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))===null||s===void 0?void 0:s.attrs,m=an(c,a,p);m&&(u=m.from,h=m.to),t.removeMark(u,h,a)}else d.forEach(u=>{t.removeMark(u.$from.pos,u.$to.pos,a)});return t.removeStoredMark(a),!0},Kf=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=fn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=z(r,n.schema)),l==="mark"&&(o=De(r,n.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,f=a.$to.pos;let d,u,h,p;t.selection.empty?n.doc.nodesBetween(c,f,(m,g)=>{s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,f),d=g,u=m)}):n.doc.nodesBetween(c,f,(m,g)=>{g<c&&s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,f),d=g,u=m),g>=c&&g<=f&&(s&&s===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{if(o===y.type){const M=Math.max(g,c),C=Math.min(g+m.nodeSize,f);t.addMark(M,C,o.create({...y.attrs,...e}))}}))}),u&&(d!==void 0&&t.setNodeMarkup(d,void 0,{...u.attrs,...e}),o&&u.marks.length&&u.marks.forEach(m=>{o===m.type&&t.addMark(h,p,o.create({...m.attrs,...e}))}))}),!0):!1},Hf=(r,e={})=>({state:t,dispatch:n})=>{const i=z(r,t.schema);return lc(i,e)(t,n)},Uf=(r,e={})=>({state:t,dispatch:n})=>{const i=z(r,t.schema);return ac(i,e)(t,n)};var Gf=Object.freeze({__proto__:null,blur:Dc,clearContent:Ac,clearNodes:Ic,command:Rc,createParagraphNear:vc,cut:Pc,deleteCurrentNode:Bc,deleteNode:zc,deleteRange:Fc,deleteSelection:Vc,enter:Lc,exitCode:$c,extendMarkRange:Wc,first:Jc,focus:jc,forEach:qc,insertContent:Kc,insertContentAt:Gc,joinBackward:Xc,joinDown:_c,joinForward:Zc,joinItemBackward:Qc,joinItemForward:ef,joinTextblockBackward:tf,joinTextblockForward:nf,joinUp:Yc,keyboardShortcut:sf,lift:of,liftEmptyBlock:lf,liftListItem:af,newlineInCode:cf,resetAttributes:ff,scrollIntoView:df,selectAll:uf,selectNodeBackward:hf,selectNodeForward:pf,selectParentNode:mf,selectTextblockEnd:gf,selectTextblockStart:yf,setContent:bf,setMark:Af,setMeta:If,setNode:Rf,setNodeSelection:vf,setTextSelection:Pf,sinkListItem:Bf,splitBlock:zf,splitListItem:Ff,toggleList:Vf,toggleMark:Lf,toggleNode:$f,toggleWrap:Wf,undoInputRule:Jf,unsetAllMarks:jf,unsetMark:qf,updateAttributes:Kf,wrapIn:Hf,wrapInList:Uf});const Yf=te.create({name:"commands",addCommands(){return{...Gf}}}),_f=te.create({name:"drop",addProseMirrorPlugins(){return[new re({key:new Te("tiptapDrop"),props:{handleDrop:(r,e,t,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:n})}}})]}}),Xf=te.create({name:"editable",addProseMirrorPlugins(){return[new re({key:new Te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Zf=new Te("focusEvents"),Qf=te.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new re({key:Zf,props:{handleDOMEvents:{focus:(e,t)=>{r.isFocused=!0;const n=r.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,t)=>{r.isFocused=!1;const n=r.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),ed=te.create({name:"keymap",addKeyboardShortcuts(){const r=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:f,$anchor:d}=a,{pos:u,parent:h}=d,p=d.parent.isTextblock&&u>0?l.doc.resolve(u-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:N.atStart(c).from===u;return!f||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:r,"Mod-Backspace":r,"Shift-Backspace":r,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":r,"Alt-Backspace":r,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return cn()||lo()?s:i},addProseMirrorPlugins(){return[new re({key:new Te("clearDocument"),appendTransaction:(r,e,t)=>{if(r.some(m=>m.getMeta("composition")))return;const n=r.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=r.some(m=>m.getMeta("preventClearDocument"));if(!n||i)return;const{empty:s,from:o,to:l}=e.selection,a=N.atStart(e.doc).from,c=N.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!un(t.doc))return;const u=t.tr,h=nn({state:t,transaction:u}),{commands:p}=new rn({editor:this.editor,state:h});if(p.clearNodes(),!!u.steps.length)return u}})]}}),td=te.create({name:"paste",addProseMirrorPlugins(){return[new re({key:new Te("tiptapPaste"),props:{handlePaste:(r,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),nd=te.create({name:"tabindex",addProseMirrorPlugins(){return[new re({key:new Te("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Ie{get name(){return this.node.type.name}constructor(e,t,n=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Ie(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ie(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Ie(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,n)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+n+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const a=new Ie(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new Ie(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,i=this.parent;for(;i&&!n;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else n=i;i=i.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{n&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(n&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,n))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const rd=`.ProseMirror {
|
|
13
|
+
`,textSerializers:o={}}=t||{};let l="";return r.nodesBetween(n,i,(a,c,f,d)=>{var u;a.isBlock&&c>n&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return f&&(l+=h({node:a,pos:c,parent:f,index:d,range:e})),!1;a.isText&&(l+=(u=a==null?void 0:a.text)===null||u===void 0?void 0:u.slice(Math.max(n,c)-c,i-c))}),l}function no(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Ec=te.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new re({key:new Te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:r}=this,{state:e,schema:t}=r,{doc:n,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(f=>f.$from.pos)),l=Math.max(...s.map(f=>f.$to.pos)),a=no(t);return to(n,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Dc=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Ac=(r=!1)=>({commands:e})=>e.setContent("",r),Ic=()=>({state:r,tr:e,dispatch:t})=>{const{selection:n}=e,{ranges:i}=n;return t&&i.forEach(({$from:s,$to:o})=>{r.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:f}=e,d=c.resolve(f.map(a)),u=c.resolve(f.map(a+l.nodeSize)),h=d.blockRange(u);if(!h)return;const p=tt(h);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Rc=r=>e=>r(e),vc=()=>({state:r,dispatch:e})=>Hs(r,e),Pc=(r,e)=>({editor:t,tr:n})=>{const{state:i}=t,s=i.doc.slice(r.from,r.to);n.deleteRange(r.from,r.to);const o=n.mapping.map(e);return n.insert(o,s.content),n.setSelection(new O(n.doc.resolve(Math.max(o-1,0)))),!0},Bc=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,n=t.$anchor.node();if(n.content.size>0)return!1;const i=r.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===n.type){if(e){const l=i.before(s),a=i.after(s);r.delete(l,a).scrollIntoView()}return!0}return!1},zc=r=>({tr:e,state:t,dispatch:n})=>{const i=z(r,t.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(n){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},Fc=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},Vc=()=>({state:r,dispatch:e})=>tn(r,e),Lc=()=>({commands:r})=>r.keyboardShortcut("Enter"),$c=()=>({state:r,dispatch:e})=>ec(r,e);function Ht(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:mr(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function ro(r,e,t={}){return r.find(n=>n.type===e&&Ht(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function xi(r,e,t={}){return!!ro(r,e,t)}function an(r,e,t){var n;if(!r||!e)return;let i=r.parent.childAfter(r.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=r.parent.childBefore(r.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(t=t||((n=i.node.marks[0])===null||n===void 0?void 0:n.attrs),!ro([...i.node.marks],e,t)))return;let o=i.index,l=r.start()+i.offset,a=o+1,c=l+i.node.nodeSize;for(;o>0&&xi([...r.parent.child(o-1).marks],e,t);)o-=1,l-=r.parent.child(o).nodeSize;for(;a<r.parent.childCount&&xi([...r.parent.child(a).marks],e,t);)c+=r.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function De(r,e){if(typeof r=="string"){if(!e.marks[r])throw Error(`There is no mark type named '${r}'. Maybe you forgot to add the extension?`);return e.marks[r]}return r}const Wc=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const s=De(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){const d=an(a,s,e);if(d&&d.from<=c&&d.to>=f){const u=O.create(o,d.from,d.to);t.setSelection(u)}}return!0},Jc=r=>e=>{const t=typeof r=="function"?r(e):r;for(let n=0;n<t.length;n+=1)if(t[n](e))return!0;return!1};function gr(r){return r instanceof O}function fe(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function io(r,e=null){if(!e)return null;const t=N.atStart(r),n=N.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?O.create(r,fe(0,i,s),fe(r.content.size,i,s)):O.create(r,fe(e,i,s),fe(e,i,s))}function so(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function cn(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const jc=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(cn()||so())&&n.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(n.hasFocus()&&r===null||r===!1)return!0;if(s&&r===null&&!gr(t.state.selection))return o(),!0;const l=io(i.doc,r)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},qc=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),Kc=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),oo=r=>{const e=r.childNodes;for(let t=e.length-1;t>=0;t-=1){const n=e[t];n.nodeType===3&&n.nodeValue&&/^(\n\s\s|\n)$/.test(n.nodeValue)?r.removeChild(n):n.nodeType===1&&oo(n)}return r};function It(r){const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return oo(t)}function kt(r,e,t){if(r instanceof de||r instanceof b)return r;t={slice:!0,parseOptions:{},...t};const n=typeof r=="object"&&r!==null,i=typeof r=="string";if(n)try{if(Array.isArray(r)&&r.length>0)return b.fromArray(r.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(r);return t.errorOnInvalidContent&&o.check(),o}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",r,"Error:",s),kt("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new Vi({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Se.fromSchema(a).parseSlice(It(r),t.parseOptions):Se.fromSchema(a).parse(It(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Se.fromSchema(e);return t.slice?s.parseSlice(It(r),t.parseOptions).content:s.parse(It(r),t.parseOptions)}return kt("",e,t)}function Hc(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof P||i instanceof B))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,f)=>{o===0&&(o=f)}),r.setSelection(N.near(r.doc.resolve(o),t))}const Uc=r=>!("type"in r),Gc=(r,e,t)=>({tr:n,dispatch:i,editor:s})=>{var o;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;const a=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{kt(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=kt(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!==null&&o!==void 0?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:f,to:d}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},u=!0,h=!0;if((Uc(l)?l:[l]).forEach(g=>{g.check(),u=u?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),f===d&&h){const{parent:g}=n.doc.resolve(f);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(f-=1,d+=1)}let m;if(u){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof b){let g="";e.forEach(y=>{y.text&&(g+=y.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;n.insertText(m,f,d)}else m=l,n.replaceWith(f,d,m);t.updateSelection&&Hc(n,n.steps.length-1,-1),t.applyInputRules&&n.setMeta("applyInputRules",{from:f,text:m}),t.applyPasteRules&&n.setMeta("applyPasteRules",{from:f,text:m})}return!0},Yc=()=>({state:r,dispatch:e})=>Xa(r,e),_c=()=>({state:r,dispatch:e})=>Za(r,e),Xc=()=>({state:r,dispatch:e})=>Ls(r,e),Zc=()=>({state:r,dispatch:e})=>js(r,e),Qc=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Yt(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},ef=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Yt(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},tf=()=>({state:r,dispatch:e})=>Ya(r,e),nf=()=>({state:r,dispatch:e})=>_a(r,e);function lo(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function rf(r){const e=r.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))cn()||lo()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return n&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const sf=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=rf(r).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const f=c.map(n.mapping);f&&i&&n.maybeStep(f)}),!0};function xt(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?z(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(d,u)=>{if(d.isText)return;const h=Math.max(n,u),p=Math.min(i,u+d.nodeSize);l.push({node:d,from:h,to:p})});const a=i-n,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Ht(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,u)=>d+u.to-u.from,0)>=a}const of=(r,e={})=>({state:t,dispatch:n})=>{const i=z(r,t.schema);return xt(t,i,e)?Qa(t,n):!1},lf=()=>({state:r,dispatch:e})=>Us(r,e),af=r=>({state:e,dispatch:t})=>{const n=z(r,e.schema);return dc(n)(e,t)},cf=()=>({state:r,dispatch:e})=>Ks(r,e);function fn(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function Si(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}const ff=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=fn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=z(r,n.schema)),l==="mark"&&(o=De(r,n.schema)),i&&t.selection.ranges.forEach(a=>{n.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,f)=>{s&&s===c.type&&t.setNodeMarkup(f,void 0,Si(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(f,f+c.nodeSize,o.create(Si(d.attrs,e)))})})}),!0):!1},df=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),uf=()=>({tr:r,dispatch:e})=>{if(e){const t=new G(r.doc);r.setSelection(t)}return!0},hf=()=>({state:r,dispatch:e})=>Ws(r,e),pf=()=>({state:r,dispatch:e})=>qs(r,e),mf=()=>({state:r,dispatch:e})=>rc(r,e),gf=()=>({state:r,dispatch:e})=>oc(r,e),yf=()=>({state:r,dispatch:e})=>sc(r,e);function Un(r,e,t={},n={}){return kt(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}const bf=(r,e=!1,t={},n={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{var a,c;const{doc:f}=s;if(t.preserveWhitespace!=="full"){const d=Un(r,i.schema,t,{errorOnInvalidContent:(a=n.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return o&&s.replaceWith(0,f.content.size,d).setMeta("preventUpdate",!e),!0}return o&&s.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:f.content.size},r,{parseOptions:t,errorOnInvalidContent:(c=n.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function ao(r,e){const t=De(e,r.schema),{from:n,to:i,empty:s}=r.selection,o=[];s?(r.storedMarks&&o.push(...r.storedMarks),o.push(...r.selection.$head.marks())):r.doc.nodesBetween(n,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function kf(r,e){const t=new Qn(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function xf(r){for(let e=0;e<r.edgeCount;e+=1){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Sf(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function co(r,e){for(let t=r.depth;t>0;t-=1){const n=r.node(t);if(e(n))return{pos:t>0?r.before(t):0,start:r.start(t),depth:t,node:n}}}function dn(r){return e=>co(e.$from,r)}function Mf(r,e){const t={from:0,to:r.content.size};return to(r,t,e)}function Cf(r,e){const t=z(e,r.schema),{from:n,to:i}=r.selection,s=[];r.doc.nodesBetween(n,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function fo(r,e){const t=fn(typeof e=="string"?e:e.name,r.schema);return t==="node"?Cf(r,e):t==="mark"?ao(r,e):{}}function wf(r,e=JSON.stringify){const t={};return r.filter(n=>{const i=e(n);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Of(r){const e=wf(r);return e.length===1?e:e.filter((t,n)=>!e.filter((s,o)=>o!==n).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Nf(r){const{mapping:e,steps:t}=r,n=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),f=e.slice(s).map(a),d=e.invert().map(c,-1),u=e.invert().map(f);n.push({oldRange:{from:d,to:u},newRange:{from:c,to:f}})})}),Of(n)}function yr(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=an(s,i.type);o&&n.push({mark:i,...o})}):t.nodesBetween(r,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||n.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),n}function Pt(r,e,t){return Object.fromEntries(Object.entries(t).filter(([n])=>{const i=r.find(s=>s.type===e&&s.name===n);return i?i.attribute.keepOnSplit:!1}))}function Gn(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?De(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Ht(d.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:u})=>{const h=d.pos,p=u.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),M=Math.min(p,g+m.nodeSize),C=M-y;o+=C,l.push(...m.marks.map(D=>({mark:D,from:y,to:M})))})}),o===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Ht(d.mark.attrs,t,{strict:!1})).reduce((d,u)=>d+u.to-u.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,u)=>d+u.to-u.from,0);return(a>0?a+c:a)>=o}function uo(r,e,t={}){if(!e)return xt(r,null,t)||Gn(r,null,t);const n=fn(e,r.schema);return n==="node"?xt(r,e,t):n==="mark"?Gn(r,e,t):!1}function Yn(r,e){const{nodeExtensions:t}=sn(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=w(x(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function un(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return/^\s*$/m.test((n=r.text)!==null&&n!==void 0?n:"")}if(r.isText)return!r.text;if(r.isAtom||r.isLeaf)return!1;if(r.content.childCount===0)return!0;if(e){let i=!0;return r.content.forEach(s=>{i!==!1&&(un(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Tf(r){return r instanceof S}function Ef(r,e,t){const i=r.state.doc.content.size,s=fe(e,0,i),o=fe(t,0,i),l=r.coordsAtPos(s),a=r.coordsAtPos(o,-1),c=Math.min(l.top,a.top),f=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),u=Math.max(l.right,a.right),h=u-d,p=f-c,y={top:c,bottom:f,left:d,right:u,width:h,height:p,x:d,y:c};return{...y,toJSON:()=>y}}function Df(r,e,t){var n;const{selection:i}=e;let s=null;if(gr(i)&&(s=i.$cursor),s){const l=(n=r.storedMarks)!==null&&n!==void 0?n:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?r.doc.inlineContent&&r.doc.type.allowsMarkType(t):!1;return r.doc.nodesBetween(l.pos,a.pos,(f,d,u)=>{if(c)return!1;if(f.isInline){const h=!u||u.type.allowsMarkType(t),p=!!t.isInSet(f.marks)||!f.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const Af=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=De(r,n.schema);if(i)if(o){const c=ao(n,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const f=c.$from.pos,d=c.$to.pos;n.doc.nodesBetween(f,d,(u,h)=>{const p=Math.max(h,f),m=Math.min(h+u.nodeSize,d);u.marks.find(y=>y.type===a)?u.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return Df(n,t,a)},If=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),Rf=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=z(r,t.schema);let o;return t.selection.$anchor.sameParent(t.selection.$head)&&(o=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>gi(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>gi(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},vf=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=fe(r,0,n.content.size),s=S.create(n,i);e.setSelection(s)}return!0},Pf=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=O.atStart(n).from,l=O.atEnd(n).to,a=fe(i,o,l),c=fe(s,o,l),f=O.create(n,a,c);e.setSelection(f)}return!0},Bf=r=>({state:e,dispatch:t})=>{const n=z(r,e.schema);return pc(n)(e,t)};function Mi(r,e){const t=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();if(t){const n=t.filter(i=>e==null?void 0:e.includes(i.type.name));r.tr.ensureMarks(n)}}const zf=({keepMarks:r=!0}={})=>({tr:e,state:t,dispatch:n,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,f=Pt(c,l.node().type.name,l.node().attrs);if(s instanceof S&&s.node.isBlock)return!l.parentOffset||!ue(o,l.pos)?!1:(n&&(r&&Mi(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,u=l.depth===0?void 0:xf(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&u?[{type:u,attrs:f}]:void 0,p=ue(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&ue(e.doc,e.mapping.map(l.pos),1,u?[{type:u}]:void 0)&&(p=!0,h=u?[{type:u,attrs:f}]:void 0),n){if(p&&(s instanceof O&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),u&&!d&&!l.parentOffset&&l.parent.type!==u)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,u)&&e.setNodeMarkup(e.mapping.map(l.before()),u)}r&&Mi(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},Ff=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const l=z(r,n.schema),{$from:a,$to:c}=n.selection,f=n.selection.node;if(f&&f.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const u=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let y=b.empty;const M=a.index(-1)?1:a.index(-2)?2:3;for(let j=a.depth-M;j>=a.depth-3;j-=1)y=b.from(a.node(j).copy(y));const C=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,D={...Pt(u,a.node().type.name,a.node().attrs),...e},E=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(D))||void 0;y=y.append(b.from(l.createAndFill(null,E)||void 0));const A=a.before(a.depth-(M-1));t.replace(A,a.after(-C),new k(y,4-M,0));let U=-1;t.doc.nodesBetween(A,t.doc.content.size,(j,T)=>{if(U>-1)return!1;j.isTextblock&&j.content.size===0&&(U=T+1)}),U>-1&&t.setSelection(O.near(t.doc.resolve(U))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Pt(u,d.type.name,d.attrs),...e},m={...Pt(u,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!ue(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:M}=n,{splittableMarks:C}=s.extensionManager,D=M||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!D||!i)return!0;const E=D.filter(A=>C.includes(A.type.name));t.ensureMarks(E)}return!0},Dn=(r,e)=>{const t=dn(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Ne(r.doc,t.pos)&&r.join(t.pos),!0},An=(r,e)=>{const t=dn(o=>o.type===e)(r.selection);if(!t)return!0;const n=r.doc.resolve(t.start).after(t.depth);if(n===void 0)return!0;const i=r.doc.nodeAt(n);return t.node.type===(i==null?void 0:i.type)&&Ne(r.doc,n)&&r.join(n),!0},Vf=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:f})=>{const{extensions:d,splittableMarks:u}=i.extensionManager,h=z(r,o.schema),p=z(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:M}=m,C=y.blockRange(M),D=g||m.$to.parentOffset&&m.$from.marks();if(!C)return!1;const E=dn(A=>Yn(A.type.name,d))(m);if(C.depth>=1&&E&&C.depth-E.depth<=1){if(E.node.type===h)return c.liftListItem(p);if(Yn(E.node.type.name,d)&&h.validContent(E.node.content)&&l)return a().command(()=>(s.setNodeMarkup(E.pos,h),!0)).command(()=>Dn(s,h)).command(()=>An(s,h)).run()}return!t||!D||!l?a().command(()=>f().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>Dn(s,h)).command(()=>An(s,h)).run():a().command(()=>{const A=f().wrapInList(h,n),U=D.filter(j=>u.includes(j.type.name));return s.ensureMarks(U),A?!0:c.clearNodes()}).wrapInList(h,n).command(()=>Dn(s,h)).command(()=>An(s,h)).run()},Lf=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=De(r,n.schema);return Gn(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},$f=(r,e,t={})=>({state:n,commands:i})=>{const s=z(r,n.schema),o=z(e,n.schema),l=xt(n,s,t);let a;return n.selection.$anchor.sameParent(n.selection.$head)&&(a=n.selection.$anchor.parent.attrs),l?i.setNode(o,a):i.setNode(s,{...a,...t})},Wf=(r,e={})=>({state:t,commands:n})=>{const i=z(r,t.schema);return xt(t,i,e)?n.lift(i):n.wrapIn(i,e)},Jf=()=>({state:r,dispatch:e})=>{const t=r.plugins;for(let n=0;n<t.length;n+=1){const i=t[n];let s;if(i.spec.isInputRules&&(s=i.getState(r))){if(e){const o=r.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const 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)}return!0}}return!1},jf=()=>({tr:r,dispatch:e})=>{const{selection:t}=r,{empty:n,ranges:i}=t;return n||e&&i.forEach(s=>{r.removeMark(s.$from.pos,s.$to.pos)}),!0},qf=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=De(r,n.schema),{$from:c,empty:f,ranges:d}=l;if(!i)return!0;if(f&&o){let{from:u,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))===null||s===void 0?void 0:s.attrs,m=an(c,a,p);m&&(u=m.from,h=m.to),t.removeMark(u,h,a)}else d.forEach(u=>{t.removeMark(u.$from.pos,u.$to.pos,a)});return t.removeStoredMark(a),!0},Kf=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=fn(typeof r=="string"?r:r.name,n.schema);return l?(l==="node"&&(s=z(r,n.schema)),l==="mark"&&(o=De(r,n.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,f=a.$to.pos;let d,u,h,p;t.selection.empty?n.doc.nodesBetween(c,f,(m,g)=>{s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,f),d=g,u=m)}):n.doc.nodesBetween(c,f,(m,g)=>{g<c&&s&&s===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,f),d=g,u=m),g>=c&&g<=f&&(s&&s===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(y=>{if(o===y.type){const M=Math.max(g,c),C=Math.min(g+m.nodeSize,f);t.addMark(M,C,o.create({...y.attrs,...e}))}}))}),u&&(d!==void 0&&t.setNodeMarkup(d,void 0,{...u.attrs,...e}),o&&u.marks.length&&u.marks.forEach(m=>{o===m.type&&t.addMark(h,p,o.create({...m.attrs,...e}))}))}),!0):!1},Hf=(r,e={})=>({state:t,dispatch:n})=>{const i=z(r,t.schema);return lc(i,e)(t,n)},Uf=(r,e={})=>({state:t,dispatch:n})=>{const i=z(r,t.schema);return ac(i,e)(t,n)};var Gf=Object.freeze({__proto__:null,blur:Dc,clearContent:Ac,clearNodes:Ic,command:Rc,createParagraphNear:vc,cut:Pc,deleteCurrentNode:Bc,deleteNode:zc,deleteRange:Fc,deleteSelection:Vc,enter:Lc,exitCode:$c,extendMarkRange:Wc,first:Jc,focus:jc,forEach:qc,insertContent:Kc,insertContentAt:Gc,joinBackward:Xc,joinDown:_c,joinForward:Zc,joinItemBackward:Qc,joinItemForward:ef,joinTextblockBackward:tf,joinTextblockForward:nf,joinUp:Yc,keyboardShortcut:sf,lift:of,liftEmptyBlock:lf,liftListItem:af,newlineInCode:cf,resetAttributes:ff,scrollIntoView:df,selectAll:uf,selectNodeBackward:hf,selectNodeForward:pf,selectParentNode:mf,selectTextblockEnd:gf,selectTextblockStart:yf,setContent:bf,setMark:Af,setMeta:If,setNode:Rf,setNodeSelection:vf,setTextSelection:Pf,sinkListItem:Bf,splitBlock:zf,splitListItem:Ff,toggleList:Vf,toggleMark:Lf,toggleNode:$f,toggleWrap:Wf,undoInputRule:Jf,unsetAllMarks:jf,unsetMark:qf,updateAttributes:Kf,wrapIn:Hf,wrapInList:Uf});const Yf=te.create({name:"commands",addCommands(){return{...Gf}}}),_f=te.create({name:"drop",addProseMirrorPlugins(){return[new re({key:new Te("tiptapDrop"),props:{handleDrop:(r,e,t,n)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:n})}}})]}}),Xf=te.create({name:"editable",addProseMirrorPlugins(){return[new re({key:new Te("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Zf=new Te("focusEvents"),Qf=te.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:r}=this;return[new re({key:Zf,props:{handleDOMEvents:{focus:(e,t)=>{r.isFocused=!0;const n=r.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1},blur:(e,t)=>{r.isFocused=!1;const n=r.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(n),!1}}}})]}}),ed=te.create({name:"keymap",addKeyboardShortcuts(){const r=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:f,$anchor:d}=a,{pos:u,parent:h}=d,p=d.parent.isTextblock&&u>0?l.doc.resolve(u-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:N.atStart(c).from===u;return!f||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:r,"Mod-Backspace":r,"Shift-Backspace":r,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},s={...n,"Ctrl-h":r,"Alt-Backspace":r,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return cn()||lo()?s:i},addProseMirrorPlugins(){return[new re({key:new Te("clearDocument"),appendTransaction:(r,e,t)=>{if(r.some(m=>m.getMeta("composition")))return;const n=r.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=r.some(m=>m.getMeta("preventClearDocument"));if(!n||i)return;const{empty:s,from:o,to:l}=e.selection,a=N.atStart(e.doc).from,c=N.atEnd(e.doc).to;if(s||!(o===a&&l===c)||!un(t.doc))return;const u=t.tr,h=nn({state:t,transaction:u}),{commands:p}=new rn({editor:this.editor,state:h});if(p.clearNodes(),!!u.steps.length)return u}})]}}),td=te.create({name:"paste",addProseMirrorPlugins(){return[new re({key:new Te("tiptapPaste"),props:{handlePaste:(r,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),nd=te.create({name:"tabindex",addProseMirrorPlugins(){return[new re({key:new Te("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Ie{get name(){return this.node.type.name}constructor(e,t,n=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new Ie(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Ie(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Ie(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,n)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,o=this.pos+n+(s?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!i&&l.depth<=this.depth)return;const a=new Ie(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new Ie(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,i=this.parent;for(;i&&!n;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else n=i;i=i.parent}return n}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},n=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{n&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(n&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,n))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const rd=`.ProseMirror {
|
|
14
14
|
position: relative;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { a as U, P as L, D as z, b as G, e as H } from "./index-DI9T3iLd.js";
|
|
2
|
+
function J(B) {
|
|
3
|
+
var a;
|
|
4
|
+
const { char: _, allowSpaces: C, allowToIncludeChar: E, allowedPrefixes: v, startOfLine: M, $position: f } = B, I = C && !E, g = H(_), k = new RegExp(`\\s${g}$`), P = M ? "^" : "", R = E ? "" : g, y = I ? new RegExp(`${P}${g}.*?(?=\\s${R}|$)`, "gm") : new RegExp(`${P}(?:^)?${g}[^\\s${R}]*`, "gm"), p = ((a = f.nodeBefore) === null || a === void 0 ? void 0 : a.isText) && f.nodeBefore.text;
|
|
5
|
+
if (!p)
|
|
6
|
+
return null;
|
|
7
|
+
const A = f.pos - p.length, n = Array.from(p.matchAll(y)).pop();
|
|
8
|
+
if (!n || n.input === void 0 || n.index === void 0)
|
|
9
|
+
return null;
|
|
10
|
+
const e = n.input.slice(Math.max(0, n.index - 1), n.index), h = new RegExp(`^[${v == null ? void 0 : v.join("")}\0]?$`).test(e);
|
|
11
|
+
if (v !== null && !h)
|
|
12
|
+
return null;
|
|
13
|
+
const o = A + n.index;
|
|
14
|
+
let i = o + n[0].length;
|
|
15
|
+
return I && k.test(p.slice(i - 1, i + 1)) && (n[0] += " ", i += 1), o < f.pos && i >= f.pos ? {
|
|
16
|
+
range: {
|
|
17
|
+
from: o,
|
|
18
|
+
to: i
|
|
19
|
+
},
|
|
20
|
+
query: n[0].slice(_.length),
|
|
21
|
+
text: n[0]
|
|
22
|
+
} : null;
|
|
23
|
+
}
|
|
24
|
+
const Q = new U("suggestion");
|
|
25
|
+
function W({ pluginKey: B = Q, editor: a, char: _ = "@", allowSpaces: C = !1, allowToIncludeChar: E = !1, allowedPrefixes: v = [" "], startOfLine: M = !1, decorationTag: f = "span", decorationClass: I = "suggestion", decorationContent: g = "", decorationEmptyClass: k = "is-empty", command: P = () => null, items: R = () => [], render: y = () => ({}), allow: p = () => !0, findSuggestionMatch: A = J }) {
|
|
26
|
+
let n;
|
|
27
|
+
const e = y == null ? void 0 : y(), h = new L({
|
|
28
|
+
key: B,
|
|
29
|
+
view() {
|
|
30
|
+
return {
|
|
31
|
+
update: async (o, i) => {
|
|
32
|
+
var s, r, c, u, d, S, m;
|
|
33
|
+
const t = (s = this.key) === null || s === void 0 ? void 0 : s.getState(i), l = (r = this.key) === null || r === void 0 ? void 0 : r.getState(o.state), $ = t.active && l.active && t.range.from !== l.range.from, j = !t.active && l.active, F = t.active && !l.active, K = !j && !F && t.query !== l.query, w = j || $ && K, D = K || $, N = F || $ && K;
|
|
34
|
+
if (!w && !D && !N)
|
|
35
|
+
return;
|
|
36
|
+
const x = N && !w ? t : l, O = o.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);
|
|
37
|
+
n = {
|
|
38
|
+
editor: a,
|
|
39
|
+
range: x.range,
|
|
40
|
+
query: x.query,
|
|
41
|
+
text: x.text,
|
|
42
|
+
items: [],
|
|
43
|
+
command: (q) => P({
|
|
44
|
+
editor: a,
|
|
45
|
+
range: x.range,
|
|
46
|
+
props: q
|
|
47
|
+
}),
|
|
48
|
+
decorationNode: O,
|
|
49
|
+
// virtual node for popper.js or tippy.js
|
|
50
|
+
// this can be used for building popups without a DOM node
|
|
51
|
+
clientRect: O ? () => {
|
|
52
|
+
var q;
|
|
53
|
+
const { decorationId: T } = (q = this.key) === null || q === void 0 ? void 0 : q.getState(a.state), b = o.dom.querySelector(`[data-decoration-id="${T}"]`);
|
|
54
|
+
return (b == null ? void 0 : b.getBoundingClientRect()) || null;
|
|
55
|
+
} : null
|
|
56
|
+
}, w && ((c = e == null ? void 0 : e.onBeforeStart) === null || c === void 0 || c.call(e, n)), D && ((u = e == null ? void 0 : e.onBeforeUpdate) === null || u === void 0 || u.call(e, n)), (D || w) && (n.items = await R({
|
|
57
|
+
editor: a,
|
|
58
|
+
query: x.query
|
|
59
|
+
})), N && ((d = e == null ? void 0 : e.onExit) === null || d === void 0 || d.call(e, n)), D && ((S = e == null ? void 0 : e.onUpdate) === null || S === void 0 || S.call(e, n)), w && ((m = e == null ? void 0 : e.onStart) === null || m === void 0 || m.call(e, n));
|
|
60
|
+
},
|
|
61
|
+
destroy: () => {
|
|
62
|
+
var o;
|
|
63
|
+
n && ((o = e == null ? void 0 : e.onExit) === null || o === void 0 || o.call(e, n));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
state: {
|
|
68
|
+
// Initialize the plugin's internal state.
|
|
69
|
+
init() {
|
|
70
|
+
return {
|
|
71
|
+
active: !1,
|
|
72
|
+
range: {
|
|
73
|
+
from: 0,
|
|
74
|
+
to: 0
|
|
75
|
+
},
|
|
76
|
+
query: null,
|
|
77
|
+
text: null,
|
|
78
|
+
composing: !1
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
// Apply changes to the plugin state from a view transaction.
|
|
82
|
+
apply(o, i, s, r) {
|
|
83
|
+
const { isEditable: c } = a, { composing: u } = a.view, { selection: d } = o, { empty: S, from: m } = d, t = { ...i };
|
|
84
|
+
if (t.composing = u, c && (S || a.view.composing)) {
|
|
85
|
+
(m < i.range.from || m > i.range.to) && !u && !i.composing && (t.active = !1);
|
|
86
|
+
const l = A({
|
|
87
|
+
char: _,
|
|
88
|
+
allowSpaces: C,
|
|
89
|
+
allowToIncludeChar: E,
|
|
90
|
+
allowedPrefixes: v,
|
|
91
|
+
startOfLine: M,
|
|
92
|
+
$position: d.$from
|
|
93
|
+
}), $ = `id_${Math.floor(Math.random() * 4294967295)}`;
|
|
94
|
+
l && p({
|
|
95
|
+
editor: a,
|
|
96
|
+
state: r,
|
|
97
|
+
range: l.range,
|
|
98
|
+
isActive: i.active
|
|
99
|
+
}) ? (t.active = !0, t.decorationId = i.decorationId ? i.decorationId : $, t.range = l.range, t.query = l.query, t.text = l.text) : t.active = !1;
|
|
100
|
+
} else
|
|
101
|
+
t.active = !1;
|
|
102
|
+
return t.active || (t.decorationId = null, t.range = { from: 0, to: 0 }, t.query = null, t.text = null), t;
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
props: {
|
|
106
|
+
// Call the keydown hook if suggestion is active.
|
|
107
|
+
handleKeyDown(o, i) {
|
|
108
|
+
var s;
|
|
109
|
+
const { active: r, range: c } = h.getState(o.state);
|
|
110
|
+
return r && ((s = e == null ? void 0 : e.onKeyDown) === null || s === void 0 ? void 0 : s.call(e, { view: o, event: i, range: c })) || !1;
|
|
111
|
+
},
|
|
112
|
+
// Setup decorator on the currently active suggestion.
|
|
113
|
+
decorations(o) {
|
|
114
|
+
const { active: i, range: s, decorationId: r, query: c } = h.getState(o);
|
|
115
|
+
if (!i)
|
|
116
|
+
return null;
|
|
117
|
+
const u = !(c != null && c.length), d = [I];
|
|
118
|
+
return u && d.push(k), z.create(o.doc, [
|
|
119
|
+
G.inline(s.from, s.to, {
|
|
120
|
+
nodeName: f,
|
|
121
|
+
class: d.join(" "),
|
|
122
|
+
"data-decoration-id": r,
|
|
123
|
+
"data-decoration-content": g
|
|
124
|
+
})
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return h;
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
W as S
|
|
133
|
+
};
|