reactjs-tiptap-editor 1.0.26 → 1.0.29
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-B4KDkZ0z.js → ActionMenuButton-BhiGvRJ7.js} +1 -1
- package/lib/{ActionMenuButton-C3Cfeza9.cjs → ActionMenuButton-qUxkZlQg.cjs} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +27 -27
- package/lib/Blockquote.cjs +3 -3
- package/lib/Blockquote.js +251 -244
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +2 -2
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/Callout-B9uXfbP3.js +340 -0
- package/lib/Callout-C_TXsss3.cjs +1 -0
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +8 -222
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +2 -2
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +2 -2
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +2 -2
- package/lib/{Drawer-D7E9kTca.cjs → Drawer-D3B4lQJF.cjs} +1 -1
- package/lib/{Drawer-DA0FLHs9.js → Drawer-h401Yy6Y.js} +20 -20
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +168 -135
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +5 -5
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +5 -5
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +5 -5
- package/lib/FormatPainter.cjs +1 -1
- package/lib/FormatPainter.js +2 -2
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +10 -10
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +3 -3
- package/lib/History.cjs +2 -2
- package/lib/History.js +584 -531
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-DZ3r3QzK.js → Iframe-Dhn40BXx.js} +3 -3
- package/lib/{Iframe-OMVd0xa_.cjs → Iframe-bvGuzYwC.cjs} +1 -1
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +9 -6
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +19 -19
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +15 -15
- package/lib/{Indent-kI4G-clX.js → Indent-BK9DvCL7.js} +2 -2
- package/lib/{Indent-QgCoonRk.cjs → Indent-IOByomps.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +2 -2
- package/lib/{Katex-BPbXjcZQ.js → Katex-C_Ah9G9w.js} +7 -6
- package/lib/Katex-oLGrtLTf.cjs +4 -0
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +4 -4
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-Z7RRurvx.cjs → LinkEditBlock-BojxdGTm.cjs} +2 -2
- package/lib/{LinkEditBlock-BYWwH2_x.js → LinkEditBlock-DRdKXffy.js} +39 -35
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +4 -4
- package/lib/Mermaid.cjs +2 -2
- package/lib/Mermaid.js +62 -61
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +5 -5
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +8 -8
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +7 -7
- package/lib/{SlashCommandNodeView-DPPmYEjC.cjs → SlashCommandNodeView-Dai-O3aD.cjs} +1 -1
- package/lib/{SlashCommandNodeView-C0l3Fb_3.js → SlashCommandNodeView-qwW9cuYt.js} +6 -6
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/{Table-DwseaFSD.js → Table-BKM8SvVj.js} +20 -20
- package/lib/{Table-D5G3rfwb.cjs → Table-CWI7tKme.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-q4ZGZL0i.cjs → Twitter-BfsPzA8_.cjs} +1 -1
- package/lib/{Twitter-DP26Lkn8.js → Twitter-CofLQ-zj.js} +9 -9
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +5 -5
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +2258 -2552
- package/lib/{clsx-DRbkQ4T7.cjs → clsx-DJURdKPs.cjs} +2 -2
- package/lib/{clsx-_bq4MQQ7.js → clsx-b_2OwHLk.js} +19 -19
- package/lib/{dropdown-menu-CURWpB9o.cjs → dropdown-menu-CEMxzgnU.cjs} +1 -1
- package/lib/{dropdown-menu-BKSX4gvT.js → dropdown-menu-CKAKsyqu.js} +1 -1
- package/lib/extensions/Image/Image.d.ts +13 -1
- package/lib/index-BJQ1G8B1.js +311 -0
- package/lib/index-BO82_0q8.cjs +1 -0
- package/lib/{index-DQy9iBzV.js → index-Bn_WPziX.js} +1 -1
- package/lib/{index-BpLw6ebr.cjs → index-CwbGrQFa.cjs} +1 -1
- package/lib/{index-DtyAGMbq.js → index-DKruDABV.js} +1 -1
- package/lib/{index-SEMQrdk2.cjs → index-DN-IR-K0.cjs} +1 -1
- package/lib/{index-C52cuQ_Y.js → index-DRcwHivm.js} +1415 -1350
- package/lib/index-DUeBQoIA.cjs +1 -0
- package/lib/{index-Dbm_Mans.js → index-DeoYYWEA.js} +1 -1
- package/lib/{index-CHVV5iY-.cjs → index-Dgs2thVL.cjs} +1 -1
- package/lib/{index-BaR0Brts.js → index-DjB2kNdz.js} +171 -166
- package/lib/{index-CJMI7Fjf.js → index-DuWMq-Qs.js} +1 -1
- package/lib/{index-BGfIcDCQ.cjs → index-EoGU7W4e.cjs} +1 -1
- package/lib/{index-CDw4Eszh.cjs → index-MDz4NZcT.cjs} +9 -9
- package/lib/{index-Dx-Dh7KS.js → index-n4kM0Ll-.js} +110 -105
- package/lib/{index-BgNKVyMW.cjs → index-qZURFC5Q.cjs} +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.js +12 -12
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +1 -1
- package/lib/{popover-BB-ZDnqk.js → popover-Beieacfy.js} +1 -1
- package/lib/{popover-CrywEkBR.cjs → popover-Bl1kxRJX.cjs} +1 -1
- package/lib/{renderNodeView-5h3-p80E.cjs → renderNodeView-BIgT6Ghg.cjs} +1 -1
- package/lib/{renderNodeView-DoKZ4GYy.js → renderNodeView-Bi58v3DZ.js} +2 -2
- package/lib/{separator-BGO9AZp4.cjs → separator-DMLtkcoo.cjs} +1 -1
- package/lib/{separator-DuuOJRQd.js → separator-DfvK668q.js} +14 -14
- package/lib/style.css +1 -1
- package/lib/textarea-DV9Fw3y1.cjs +1 -0
- package/lib/textarea-GXaWJbm9.js +20 -0
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +1 -1
- package/lib/{updatePosition-CFTYKYNJ.js → updatePosition-DY1jI7qb.js} +2 -2
- package/lib/{updatePosition-B1oRJE1x.cjs → updatePosition-D_D-TbEu.cjs} +1 -1
- package/package.json +59 -59
- package/lib/Katex-CUofhjB5.cjs +0 -4
- package/lib/index-BG0kQamI.js +0 -285
- package/lib/index-NsYff_Ni.cjs +0 -1
- package/lib/index-aujjnfSJ.cjs +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
`);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;_t.hasOwnProperty(o)&&this.parser.normalizeLists&&er(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:Zn.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,f=this.needsBlock;if(Ht.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=f}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
3
3
|
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=W.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):vt(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=wt(e,s,o.options);o.options&ue&&o.content.length==0&&(l|=ue);let a=W.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):vt(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ke(e,t,a,i,null,l)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=de)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let f=a>0||a==0&&i?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!f||f.name!=c&&!f.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}}function er(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&_t.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function tr(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function kt(r){let e={};for(let t in r)e[t]=r[t];return e}function vt(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:f}=l.edge(a);if(c==e||s.indexOf(f)<0&&o(f))return!0}};if(o(i.contentMatch))return!0}}class et{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=ve(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],f=this.serializeMark(c,o.isInline,t);f&&(s.push([c,i]),i.appendChild(f.dom),i=f.contentDOM||f.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){if(e.isText)return ve(t).createTextNode(e.text);let{dom:n,contentDOM:i}=Ee(ve(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&Ee(ve(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return typeof t=="string"?{dom:e.createTextNode(t)}:Ee(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new et(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=St(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return St(e.marks)}}function St(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function ve(r){return r.document||window.document}const bt=new WeakMap;function nr(r){let e=bt.get(r);return e===void 0&&bt.set(r,e=rr(r)),e}function rr(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function Ee(r,e,t,n){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=nr(n))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),c=e[1],f=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){f=2;for(let u in c)if(c[u]!=null){let d=u.indexOf(" ");d>0?a.setAttributeNS(u.slice(0,d),u.slice(d+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=f;u<e.length;u++){let d=e[u];if(d===0){if(u<e.length-1||u>f)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof d=="string")a.appendChild(r.createTextNode(d));else{let{dom:h,contentDOM:p}=Ee(r,d,t,n);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Vt=65535,qt=Math.pow(2,16);function ir(r,e){return r+e*qt}function Mt(r){return r&Vt}function sr(r){return(r-(r&Vt))/qt}const Kt=1,Ut=2,Ce=4,Xt=8;class Xe{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Xt)>0}get deletedBefore(){return(this.delInfo&(Kt|Ce))>0}get deletedAfter(){return(this.delInfo&(Ut|Ce))>0}get deletedAcross(){return(this.delInfo&Ce)>0}}class F{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&F.empty)return F.empty}recover(e){let t=0,n=Mt(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+sr(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],f=this.ranges[l+o],u=a+c;if(e<=u){let d=c?e==a?-1:e==u?1:t:t,h=a+i+(d<0?0:f);if(n)return h;let p=e==(t<0?a:u)?null:ir(l/3,e-a),m=e==a?Ut:e==u?Kt:Ce;return(t<0?e!=a:e!=u)&&(m|=Xt),new Xe(h,m,p)}i+=f-c}return n?e+i:new Xe(e+i,0,null)}touches(e,t){let n=0,i=Mt(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+s],f=a+c;if(e<=f&&l==i*3)return!0;n+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],f=this.ranges[i+n];e(l,l+c,a,a+f),s+=f-c}}invert(){return new F(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?F.empty:new F(e<0?[0,-e,0]:[0,0,e])}}F.empty=new F([]);class he{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new he(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new he;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Xe(e,i,null)}}const Fe=Object.create(null);class O{getMap(){return F.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Fe[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Fe)throw new RangeError("Duplicate use of step JSON ID "+e);return Fe[e]=t,t.prototype.jsonID=e,t}}class A{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new A(e,null)}static fail(e){return new A(null,e)}static fromReplace(e,t,n,i){try{return A.ok(e.replace(t,n,i))}catch(s){if(s instanceof _n)return A.fail(s.message);throw s}}}function tt(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(tt(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return w.fromArray(n)}class Y extends O{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new x(tt(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return A.fromReplace(e,this.from,this.to,s)}invert(){return new H(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Y(t.pos,n.pos,this.mark)}merge(e){return e instanceof Y&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Y(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Y(t.from,t.to,e.markFromJSON(t.mark))}}O.jsonID("addMark",Y);class H extends O{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new x(tt(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return A.fromReplace(e,this.from,this.to,n)}invert(){return new Y(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new H(t.pos,n.pos,this.mark)}merge(e){return e instanceof H&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new H(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new H(t.from,t.to,e.markFromJSON(t.mark))}}O.jsonID("removeMark",H);class Q extends O{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return A.fromReplace(e,this.pos,this.pos+1,new x(w.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new Q(this.pos,t.marks[i]);return new Q(this.pos,this.mark)}}return new ee(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Q(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Q(t.pos,e.markFromJSON(t.mark))}}O.jsonID("addNodeMark",Q);class ee extends O{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return A.fromReplace(e,this.pos,this.pos+1,new x(w.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Q(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ee(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ee(t.pos,e.markFromJSON(t.mark))}}O.jsonID("removeNodeMark",ee);class T extends O{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&Ye(e,this.from,this.to)?A.fail("Structure replace would overwrite content"):A.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new F([this.from,this.to-this.from,this.slice.size])}invert(e){return new T(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&T.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new T(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof T)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?x.empty:new x(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new T(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?x.empty:new x(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new T(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new T(t.from,t.to,x.fromJSON(e,t.slice),!!t.structure)}}T.MAP_BIAS=1;O.jsonID("replace",T);class I extends O{constructor(e,t,n,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Ye(e,this.from,this.gapFrom)||Ye(e,this.gapTo,this.to)))return A.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return A.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?A.fromReplace(e,this.from,this.to,n):A.fail("Content does not fit in gap")}getMap(){return new F([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new I(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new I(t.pos,n.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new I(t.from,t.to,t.gapFrom,t.gapTo,x.fromJSON(e,t.slice),t.insert,!!t.structure)}}O.jsonID("replaceAround",I);function Ye(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function or(r,e,t,n){let i=[],s=[],o,l;r.doc.nodesBetween(e,t,(a,c,f)=>{if(!a.isInline)return;let u=a.marks;if(!n.isInSet(u)&&f.type.allowsMarkType(n.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(o&&o.to==d&&o.mark.eq(u[m])?o.to=h:i.push(o=new H(d,h,u[m])));l&&l.to==d?l.to=h:s.push(l=new Y(d,h,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function lr(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(n instanceof Ze){let c=o.marks,f;for(;f=n.isInSet(c);)(a||(a=[])).push(f),c=f.removeFromSet(c)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let f=0;f<a.length;f++){let u=a[f],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&u.eq(i[h].style)&&(d=p)}d?(d.to=c,d.step=s):i.push({style:u,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>r.step(new H(o.from,o.to,o.style)))}function nt(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),f=l+c.nodeSize,u=n.matchType(c.type);if(!u)o.push(new T(l,f,x.empty));else{n=u;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||r.step(new H(l,f,c.marks[d]));if(i&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new x(w.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new T(l+d.index,l+d.index+d[0].length,p))}}l=f}if(!n.validEnd){let a=n.fillBefore(w.empty,!0);r.replace(l,l,new x(a,0,0))}for(let a=o.length-1;a>=0;a--)r.step(o[a])}function ar(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function le(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let o=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-s;if(n<r.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!ar(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function cr(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),l=i.after(s+1),a=o,c=l,f=w.empty,u=0;for(let p=s,m=!1;p>t;p--)m||n.index(p)>0?(m=!0,f=w.from(n.node(p).copy(f)),u++):a--;let d=w.empty,h=0;for(let p=s,m=!1;p>t;p--)m||i.after(p+1)<i.end(p)?(m=!0,d=w.from(i.node(p).copy(d)),h++):c++;r.step(new I(a,c,o,l,new x(f.append(d),u,h),f.size-u,!0))}function rt(r,e,t=null,n=r){let i=fr(r,e),s=i&&ur(n,e);return s?i.map(Et).concat({type:e,attrs:t}).concat(s.map(Et)):null}function Et(r){return{type:r,attrs:null}}function fr(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.contentMatchAt(n).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(n,i,o)?s:null}function ur(r,e){let{parent:t,startIndex:n,endIndex:i}=r,s=t.child(n),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=n;a&&c<i;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function dr(r,e,t){let n=w.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=w.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new I(i,s,i,s,new x(n,0,0),t.length,!0))}function hr(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,a)&&pr(r.doc,r.mapping.slice(s).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Qt(r,o,l,s),nt(r,r.mapping.slice(s).map(l,1),n,void 0,c===null);let f=r.mapping.slice(s),u=f.map(l,1),d=f.map(l+o.nodeSize,1);return r.step(new I(u,d,u+1,d-1,new x(w.from(n.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Yt(r,o,l,s),!1}})}function Yt(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Qt(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
|
|
4
4
|
`))}})}function pr(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function mr(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new I(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new x(w.from(o),0,0),1,!0))}function X(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,f=t-2;c>s;c--,f--){let u=i.node(c),d=i.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(d,u.childCount),p=n&&n[f+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=n&&n[f]||u;if(!u.canReplace(d+1,u.childCount)||!m.type.validContent(h))return!1}let l=i.indexAfter(s),a=n&&n[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function gr(r,e,t=1,n){let i=r.doc.resolve(e),s=w.empty,o=w.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=w.from(i.node(l).copy(s));let f=n&&n[c];o=w.from(f?f.type.create(f.attrs,o):i.node(l).copy(o))}r.step(new T(e,e,new x(s.append(o),t,t),!0))}function G(r,e){let t=r.resolve(e),n=t.index();return Gt(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function yr(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function Gt(r,e){return!!(r&&e&&!r.isLeaf&&yr(r,e))}function Re(r,e,t=-1){let n=r.resolve(e);for(let i=n.depth;;i--){let s,o,l=n.index(i);if(i==n.depth?(s=n.nodeBefore,o=n.nodeAfter):t>0?(s=n.node(i+1),l++,o=n.node(i).maybeChild(l)):(s=n.node(i).maybeChild(l-1),o=n.node(i+1)),s&&!s.isTextblock&&Gt(s,o)&&n.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?n.before(i):n.after(i)}}function wr(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let f=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);f&&!u?n=!1:!f&&u&&(n=!0)}let l=r.steps.length;if(n===!1){let f=r.doc.resolve(e+t);Qt(r,f.node(),f.before(),l)}o.inlineContent&&nt(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new T(c,a.map(e+t,-1),x.empty,!0)),n===!0){let f=r.doc.resolve(c);Yt(r,f.node(),f.before(),r.steps.length)}return r}function xr(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function kr(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),c=n.node(o),f=!1;if(s==1)f=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);f=u&&c.canReplaceWith(a,a,u[0])}if(f)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function ze(r,e,t=e,n=x.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return Zt(i,s,n)?new T(e,t,n):new vr(i,s,n).fit()}function Zt(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class vr{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=w.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=w.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new x(s,o,l);return e>-1?new I(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new T(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=Le(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],f,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(w.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:u};if(t==2&&o&&(f=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:f};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Le(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new x(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Le(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new x(ce(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new x(ce(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,c=0,f=[],{match:u,type:d}=this.frontier[t];if(i){for(let m=0;m<i.childCount;m++)f.push(i.child(m));u=u.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,f.push(en(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=fe(this.placed,t,w.from(f)),this.frontier[t].match=u,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?x.empty:new x(ce(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new x(ce(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!We(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=We(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],f=We(e,l,c,a,!0);if(!f||f.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=fe(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=fe(this.placed,this.depth,w.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(w.empty,!0);t.childCount&&(this.placed=fe(this.placed,this.frontier.length,t))}}function ce(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(ce(r.firstChild.content,e-1,t)))}function fe(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(fe(r.lastChild.content,e-1,t)))}function Le(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function en(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,en(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(w.empty,!0)))),r.copy(n)}function We(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!Sr(t,s.content,o)?l:null}function Sr(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function br(r){return r.spec.defining||r.spec.definingForContent}function Mr(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(Zt(i,s,n))return r.step(new T(e,t,n));let o=nn(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let d=i.depth,h=i.pos-1;d>0;d--,h--){let p=i.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(d)>-1?l=d:i.before(d)==h&&o.splice(1,0,-d)}let a=o.indexOf(l),c=[],f=n.openStart;for(let d=n.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==n.openStart)break;d=p.content}for(let d=f-1;d>=0;d--){let h=c[d],p=br(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))f=d;else if(p||!h.type.isTextblock)break}for(let d=n.openStart;d>=0;d--){let h=(d+f+1)%(n.openStart+1),p=c[h];if(p)for(let m=0;m<o.length;m++){let g=o[(m+a)%o.length],y=!0;g<0&&(y=!1,g=-g);let k=i.node(g-1),S=i.index(g-1);if(k.canReplaceWith(S,S,p.type,p.marks))return r.replace(i.before(g),y?s.after(g):t,new x(tn(n.content,0,n.openStart,h),h,n.openEnd))}}let u=r.steps.length;for(let d=o.length-1;d>=0&&(r.replace(e,t,n),!(r.steps.length>u));d--){let h=o[d];h<0||(e=i.before(h),t=s.after(h))}}function tn(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(tn(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(w.empty,!0))}return r}function Er(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=xr(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new x(w.from(n),0,0))}function Cr(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t);if(n.parent.isTextblock&&i.parent.isTextblock&&n.start()!=i.start()&&n.parentOffset==0&&i.parentOffset==0){let o=n.sharedDepth(t),l=!1;for(let a=n.depth;a>o;a--)n.node(a).type.spec.isolating&&(l=!0);for(let a=i.depth;a>o;a--)i.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=n.depth;a>0&&e==n.start(a);a--)e=n.before(a);for(let a=i.depth;a>0&&t==i.start(a);a--)t=i.before(a);n=r.doc.resolve(e),i=r.doc.resolve(t)}}let s=nn(n,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function nn(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class ne extends O{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return A.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return A.fromReplace(e,this.pos,this.pos+1,new x(w.from(i),0,t.isLeaf?0:1))}getMap(){return F.empty}invert(e){return new ne(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ne(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ne(t.pos,t.attr,t.value)}}O.jsonID("attr",ne);class pe extends O{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return A.ok(n)}getMap(){return F.empty}invert(e){return new pe(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new pe(t.attr,t.value)}}O.jsonID("docAttr",pe);let re=class extends Error{};re=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};re.prototype=Object.create(Error.prototype);re.prototype.constructor=re;re.prototype.name="TransformError";class rn{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new he}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new re(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((s,o,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=x.empty){let i=ze(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new x(w.from(n),0,0))}delete(e,t){return this.replace(e,t,x.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Mr(this,e,t,n),this}replaceRangeWith(e,t,n){return Er(this,e,t,n),this}deleteRange(e,t){return Cr(this,e,t),this}lift(e,t){return cr(this,e,t),this}join(e,t=1){return wr(this,e,t),this}wrap(e,t){return dr(this,e,t),this}setBlockType(e,t=e,n,i=null){return hr(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return mr(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new ne(e,t,n)),this}setDocAttribute(e,t){return this.step(new pe(e,t)),this}addNodeMark(e,t){return this.step(new Q(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof W)t.isInSet(n.marks)&&this.step(new ee(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new ee(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return gr(this,e,t,n),this}addMark(e,t,n){return or(this,e,t,n),this}removeMark(e,t,n){return lr(this,e,t,n),this}clearIncompatible(e,t,n){return nt(this,e,t,n),this}}const Je=Object.create(null);class C{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new sn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=x.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],f=e.mapping.slice(s);e.replaceRange(f.map(a.pos),f.map(c.pos),l?x.empty:t),l==0&&At(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(n),c=a.map(o.pos),f=a.map(l.pos);s?e.deleteRange(c,f):(e.replaceRangeWith(c,f,t),At(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new P(e):te(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?te(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):te(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new J(e.node(0))}static atStart(e){return te(e,e,0,0,1)||new J(e)}static atEnd(e){return te(e,e,e.content.size,e.childCount,-1)||new J(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Je[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Je)throw new RangeError("Duplicate use of selection JSON ID "+e);return Je[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}}C.prototype.visible=!0;class sn{constructor(e,t){this.$from=e,this.$to=t}}let Ct=!1;function Tt(r){!Ct&&!r.parent.inlineContent&&(Ct=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class P extends C{constructor(e,t=e){Tt(e),Tt(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return C.near(n);let i=e.resolve(t.map(this.anchor));return new P(i.parent.inlineContent?i:n,n)}replace(e,t=x.empty){if(super.replace(e,t),t==x.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof P&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Oe(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new P(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=C.findFrom(t,n,!0)||C.findFrom(t,-n,!0);if(s)t=s.$head;else return C.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(C.findFrom(e,-n,!0)||C.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new P(e,t)}}C.jsonID("text",P);class Oe{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Oe(e.map(this.anchor),e.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}}class E extends C{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?C.near(s):new E(s)}content(){return new x(w.from(this.node),0,0)}eq(e){return e instanceof E&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new it(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new E(e.resolve(t.anchor))}static create(e,t){return new E(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}E.prototype.visible=!1;C.jsonID("node",E);class it{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Oe(n,n):new it(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&E.isSelectable(n)?new E(t):C.near(t)}}class J extends C{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=x.empty){if(t==x.empty){e.delete(0,e.doc.content.size);let n=C.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new J(e)}map(e){return new J(e)}eq(e){return e instanceof J}getBookmark(){return Tr}}C.jsonID("all",J);const Tr={map(){return this},resolve(r){return new J(r)}};function te(r,e,t,n,i,s=!1){if(e.inlineContent)return P.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&E.isSelectable(l))return E.create(r,t-(i<0?l.nodeSize:0))}else{let a=te(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function At(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof T||i instanceof I))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,f)=>{o==null&&(o=f)}),r.setSelection(C.near(r.doc.resolve(o),t))}function It(r,e){return!e||!r?r:r.bind(e)}class Se{constructor(e,t,n){this.name=e,this.init=It(t.init,n),this.apply=It(t.apply,n)}}new Se("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Se("selection",{init(r,e){return r.selection||C.atStart(e.doc)},apply(r){return r.selection}}),new Se("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Se("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}});function on(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=on(i,e,{})),t[n]=i}return t}class Ar{constructor(e){this.spec=e,this.props={},e.props&&on(e.props,this,this.props),this.key=e.key?e.key.key:ln("plugin")}getState(e){return e[this.key]}}const je=Object.create(null);function ln(r){return r in je?r+"$"+ ++je[r]:(je[r]=0,r+"$")}class Ir{constructor(e="key"){this.key=ln(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const st=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function an(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const cn=(r,e,t)=>{let n=an(r,t);if(!n)return!1;let i=ot(n);if(!i){let o=n.blockRange(),l=o&&le(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(wn(r,i,e,-1))return!0;if(n.parent.content.size==0&&(ie(s,"end")||E.isSelectable(s)))for(let o=n.depth;;o--){let l=ze(r.doc,n.before(o),n.after(o),x.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(ie(s,"end")?C.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):E.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},Nr=(r,e,t)=>{let n=an(r,t);if(!n)return!1;let i=ot(n);return i?fn(r,i,e):!1},Rr=(r,e,t)=>{let n=dn(r,t);if(!n)return!1;let i=lt(n);return i?fn(r,i,e):!1};function fn(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=ze(r.doc,s,a,x.empty);if(!c||c.from!=s||c instanceof T&&c.slice.size>=a-s)return!1;if(t){let f=r.tr.step(c);f.setSelection(P.create(f.doc,s)),t(f.scrollIntoView())}return!0}function ie(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 un=(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=ot(n)}let o=s&&s.nodeBefore;return!o||!E.isSelectable(o)?!1:(e&&e(r.tr.setSelection(E.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function ot(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 dn(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const hn=(r,e,t)=>{let n=dn(r,t);if(!n)return!1;let i=lt(n);if(!i)return!1;let s=i.nodeAfter;if(wn(r,i,e,1))return!0;if(n.parent.content.size==0&&(ie(s,"start")||E.isSelectable(s))){let o=ze(r.doc,n.before(),n.after(),x.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(ie(s,"start")?C.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):E.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},pn=(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=lt(n)}let o=s&&s.nodeAfter;return!o||!E.isSelectable(o)?!1:(e&&e(r.tr.setSelection(E.create(r.doc,s.pos)).scrollIntoView()),!0)};function lt(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 zr=(r,e)=>{let t=r.selection,n=t instanceof E,i;if(n){if(t.node.isTextblock||!G(r.doc,t.from))return!1;i=t.from}else if(i=Re(r.doc,t.from,-1),i==null)return!1;if(e){let s=r.tr.join(i);n&&s.setSelection(E.create(s.doc,i-r.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Or=(r,e)=>{let t=r.selection,n;if(t instanceof E){if(t.node.isTextblock||!G(r.doc,t.to))return!1;n=t.to}else if(n=Re(r.doc,t.to,1),n==null)return!1;return e&&e(r.tr.join(n).scrollIntoView()),!0},Pr=(r,e)=>{let{$from:t,$to:n}=r.selection,i=t.blockRange(n),s=i&&le(i);return s==null?!1:(e&&e(r.tr.lift(i,s).scrollIntoView()),!0)},mn=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
5
|
-
`).scrollIntoView()),!0)};function at(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 $r=(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=at(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(C.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},gn=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof J||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=at(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(P.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},yn=(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(X(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&le(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function Br(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof E&&e.selection.node.isBlock)return!n.parentOffset||!X(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=at(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 P||e.selection instanceof J)&&f.deleteSelection();let u=f.mapping.map(n.pos),d=X(f.doc,u,s.length,s);if(d||(s[0]=l?{type:l}:null,d=X(f.doc,u,s.length,s)),!d)return!1;if(f.split(u,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 Dr=Br(),Fr=(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(E.create(r.doc,i))),!0)};function Lr(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||G(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function wn(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Lr(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=w.empty;for(let y=o.length-1;y>=0;y--)p=w.from(o[y].create(null,p));p=w.from(i.copy(p));let m=r.tr.step(new I(e.pos-1,h,e.pos,h,new x(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&G(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||n>0&&a?null:C.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),d=u&&le(u);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(u,d).scrollIntoView()),!0;if(c&&ie(s,"start",!0)&&ie(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=w.empty;for(let S=p.length-1;S>=0;S--)y=w.from(p[S].copy(y));let k=r.tr.step(new I(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new x(y,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function xn(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(P.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const Wr=xn(-1),Jr=xn(1);function jr(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&rt(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Nt(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),u=f.index();i=f.parent.canReplaceWith(u,u+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 ct(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}ct(st,cn,un);ct(st,hn,pn);ct(mn,gn,yn,Dr);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Hr(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 _r(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function _r(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 Ke(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Ke(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=rt(s,t,n,e);return l?(r&&Vr(r,e,l,i,t),!0):!1}function Vr(r,e,t,n,i){let s=w.empty;for(let f=t.length-1;f>=0;f--)s=w.from(t[f].type.create(t[f].attrs,s));r.step(new I(e.start-(n?2:0),e.end,e.start,e.end,new x(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,u=e.endIndex,d=!0;f<u;f++,d=!1)!d&&X(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return r}function qr(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?Kr(e,t,r,s):Ur(e,t,s):!0:!1}}function Kr(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new I(s-1,o,s,o,new x(w.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Ke(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=le(n);if(l==null)return!1;i.lift(n,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return G(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Ur(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?w.empty:w.from(i))))return!1;let u=s.pos,d=u+o.nodeSize;return n.step(new I(u-(l?1:0),d+(a?1:0),u+1,d-1,new x((l?w.empty:w.from(i.copy(w.empty))).append(a?w.empty:w.from(i.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function Xr(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=w.from(c?r.create():null),u=new x(w.from(r.create(null,w.from(l.type.create(null,f)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new I(d-(c?3:1),h,d,h,u,1,!0)).scrollIntoView())}return!0}}var Yr=Object.defineProperty,ft=(r,e)=>{for(var t in e)Yr(r,t,{get:e[t],enumerable:!0})};function kn(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}}}var Qr=class{constructor(r){this.editor=r.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=r.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:r,editor:e,state:t}=this,{view:n}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(r).map(([o,l])=>[o,(...c)=>{const f=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&n.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o=[],l=!!r,a=r||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(u=>u===!0)),f={...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...p)=>{const m=this.buildProps(a,e),g=d(...p)(m);return o.push(g),f}])),run:c};return f}createCan(r){const{rawCommands:e,state:t}=this,n=!1,i=r||t.tr,s=this.buildProps(i,n);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,n)}}buildProps(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o={tr:r,editor:n,view:s,state:kn({state:i,transaction:r}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(r,e),can:()=>this.createCan(r),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},vn={};ft(vn,{blur:()=>Gr,clearContent:()=>Zr,clearNodes:()=>ei,command:()=>ti,createParagraphNear:()=>ni,cut:()=>ri,deleteCurrentNode:()=>ii,deleteNode:()=>si,deleteRange:()=>oi,deleteSelection:()=>ci,enter:()=>fi,exitCode:()=>ui,extendMarkRange:()=>hi,first:()=>pi,focus:()=>yi,forEach:()=>wi,insertContent:()=>xi,insertContentAt:()=>Si,joinBackward:()=>Ei,joinDown:()=>Mi,joinForward:()=>Ci,joinItemBackward:()=>Ti,joinItemForward:()=>Ai,joinTextblockBackward:()=>Ii,joinTextblockForward:()=>Ni,joinUp:()=>bi,keyboardShortcut:()=>zi,lift:()=>Oi,liftEmptyBlock:()=>Pi,liftListItem:()=>$i,newlineInCode:()=>Bi,resetAttributes:()=>Di,scrollIntoView:()=>Fi,selectAll:()=>Li,selectNodeBackward:()=>Wi,selectNodeForward:()=>Ji,selectParentNode:()=>ji,selectTextblockEnd:()=>Hi,selectTextblockStart:()=>_i,setContent:()=>qi,setMark:()=>ps,setMeta:()=>ms,setNode:()=>gs,setNodeSelection:()=>ys,setTextDirection:()=>ws,setTextSelection:()=>xs,sinkListItem:()=>ks,splitBlock:()=>vs,splitListItem:()=>Ss,toggleList:()=>Ms,toggleMark:()=>Es,toggleNode:()=>Cs,toggleWrap:()=>Ts,undoInputRule:()=>As,unsetAllMarks:()=>Is,unsetMark:()=>Ns,unsetTextDirection:()=>Rs,updateAttributes:()=>zs,wrapIn:()=>Os,wrapInList:()=>Ps});var Gr=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),Zr=(r=!0)=>({commands:e})=>e.setContent("",{emitUpdate:r}),ei=()=>({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,u=c.resolve(f.map(a)),d=c.resolve(f.map(a+l.nodeSize)),h=u.blockRange(d);if(!h)return;const p=le(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},ti=r=>e=>r(e),ni=()=>({state:r,dispatch:e})=>gn(r,e),ri=(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 v.TextSelection(n.doc.resolve(Math.max(o-1,0)))),!0},ii=()=>({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};function N(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}var si=r=>({tr:e,state:t,dispatch:n})=>{const i=N(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},oi=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},li=r=>r.content?/^text(\*|\+)/.test(r.content):!1,Rt=(r,e,t)=>{if(!r.parent.isInline||t==="left"&&r.pos>r.start()||t==="right"&&r.pos<r.end())return r.pos;const n=e.nodes[r.parent.type.name].spec;return li(n)?t==="left"?r.start()-1:r.end()+1:r.pos},ai=(r,e,t)=>{const n=Rt(r,t,"left"),i=Rt(e,t,"right");return{from:n,to:i}},ci=()=>({state:r,dispatch:e})=>{const{$from:t,$to:n}=r.selection;if(r.selection.empty)return!1;const{from:i,to:s}=ai(t,n,r.schema);return e&&(r.tr.deleteRange(i,s).scrollIntoView(),e(r.tr)),!0},fi=()=>({commands:r})=>r.keyboardShortcut("Enter"),ui=()=>({state:r,dispatch:e})=>$r(r,e);function di(r){return Object.prototype.toString.call(r)==="[object RegExp]"}function Ne(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:di(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function Sn(r,e,t={}){return r.find(n=>n.type===e&&Ne(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function zt(r,e,t={}){return!!Sn(r,e,t)}function ut(r,e,t){if(!r||!e)return;let n=r.parent.childAfter(r.parentOffset);if((!n.node||!n.node.marks.some(c=>c.type===e))&&(n=r.parent.childBefore(r.parentOffset)),!n.node||!n.node.marks.some(c=>c.type===e))return;if(!t){const c=n.node.marks.find(f=>f.type===e);c&&(t=c.attrs)}if(!Sn([...n.node.marks],e,t))return;let s=n.index,o=r.start()+n.offset,l=s+1,a=o+n.node.nodeSize;for(;s>0&&zt([...r.parent.child(s-1).marks],e,t);)s-=1,o-=r.parent.child(s).nodeSize;for(;l<r.parent.childCount&&zt([...r.parent.child(l).marks],e,t);)a+=r.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Z(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}var hi=(r,e)=>({tr:t,state:n,dispatch:i})=>{const s=Z(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){const u=ut(a,s,e);if(u&&u.from<=c&&u.to>=f){const d=v.TextSelection.create(o,u.from,u.to);t.setSelection(d)}}return!0},pi=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 Pe(r){return r instanceof v.TextSelection}function U(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function mi(r,e=null){if(!e)return null;const t=v.Selection.atStart(r),n=v.Selection.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?v.TextSelection.create(r,U(0,i,s),U(r.content.size,i,s)):v.TextSelection.create(r,U(e,i,s),U(e,i,s))}function Qe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function me(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function gi(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var yi=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(me()||Qe())&&n.dom.focus(),gi()&&!me()&&!Qe()&&n.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(n.hasFocus()&&r===null||r===!1)return!0}catch{return!1}if(s&&r===null&&!Pe(t.state.selection))return o(),!0;const l=mi(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},wi=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),xi=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),bn=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&&bn(n)}return r};function be(r){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return bn(t)}function ge(r,e,t){if(r instanceof L.Node||r instanceof L.Fragment)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 L.Fragment.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),ge("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new L.Schema({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?L.DOMParser.fromSchema(a).parseSlice(be(r),t.parseOptions):L.DOMParser.fromSchema(a).parse(be(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=L.DOMParser.fromSchema(e);return t.slice?s.parseSlice(be(r),t.parseOptions).content:s.parse(be(r),t.parseOptions)}return ge("",e,t)}function ki(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof T||i instanceof I))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,f)=>{o===0&&(o=f)}),r.setSelection(v.Selection.near(r.doc.resolve(o),t))}var vi=r=>!("type"in r),Si=(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:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{ge(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=ge(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:f,to:u}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},d=!0,h=!0;if((vi(l)?l:[l]).forEach(g=>{g.check(),d=d?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),f===u&&h){const{parent:g}=n.doc.resolve(f);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(f-=1,u+=1)}let m;if(d){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof L.Fragment){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,u)}else{m=l;const g=n.doc.resolve(f),y=g.node(),k=g.parentOffset===0,S=y.isText||y.isTextblock,M=y.content.size>0;k&&S&&M&&h&&(f=Math.max(0,f-1)),n.replaceWith(f,u,m)}t.updateSelection&&ki(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},bi=()=>({state:r,dispatch:e})=>zr(r,e),Mi=()=>({state:r,dispatch:e})=>Or(r,e),Ei=()=>({state:r,dispatch:e})=>cn(r,e),Ci=()=>({state:r,dispatch:e})=>hn(r,e),Ti=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Re(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Ai=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Re(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Ii=()=>({state:r,dispatch:e})=>Nr(r,e),Ni=()=>({state:r,dispatch:e})=>Rr(r,e);function Mn(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ri(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))me()||Mn()?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}var zi=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Ri(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 se(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?N(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(u,d)=>{if(u.isText)return;const h=Math.max(n,d),p=Math.min(i,d+u.nodeSize);l.push({node:u,from:h,to:p})});const a=i-n,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>Ne(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var Oi=(r,e={})=>({state:t,dispatch:n})=>{const i=N(r,t.schema);return se(t,i,e)?Pr(t,n):!1},Pi=()=>({state:r,dispatch:e})=>yn(r,e),$i=r=>({state:e,dispatch:t})=>{const n=N(r,e.schema);return qr(n)(e,t)},Bi=()=>({state:r,dispatch:e})=>mn(r,e);function $e(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function Ot(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}var Di=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=$e(typeof r=="string"?r:r.name,n.schema);if(!l)return!1;l==="node"&&(s=N(r,n.schema)),l==="mark"&&(o=Z(r,n.schema));let a=!1;return t.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(f,u)=>{s&&s===f.type&&(a=!0,i&&t.setNodeMarkup(u,void 0,Ot(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(d=>{o===d.type&&(a=!0,i&&t.addMark(u,u+f.nodeSize,o.create(Ot(d.attrs,e))))})})}),a},Fi=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),Li=()=>({tr:r,dispatch:e})=>{if(e){const t=new v.AllSelection(r.doc);r.setSelection(t)}return!0},Wi=()=>({state:r,dispatch:e})=>un(r,e),Ji=()=>({state:r,dispatch:e})=>pn(r,e),ji=()=>({state:r,dispatch:e})=>Fr(r,e),Hi=()=>({state:r,dispatch:e})=>Jr(r,e),_i=()=>({state:r,dispatch:e})=>Wr(r,e);function Vi(r,e,t={},n={}){return ge(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}var qi=(r,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:n={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(n.preserveWhitespace!=="full"){const c=Vi(r,i.schema,n,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},r,{parseOptions:n,errorOnInvalidContent:e??i.options.enableContentCheck})};function En(r,e){const t=Z(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 Cn(r,e){const t=new rn(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function Ki(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 Ui(r,e){const t=[];return r.descendants((n,i)=>{e(n)&&t.push({node:n,pos:i})}),t}function Xi(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function Tn(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 ye(r){return e=>Tn(e.$from,r)}function oe(r,e,t){return r.config[e]===void 0&&r.parent?oe(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?oe(r.parent,e,t):null}):r.config[e]}function Yi(r){return typeof r=="function"}function _(r,e=void 0,...t){return Yi(r)?e?r.bind(e)(...t):r(...t):r}function An(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 Qi(r){const e=[];let t="",n=!1,i=!1,s=0;const o=r.length;for(let l=0;l<o;l+=1){const a=r[l];if(a==="'"&&!i){n=!n,t+=a;continue}if(a==='"'&&!n){i=!i,t+=a;continue}if(!n&&!i){if(a==="("){s+=1,t+=a;continue}if(a===")"&&s>0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function Pt(r){const e=[],t=Qi(r||""),n=t.length;for(let i=0;i<n;i+=1){const s=t[i],o=s.indexOf(":");if(o===-1)continue;const l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function In(...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=new Map([...Pt(n[i]),...Pt(s)]);n[i]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else n[i]=s}),n},{})}function Gi(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)=>In(t,n),{})}function Nn(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
5
|
+
`).scrollIntoView()),!0)};function at(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 $r=(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=at(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(C.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},gn=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof J||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=at(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(P.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},yn=(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(X(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&le(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function Br(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof E&&e.selection.node.isBlock)return!n.parentOffset||!X(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=at(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 P||e.selection instanceof J)&&f.deleteSelection();let u=f.mapping.map(n.pos),d=X(f.doc,u,s.length,s);if(d||(s[0]=l?{type:l}:null,d=X(f.doc,u,s.length,s)),!d)return!1;if(f.split(u,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 Dr=Br(),Fr=(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(E.create(r.doc,i))),!0)};function Lr(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||G(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function wn(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Lr(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=w.empty;for(let y=o.length-1;y>=0;y--)p=w.from(o[y].create(null,p));p=w.from(i.copy(p));let m=r.tr.step(new I(e.pos-1,h,e.pos,h,new x(p,1,0),o.length,!0)),g=m.doc.resolve(h+2*o.length);g.nodeAfter&&g.nodeAfter.type==i.type&&G(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=s.type.spec.isolating||n>0&&a?null:C.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),d=u&&le(u);if(d!=null&&d>=e.depth)return t&&t(r.tr.lift(u,d).scrollIntoView()),!0;if(c&&ie(s,"start",!0)&&ie(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=w.empty;for(let S=p.length-1;S>=0;S--)y=w.from(p[S].copy(y));let k=r.tr.step(new I(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new x(y,p.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function xn(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(P.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const Wr=xn(-1),Jr=xn(1);function jr(r,e=null){return function(t,n){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&rt(o,r,e);return l?(n&&n(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Nt(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),u=f.index();i=f.parent.canReplaceWith(u,u+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 ct(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}ct(st,cn,un);ct(st,hn,pn);ct(mn,gn,yn,Dr);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Hr(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 _r(l,o,r,e)?(n&&n(l.scrollIntoView()),!0):!1}}function _r(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 Ke(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Ke(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=rt(s,t,n,e);return l?(r&&Vr(r,e,l,i,t),!0):!1}function Vr(r,e,t,n,i){let s=w.empty;for(let f=t.length-1;f>=0;f--)s=w.from(t[f].type.create(t[f].attrs,s));r.step(new I(e.start-(n?2:0),e.end,e.start,e.end,new x(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,u=e.endIndex,d=!0;f<u;f++,d=!1)!d&&X(r.doc,a,l)&&(r.split(a,l),a+=2*l),a+=c.child(f).nodeSize;return r}function qr(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?Kr(e,t,r,s):Ur(e,t,s):!0:!1}}function Kr(r,e,t,n){let i=r.tr,s=n.end,o=n.$to.end(n.depth);s<o&&(i.step(new I(s-1,o,s,o,new x(w.from(t.create(null,n.parent.copy())),1,0),1,!0)),n=new Ke(i.doc.resolve(n.$from.pos),i.doc.resolve(o),n.depth));const l=le(n);if(l==null)return!1;i.lift(n,l);let a=i.doc.resolve(i.mapping.map(s,-1)-1);return G(i.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&i.join(a.pos),e(i.scrollIntoView()),!0}function Ur(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?w.empty:w.from(i))))return!1;let u=s.pos,d=u+o.nodeSize;return n.step(new I(u-(l?1:0),d+(a?1:0),u+1,d-1,new x((l?w.empty:w.from(i.copy(w.empty))).append(a?w.empty:w.from(i.copy(w.empty))),l?0:1,a?0:1),l?0:1)),e(n.scrollIntoView()),!0}function Xr(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=w.from(c?r.create():null),u=new x(w.from(r.create(null,w.from(l.type.create(null,f)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new I(d-(c?3:1),h,d,h,u,1,!0)).scrollIntoView())}return!0}}var Yr=Object.defineProperty,ft=(r,e)=>{for(var t in e)Yr(r,t,{get:e[t],enumerable:!0})};function kn(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}}}var Qr=class{constructor(r){this.editor=r.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=r.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:r,editor:e,state:t}=this,{view:n}=e,{tr:i}=t,s=this.buildProps(i);return Object.fromEntries(Object.entries(r).map(([o,l])=>[o,(...c)=>{const f=l(...c)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&n.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o=[],l=!!r,a=r||i.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(a),o.every(u=>u===!0)),f={...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...p)=>{const m=this.buildProps(a,e),g=d(...p)(m);return o.push(g),f}])),run:c};return f}createCan(r){const{rawCommands:e,state:t}=this,n=!1,i=r||t.tr,s=this.buildProps(i,n);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,n)}}buildProps(r,e=!0){const{rawCommands:t,editor:n,state:i}=this,{view:s}=n,o={tr:r,editor:n,view:s,state:kn({state:i,transaction:r}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(r,e),can:()=>this.createCan(r),get commands(){return Object.fromEntries(Object.entries(t).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},vn={};ft(vn,{blur:()=>Gr,clearContent:()=>Zr,clearNodes:()=>ei,command:()=>ti,createParagraphNear:()=>ni,cut:()=>ri,deleteCurrentNode:()=>ii,deleteNode:()=>si,deleteRange:()=>oi,deleteSelection:()=>ci,enter:()=>fi,exitCode:()=>ui,extendMarkRange:()=>hi,first:()=>pi,focus:()=>yi,forEach:()=>wi,insertContent:()=>xi,insertContentAt:()=>Si,joinBackward:()=>Ei,joinDown:()=>Mi,joinForward:()=>Ci,joinItemBackward:()=>Ti,joinItemForward:()=>Ai,joinTextblockBackward:()=>Ii,joinTextblockForward:()=>Ni,joinUp:()=>bi,keyboardShortcut:()=>zi,lift:()=>Oi,liftEmptyBlock:()=>Pi,liftListItem:()=>$i,newlineInCode:()=>Bi,resetAttributes:()=>Di,scrollIntoView:()=>Fi,selectAll:()=>Li,selectNodeBackward:()=>Wi,selectNodeForward:()=>Ji,selectParentNode:()=>ji,selectTextblockEnd:()=>Hi,selectTextblockStart:()=>_i,setContent:()=>qi,setMark:()=>ps,setMeta:()=>ms,setNode:()=>gs,setNodeSelection:()=>ys,setTextDirection:()=>ws,setTextSelection:()=>xs,sinkListItem:()=>ks,splitBlock:()=>vs,splitListItem:()=>Ss,toggleList:()=>Ms,toggleMark:()=>Es,toggleNode:()=>Cs,toggleWrap:()=>Ts,undoInputRule:()=>As,unsetAllMarks:()=>Is,unsetMark:()=>Ns,unsetTextDirection:()=>Rs,updateAttributes:()=>zs,wrapIn:()=>Os,wrapInList:()=>Ps});var Gr=()=>({editor:r,view:e})=>(requestAnimationFrame(()=>{var t;r.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())==null||t.removeAllRanges())}),!0),Zr=(r=!0)=>({commands:e})=>e.setContent("",{emitUpdate:r}),ei=()=>({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,u=c.resolve(f.map(a)),d=c.resolve(f.map(a+l.nodeSize)),h=u.blockRange(d);if(!h)return;const p=le(h);if(l.type.isTextblock){const{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},ti=r=>e=>r(e),ni=()=>({state:r,dispatch:e})=>gn(r,e),ri=(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 v.TextSelection(n.doc.resolve(Math.max(o-1,0)))),!0},ii=()=>({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};function N(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}var si=r=>({tr:e,state:t,dispatch:n})=>{const i=N(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},oi=r=>({tr:e,dispatch:t})=>{const{from:n,to:i}=r;return t&&e.delete(n,i),!0},li=r=>r.content?/^text(\*|\+)/.test(r.content):!1,Rt=(r,e,t)=>{if(!r.parent.isInline||t==="left"&&r.pos>r.start()||t==="right"&&r.pos<r.end())return r.pos;const n=e.nodes[r.parent.type.name].spec;return li(n)?t==="left"?r.start()-1:r.end()+1:r.pos},ai=(r,e,t)=>{const n=Rt(r,t,"left"),i=Rt(e,t,"right");return{from:n,to:i}},ci=()=>({state:r,dispatch:e})=>{if(r.selection.empty)return!1;if(e){const t=r.tr,{ranges:n}=r.selection,i=t.steps.length;n.forEach(s=>{const o=t.mapping.slice(i),l=t.doc.resolve(o.map(s.$from.pos)),a=t.doc.resolve(o.map(s.$to.pos)),{from:c,to:f}=ai(l,a,r.schema);t.deleteRange(c,f)}),t.scrollIntoView(),e(t)}return!0},fi=()=>({commands:r})=>r.keyboardShortcut("Enter"),ui=()=>({state:r,dispatch:e})=>$r(r,e);function di(r){return Object.prototype.toString.call(r)==="[object RegExp]"}function Ne(r,e,t={strict:!0}){const n=Object.keys(e);return n.length?n.every(i=>t.strict?e[i]===r[i]:di(e[i])?e[i].test(r[i]):e[i]===r[i]):!0}function Sn(r,e,t={}){return r.find(n=>n.type===e&&Ne(Object.fromEntries(Object.keys(t).map(i=>[i,n.attrs[i]])),t))}function zt(r,e,t={}){return!!Sn(r,e,t)}function ut(r,e,t){if(!r||!e)return;let n=r.parent.childAfter(r.parentOffset);if((!n.node||!n.node.marks.some(c=>c.type===e))&&(n=r.parent.childBefore(r.parentOffset)),!n.node||!n.node.marks.some(c=>c.type===e))return;if(!t){const c=n.node.marks.find(f=>f.type===e);c&&(t=c.attrs)}if(!Sn([...n.node.marks],e,t))return;let s=n.index,o=r.start()+n.offset,l=s+1,a=o+n.node.nodeSize;for(;s>0&&zt([...r.parent.child(s-1).marks],e,t);)s-=1,o-=r.parent.child(s).nodeSize;for(;l<r.parent.childCount&&zt([...r.parent.child(l).marks],e,t);)a+=r.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Z(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}var hi=(r,e)=>({tr:t,state:n,dispatch:i})=>{const s=Z(r,n.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){const u=ut(a,s,e);if(u&&u.from<=c&&u.to>=f){const d=v.TextSelection.create(o,u.from,u.to);t.setSelection(d)}}return!0},pi=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 Pe(r){return r instanceof v.TextSelection}function U(r=0,e=0,t=0){return Math.min(Math.max(r,e),t)}function mi(r,e=null){if(!e)return null;const t=v.Selection.atStart(r),n=v.Selection.atEnd(r);if(e==="start"||e===!0)return t;if(e==="end")return n;const i=t.from,s=n.to;return e==="all"?v.TextSelection.create(r,U(0,i,s),U(r.content.size,i,s)):v.TextSelection.create(r,U(e,i,s),U(e,i,s))}function Qe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function me(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function gi(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var yi=(r=null,e={})=>({editor:t,view:n,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(me()||Qe())&&n.dom.focus(),gi()&&!me()&&!Qe()&&n.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{t.isDestroyed||(n.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};try{if(n.hasFocus()&&r===null||r===!1)return!0}catch{return!1}if(s&&r===null&&!Pe(t.state.selection))return o(),!0;const l=mi(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},wi=(r,e)=>t=>r.every((n,i)=>e(n,{...t,index:i})),xi=(r,e)=>({tr:t,commands:n})=>n.insertContentAt({from:t.selection.from,to:t.selection.to},r,e),bn=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&&bn(n)}return r};function be(r){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${r}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return bn(t)}function ge(r,e,t){if(r instanceof L.Node||r instanceof L.Fragment)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 L.Fragment.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),ge("",e,t)}if(i){if(t.errorOnInvalidContent){let o=!1,l="";const a=new L.Schema({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?L.DOMParser.fromSchema(a).parseSlice(be(r),t.parseOptions):L.DOMParser.fromSchema(a).parse(be(r),t.parseOptions),t.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=L.DOMParser.fromSchema(e);return t.slice?s.parseSlice(be(r),t.parseOptions).content:s.parse(be(r),t.parseOptions)}return ge("",e,t)}function ki(r,e,t){const n=r.steps.length-1;if(n<e)return;const i=r.steps[n];if(!(i instanceof T||i instanceof I))return;const s=r.mapping.maps[n];let o=0;s.forEach((l,a,c,f)=>{o===0&&(o=f)}),r.setSelection(v.Selection.near(r.doc.resolve(o),t))}var vi=r=>!("type"in r),Si=(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:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...t.parseOptions};if(!t.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{ge(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){a(g)}try{l=ge(e,s.schema,{parseOptions:c,errorOnInvalidContent:(o=t.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(g){return a(g),!1}let{from:f,to:u}=typeof r=="number"?{from:r,to:r}:{from:r.from,to:r.to},d=!0,h=!0;if((vi(l)?l:[l]).forEach(g=>{g.check(),d=d?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),f===u&&h){const{parent:g}=n.doc.resolve(f);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(f-=1,u+=1)}let m;if(d){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof L.Fragment){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,u)}else{m=l;const g=n.doc.resolve(f),y=g.node(),k=g.parentOffset===0,S=y.isText||y.isTextblock,M=y.content.size>0;k&&S&&M&&h&&(f=Math.max(0,f-1)),n.replaceWith(f,u,m)}t.updateSelection&&ki(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},bi=()=>({state:r,dispatch:e})=>zr(r,e),Mi=()=>({state:r,dispatch:e})=>Or(r,e),Ei=()=>({state:r,dispatch:e})=>cn(r,e),Ci=()=>({state:r,dispatch:e})=>hn(r,e),Ti=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Re(r.doc,r.selection.$from.pos,-1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Ai=()=>({state:r,dispatch:e,tr:t})=>{try{const n=Re(r.doc,r.selection.$from.pos,1);return n==null?!1:(t.join(n,2),e&&e(t),!0)}catch{return!1}},Ii=()=>({state:r,dispatch:e})=>Nr(r,e),Ni=()=>({state:r,dispatch:e})=>Rr(r,e);function Mn(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Ri(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))me()||Mn()?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}var zi=r=>({editor:e,view:t,tr:n,dispatch:i})=>{const s=Ri(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 se(r,e,t={}){const{from:n,to:i,empty:s}=r.selection,o=e?N(e,r.schema):null,l=[];r.doc.nodesBetween(n,i,(u,d)=>{if(u.isText)return;const h=Math.max(n,d),p=Math.min(i,d+u.nodeSize);l.push({node:u,from:h,to:p})});const a=i-n,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>Ne(u.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var Oi=(r,e={})=>({state:t,dispatch:n})=>{const i=N(r,t.schema);return se(t,i,e)?Pr(t,n):!1},Pi=()=>({state:r,dispatch:e})=>yn(r,e),$i=r=>({state:e,dispatch:t})=>{const n=N(r,e.schema);return qr(n)(e,t)},Bi=()=>({state:r,dispatch:e})=>mn(r,e);function $e(r,e){return e.nodes[r]?"node":e.marks[r]?"mark":null}function Ot(r,e){const t=typeof e=="string"?[e]:e;return Object.keys(r).reduce((n,i)=>(t.includes(i)||(n[i]=r[i]),n),{})}var Di=(r,e)=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=$e(typeof r=="string"?r:r.name,n.schema);if(!l)return!1;l==="node"&&(s=N(r,n.schema)),l==="mark"&&(o=Z(r,n.schema));let a=!1;return t.selection.ranges.forEach(c=>{n.doc.nodesBetween(c.$from.pos,c.$to.pos,(f,u)=>{s&&s===f.type&&(a=!0,i&&t.setNodeMarkup(u,void 0,Ot(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(d=>{o===d.type&&(a=!0,i&&t.addMark(u,u+f.nodeSize,o.create(Ot(d.attrs,e))))})})}),a},Fi=()=>({tr:r,dispatch:e})=>(e&&r.scrollIntoView(),!0),Li=()=>({tr:r,dispatch:e})=>{if(e){const t=new v.AllSelection(r.doc);r.setSelection(t)}return!0},Wi=()=>({state:r,dispatch:e})=>un(r,e),Ji=()=>({state:r,dispatch:e})=>pn(r,e),ji=()=>({state:r,dispatch:e})=>Fr(r,e),Hi=()=>({state:r,dispatch:e})=>Jr(r,e),_i=()=>({state:r,dispatch:e})=>Wr(r,e);function Vi(r,e,t={},n={}){return ge(r,e,{slice:!1,parseOptions:t,errorOnInvalidContent:n.errorOnInvalidContent})}var qi=(r,{errorOnInvalidContent:e,emitUpdate:t=!0,parseOptions:n={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:a}=s;if(n.preserveWhitespace!=="full"){const c=Vi(r,i.schema,n,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!t),!0}return o&&s.setMeta("preventUpdate",!t),l.insertContentAt({from:0,to:a.content.size},r,{parseOptions:n,errorOnInvalidContent:e??i.options.enableContentCheck})};function En(r,e){const t=Z(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 Cn(r,e){const t=new rn(r);return e.forEach(n=>{n.steps.forEach(i=>{t.step(i)})}),t}function Ki(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 Ui(r,e){const t=[];return r.descendants((n,i)=>{e(n)&&t.push({node:n,pos:i})}),t}function Xi(r,e,t){const n=[];return r.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&n.push({node:i,pos:s})}),n}function Tn(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 ye(r){return e=>Tn(e.$from,r)}function oe(r,e,t){return r.config[e]===void 0&&r.parent?oe(r.parent,e,t):typeof r.config[e]=="function"?r.config[e].bind({...t,parent:r.parent?oe(r.parent,e,t):null}):r.config[e]}function Yi(r){return typeof r=="function"}function _(r,e=void 0,...t){return Yi(r)?e?r.bind(e)(...t):r(...t):r}function An(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 Qi(r){const e=[];let t="",n=!1,i=!1,s=0;const o=r.length;for(let l=0;l<o;l+=1){const a=r[l];if(a==="'"&&!i){n=!n,t+=a;continue}if(a==='"'&&!n){i=!i,t+=a;continue}if(!n&&!i){if(a==="("){s+=1,t+=a;continue}if(a===")"&&s>0){s-=1,t+=a;continue}if(a===";"&&s===0){e.push(t),t="";continue}}t+=a}return t&&e.push(t),e}function Pt(r){const e=[],t=Qi(r||""),n=t.length;for(let i=0;i<n;i+=1){const s=t[i],o=s.indexOf(":");if(o===-1)continue;const l=s.slice(0,o).trim(),a=s.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function In(...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=new Map([...Pt(n[i]),...Pt(s)]);n[i]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else n[i]=s}),n},{})}function Gi(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)=>In(t,n),{})}function Nn(r,e,t){const{from:n,to:i}=e,{blockSeparator:s=`
|
|
6
6
|
|
|
7
7
|
`,textSerializers:o={}}=t||{};let l="";return r.nodesBetween(n,i,(a,c,f,u)=>{var d;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:u,range:e})),!1;a.isText&&(l+=(d=a==null?void 0:a.text)==null?void 0:d.slice(Math.max(n,c)-c,i-c))}),l}function Zi(r,e){const t={from:0,to:r.content.size};return Nn(r,t,e)}function Rn(r){return Object.fromEntries(Object.entries(r.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function es(r,e){const t=N(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 ts(r,e){const t=$e(typeof e=="string"?e:e.name,r.schema);return t==="node"?es(r,e):t==="mark"?En(r,e):{}}function ns(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 rs(r){const e=ns(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 zn(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),u=e.invert().map(c,-1),d=e.invert().map(f);n.push({oldRange:{from:u,to:d},newRange:{from:c,to:f}})})}),rs(n)}function dt(r,e,t){const n=[];return r===e?t.resolve(r).marks().forEach(i=>{const s=t.resolve(r),o=ut(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}var is=(r,e,t,n=20)=>{const i=r.doc.resolve(t);let s=n,o=null;for(;s>0&&o===null;){const l=i.node(s);(l==null?void 0:l.type.name)===e?o=l:s-=1}return[o,s]};function Te(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 Ge(r,e,t={}){const{empty:n,ranges:i}=r.selection,s=e?Z(e,r.schema):null;if(n)return!!(r.storedMarks||r.selection.$from.marks()).filter(u=>s?s.name===u.type.name:!0).find(u=>Ne(u.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:u,$to:d})=>{const h=u.pos,p=d.pos;r.doc.nodesBetween(h,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),k=Math.min(p,g+m.nodeSize),S=k-y;o+=S,l.push(...m.marks.map(M=>({mark:M,from:y,to:k})))})}),o===0)return!1;const a=l.filter(u=>s?s.name===u.mark.type.name:!0).filter(u=>Ne(u.mark.attrs,t,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>s?u.mark.type!==s&&u.mark.type.excludes(s):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=o}function ss(r,e,t={}){if(!e)return se(r,null,t)||Ge(r,null,t);const n=$e(e,r.schema);return n==="node"?se(r,e,t):n==="mark"?Ge(r,e,t):!1}var ls=(r,e)=>{const{$from:t,$to:n,$anchor:i}=r.selection;if(e){const s=ye(l=>l.type.name===e)(r.selection);if(!s)return!1;const o=r.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(n.parentOffset<n.parent.nodeSize-2||t.pos!==n.pos)},as=r=>{const{$from:e,$to:t}=r.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Ae(r,e){const{nodeExtensions:t}=An(e),n=t.find(o=>o.name===r);if(!n)return!1;const i={name:n.name,options:n.options,storage:n.storage},s=_(oe(n,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function ht(r,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var n;if(t){if(r.type.name==="hardBreak")return!0;if(r.isText)return!/\S/.test((n=r.text)!=null?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&&(ht(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function cs(r){return r instanceof v.NodeSelection}function fs({selection:r,pos:e,nodeSize:t,selectedOnTextSelection:n=!1}){const{from:i,to:s}=r;return!!(i<=e&&s>=e+t||n&&Pe(r)&&i>e&&s<e+t)}var On=class Pn{constructor(e){this.position=e}static fromJSON(e){return new Pn(e.position)}toJSON(){return{position:this.position}}};function us(r,e){const t=e.mapping.mapResult(r.position);return{position:new On(t.pos),mapResult:t}}function ds(r,e,t){const i=r.state.doc.content.size,s=U(e,0,i),o=U(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),u=Math.min(l.left,a.left),d=Math.max(l.right,a.right),h=d-u,p=f-c,y={top:c,bottom:f,left:u,right:d,width:h,height:p,x:u,y:c};return{...y,toJSON:()=>y}}function hs(r,e,t){var n;const{selection:i}=e;let s=null;if(Pe(i)&&(s=i.$cursor),s){const l=(n=r.storedMarks)!=null?n:s.marks();return s.parent.type.allowsMarkType(t)&&(!!t.isInSet(l)||!l.some(c=>c.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,u,d)=>{if(c)return!1;if(f.isInline){const h=!d||d.type.allowsMarkType(t),p=!!t.isInSet(f.marks)||!f.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}var ps=(r,e={})=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Z(r,n.schema);if(i)if(o){const c=En(n,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const f=c.$from.pos,u=c.$to.pos;n.doc.nodesBetween(f,u,(d,h)=>{const p=Math.max(h,f),m=Math.min(h+d.nodeSize,u);d.marks.find(y=>y.type===a)?d.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return hs(n,t,a)},ms=(r,e)=>({tr:t})=>(t.setMeta(r,e),!0),gs=(r,e={})=>({state:t,dispatch:n,chain:i})=>{const s=N(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})=>Nt(s,{...o,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Nt(s,{...o,...e})(l,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ys=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,i=U(r,0,n.content.size),s=v.NodeSelection.create(n,i);e.setSelection(s)}return!0},ws=(r,e)=>({tr:t,state:n,dispatch:i})=>{const{selection:s}=n;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&t.doc.nodesBetween(o,l,(a,c)=>{a.isText||t.setNodeMarkup(c,void 0,{...a.attrs,dir:r})}),!0},xs=r=>({tr:e,dispatch:t})=>{if(t){const{doc:n}=e,{from:i,to:s}=typeof r=="number"?{from:r,to:r}:r,o=v.TextSelection.atStart(n).from,l=v.TextSelection.atEnd(n).to,a=U(i,o,l),c=U(s,o,l),f=v.TextSelection.create(n,a,c);e.setSelection(f)}return!0},ks=r=>({state:e,dispatch:t})=>{const n=N(r,e.schema);return Xr(n)(e,t)};function $t(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)}}var vs=({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=Te(c,l.node().type.name,l.node().attrs);if(s instanceof v.NodeSelection&&s.node.isBlock)return!l.parentOffset||!X(o,l.pos)?!1:(n&&(r&&$t(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:Ki(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=u&&d?[{type:d,attrs:f}]:void 0,p=X(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&X(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(p=!0,h=d?[{type:d,attrs:f}]:void 0),n){if(p&&(s instanceof v.TextSelection&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),d&&!u&&!l.parentOffset&&l.parent.type!==d)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}r&&$t(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return p},Ss=(r,e={})=>({tr:t,state:n,dispatch:i,editor:s})=>{var o;const l=N(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 u=a.node(-1);if(u.type!==l)return!1;const d=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=L.Fragment.empty;const k=a.index(-1)?1:a.index(-2)?2:3;for(let $=a.depth-k;$>=a.depth-3;$-=1)y=L.Fragment.from(a.node($).copy(y));const S=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,M={...Te(d,a.node().type.name,a.node().attrs),...e},b=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(M))||void 0;y=y.append(L.Fragment.from(l.createAndFill(null,b)||void 0));const R=a.before(a.depth-(k-1));t.replace(R,a.after(-S),new L.Slice(y,4-k,0));let z=-1;t.doc.nodesBetween(R,t.doc.content.size,($,j)=>{if(z>-1)return!1;$.isTextblock&&$.content.size===0&&(z=j+1)}),z>-1&&t.setSelection(v.TextSelection.near(t.doc.resolve(z))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Te(d,u.type.name,u.attrs),...e},m={...Te(d,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(!X(t.doc,a.pos,2))return!1;if(i){const{selection:y,storedMarks:k}=n,{splittableMarks:S}=s.extensionManager,M=k||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!M||!i)return!0;const b=M.filter(R=>S.includes(R.type.name));t.ensureMarks(b)}return!0};function Bt(r){return!r||r==="1"?null:r}function $n(r,e){return Bt(r)===Bt(e)}var He=(r,e)=>{const t=ye(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)&&G(r.doc,t.pos))||!$n(t.node.attrs.type,i==null?void 0:i.attrs.type)||r.join(t.pos),!0},_e=(r,e)=>{const t=ye(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)&&G(r.doc,n))||!$n(t.node.attrs.type,i==null?void 0:i.attrs.type)||r.join(n),!0};function bs(r){const e=r.doc,t=e.firstChild;if(!t)return null;const n=e.resolve(1),i=e.resolve(t.nodeSize-1);return v.TextSelection.between(n,i)}var Ms=(r,e,t,n={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:f})=>{const{extensions:u,splittableMarks:d}=i.extensionManager,h=N(r,o.schema),p=N(e,o.schema),{selection:m,storedMarks:g}=o,{$from:y,$to:k}=m,S=y.blockRange(k),M=g||m.$to.parentOffset&&m.$from.marks();if(!S)return!1;const b=ye(K=>Ae(K.type.name,u))(m),R=m.from===0&&m.to===o.doc.content.size,z=o.doc.content.content,$=z.length===1?z[0]:null,j=R&&$&&Ae($.type.name,u)?{node:$,pos:0}:null,q=b??j,Be=!!b&&S.depth>=1&&S.depth-b.depth<=1,ae=!!j;if((Be||ae)&&q){if(q.node.type===h)return R&&ae?a().command(({tr:K,dispatch:D})=>{const B=bs(K);return B?(K.setSelection(B),D&&D(K),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Ae(q.node.type.name,u)&&h.validContent(q.node.content))return a().command(()=>(s.setNodeMarkup(q.pos,h),!0)).command(()=>He(s,h)).command(()=>_e(s,h)).run()}return!t||!M||!l?a().command(()=>f().wrapInList(h,n)?!0:c.clearNodes()).wrapInList(h,n).command(()=>He(s,h)).command(()=>_e(s,h)).run():a().command(()=>{const K=f().wrapInList(h,n),D=M.filter(B=>d.includes(B.type.name));return s.ensureMarks(D),K?!0:c.clearNodes()}).wrapInList(h,n).command(()=>He(s,h)).command(()=>_e(s,h)).run()},Es=(r,e={},t={})=>({state:n,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Z(r,n.schema);return Ge(n,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},Cs=(r,e,t={})=>({state:n,commands:i})=>{const s=N(r,n.schema),o=N(e,n.schema),l=se(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})},Ts=(r,e={})=>({state:t,commands:n})=>{const i=N(r,t.schema);return se(t,i,e)?n.lift(i):n.wrapIn(i,e)},As=()=>({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},Is=(r={})=>({tr:e,dispatch:t,editor:n})=>{const{ignoreClearable:i=!1}=r,{selection:s}=e,{empty:o,ranges:l}=s;if(o)return!0;const{nonClearableMarks:a}=n.extensionManager;if(t){const c=Object.values(n.schema.marks).filter(f=>i||!a.includes(f.name));l.forEach(f=>{for(const u of c)e.removeMark(f.$from.pos,f.$to.pos,u)})}return!0},Ns=(r,e={})=>({tr:t,state:n,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Z(r,n.schema),{$from:c,empty:f,ranges:u}=l;if(!i)return!0;if(f&&o){let{from:d,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))==null?void 0:s.attrs,m=ut(c,a,p);m&&(d=m.from,h=m.to),t.removeMark(d,h,a)}else u.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},Rs=r=>({tr:e,state:t,dispatch:n})=>{const{selection:i}=t;let s,o;return typeof r=="number"?(s=r,o=r):r&&"from"in r&&"to"in r?(s=r.from,o=r.to):(s=i.from,o=i.to),n&&e.doc.nodesBetween(s,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},zs=(r,e={})=>({tr:t,state:n,dispatch:i})=>{let s=null,o=null;const l=$e(typeof r=="string"?r:r.name,n.schema);if(!l)return!1;l==="node"&&(s=N(r,n.schema)),l==="mark"&&(o=Z(r,n.schema));let a=!1;return t.selection.ranges.forEach(c=>{const f=c.$from.pos,u=c.$to.pos;let d,h,p,m;t.selection.empty?n.doc.nodesBetween(f,u,(g,y)=>{s&&s===g.type&&(a=!0,p=Math.max(y,f),m=Math.min(y+g.nodeSize,u),d=y,h=g)}):n.doc.nodesBetween(f,u,(g,y)=>{y<f&&s&&s===g.type&&(a=!0,p=Math.max(y,f),m=Math.min(y+g.nodeSize,u),d=y,h=g),y>=f&&y<=u&&(s&&s===g.type&&(a=!0,i&&t.setNodeMarkup(y,void 0,{...g.attrs,...e})),o&&g.marks.length&&g.marks.forEach(k=>{if(o===k.type&&(a=!0,i)){const S=Math.max(y,f),M=Math.min(y+g.nodeSize,u);t.addMark(S,M,o.create({...k.attrs,...e}))}}))}),h&&(d!==void 0&&i&&t.setNodeMarkup(d,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&i&&t.addMark(p,m,o.create({...g.attrs,...e}))}))}),a},Os=(r,e={})=>({state:t,dispatch:n})=>{const i=N(r,t.schema);return jr(i,e)(t,n)},Ps=(r,e={})=>({state:t,dispatch:n})=>{const i=N(r,t.schema);return Hr(i,e)(t,n)};function $s(r,e){const{selection:t}=r,{$from:n}=t;if(t instanceof v.NodeSelection){const s=n.index();return n.parent.canReplaceWith(s,s+1,e)}let i=n.depth;for(;i>=0;){const s=n.index(i);if(n.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function Bs(r,e,t){const n=document.querySelector(`style[data-tiptap-style${`-${t}`}]`);if(n!==null)return n;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${`-${t}`}`,""),i.innerHTML=r,document.getElementsByTagName("head")[0].appendChild(i),i}function Ds(r){return r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Fs(r,e){const t=r.getAttribute("style");if(!t)return null;const n=t.split(";").map(s=>s.trim()).filter(Boolean),i=e.toLowerCase();for(let s=n.length-1;s>=0;s-=1){const o=n[s],l=o.indexOf(":");if(l===-1)continue;if(o.slice(0,l).trim().toLowerCase()===i)return o.slice(l+1).trim()}return null}function Ls(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}function Ws(r){return typeof r=="number"}function Js(r){return Object.prototype.toString.call(r).slice(8,-1)}function Me(r){return Js(r)!=="Object"?!1:r.constructor===Object&&Object.getPrototypeOf(r)===Object.prototype}var js={};ft(js,{createAtomBlockMarkdownSpec:()=>Hs,createBlockMarkdownSpec:()=>_s,createInlineMarkdownSpec:()=>Bn,parseAttributes:()=>pt,parseIndentedBlocks:()=>Dn,renderNestedMarkdownContent:()=>Fn,serializeAttributes:()=>mt});function pt(r){if(!(r!=null&&r.trim()))return{};const e={},t=[],n=r.replace(/["']([^"']*)["']/g,c=>(t.push(c),`__QUOTED_${t.length-1}__`)),i=n.match(/(?:^|\s)\.([\w-]+)/g);if(i){const c=i.map(f=>f.trim().slice(1));e.class=c.join(" ")}const s=n.match(/(?:^|\s)#([\w-]+)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(n.matchAll(o)).forEach(([,c,f])=>{var u;const d=parseInt(((u=f.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),h=t[d];h&&(e[c]=h.slice(1,-1))});const a=n.replace(/(?:^|\s)\.([\w-]+)/g,"").replace(/(?:^|\s)#([\w-]+)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(f=>{f.match(/^[a-zA-Z][\w-]*$/)&&(e[f]=!0)}),e}function mt(r){if(!r||Object.keys(r).length===0)return"";const e=[];return r.class&&String(r.class).split(/\s+/).filter(Boolean).forEach(n=>e.push(`.${n}`)),r.id&&e.push(`#${r.id}`),Object.entries(r).forEach(([t,n])=>{t==="class"||t==="id"||(n===!0?e.push(t):n!==!1&&n!=null&&e.push(`${t}="${String(n)}"`))}),e.join(" ")}function Hs(r){const{nodeName:e,name:t,parseAttributes:n=pt,serializeAttributes:i=mt,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=r,a=t||e,c=f=>{if(!l)return f;const u={};return l.forEach(d=>{d in f&&(u[d]=f[d])}),u};return{parseMarkdown:(f,u)=>{const d={...s,...f.attributes};return u.createNode(e,d,[])},markdownTokenizer:{name:e,level:"block",start(f){var u;const d=new RegExp(`^:::${a}(?:\\s|$)`,"m"),h=(u=f.match(d))==null?void 0:u.index;return h!==void 0?h:-1},tokenize(f,u,d){const h=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=f.match(h);if(!p)return;const m=p[1]||"",g=n(m);if(!o.find(k=>!(k in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:f=>{const u=c(f.attrs||{}),d=i(u),h=d?` {${d}}`:"";return`:::${a}${h} :::`}}}function _s(r){const{nodeName:e,name:t,getContent:n,parseAttributes:i=pt,serializeAttributes:s=mt,defaultAttributes:o={},content:l="block",allowedAttributes:a}=r,c=t||e,f=u=>{if(!a)return u;const d={};return a.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{let h;if(n){const m=n(u);h=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?h=d.parseChildren(u.tokens||[]):h=d.parseInline(u.tokens||[]);const p={...o,...u.attributes};return d.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${c}`,"m"),p=(d=u.match(h))==null?void 0:d.index;return p!==void 0?p:-1},tokenize(u,d,h){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=u.match(m);if(!g)return;const[y,k=""]=g,S=i(k);let M=1;const b=y.length;let R="";const z=/^:::([\w-]*)(\s.*)?/gm,$=u.slice(b);for(z.lastIndex=0;;){const j=z.exec($);if(j===null)break;const q=j.index,Be=j[1];if(!((p=j[2])!=null&&p.endsWith(":::"))){if(Be)M+=1;else if(M-=1,M===0){const ae=$.slice(0,q);R=ae.trim();const K=u.slice(0,b+q+j[0].length);let D=[];if(R)if(l==="block")for(D=h.blockTokens(ae),D.forEach(B=>{B.text&&(!B.tokens||B.tokens.length===0)&&(B.tokens=h.inlineTokens(B.text))});D.length>0;){const B=D[D.length-1];if(B.type==="paragraph"&&(!B.text||B.text.trim()===""))D.pop();else break}else D=h.inlineTokens(R);return{type:e,raw:K,attributes:S,content:R,tokens:D}}}}}},renderMarkdown:(u,d)=>{const h=f(u.attrs||{}),p=s(h),m=p?` {${p}}`:"",g=d.renderChildren(u.content||[],`
|
|
8
8
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";const c=require("./index-
|
|
2
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(tt,this.editor.getAttributes(_)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=c.wrappingInputRule({find:S,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=c.wrappingInputRule({find:S,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(_),editor:this.editor})),[t]}}),et=(t,e,n)=>{const{selection:s}=t;if(!s.empty)return null;const{$from:r}=s;if(!r.parent.isTextblock||r.parentOffset!==r.parent.content.size)return null;let i=-1;for(let p=r.depth;p>0;p-=1)if(r.node(p).type.name===e){i=p;break}if(i<0)return null;const a=r.node(i),o=r.index(i);if(o+1>=a.childCount)return null;const l=a.child(o+1);if(!n.includes(l.type.name))return null;const f=t.schema.nodes[e];let h=!1;if(l.forEach(p=>{p.type===f&&p.childCount>1&&(h=!0)}),!h)return null;const u=t.doc.resolve(r.after()).nodeAfter;if(!u||!n.includes(u.type.name))return null;const d=[];return u.forEach(p=>{d.push(p)}),d.length===0?null:{listItemDepth:i,nestedList:u,nestedListPos:r.after(),insertPos:r.after(i),items:d}},nt=(t,e,n,s)=>{const r=et(t,n,s);if(!r)return!1;const{selection:i}=t,{nestedList:a,nestedListPos:o,insertPos:l,items:f}=r,h=t.tr;h.delete(o,o+a.nodeSize);const u=h.mapping.map(l);return h.insert(u,Z.Fragment.from(f)),h.setSelection(i.map(h.doc,h.mapping)),e&&e(h),!0},st=(t,e,n)=>nt(t.state,t.view.dispatch,e,n),H=(t,e)=>c.Extension.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>st(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),B=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],b="abcdefghijklmnopqrstuvwxyz",rt="[a-zA-Z]{1,2}",C=String.raw`\d+|[ivxlcdmIVXLCDM]+|${rt}`;function T(t){let e=t,n="";for(const[s,r]of B)for(;e>=s;)n+=r,e-=s;return n}function N(t){return T(t).toUpperCase()}function j(t){const e=t.toLowerCase();let n=0,s=0;for(;n<e.length;){let r=!1;for(const[i,a]of B)if(e.startsWith(a,n)){s+=i,n+=a.length,r=!0;break}if(!r)return 0}return s}function it(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=j(t);return e<=0?!1:(t===t.toLowerCase()?T(e):N(e))===t}function ot(t){const e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const n=e.charCodeAt(0)-97,s=e.charCodeAt(1)-97;return(n+1)*26+s+1}return 0}function v(t){if(t<=26)return b[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?b[n]:b[e]+b[n]}function I(t){if(!(!t||/^\d+$/.test(t))){if(it(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function E(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=I(t);if(e==="i"||e==="I")return j(t);if(e==="a"||e==="A"){const s=ot(t);return s>0?s:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function at(t,e){if(t==="numeric")return String(e);switch(t){case"a":return v(e);case"A":return v(e).toUpperCase();case"i":return T(e);case"I":return N(e);default:return String(e)}}function ut(t){var e;if(t.length===0)return!1;const n=(e=I(t[0]))!=null?e:"numeric",s=E(t[0]);if(s<1)return!1;for(let r=0;r<t.length;r++){const i=at(n,s+r);if(t[r]!==i)return!1}return!0}function ct(t){return{type:I(t),start:E(t)}}function lt(t){const{type:e,start:n}=ct(t),s={};return e&&(s.type=e),n!==1&&(s.start=n),s}function dt(t,e,n=". "){const s=e+1;if(!t||t==="1")return`${s}${n}`;switch(t){case"a":return`${v(s)}${n}`;case"A":return`${v(s).toUpperCase()}${n}`;case"i":return`${T(s)}${n}`;case"I":return`${N(s)}${n}`;default:return`${s}${n}`}}function pt(t){var e,n;const s=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&(s==null?void 0:s.type)==="list"&&s.ordered&&s.raw===t.text)}function ht(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var ft=c.Node3.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",c.mergeAttributes(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const s=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let r=[];if(t.tokens&&t.tokens.length>0){if(pt(t))return{type:"listItem",content:[{type:"paragraph",content:ht(t.text||"",e)}]};if(t.tokens.some(a=>a.type==="paragraph"))r=s(t.tokens);else{const a=t.tokens[0];if(a&&a.type==="text"&&a.tokens&&a.tokens.length>0){if(r=[{type:"paragraph",content:e.parseInline(a.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),f=s(l);r.push(...f)}}else r=s(t.tokens)}}return r.length===0&&(r=[{type:"paragraph",content:[]}]),{type:"listItem",content:r}},renderMarkdown:(t,e,n)=>c.renderNestedMarkdownContent(t,e,s=>{var r,i,a,o;if(s.parentType==="bulletList")return"- ";if(s.parentType==="orderedList"){const l=((i=(r=s.meta)==null?void 0:r.parentAttrs)==null?void 0:i.start)||1,f=(o=(a=s.meta)==null?void 0:a.parentAttrs)==null?void 0:o.type,h=l-1+(s.index||0);return dt(f,h,". ")}return"- "},n),addExtensions(){return[H(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),mt={};Q(mt,{findListItemPos:()=>A,getNextListDepth:()=>R,handleBackspace:()=>x,handleDelete:()=>M,hasListBefore:()=>K,hasListItemAfter:()=>Lt,hasListItemBefore:()=>kt,listItemHasSubList:()=>gt,nextListIsDeeper:()=>z,nextListIsHigher:()=>V});var A=(t,e)=>{const{$from:n}=e.selection,s=c.getNodeType(t,e.schema);let r=null,i=n.depth,a=n.pos,o=null;for(;i>0&&o===null;)r=n.node(i),r.type===s?o=i:(i-=1,a-=1);return o===null?null:{$pos:e.doc.resolve(a),depth:o}},R=(t,e)=>{const n=A(t,e);if(!n)return!1;const[,s]=c.getNodeAtPosition(e,t,n.$pos.pos+4);return s},K=(t,e,n)=>{const{$anchor:s}=t.selection,r=Math.max(0,s.pos-2),i=t.doc.resolve(r).node();return!(!i||!n.includes(i.type.name))},x=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!c.isNodeActive(t.state,e)&&K(t.state,e,n)){const{$anchor:s}=t.state.selection,r=t.state.doc.resolve(s.before()-1),i=[];r.node().descendants((l,f)=>{l.type.name===e&&i.push({node:l,pos:f})});const a=i.at(-1);if(!a)return!1;const o=t.state.doc.resolve(r.start()+a.pos+1);return t.chain().cut({from:s.start()-1,to:s.end()+1},o.end()).joinForward().run()}return!c.isNodeActive(t.state,e)||!c.isAtStartOfNode(t.state)?!1:t.chain().liftListItem(e).run()},z=(t,e)=>{const n=R(t,e),s=A(t,e);return!s||!n?!1:n>s.depth},V=(t,e)=>{const n=R(t,e),s=A(t,e);return!s||!n?!1:n<s.depth},M=(t,e)=>{if(!c.isNodeActive(t.state,e)||!c.isAtEndOfNode(t.state,e))return!1;const{selection:n}=t.state,{$from:s,$to:r}=n;return!n.empty&&s.sameParent(r)?!1:z(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():V(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},Lt=(t,e)=>{var n;const{$anchor:s}=e.selection,r=e.doc.resolve(s.pos-s.parentOffset-2);return!(r.index()===r.parent.childCount-1||((n=r.nodeAfter)==null?void 0:n.type.name)!==t)},kt=(t,e)=>{var n;const{$anchor:s}=e.selection,r=e.doc.resolve(s.pos-2);return!(r.index()===0||((n=r.nodeBefore)==null?void 0:n.type.name)!==t)},gt=(t,e,n)=>{if(!n)return!1;const s=c.getNodeType(t,e.schema);let r=!1;return n.descendants(i=>{i.type===s&&(r=!0)}),r},yt=c.Extension.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&M(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&M(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&x(t,n,s)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&x(t,n,s)&&(e=!0)}),e}}}}),w=new RegExp(`^(\\s*)(${C})([.)])\\s+(.*)$`),bt=new RegExp(`^(\\s*)(${C})([.)])\\s+`),vt=/^\s/;function Tt(t){return w.test(t.trimStart())}function It(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||Tt(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function At(t){const e=[],n=[];let s=!1;return t.forEach(r=>{if(s){n.push(r);return}if(r.trim()===""){s=!0,n.push(r);return}if(e.length>0&&It(r)){s=!0,n.push(r);return}e.push(r)}),{paragraphLines:e,blockLines:n}}function xt(t){const e=[];let n=0,s=0;for(;n<t.length;){const r=t[n],i=r.match(w);if(!i)break;const[,a,o,l,f]=i,h=a.length,u=parseInt(o,10),d=isNaN(u)?I(o):void 0,p=isNaN(u)?E(o):u,k=[f];let m=n+1;const L=[r];let y=!1;for(;m<t.length;){const g=t[m];if(g.match(w))break;if(g.trim()==="")L.push(g),k.push(""),y=!0,m+=1;else if(g.match(vt)){const W=g.length-g.trimStart().length,G=h+o.length+1;L.push(g),k.push(g.slice(Math.min(W,G))),m+=1}else{if(y)break;L.push(g),k.push(g),m+=1}}e.push({indent:h,number:p,type:d,content:k.join(`
|
|
1
|
+
"use strict";const c=require("./index-EoGU7W4e.cjs"),J=require("@tiptap/pm/model"),Y=require("@tiptap/pm/state");var Q=Object.defineProperty,tt=(t,e)=>{for(var n in e)Q(t,n,{get:e[n],enumerable:!0})},et="listItem",$="textStyle",S=/^\s*([-+*])\s$/,H=c.Node3.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",c.mergeAttributes(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
2
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(et,this.editor.getAttributes($)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=c.wrappingInputRule({find:S,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=c.wrappingInputRule({find:S,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes($),editor:this.editor})),[t]}}),nt=(t,e,n)=>{const{selection:s}=t;if(!s.empty)return null;const{$from:r}=s;if(!r.parent.isTextblock||r.parentOffset!==r.parent.content.size)return null;let i=-1;for(let p=r.depth;p>0;p-=1)if(r.node(p).type.name===e){i=p;break}if(i<0)return null;const a=r.node(i),o=r.index(i);if(o+1>=a.childCount)return null;const l=a.child(o+1);if(!n.includes(l.type.name))return null;const f=t.schema.nodes[e];let h=!1;if(l.forEach(p=>{p.type===f&&p.childCount>1&&(h=!0)}),!h)return null;const u=t.doc.resolve(r.after()).nodeAfter;if(!u||!n.includes(u.type.name))return null;const d=[];return u.forEach(p=>{d.push(p)}),d.length===0?null:{listItemDepth:i,nestedList:u,nestedListPos:r.after(),insertPos:r.after(i),items:d}},st=(t,e,n,s)=>{const r=nt(t,n,s);if(!r)return!1;const{selection:i}=t,{nestedList:a,nestedListPos:o,insertPos:l,items:f}=r,h=t.tr;h.delete(o,o+a.nodeSize);const u=h.mapping.map(l);return h.insert(u,J.Fragment.from(f)),h.setSelection(i.map(h.doc,h.mapping)),e&&e(h),!0},rt=(t,e,n)=>st(t.state,t.view.dispatch,e,n),B=(t,e)=>c.Extension.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>rt(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),j=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],v="abcdefghijklmnopqrstuvwxyz",it="[a-zA-Z]{1,2}",N=String.raw`\d+|[ivxlcdmIVXLCDM]+|${it}`;function T(t){let e=t,n="";for(const[s,r]of j)for(;e>=s;)n+=r,e-=s;return n}function E(t){return T(t).toUpperCase()}function K(t){const e=t.toLowerCase();let n=0,s=0;for(;n<e.length;){let r=!1;for(const[i,a]of j)if(e.startsWith(a,n)){s+=i,n+=a.length,r=!0;break}if(!r)return 0}return s}function ot(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=K(t);return e<=0?!1:(t===t.toLowerCase()?T(e):E(e))===t}function at(t){const e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const n=e.charCodeAt(0)-97,s=e.charCodeAt(1)-97;return(n+1)*26+s+1}return 0}function I(t){if(t<=26)return v[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?v[n]:v[e]+v[n]}function A(t){if(!(!t||/^\d+$/.test(t))){if(ot(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function R(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=A(t);if(e==="i"||e==="I")return K(t);if(e==="a"||e==="A"){const s=at(t);return s>0?s:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function ut(t,e){if(t==="numeric")return String(e);switch(t){case"a":return I(e);case"A":return I(e).toUpperCase();case"i":return T(e);case"I":return E(e);default:return String(e)}}function ct(t){var e;if(t.length===0)return!1;const n=(e=A(t[0]))!=null?e:"numeric",s=R(t[0]);if(s<1)return!1;for(let r=0;r<t.length;r++){const i=ut(n,s+r);if(t[r]!==i)return!1}return!0}function lt(t){return{type:A(t),start:R(t)}}function dt(t){const{type:e,start:n}=lt(t),s={};return e&&(s.type=e),n!==1&&(s.start=n),s}function pt(t,e,n=". "){const s=e+1;if(!t||t==="1")return`${s}${n}`;switch(t){case"a":return`${I(s)}${n}`;case"A":return`${I(s).toUpperCase()}${n}`;case"i":return`${T(s)}${n}`;case"I":return`${E(s)}${n}`;default:return`${s}${n}`}}function ht(t){var e,n;const s=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&(s==null?void 0:s.type)==="list"&&s.ordered&&s.raw===t.text)}function ft(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var mt=c.Node3.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",c.mergeAttributes(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const s=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let r=[];if(t.tokens&&t.tokens.length>0){if(ht(t))return{type:"listItem",content:[{type:"paragraph",content:ft(t.text||"",e)}]};if(t.tokens.some(a=>a.type==="paragraph"))r=s(t.tokens);else{const a=t.tokens[0];if(a&&a.type==="text"&&a.tokens&&a.tokens.length>0){if(r=[{type:"paragraph",content:e.parseInline(a.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),f=s(l);r.push(...f)}}else r=s(t.tokens)}}return r.length===0&&(r=[{type:"paragraph",content:[]}]),{type:"listItem",content:r}},renderMarkdown:(t,e,n)=>c.renderNestedMarkdownContent(t,e,s=>{var r,i,a,o;if(s.parentType==="bulletList")return"- ";if(s.parentType==="orderedList"){const l=((i=(r=s.meta)==null?void 0:r.parentAttrs)==null?void 0:i.start)||1,f=(o=(a=s.meta)==null?void 0:a.parentAttrs)==null?void 0:o.type,h=l-1+(s.index||0);return pt(f,h,". ")}return"- "},n),addExtensions(){return[B(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Lt={};tt(Lt,{findListItemPos:()=>x,getNextListDepth:()=>_,handleBackspace:()=>M,handleDelete:()=>w,hasListBefore:()=>z,hasListItemAfter:()=>kt,hasListItemBefore:()=>gt,listItemHasSubList:()=>yt,nextListIsDeeper:()=>F,nextListIsHigher:()=>V});var x=(t,e)=>{const{$from:n}=e.selection,s=c.getNodeType(t,e.schema);let r=null,i=n.depth,a=n.pos,o=null;for(;i>0&&o===null;)r=n.node(i),r.type===s?o=i:(i-=1,a-=1);return o===null?null:{$pos:e.doc.resolve(a),depth:o}},_=(t,e)=>{const n=x(t,e);if(!n)return!1;const[,s]=c.getNodeAtPosition(e,t,n.$pos.pos+4);return s},z=(t,e,n)=>{const{$anchor:s}=t.selection,r=Math.max(0,s.pos-2),i=t.doc.resolve(r).node();return!(!i||!n.includes(i.type.name))},M=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!c.isNodeActive(t.state,e)&&z(t.state,e,n)){const{$anchor:s}=t.state.selection,r=t.state.doc.resolve(s.before()-1),i=[];r.node().descendants((l,f)=>{l.type.name===e&&i.push({node:l,pos:f})});const a=i.at(-1);if(!a)return!1;const o=t.state.doc.resolve(r.start()+a.pos+1);return t.chain().cut({from:s.start()-1,to:s.end()+1},o.end()).joinForward().run()}return!c.isNodeActive(t.state,e)||!c.isAtStartOfNode(t.state)?!1:t.chain().liftListItem(e).run()},F=(t,e)=>{const n=_(t,e),s=x(t,e);return!s||!n?!1:n>s.depth},V=(t,e)=>{const n=_(t,e),s=x(t,e);return!s||!n?!1:n<s.depth},w=(t,e)=>{if(!c.isNodeActive(t.state,e)||!c.isAtEndOfNode(t.state,e))return!1;const{selection:n}=t.state,{$from:s,$to:r}=n;return!n.empty&&s.sameParent(r)?!1:F(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():V(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},kt=(t,e)=>{var n;const{$anchor:s}=e.selection,r=e.doc.resolve(s.pos-s.parentOffset-2);return!(r.index()===r.parent.childCount-1||((n=r.nodeAfter)==null?void 0:n.type.name)!==t)},gt=(t,e)=>{var n;const{$anchor:s}=e.selection,r=e.doc.resolve(s.pos-2);return!(r.index()===0||((n=r.nodeBefore)==null?void 0:n.type.name)!==t)},yt=(t,e,n)=>{if(!n)return!1;const s=c.getNodeType(t,e.schema);let r=!1;return n.descendants(i=>{i.type===s&&(r=!0)}),r},bt=c.Extension.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&w(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&w(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&M(t,n,s)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:s})=>{t.state.schema.nodes[n]!==void 0&&M(t,n,s)&&(e=!0)}),e}}}}),C=new RegExp(`^(\\s*)(${N})([.)])\\s+(.*)$`),vt=new RegExp(`^(\\s*)(${N})([.)])\\s+`),It=/^\s/,b={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Tt(t){return C.test(t.trimStart())}function At(t){const e=t.trimStart();return b.bulletItem.test(e)||Tt(e)||b.heading.test(e)||b.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||b.codeFence.test(e)}function xt(t){return Object.values(b).some(e=>e.test(t))}function Mt(t){const e=[],n=[];let s=!1;return t.forEach(r=>{if(s){n.push(r);return}if(r.trim()===""){s=!0,n.push(r);return}if(e.length>0&&At(r)){s=!0,n.push(r);return}e.push(r)}),{paragraphLines:e,blockLines:n}}function wt(t){const e=[];let n=0,s=0;for(;n<t.length;){const r=t[n],i=r.match(C);if(!i)break;const[,a,o,l,f]=i,h=a.length,u=parseInt(o,10),d=isNaN(u)?A(o):void 0,p=isNaN(u)?R(o):u,k=[f];let m=n+1;const L=[r];let y=!1;for(;m<t.length;){const g=t[m];if(g.match(C))break;if(g.trim()==="")L.push(g),k.push(""),y=!0,m+=1;else if(g.match(It)){const G=g.length-g.trimStart().length,Z=h+o.length+1;L.push(g),k.push(g.slice(Math.min(G,Z))),m+=1}else{if(y||xt(g))break;L.push(g),k.push(g),m+=1}}e.push({indent:h,number:p,type:d,content:k.join(`
|
|
3
3
|
`).trim(),contentLines:k,raw:L.join(`
|
|
4
|
-
`)}),s=m,n=m}return[e,s]}var
|
|
5
|
-
`).filter(i=>i.trim().length>0);if(e.length===0)return null;const n=[];for(const i of e){const a=i.trim().match(
|
|
4
|
+
`)}),s=m,n=m}return[e,s]}var Ct=new RegExp(`^(${N})([.)])\\s+(.+)$`);function Nt(t){const e=t.split(`
|
|
5
|
+
`).filter(i=>i.trim().length>0);if(e.length===0)return null;const n=[];for(const i of e){const a=i.trim().match(Ct);if(!a)return null;n.push({marker:a[1],content:a[3]})}const s=n.map(i=>i.marker);return ct(s)?{type:"orderedList",attrs:dt(n[0].marker),content:n.map(i=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:i.content}]}]}))}:null}function X(t,e,n){const s=[];let r=0;for(;r<t.length;){const i=t[r];if(i.indent===e){const{paragraphLines:a,blockLines:o}=Mt(i.contentLines),l=a.join(`
|
|
6
6
|
`).trim(),f=[];l&&f.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const h=o.join(`
|
|
7
7
|
`).trim();if(h){const p=n.blockTokens(h);f.push(...p)}let u=r+1;const d=[];for(;u<t.length&&t[u].indent>e;)d.push(t[u]),u+=1;if(d.length>0){const p=Math.min(...d.map(m=>m.indent)),k=X(d,p,n);f.push({type:"list",ordered:!0,start:d[0].number,typeMarker:d[0].type,items:k,raw:d.map(m=>m.raw).join(`
|
|
8
|
-
`)})}s.push({type:"list_item",raw:i.raw,tokens:f}),r=u}else r+=1}return s}function
|
|
9
|
-
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(
|
|
10
|
-
`),[a,o]=
|
|
11
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(
|
|
12
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const s=i=>{const a=c.parseIndentedBlocks(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:s},n);return a?[{type:"taskList",raw:a.raw,items:a.items}]:n.blockTokens(i)},r=c.parseIndentedBlocks(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,a)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:a}),customNestedParser:s},n);if(r)return{type:"taskList",raw:r.raw,items:r.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});c.Extension.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(
|
|
8
|
+
`)})}s.push({type:"list_item",raw:i.raw,tokens:f}),r=u}else r+=1}return s}function Et(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const s=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(r=>{if(r.type==="paragraph"||r.type==="list"||r.type==="blockquote"||r.type==="code")s.push(...e.parseChildren([r]));else if(r.type==="text"&&r.tokens){const i=e.parseChildren([r]);s.push({type:"paragraph",content:i})}else{const i=e.parseChildren([r]);i.length>0&&s.push(...i)}}),{type:"listItem",content:s}})}var Rt="listItem",D="textStyle",O=/^(\d+)\.\s$/;function P(t){const e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var q=c.Node3.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>{const e=t.getAttribute("type");if(e)return e;const n=t.getAttribute("style");if(n){const r=P(n);if(r)return r}const s=t.querySelector("li");if(s){const r=s.getAttribute("style");if(r){const i=P(r);if(i)return i}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:n,...s}=t,r=c.mergeAttributes(this.options.HTMLAttributes,s);return e!==1&&(r.start=e),n&&n!=="1"&&(r.type=n),["ol",r,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,s=t.typeMarker,r=t.items?Et(t.items,e):[],i={};return n!==1&&(i.start=n),s&&(i.type=s),Object.keys(i).length>0?{type:"orderedList",attrs:i,content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
9
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(vt),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var s,r;const i=t.split(`
|
|
10
|
+
`),[a,o]=wt(i);if(a.length===0)return;const l=X(a,a[0].indent,n);if(l.length===0)return;const f=((s=a[0])==null?void 0:s.number)||1,h=(r=a[0])==null?void 0:r.type;return{type:"list",ordered:!0,start:f,typeMarker:h,items:l,raw:i.slice(0,o).join(`
|
|
11
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Rt,this.editor.getAttributes(D)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new Y.Plugin({props:{handlePaste:(t,e)=>{var n,s;const r=(n=e.clipboardData)==null?void 0:n.getData("text/html");if(r!=null&&r.trim())return!1;const i=(s=e.clipboardData)==null?void 0:s.getData("text/plain");if(!i)return!1;const a=Nt(i);if(!a)return!1;try{const o=t.state.schema.nodeFromJSON(a),l=t.state.tr.replaceSelectionWith(o);return t.dispatch(l),!0}catch{return!1}}}})]},addInputRules(){const t=(n,s)=>(!s.attrs.type||s.attrs.type==="1")&&s.childCount+s.attrs.start===+n[1];let e=c.wrappingInputRule({find:O,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=c.wrappingInputRule({find:O,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(D)}),joinPredicate:t,editor:this.editor})),[e]}}),_t=/^\s*(\[([( |x])?\])\s$/,U=c.Node3.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",c.mergeAttributes(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const s=e.parseChildren(t.nestedTokens);n.push(...s)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const r=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return c.renderNestedMarkdownContent(t,e,r)},addExtensions(){return this.options.nested?[B(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:s})=>{const r=document.createElement("li"),i=document.createElement("label"),a=document.createElement("span"),o=document.createElement("input"),l=document.createElement("div"),f=u=>{var d,p;o.ariaLabel=((p=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:p.call(d,u,o.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};f(t),i.contentEditable="false",o.type="checkbox",o.addEventListener("mousedown",u=>u.preventDefault()),o.addEventListener("change",u=>{if(!s.isEditable&&!this.options.onReadOnlyChecked){o.checked=!o.checked;return}const{checked:d}=u.target;s.isEditable&&typeof n=="function"&&s.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const k=n();if(typeof k!="number")return!1;const m=p.doc.nodeAt(k);return p.setNodeMarkup(k,void 0,{...m==null?void 0:m.attrs,checked:d}),!0}).run(),!s.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(o.checked=!o.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{r.setAttribute(u,d)}),r.dataset.checked=t.attrs.checked,o.checked=t.attrs.checked,i.append(o,a),r.append(i,l),Object.entries(e).forEach(([u,d])=>{r.setAttribute(u,d)});let h=new Set(Object.keys(e));return{dom:r,contentDOM:l,update:u=>{if(u.type!==this.type)return!1;r.dataset.checked=u.attrs.checked,o.checked=u.attrs.checked,f(u);const d=s.extensionManager.attributes,p=c.getRenderedAttributes(u,d),k=new Set(Object.keys(p)),m=this.options.HTMLAttributes;return h.forEach(L=>{k.has(L)||(L in m?r.setAttribute(L,m[L]):r.removeAttribute(L))}),Object.entries(p).forEach(([L,y])=>{y==null?L in m?r.setAttribute(L,m[L]):r.removeAttribute(L):r.setAttribute(L,y)}),h=k,!0}}}},addInputRules(){return[c.wrappingInputRule({find:_t,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),W=c.Node3.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",c.mergeAttributes(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
12
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const s=i=>{const a=c.parseIndentedBlocks(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:o=>({indentLevel:o[1].length,mainContent:o[4],checked:o[3].toLowerCase()==="x"}),createToken:(o,l)=>({type:"taskItem",raw:"",mainContent:o.mainContent,indentLevel:o.indentLevel,checked:o.checked,text:o.mainContent,tokens:n.inlineTokens(o.mainContent),nestedTokens:l}),customNestedParser:s},n);return a?[{type:"taskList",raw:a.raw,items:a.items}]:n.blockTokens(i)},r=c.parseIndentedBlocks(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,a)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:a}),customNestedParser:s},n);if(r)return{type:"taskList",raw:r.raw,items:r.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});c.Extension.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(H.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(mt.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(bt.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(q.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(U.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(W.configure(this.options.taskList)),t}});exports.BulletList=H;exports.OrderedList=q;exports.TaskItem=U;exports.TaskList=W;
|