@ni/nimble-components 35.5.3 → 35.5.4

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.
@@ -6378,14 +6378,14 @@ return tx.fromReplace(t,this.pos,this.pos+1,new jy(Py.from(n),0,e.isLeaf?0:1))}i
6378
6378
  return e&&this.mark.isInSet(e.marks)?new ox(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1)
6379
6379
  return e.deletedAfter?null:new rx(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")
6380
6380
  return new rx(e.pos,t.markFromJSON(e.mark))}}Qw.jsonID("removeNodeMark",rx)
6381
- class sx extends Qw{constructor(t,e,n,i=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=i}apply(t){return this.structure&&lx(t,this.from,this.to)?tx.fail("Structure replace would overwrite content"):tx.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Yw([this.from,this.to-this.from,this.slice.size])}invert(t){return new sx(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)
6382
- return e.deletedAcross&&n.deletedAcross?null:new sx(e.pos,Math.max(e.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof sx)||t.structure||this.structure)return null
6381
+ class sx extends Qw{constructor(t,e,n,i=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=i}apply(t){return this.structure&&lx(t,this.from,this.to)?tx.fail("Structure replace would overwrite content"):tx.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Yw([this.from,this.to-this.from,this.slice.size])}invert(t){return new sx(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&&sx.MAP_BIAS<0?e:t.mapResult(this.from,1)
6382
+ return n.deletedAcross&&e.deletedAcross?null:new sx(n.pos,Math.max(n.pos,e.pos),this.slice,this.structure)}merge(t){if(!(t instanceof sx)||t.structure||this.structure)return null
6383
6383
  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
6384
6384
  {let e=this.slice.size+t.slice.size==0?jy.empty:new jy(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd)
6385
6385
  return new sx(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?jy.empty:new jy(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd)
6386
6386
  return new sx(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to}
6387
6387
  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")
6388
- return new sx(e.from,e.to,jy.fromJSON(t,e.slice),!!e.structure)}}Qw.jsonID("replace",sx)
6388
+ return new sx(e.from,e.to,jy.fromJSON(t,e.slice),!!e.structure)}}sx.MAP_BIAS=1,Qw.jsonID("replace",sx)
6389
6389
  class ax extends Qw{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&&(lx(t,this.from,this.gapFrom)||lx(t,this.gapTo,this.to)))return tx.fail("Structure gap-replace would overwrite content")
6390
6390
  let e=t.slice(this.gapFrom,this.gapTo)
6391
6391
  if(e.openStart||e.openEnd)return tx.fail("Gap is not a flat range")
@@ -6553,7 +6553,13 @@ if(i.node(t).canReplaceWith(e,e,n))return i.before(t+1)
6553
6553
  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)
6554
6554
  if(i.node(t).canReplaceWith(e,e,n))return i.after(t+1)
6555
6555
  if(e<i.node(t).childCount)return null}return null}(t.doc,e,i.type)
6556
- null!=o&&(e=n=o)}t.replaceRange(e,n,new jy(Py.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=Tx(i,o)
6556
+ null!=o&&(e=n=o)}t.replaceRange(e,n,new jy(Py.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)
6557
+ if(i.parent.isTextblock&&o.parent.isTextblock&&i.start()!=o.start()&&0==i.parentOffset&&0==o.parentOffset){let r=i.sharedDepth(n),s=!1
6558
+ for(let t=i.depth;t>r;t--)i.node(t).type.spec.isolating&&(s=!0)
6559
+ for(let t=o.depth;t>r;t--)o.node(t).type.spec.isolating&&(s=!0)
6560
+ if(!s){for(let t=i.depth;t>0&&e==i.start(t);t--)e=i.before(t)
6561
+ for(let t=o.depth;t>0&&n==o.start(t);t--)n=o.before(t)
6562
+ i=t.doc.resolve(e),o=t.doc.resolve(n)}}let r=Tx(i,o)
6557
6563
  for(let e=0;e<r.length;e++){let n=r[e],s=e==r.length-1
6558
6564
  if(s&&0==n||i.node(n).type.contentMatch.validEnd)return t.delete(i.start(n),o.end(n))
6559
6565
  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)
@@ -7761,17 +7767,16 @@ if(!s||!o.canReplaceWith(r,r,s))return!1
7761
7767
  if(e){let i=n.after(),o=t.tr.replaceWith(i,i,s.createAndFill())
7762
7768
  o.setSelection(Lx.near(o.doc.resolve(i),1)),e(o.scrollIntoView())}return!0})(t,e)
