@tempots/beatui 0.31.0 → 0.32.1
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/dist/{2019-C660mMK6.js → 2019-BAbSTPyW.js} +2 -2
- package/dist/{2019-BY_FFnZU.cjs → 2019-BMZkvreo.cjs} +1 -1
- package/dist/{2020-C3P-aGet.js → 2020-BQNEk3m-.js} +2 -2
- package/dist/{2020-Cyyhc8pv.cjs → 2020-COaJ7nGc.cjs} +1 -1
- package/dist/{ar-DcFl4tkv.cjs → ar-CqAHPRKu.cjs} +1 -1
- package/dist/{ar-BUxQ3yNv.js → ar-avevuYiW.js} +1 -1
- package/dist/auth/index.cjs.js +1 -1
- package/dist/auth/index.es.js +4 -4
- package/dist/beatui.css +187 -5
- package/dist/beatui.tailwind.css +187 -5
- package/dist/{de-DEUS3n0J.cjs → de--4OtRESW.cjs} +1 -1
- package/dist/{de-CKKQr2-K.js → de-Cz7ah611.js} +1 -1
- package/dist/{es-CIeoDpkc.cjs → es-CE1wRgxl.cjs} +1 -1
- package/dist/{es-C5VUn_X1.js → es-CiNQQzF1.js} +1 -1
- package/dist/{fa-gXa9Xdjn.cjs → fa-DjuJZNLK.cjs} +1 -1
- package/dist/{fa-Cs2LZsfr.js → fa-Gkt0b9XN.js} +1 -1
- package/dist/{fr-6SpJ-gVV.cjs → fr-DotyzMGL.cjs} +1 -1
- package/dist/{fr-Dlw8mKFp.js → fr-xM9p9Q6G.js} +1 -1
- package/dist/{he-D9cwxZOb.cjs → he-BQ6ygVEQ.cjs} +1 -1
- package/dist/{he-Cm4NxsyE.js → he-CoO6PsiS.js} +1 -1
- package/dist/{hi-CNRHnMsQ.cjs → hi-BCfJ0mRh.cjs} +1 -1
- package/dist/{hi-Cjz1aQX2.js → hi-DA3-4Cdo.js} +1 -1
- package/dist/{index-klVI8k8O.cjs → index-1_pssujS.cjs} +2 -2
- package/dist/{index-CXY0yKJD.cjs → index-B4irUWVb.cjs} +1 -1
- package/dist/{index-C-FUCwXi.js → index-CDOHHPwQ.js} +4 -4
- package/dist/{index-CYY_JLSN.cjs → index-CFh4D56e.cjs} +1 -1
- package/dist/{index-DwyUOY3r.js → index-Caetcp0r.js} +1 -1
- package/dist/{index-Jd2O_Iux.js → index-DfmwsIle.js} +5 -5
- package/dist/{index-DKy2mZws.cjs → index-DqeaEUPG.cjs} +1 -1
- package/dist/{index-_Kh76-c2.js → index-E76KKV9V.js} +1 -1
- package/dist/index.cjs.js +4 -4
- package/dist/index.es.js +1570 -1492
- package/dist/{it-iuFeIEsO.js → it-EdPuWBJR.js} +1 -1
- package/dist/{it-DvBJ31Ls.cjs → it-pv2Gm3jb.cjs} +1 -1
- package/dist/{ja-D6Dd96v-.js → ja-BSRCR430.js} +1 -1
- package/dist/{ja-FKJGj5My.cjs → ja-CuRaPMgh.cjs} +1 -1
- package/dist/json-schema/index.cjs.js +1 -1
- package/dist/json-schema/index.es.js +1 -1
- package/dist/{ko-PqVOGPUi.cjs → ko-C7YP1PL4.cjs} +1 -1
- package/dist/{ko-C8GOsfIU.js → ko-Dm4oD1fh.js} +1 -1
- package/dist/{modal-RQtwnFy9.cjs → modal-CepbiM3u.cjs} +1 -1
- package/dist/{modal-CuhK7DqK.js → modal-eY-3j_zS.js} +2 -2
- package/dist/monaco/index.cjs.js +1 -1
- package/dist/monaco/index.es.js +1 -1
- package/dist/{nl-Ct2cyWWi.js → nl-B0l1kdfd.js} +1 -1
- package/dist/{nl-DAhT0vfu.cjs → nl-ClCD6lP-.cjs} +1 -1
- package/dist/{notice-Dz_BJg8D.js → notice-Ct8ZHvwq.js} +1 -1
- package/dist/{notice-BnX2sRrK.cjs → notice-cpODDUvJ.cjs} +1 -1
- package/dist/{pl-DewgRE-k.js → pl-DVKneBSY.js} +1 -1
- package/dist/{pl-JgD0mCRa.cjs → pl-fyCkqVrr.cjs} +1 -1
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/{pt-BkoMl_PC.cjs → pt-BHExG3lf.cjs} +1 -1
- package/dist/{pt-CNyp2zeW.js → pt-Bw0sTDOX.js} +1 -1
- package/dist/{ru-U6PdSzha.js → ru-B26VQ4f9.js} +1 -1
- package/dist/{ru-9OW0HQFS.cjs → ru-PuEOLDw1.cjs} +1 -1
- package/dist/theme-B7C5kIJj.cjs +1 -0
- package/dist/theme-DsQOxXW1.js +34 -0
- package/dist/{toolbar-DTh9Ouhs.js → toolbar-ClJbaKID.js} +1 -1
- package/dist/{toolbar-D7fDCmUn.cjs → toolbar-kwkvH3nX.cjs} +1 -1
- package/dist/{tr-DsOaoQqh.cjs → tr-CI97fTpD.cjs} +1 -1
- package/dist/{tr-CQVvooxi.js → tr-DQMivdvy.js} +1 -1
- package/dist/{translations-Cic51rHH.js → translations-1yD6Rm5l.js} +1 -1
- package/dist/{translations-BDRano6u.cjs → translations-DQxg-W9w.cjs} +1 -1
- package/dist/{translations-DDFTHcX3.cjs → translations-ZB5oDFId.cjs} +1 -1
- package/dist/{translations-D4PjDB1t.js → translations-iam7PITs.js} +2 -2
- package/dist/types/components/beatui.d.ts +4 -1
- package/dist/types/components/navigation/tabs/tabs.d.ts +6 -1
- package/dist/types/components/overlay/index.d.ts +1 -0
- package/dist/types/components/overlay/ribbon.d.ts +22 -0
- package/dist/types/components/theme/theme.d.ts +5 -2
- package/dist/{ur-C8v4y2tI.cjs → ur-B3CiO8KH.cjs} +1 -1
- package/dist/{ur-C3LypxEh.js → ur-o3rog5MJ.js} +1 -1
- package/dist/{utils-D8WljbbZ.cjs → utils-CCAYvnZh.cjs} +1 -1
- package/dist/{utils-DY9kZecl.js → utils-CuD-_CDx.js} +2 -2
- package/dist/{vi-M5ObJg3d.js → vi-C7cb2K_B.js} +1 -1
- package/dist/{vi-DzLo7qhK.cjs → vi-FibsLfdk.cjs} +1 -1
- package/dist/{zh-BXk4IZBo.cjs → zh-BtSj_Euh.cjs} +1 -1
- package/dist/{zh-DGA8R46s.js → zh-NGrfqAHM.js} +1 -1
- package/package.json +1 -1
- package/dist/theme-CJVt8QIc.js +0 -34
- package/dist/theme-YS3sFklH.cjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const S=require("@tempots/dom"),It=require("./toolbar-D7fDCmUn.cjs"),Rr=require("./translations-BDRano6u.cjs"),jo=require("./link-portal-_tiDFZqh.cjs"),Uo=require("@tempots/ui"),Ko=require("./theme-YS3sFklH.cjs");function Ii(t,e){return Ri(t,e)!=null}function Ri(t,e){const{from:n,$from:r,to:u,empty:i}=t.selection;if(!e)return null;if(i){if(t.storedMarks){const c=t.storedMarks.find(f=>f.type.name===e.name);if(c!=null)return c}const l=r.marks().find(c=>c.type.name===e.name);if(l!=null)return l;const a=r.nodeAfter;if(a&&a.marks){const c=a.marks.find(f=>f.type.name===e.name);if(c!=null)return c}return null}let s=null;return t.doc.nodesBetween(n,u,o=>{if(s!=null)return!1;if(o.marks){const l=o.marks.find(a=>a.type.name===e.name);if(l!=null)return s=l,!1}}),s}function ln(t,e,n){return t.map(()=>{const r=e.value,u=r.state.schema.marks[n];return Ii(r.state,u)})}function Zo(t,e,n){const{$from:r}=t.selection;for(let i=r.depth;i>0;i--){const s=r.node(i);if(s.type.name===e.name)return n!=null?Object.keys(n).every(o=>s.attrs[o]===n[o]):!0}const u=t.doc.nodeAt(r.pos);return u&&u.type.name===e.name?n!=null?Object.keys(n).every(i=>u.attrs[i]===n[i]):!0:!1}function Dt(t,e,n,r){return t.map(()=>{const u=e.value,i=u.state.schema.nodes[n];return i?Zo(u.state,i,r):!1})}function fe({active:t,display:e,onClick:n,disabled:r,label:u,icon:i,size:s}){return S.When(e,()=>It.ToolbarButton({onClick:n,disabled:r,variant:t.map(o=>o?"filled":"light"),size:s},S.attr.title(u),Rr.Icon({icon:i,size:s})))}function Go(t,e){const n=t.state.schema.marks.link;if(n==null)return;const{from:r,to:u}=t.state.selection,i=t.state.tr.addMark(r,u,n.create({href:e,title:null}));t.dispatch(i),t.focus()}function Bi(t){const{state:e}=t,{$from:n,$to:r}=e.selection;if(!vi(e))return null;let u=n.pos,i=r.pos;const s=e.doc;for(;u>0&&s.resolve(u-1).nodeAfter?.marks?.some(a=>a.type.name==="link");)u--;for(;i<s.content.size&&s.resolve(i).nodeAfter?.marks?.some(a=>a.type.name==="link");)i++;return{start:u,end:i}}function Yo(t,e){const n=t.state.schema.marks.link;if(n==null)return;const r=Bi(t);if(r==null)return;const{start:u,end:i}=r,s=t.state.tr.removeMark(u,i,n).addMark(u,i,n.create({href:e,title:null}));t.dispatch(s)}function Xo(t){const e=t.state.schema.marks.link;if(e==null)return;const n=Bi(t);if(n==null)return;const{start:r,end:u}=n,i=t.state.tr.removeMark(r,u,e);t.dispatch(i),t.focus()}function vi(t){return Ii(t,t.schema.marks.link)}function Qo({stateUpdate:t,view:e,isReadOnly:n,label:r,linkUrlPlaceholder:u,size:i}){const s=S.prop(null);s.on(l=>{l!=null&&Yo(e.value,l)});const o=t.on(()=>{const l=Ri(e.value.state,e.value.state.schema.marks.link);l!=null?s.set(l.attrs.href??""):s.set(null)});return S.Fragment(S.OnDispose(s.dispose,o),It.ToolbarGroup(fe({display:S.signal(!0),active:ln(t,e,"link"),disabled:n,label:r,icon:"mdi:link-variant",size:i,onClick:()=>{const l=e.value.state;if(vi(l))Xo(e.value),s.set(null);else{const a="";Go(e.value,a),s.set(a)}}}),S.Ensure(s,l=>Rr.TextInput({value:l,autofocus:!0,onInput:s.set,placeholder:u,size:i}))),S.Ensure(s,l=>It.ToolbarButton({disabled:l.map(a=>a.trim()===""),variant:"text",onClick:()=>{const a=s.value;a&&window.open(a,"_blank")},size:i},"go")))}function tn({display:t},...e){return S.When(S.computedOf(...t)((...n)=>n.some(Boolean)),()=>It.ToolbarGroup(...e))}function zi({view:t,stateUpdate:e,features:n,readOnly:r=S.signal(!1),size:u="sm"}){return S.Ensure(t,i=>S.Use(Rr.BeatUII18n,s=>{const o=s.$.prosemirror,l=i;return It.Toolbar(tn({display:[n.$.bold,n.$.italic,n.$.code]},fe({active:ln(e,l,"strong"),display:n.$.bold,onClick:()=>Ln(l.value,"strong"),disabled:r,label:o.$.bold,icon:"mdi:format-bold",size:u}),fe({active:ln(e,l,"em"),display:n.$.italic,onClick:()=>Ln(l.value,"em"),disabled:r,label:o.$.italic,icon:"mdi:format-italic",size:u}),fe({active:ln(e,l,"code"),display:n.$.code,onClick:()=>Ln(l.value,"code"),disabled:r,label:o.$.code,icon:"mdi:code-tags",size:u})),tn({display:[n.$.headings]},S.Repeat(n.$.headerLevels.map(a=>Math.min(Math.max(a,1),6)),({counter:a})=>fe({active:Dt(e,l,"heading",{level:a}),display:n.$.headings,onClick:()=>el(l.value,a),disabled:r,label:o.map(c=>c.heading(a)),icon:`mdi:format-header-${a}`,size:u}))),tn({display:[n.$.bulletList,n.$.orderedList]},fe({active:Dt(e,l,"bullet_list"),display:n.$.bulletList,onClick:()=>lu(l.value,"bullet_list"),disabled:r,label:o.$.bulletList,icon:"mdi:format-list-bulleted",size:u}),fe({active:Dt(e,l,"ordered_list"),display:n.$.orderedList,onClick:()=>lu(l.value,"ordered_list"),disabled:r,label:o.$.orderedList,icon:"mdi:format-list-numbered",size:u})),tn({display:[n.$.blockquote,n.$.codeBlock,n.$.horizontalRule]},fe({active:Dt(e,l,"blockquote"),display:n.$.blockquote,onClick:()=>tl(l.value),disabled:r,label:o.$.blockquote,icon:"mdi:format-quote-close",size:u}),fe({active:Dt(e,l,"code_block"),display:n.$.codeBlock,onClick:()=>nl(l.value),disabled:r,label:o.$.codeBlock,icon:"mdi:code-braces",size:u}),fe({active:S.signal(!1),display:n.$.horizontalRule,onClick:()=>rl(l.value),disabled:r,label:o.$.horizontalRule,icon:"mdi:minus",size:u})),S.When(n.$.links,()=>Qo({stateUpdate:e,view:l,isReadOnly:r,label:o.$.link,linkUrlPlaceholder:o.$.linkUrlPlaceholder,size:u})))}))}async function Ln(t,e){const{toggleMark:n}=await Promise.resolve().then(()=>zn),r=t.state.schema.marks[e];r!=null&&(n(r)(t.state,t.dispatch),t.focus())}async function el(t,e){const{setBlockType:n}=await Promise.resolve().then(()=>zn),r=t.state.schema.nodes.heading;r!=null&&(n(r,{level:e})(t.state,t.dispatch),t.focus())}async function lu(t,e){const{wrapInList:n,liftListItem:r}=await Promise.resolve().then(()=>require("./index-DKy2mZws.cjs")),u=t.state.schema.nodes[e],i=t.state.schema.nodes.list_item;if(u==null||i==null)return;const{state:s}=t,{$from:o}=s.selection;let l=null;for(let a=o.depth;a>0;a--){const c=o.node(a);if(c.type.name==="bullet_list"||c.type.name==="ordered_list"){l=c.type.name;break}}l===e?r(i)(s,t.dispatch):l!=null?r(i)(t.state,t.dispatch)&&n(u)(t.state,t.dispatch):n(u)(s,t.dispatch),t.focus()}async function tl(t){const{wrapIn:e,lift:n}=await Promise.resolve().then(()=>zn),r=t.state.schema.nodes.blockquote;if(r==null)return;const{state:u}=t,{$from:i}=u.selection;let s=!1;for(let o=i.depth;o>0;o--)if(i.node(o).type.name==="blockquote"){s=!0;break}s?n(u,t.dispatch):e(r)(u,t.dispatch),t.focus()}async function nl(t){const{setBlockType:e}=await Promise.resolve().then(()=>zn),n=t.state.schema.nodes.code_block,r=t.state.schema.nodes.paragraph;if(n==null||r==null)return;const{state:u}=t,{$from:i}=u.selection;let s=!1;for(let o=i.depth;o>0;o--)if(i.node(o).type.name==="code_block"){s=!0;break}s?e(r)(u,t.dispatch):e(n)(u,t.dispatch),t.focus()}function rl(t){const e=t.state.schema.nodes.horizontal_rule;if(e!=null){const n=t.state.tr.replaceSelectionWith(e.create());t.dispatch(n),t.focus()}}function q(t){this.content=t}q.prototype={constructor:q,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,u=r.find(t),i=r.content.slice();return u==-1?i.push(n||t,e):(i[u+1]=e,n&&(i[u]=n)),new q(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new q(n)},addToStart:function(t,e){return new q([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new q(n)},addBefore:function(t,e,n){var r=this.remove(e),u=r.content.slice(),i=r.find(t);return u.splice(i==-1?u.length:i,0,e,n),new q(u)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=q.from(t),t.size?new q(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=q.from(t),t.size?new q(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=q.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};q.from=function(t){if(t instanceof q)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new q(e)};function Pi(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let u=t.child(r),i=e.child(r);if(u==i){n+=u.nodeSize;continue}if(!u.sameMarkup(i))return n;if(u.isText&&u.text!=i.text){for(let s=0;u.text[s]==i.text[s];s++)n++;return n}if(u.content.size||i.content.size){let s=Pi(u.content,i.content,n+1);if(s!=null)return s}n+=u.nodeSize}}function Li(t,e,n,r){for(let u=t.childCount,i=e.childCount;;){if(u==0||i==0)return u==i?null:{a:n,b:r};let s=t.child(--u),o=e.child(--i),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let a=0,c=Math.min(s.text.length,o.text.length);for(;a<c&&s.text[s.text.length-a-1]==o.text[o.text.length-a-1];)a++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let a=Li(s.content,o.content,n-1,r-1);if(a)return a}n-=l,r-=l}}class k{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,u=0,i){for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;if(a>e&&r(l,u+o,i||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,u+c)}o=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,u){let i="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let a=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?u?typeof u=="function"?u(o):u:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&r&&(s?s=!1:i+=r),i+=a},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,u=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(u[u.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)u.push(e.content[i]);return new k(u,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],u=0;if(n>e)for(let i=0,s=0;s<n;i++){let o=this.content[i],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),u+=o.nodeSize),s=l}return new k(r,u)}cutByIndex(e,n){return e==n?k.empty:e==0&&n==this.content.length?this:new k(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let u=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return u[e]=n,new k(u,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let u=this.content[n];e(u,r,n),r+=u.nodeSize}}findDiffStart(e,n=0){return Pi(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Li(this,e,n,r)}findIndex(e){if(e==0)return nn(0,e);if(e==this.size)return nn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let u=this.child(n),i=r+u.nodeSize;if(i>=e)return i==e?nn(n+1,i):nn(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return k.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let n,r=0;for(let u=0;u<e.length;u++){let i=e[u];r+=i.nodeSize,u&&i.isText&&e[u-1].sameMarkup(i)?(n||(n=e.slice(0,u)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new k(n||e,r)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const qn={index:0,offset:0};function nn(t,e){return qn.index=t,qn.offset=e,qn}function hn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!hn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!hn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class T{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let u=0;u<e.length;u++){let i=e[u];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,u));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,u)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let u=r.create(n.attrs);return r.checkAttrs(u.attrs),u}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return T.none;if(e instanceof T)return[e];let n=e.slice();return n.sort((r,u)=>r.type.rank-u.type.rank),n}}T.none=[];class pn extends Error{}class _{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Vi(this.content,e+this.openStart,n);return r&&new _(r,this.openStart,this.openEnd)}removeBetween(e,n){return new _(qi(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return _.empty;let r=n.openStart||0,u=n.openEnd||0;if(typeof r!="number"||typeof u!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _(k.fromJSON(e,n.content),r,u)}static maxOpen(e,n=!0){let r=0,u=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)u++;return new _(e,r,u)}}_.empty=new _(k.empty,0,0);function qi(t,e,n){let{index:r,offset:u}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(u==e||i.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(qi(i.content,e-u-1,n-u-1)))}function Vi(t,e,n,r){let{index:u,offset:i}=t.findIndex(e),s=t.maybeChild(u);if(i==e||s.isText)return r&&!r.canReplace(u,u,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Vi(s.content,e-i-1,n,s);return o&&t.replaceChild(u,s.copy(o))}function ul(t,e,n){if(n.openStart>t.depth)throw new pn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new pn("Inconsistent open depths");return $i(t,e,n,0)}function $i(t,e,n,r){let u=t.index(r),i=t.node(r);if(u==e.index(r)&&r<t.depth-n.openStart){let s=$i(t,e,n,r+1);return i.copy(i.content.replaceChild(u,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Ge(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=il(n,t);return Ge(i,Hi(t,s,o,e,r))}else return Ge(i,mn(t,e,r))}function Wi(t,e){if(!e.type.compatibleContent(t.type))throw new pn("Cannot join "+e.type.name+" onto "+t.type.name)}function pr(t,e,n){let r=t.node(n);return Wi(r,e.node(n)),r}function Ze(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function wt(t,e,n,r){let u=(e||t).node(n),i=0,s=e?e.index(n):u.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ze(t.nodeAfter,r),i++));for(let o=i;o<s;o++)Ze(u.child(o),r);e&&e.depth==n&&e.textOffset&&Ze(e.nodeBefore,r)}function Ge(t,e){return t.type.checkContent(e),t.copy(e)}function Hi(t,e,n,r,u){let i=t.depth>u&&pr(t,e,u+1),s=r.depth>u&&pr(n,r,u+1),o=[];return wt(null,t,u,o),i&&s&&e.index(u)==n.index(u)?(Wi(i,s),Ze(Ge(i,Hi(t,e,n,r,u+1)),o)):(i&&Ze(Ge(i,mn(t,e,u+1)),o),wt(e,n,u,o),s&&Ze(Ge(s,mn(n,r,u+1)),o)),wt(r,null,u,o),new k(o)}function mn(t,e,n){let r=[];if(wt(null,t,n,r),t.depth>n){let u=pr(t,e,n+1);Ze(Ge(u,mn(t,e,n+1)),r)}return wt(e,null,n,r),new k(r)}function il(t,e){let n=e.depth-t.openStart,u=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)u=e.node(i).copy(k.from(u));return{start:u.resolveNoCache(t.openStart+n),end:u.resolveNoCache(u.content.size-t.openEnd-n)}}class Rt{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],u=e.child(n);return r?e.child(n).cut(r):u}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],u=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)u+=r.child(i).nodeSize;return u}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return T.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),u=e.maybeChild(n);if(!r){let o=r;r=u,u=o}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!u||!i[s].isInSet(u.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,u=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!u||!r[i].isInSet(u.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ji(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],u=0,i=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(i),a=i-l;if(r.push(s,o,u+l),!a||(s=s.child(o),s.isText))break;i=a-1,u+=l+1}return new Rt(n,r,i)}static resolveCached(e,n){let r=au.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else au.set(e,r=new sl);let u=r.elts[r.i]=Rt.resolve(e,n);return r.i=(r.i+1)%ol,u}}class sl{constructor(){this.elts=[],this.i=0}}const ol=12,au=new WeakMap;class Ji{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ll=Object.create(null);class be{constructor(e,n,r,u=T.none){this.type=e,this.attrs=n,this.marks=u,this.content=r||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,u=0){this.content.nodesBetween(e,n,r,u,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,u){return this.content.textBetween(e,n,r,u)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&hn(this.attrs,n||e.defaultAttrs||ll)&&T.sameSet(this.marks,r||T.none)}copy(e=null){return e==this.content?this:new be(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new be(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return _.empty;let u=this.resolve(e),i=this.resolve(n),s=r?0:u.sharedDepth(n),o=u.start(s),a=u.node(s).content.cut(u.pos-o,i.pos-o);return new _(a,u.depth-s,i.depth-s)}replace(e,n,r){return ul(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:u}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(u==e||n.isText)return n;e-=u+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let u=this.content.child(n-1);return{node:u,index:n-1,offset:r-u.nodeSize}}resolve(e){return Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.resolve(this,e)}rangeHasMark(e,n,r){let u=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(u=!0),!u)),u}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ji(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=k.empty,u=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,u,i),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=u;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,u){if(u&&!this.type.allowsMarks(u))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=T.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!T.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let u=k.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,u,r);return i.type.checkAttrs(i.attrs),i}}be.prototype.text=void 0;class gn extends be{constructor(e,n,r,u){if(super(e,n,null,u),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ji(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new gn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gn(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ji(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class et{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new al(e,n);if(r.next==null)return et.empty;let u=Ui(r);r.next&&r.err("Unexpected trailing text");let i=gl(ml(u));return bl(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let u=this;for(let i=n;u&&i<r;i++)u=u.matchType(e.child(i).type);return u}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let u=[this];function i(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return k.from(o.map(a=>a.createAndFill()));for(let a=0;a<s.next.length;a++){let{type:c,next:f}=s.next[a];if(!(c.isText||c.hasRequiredAttrs())&&u.indexOf(f)==-1){u.push(f);let p=i(f,o.concat(c));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let u=r.shift(),i=u.match;if(i.matchType(e)){let s=[];for(let o=u;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:o,next:l}=i.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!u.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:u}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let u=0;u<r.next.length;u++)e.indexOf(r.next[u].next)==-1&&n(r.next[u].next)}return n(this),e.map((r,u)=>{let i=u+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
|
|
1
|
+
"use strict";const S=require("@tempots/dom"),It=require("./toolbar-kwkvH3nX.cjs"),Rr=require("./translations-DQxg-W9w.cjs"),jo=require("./link-portal-_tiDFZqh.cjs"),Uo=require("@tempots/ui"),Ko=require("./theme-B7C5kIJj.cjs");function Ii(t,e){return Ri(t,e)!=null}function Ri(t,e){const{from:n,$from:r,to:u,empty:i}=t.selection;if(!e)return null;if(i){if(t.storedMarks){const c=t.storedMarks.find(f=>f.type.name===e.name);if(c!=null)return c}const l=r.marks().find(c=>c.type.name===e.name);if(l!=null)return l;const a=r.nodeAfter;if(a&&a.marks){const c=a.marks.find(f=>f.type.name===e.name);if(c!=null)return c}return null}let s=null;return t.doc.nodesBetween(n,u,o=>{if(s!=null)return!1;if(o.marks){const l=o.marks.find(a=>a.type.name===e.name);if(l!=null)return s=l,!1}}),s}function ln(t,e,n){return t.map(()=>{const r=e.value,u=r.state.schema.marks[n];return Ii(r.state,u)})}function Zo(t,e,n){const{$from:r}=t.selection;for(let i=r.depth;i>0;i--){const s=r.node(i);if(s.type.name===e.name)return n!=null?Object.keys(n).every(o=>s.attrs[o]===n[o]):!0}const u=t.doc.nodeAt(r.pos);return u&&u.type.name===e.name?n!=null?Object.keys(n).every(i=>u.attrs[i]===n[i]):!0:!1}function Dt(t,e,n,r){return t.map(()=>{const u=e.value,i=u.state.schema.nodes[n];return i?Zo(u.state,i,r):!1})}function fe({active:t,display:e,onClick:n,disabled:r,label:u,icon:i,size:s}){return S.When(e,()=>It.ToolbarButton({onClick:n,disabled:r,variant:t.map(o=>o?"filled":"light"),size:s},S.attr.title(u),Rr.Icon({icon:i,size:s})))}function Go(t,e){const n=t.state.schema.marks.link;if(n==null)return;const{from:r,to:u}=t.state.selection,i=t.state.tr.addMark(r,u,n.create({href:e,title:null}));t.dispatch(i),t.focus()}function Bi(t){const{state:e}=t,{$from:n,$to:r}=e.selection;if(!vi(e))return null;let u=n.pos,i=r.pos;const s=e.doc;for(;u>0&&s.resolve(u-1).nodeAfter?.marks?.some(a=>a.type.name==="link");)u--;for(;i<s.content.size&&s.resolve(i).nodeAfter?.marks?.some(a=>a.type.name==="link");)i++;return{start:u,end:i}}function Yo(t,e){const n=t.state.schema.marks.link;if(n==null)return;const r=Bi(t);if(r==null)return;const{start:u,end:i}=r,s=t.state.tr.removeMark(u,i,n).addMark(u,i,n.create({href:e,title:null}));t.dispatch(s)}function Xo(t){const e=t.state.schema.marks.link;if(e==null)return;const n=Bi(t);if(n==null)return;const{start:r,end:u}=n,i=t.state.tr.removeMark(r,u,e);t.dispatch(i),t.focus()}function vi(t){return Ii(t,t.schema.marks.link)}function Qo({stateUpdate:t,view:e,isReadOnly:n,label:r,linkUrlPlaceholder:u,size:i}){const s=S.prop(null);s.on(l=>{l!=null&&Yo(e.value,l)});const o=t.on(()=>{const l=Ri(e.value.state,e.value.state.schema.marks.link);l!=null?s.set(l.attrs.href??""):s.set(null)});return S.Fragment(S.OnDispose(s.dispose,o),It.ToolbarGroup(fe({display:S.signal(!0),active:ln(t,e,"link"),disabled:n,label:r,icon:"mdi:link-variant",size:i,onClick:()=>{const l=e.value.state;if(vi(l))Xo(e.value),s.set(null);else{const a="";Go(e.value,a),s.set(a)}}}),S.Ensure(s,l=>Rr.TextInput({value:l,autofocus:!0,onInput:s.set,placeholder:u,size:i}))),S.Ensure(s,l=>It.ToolbarButton({disabled:l.map(a=>a.trim()===""),variant:"text",onClick:()=>{const a=s.value;a&&window.open(a,"_blank")},size:i},"go")))}function tn({display:t},...e){return S.When(S.computedOf(...t)((...n)=>n.some(Boolean)),()=>It.ToolbarGroup(...e))}function zi({view:t,stateUpdate:e,features:n,readOnly:r=S.signal(!1),size:u="sm"}){return S.Ensure(t,i=>S.Use(Rr.BeatUII18n,s=>{const o=s.$.prosemirror,l=i;return It.Toolbar(tn({display:[n.$.bold,n.$.italic,n.$.code]},fe({active:ln(e,l,"strong"),display:n.$.bold,onClick:()=>Ln(l.value,"strong"),disabled:r,label:o.$.bold,icon:"mdi:format-bold",size:u}),fe({active:ln(e,l,"em"),display:n.$.italic,onClick:()=>Ln(l.value,"em"),disabled:r,label:o.$.italic,icon:"mdi:format-italic",size:u}),fe({active:ln(e,l,"code"),display:n.$.code,onClick:()=>Ln(l.value,"code"),disabled:r,label:o.$.code,icon:"mdi:code-tags",size:u})),tn({display:[n.$.headings]},S.Repeat(n.$.headerLevels.map(a=>Math.min(Math.max(a,1),6)),({counter:a})=>fe({active:Dt(e,l,"heading",{level:a}),display:n.$.headings,onClick:()=>el(l.value,a),disabled:r,label:o.map(c=>c.heading(a)),icon:`mdi:format-header-${a}`,size:u}))),tn({display:[n.$.bulletList,n.$.orderedList]},fe({active:Dt(e,l,"bullet_list"),display:n.$.bulletList,onClick:()=>lu(l.value,"bullet_list"),disabled:r,label:o.$.bulletList,icon:"mdi:format-list-bulleted",size:u}),fe({active:Dt(e,l,"ordered_list"),display:n.$.orderedList,onClick:()=>lu(l.value,"ordered_list"),disabled:r,label:o.$.orderedList,icon:"mdi:format-list-numbered",size:u})),tn({display:[n.$.blockquote,n.$.codeBlock,n.$.horizontalRule]},fe({active:Dt(e,l,"blockquote"),display:n.$.blockquote,onClick:()=>tl(l.value),disabled:r,label:o.$.blockquote,icon:"mdi:format-quote-close",size:u}),fe({active:Dt(e,l,"code_block"),display:n.$.codeBlock,onClick:()=>nl(l.value),disabled:r,label:o.$.codeBlock,icon:"mdi:code-braces",size:u}),fe({active:S.signal(!1),display:n.$.horizontalRule,onClick:()=>rl(l.value),disabled:r,label:o.$.horizontalRule,icon:"mdi:minus",size:u})),S.When(n.$.links,()=>Qo({stateUpdate:e,view:l,isReadOnly:r,label:o.$.link,linkUrlPlaceholder:o.$.linkUrlPlaceholder,size:u})))}))}async function Ln(t,e){const{toggleMark:n}=await Promise.resolve().then(()=>zn),r=t.state.schema.marks[e];r!=null&&(n(r)(t.state,t.dispatch),t.focus())}async function el(t,e){const{setBlockType:n}=await Promise.resolve().then(()=>zn),r=t.state.schema.nodes.heading;r!=null&&(n(r,{level:e})(t.state,t.dispatch),t.focus())}async function lu(t,e){const{wrapInList:n,liftListItem:r}=await Promise.resolve().then(()=>require("./index-DqeaEUPG.cjs")),u=t.state.schema.nodes[e],i=t.state.schema.nodes.list_item;if(u==null||i==null)return;const{state:s}=t,{$from:o}=s.selection;let l=null;for(let a=o.depth;a>0;a--){const c=o.node(a);if(c.type.name==="bullet_list"||c.type.name==="ordered_list"){l=c.type.name;break}}l===e?r(i)(s,t.dispatch):l!=null?r(i)(t.state,t.dispatch)&&n(u)(t.state,t.dispatch):n(u)(s,t.dispatch),t.focus()}async function tl(t){const{wrapIn:e,lift:n}=await Promise.resolve().then(()=>zn),r=t.state.schema.nodes.blockquote;if(r==null)return;const{state:u}=t,{$from:i}=u.selection;let s=!1;for(let o=i.depth;o>0;o--)if(i.node(o).type.name==="blockquote"){s=!0;break}s?n(u,t.dispatch):e(r)(u,t.dispatch),t.focus()}async function nl(t){const{setBlockType:e}=await Promise.resolve().then(()=>zn),n=t.state.schema.nodes.code_block,r=t.state.schema.nodes.paragraph;if(n==null||r==null)return;const{state:u}=t,{$from:i}=u.selection;let s=!1;for(let o=i.depth;o>0;o--)if(i.node(o).type.name==="code_block"){s=!0;break}s?e(r)(u,t.dispatch):e(n)(u,t.dispatch),t.focus()}function rl(t){const e=t.state.schema.nodes.horizontal_rule;if(e!=null){const n=t.state.tr.replaceSelectionWith(e.create());t.dispatch(n),t.focus()}}function q(t){this.content=t}q.prototype={constructor:q,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,u=r.find(t),i=r.content.slice();return u==-1?i.push(n||t,e):(i[u+1]=e,n&&(i[u]=n)),new q(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new q(n)},addToStart:function(t,e){return new q([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new q(n)},addBefore:function(t,e,n){var r=this.remove(e),u=r.content.slice(),i=r.find(t);return u.splice(i==-1?u.length:i,0,e,n),new q(u)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=q.from(t),t.size?new q(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=q.from(t),t.size?new q(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=q.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};q.from=function(t){if(t instanceof q)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new q(e)};function Pi(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let u=t.child(r),i=e.child(r);if(u==i){n+=u.nodeSize;continue}if(!u.sameMarkup(i))return n;if(u.isText&&u.text!=i.text){for(let s=0;u.text[s]==i.text[s];s++)n++;return n}if(u.content.size||i.content.size){let s=Pi(u.content,i.content,n+1);if(s!=null)return s}n+=u.nodeSize}}function Li(t,e,n,r){for(let u=t.childCount,i=e.childCount;;){if(u==0||i==0)return u==i?null:{a:n,b:r};let s=t.child(--u),o=e.child(--i),l=s.nodeSize;if(s==o){n-=l,r-=l;continue}if(!s.sameMarkup(o))return{a:n,b:r};if(s.isText&&s.text!=o.text){let a=0,c=Math.min(s.text.length,o.text.length);for(;a<c&&s.text[s.text.length-a-1]==o.text[o.text.length-a-1];)a++,n--,r--;return{a:n,b:r}}if(s.content.size||o.content.size){let a=Li(s.content,o.content,n-1,r-1);if(a)return a}n-=l,r-=l}}class k{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,u=0,i){for(let s=0,o=0;o<n;s++){let l=this.content[s],a=o+l.nodeSize;if(a>e&&r(l,u+o,i||null,s)!==!1&&l.content.size){let c=o+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,u+c)}o=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,u){let i="",s=!0;return this.nodesBetween(e,n,(o,l)=>{let a=o.isText?o.text.slice(Math.max(e,l)-l,n-l):o.isLeaf?u?typeof u=="function"?u(o):u:o.type.spec.leafText?o.type.spec.leafText(o):"":"";o.isBlock&&(o.isLeaf&&a||o.isTextblock)&&r&&(s?s=!1:i+=r),i+=a},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,u=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(u[u.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)u.push(e.content[i]);return new k(u,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],u=0;if(n>e)for(let i=0,s=0;s<n;i++){let o=this.content[i],l=s+o.nodeSize;l>e&&((s<e||l>n)&&(o.isText?o=o.cut(Math.max(0,e-s),Math.min(o.text.length,n-s)):o=o.cut(Math.max(0,e-s-1),Math.min(o.content.size,n-s-1))),r.push(o),u+=o.nodeSize),s=l}return new k(r,u)}cutByIndex(e,n){return e==n?k.empty:e==0&&n==this.content.length?this:new k(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let u=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return u[e]=n,new k(u,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let u=this.content[n];e(u,r,n),r+=u.nodeSize}}findDiffStart(e,n=0){return Pi(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Li(this,e,n,r)}findIndex(e){if(e==0)return nn(0,e);if(e==this.size)return nn(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let u=this.child(n),i=r+u.nodeSize;if(i>=e)return i==e?nn(n+1,i):nn(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return k.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let n,r=0;for(let u=0;u<e.length;u++){let i=e[u];r+=i.nodeSize,u&&i.isText&&e[u-1].sameMarkup(i)?(n||(n=e.slice(0,u)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new k(n||e,r)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const qn={index:0,offset:0};function nn(t,e){return qn.index=t,qn.offset=e,qn}function hn(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!hn(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!hn(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class T{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let u=0;u<e.length;u++){let i=e[u];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,u));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,u)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let u=r.create(n.attrs);return r.checkAttrs(u.attrs),u}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return T.none;if(e instanceof T)return[e];let n=e.slice();return n.sort((r,u)=>r.type.rank-u.type.rank),n}}T.none=[];class pn extends Error{}class _{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Vi(this.content,e+this.openStart,n);return r&&new _(r,this.openStart,this.openEnd)}removeBetween(e,n){return new _(qi(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return _.empty;let r=n.openStart||0,u=n.openEnd||0;if(typeof r!="number"||typeof u!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _(k.fromJSON(e,n.content),r,u)}static maxOpen(e,n=!0){let r=0,u=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)u++;return new _(e,r,u)}}_.empty=new _(k.empty,0,0);function qi(t,e,n){let{index:r,offset:u}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:o}=t.findIndex(n);if(u==e||i.isText){if(o!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(qi(i.content,e-u-1,n-u-1)))}function Vi(t,e,n,r){let{index:u,offset:i}=t.findIndex(e),s=t.maybeChild(u);if(i==e||s.isText)return r&&!r.canReplace(u,u,n)?null:t.cut(0,e).append(n).append(t.cut(e));let o=Vi(s.content,e-i-1,n,s);return o&&t.replaceChild(u,s.copy(o))}function ul(t,e,n){if(n.openStart>t.depth)throw new pn("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new pn("Inconsistent open depths");return $i(t,e,n,0)}function $i(t,e,n,r){let u=t.index(r),i=t.node(r);if(u==e.index(r)&&r<t.depth-n.openStart){let s=$i(t,e,n,r+1);return i.copy(i.content.replaceChild(u,s))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let s=t.parent,o=s.content;return Ge(s,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}else{let{start:s,end:o}=il(n,t);return Ge(i,Hi(t,s,o,e,r))}else return Ge(i,mn(t,e,r))}function Wi(t,e){if(!e.type.compatibleContent(t.type))throw new pn("Cannot join "+e.type.name+" onto "+t.type.name)}function pr(t,e,n){let r=t.node(n);return Wi(r,e.node(n)),r}function Ze(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function wt(t,e,n,r){let u=(e||t).node(n),i=0,s=e?e.index(n):u.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ze(t.nodeAfter,r),i++));for(let o=i;o<s;o++)Ze(u.child(o),r);e&&e.depth==n&&e.textOffset&&Ze(e.nodeBefore,r)}function Ge(t,e){return t.type.checkContent(e),t.copy(e)}function Hi(t,e,n,r,u){let i=t.depth>u&&pr(t,e,u+1),s=r.depth>u&&pr(n,r,u+1),o=[];return wt(null,t,u,o),i&&s&&e.index(u)==n.index(u)?(Wi(i,s),Ze(Ge(i,Hi(t,e,n,r,u+1)),o)):(i&&Ze(Ge(i,mn(t,e,u+1)),o),wt(e,n,u,o),s&&Ze(Ge(s,mn(n,r,u+1)),o)),wt(r,null,u,o),new k(o)}function mn(t,e,n){let r=[];if(wt(null,t,n,r),t.depth>n){let u=pr(t,e,n+1);Ze(Ge(u,mn(t,e,n+1)),r)}return wt(e,null,n,r),new k(r)}function il(t,e){let n=e.depth-t.openStart,u=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)u=e.node(i).copy(k.from(u));return{start:u.resolveNoCache(t.openStart+n),end:u.resolveNoCache(u.content.size-t.openEnd-n)}}class Rt{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],u=e.child(n);return r?e.child(n).cut(r):u}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],u=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)u+=r.child(i).nodeSize;return u}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return T.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),u=e.maybeChild(n);if(!r){let o=r;r=u,u=o}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!u||!i[s].isInSet(u.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,u=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!u||!r[i].isInSet(u.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ji(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],u=0,i=n;for(let s=e;;){let{index:o,offset:l}=s.content.findIndex(i),a=i-l;if(r.push(s,o,u+l),!a||(s=s.child(o),s.isText))break;i=a-1,u+=l+1}return new Rt(n,r,i)}static resolveCached(e,n){let r=au.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==n)return s}else au.set(e,r=new sl);let u=r.elts[r.i]=Rt.resolve(e,n);return r.i=(r.i+1)%ol,u}}class sl{constructor(){this.elts=[],this.i=0}}const ol=12,au=new WeakMap;class Ji{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ll=Object.create(null);class be{constructor(e,n,r,u=T.none){this.type=e,this.attrs=n,this.marks=u,this.content=r||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,u=0){this.content.nodesBetween(e,n,r,u,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,u){return this.content.textBetween(e,n,r,u)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&hn(this.attrs,n||e.defaultAttrs||ll)&&T.sameSet(this.marks,r||T.none)}copy(e=null){return e==this.content?this:new be(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new be(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return _.empty;let u=this.resolve(e),i=this.resolve(n),s=r?0:u.sharedDepth(n),o=u.start(s),a=u.node(s).content.cut(u.pos-o,i.pos-o);return new _(a,u.depth-s,i.depth-s)}replace(e,n,r){return ul(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:u}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(u==e||n.isText)return n;e-=u+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let u=this.content.child(n-1);return{node:u,index:n-1,offset:r-u.nodeSize}}resolve(e){return Rt.resolveCached(this,e)}resolveNoCache(e){return Rt.resolve(this,e)}rangeHasMark(e,n,r){let u=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(u=!0),!u)),u}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ji(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=k.empty,u=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,u,i),o=s&&s.matchFragment(this.content,n);if(!o||!o.validEnd)return!1;for(let l=u;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,u){if(u&&!this.type.allowsMarks(u))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,n);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=T.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!T.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let u=k.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,u,r);return i.type.checkAttrs(i.attrs),i}}be.prototype.text=void 0;class gn extends be{constructor(e,n,r,u){if(super(e,n,null,u),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ji(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new gn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gn(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ji(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class et{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new al(e,n);if(r.next==null)return et.empty;let u=Ui(r);r.next&&r.err("Unexpected trailing text");let i=gl(ml(u));return bl(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let u=this;for(let i=n;u&&i<r;i++)u=u.matchType(e.child(i).type);return u}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let u=[this];function i(s,o){let l=s.matchFragment(e,r);if(l&&(!n||l.validEnd))return k.from(o.map(a=>a.createAndFill()));for(let a=0;a<s.next.length;a++){let{type:c,next:f}=s.next[a];if(!(c.isText||c.hasRequiredAttrs())&&u.indexOf(f)==-1){u.push(f);let p=i(f,o.concat(c));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let u=r.shift(),i=u.match;if(i.matchType(e)){let s=[];for(let o=u;o.type;o=o.via)s.push(o.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:o,next:l}=i.next[s];!o.isLeaf&&!o.hasRequiredAttrs()&&!(o.name in n)&&(!u.type||l.validEnd)&&(r.push({match:o.contentMatch,type:o,via:u}),n[o.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let u=0;u<r.next.length;u++)e.indexOf(r.next[u].next)==-1&&n(r.next[u].next)}return n(this),e.map((r,u)=>{let i=u+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
|
|
2
2
|
`)}}et.empty=new et(!0);class al{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ui(t){let e=[];do e.push(cl(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function cl(t){let e=[];do e.push(fl(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function fl(t){let e=pl(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=dl(t,e);else break;return e}function cu(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function dl(t,e){let n=cu(t),r=n;return t.eat(",")&&(t.next!="}"?r=cu(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function hl(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let u=[];for(let i in n){let s=n[i];s.isInGroup(e)&&u.push(s)}return u.length==0&&t.err("No node type or group '"+e+"' found"),u}function pl(t){if(t.eat("(")){let e=Ui(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=hl(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ml(t){let e=[[]];return u(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,o,l){let a={term:l,to:o};return e[s].push(a),a}function u(s,o){s.forEach(l=>l.to=o)}function i(s,o){if(s.type=="choice")return s.exprs.reduce((l,a)=>l.concat(i(a,o)),[]);if(s.type=="seq")for(let l=0;;l++){let a=i(s.exprs[l],o);if(l==s.exprs.length-1)return a;u(a,o=n())}else if(s.type=="star"){let l=n();return r(o,l),u(i(s.expr,l),l),[r(l)]}else if(s.type=="plus"){let l=n();return u(i(s.expr,o),l),u(i(s.expr,l),l),[r(l)]}else{if(s.type=="opt")return[r(o)].concat(i(s.expr,o));if(s.type=="range"){let l=o;for(let a=0;a<s.min;a++){let c=n();u(i(s.expr,l),c),l=c}if(s.max==-1)u(i(s.expr,l),l);else for(let a=s.min;a<s.max;a++){let c=n();r(l,c),u(i(s.expr,l),c),l=c}return[r(l)]}else{if(s.type=="name")return[r(o,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ki(t,e){return e-t}function fu(t,e){let n=[];return r(e),n.sort(Ki);function r(u){let i=t[u];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(u);for(let s=0;s<i.length;s++){let{term:o,to:l}=i[s];!o&&n.indexOf(l)==-1&&r(l)}}}function gl(t){let e=Object.create(null);return n(fu(t,0));function n(r){let u=[];r.forEach(s=>{t[s].forEach(({term:o,to:l})=>{if(!o)return;let a;for(let c=0;c<u.length;c++)u[c][0]==o&&(a=u[c][1]);fu(t,l).forEach(c=>{a||u.push([o,a=[]]),a.indexOf(c)==-1&&a.push(c)})})});let i=e[r.join(",")]=new et(r.indexOf(t.length-1)>-1);for(let s=0;s<u.length;s++){let o=u[s][1].sort(Ki);i.next.push({type:u[s][0],next:e[o.join(",")]||n(o)})}return i}}function bl(t,e){for(let n=0,r=[t];n<r.length;n++){let u=r[n],i=!u.validEnd,s=[];for(let o=0;o<u.next.length;o++){let{type:l,next:a}=u.next[o];s.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(a)==-1&&r.push(a)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Zi(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Gi(t,e){let n=Object.create(null);for(let r in t){let u=e&&e[r];if(u===void 0){let i=t[r];if(i.hasDefault)u=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=u}return n}function Yi(t,e,n,r){for(let u in e)if(!(u in t))throw new RangeError(`Unsupported attribute ${u} for ${n} of type ${u}`);for(let u in t){let i=t[u];i.validate&&i.validate(e[u])}}function Xi(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new kl(t,r,e[r]);return n}let du=class Qi{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Xi(e,r.attrs),this.defaultAttrs=Zi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==et.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Gi(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),k.from(n),T.setFrom(r))}createChecked(e=null,n,r){return n=k.from(n),this.checkContent(n),new be(this,this.computeAttrs(e),n,T.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=k.from(n),n.size){let s=this.contentMatch.fillBefore(n);if(!s)return null;n=s.append(n)}let u=this.contentMatch.matchFragment(n),i=u&&u.fillBefore(k.empty,!0);return i?new be(this,e,n.append(i),T.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Yi(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:T.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,s)=>r[i]=new Qi(i,n,s));let u=n.spec.topNode||"doc";if(!r[u])throw new RangeError("Schema is missing its top node type ('"+u+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function xl(t,e,n){let r=n.split("|");return u=>{let i=u===null?"null":typeof u;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class kl{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?xl(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Mn{constructor(e,n,r,u){this.name=e,this.rank=n,this.schema=r,this.spec=u,this.attrs=Xi(e,u.attrs),this.excluded=null;let i=Zi(this.attrs);this.instance=i?new T(this,i):null}create(e=null){return!e&&this.instance?this.instance:new T(this,Gi(this.attrs,e))}static compile(e,n){let r=Object.create(null),u=0;return e.forEach((i,s)=>r[i]=new Mn(i,u++,n,s)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Yi(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Br{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let u in e)n[u]=e[u];n.nodes=q.from(e.nodes),n.marks=q.from(e.marks||{}),this.nodes=du.compile(this.spec.nodes,this),this.marks=Mn.compile(this.spec.marks,this);let r=Object.create(null);for(let u in this.nodes){if(u in this.marks)throw new RangeError(u+" can not be both a node and a mark");let i=this.nodes[u],s=i.spec.content||"",o=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=et.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=o=="_"?null:o?hu(this,o.split(" ")):o==""||!i.inlineContent?[]:null}for(let u in this.marks){let i=this.marks[u],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:hu(this,s.split(" "))}this.nodeFromJSON=u=>be.fromJSON(this,u),this.markFromJSON=u=>T.fromJSON(this,u),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,u){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof du){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,u)}text(e,n){let r=this.nodes.text;return new gn(r,r.defaultAttrs,e,T.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function hu(t,e){let n=[];for(let r=0;r<e.length;r++){let u=e[r],i=t.marks[u],s=i;if(i)n.push(i);else for(let o in t.marks){let l=t.marks[o];(u=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(u)>-1)&&n.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function yl(t){return t.tag!=null}function Cl(t){return t.style!=null}class Bt{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(u=>{if(yl(u))this.tags.push(u);else if(Cl(u)){let i=/[^=]*/.exec(u.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(u)}}),this.normalizeLists=!this.tags.some(u=>{if(!/^(ul|ol)\b/.test(u.tag)||!u.node)return!1;let i=e.nodes[u.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new mu(this,n,!1);return r.addAll(e,T.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new mu(this,n,!0);return r.addAll(e,T.none,n.from,n.to),_.maxOpen(r.finish())}matchTag(e,n,r){for(let u=r?this.tags.indexOf(r)+1:0;u<this.tags.length;u++){let i=this.tags[u];if(El(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,n,r,u){for(let i=u?this.styles.indexOf(u)+1:0;i<this.styles.length;i++){let s=this.styles[i],o=s.style;if(!(o.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||o.length>e.length&&(o.charCodeAt(e.length)!=61||o.slice(e.length+1)!=n))){if(s.getAttrs){let l=s.getAttrs(n);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(e){let n=[];function r(u){let i=u.priority==null?50:u.priority,s=0;for(;s<n.length;s++){let o=n[s];if((o.priority==null?50:o.priority)<i)break}n.splice(s,0,u)}for(let u in e.marks){let i=e.marks[u].spec.parseDOM;i&&i.forEach(s=>{r(s=gu(s)),s.mark||s.ignore||s.clearMark||(s.mark=u)})}for(let u in e.nodes){let i=e.nodes[u].spec.parseDOM;i&&i.forEach(s=>{r(s=gu(s)),s.node||s.ignore||s.mark||(s.node=u)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Bt(e,Bt.schemaRules(e)))}}const es={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Dl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ts={ol:!0,ul:!0},vt=1,mr=2,Tt=4;function pu(t,e,n){return e!=null?(e?vt:0)|(e==="full"?mr:0):t&&t.whitespace=="pre"?vt|mr:n&~Tt}class rn{constructor(e,n,r,u,i,s){this.type=e,this.attrs=n,this.marks=r,this.solid=u,this.options=s,this.content=[],this.activeMarks=T.none,this.match=i||(s&Tt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(k.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,u;return(u=r.findWrapping(e.type))?(this.match=r,u):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&vt)){let r=this.content[this.content.length-1],u;if(r&&r.isText&&(u=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==u[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-u[0].length))}}let n=k.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!es.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class mu{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let u=n.topNode,i,s=pu(null,n.preserveWhitespace,0)|(r?Tt:0);u?i=new rn(u.type,u.attrs,T.none,!0,n.topMatch||u.type.contentMatch,s):r?i=new rn(null,null,T.none,!0,null,s):i=new rn(e.schema.topNodeType,null,T.none,!0,null,s),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,u=this.top,i=u.options&mr?"full":this.localPreserveWS||(u.options&vt)>0;if(i==="full"||u.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
3
3
|
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=u.content[u.content.length-1],o=e.previousSibling;(!s||o&&o.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let u=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),o;ts.hasOwnProperty(s)&&this.parser.normalizeLists&&_l(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Dl.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let a,c=this.needsBlock;if(es.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),a=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),a&&this.sync(i),this.needsBlock=c}else{let a=this.readStyles(e,n);a&&this.addElementByRule(e,l,a,l.consuming===!1?o:void 0)}this.localPreserveWS=u}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
4
|
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let u=0;u<this.parser.matchedStyles.length;u++){let i=this.parser.matchedStyles[u],s=r.getPropertyValue(i);if(s)for(let o=void 0;;){let l=this.parser.matchStyle(i,s,this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(a=>!l.clearMark(a)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)o=l;else break}}return n}addElementByRule(e,n,r,u){let i,s;if(n.node)if(s=this.parser.schema.nodes[n.node],s.isLeaf)this.insertNode(s.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(s,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let o=this.top;if(s&&s.isLeaf)this.findInside(e);else if(u)this.addElement(e,r,u);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(o)&&this.open--}addAll(e,n,r,u){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,o=u==null?null:e.childNodes[u];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,n);this.findAtPoint(e,i)}findPlace(e,n,r){let u,i;for(let s=this.open,o=0;s>=0;s--){let l=this.nodes[s],a=l.findWrapping(e);if(a&&(!u||u.length>a.length+o)&&(u=a,i=l,!a.length))break;if(l.solid){if(r)break;o+=2}}if(!u)return null;this.sync(i);for(let s=0;s<u.length;s++)n=this.enterInner(u[s],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let u=this.findPlace(e,n,r);if(u){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=T.none;for(let o of u.concat(e.marks))(i.type?i.type.allowsMarkType(o.type):bu(o.type,e.type))&&(s=o.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,n,r,u){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,u)),i}enterInner(e,n,r,u=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let o=pu(e,i,s.options);s.options&Tt&&s.content.length==0&&(o|=Tt);let l=T.none;return r=r.filter(a=>(s.type?s.type.allowsMarkType(a.type):bu(a.type,e))?(l=a.addToSet(l),!1):!0),this.nodes.push(new rn(e,n,l,u,null,o)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=vt)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let u=r.length-1;u>=0;u--)e+=r[u].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let u=0;u<this.find.length;u++)this.find[u].pos==null&&e.nodeType==1&&e.contains(this.find[u].node)&&n.compareDocumentPosition(this.find[u].node)&(r?2:4)&&(this.find[u].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,u=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(u?0:1),s=(o,l)=>{for(;o>=0;o--){let a=n[o];if(a==""){if(o==n.length-1||o==0)continue;for(;l>=i;l--)if(s(o-1,l))return!0;return!1}else{let c=l>0||l==0&&u?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!c||c.name!=a&&!c.isInGroup(a))return!1;l--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function _l(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ts.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function El(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function gu(t){let e={};for(let n in t)e[n]=t[n];return e}function bu(t,e){let n=e.schema.nodes;for(let r in n){let u=n[r];if(!u.allowsMarkType(t))continue;let i=[],s=o=>{i.push(o);for(let l=0;l<o.edgeCount;l++){let{type:a,next:c}=o.edge(l);if(a==e||i.indexOf(c)<0&&s(c))return!0}};if(s(u.contentMatch))return!0}}class xt{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Vn(n).createDocumentFragment());let u=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let o=0,l=0;for(;o<i.length&&l<s.marks.length;){let a=s.marks[l];if(!this.marks[a.type.name]){l++;continue}if(!a.eq(i[o][0])||a.type.spec.spanning===!1)break;o++,l++}for(;o<i.length;)u=i.pop()[1];for(;l<s.marks.length;){let a=s.marks[l++],c=this.serializeMark(a,s.isInline,n);c&&(i.push([a,u]),u.appendChild(c.dom),u=c.contentDOM||c.dom)}}u.appendChild(this.serializeNodeInner(s,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:u}=an(Vn(n),this.nodes[e.type.name](e),null,e.attrs);if(u){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,u)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let u=e.marks.length-1;u>=0;u--){let i=this.serializeMark(e.marks[u],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let u=this.marks[e.type.name];return u&&an(Vn(r),u(e,n),null,e.attrs)}static renderSpec(e,n,r=null,u){return an(e,n,r,u)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new xt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=xu(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return xu(e.marks)}}function xu(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Vn(t){return t.document||window.document}const ku=new WeakMap;function Sl(t){let e=ku.get(t);return e===void 0&&ku.set(t,e=Al(t)),e}function Al(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let u=0;u<r.length;u++)n(r[u]);else for(let u in r)n(r[u])}return n(t),e}function an(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let u=e[0],i;if(typeof u!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Sl(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=u.indexOf(" ");s>0&&(n=u.slice(0,s),u=u.slice(s+1));let o,l=n?t.createElementNS(n,u):t.createElement(u),a=e[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let f in a)if(a[f]!=null){let p=f.indexOf(" ");p>0?l.setAttributeNS(f.slice(0,p),f.slice(p+1),a[f]):f=="style"&&l.style?l.style.cssText=a[f]:l.setAttribute(f,a[f])}}for(let f=c;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:d}=an(t,p,n,r);if(l.appendChild(h),d){if(o)throw new RangeError("Multiple content holes");o=d}}}return{dom:l,contentDOM:o}}const ns=65535,rs=Math.pow(2,16);function Ml(t,e){return t+e*rs}function yu(t){return t&ns}function wl(t){return(t-(t&ns))/rs}const us=1,is=2,cn=4,ss=8;class gr{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ss)>0}get deletedBefore(){return(this.delInfo&(us|cn))>0}get deletedAfter(){return(this.delInfo&(is|cn))>0}get deletedAcross(){return(this.delInfo&cn)>0}}class Q{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Q.empty)return Q.empty}recover(e){let n=0,r=yu(e);if(!this.inverted)for(let u=0;u<r;u++)n+=this.ranges[u*3+2]-this.ranges[u*3+1];return this.ranges[r*3]+n+wl(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let u=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?u:0);if(l>e)break;let a=this.ranges[o+i],c=this.ranges[o+s],f=l+a;if(e<=f){let p=a?e==l?-1:e==f?1:n:n,h=l+u+(p<0?0:c);if(r)return h;let d=e==(n<0?l:f)?null:Ml(o/3,e-l),m=e==l?is:e==f?us:cn;return(n<0?e!=l:e!=f)&&(m|=ss),new gr(h,m,d)}u+=c-a}return r?e+u:new gr(e+u,0,null)}touches(e,n){let r=0,u=yu(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let l=this.ranges[o]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[o+i],c=l+a;if(e<=c&&o==u*3)return!0;r+=this.ranges[o+s]-a}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let u=0,i=0;u<this.ranges.length;u+=3){let s=this.ranges[u],o=s-(this.inverted?i:0),l=s+(this.inverted?0:i),a=this.ranges[u+n],c=this.ranges[u+r];e(o,o+a,l,l+c),i+=c-a}}invert(){return new Q(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Q.empty:new Q(e<0?[0,-e,0]:[0,0,e])}}Q.empty=new Q([]);class zt{constructor(e,n,r=0,u=e?e.length:0){this.mirror=n,this.from=r,this.to=u,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new zt(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let u=e.getMirror(n);this.appendMap(e._maps[n],u!=null&&u<n?r+u:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let u=e.getMirror(n);this.appendMap(e._maps[n].invert(),u!=null&&u>n?r-u-1:void 0)}}invert(){let e=new zt;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let u=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],o=s.mapResult(e,n);if(o.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(o.recover);continue}}u|=o.delInfo,e=o.pos}return r?e:new gr(e,u,null)}}const $n=Object.create(null);class j{getMap(){return Q.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=$n[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in $n)throw new RangeError("Duplicate use of step JSON ID "+e);return $n[e]=n,n.prototype.jsonID=e,n}}class R{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new R(e,null)}static fail(e){return new R(null,e)}static fromReplace(e,n,r,u){try{return R.ok(e.replace(n,r,u))}catch(i){if(i instanceof pn)return R.fail(i.message);throw i}}}function vr(t,e,n){let r=[];for(let u=0;u<t.childCount;u++){let i=t.child(u);i.content.size&&(i=i.copy(vr(i.content,e,i))),i.isInline&&(i=e(i,n,u)),r.push(i)}return k.fromArray(r)}class Be extends j{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),u=r.node(r.sharedDepth(this.to)),i=new _(vr(n.content,(s,o)=>!s.isAtom||!o.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),u),n.openStart,n.openEnd);return R.fromReplace(e,this.from,this.to,i)}invert(){return new pe(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Be(n.pos,r.pos,this.mark)}merge(e){return e instanceof Be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Be(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Be(n.from,n.to,e.markFromJSON(n.mark))}}j.jsonID("addMark",Be);class pe extends j{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new _(vr(n.content,u=>u.mark(this.mark.removeFromSet(u.marks)),e),n.openStart,n.openEnd);return R.fromReplace(e,this.from,this.to,r)}invert(){return new Be(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new pe(n.pos,r.pos,this.mark)}merge(e){return e instanceof pe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pe(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new pe(n.from,n.to,e.markFromJSON(n.mark))}}j.jsonID("removeMark",pe);class ve extends j{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return R.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return R.fromReplace(e,this.pos,this.pos+1,new _(k.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let u=0;u<n.marks.length;u++)if(!n.marks[u].isInSet(r))return new ve(this.pos,n.marks[u]);return new ve(this.pos,this.mark)}}return new tt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ve(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ve(n.pos,e.markFromJSON(n.mark))}}j.jsonID("addNodeMark",ve);class tt extends j{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return R.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return R.fromReplace(e,this.pos,this.pos+1,new _(k.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ve(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new tt(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new tt(n.pos,e.markFromJSON(n.mark))}}j.jsonID("removeNodeMark",tt);class H extends j{constructor(e,n,r,u=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=u}apply(e){return this.structure&&br(e,this.from,this.to)?R.fail("Structure replace would overwrite content"):R.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Q([this.from,this.to-this.from,this.slice.size])}invert(e){return new H(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new H(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof H)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?_.empty:new _(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new H(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?_.empty:new _(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new H(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new H(n.from,n.to,_.fromJSON(e,n.slice),!!n.structure)}}j.jsonID("replace",H);class G extends j{constructor(e,n,r,u,i,s,o=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=u,this.slice=i,this.insert=s,this.structure=o}apply(e){if(this.structure&&(br(e,this.from,this.gapFrom)||br(e,this.gapTo,this.to)))return R.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return R.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?R.fromReplace(e,this.from,this.to,r):R.fail("Content does not fit in gap")}getMap(){return new Q([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new G(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),u=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||u<n.pos||i>r.pos?null:new G(n.pos,r.pos,u,i,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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new G(n.from,n.to,n.gapFrom,n.gapTo,_.fromJSON(e,n.slice),n.insert,!!n.structure)}}j.jsonID("replaceAround",G);function br(t,e,n){let r=t.resolve(e),u=n-e,i=r.depth;for(;u>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,u--;if(u>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;u>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,u--}}return!1}function Tl(t,e,n,r){let u=[],i=[],s,o;t.doc.nodesBetween(e,n,(l,a,c)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let p=Math.max(a,e),h=Math.min(a+l.nodeSize,n),d=r.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(d)||(s&&s.to==p&&s.mark.eq(f[m])?s.to=h:u.push(s=new pe(p,h,f[m])));o&&o.to==p?o.to=h:i.push(o=new Be(p,h,r))}}),u.forEach(l=>t.step(l)),i.forEach(l=>t.step(l))}function Ol(t,e,n,r){let u=[],i=0;t.doc.nodesBetween(e,n,(s,o)=>{if(!s.isInline)return;i++;let l=null;if(r instanceof Mn){let a=s.marks,c;for(;c=r.isInSet(a);)(l||(l=[])).push(c),a=c.removeFromSet(a)}else r?r.isInSet(s.marks)&&(l=[r]):l=s.marks;if(l&&l.length){let a=Math.min(o+s.nodeSize,n);for(let c=0;c<l.length;c++){let f=l[c],p;for(let h=0;h<u.length;h++){let d=u[h];d.step==i-1&&f.eq(u[h].style)&&(p=d)}p?(p.to=a,p.step=i):u.push({style:f,from:Math.max(o,e),to:a,step:i})}}}),u.forEach(s=>t.step(new pe(s.from,s.to,s.style)))}function zr(t,e,n,r=n.contentMatch,u=!0){let i=t.doc.nodeAt(e),s=[],o=e+1;for(let l=0;l<i.childCount;l++){let a=i.child(l),c=o+a.nodeSize,f=r.matchType(a.type);if(!f)s.push(new H(o,c,_.empty));else{r=f;for(let p=0;p<a.marks.length;p++)n.allowsMarkType(a.marks[p].type)||t.step(new pe(o,c,a.marks[p]));if(u&&a.isText&&n.whitespace!="pre"){let p,h=/\r?\n|\r/g,d;for(;p=h.exec(a.text);)d||(d=new _(k.from(n.schema.text(" ",n.allowedMarks(a.marks))),0,0)),s.push(new H(o+p.index,o+p.index+p[0].length,d))}}o=c}if(!r.validEnd){let l=r.fillBefore(k.empty,!0);t.replace(o,o,new _(l,0,0))}for(let l=s.length-1;l>=0;l--)t.step(s[l])}function Fl(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function jt(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let u=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(r<t.depth&&u.canReplace(i,s,n))return r;if(r==0||u.type.spec.isolating||!Fl(u,i,s))break}return null}function Nl(t,e,n){let{$from:r,$to:u,depth:i}=e,s=r.before(i+1),o=u.after(i+1),l=s,a=o,c=k.empty,f=0;for(let d=i,m=!1;d>n;d--)m||r.index(d)>0?(m=!0,c=k.from(r.node(d).copy(c)),f++):l--;let p=k.empty,h=0;for(let d=i,m=!1;d>n;d--)m||u.after(d+1)<u.end(d)?(m=!0,p=k.from(u.node(d).copy(p)),h++):a++;t.step(new G(l,a,s,o,new _(c.append(p),f,h),c.size-f,!0))}function ls(t,e,n=null,r=t){let u=Il(t,e),i=u&&Rl(r,e);return i?u.map(Cu).concat({type:e,attrs:n}).concat(i.map(Cu)):null}function Cu(t){return{type:t,attrs:null}}function Il(t,e){let{parent:n,startIndex:r,endIndex:u}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,u,s)?i:null}function Rl(t,e){let{parent:n,startIndex:r,endIndex:u}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:e).contentMatch;for(let a=r;l&&a<u;a++)l=l.matchType(n.child(a).type);return!l||!l.validEnd?null:s}function Bl(t,e,n){let r=k.empty;for(let s=n.length-1;s>=0;s--){if(r.size){let o=n[s].type.contentMatch.matchFragment(r);if(!o||!o.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=k.from(n[s].type.create(n[s].attrs,r))}let u=e.start,i=e.end;t.step(new G(u,i,u,i,new _(r,0,0),n.length,!0))}function vl(t,e,n,r,u){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,o)=>{let l=typeof u=="function"?u(s):u;if(s.isTextblock&&!s.hasMarkup(r,l)&&zl(t.doc,t.mapping.slice(i).map(o),r)){let a=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",d=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!d?a=!1:!h&&d&&(a=!0)}a===!1&&cs(t,s,o,i),zr(t,t.mapping.slice(i).map(o,1),r,void 0,a===null);let c=t.mapping.slice(i),f=c.map(o,1),p=c.map(o+s.nodeSize,1);return t.step(new G(f,p,f+1,p-1,new _(k.from(r.create(l,null,s.marks)),0,0),1,!0)),a===!0&&as(t,s,o,i),!1}})}function as(t,e,n,r){e.forEach((u,i)=>{if(u.isText){let s,o=/\r?\n|\r/g;for(;s=o.exec(u.text);){let l=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function cs(t,e,n,r){e.forEach((u,i)=>{if(u.type==u.type.schema.linebreakReplacement){let s=t.mapping.slice(r).map(n+1+i);t.replaceWith(s,s+1,e.type.schema.text(`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { When as It, attr as Je, prop as vi, Fragment as Xo, OnDispose as mr, Ensure as gr, signal as br, computedOf as zi, Use as Pi, Repeat as Qo, Value as j, html as au, Task as el, WithElement as tl } from "@tempots/dom";
|
|
2
|
-
import { a as Li, b as qi, T as nl } from "./toolbar-
|
|
3
|
-
import { I as rl, T as ul, a as il } from "./translations-
|
|
2
|
+
import { a as Li, b as qi, T as nl } from "./toolbar-ClJbaKID.js";
|
|
3
|
+
import { I as rl, T as ul, a as il } from "./translations-iam7PITs.js";
|
|
4
4
|
import { L as sl } from "./link-portal-Cr2l9f3k.js";
|
|
5
5
|
import { ticker as ol } from "@tempots/ui";
|
|
6
|
-
import { T as ll } from "./theme-
|
|
6
|
+
import { T as ll } from "./theme-DsQOxXW1.js";
|
|
7
7
|
function Vi(t, e) {
|
|
8
8
|
return $i(t, e) != null;
|
|
9
9
|
}
|
|
@@ -350,7 +350,7 @@ async function ml(t, e) {
|
|
|
350
350
|
r != null && (n(r, { level: e })(t.state, t.dispatch), t.focus());
|
|
351
351
|
}
|
|
352
352
|
async function cu(t, e) {
|
|
353
|
-
const { wrapInList: n, liftListItem: r } = await import("./index-
|
|
353
|
+
const { wrapInList: n, liftListItem: r } = await import("./index-Caetcp0r.js"), u = t.state.schema.nodes[e], i = t.state.schema.nodes.list_item;
|
|
354
354
|
if (u == null || i == null) return;
|
|
355
355
|
const { state: s } = t, { $from: o } = s.selection;
|
|
356
356
|
let l = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const m=require("./index-
|
|
1
|
+
"use strict";const m=require("./index-1_pssujS.cjs");var R={},_={},O;function H(){if(O)return _;O=1,Object.defineProperty(_,"__esModule",{value:!0}),_.dynamicAnchor=void 0;const e=m.requireCodegen(),r=m.requireNames(),n=m.requireCompile(),l=m.requireRef(),o={keyword:"$dynamicAnchor",schemaType:"string",code:i=>t(i,i.schema)};function t(i,v){const{gen:s,it:d}=i;d.schemaEnv.root.dynamicAnchors[v]=!0;const y=(0,e._)`${r.default.dynamicAnchors}${(0,e.getProperty)(v)}`,a=d.errSchemaPath==="#"?d.validateName:u(i);s.if((0,e._)`!${y}`,()=>s.assign(y,a))}_.dynamicAnchor=t;function u(i){const{schemaEnv:v,schema:s,self:d}=i.it,{root:y,baseId:a,localRefs:f,meta:p}=v.root,{schemaId:S}=d.opts,c=new n.SchemaEnv({schema:s,schemaId:S,root:y,baseId:a,localRefs:f,meta:p});return n.compileSchema.call(d,c),(0,l.getValidate)(i,c)}return _.default=o,_}var q={},C;function J(){if(C)return q;C=1,Object.defineProperty(q,"__esModule",{value:!0}),q.dynamicRef=void 0;const e=m.requireCodegen(),r=m.requireNames(),n=m.requireRef(),l={keyword:"$dynamicRef",schemaType:"string",code:t=>o(t,t.schema)};function o(t,u){const{gen:i,keyword:v,it:s}=t;if(u[0]!=="#")throw new Error(`"${v}" only supports hash fragment reference`);const d=u.slice(1);if(s.allErrors)y();else{const f=i.let("valid",!1);y(f),t.ok(f)}function y(f){if(s.schemaEnv.root.dynamicAnchors[d]){const p=i.let("_v",(0,e._)`${r.default.dynamicAnchors}${(0,e.getProperty)(d)}`);i.if(p,a(p,f),a(s.validateName,f))}else a(s.validateName,f)()}function a(f,p){return p?()=>i.block(()=>{(0,n.callRef)(t,f),i.let(p,!0)}):()=>(0,n.callRef)(t,f)}}return q.dynamicRef=o,q.default=l,q}var $={},N;function K(){if(N)return $;N=1,Object.defineProperty($,"__esModule",{value:!0});const e=H(),r=m.requireUtil(),n={keyword:"$recursiveAnchor",schemaType:"boolean",code(l){l.schema?(0,e.dynamicAnchor)(l,""):(0,r.checkStrictMode)(l.it,"$recursiveAnchor: false is ignored")}};return $.default=n,$}var b={},I;function Q(){if(I)return b;I=1,Object.defineProperty(b,"__esModule",{value:!0});const e=J(),r={keyword:"$recursiveRef",schemaType:"string",code:n=>(0,e.dynamicRef)(n,n.schema)};return b.default=r,b}var U;function W(){if(U)return R;U=1,Object.defineProperty(R,"__esModule",{value:!0});const e=H(),r=J(),n=K(),l=Q(),o=[e.default,r.default,n.default,l.default];return R.default=o,R}var P={},g={},E;function X(){if(E)return g;E=1,Object.defineProperty(g,"__esModule",{value:!0});const e=m.requireDependencies(),r={keyword:"dependentRequired",type:"object",schemaType:"object",error:e.error,code:n=>(0,e.validatePropertyDeps)(n)};return g.default=r,g}var j={},V;function Y(){if(V)return j;V=1,Object.defineProperty(j,"__esModule",{value:!0});const e=m.requireDependencies(),r={keyword:"dependentSchemas",type:"object",schemaType:"object",code:n=>(0,e.validateSchemaDeps)(n)};return j.default=r,j}var k={},L;function Z(){if(L)return k;L=1,Object.defineProperty(k,"__esModule",{value:!0});const e=m.requireUtil(),r={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:n,parentSchema:l,it:o}){l.contains===void 0&&(0,e.checkStrictMode)(o,`"${n}" without "contains" is ignored`)}};return k.default=r,k}var z;function x(){if(z)return P;z=1,Object.defineProperty(P,"__esModule",{value:!0});const e=X(),r=Y(),n=Z(),l=[e.default,r.default,n.default];return P.default=l,P}var w={},A={},B;function ee(){if(B)return A;B=1,Object.defineProperty(A,"__esModule",{value:!0});const e=m.requireCodegen(),r=m.requireUtil(),n=m.requireNames(),o={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:{message:"must NOT have unevaluated properties",params:({params:t})=>(0,e._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},code(t){const{gen:u,schema:i,data:v,errsCount:s,it:d}=t;if(!s)throw new Error("ajv implementation error");const{allErrors:y,props:a}=d;a instanceof e.Name?u.if((0,e._)`${a} !== true`,()=>u.forIn("key",v,c=>u.if(p(a,c),()=>f(c)))):a!==!0&&u.forIn("key",v,c=>a===void 0?f(c):u.if(S(a,c),()=>f(c))),d.props=!0,t.ok((0,e._)`${s} === ${n.default.errors}`);function f(c){if(i===!1){t.setParams({unevaluatedProperty:c}),t.error(),y||u.break();return}if(!(0,r.alwaysValidSchema)(d,i)){const h=u.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:c,dataPropType:r.Type.Str},h),y||u.if((0,e.not)(h),()=>u.break())}}function p(c,h){return(0,e._)`!${c} || !${c}[${h}]`}function S(c,h){const T=[];for(const M in c)c[M]===!0&&T.push((0,e._)`${h} !== ${M}`);return(0,e.and)(...T)}}};return A.default=o,A}var D={},F;function re(){if(F)return D;F=1,Object.defineProperty(D,"__esModule",{value:!0});const e=m.requireCodegen(),r=m.requireUtil(),l={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:{message:({params:{len:o}})=>(0,e.str)`must NOT have more than ${o} items`,params:({params:{len:o}})=>(0,e._)`{limit: ${o}}`},code(o){const{gen:t,schema:u,data:i,it:v}=o,s=v.items||0;if(s===!0)return;const d=t.const("len",(0,e._)`${i}.length`);if(u===!1)o.setParams({len:s}),o.fail((0,e._)`${d} > ${s}`);else if(typeof u=="object"&&!(0,r.alwaysValidSchema)(v,u)){const a=t.var("valid",(0,e._)`${d} <= ${s}`);t.if((0,e.not)(a),()=>y(a,s)),o.ok(a)}v.items=!0;function y(a,f){t.forRange("i",f,d,p=>{o.subschema({keyword:"unevaluatedItems",dataProp:p,dataPropType:r.Type.Num},a),v.allErrors||t.if((0,e.not)(a),()=>t.break())})}}};return D.default=l,D}var G;function ne(){if(G)return w;G=1,Object.defineProperty(w,"__esModule",{value:!0});const e=ee(),r=re(),n=[e.default,r.default];return w.default=n,w}exports.requireDynamic=W;exports.requireNext=x;exports.requireUnevaluated=ne;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { N as I, f as S, R as $, S as x, F as u, l as w, c as R, a as L } from "./index-
|
|
1
|
+
import { N as I, f as S, R as $, S as x, F as u, l as w, c as R, a as L } from "./index-CDOHHPwQ.js";
|
|
2
2
|
function b(d, t = null) {
|
|
3
3
|
return function(e, n) {
|
|
4
4
|
let { $from: o, $to: l } = e.selection, f = o.blockRange(l);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as Se, S as de, I as Ft, c as Z, M as Yt, P as Xs, E as Ys, b as Tr, N as ds, L as Le, x as Zs, C as hs, i as Qs, A as ea, l as ta } from "./notice-
|
|
2
|
-
import { _ as $r, X as ra, S as na, N as sa, a as ps, g as aa, t as le, u as Ve, s as Zt, z as ia, C as oa, W as ua, I as ca, K as la, r as fa, p as da, o as ha, q as pa, c as Ue, T as ma, y as ya, w as pr, v as ga, M as Xe, H as va, D as _a, A as ba, R as $a, x as wa, m as Sa, G as Pa, j as ms, O as Ea, L as Oa, b as ja } from "./utils-
|
|
1
|
+
import { a as Se, S as de, I as Ft, c as Z, M as Yt, P as Xs, E as Ys, b as Tr, N as ds, L as Le, x as Zs, C as hs, i as Qs, A as ea, l as ta } from "./notice-Ct8ZHvwq.js";
|
|
2
|
+
import { _ as $r, X as ra, S as na, N as sa, a as ps, g as aa, t as le, u as Ve, s as Zt, z as ia, C as oa, W as ua, I as ca, K as la, r as fa, p as da, o as ha, q as pa, c as Ue, T as ma, y as ya, w as pr, v as ga, M as Xe, H as va, D as _a, A as ba, R as $a, x as wa, m as Sa, G as Pa, j as ms, O as Ea, L as Oa, b as ja } from "./utils-CuD-_CDx.js";
|
|
3
3
|
import { attr as F, Value as ne, Fragment as je, WithElement as ys, Empty as gs, html as H, When as Je, computedOf as ie, prop as ke, Use as wr, style as vs, Ensure as _s, aria as ka, on as Ge, MapSignal as Ut, Async as Ra, OnDispose as Na } from "@tempots/dom";
|
|
4
|
-
import { T as Ia, a as Sr, I as bs, B as Aa } from "./translations-
|
|
4
|
+
import { T as Ia, a as Sr, I as bs, B as Aa } from "./translations-iam7PITs.js";
|
|
5
5
|
import { f as Ca } from "./colors-WfmhQ5e1.js";
|
|
6
6
|
function Ta(e, t) {
|
|
7
7
|
for (var r = 0; r < t.length; r++) {
|
|
@@ -4730,9 +4730,9 @@ async function Qn(e, t, r) {
|
|
|
4730
4730
|
const n = (await (() => {
|
|
4731
4731
|
switch (e) {
|
|
4732
4732
|
case "2020-12":
|
|
4733
|
-
return import("./2020-
|
|
4733
|
+
return import("./2020-BQNEk3m-.js").then((s) => s._);
|
|
4734
4734
|
case "2019-09":
|
|
4735
|
-
return import("./2019-
|
|
4735
|
+
return import("./2019-BAbSTPyW.js").then((s) => s._);
|
|
4736
4736
|
case "draft-07":
|
|
4737
4737
|
return Promise.resolve().then(() => iu);
|
|
4738
4738
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-B4irUWVb.cjs");function S(f,t=null){return function(e,n){let{$from:o,$to:l}=e.selection,i=o.blockRange(l);if(!i)return!1;let d=n?e.tr:null;return h(d,i,f,t)?(n&&n(d.scrollIntoView()),!0):!1}}function h(f,t,e,n=null){let o=!1,l=t,i=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(e)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let u=i.resolve(t.start-2);l=new r.NodeRange(u,u,t.depth),t.endIndex<t.parent.childCount&&(t=new r.NodeRange(t.$from,i.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let d=r.findWrapping(l,e,n,t);return d?(f&&$(f,t,d,o,e),!0):!1}function $(f,t,e,n,o){let l=r.Fragment.empty;for(let p=e.length-1;p>=0;p--)l=r.Fragment.from(e[p].type.create(e[p].attrs,l));f.step(new r.ReplaceAroundStep(t.start-(n?2:0),t.end,t.start,t.end,new r.Slice(l,0,0),e.length,!0));let i=0;for(let p=0;p<e.length;p++)e[p].type==o&&(i=p+1);let d=e.length-i,u=t.start+e.length-(n?2:0),m=t.parent;for(let p=t.startIndex,s=t.endIndex,c=!0;p<s;p++,c=!1)!c&&r.canSplit(f.doc,u,d)&&(f.split(u,d),u+=2*d),u+=m.child(p).nodeSize;return f}function R(f){return function(t,e){let{$from:n,$to:o}=t.selection,l=n.blockRange(o,i=>i.childCount>0&&i.firstChild.type==f);return l?e?n.node(l.depth-1).type==f?x(t,e,f,l):F(t,e,l):!0:!1}}function x(f,t,e,n){let o=f.tr,l=n.end,i=n.$to.end(n.depth);l<i&&(o.step(new r.ReplaceAroundStep(l-1,i,l,i,new r.Slice(r.Fragment.from(e.create(null,n.parent.copy())),1,0),1,!0)),n=new r.NodeRange(o.doc.resolve(n.$from.pos),o.doc.resolve(i),n.depth));const d=r.liftTarget(n);if(d==null)return!1;o.lift(n,d);let u=o.doc.resolve(o.mapping.map(l,-1)-1);return r.canJoin(o.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&o.join(u.pos),t(o.scrollIntoView()),!0}function F(f,t,e){let n=f.tr,o=e.parent;for(let a=e.end,I=e.endIndex-1,y=e.startIndex;I>y;I--)a-=o.child(I).nodeSize,n.delete(a-1,a+1);let l=n.doc.resolve(e.start),i=l.nodeAfter;if(n.mapping.map(e.end)!=e.start+l.nodeAfter.nodeSize)return!1;let d=e.startIndex==0,u=e.endIndex==o.childCount,m=l.node(-1),p=l.index(-1);if(!m.canReplace(p+(d?0:1),p+1,i.content.append(u?r.Fragment.empty:r.Fragment.from(o))))return!1;let s=l.pos,c=s+i.nodeSize;return n.step(new r.ReplaceAroundStep(s-(d?1:0),c+(u?1:0),s+1,c-1,new r.Slice((d?r.Fragment.empty:r.Fragment.from(o.copy(r.Fragment.empty))).append(u?r.Fragment.empty:r.Fragment.from(o.copy(r.Fragment.empty))),d?0:1,u?0:1),d?0:1)),t(n.scrollIntoView()),!0}exports.liftListItem=R;exports.wrapInList=S;exports.wrapRangeInList=h;
|