reactjs-tiptap-editor 1.0.23 → 1.0.25

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.
Files changed (153) hide show
  1. package/lib/{ActionMenuButton-C53IYt_R.js → ActionMenuButton-8cTG45Ft.js} +1 -1
  2. package/lib/{ActionMenuButton-Da0H9Beu.cjs → ActionMenuButton-CXeFhner.cjs} +1 -1
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +3 -3
  5. package/lib/Blockquote.cjs +1 -1
  6. package/lib/Blockquote.js +2 -2
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +2 -2
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +2 -2
  11. package/lib/{Callout-CdXbDkZ6.cjs → Callout-DWOMZPiP.cjs} +1 -1
  12. package/lib/{Callout-igc-a1lj.js → Callout-ZlPQrMEt.js} +3 -3
  13. package/lib/Callout.cjs +1 -1
  14. package/lib/Callout.js +4 -4
  15. package/lib/Clear.cjs +1 -1
  16. package/lib/Clear.js +2 -2
  17. package/lib/Code.cjs +1 -1
  18. package/lib/Code.js +6 -6
  19. package/lib/CodeBlock.cjs +1 -1
  20. package/lib/CodeBlock.js +27 -27
  21. package/lib/CodeView.cjs +1 -1
  22. package/lib/CodeView.js +2 -2
  23. package/lib/Color.cjs +1 -1
  24. package/lib/Color.js +3 -3
  25. package/lib/Column.cjs +1 -1
  26. package/lib/Column.js +7 -7
  27. package/lib/{Drawer-DzroBQds.js → Drawer-C-EO1uoK.js} +20 -20
  28. package/lib/{Drawer-CrMuQNbZ.cjs → Drawer-TJY4NuHx.cjs} +1 -1
  29. package/lib/Drawer.cjs +1 -1
  30. package/lib/Drawer.js +4 -4
  31. package/lib/Emoji.cjs +1 -1
  32. package/lib/Emoji.js +4311 -1859
  33. package/lib/Excalidraw.cjs +1 -1
  34. package/lib/Excalidraw.js +3 -3
  35. package/lib/ExportPdf.cjs +1 -1
  36. package/lib/ExportPdf.js +2 -2
  37. package/lib/ExportWord.cjs +1 -1
  38. package/lib/ExportWord.js +2 -2
  39. package/lib/FontFamily.cjs +1 -1
  40. package/lib/FontFamily.js +4 -4
  41. package/lib/FontSize.cjs +1 -1
  42. package/lib/FontSize.js +4 -4
  43. package/lib/Heading.cjs +1 -1
  44. package/lib/Heading.js +9 -9
  45. package/lib/Highlight.cjs +1 -1
  46. package/lib/Highlight.js +79 -50
  47. package/lib/History.cjs +1 -1
  48. package/lib/History.js +556 -418
  49. package/lib/HorizontalRule.cjs +1 -1
  50. package/lib/HorizontalRule.js +2 -2
  51. package/lib/{Iframe-DVLx3H0m.cjs → Iframe-5zx43DL4.cjs} +1 -1
  52. package/lib/{Iframe-Dt2Styg8.js → Iframe-CGb6-2LD.js} +3 -3
  53. package/lib/Iframe.cjs +1 -1
  54. package/lib/Iframe.js +3 -3
  55. package/lib/Image.cjs +1 -1
  56. package/lib/Image.js +3 -3
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +4 -4
  59. package/lib/ImportWord.cjs +1 -1
  60. package/lib/ImportWord.js +2 -2
  61. package/lib/{Indent-BCZFJKcN.js → Indent-CdMYsDNS.js} +4 -4
  62. package/lib/{Indent-CQCn1r9U.cjs → Indent-DuwV8s1t.cjs} +1 -1
  63. package/lib/Indent.cjs +1 -1
  64. package/lib/Indent.js +2 -2
  65. package/lib/Italic.cjs +1 -1
  66. package/lib/Italic.js +2 -2
  67. package/lib/{Katex--VT0zcjU.js → Katex-CCP_ZQz2.js} +4 -4
  68. package/lib/{Katex-By61XteD.cjs → Katex-D9FP7EUE.cjs} +1 -1
  69. package/lib/Katex.cjs +1 -1
  70. package/lib/Katex.js +3 -3
  71. package/lib/LineHeight.cjs +1 -1
  72. package/lib/LineHeight.js +3 -3
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +2 -2
  75. package/lib/{LinkEditBlock-C_F9zWEj.js → LinkEditBlock-B1m-TVMu.js} +222 -224
  76. package/lib/LinkEditBlock-DQ8-iufJ.cjs +5 -0
  77. package/lib/MarkdownPaste.cjs +1 -1
  78. package/lib/MarkdownPaste.js +1 -1
  79. package/lib/Mention.cjs +1 -1
  80. package/lib/Mention.js +8 -8
  81. package/lib/Mermaid.cjs +1 -1
  82. package/lib/Mermaid.js +27 -27
  83. package/lib/MoreMark.cjs +1 -1
  84. package/lib/MoreMark.js +3 -3
  85. package/lib/OrderedList.cjs +1 -1
  86. package/lib/OrderedList.js +2 -2
  87. package/lib/SearchAndReplace.cjs +1 -1
  88. package/lib/SearchAndReplace.js +3 -3
  89. package/lib/SlashCommand.cjs +1 -1
  90. package/lib/SlashCommand.js +6 -6
  91. package/lib/{SlashCommandNodeView-Aqc77oRC.cjs → SlashCommandNodeView-DNixmQGa.cjs} +1 -1
  92. package/lib/{SlashCommandNodeView-DxlBPKPV.js → SlashCommandNodeView-Dt6n1SP9.js} +1 -1
  93. package/lib/Strike.cjs +1 -1
  94. package/lib/Strike.js +2 -2
  95. package/lib/Table-C5JxBXef.cjs +9 -0
  96. package/lib/Table-DdEgaUwa.js +1984 -0
  97. package/lib/Table.cjs +1 -1
  98. package/lib/Table.js +1 -1
  99. package/lib/TaskList.cjs +1 -1
  100. package/lib/TaskList.js +2 -2
  101. package/lib/TextAlign.cjs +1 -1
  102. package/lib/TextAlign.js +3 -3
  103. package/lib/TextDirection.cjs +1 -1
  104. package/lib/TextDirection.js +3 -3
  105. package/lib/TextUnderline.cjs +1 -1
  106. package/lib/TextUnderline.js +2 -2
  107. package/lib/{Twitter-f-oMDZuV.cjs → Twitter--tfifMt1.cjs} +1 -1
  108. package/lib/{Twitter-DP_9V0zb.js → Twitter-Dnz9qyW0.js} +4 -4
  109. package/lib/Twitter.cjs +1 -1
  110. package/lib/Twitter.js +3 -3
  111. package/lib/Video.cjs +1 -1
  112. package/lib/Video.js +2 -2
  113. package/lib/bubble.cjs +6 -6
  114. package/lib/bubble.js +1573 -1561
  115. package/lib/{clsx-Bg-2aTKh.js → clsx-0OU6n9va.js} +379 -353
  116. package/lib/clsx-D6gYQn3o.cjs +33 -0
  117. package/lib/{dropdown-menu-uIj8M0jD.js → dropdown-menu-ROihzXsP.js} +1 -1
  118. package/lib/{dropdown-menu-DeBV2h9-.cjs → dropdown-menu-yQ-sQ1k4.cjs} +1 -1
  119. package/lib/index-BAb_UADw.cjs +1 -0
  120. package/lib/index-BF3EVCB1.cjs +2 -0
  121. package/lib/{index-D0EmqTpe.js → index-BblvcbTH.js} +1130 -1064
  122. package/lib/index-Bcj8cyOO.cjs +24 -0
  123. package/lib/index-CGjT-a9h.js +1377 -0
  124. package/lib/index-CPTpXLfX.cjs +11 -0
  125. package/lib/{index-C3dgmjIF.cjs → index-CUvjYuRp.cjs} +1 -1
  126. package/lib/{index-DXtVL0al.js → index-Cal5SPfB.js} +189 -134
  127. package/lib/{index-CjLxMm5d.js → index-D-Ouz0vF.js} +1 -1
  128. package/lib/{index-ezTXvA7H.cjs → index-Gi752TMk.cjs} +1 -1
  129. package/lib/{index-BVtsbzV8.js → index-X6WZUM9O.js} +15 -15
  130. package/lib/{index-CbkpBnTX.js → index-zw-Kd38i.js} +47 -50
  131. package/lib/index.cjs +1 -1
  132. package/lib/index.js +2 -2
  133. package/lib/{popover-Cq1iLY7i.cjs → popover-BPzkMuyi.cjs} +1 -1
  134. package/lib/{popover-mlZeH-7I.js → popover-BfWFqCIs.js} +1 -1
  135. package/lib/{renderNodeView-CbxCTni3.js → renderNodeView-CfWJK4rG.js} +2 -2
  136. package/lib/{renderNodeView-DFVrJy0l.cjs → renderNodeView-D--fDFov.cjs} +1 -1
  137. package/lib/{separator-Bh_ttGZg.js → separator-CBPrZizK.js} +2 -2
  138. package/lib/{separator-DvAvl5_5.cjs → separator-DpaS43Gt.cjs} +1 -1
  139. package/lib/{textarea-MU5imD7D.js → textarea-Bl64keav.js} +1 -1
  140. package/lib/{textarea-CKXzGwId.cjs → textarea-wvARZKyA.cjs} +1 -1
  141. package/lib/updatePosition-BwzAsiY0.js +16 -0
  142. package/lib/{updatePosition-CQE1ct18.cjs → updatePosition-DGPtRfWN.cjs} +1 -1
  143. package/package.json +60 -60
  144. package/lib/LinkEditBlock-BLkA2CYZ.cjs +0 -5
  145. package/lib/Table-DqXkwJAY.cjs +0 -9
  146. package/lib/Table-r09L4PvT.js +0 -1945
  147. package/lib/clsx-DSAWW32g.cjs +0 -33
  148. package/lib/index-C4WLt4NA.cjs +0 -24
  149. package/lib/index-DlxZt4_j.cjs +0 -1
  150. package/lib/index-P5_MyY0i.js +0 -1362
  151. package/lib/index-TcJ2UKnv.cjs +0 -1
  152. package/lib/index-fbGGohBT.cjs +0 -12
  153. package/lib/updatePosition-BGD41Hbg.js +0 -16