7763
7769
  function x$(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function C$(t,e,n={strict:!0}){const i=Object.keys(e)
7764
- return!i.length||i.every(i=>n.strict?e[i]===t[i]:x$(e[i])?e[i].test(t[i]):e[i]===t[i])}function k$(t,e,n={}){return t.find(t=>t.type===e&&C$(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function S$(t,e,n={}){return!!k$(t,e,n)}function _$(t,e,n){var i
7765
- if(!t||!e)return
7766
- let o=t.parent.childAfter(t.parentOffset)
7767
- 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
7768
- n=n||(null==(i=o.node.marks[0])?void 0:i.attrs)
7769
- if(!k$([...o.node.marks],e,n))return
7770
- let r=o.index,s=t.start()+o.offset,a=r+1,l=s+o.node.nodeSize
7771
- for(;r>0&&S$([...t.parent.child(r-1).marks],e,n);)r-=1,s-=t.parent.child(r).nodeSize
7772
- for(;a<t.parent.childCount&&S$([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1
7773
- return{from:s,to:l}}function $$(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?`)
7774
- return e.marks[t]}return t}var M$=(t,e={})=>({tr:n,state:i,dispatch:o})=>{const r=$$(t,i.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a
7770
+ return!i.length||i.every(i=>n.strict?e[i]===t[i]:x$(e[i])?e[i].test(t[i]):e[i]===t[i])}function k$(t,e,n={}){return t.find(t=>t.type===e&&C$(Object.fromEntries(Object.keys(n).map(e=>[e,t.attrs[e]])),n))}function S$(t,e,n={}){return!!k$(t,e,n)}function _$(t,e,n){if(!t||!e)return
7771
+ let i=t.parent.childAfter(t.parentOffset)
7772
+ 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
7773
+ if(!n){const t=i.node.marks.find(t=>t.type===e)
7774
+ t&&(n=t.attrs)}if(!k$([...i.node.marks],e,n))return
7775
+ let o=i.index,r=t.start()+i.offset,s=o+1,a=r+i.node.nodeSize
7776
+ for(;o>0&&S$([...t.parent.child(o-1).marks],e,n);)o-=1,r-=t.parent.child(o).nodeSize
7777
+ for(;s<t.parent.childCount&&S$([...t.parent.child(s).marks],e,n);)a+=t.parent.child(s).nodeSize,s+=1
7778
+ return{from:r,to:a}}function $$(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?`)
7779
+ return e.marks[t]}return t}var M$=(t,e)=>({tr:n,state:i,dispatch:o})=>{const r=$$(t,i.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a
7775
7780
  if(o){const t=_$(l,r,e)
7776
7781
  if(t&&t.from<=c&&t.to>=d){const e=Vx.create(s,t.from,t.to)
7777
7782
  n.setSelection(e)}}return!0},I$=t=>e=>{const n="function"==typeof t?t(e):t
@@ -8199,7 +8204,7 @@ NM(s).forEach(e=>{s.mapping.mapResult(e.oldRange.from).deletedAfter&&s.mapping.m
8199
8204
  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})})})
8200
8205
  const a=s.mapping
8201
8206
  s.steps.forEach((e,n)=>{var i,o
8202
- if(e instanceof ix){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))
8207
+ if(e instanceof ix){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))
8203
8208
  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})}})}
8204
8209
  null==(o=null==(i=null==(n=this.editor.options.coreExtensionOptions)?void 0:n.delete)?void 0:i.async)||o?setTimeout(r,0):r()}}),DI=II.create({name:"drop",addProseMirrorPlugins(){return[new nC({key:new rC("tiptapDrop"),props:{handleDrop:(t,e,n,i)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:i})}}})]}}),OI=II.create({name:"editable",addProseMirrorPlugins(){return[new nC({key:new rC("editable"),props:{editable:()=>this.editor.options.editable}})]}}),RI=new rC("focusEvents"),FI=II.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this
