@ni/spright-components 6.15.2 → 6.15.3

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.
@@ -6394,14 +6394,14 @@ return ux.fromReplace(t,this.pos,this.pos+1,new iw(Xy.from(n),0,e.isLeaf?0:1))}i
6394
6394
  return e&&this.mark.isInSet(e.marks)?new gx(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1)
6395
6395
  return e.deletedAfter?null:new vx(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON")
6396
6396
  return new vx(e.pos,t.markFromJSON(e.mark))}}hx.jsonID("removeNodeMark",vx)
6397
- class bx extends hx{constructor(t,e,n,i=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=i}apply(t){return this.structure&&wx(t,this.from,this.to)?ux.fail("Structure replace would overwrite content"):ux.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new lx([this.from,this.to-this.from,this.slice.size])}invert(t){return new bx(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1)
6398
- return e.deletedAcross&&n.deletedAcross?null:new bx(e.pos,Math.max(e.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof bx)||t.structure||this.structure)return null
6397
+ class bx extends hx{constructor(t,e,n,i=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=i}apply(t){return this.structure&&wx(t,this.from,this.to)?ux.fail("Structure replace would overwrite content"):ux.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new lx([this.from,this.to-this.from,this.slice.size])}invert(t){return new bx(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.to,-1),n=this.from==this.to&&bx.MAP_BIAS<0?e:t.mapResult(this.from,1)
6398
+ return n.deletedAcross&&e.deletedAcross?null:new bx(n.pos,Math.max(n.pos,e.pos),this.slice,this.structure)}merge(t){if(!(t instanceof bx)||t.structure||this.structure)return null
6399
6399
  if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null
6400
6400
  {let e=this.slice.size+t.slice.size==0?iw.empty:new iw(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd)
6401
6401
  return new bx(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?iw.empty:new iw(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd)
6402
6402
  return new bx(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to}
6403
6403
  return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON")
6404
- return new bx(e.from,e.to,iw.fromJSON(t,e.slice),!!e.structure)}}hx.jsonID("replace",bx)
6404
+ return new bx(e.from,e.to,iw.fromJSON(t,e.slice),!!e.structure)}}bx.MAP_BIAS=1,hx.jsonID("replace",bx)
6405
6405
  class yx extends hx{constructor(t,e,n,i,o,r,s=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=i,this.slice=o,this.insert=r,this.structure=s}apply(t){if(this.structure&&(wx(t,this.from,this.gapFrom)||wx(t,this.gapTo,this.to)))return ux.fail("Structure gap-replace would overwrite content")
6406
6406
  let e=t.slice(this.gapFrom,this.gapTo)
6407
6407
  if(e.openStart||e.openEnd)return ux.fail("Gap is not a flat range")
@@ -6569,7 +6569,13 @@ if(i.node(t).canReplaceWith(e,e,n))return i.before(t+1)
6569
6569
  if(e>0)return null}if(i.parentOffset==i.parent.content.size)for(let t=i.depth-1;t>=0;t--){let e=i.indexAfter(t)
6570
6570
  if(i.node(t).canReplaceWith(e,e,n))return i.after(t+1)
6571
6571
  if(e<i.node(t).childCount)return null}return null}(t.doc,e,i.type)
6572
- null!=o&&(e=n=o)}t.replaceRange(e,n,new iw(Xy.from(i),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let i=t.doc.resolve(e),o=t.doc.resolve(n),r=Ux(i,o)
6572
+ null!=o&&(e=n=o)}t.replaceRange(e,n,new iw(Xy.from(i),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let i=t.doc.resolve(e),o=t.doc.resolve(n)
6573
+ if(i.parent.isTextblock&&o.parent.isTextblock&&i.start()!=o.start()&&0==i.parentOffset&&0==o.parentOffset){let r=i.sharedDepth(n),s=!1
6574
+ for(let t=i.depth;t>r;t--)i.node(t).type.spec.isolating&&(s=!0)
6575
+ for(let t=o.depth;t>r;t--)o.node(t).type.spec.isolating&&(s=!0)
6576
+ if(!s){for(let t=i.depth;t>0&&e==i.start(t);t--)e=i.before(t)
6577
+ for(let t=o.depth;t>0&&n==o.start(t);t--)n=o.before(t)
6578
+ i=t.doc.resolve(e),o=t.doc.resolve(n)}}let r=Ux(i,o)
6573
6579
  for(let e=0;e<r.length;e++){let n=r[e],s=e==r.length-1
6574
6580
  if(s&&0==n||i.node(n).type.contentMatch.validEnd)return t.delete(i.start(n),o.end(n))
6575
6581
  if(n>0&&(s||i.node(n-1).canReplace(i.index(n-1),o.indexAfter(n-1))))return t.delete(i.before(n),o.after(n))}for(let r=1;r<=i.depth&&r<=o.depth;r++)if(e-i.start(r)==i.depth-r&&n>i.end(r)&&o.end(r)-n!=o.depth-r&&i.start(r-1)==o.start(r-1)&&i.node(r-1).canReplace(i.index(r-1),o.index(r-1)))return t.delete(i.before(r),n)
@@ -7777,17 +7783,16 @@ if(!s||!o.canReplaceWith(r,r,s))return!1
7777
7783
  if(e){let i=n.after(),o=t.tr.replaceWith(i,i,s.createAndFill())
7778
7784
  o.setSelection(Kx.near(o.doc.resolve(i),1)),e(o.scrollIntoView())}return!0})(t,e)
7779
7785
  function O$(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function R$(t,e,n={strict:!0}){const i=Object.keys(e)
7780
- return!i.length||i.every(i=>n.strict?e[i]===t[i]:O$(e[i])?e[i].test(t[i]):e[i]===t[i])}function F$(t,e,n={}){return t.find(t=>t.type===e&&R$(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function N$(t,e,n={}){return!!F$(t,e,n)}function L$(t,e,n){var i
7781
- if(!t||!e)return
7782
- let o=t.parent.childAfter(t.parentOffset)
7783
- if(o.node&&o.node.marks.some(t=>t.type===e)||(o=t.parent.childBefore(t.parentOffset)),!o.node||!o.node.marks.some(t=>t.type===e))return
7784
- n=n||(null==(i=o.node.marks[0])?void 0:i.attrs)
7785
- if(!F$([...o.node.marks],e,n))return
7786
- let r=o.index,s=t.start()+o.offset,a=r+1,l=s+o.node.nodeSize
7787
- for(;r>0&&N$([...t.parent.child(r-1).marks],e,n);)r-=1,s-=t.parent.child(r).nodeSize
7788
- for(;a<t.parent.childCount&&N$([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1
7789
- return{from:s,to:l}}function B$(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`)
7790
- return e.marks[t]}return t}var P$=(t,e={})=>({tr:n,state:i,dispatch:o})=>{const r=B$(t,i.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a
7786
+ return!i.length||i.every(i=>n.strict?e[i]===t[i]:O$(e[i])?e[i].test(t[i]):e[i]===t[i])}function F$(t,e,n={}){return t.find(t=>t.type===e&&R$(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function N$(t,e,n={}){return!!F$(t,e,n)}function L$(t,e,n){if(!t||!e)return
7787
+ let i=t.parent.childAfter(t.parentOffset)
7788
+ if(i.node&&i.node.marks.some(t=>t.type===e)||(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(t=>t.type===e))return
7789
+ if(!n){const t=i.node.marks.find(t=>t.type===e)
7790
+ t&&(n=t.attrs)}if(!F$([...i.node.marks],e,n))return
7791
+ let o=i.index,r=t.start()+i.offset,s=o+1,a=r+i.node.nodeSize
7792
+ for(;o>0&&N$([...t.parent.child(o-1).marks],e,n);)o-=1,r-=t.parent.child(o).nodeSize
7793
+ for(;s<t.parent.childCount&&N$([...t.parent.child(s).marks],e,n);)a+=t.parent.child(s).nodeSize,s+=1
7794
+ return{from:r,to:a}}function B$(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`)
7795
+ return e.marks[t]}return t}var P$=(t,e)=>({tr:n,state:i,dispatch:o})=>{const r=B$(t,i.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a
7791
7796
  if(o){const t=L$(l,r,e)
7792
7797
  if(t&&t.from<=c&&t.to>=d){const e=Qx.create(s,t.from,t.to)
7793
7798
  n.setSelection(e)}}return!0},z$=t=>e=>{const n="function"==typeof t?t(e):t
@@ -8215,7 +8220,7 @@ ZM(s).forEach(e=>{s.mapping.mapResult(e.oldRange.from).deletedAfter&&s.mapping.m
8215
8220
  this.editor.emit("delete",{type:"node",node:n,from:i,to:o,newFrom:s.mapping.map(i),newTo:s.mapping.map(o),deletedRange:e.oldRange,newRange:e.newRange,partial:!r,editor:this.editor,transaction:t,combinedTransform:s})})})
8216
8221
  const a=s.mapping
8217
8222
  s.steps.forEach((e,n)=>{var i,o
8218
- if(e instanceof mx){const r=a.slice(n).map(e.from,-1),l=a.slice(n).map(e.to),c=a.invert().map(r,-1),d=a.invert().map(l),h=null==(i=s.doc.nodeAt(r-1))?void 0:i.marks.some(t=>t.eq(e.mark)),u=null==(o=s.doc.nodeAt(l))?void 0:o.marks.some(t=>t.eq(e.mark))
8223
+ if(e instanceof mx){const r=a.slice(n).map(e.from,-1),l=a.slice(n).map(e.to),c=a.invert().map(r,-1),d=a.invert().map(l),h=r>0&&(null==(i=s.doc.nodeAt(r-1))?void 0:i.marks.some(t=>t.eq(e.mark))),u=null==(o=s.doc.nodeAt(l))?void 0:o.marks.some(t=>t.eq(e.mark))
8219
8224
  this.editor.emit("delete",{type:"mark",mark:e.mark,from:e.from,to:e.to,deletedRange:{from:c,to:d},newRange:{from:r,to:l},partial:Boolean(u||h),editor:this.editor,transaction:t,combinedTransform:s})}})}
8220
8225
  null==(o=null==(i=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:i.async)||o?setTimeout(r,0):r()}}),qI=zI.create({name:"drop",addProseMirrorPlugins(){return[new fC({key:new vC("tiptapDrop"),props:{handleDrop:(t,e,n,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:i})}}})]}}),jI=zI.create({name:"editable",addProseMirrorPlugins(){return[new fC({key:new vC("editable"),props:{editable:()=>this.editor.options.editable}})]}}),WI=new vC("focusEvents"),GI=zI.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this
8221
8226
  return[new fC({key:WI,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0
@@ -10136,34 +10141,35 @@ let w=y+g[0].length
10136
10141
  return l&&d.test(f.slice(w-1,w+1))&&(g[0]+=" ",w+=1),y<a.pos&&w>=a.pos?{range:{from:y,to:w},query:g[0].slice(n.length),text:g[0]}:null}zI.create({name:"listKit",addExtensions(){const t=[]
10137
10142
  return!1!==this.options.bulletList&&t.push(yF.configure(this.options.bulletList)),!1!==this.options.listItem&&t.push(wF.configure(this.options.listItem)),!1!==this.options.listKeymap&&t.push(TF.configure(this.options.listKeymap)),!1!==this.options.orderedList&&t.push(LF.configure(this.options.orderedList)),!1!==this.options.taskItem&&t.push(PF.configure(this.options.taskItem)),!1!==this.options.taskList&&t.push(zF.configure(this.options.taskList)),t}})
10138
10143
  var HF=new vC("suggestion")
10139
- function UF({pluginKey:t=HF,editor:e,char:n="@",allowSpaces:i=!1,allowToIncludeChar:o=!1,allowedPrefixes:r=[" "],startOfLine:s=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:h=()=>null,items:u=()=>[],render:p=()=>({}),allow:f=()=>!0,findSuggestionMatch:m=VF,shouldShow:g}){let v
10140
- const b=null==p?void 0:p(),y=()=>{const t=e.state.selection.$anchor.pos,n=e.view.coordsAtPos(t),{top:i,right:o,bottom:r,left:s}=n
10141
- try{return new DOMRect(s,i,o-s,r-i)}catch{return null}},w=(n,i)=>i?()=>{const i=t.getState(e.state),o=null==i?void 0:i.decorationId,r=n.dom.querySelector(`[data-decoration-id="${o}"]`)
10142
- return(null==r?void 0:r.getBoundingClientRect())||null}:y
10143
- const x=new fC({key:t,view(){return{update:async(t,n)=>{var i,o,r,s,a,l,c
10144
- const d=null==(i=this.key)?void 0:i.getState(n),p=null==(o=this.key)?void 0:o.getState(t.state),f=d.active&&p.active&&d.range.from!==p.range.from,m=!d.active&&p.active,g=d.active&&!p.active,y=!m&&!g&&d.query!==p.query,x=m||f&&y,C=y||f,k=g||f&&y
10145
- if(!x&&!C&&!k)return
10146
- const S=k&&!x?d:p,_=t.dom.querySelector(`[data-decoration-id="${S.decorationId}"]`)
10147
- v={editor:e,range:S.range,query:S.query,text:S.text,items:[],command:t=>h({editor:e,range:S.range,props:t}),decorationNode:_,clientRect:w(t,_)},x&&(null==(r=null==b?void 0:b.onBeforeStart)||r.call(b,v)),C&&(null==(s=null==b?void 0:b.onBeforeUpdate)||s.call(b,v)),(C||x)&&(v.items=await u({editor:e,query:S.query})),k&&(null==(a=null==b?void 0:b.onExit)||a.call(b,v)),C&&(null==(l=null==b?void 0:b.onUpdate)||l.call(b,v)),x&&(null==(c=null==b?void 0:b.onStart)||c.call(b,v))},destroy:()=>{var t
10148
- v&&(null==(t=null==b?void 0:b.onExit)||t.call(b,v))}}},state:{init:()=>({active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}),apply(a,l,c,d){const{isEditable:h}=e,{composing:u}=e.view,{selection:p}=a,{empty:v,from:b}=p,y={...l},w=a.getMeta(t)
10149
- if(w&&w.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y
10150
- if(y.composing=u,h&&(v||e.view.composing)){!(b<l.range.from||b>l.range.to)||u||l.composing||(y.active=!1)
10144
+ function UF({pluginKey:t=HF,editor:e,char:n="@",allowSpaces:i=!1,allowToIncludeChar:o=!1,allowedPrefixes:r=[" "],startOfLine:s=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:h=()=>null,items:u=()=>[],render:p=()=>({}),allow:f=()=>!0,findSuggestionMatch:m=VF,shouldShow:g,shouldResetDismissed:v}){let b
10145
+ const y=null==p?void 0:p(),w=i&&!o,x=()=>{const t=e.state.selection.$anchor.pos,n=e.view.coordsAtPos(t),{top:i,right:o,bottom:r,left:s}=n
10146
+ try{return new DOMRect(s,i,o-s,r-i)}catch{return null}},C=(n,i)=>i?()=>{const i=t.getState(e.state),o=null==i?void 0:i.decorationId,r=n.dom.querySelector(`[data-decoration-id="${o}"]`)
10147
+ return(null==r?void 0:r.getBoundingClientRect())||null}:x
10148
+ const k=new fC({key:t,view(){return{update:async(t,n)=>{var i,o,r,s,a,l,c
10149
+ const d=null==(i=this.key)?void 0:i.getState(n),p=null==(o=this.key)?void 0:o.getState(t.state),f=d.active&&p.active&&d.range.from!==p.range.from,m=!d.active&&p.active,g=d.active&&!p.active,v=!m&&!g&&d.query!==p.query,w=m||f&&v,x=v||f,k=g||f&&v
10150
+ if(!w&&!x&&!k)return
10151
+ const S=k&&!w?d:p,_=t.dom.querySelector(`[data-decoration-id="${S.decorationId}"]`)
10152
+ b={editor:e,range:S.range,query:S.query,text:S.text,items:[],command:t=>h({editor:e,range:S.range,props:t}),decorationNode:_,clientRect:C(t,_)},w&&(null==(r=null==y?void 0:y.onBeforeStart)||r.call(y,b)),x&&(null==(s=null==y?void 0:y.onBeforeUpdate)||s.call(y,b)),(x||w)&&(b.items=await u({editor:e,query:S.query})),k&&(null==(a=null==y?void 0:y.onExit)||a.call(y,b)),x&&(null==(l=null==y?void 0:y.onUpdate)||l.call(y,b)),w&&(null==(c=null==y?void 0:y.onStart)||c.call(y,b))},destroy:()=>{var t
10153
+ b&&(null==(t=null==y?void 0:y.onExit)||t.call(y,b))}}},state:{init:()=>({active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}),apply(a,l,c,d){const{isEditable:h}=e,{composing:u}=e.view,{selection:p}=a,{empty:b,from:y}=p,x={...l},C=a.getMeta(t)
10154
+ if(C&&C.exit)return x.active=!1,x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null,x.dismissedRange=l.active?{...l.range}:l.dismissedRange,x
10155
+ if(x.composing=u,a.docChanged&&null!==x.dismissedRange&&(x.dismissedRange={from:a.mapping.map(x.dismissedRange.from),to:a.mapping.map(x.dismissedRange.to)}),h&&(b||e.view.composing)){!(y<l.range.from||y>l.range.to)||u||l.composing||(x.active=!1)
10151
10156
  const t=m({char:n,allowSpaces:i,allowToIncludeChar:o,allowedPrefixes:r,startOfLine:s,$position:p.$from}),c=`id_${Math.floor(4294967295*Math.random())}`
10152
- t&&f({editor:e,state:d,range:t.range,isActive:l.active})&&(!g||g({editor:e,range:t.range,query:t.query,text:t.text,transaction:a}))?(y.active=!0,y.decorationId=l.decorationId?l.decorationId:c,y.range=t.range,y.query=t.query,y.text=t.text):y.active=!1}else y.active=!1
10153
- return y.active||(y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null),y}},props:{handleKeyDown(n,i){var o,r,s,a
10154
- const{active:l,range:c}=x.getState(n.state)
10155
- if(!l)return!1
10156
- if("Escape"===i.key||"Esc"===i.key){const a=x.getState(n.state),l=null!=(o=null==v?void 0:v.decorationNode)?o:null,c=null!=l?l:(null==a?void 0:a.decorationId)?n.dom.querySelector(`[data-decoration-id="${a.decorationId}"]`):null
10157
- if((null==(r=null==b?void 0:b.onKeyDown)?void 0:r.call(b,{view:n,event:i,range:a.range}))||!1)return!0
10158
- const d={editor:e,range:a.range,query:a.query,text:a.text,items:[],command:t=>h({editor:e,range:a.range,props:t}),decorationNode:c,clientRect:c?()=>c.getBoundingClientRect()||null:null}
10159
- return null==(s=null==b?void 0:b.onExit)||s.call(b,d),function(n,i){var o
10160
- try{const i=t.getState(n.state),r=(null==i?void 0:i.decorationId)?n.dom.querySelector(`[data-decoration-id="${i.decorationId}"]`):null,s={editor:e,range:(null==i?void 0:i.range)||{from:0,to:0},query:(null==i?void 0:i.query)||null,text:(null==i?void 0:i.text)||null,items:[],command:t=>h({editor:e,range:(null==i?void 0:i.range)||{from:0,to:0},props:t}),decorationNode:r,clientRect:w(n,r)}
10161
- null==(o=null==b?void 0:b.onExit)||o.call(b,s)}catch{}const r=n.state.tr.setMeta(i,{exit:!0})
10162
- n.dispatch(r)}(n,t),!0}return(null==(a=null==b?void 0:b.onKeyDown)?void 0:a.call(b,{view:n,event:i,range:c}))||!1},decorations(t){const{active:e,range:n,decorationId:i,query:o}=x.getState(t)
10157
+ t&&f({editor:e,state:d,range:t.range,isActive:l.active})&&(!g||g({editor:e,range:t.range,query:t.query,text:t.text,transaction:a}))?(null===x.dismissedRange||(({match:t,dismissedRange:n,state:i,transaction:o})=>!(null==v?void 0:v({editor:e,state:i,range:n,match:t,transaction:o,allowSpaces:w}))&&(w?t.range.from===n.from:t.range.from===n.from&&!function(t){return!!t.docChanged&&t.steps.some(t=>{const e=t.slice
10158
+ if(!(null==e?void 0:e.content))return!1
10159
+ const n=e.content.textBetween(0,e.content.size,"\n")
10160
+ return/\s/.test(n)})}(o)))({match:t,dismissedRange:x.dismissedRange,state:d,transaction:a})||(x.dismissedRange=null),null===x.dismissedRange?(x.active=!0,x.decorationId=l.decorationId?l.decorationId:c,x.range=t.range,x.query=t.query,x.text=t.text):x.active=!1):(t||(x.dismissedRange=null),x.active=!1)}else x.active=!1
10161
+ return x.active||(x.decorationId=null,x.range={from:0,to:0},x.query=null,x.text=null),x}},props:{handleKeyDown(n,i){var o,r
10162
+ const{active:s,range:a}=k.getState(n.state)
10163
+ if(!s)return!1
10164
+ if("Escape"===i.key||"Esc"===i.key){const r=k.getState(n.state)
10165
+ return null==(o=null==y?void 0:y.onKeyDown)||o.call(y,{view:n,event:i,range:r.range}),function(n,i){var o
10166
+ try{const i=t.getState(n.state),r=(null==i?void 0:i.decorationId)?n.dom.querySelector(`[data-decoration-id="${i.decorationId}"]`):null,s={editor:e,range:(null==i?void 0:i.range)||{from:0,to:0},query:(null==i?void 0:i.query)||null,text:(null==i?void 0:i.text)||null,items:[],command:t=>h({editor:e,range:(null==i?void 0:i.range)||{from:0,to:0},props:t}),decorationNode:r,clientRect:C(n,r)}
10167
+ null==(o=null==y?void 0:y.onExit)||o.call(y,s)}catch{}const r=n.state.tr.setMeta(i,{exit:!0})
10168
+ n.dispatch(r)}(n,t),!0}return(null==(r=null==y?void 0:y.onKeyDown)?void 0:r.call(y,{view:n,event:i,range:a}))||!1},decorations(t){const{active:e,range:n,decorationId:i,query:o}=k.getState(t)
10163
10169
  if(!e)return null
10164
10170
  const r=!(null==o?void 0:o.length),s=[l]
10165
10171
  return r&&s.push(d),M_.create(t.doc,[S_.inline(n.from,n.to,{nodeName:a,class:s.join(" "),"data-decoration-id":i,"data-decoration-content":c})])}}})
10166
- return x}function qF(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>function({editor:t,overrideSuggestionOptions:e,extensionName:n,char:i="@"}){const o=new vC
10172
+ return k}function qF(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>function({editor:t,overrideSuggestionOptions:e,extensionName:n,char:i="@"}){const o=new vC
10167
10173
  return{editor:t,char:i,pluginKey:o,command:({editor:t,range:e,props:o})=>{var r,s,a
10168
10174
  const l=t.view.state.selection.$to.nodeAfter;(null==(r=null==l?void 0:l.text)?void 0:r.startsWith(" "))&&(e.to+=1),t.chain().focus().insertContentAt(e,[{type:n,attrs:{...o,mentionSuggestionChar:i}},{type:"text",text:" "}]).run(),null==(a=null==(s=t.view.dom.ownerDocument.defaultView)?void 0:s.getSelection())||a.collapseToEnd()},allow:({state:t,range:e})=>{const i=t.doc.resolve(e.from),o=t.schema.nodes[n]
10169
10175
  return!!i.parent.type.contentMatch.matchType(o)},...e}}({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function jF(t,e){const n=qF(t),i=n.find(t=>t.char===e)
@@ -10185,7 +10191,7 @@ let s=new xw,a=0
10185
10191
  return e.doc.nodesBetween(r-1,r,(t,e)=>{if(t.type.name===this.name)return n=!0,s=t,a=e,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":s.attrs.mentionSuggestionChar,a,a+s.nodeSize),n})}},addProseMirrorPlugins(){return qF(this).map(UF)}}),GF=WF,ZF="&nbsp;",KF=hE.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",LM(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[]
10186
10192
  if(1===n.length&&"image"===n[0].type)return e.parseChildren([n[0]])
10187
10193
  const i=e.parseInline(n)
10188
- return 1!==i.length||"text"!==i[0].type||i[0].text!==ZF&&" "!==i[0].text?e.createNode("paragraph",void 0,i):e.createNode("paragraph",void 0,[])},renderMarkdown:(t,e,n)=>{var i,o
10194
+ return!(1===n.length&&"text"===n[0].type&&(n[0].raw===ZF||n[0].text===ZF||" "===n[0].raw||" "===n[0].text))||1!==i.length||"text"!==i[0].type||i[0].text!==ZF&&" "!==i[0].text?e.createNode("paragraph",void 0,i):e.createNode("paragraph",void 0,[])},renderMarkdown:(t,e,n)=>{var i,o
10189
10195
  if(!t)return""
10190
10196
  const r=Array.isArray(t.content)?t.content:[]
10191
10197
  if(0===r.length){const t=Array.isArray(null==(i=null==n?void 0:n.previousNode)?void 0:i.content)?n.previousNode.content:[]
@@ -10371,11 +10377,12 @@ if((i||!this.options.showOnlyCurrent)&&a){const o=[this.options.emptyNodeClass]
10371
10377
  s&&o.push(this.options.emptyEditorClass)
10372
10378
  const a=S_.node(n,n+e.nodeSize,{class:o.join(" "),[t]:"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:e,pos:n,hasAnchor:i}):this.options.placeholder})
10373
10379
  r.push(a)}return this.options.includeChildren}),M_.create(e,r)}}})]}})
10374
- function EN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(null==e?void 0:e.type)===t}zI.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:e}=this
10375
- return[new fC({key:new vC("selection"),props:{decorations:n=>n.selection.empty||t.isFocused||!t.isEditable||n.selection instanceof eC||t.view.dragging?null:M_.create(n.doc,[S_.inline(n.selection.from,n.selection.to,{class:e.className})])}})]}}),zI.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t
10380
+ zI.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:e}=this
10381
+ return[new fC({key:new vC("selection"),props:{decorations:n=>n.selection.empty||t.isFocused||!t.isEditable||n.selection instanceof eC||t.view.dragging?null:M_.create(n.doc,[S_.inline(n.selection.from,n.selection.to,{class:e.className})])}})]}})
10382
+ function EN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(null==e?void 0:e.type)===t}zI.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t
10376
10383
  const e=new vC(this.name),n=this.options.node||(null==(t=this.editor.schema.topNodeType.contentMatch.defaultType)?void 0:t.name)||"paragraph",i=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>(this.options.notAfter||[]).concat(n).includes(t.name))
10377
10384
  return[new fC({key:e,appendTransaction:(t,i,o)=>{const{doc:r,tr:s,schema:a}=o,l=e.getState(o),c=r.content.size,d=a.nodes[n]
10378
- if(l)return s.insert(c,d.create())},state:{init:(t,e)=>!EN({node:e.tr.doc.lastChild,types:i}),apply:(t,e)=>{if(!t.docChanged)return e
10385
+ if(!t.some(t=>t.getMeta("skipTrailingNode"))&&l)return s.insert(c,d.create())},state:{init:(t,e)=>!EN({node:e.tr.doc.lastChild,types:i}),apply:(t,e)=>{if(!t.docChanged)return e
10379
10386
  if(t.getMeta("__uniqueIDTransaction"))return e
10380
10387
  return!EN({node:t.doc.lastChild,types:i})}}})]}})
10381
10388
  var AN=zI.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>_N(t,e),redo:()=>({state:t,dispatch:e})=>$N(t,e)}),addProseMirrorPlugins(){return[kN(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}})