package/lib/History.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-C4WLt4NA.cjs"),C=require("@tiptap/pm/state"),E=require("@tiptap/pm/view"),R=require("./index-C3dgmjIF.cjs"),I=require("react/jsx-runtime"),x=require("./index-ezTXvA7H.cjs");require("react");require("./theme.cjs");function U(n={}){return new h.Plugin({view(e){return new W(e,n)}})}class W{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let c=e.nodeBefore,p=e.nodeAfter;if(c||p){let m=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(m){let v=m.getBoundingClientRect(),A=c?v.bottom:v.top;c&&p&&(A=(A+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let M=this.width/2*l;r={left:v.left,right:v.right,top:A-M,bottom:A+M}}}}if(!r){let c=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:c.left-p,right:c.left+p,top:c.top,bottom:c.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let d,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")d=-pageXOffset,u=-pageYOffset;else{let c=a.getBoundingClientRect(),p=c.width/a.offsetWidth,m=c.height/a.offsetHeight;d=c.left-a.scrollLeft*p,u=c.top-a.scrollTop*m}this.element.style.left=(r.left-d)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=h.dropPoint(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class f extends h.Selection{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return f.valid(r)?new f(r):h.Selection.near(r)}content(){return h.Slice.empty}eq(e){return e instanceof f&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new f(e.resolve(t.pos))}getBookmark(){return new z(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!q(e)||!X(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&f.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(f.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!h.NodeSelection.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(f.valid(l))return l}return null}}}f.prototype.visible=!1;f.findFrom=f.findGapCursorFrom;h.Selection.jsonID("gapcursor",f);class z{constructor(e){this.pos=e}map(e){return new z(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return f.valid(t)?new f(t):h.Selection.near(t)}}function B(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function q(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function X(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y(){return new h.Plugin({props:{decorations:$,createSelectionBetween(n,e,t){return e.pos==t.pos&&f.valid(t)?new f(t):null},handleClick:J,handleKeyDown:Z,handleDOMEvents:{beforeinput:Q}}})}const Z=R.keydownHandler({ArrowLeft:S("horiz",-1),ArrowRight:S("horiz",1),ArrowUp:S("vert",-1),ArrowDown:S("vert",1)});function S(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof h.TextSelection){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let d=f.findGapCursorFrom(l,e,a);return d?(i&&i(r.tr.setSelection(new f(d))),!0):!1}}function J(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!f.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&h.NodeSelection.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new f(r))),!0)}function Q(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof f))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=h.Fragment.empty;for(let s=r.length-1;s>=0;s--)i=h.Fragment.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new h.Slice(i,0,0));return o.setSelection(h.TextSelection.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function $(n){if(!(n.selection instanceof f))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",R.DecorationSet.create(n.doc,[R.Decoration.widget(n.selection.head,e,{key:"gapcursor"})])}var O=200,g=function(){};g.prototype.append=function(e){return e.length?(e=g.from(e),!this.length&&e||e.length<O&&this.leafAppend(e)||this.length<O&&e.leafPrepend(this)||this.appendInner(e)):this};g.prototype.prepend=function(e){return e.length?g.from(e).append(this):this};g.prototype.appendInner=function(e){return new ee(this,e)};g.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?g.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};g.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};g.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};g.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};g.from=function(e){return e instanceof g?e:e&&e.length?new j(e):g.empty};var j=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=O)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=O)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(g);g.empty=new j([]);var ee=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(r,i):r>=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(g);const te=500;class w{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,d=[],u=[];return this.items.forEach((c,p)=>{if(!c.step){i||(i=this.remapping(r,p+1),o=i.maps.length),o--,u.push(c);return}if(i){u.push(new y(c.map));let m=c.step.map(i.slice(o)),v;m&&s.maybeStep(m).doc&&(v=s.mapping.maps[s.mapping.maps.length-1],d.push(new y(v,void 0,void 0,d.length+u.length))),o--,v&&i.appendMap(v,o)}else s.maybeStep(c.step);if(c.selection)return l=i?c.selection.map(i.slice(o)):c.selection,a=new w(this.items.slice(0,r).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let c=e.steps[u].invert(e.docs[u]),p=new y(e.mapping.maps[u],c,t),m;(m=a&&a.merge(p))&&(p=m,u?o.pop():l=l.slice(0,l.length-1)),o.push(p),t&&(s++,t=void 0),i||(a=p)}let d=s-r.depth;return d>ie&&(l=ne(l,d),s-=d),new w(l.append(o),s)}remapping(e,t){let r=new h.Mapping;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new w(this.items.append(e.map(t=>new y(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=t;this.items.forEach(p=>{let m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let v=o.maps[m];if(p.step){let A=e.steps[m].invert(e.docs[m]),M=p.selection&&p.selection.map(o.slice(a+1,m));M&&l++,r.push(new y(v,A,M))}else r.push(new y(v))},i);let d=[];for(let p=t;p<s;p++)d.push(new y(o.maps[p]));let u=this.items.slice(0,i).append(d).append(r),c=new w(u,l);return c.emptyItemCount()>te&&(c=c.compress(this.items.length-r.length)),c}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),d=a&&a.getMap();if(r--,d&&t.appendMap(d,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&o++;let c=new y(d.invert(),a,u),p,m=i.length-1;(p=i.length&&i[m].merge(c))?i[m]=p:i.push(c)}}else s.map&&r--},this.items.length,0),new w(g.from(i.reverse()),o)}}w.empty=new w(g.empty,0);function ne(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class y{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new y(t.getMap().invert(),t,this.selection)}}}class P{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}}const ie=20;function re(n,e,t,r){let i=t.getMeta(b),o;if(i)return i.historyState;t.getMeta(le)&&(n=new P(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(b))return s.getMeta(b).redo?new P(n.done.addTransform(t,void 0,r,T(e)),n.undone,F(t.mapping.maps),n.prevTime,n.prevComposition):new P(n.done,n.undone.addTransform(t,void 0,r,T(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!oe(t,n.prevRanges)),d=s?D(n.prevRanges,t.mapping):F(t.mapping.maps);return new P(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,T(e)),w.empty,d,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new P(n.done.rebased(t,o),n.undone.rebased(t,o),D(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new P(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),D(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function oe(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function F(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function D(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),o=e.map(n[r+1],-1);i<=o&&t.push(i,o)}return t}function se(n,e,t){let r=T(e),i=b.get(e).spec.config,o=(t?n.undone:n.done).popEvent(e,r);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?n.done:n.undone).addTransform(o.transform,e.selection.getBookmark(),i,r),a=new P(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(b,{redo:t,historyState:a})}let k=!1,L=null;function T(n){let e=n.plugins;if(L!=e){k=!1,L=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){k=!0;break}}return k}const b=new h.PluginKey("history"),le=new h.PluginKey("closeHistory");function ae(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new h.Plugin({key:b,state:{init(){return new P(w.empty,w.empty,null,0,-1)},apply(e,t,r){return re(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?H:r=="historyRedo"?G:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function _(n,e){return(t,r)=>{let i=b.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=se(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}const H=_(!1,!0),G=_(!0,!0);h.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:n=>n.length,wordCounter:n=>n.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc;if(((n==null?void 0:n.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=n=>{const e=(n==null?void 0:n.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let n=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,r)=>{if(n)return;const i=this.options.limit;if(i==null||i===0){n=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const s=o-i,l=0,a=s;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const d=r.tr.deleteRange(l,a);return n=!0,d}n=!0},filterTransaction:(e,t)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:t.doc}),o=this.storage.characters({node:e.doc});if(o<=r||i>r&&o>r&&o<=i)return!0;if(i>r&&o>r&&o>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,d=l-a,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>r)}})]}});h.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[U(this.options)]}});h.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:n,selection:e})=>{const{isEditable:t,isFocused:r}=this.editor,{anchor:i}=e,o=[];if(!t||!r)return E.DecorationSet.create(n,[]);let s=0;this.options.mode==="deepest"&&n.descendants((a,d)=>{if(a.isText)return;if(!(i>=d&&i<=d+a.nodeSize-1))return!1;s+=1});let l=0;return n.descendants((a,d)=>{if(a.isText||!(i>=d&&i<=d+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(E.Decoration.node(d,d+a.nodeSize,{class:this.options.className}))}),E.DecorationSet.create(n,o)}}})]}});h.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Y()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=h.callOrReturn(h.getExtensionField(n,"allowGapCursor",t)))!=null?e:null}}});var V="placeholder";function de(n){return n.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}h.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:V,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const n=this.options.dataAttribute?`data-${de(this.options.dataAttribute)}`:`data-${V}`;return[new C.Plugin({key:new C.PluginKey("placeholder"),props:{decorations:({doc:e,selection:t})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=t,o=[];if(!r)return null;const s=this.editor.isEmpty;return e.descendants((l,a)=>{const d=i>=a&&i<=a+l.nodeSize,u=!l.isLeaf&&h.isNodeEmpty(l);if(!l.type.isTextblock)return this.options.includeChildren;if((d||!this.options.showOnlyCurrent)&&u){const c=[this.options.emptyNodeClass];s&&c.push(this.options.emptyEditorClass);const p=E.Decoration.node(a,a+l.nodeSize,{class:c.join(" "),[n]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:a,hasAnchor:d}):this.options.placeholder});o.push(p)}return this.options.includeChildren}),E.DecorationSet.create(e,o)}}})]}});h.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:n,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||n.isFocused||!n.isEditable||h.isNodeSelection(t.selection)||n.view.dragging?null:E.DecorationSet.create(t.doc,[E.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function K({types:n,node:e}){return e&&Array.isArray(n)&&n.includes(e.type)||(e==null?void 0:e.type)===n}h.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var n;const e=new C.PluginKey(this.name),t=this.options.node||((n=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:n.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new C.Plugin({key:e,appendTransaction:(i,o,s)=>{const{doc:l,tr:a,schema:d}=s,u=e.getState(s),c=l.content.size,p=d.nodes[t];if(u)return a.insert(c,p.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!K({node:s,types:r})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!K({node:s,types:r})}}})]}});var ce=h.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>H(n,e),redo:()=>({state:n,dispatch:e})=>G(n,e)}},addProseMirrorPlugins(){return[ae(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()}}});function ue(){var u;const n=x.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:r=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((u=n==null?void 0:n.componentProps)==null?void 0:u.undo)??{},{disabled:l}=x.useActive(s),a=x.icons[e],d=()=>{l||o&&o()};return!n||!a?I.jsx(I.Fragment,{}):I.jsx(x.ActionButton,{action:d,disabled:l,icon:e,shortcutKeys:r,tooltip:t,tooltipOptions:i})}function pe(){var d;const n=x.useButtonProps(N.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:r=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((d=n==null?void 0:n.componentProps)==null?void 0:d.redo)??{},{disabled:l}=x.useActive(s),a=()=>{l||o&&o()};return n?I.jsx(x.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:r,tooltip:t,tooltipOptions:i}):I.jsx(I.Fragment,{})}const N=ce.extend({addOptions(){var n;return{...(n=this.parent)==null?void 0:n.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:r})=>{var i,o;return{componentProps:{undo:{action:()=>{e.chain().focus().undo().run()},shortcutKeys:((i=r.options.shortcutKeys)==null?void 0:i[0])??["mod","Z"],isActive:()=>e.can().undo(),icon:"Undo2",tooltip:t("editor.undo.tooltip")},redo:{action:()=>{e.chain().focus().redo().run()},shortcutKeys:((o=r.options.shortcutKeys)==null?void 0:o[1])??["shift","mod","Z"],isActive:()=>e.can().redo(),icon:"Redo2",tooltip:t("editor.redo.tooltip")}}}}}}});exports.History=N;exports.RichTextRedo=pe;exports.RichTextUndo=ue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-Bcj8cyOO.cjs"),C=require("@tiptap/pm/state"),S=require("@tiptap/pm/view"),z=require("./index-CUvjYuRp.cjs"),T=require("react/jsx-runtime"),x=require("./index-Gi752TMk.cjs");require("react");require("./theme.cjs");function X(o={}){return new h.Plugin({view(e){return new q(e,o)}})}class q{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let r=s=>{this[i](s)};return e.dom.addEventListener(i,r),{name:i,handler:r}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,i=this.editorView.dom,r=i.getBoundingClientRect(),s=r.width/i.offsetWidth,l=r.height/i.offsetHeight;if(t){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let g=f.getBoundingClientRect(),P=d?g.bottom:g.top;d&&p&&(P=(P+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let E=this.width/2*l;n={left:g.left,right:g.right,top:P-E,bottom:P+E}}}}if(!n){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;n={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*f}this.element.style.left=(n.left-c)/s+"px",this.element.style.top=(n.top-u)/l+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,r=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!r){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=h.dropPoint(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class m extends h.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return m.valid(n)?new m(n):h.Selection.near(n)}content(){return h.Slice.empty}eq(e){return e instanceof m&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new m(e.resolve(t.pos))}getBookmark(){return new k(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Z(e)||!J(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&m.valid(e))return e;let i=e.pos,r=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){r=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(m.valid(a))return a}for(;;){let s=t>0?r.firstChild:r.lastChild;if(!s){if(r.isAtom&&!r.isText&&!h.NodeSelection.isSelectable(r)){e=e.doc.resolve(i+r.nodeSize*t),n=!1;continue e}break}r=s,i+=t;let l=e.doc.resolve(i);if(m.valid(l))return l}return null}}}m.prototype.visible=!1;m.findFrom=m.findGapCursorFrom;h.Selection.jsonID("gapcursor",m);class k{constructor(e){this.pos=e}map(e){return new k(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return m.valid(t)?new m(t):h.Selection.near(t)}}function H(o){return o.isAtom||o.spec.isolating||o.spec.createGapCursor}function Z(o){for(let e=o.depth;e>=0;e--){let t=o.index(e),n=o.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||H(i.type))return!0;if(i.inlineContent)return!1}}return!0}function J(o){for(let e=o.depth;e>=0;e--){let t=o.indexAfter(e),n=o.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||H(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Q(){return new h.Plugin({props:{decorations:ne,createSelectionBetween(o,e,t){return e.pos==t.pos&&m.valid(t)?new m(t):null},handleClick:ee,handleKeyDown:$,handleDOMEvents:{beforeinput:te}}})}const $=z.keydownHandler({ArrowLeft:I("horiz",-1),ArrowRight:I("horiz",1),ArrowUp:I("vert",-1),ArrowDown:I("vert",1)});function I(o,e){const t=o=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,r){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof h.TextSelection){if(!r.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=m.findGapCursorFrom(l,e,a);return c?(i&&i(n.tr.setSelection(new m(c))),!0):!1}}function ee(o,e,t){if(!o||!o.editable)return!1;let n=o.state.doc.resolve(e);if(!m.valid(n))return!1;let i=o.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&h.NodeSelection.isSelectable(o.state.doc.nodeAt(i.inside))?!1:(o.dispatch(o.state.tr.setSelection(new m(n))),!0)}function te(o,e){if(e.inputType!="insertCompositionText"||!(o.state.selection instanceof m))return!1;let{$from:t}=o.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(o.state.schema.nodes.text);if(!n)return!1;let i=h.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=h.Fragment.from(n[s].createAndFill(null,i));let r=o.state.tr.replace(t.pos,t.pos,new h.Slice(i,0,0));return r.setSelection(h.TextSelection.near(r.doc.resolve(t.pos+1))),o.dispatch(r),!1}function ne(o){if(!(o.selection instanceof m))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",z.DecorationSet.create(o.doc,[z.Decoration.widget(o.selection.head,e,{key:"gapcursor"})])}var R=200,v=function(){};v.prototype.append=function(e){return e.length?(e=v.from(e),!this.length&&e||e.length<R&&this.leafAppend(e)||this.length<R&&e.leafPrepend(this)||this.appendInner(e)):this};v.prototype.prepend=function(e){return e.length?v.from(e).append(this):this};v.prototype.appendInner=function(e){return new oe(this,e)};v.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?v.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};v.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};v.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};v.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(r,s){return i.push(e(r,s))},t,n),i};v.from=function(e){return e instanceof v?e:e&&e.length?new j(e):v.empty};var j=(function(o){function e(n){o.call(this),this.values=n}o&&(e.__proto__=o),e.prototype=Object.create(o&&o.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,r){return i==0&&r==this.length?this:new e(this.values.slice(i,r))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,r,s,l){for(var a=r;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,s,l){for(var a=r-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=R)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=R)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(v);v.empty=new j([]);var oe=(function(o){function e(t,n){o.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return o&&(e.__proto__=o),e.prototype=Object.create(o&&o.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,r,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(r,l),s)===!1||r>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,r)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,r,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(r,l)-l,s+l)===!1||r<l&&this.left.forEachInvertedInner(n,Math.min(i,l),r,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var r=this.left.length;return i<=r?this.left.slice(n,i):n>=r?this.right.slice(n-r,i-r):this.left.slice(n,r).append(this.right.slice(0,i-r))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(v);const ie=500;class y{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,r;t&&(i=this.remapping(n,this.items.length),r=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){i||(i=this.remapping(n,p+1),r=i.maps.length),r--,u.push(d);return}if(i){u.push(new w(d.map));let f=d.step.map(i.slice(r)),g;f&&s.maybeStep(f).doc&&(g=s.mapping.maps[s.mapping.maps.length-1],c.push(new w(g,void 0,void 0,c.length+u.length))),r--,g&&i.appendMap(g,r)}else s.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(r)):d.selection,a=new y(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,i){let r=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new w(e.mapping.maps[u],d,t),f;(f=a&&a.merge(p))&&(p=f,u?r.pop():l=l.slice(0,l.length-1)),r.push(p),t&&(s++,t=void 0),i||(a=p)}let c=s-n.depth;return c>se&&(l=re(l,c),s-=c),new y(l.append(r),s)}remapping(e,t){let n=new h.Mapping;return this.items.forEach((i,r)=>{let s=i.mirrorOffset!=null&&r-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new y(this.items.append(e.map(t=>new w(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),r=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},i);let a=t;this.items.forEach(p=>{let f=r.getMirror(--a);if(f==null)return;s=Math.min(s,f);let g=r.maps[f];if(p.step){let P=e.steps[f].invert(e.docs[f]),E=p.selection&&p.selection.map(r.slice(a+1,f));E&&l++,n.push(new w(g,P,E))}else n.push(new w(g))},i);let c=[];for(let p=t;p<s;p++)c.push(new w(r.maps[p]));let u=this.items.slice(0,i).append(c).append(n),d=new y(u,l);return d.emptyItemCount()>ie&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],r=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&r++;else if(s.step){let a=s.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let u=s.selection&&s.selection.map(t.slice(n));u&&r++;let d=new w(c.invert(),a,u),p,f=i.length-1;(p=i.length&&i[f].merge(d))?i[f]=p:i.push(d)}}else s.map&&n--},this.items.length,0),new y(v.from(i.reverse()),r)}}y.empty=new y(v.empty,0);function re(o,e){let t;return o.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),o.slice(t)}class w{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new w(t.getMap().invert(),t,this.selection)}}}class b{constructor(e,t,n,i,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=r}}const se=20;function le(o,e,t,n){let i=t.getMeta(M),r;if(i)return i.historyState;t.getMeta(de)&&(o=new b(o.done,o.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return o;if(s&&s.getMeta(M))return s.getMeta(M).redo?new b(o.done.addTransform(t,void 0,n,O(e)),o.undone,B(t.mapping.maps),o.prevTime,o.prevComposition):new b(o.done,o.undone.addTransform(t,void 0,n,O(e)),null,o.prevTime,o.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=o.prevTime==0||!s&&o.prevComposition!=l&&(o.prevTime<(t.time||0)-n.newGroupDelay||!ae(t,o.prevRanges)),c=s?D(o.prevRanges,t.mapping):B(t.mapping.maps);return new b(o.done.addTransform(t,a?e.selection.getBookmark():void 0,n,O(e)),y.empty,c,t.time,l??o.prevComposition)}else return(r=t.getMeta("rebased"))?new b(o.done.rebased(t,r),o.undone.rebased(t,r),D(o.prevRanges,t.mapping),o.prevTime,o.prevComposition):new b(o.done.addMaps(t.mapping.maps),o.undone.addMaps(t.mapping.maps),D(o.prevRanges,t.mapping),o.prevTime,o.prevComposition)}function ae(o,e){if(!e)return!1;if(!o.docChanged)return!0;let t=!1;return o.mapping.maps[0].forEach((n,i)=>{for(let r=0;r<e.length;r+=2)n<=e[r+1]&&i>=e[r]&&(t=!0)}),t}function B(o){let e=[];for(let t=o.length-1;t>=0&&e.length==0;t--)o[t].forEach((n,i,r,s)=>e.push(r,s));return e}function D(o,e){if(!o)return null;let t=[];for(let n=0;n<o.length;n+=2){let i=e.map(o[n],1),r=e.map(o[n+1],-1);i<=r&&t.push(i,r)}return t}function ce(o,e,t){let n=O(e),i=M.get(e).spec.config,r=(t?o.undone:o.done).popEvent(e,n);if(!r)return null;let s=r.selection.resolve(r.transform.doc),l=(t?o.done:o.undone).addTransform(r.transform,e.selection.getBookmark(),i,n),a=new b(t?l:r.remaining,t?r.remaining:l,null,0,-1);return r.transform.setSelection(s).setMeta(M,{redo:t,historyState:a})}let N=!1,F=null;function O(o){let e=o.plugins;if(F!=e){N=!1,F=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){N=!0;break}}return N}const M=new h.PluginKey("history"),de=new h.PluginKey("closeHistory");function ue(o={}){return o={depth:o.depth||100,newGroupDelay:o.newGroupDelay||500},new h.Plugin({key:M,state:{init(){return new b(y.empty,y.empty,null,0,-1)},apply(e,t,n){return le(t,n,e,o)}},config:o,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?U:n=="historyRedo"?W:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function G(o,e){return(t,n)=>{let i=M.getState(t);if(!i||(o?i.undone:i.done).eventCount==0)return!1;if(n){let r=ce(i,t,o);r&&n(e?r.scrollIntoView():r)}return!0}}const U=G(!1,!0),W=G(!0,!0);h.Extension.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:o=>o.length,wordCounter:o=>o.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=o=>{const e=(o==null?void 0:o.node)||this.editor.state.doc;if(((o==null?void 0:o.mode)||this.options.mode)==="textSize"){const n=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(n)}return e.nodeSize},this.storage.words=o=>{const e=(o==null?void 0:o.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let o=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,n)=>{if(o)return;const i=this.options.limit,r=this.options.autoTrim;if(i==null||i===0||r===!1){o=!0;return}const s=this.storage.characters({node:n.doc});if(s>i){const l=s-i,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const u=n.tr.deleteRange(a,c);return o=!0,u}o=!0},filterTransaction:(e,t)=>{const n=this.options.limit;if(!e.docChanged||n===0||n===null||n===void 0)return!0;const i=this.storage.characters({node:t.doc}),r=this.storage.characters({node:e.doc});if(r<=n||i>n&&r>n&&r<=i)return!0;if(i>n&&r>n&&r>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=r-n,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>n)}})]}});h.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[X(this.options)]}});h.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:o,selection:e})=>{const{isEditable:t,isFocused:n}=this.editor,{anchor:i}=e,r=[];if(!t||!n)return S.DecorationSet.create(o,[]);let s=0;this.options.mode==="deepest"&&o.descendants((a,c)=>{if(a.isText)return;if(!(i>=c&&i<=c+a.nodeSize-1))return!1;s+=1});let l=0;return o.descendants((a,c)=>{if(a.isText||!(i>=c&&i<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&s-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";r.push(S.Decoration.node(c,c+a.nodeSize,{class:this.options.className}))}),S.DecorationSet.create(o,r)}}})]}});h.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Q()]},extendNodeSchema(o){var e;const t={name:o.name,options:o.options,storage:o.storage};return{allowGapCursor:(e=h.callOrReturn(h.getExtensionField(o,"allowGapCursor",t)))!=null?e:null}}});function _(o){const{editor:e,placeholder:t,dataAttribute:n,pos:i,node:r,isEmptyDoc:s,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=o,u=[a];return s&&u.push(c),S.Decoration.node(i,i+r.nodeSize,{class:u.join(" "),[n]:typeof t=="function"?t({editor:e,node:r,pos:i,hasAnchor:l}):t})}function pe(o){const e=getComputedStyle(o),t=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(t)}function he(o){let e=o;for(;e;){if(pe(e))return e;const t=e.parentElement;if(!t){const n=e.getRootNode();if(n instanceof ShadowRoot){e=n.host;continue}return window}e=t}return window}function fe(o){return o===window?{top:0,bottom:window.innerHeight}:o.getBoundingClientRect()}function me({doc:o,view:e,scrollContainer:t}){const n=e.dom.getBoundingClientRect(),i=t?fe(t):{top:0,bottom:window.innerHeight},r=Math.max(n.top,i.top),s=Math.min(n.bottom,i.bottom);if(r>=s)return{top:0,bottom:o.content.size};const a=getComputedStyle(e.dom).direction==="rtl"?Math.max(n.right-2,n.left+2):n.left+2,c=e.posAtCoords({left:a,top:r+2}),u=e.posAtCoords({left:a,top:s-2});return{top:c?c.pos:0,bottom:u?u.pos:o.content.size}}function ge(o,e){let t=null;return{call:((...r)=>{t||(o(...r),t=setTimeout(()=>{t=null},e))}),cancel:()=>{t&&(clearTimeout(t),t=null)}}}var V="placeholder";function ve(o){return o.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var A=new C.PluginKey("tiptap__placeholder");h.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:V,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const o=this.options.dataAttribute?`data-${ve(this.options.dataAttribute)}`:`data-${V}`;return[new C.Plugin({state:{init(){return{topPos:null,bottomPos:null}},apply(e,t){const n=e.getMeta(A);return n!=null&&n.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:e.docChanged?{topPos:t.topPos!==null?e.mapping.map(t.topPos):null,bottomPos:t.bottomPos!==null?e.mapping.map(t.bottomPos):null}:t}},key:A,view(e){const t=he(e.dom),n=()=>{const l=me({view:e,doc:e.state.doc,scrollContainer:t}),a=A.getState(e.state);if(a.topPos===l.top&&a.bottomPos===l.bottom)return;const c=e.state.tr.setMeta(A,{positions:l}).setMeta("tiptap__viewportUpdate",!0);e.dispatch(c)},{call:i,cancel:r}=ge(n,250),s=t;return s.addEventListener("scroll",i,{passive:!0}),n(),{update(l,a){e.state.doc.content.size!==a.doc.content.size&&n()},destroy:()=>{r(),s.removeEventListener("scroll",i)}}},props:{decorations:({doc:e,selection:t})=>{var n,i;if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:s}=t,l=[],a=this.editor.isEmpty;if(this.options.showOnlyCurrent&&!this.options.includeChildren){const u=e.resolve(s);if(u.depth>0){const d=u.node(1),p=u.before(1);if(d.type.isTextblock&&h.isNodeEmpty(d)){const f=s>=p&&s<=p+d.nodeSize,g=_({node:d,dataAttribute:o,hasAnchor:f,placeholder:this.options.placeholder,classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,pos:u.before(1)});l.push(g)}}}else{const u=A.getState(this.editor.state),d=(n=u.topPos)!=null?n:0,p=(i=u.bottomPos)!=null?i:e.content.size;e.nodesBetween(d,p,(f,g)=>{const P=s>=g&&s<=g+f.nodeSize,E=!f.isLeaf&&h.isNodeEmpty(f);if(!f.type.isTextblock)return this.options.includeChildren;if((P||!this.options.showOnlyCurrent)&&E){const Y=_({classes:{emptyEditor:this.options.emptyEditorClass,emptyNode:this.options.emptyNodeClass},editor:this.editor,isEmptyDoc:a,dataAttribute:o,hasAnchor:P,placeholder:this.options.placeholder,node:f,pos:g});l.push(Y)}return this.options.includeChildren})}return S.DecorationSet.create(e,l)}}})]}});h.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:o,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||o.isFocused||!o.isEditable||h.isNodeSelection(t.selection)||o.view.dragging?null:S.DecorationSet.create(t.doc,[S.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});var ye="skipTrailingNode";function K({types:o,node:e}){return e&&Array.isArray(o)&&o.includes(e.type)||(e==null?void 0:e.type)===o}h.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var o;const e=new C.PluginKey(this.name),t=this.options.node||((o=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:o.name)||"paragraph",n=Object.entries(this.editor.schema.nodes).map(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(t).includes(i.name));return[new C.Plugin({key:e,appendTransaction:(i,r,s)=>{const{doc:l,tr:a,schema:c}=s,u=e.getState(s),d=l.content.size,p=c.nodes[t];if(!i.some(f=>f.getMeta(ye))&&u)return a.insert(d,p.create())},state:{init:(i,r)=>{const s=r.tr.doc.lastChild;return!K({node:s,types:n})},apply:(i,r)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return r;const s=i.doc.lastChild;return!K({node:s,types:n})}}})]}});var we=h.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:o,dispatch:e})=>U(o,e),redo:()=>({state:o,dispatch:e})=>W(o,e)}},addProseMirrorPlugins(){return[ue(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()}}});function Ce(){var u;const o=x.useButtonProps(L.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:r=void 0,isActive:s=void 0}=((u=o==null?void 0:o.componentProps)==null?void 0:u.undo)??{},{disabled:l}=x.useActive(s),a=x.icons[e],c=()=>{l||r&&r()};return!o||!a?T.jsx(T.Fragment,{}):T.jsx(x.ActionButton,{action:c,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i})}function Pe(){var c;const o=x.useButtonProps(L.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:r=void 0,isActive:s=void 0}=((c=o==null?void 0:o.componentProps)==null?void 0:c.redo)??{},{disabled:l}=x.useActive(s),a=()=>{l||r&&r()};return o?T.jsx(x.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i}):T.jsx(T.Fragment,{})}const L=we.extend({addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:n})=>{var i,r;return{componentProps:{undo:{action:()=>{e.chain().focus().undo().run()},shortcutKeys:((i=n.options.shortcutKeys)==null?void 0:i[0])??["mod","Z"],isActive:()=>e.can().undo(),icon:"Undo2",tooltip:t("editor.undo.tooltip")},redo:{action:()=>{e.chain().focus().redo().run()},shortcutKeys:((r=n.options.shortcutKeys)==null?void 0:r[1])??["shift","mod","Z"],isActive:()=>e.can().redo(),icon:"Redo2",tooltip:t("editor.redo.tooltip")}}}}}}});exports.History=L;exports.RichTextRedo=Pe;exports.RichTextUndo=Ce;