8205
8210
  return[new nC({key:RI,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0
@@ -10120,34 +10125,35 @@ let w=y+g[0].length
10120
10125
  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}II.create({name:"listKit",addExtensions(){const t=[]
10121
10126
  return!1!==this.options.bulletList&&t.push(aF.configure(this.options.bulletList)),!1!==this.options.listItem&&t.push(lF.configure(this.options.listItem)),!1!==this.options.listKeymap&&t.push(yF.configure(this.options.listKeymap)),!1!==this.options.orderedList&&t.push(_F.configure(this.options.orderedList)),!1!==this.options.taskItem&&t.push(MF.configure(this.options.taskItem)),!1!==this.options.taskList&&t.push(IF.configure(this.options.taskList)),t}})
10122
10127
  var AF=new rC("suggestion")
10123
- function TF({pluginKey:t=AF,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=EF,shouldShow:g}){let v
10124
- 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
10125
- 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}"]`)
10126
- return(null==r?void 0:r.getBoundingClientRect())||null}:y
10127
- const x=new nC({key:t,view(){return{update:async(t,n)=>{var i,o,r,s,a,l,c
10128
- 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
10129
- if(!x&&!C&&!k)return
10130
- const S=k&&!x?d:p,_=t.dom.querySelector(`[data-decoration-id="${S.decorationId}"]`)
10131
- 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
10132
- 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)
10133
- if(w&&w.exit)return y.active=!1,y.decorationId=null,y.range={from:0,to:0},y.query=null,y.text=null,y
10134
- if(y.composing=u,h&&(v||e.view.composing)){!(b<l.range.from||b>l.range.to)||u||l.composing||(y.active=!1)
10128
+ function TF({pluginKey:t=AF,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=EF,shouldShow:g,shouldResetDismissed:v}){let b
10129
+ 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
10130
+ 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}"]`)
10131
+ return(null==r?void 0:r.getBoundingClientRect())||null}:x
10132
+ const k=new nC({key:t,view(){return{update:async(t,n)=>{var i,o,r,s,a,l,c
10133
+ 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
10134
+ if(!w&&!x&&!k)return
10135
+ const S=k&&!w?d:p,_=t.dom.querySelector(`[data-decoration-id="${S.decorationId}"]`)
10136
+ 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
10137
+ 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)
10138
+ 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
10139
+ 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)
10135
10140
  const t=m({char:n,allowSpaces:i,allowToIncludeChar:o,allowedPrefixes:r,startOfLine:s,$position:p.$from}),c=`id_${Math.floor(4294967295*Math.random())}`
10136
- 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
10137
- 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
10138
- const{active:l,range:c}=x.getState(n.state)
10139
- if(!l)return!1
10140
- 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
10141
- if((null==(r=null==b?void 0:b.onKeyDown)?void 0:r.call(b,{view:n,event:i,range:a.range}))||!1)return!0
10142
- 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}
10143
- return null==(s=null==b?void 0:b.onExit)||s.call(b,d),function(n,i){var o
10144
- 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)}
10145
- null==(o=null==b?void 0:b.onExit)||o.call(b,s)}catch{}const r=n.state.tr.setMeta(i,{exit:!0})
10146
- 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)
10141
+ 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
10142
+ if(!(null==e?void 0:e.content))return!1
10143
+ const n=e.content.textBetween(0,e.content.size,"\n")
10144
+ 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
10145
+ 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
10146
+ const{active:s,range:a}=k.getState(n.state)
10147
+ if(!s)return!1
10148
+ if("Escape"===i.key||"Esc"===i.key){const r=k.getState(n.state)
10149
+ return null==(o=null==y?void 0:y.onKeyDown)||o.call(y,{view:n,event:i,range:r.range}),function(n,i){var o
10150
+ 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)}
10151
+ null==(o=null==y?void 0:y.onExit)||o.call(y,s)}catch{}const r=n.state.tr.setMeta(i,{exit:!0})
10152
+ 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)
10147
10153
  if(!e)return null
10148
10154
  const r=!(null==o?void 0:o.length),s=[l]
10149
10155
  return r&&s.push(d),m_.create(t.doc,[u_.inline(n.from,n.to,{nodeName:a,class:s.join(" "),"data-decoration-id":i,"data-decoration-content":c})])}}})
10150
- return x}function DF(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 rC
10156
+ return k}function DF(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 rC
10151
10157
  return{editor:t,char:i,pluginKey:o,command:({editor:t,range:e,props:o})=>{var r,s,a
10152
10158
  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]
10153
10159
  return!!i.parent.type.contentMatch.matchType(o)},...e}}({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function OF(t,e){const n=DF(t),i=n.find(t=>t.char===e)
@@ -10169,7 +10175,7 @@ let s=new cw,a=0
10169
10175
  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 DF(this).map(TF)}}),FF=RF,NF="&nbsp;",LF=QI.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",_M(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[]
10170
10176
  if(1===n.length&&"image"===n[0].type)return e.parseChildren([n[0]])
10171
10177
  const i=e.parseInline(n)
10172
- return 1!==i.length||"text"!==i[0].type||i[0].text!==NF&&" "!==i[0].text?e.createNode("paragraph",void 0,i):e.createNode("paragraph",void 0,[])},renderMarkdown:(t,e,n)=>{var i,o
10178
+ return!(1===n.length&&"text"===n[0].type&&(n[0].raw===NF||n[0].text===NF||" "===n[0].raw||" "===n[0].text))||1!==i.length||"text"!==i[0].type||i[0].text!==NF&&" "!==i[0].text?e.createNode("paragraph",void 0,i):e.createNode("paragraph",void 0,[])},renderMarkdown:(t,e,n)=>{var i,o
10173
10179
  if(!t)return""
10174
10180
  const r=Array.isArray(t.content)?t.content:[]
10175
10181
  if(0===r.length){const t=Array.isArray(null==(i=null==n?void 0:n.previousNode)?void 0:i.content)?n.previousNode.content:[]
@@ -10355,11 +10361,12 @@ if((i||!this.options.showOnlyCurrent)&&a){const o=[this.options.emptyNodeClass]
10355
10361
  s&&o.push(this.options.emptyEditorClass)
10356
10362
  const a=u_.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})
10357
10363
  r.push(a)}return this.options.includeChildren}),m_.create(e,r)}}})]}})
10358
- function vN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(null==e?void 0:e.type)===t}II.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:e}=this
10359
- return[new nC({key:new rC("selection"),props:{decorations:n=>n.selection.empty||t.isFocused||!t.isEditable||n.selection instanceof Ux||t.view.dragging?null:m_.create(n.doc,[u_.inline(n.selection.from,n.selection.to,{class:e.className})])}})]}}),II.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t
10364
+ II.create({name:"selection",addOptions:()=>({className:"selection"}),addProseMirrorPlugins(){const{editor:t,options:e}=this
10365
+ return[new nC({key:new rC("selection"),props:{decorations:n=>n.selection.empty||t.isFocused||!t.isEditable||n.selection instanceof Ux||t.view.dragging?null:m_.create(n.doc,[u_.inline(n.selection.from,n.selection.to,{class:e.className})])}})]}})
10366
+ function vN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(null==e?void 0:e.type)===t}II.create({name:"trailingNode",addOptions:()=>({node:void 0,notAfter:[]}),addProseMirrorPlugins(){var t
10360
10367
  const e=new rC(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))
10361
10368
  return[new nC({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]
10362
- if(l)return s.insert(c,d.create())},state:{init:(t,e)=>!vN({node:e.tr.doc.lastChild,types:i}),apply:(t,e)=>{if(!t.docChanged)return e
10369
+ if(!t.some(t=>t.getMeta("skipTrailingNode"))&&l)return s.insert(c,d.create())},state:{init:(t,e)=>!vN({node:e.tr.doc.lastChild,types:i}),apply:(t,e)=>{if(!t.docChanged)return e
10363
10370
  if(t.getMeta("__uniqueIDTransaction"))return e
10364
10371
  return!vN({node:t.doc.lastChild,types:i})}}})]}})
10365
10372
  var bN=II.create({name:"undoRedo",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:t,dispatch:e})=>pN(t,e),redo:()=>({state:t,dispatch:e})=>fN(t,e)}),addProseMirrorPlugins(){return[hN(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()}}})