reactjs-tiptap-editor 1.0.9 → 1.0.10

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 (159) hide show
  1. package/lib/{ActionMenuButton-CmDopTWt.cjs → ActionMenuButton-BPdRqzDX.cjs} +1 -1
  2. package/lib/{ActionMenuButton-C4aNFFa8.js → ActionMenuButton-CKTxYtl7.js} +2 -2
  3. package/lib/Attachment.cjs +1 -1
  4. package/lib/Attachment.js +7 -7
  5. package/lib/Blockquote.cjs +1 -1
  6. package/lib/Blockquote.js +3 -3
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +6 -6
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +3 -3
  11. package/lib/Clear.cjs +1 -1
  12. package/lib/Clear.js +3 -3
  13. package/lib/Code.cjs +1 -1
  14. package/lib/Code.js +6 -6
  15. package/lib/CodeBlock.cjs +39 -39
  16. package/lib/CodeBlock.js +837 -945
  17. package/lib/CodeView.cjs +1 -1
  18. package/lib/CodeView.js +3 -3
  19. package/lib/Color.cjs +1 -1
  20. package/lib/Color.js +5 -5
  21. package/lib/Column.cjs +1 -1
  22. package/lib/Column.js +8 -8
  23. package/lib/{Drawer-DG0gPU_U.js → Drawer-Cfx115up.js} +14 -14
  24. package/lib/{Drawer-CTr2snNd.cjs → Drawer-hHj4Opkg.cjs} +1 -1
  25. package/lib/Drawer.cjs +1 -1
  26. package/lib/Drawer.js +3 -3
  27. package/lib/Emoji.cjs +1 -1
  28. package/lib/Emoji.js +16 -15
  29. package/lib/{Excalidraw-DtezFdjR.cjs → Excalidraw-8pWJ17Ye.cjs} +1 -1
  30. package/lib/{Excalidraw-DpgdxOsc.js → Excalidraw-CO93Tsmb.js} +19 -19
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +2 -2
  33. package/lib/ExportPdf.cjs +1 -1
  34. package/lib/ExportPdf.js +3 -3
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +3 -3
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +5 -5
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +5 -5
  41. package/lib/Heading.cjs +1 -1
  42. package/lib/Heading.js +13 -13
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +5 -5
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +4 -4
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +3 -3
  49. package/lib/{Icon-C_buGjWy.js → Icon-D7GJZzoa.js} +1 -1
  50. package/lib/{Icon-b6HQAURz.cjs → Icon-gtc3g-VK.cjs} +1 -1
  51. package/lib/{Iframe-CUrXCDxj.cjs → Iframe-BmXO2c65.cjs} +1 -1
  52. package/lib/{Iframe-De88TYvj.js → Iframe-DwhclppJ.js} +13 -13
  53. package/lib/Iframe.cjs +1 -1
  54. package/lib/Iframe.js +2 -2
  55. package/lib/Image.cjs +1 -1
  56. package/lib/Image.js +46 -46
  57. package/lib/ImageGif.cjs +1 -1
  58. package/lib/ImageGif.js +16 -16
  59. package/lib/ImportWord.cjs +2 -2
  60. package/lib/ImportWord.js +8 -8
  61. package/lib/{Indent-Bensb2nf.js → Indent-BOsymiZ7.js} +5 -5
  62. package/lib/{Indent-D_KtZNHW.cjs → Indent-DPkMWfcv.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 +3 -3
  67. package/lib/{Katex-NqelWRoi.cjs → Katex-B1XbT8-X.cjs} +2 -2
  68. package/lib/{Katex-C0dtqznb.js → Katex-BYK-b9X2.js} +23 -23
  69. package/lib/Katex.cjs +1 -1
  70. package/lib/Katex.js +2 -2
  71. package/lib/LineHeight.cjs +1 -1
  72. package/lib/LineHeight.js +12 -12
  73. package/lib/Link.cjs +1 -1
  74. package/lib/Link.js +2 -2
  75. package/lib/{LinkEditBlock-BSZ-vgNB.cjs → LinkEditBlock-4-iRXH7m.cjs} +2 -2
  76. package/lib/{LinkEditBlock-Bv12sKvW.js → LinkEditBlock-DgrLUMsJ.js} +52 -52
  77. package/lib/Mention.cjs +1 -1
  78. package/lib/Mention.js +23 -22
  79. package/lib/Mermaid.cjs +2 -2
  80. package/lib/Mermaid.js +38 -38
  81. package/lib/MoreMark.cjs +1 -1
  82. package/lib/MoreMark.js +11 -11
  83. package/lib/OrderedList.cjs +1 -1
  84. package/lib/OrderedList.js +3 -3
  85. package/lib/SearchAndReplace.cjs +1 -1
  86. package/lib/SearchAndReplace.js +16 -16
  87. package/lib/SlashCommand.cjs +1 -1
  88. package/lib/SlashCommand.js +39 -266
  89. package/lib/SlashCommandNodeView-BpNNU7Sm.js +254 -0
  90. package/lib/SlashCommandNodeView-CQvMTXys.cjs +1 -0
  91. package/lib/Strike.cjs +1 -1
  92. package/lib/Strike.js +3 -3
  93. package/lib/{Table-D9ckv6Tb.js → Table-CT9R9Sdq.js} +5 -5
  94. package/lib/{Table-cy1mUM2X.cjs → Table-LnWGm2m8.cjs} +1 -1
  95. package/lib/Table.cjs +1 -1
  96. package/lib/Table.js +1 -1
  97. package/lib/TaskList.cjs +1 -1
  98. package/lib/TaskList.js +3 -3
  99. package/lib/TextAlign.cjs +1 -1
  100. package/lib/TextAlign.js +10 -10
  101. package/lib/TextDirection.cjs +1 -1
  102. package/lib/TextDirection.js +10 -10
  103. package/lib/TextUnderline.cjs +1 -1
  104. package/lib/TextUnderline.js +3 -3
  105. package/lib/{Twitter-Bvs3sW8F.cjs → Twitter-Bo4JkBTL.cjs} +1 -1
  106. package/lib/{Twitter-KUvyySA0.js → Twitter-mowilxRd.js} +55 -55
  107. package/lib/Twitter.cjs +1 -1
  108. package/lib/Twitter.js +2 -2
  109. package/lib/Video.cjs +1 -1
  110. package/lib/Video.js +22 -22
  111. package/lib/bubble.cjs +4 -4
  112. package/lib/bubble.js +1604 -1506
  113. package/lib/{button-D8SI-g7p.js → button-CBO-WDXK.js} +1 -1
  114. package/lib/{button-U6XpZt2X.cjs → button-wt49IYwP.cjs} +1 -1
  115. package/lib/{checkbox-xrY2c5yo.js → checkbox-D1h32VWM.js} +1 -1
  116. package/lib/{checkbox-DaIBNthL.cjs → checkbox-DUcLSGZD.cjs} +1 -1
  117. package/lib/{dialog-DjnkASYP.js → dialog-DSvgtlDI.js} +1 -1
  118. package/lib/{dialog-DgnnVCfv.cjs → dialog-DY868Uji.cjs} +1 -1
  119. package/lib/{dropdown-menu-bI14Gyw4.js → dropdown-menu-B88Qn2KR.js} +3 -2
  120. package/lib/dropdown-menu-BripAeGB.cjs +1 -0
  121. package/lib/extensions/SlashCommand/types.d.ts +1 -0
  122. package/lib/index-9A6-kVBM.js +1351 -0
  123. package/lib/{index-4pRt5Vqu.js → index-BIqaogQg.js} +775 -662
  124. package/lib/index-BvIJKpX1.cjs +8 -0
  125. package/lib/index-Cv9Z6dyV.cjs +1 -0
  126. package/lib/{index-EKFybgpP.js → index-DKt5wfAc.js} +1 -1
  127. package/lib/{index-BimeTI7q.js → index-DRHrDScg.js} +1 -1
  128. package/lib/{index-BQ6ZdLsu.js → index-DmPwbBqm.js} +1 -1
  129. package/lib/{index-CbIQPoF6.js → index-sVScpCFG.js} +20 -20
  130. package/lib/index.cjs +1 -1
  131. package/lib/index.js +5 -5
  132. package/lib/{input-BtDj0NeF.cjs → input-BeD5GdMv.cjs} +1 -1
  133. package/lib/{input-C5zU49Q1.js → input-Bx4uo4gO.js} +1 -1
  134. package/lib/{isNumber-8HKEgTkA.js → isNumber-DF0fU3ob.js} +1 -1
  135. package/lib/{label-C8BonzOY.cjs → label--161UPH6.cjs} +1 -1
  136. package/lib/{label-BEUVs-IA.js → label-uKG7RzFU.js} +1 -1
  137. package/lib/{popover-CPY5lMCj.js → popover-BVX8otO9.js} +1 -1
  138. package/lib/{popover-DjL0De8d.cjs → popover-Csk538NC.cjs} +1 -1
  139. package/lib/{separator-BzMkiI_c.cjs → separator-DLRVddHS.cjs} +1 -1
  140. package/lib/{separator-BlIlS7LP.js → separator-DtrEdjAF.js} +18 -18
  141. package/lib/{store-BSCjQxMK.cjs → store-B8IkVz1J.cjs} +1 -1
  142. package/lib/{store-D_GvIPxo.js → store-CsIFDUKR.js} +1 -1
  143. package/lib/style.css +1 -1
  144. package/lib/{tabs-tQpXIzfV.js → tabs-BKpr0QQB.js} +1 -1
  145. package/lib/{tabs-CHy82_rs.cjs → tabs-DOasUMDU.cjs} +1 -1
  146. package/lib/{textarea-CMDYVXYo.js → textarea-Ba9OOzba.js} +1 -1
  147. package/lib/{textarea-B-qfanCT.cjs → textarea-D9egO4qC.cjs} +1 -1
  148. package/lib/{throttle-BIkZV3Y_.js → throttle-DsowOft0.js} +1 -1
  149. package/lib/updatePosition-Bbd8ETMv.js +16 -0
  150. package/lib/updatePosition-M2IyqkI1.cjs +1 -0
  151. package/lib/{useButtonProps-DTngjZge.js → useButtonProps-C_bqxmHi.js} +14 -14
  152. package/lib/{useButtonProps-BqBGuqoP.cjs → useButtonProps-DEtmDVPr.cjs} +1 -1
  153. package/package.json +1 -1
  154. package/lib/dropdown-menu-BvVMltdB.cjs +0 -1
  155. package/lib/floating-ui.dom-U1vPFQ5f.js +0 -1151
  156. package/lib/floating-ui.dom-VCrc58uF.cjs +0 -1
  157. package/lib/index-DvvMf6Wu.cjs +0 -7
  158. package/lib/updatePosition-GLTrgcib.js +0 -215
  159. package/lib/updatePosition-u2mTh3mG.cjs +0 -1
package/lib/History.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./index-BBNITgNi.cjs"),C=require("@tiptap/pm/state"),x=require("@tiptap/pm/view"),R=require("./index--nUS7Y66.cjs"),S=require("react/jsx-runtime"),z=require("./index-DvvMf6Wu.cjs");require("react");const A=require("./useButtonProps-BqBGuqoP.cjs");function W(r={}){return new p.Plugin({view(e){return new U(e,r)}})}class U{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 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,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let c=e.nodeBefore,h=e.nodeAfter;if(c||h){let m=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(m){let v=m.getBoundingClientRect(),M=c?v.bottom:v.top;c&&h&&(M=(M+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;n={left:v.left,right:v.right,top:M-b,bottom:M+b}}}}if(!n){let c=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;n={left:c.left-h,right:c.left+h,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(),h=c.width/a.offsetWidth,m=c.height/a.offsetHeight;d=c.left-a.scrollLeft*h,u=c.top-a.scrollTop*m}this.element.style.left=(n.left-d)/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,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=p.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 p.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return f.valid(n)?new f(n):p.Selection.near(n)}content(){return p.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 N(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!q(e)||!X(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&&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&&!p.NodeSelection.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!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;p.Selection.jsonID("gapcursor",f);class N{constructor(e){this.pos=e}map(e){return new N(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return f.valid(t)?new f(t):p.Selection.near(t)}}function B(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function q(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function X(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y(){return new p.Plugin({props:{decorations:$,createSelectionBetween(r,e,t){return e.pos==t.pos&&f.valid(t)?new f(t):null},handleClick:Z,handleKeyDown:J,handleDOMEvents:{beforeinput:Q}}})}const J=R.keydownHandler({ArrowLeft:I("horiz",-1),ArrowRight:I("horiz",1),ArrowUp:I("vert",-1),ArrowDown:I("vert",1)});function I(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof p.TextSelection){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let d=f.findGapCursorFrom(l,e,a);return d?(i&&i(n.tr.setSelection(new f(d))),!0):!1}}function Z(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!f.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&p.NodeSelection.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new f(n))),!0)}function Q(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof f))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=p.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=p.Fragment.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new p.Slice(i,0,0));return o.setSelection(p.TextSelection.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function $(r){if(!(r.selection instanceof f))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",R.DecorationSet.create(r.doc,[R.Decoration.widget(r.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,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)};g.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};g.from=function(e){return e instanceof g?e:e&&e.length?new j(e):g.empty};var j=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},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})(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 n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,l,a,d=[],u=[];return this.items.forEach((c,h)=>{if(!c.step){i||(i=this.remapping(n,h+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,n).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,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]),h=new y(e.mapping.maps[u],c,t),m;(m=a&&a.merge(h))&&(h=m,u?o.pop():l=l.slice(0,l.length-1)),o.push(h),t&&(s++,t=void 0),i||(a=h)}let d=s-n.depth;return d>ie&&(l=ne(l,d),s-=d),new w(l.append(o),s)}remapping(e,t){let n=new p.Mapping;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-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 w(this.items.append(e.map(t=>new y(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},i);let a=t;this.items.forEach(h=>{let m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let v=o.maps[m];if(h.step){let M=e.steps[m].invert(e.docs[m]),b=h.selection&&h.selection.map(o.slice(a+1,m));b&&l++,n.push(new y(v,M,b))}else n.push(new y(v))},i);let d=[];for(let h=t;h<s;h++)d.push(new y(o.maps[h]));let u=this.items.slice(0,i).append(d).append(n),c=new w(u,l);return c.emptyItemCount()>te&&(c=c.compress(this.items.length-n.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),n=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(n)),d=a&&a.getMap();if(n--,d&&t.appendMap(d,n),a){let u=s.selection&&s.selection.map(t.slice(n));u&&o++;let c=new y(d.invert(),a,u),h,m=i.length-1;(h=i.length&&i[m].merge(c))?i[m]=h:i.push(c)}}else s.map&&n--},this.items.length,0),new w(g.from(i.reverse()),o)}}w.empty=new w(g.empty,0);function ne(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class y{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 y(t.getMap().invert(),t,this.selection)}}}class P{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const ie=20;function re(r,e,t,n){let i=t.getMeta(E),o;if(i)return i.historyState;t.getMeta(le)&&(r=new P(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(E))return s.getMeta(E).redo?new P(r.done.addTransform(t,void 0,n,T(e)),r.undone,V(t.mapping.maps),r.prevTime,r.prevComposition):new P(r.done,r.undone.addTransform(t,void 0,n,T(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!s&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!oe(t,r.prevRanges)),d=s?D(r.prevRanges,t.mapping):V(t.mapping.maps);return new P(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,T(e)),w.empty,d,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new P(r.done.rebased(t,o),r.undone.rebased(t,o),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new P(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function oe(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function V(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function D(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function se(r,e,t){let n=T(e),i=E.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),a=new P(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(E,{redo:t,historyState:a})}let k=!1,K=null;function T(r){let e=r.plugins;if(K!=e){k=!1,K=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){k=!0;break}}return k}const E=new p.PluginKey("history"),le=new p.PluginKey("closeHistory");function ae(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new p.Plugin({key:E,state:{init(){return new P(w.empty,w.empty,null,0,-1)},apply(e,t,n){return re(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?G:n=="historyRedo"?_:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function H(r,e){return(t,n)=>{let i=E.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=se(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const G=H(!1,!0),_=H(!0,!0);p.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:r=>r.length,wordCounter:r=>r.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc;if(((r==null?void 0:r.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=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let r=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,n)=>{if(r)return;const i=this.options.limit;if(i==null||i===0){r=!0;return}const o=this.storage.characters({node:n.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=n.tr.deleteRange(l,a);return r=!0,d}r=!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}),o=this.storage.characters({node:e.doc});if(o<=n||i>n&&o>n&&o<=i)return!0;if(i>n&&o>n&&o>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-n,d=l-a,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>n)}})]}});p.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[W(this.options)]}});p.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:r,selection:e})=>{const{isEditable:t,isFocused:n}=this.editor,{anchor:i}=e,o=[];if(!t||!n)return x.DecorationSet.create(r,[]);let s=0;this.options.mode==="deepest"&&r.descendants((a,d)=>{if(a.isText)return;if(!(i>=d&&i<=d+a.nodeSize-1))return!1;s+=1});let l=0;return r.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(x.Decoration.node(d,d+a.nodeSize,{class:this.options.className}))}),x.DecorationSet.create(r,o)}}})]}});p.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Y()]},extendNodeSchema(r){var e;const t={name:r.name,options:r.options,storage:r.storage};return{allowGapCursor:(e=p.callOrReturn(p.getExtensionField(r,"allowGapCursor",t)))!=null?e:null}}});p.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("placeholder"),props:{decorations:({doc:r,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,i=[];if(!t)return null;const o=this.editor.isEmpty;return r.descendants((s,l)=>{const a=n>=l&&n<=l+s.nodeSize,d=!s.isLeaf&&p.isNodeEmpty(s);if((a||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const c=x.Decoration.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});i.push(c)}return this.options.includeChildren}),x.DecorationSet.create(r,i)}}})]}});p.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:r,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||r.isFocused||!r.isEditable||p.isNodeSelection(t.selection)||r.view.dragging?null:x.DecorationSet.create(t.doc,[x.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function L({types:r,node:e}){return e&&Array.isArray(r)&&r.includes(e.type)||(e==null?void 0:e.type)===r}p.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var r;const e=new C.PluginKey(this.name),t=this.options.node||((r=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:r.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,o,s)=>{const{doc:l,tr:a,schema:d}=s,u=e.getState(s),c=l.content.size,h=d.nodes[t];if(u)return a.insert(c,h.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!L({node:s,types:n})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!L({node:s,types:n})}}})]}});var de=p.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:r,dispatch:e})=>G(r,e),redo:()=>({state:r,dispatch:e})=>_(r,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 ce(){var u;const r=A.useButtonProps(F.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((u=r==null?void 0:r.componentProps)==null?void 0:u.undo)??{},{disabled:l}=A.useActive(s),a=z.icons[e],d=()=>{l||o&&o()};return!r||!a?S.jsx(S.Fragment,{}):S.jsx(z.ActionButton,{action:d,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i})}function ue(){var d;const r=A.useButtonProps(F.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((d=r==null?void 0:r.componentProps)==null?void 0:d.redo)??{},{disabled:l}=A.useActive(s),a=()=>{l||o&&o()};return r?S.jsx(z.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i}):S.jsx(S.Fragment,{})}const F=de.extend({addOptions(){var r;return{...(r=this.parent)==null?void 0:r.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:n})=>{var i,o;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:((o=n.options.shortcutKeys)==null?void 0:o[1])??["shift","mod","Z"],isActive:()=>e.can().redo(),icon:"Redo2",tooltip:t("editor.redo.tooltip")}}}}}}});exports.History=F;exports.RichTextRedo=ue;exports.RichTextUndo=ce;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./index-BBNITgNi.cjs"),C=require("@tiptap/pm/state"),x=require("@tiptap/pm/view"),R=require("./index--nUS7Y66.cjs"),S=require("react/jsx-runtime"),z=require("./index-BvIJKpX1.cjs");require("react");const A=require("./useButtonProps-DEtmDVPr.cjs");function W(r={}){return new p.Plugin({view(e){return new U(e,r)}})}class U{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 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,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let c=e.nodeBefore,h=e.nodeAfter;if(c||h){let m=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(m){let v=m.getBoundingClientRect(),M=c?v.bottom:v.top;c&&h&&(M=(M+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;n={left:v.left,right:v.right,top:M-b,bottom:M+b}}}}if(!n){let c=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*s;n={left:c.left-h,right:c.left+h,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(),h=c.width/a.offsetWidth,m=c.height/a.offsetHeight;d=c.left-a.scrollLeft*h,u=c.top-a.scrollTop*m}this.element.style.left=(n.left-d)/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,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=p.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 p.Selection{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return f.valid(n)?new f(n):p.Selection.near(n)}content(){return p.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 N(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!q(e)||!X(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&&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&&!p.NodeSelection.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!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;p.Selection.jsonID("gapcursor",f);class N{constructor(e){this.pos=e}map(e){return new N(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return f.valid(t)?new f(t):p.Selection.near(t)}}function B(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function q(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function X(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.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||B(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Y(){return new p.Plugin({props:{decorations:$,createSelectionBetween(r,e,t){return e.pos==t.pos&&f.valid(t)?new f(t):null},handleClick:Z,handleKeyDown:J,handleDOMEvents:{beforeinput:Q}}})}const J=R.keydownHandler({ArrowLeft:I("horiz",-1),ArrowRight:I("horiz",1),ArrowUp:I("vert",-1),ArrowDown:I("vert",1)});function I(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof p.TextSelection){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let d=f.findGapCursorFrom(l,e,a);return d?(i&&i(n.tr.setSelection(new f(d))),!0):!1}}function Z(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!f.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&p.NodeSelection.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new f(n))),!0)}function Q(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof f))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=p.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=p.Fragment.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new p.Slice(i,0,0));return o.setSelection(p.TextSelection.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function $(r){if(!(r.selection instanceof f))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",R.DecorationSet.create(r.doc,[R.Decoration.widget(r.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,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)};g.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};g.from=function(e){return e instanceof g?e:e&&e.length?new j(e):g.empty};var j=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.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,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},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})(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 n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,l,a,d=[],u=[];return this.items.forEach((c,h)=>{if(!c.step){i||(i=this.remapping(n,h+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,n).append(u.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,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]),h=new y(e.mapping.maps[u],c,t),m;(m=a&&a.merge(h))&&(h=m,u?o.pop():l=l.slice(0,l.length-1)),o.push(h),t&&(s++,t=void 0),i||(a=h)}let d=s-n.depth;return d>ie&&(l=ne(l,d),s-=d),new w(l.append(o),s)}remapping(e,t){let n=new p.Mapping;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-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 w(this.items.append(e.map(t=>new y(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},i);let a=t;this.items.forEach(h=>{let m=o.getMirror(--a);if(m==null)return;s=Math.min(s,m);let v=o.maps[m];if(h.step){let M=e.steps[m].invert(e.docs[m]),b=h.selection&&h.selection.map(o.slice(a+1,m));b&&l++,n.push(new y(v,M,b))}else n.push(new y(v))},i);let d=[];for(let h=t;h<s;h++)d.push(new y(o.maps[h]));let u=this.items.slice(0,i).append(d).append(n),c=new w(u,l);return c.emptyItemCount()>te&&(c=c.compress(this.items.length-n.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),n=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(n)),d=a&&a.getMap();if(n--,d&&t.appendMap(d,n),a){let u=s.selection&&s.selection.map(t.slice(n));u&&o++;let c=new y(d.invert(),a,u),h,m=i.length-1;(h=i.length&&i[m].merge(c))?i[m]=h:i.push(c)}}else s.map&&n--},this.items.length,0),new w(g.from(i.reverse()),o)}}w.empty=new w(g.empty,0);function ne(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class y{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 y(t.getMap().invert(),t,this.selection)}}}class P{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const ie=20;function re(r,e,t,n){let i=t.getMeta(E),o;if(i)return i.historyState;t.getMeta(le)&&(r=new P(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(E))return s.getMeta(E).redo?new P(r.done.addTransform(t,void 0,n,T(e)),r.undone,V(t.mapping.maps),r.prevTime,r.prevComposition):new P(r.done,r.undone.addTransform(t,void 0,n,T(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!s&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!oe(t,r.prevRanges)),d=s?D(r.prevRanges,t.mapping):V(t.mapping.maps);return new P(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,T(e)),w.empty,d,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new P(r.done.rebased(t,o),r.undone.rebased(t,o),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new P(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),D(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function oe(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function V(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function D(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function se(r,e,t){let n=T(e),i=E.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),a=new P(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(E,{redo:t,historyState:a})}let k=!1,K=null;function T(r){let e=r.plugins;if(K!=e){k=!1,K=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){k=!0;break}}return k}const E=new p.PluginKey("history"),le=new p.PluginKey("closeHistory");function ae(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new p.Plugin({key:E,state:{init(){return new P(w.empty,w.empty,null,0,-1)},apply(e,t,n){return re(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?G:n=="historyRedo"?_:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function H(r,e){return(t,n)=>{let i=E.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=se(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const G=H(!1,!0),_=H(!0,!0);p.Extension.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:r=>r.length,wordCounter:r=>r.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc;if(((r==null?void 0:r.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=r=>{const e=(r==null?void 0:r.node)||this.editor.state.doc,t=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(t)}},addProseMirrorPlugins(){let r=!1;return[new C.Plugin({key:new C.PluginKey("characterCount"),appendTransaction:(e,t,n)=>{if(r)return;const i=this.options.limit;if(i==null||i===0){r=!0;return}const o=this.storage.characters({node:n.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=n.tr.deleteRange(l,a);return r=!0,d}r=!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}),o=this.storage.characters({node:e.doc});if(o<=n||i>n&&o>n&&o<=i)return!0;if(i>n&&o>n&&o>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-n,d=l-a,u=l;return e.deleteRange(d,u),!(this.storage.characters({node:e.doc})>n)}})]}});p.Extension.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[W(this.options)]}});p.Extension.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("focus"),props:{decorations:({doc:r,selection:e})=>{const{isEditable:t,isFocused:n}=this.editor,{anchor:i}=e,o=[];if(!t||!n)return x.DecorationSet.create(r,[]);let s=0;this.options.mode==="deepest"&&r.descendants((a,d)=>{if(a.isText)return;if(!(i>=d&&i<=d+a.nodeSize-1))return!1;s+=1});let l=0;return r.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(x.Decoration.node(d,d+a.nodeSize,{class:this.options.className}))}),x.DecorationSet.create(r,o)}}})]}});p.Extension.create({name:"gapCursor",addProseMirrorPlugins(){return[Y()]},extendNodeSchema(r){var e;const t={name:r.name,options:r.options,storage:r.storage};return{allowGapCursor:(e=p.callOrReturn(p.getExtensionField(r,"allowGapCursor",t)))!=null?e:null}}});p.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new C.Plugin({key:new C.PluginKey("placeholder"),props:{decorations:({doc:r,selection:e})=>{const t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:n}=e,i=[];if(!t)return null;const o=this.editor.isEmpty;return r.descendants((s,l)=>{const a=n>=l&&n<=l+s.nodeSize,d=!s.isLeaf&&p.isNodeEmpty(s);if((a||!this.options.showOnlyCurrent)&&d){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const c=x.Decoration.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});i.push(c)}return this.options.includeChildren}),x.DecorationSet.create(r,i)}}})]}});p.Extension.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:r,options:e}=this;return[new C.Plugin({key:new C.PluginKey("selection"),props:{decorations(t){return t.selection.empty||r.isFocused||!r.isEditable||p.isNodeSelection(t.selection)||r.view.dragging?null:x.DecorationSet.create(t.doc,[x.Decoration.inline(t.selection.from,t.selection.to,{class:e.className})])}}})]}});function L({types:r,node:e}){return e&&Array.isArray(r)&&r.includes(e.type)||(e==null?void 0:e.type)===r}p.Extension.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var r;const e=new C.PluginKey(this.name),t=this.options.node||((r=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:r.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,o,s)=>{const{doc:l,tr:a,schema:d}=s,u=e.getState(s),c=l.content.size,h=d.nodes[t];if(u)return a.insert(c,h.create())},state:{init:(i,o)=>{const s=o.tr.doc.lastChild;return!L({node:s,types:n})},apply:(i,o)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return o;const s=i.doc.lastChild;return!L({node:s,types:n})}}})]}});var de=p.Extension.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:r,dispatch:e})=>G(r,e),redo:()=>({state:r,dispatch:e})=>_(r,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 ce(){var u;const r=A.useButtonProps(F.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((u=r==null?void 0:r.componentProps)==null?void 0:u.undo)??{},{disabled:l}=A.useActive(s),a=z.icons[e],d=()=>{l||o&&o()};return!r||!a?S.jsx(S.Fragment,{}):S.jsx(z.ActionButton,{action:d,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i})}function ue(){var d;const r=A.useButtonProps(F.name),{icon:e=void 0,tooltip:t=void 0,shortcutKeys:n=void 0,tooltipOptions:i={},action:o=void 0,isActive:s=void 0}=((d=r==null?void 0:r.componentProps)==null?void 0:d.redo)??{},{disabled:l}=A.useActive(s),a=()=>{l||o&&o()};return r?S.jsx(z.ActionButton,{action:a,disabled:l,icon:e,shortcutKeys:n,tooltip:t,tooltipOptions:i}):S.jsx(S.Fragment,{})}const F=de.extend({addOptions(){var r;return{...(r=this.parent)==null?void 0:r.call(this),depth:100,newGroupDelay:500,button:({editor:e,t,extension:n})=>{var i,o;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:((o=n.options.shortcutKeys)==null?void 0:o[1])??["shift","mod","Z"],isActive:()=>e.can().redo(),icon:"Redo2",tooltip:t("editor.redo.tooltip")}}}}}}});exports.History=F;exports.RichTextRedo=ue;exports.RichTextUndo=ce;
package/lib/History.js CHANGED
@@ -1,11 +1,11 @@
1
- import { Q as N, y as te, F as V, x as G, T as H, v as _, S as A, U as W, V as ne, E as C, W as re, X as ie, Y as oe, o as se } from "./index-CbIQPoF6.js";
1
+ import { Q as N, y as te, F as V, x as G, T as H, v as _, S as A, U as W, V as ne, E as C, W as re, X as ie, Y as oe, l as se } from "./index-sVScpCFG.js";
2
2
  import { Plugin as I, PluginKey as b } from "@tiptap/pm/state";
3
3
  import { DecorationSet as O, Decoration as R } from "@tiptap/pm/view";
4
- import { k as le, D as ae, a as de } from "./index-EKFybgpP.js";
4
+ import { k as le, D as ae, a as de } from "./index-DKt5wfAc.js";
5
5
  import { jsx as T, Fragment as j } from "react/jsx-runtime";
6
- import { A as U, i as ce } from "./index-4pRt5Vqu.js";
6
+ import { A as U, i as ce } from "./index-BIqaogQg.js";
7
7
  import "react";
8
- import { u as X, b as Y } from "./useButtonProps-DTngjZge.js";
8
+ import { u as X, b as Y } from "./useButtonProps-C_bqxmHi.js";
9
9
  function ue(i = {}) {
10
10
  return new N({
11
11
  view(e) {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-BBNITgNi.cjs"),l=require("@tiptap/pm/state"),f=require("./index-DvvMf6Wu.cjs"),h=require("react/jsx-runtime");require("react");const T=require("./useButtonProps-BqBGuqoP.cjs");var A=i.Node3.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",i.mergeAttributes(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,n)=>n.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:n})=>{if(!i.canInsertNode(n,n.schema.nodes[this.name]))return!1;const{selection:r}=n,{$to:s}=r,c=t();return i.isNodeSelection(r)?c.insertContentAt(s.pos,{type:this.name}):c.insertContent({type:this.name}),c.command(({state:a,tr:e,dispatch:p})=>{if(p){const{$to:o}=e.selection,u=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?e.setSelection(l.TextSelection.create(e.doc,o.pos+1)):o.nodeAfter.isBlock?e.setSelection(l.NodeSelection.create(e.doc,o.pos)):e.setSelection(l.TextSelection.create(e.doc,o.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||o.parent.type.contentMatch.defaultType,m=d==null?void 0:d.create();m&&(e.insert(u,m),e.setSelection(l.TextSelection.create(e.doc,u+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[i.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});function R(){const t=T.useButtonProps(y.name),{icon:n=void 0,tooltip:r=void 0,shortcutKeys:s=void 0,tooltipOptions:c={},action:a=void 0,isActive:e=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:o,update:u}=T.useToggleActive(e),d=()=>{o||a&&(a(),u())};return t?h.jsx(f.ActionButton,{action:d,dataState:p,disabled:o,icon:n,shortcutKeys:s,tooltip:r,tooltipOptions:c}):h.jsx(h.Fragment,{})}const y=A.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:n,t:r,extension:s})=>({component:f.ActionButton,componentProps:{action:()=>n.commands.setHorizontalRule(),disabled:!n.can().setHorizontalRule(),icon:"Minus",shortcutKeys:s.options.shortcutKeys??["mod","alt","S"],tooltip:r("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}},renderHTML(){return["div",i.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}});exports.HorizontalRule=y;exports.RichTextHorizontalRule=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-BBNITgNi.cjs"),l=require("@tiptap/pm/state"),f=require("./index-BvIJKpX1.cjs"),h=require("react/jsx-runtime");require("react");const T=require("./useButtonProps-DEtmDVPr.cjs");var A=i.Node3.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",i.mergeAttributes(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,n)=>n.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:n})=>{if(!i.canInsertNode(n,n.schema.nodes[this.name]))return!1;const{selection:r}=n,{$to:s}=r,c=t();return i.isNodeSelection(r)?c.insertContentAt(s.pos,{type:this.name}):c.insertContent({type:this.name}),c.command(({state:a,tr:e,dispatch:p})=>{if(p){const{$to:o}=e.selection,u=o.end();if(o.nodeAfter)o.nodeAfter.isTextblock?e.setSelection(l.TextSelection.create(e.doc,o.pos+1)):o.nodeAfter.isBlock?e.setSelection(l.NodeSelection.create(e.doc,o.pos)):e.setSelection(l.TextSelection.create(e.doc,o.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||o.parent.type.contentMatch.defaultType,m=d==null?void 0:d.create();m&&(e.insert(u,m),e.setSelection(l.TextSelection.create(e.doc,u+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[i.nodeInputRule({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});function R(){const t=T.useButtonProps(y.name),{icon:n=void 0,tooltip:r=void 0,shortcutKeys:s=void 0,tooltipOptions:c={},action:a=void 0,isActive:e=void 0}=(t==null?void 0:t.componentProps)??{},{dataState:p,disabled:o,update:u}=T.useToggleActive(e),d=()=>{o||a&&(a(),u())};return t?h.jsx(f.ActionButton,{action:d,dataState:p,disabled:o,icon:n,shortcutKeys:s,tooltip:r,tooltipOptions:c}):h.jsx(h.Fragment,{})}const y=A.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:n,t:r,extension:s})=>({component:f.ActionButton,componentProps:{action:()=>n.commands.setHorizontalRule(),disabled:!n.can().setHorizontalRule(),icon:"Minus",shortcutKeys:s.options.shortcutKeys??["mod","alt","S"],tooltip:r("editor.horizontalrule.tooltip")}})}},addKeyboardShortcuts(){return{"Mod-Alt-s":()=>this.editor.commands.setHorizontalRule()}},renderHTML(){return["div",i.mergeAttributes(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}});exports.HorizontalRule=y;exports.RichTextHorizontalRule=R;
@@ -1,9 +1,9 @@
1
- import { N as T, n as A, l as y, o as H, m as h } from "./index-CbIQPoF6.js";
1
+ import { N as T, n as A, k as y, l as H, m as h } from "./index-sVScpCFG.js";
2
2
  import { TextSelection as u, NodeSelection as R } from "@tiptap/pm/state";
3
- import { A as f } from "./index-4pRt5Vqu.js";
3
+ import { A as f } from "./index-BIqaogQg.js";
4
4
  import { jsx as m, Fragment as M } from "react/jsx-runtime";
5
5
  import "react";
6
- import { u as v, a as z } from "./useButtonProps-DTngjZge.js";
6
+ import { u as v, a as z } from "./useButtonProps-C_bqxmHi.js";
7
7
  var S = T.create({
8
8
  name: "horizontalRule",
9
9
  addOptions() {
@@ -1,5 +1,5 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
- import { i } from "./index-4pRt5Vqu.js";
2
+ import { i } from "./index-BIqaogQg.js";
3
3
  import "react";
4
4
  function l(n) {
5
5
  const t = i[n.name];
@@ -1 +1 @@
1
- "use strict";const c=require("react/jsx-runtime"),t=require("./index-DvvMf6Wu.cjs");require("react");function i(n){const e=t.icons[n.name];return e?c.jsx(e,{onClick:n==null?void 0:n.onClick,className:`richtext-w-4 richtext-h-4 ${(n==null?void 0:n.className)||""}`}):null}exports.IconComponent=i;
1
+ "use strict";const c=require("react/jsx-runtime"),t=require("./index-BvIJKpX1.cjs");require("react");function i(n){const e=t.icons[n.name];return e?c.jsx(e,{onClick:n==null?void 0:n.onClick,className:`richtext-w-4 richtext-h-4 ${(n==null?void 0:n.className)||""}`}):null}exports.IconComponent=i;
@@ -1 +1 @@
1
- "use strict";const u=require("./index-BBNITgNi.cjs"),s=require("react/jsx-runtime"),b=require("react"),S=require("re-resizable"),h=require("./dom-dataset-BqoJhJXt.cjs"),x=require("./index-DvvMf6Wu.cjs"),g=require("./useButtonProps-BqBGuqoP.cjs"),I=require("./input-BtDj0NeF.cjs"),P=require("./button-U6XpZt2X.cjs"),m={youtube:{example:"https://www.youtube.com/watch?v=I4sMhHbHYXM",src:"https://www.youtube.com/embed/I4sMhHbHYXM",srcPrefix:"https://www.youtube.com/embed",linkRule:[/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/]},youku:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"https://player.youku.com/embed",linkRule:[String.raw`v.youku.com\/v_show\/id_\w+\=*`],idRule:String.raw`id_\w+\=*`},bilibili:{example:"https://www.bilibili.com/video/BV1EJ411u7DN",src:"https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN",srcPrefix:"https://player.bilibili.com/player.html?bvid",linkRule:[String.raw`www.bilibili.com\/video\/\w+`]},qqvideo:{example:"https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html",src:"https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v",srcPrefix:"https://v.qq.com/txp/iframe/player.html?vid",linkRule:[String.raw`v.qq.com\/x\/cover\/\w+\/\w+`]},amap:{example:"https://ditu.amap.com/",src:"https://www.amap.com/place/B000A45467",srcPrefix:"",linkRule:[String.raw`\.amap\.com`]},baidu_map:{example:"https://j.map.baidu.com/15/fo",src:"https://j.map.baidu.com/15/fo",srcPrefix:"",linkRule:[String.raw`map\.baidu\.com`]},modao:{example:"https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx",src:"https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2",srcPrefix:"",linkRule:[String.raw`https:\/\/\w+.modao.cc\/app\/\w+\/embed\/v2`],tips:"Modao > More > Share > Embed > COPY"},lanhu:{example:"https://lanhuapp.com/link/#/invite?sid=evP7L",src:"https://lanhuapp.com/url/evP7L",srcPrefix:"",linkRule:[String.raw`https:\/\/lanhuapp.com\/url\/\w+`],tips:"Lanhu > Project > Share > Copy Link"},figma:{example:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",src:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",srcPrefix:"https://www.figma.com/embed?embed_host=share&url",linkRule:[String.raw`https:\/\/www.figma.com\/file\/\w+`]},canva:{example:"https://www.canva.cn/design/DAD61-t29UI/view",src:"https://www.canva.cn/design/DAD61-t29UI/view",srcPrefix:"",linkRule:[String.raw`https:\/\/www.canva.cn\/design\/.+\/view`]},processon:{example:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",src:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",srcPrefix:"",linkRule:[String.raw`https:\/\/www.processon.com\/embed\/\w+`]},codepen:{example:"https://codepen.io/mekery/embed/YzyrKOJ",src:"https://codepen.io/mekery/embed/YzyrKOJ",srcPrefix:"",linkRule:[String.raw`https:\/\/codepen.io\/.+\/embed\/\w+`]},jinshuju:{example:"https://jinshuju.net/f/q9YvVf",src:"https://jinshuju.net/f/q9YvVf",srcPrefix:"",linkRule:[String.raw`https:\/\/jinshuju.net\/f\/\w+`]},iframe:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"",linkRule:[".+"]},googlemaps:{example:"https://goo.gl/maps/8Ys8b4K1ZJY2",src:"https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2",srcPrefix:"",linkRule:[String.raw`https:\/\/goo.gl\/maps\/\w+`]}};function R(e){const t=m.youtube,i=e.matchedUrl;e.validLink=!0;const r=i.split("="),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}/${c}`,e.validId=!0}return e}function j(e){const t=m.youku,i=e.matchedUrl,r=t.idRule,n=new RegExp(r),c=i.match(n);if(c&&c.length>0){const o=c[0].slice(3);e.validId=!0,e.src=`${t.srcPrefix}/${o}`}else e.validId=!1;return e}function M(e){const t=m.bilibili,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function q(e){const t=m.qqvideo,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function N(e,t){return t.src=e,t.validId=!0,t}function U(e,t){return t.src=e,t.validId=!0,t}function A(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function D(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function L(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function $(e){const t=m.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function _(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function T(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function z(e){return e.src=`${e.matchedUrl}`,e.validId=!0,e.originalLink=e.src,e}function Y(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function C(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function E(e,t,i){if(e==="googlemaps")return i.validLink=!0,i.matchedUrl=t,i;const n=m[e].linkRule;for(const c of n){const o=new RegExp(c),a=t.match(o);if(a&&a.length>0)return i.validLink=!0,i.matchedUrl=e==="youtube"?a[1]:a[0],i}return i}function H(e){var i,r;let t="iframe";return((i=e.includes)!=null&&i.call(e,"youtube")||(r=e.includes)!=null&&r.call(e,"youtu.be"))&&(t="youtube"),e.includes("youku")&&(t="youku"),e.includes("bilibili")&&(t="bilibili"),e.includes("qq")&&(t="qqvideo"),e.includes("amap")&&(t="amap"),e.includes("map.baidu")&&(t="baidu_map"),(e.includes("google.com/maps")||e.includes("maps.app.goo.gl"))&&(t="googlemaps"),e.includes("modao")&&(t="modao"),e.includes("lanhuapp")&&(t="lanhu"),e.includes("figma")&&(t="figma"),e.includes("canva")&&(t="canva"),e.includes("processon")&&(t="processon"),e.includes("codepen")&&(t="codepen"),e.includes("jinshuju")&&(t="jinshuju"),e.includes("iframe")&&(t="iframe"),t}function k(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=H(e);if(t=E(i,e,t),!t.validLink)return t;switch(i){case"youtube":return R(t);case"youku":return j(t);case"bilibili":return M(t);case"qqvideo":return q(t);case"amap":return N(e,t);case"baidu_map":return U(e,t);case"googlemaps":return A(e,t);case"modao":return D(t);case"lanhu":return L(t);case"figma":return $(t);case"canva":return _(e,t);case"processon":return T(e,t);case"codepen":return z(t);case"jinshuju":return Y(e,t);case"iframe":return C(e,t);default:return e}}const B="_wrap_5y04w_1",V="_innerWrap_5y04w_15",v={wrap:B,innerWrap:V};function K({editor:e,node:t,updateAttributes:i}){const r=x.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,p]=b.useState("");function l(){if(!a)return;const d=k(a);e.chain().updateAttributes(f.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const y=b.useCallback(d=>{i({width:d.width,height:d.height})},[i]);return s.jsxs(u.NodeViewWrapper,{children:[!n&&s.jsxs("div",{className:"richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-border richtext-p-[10px]",children:[s.jsx(I.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>p(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(P.Button,{className:"richtext-w-[60px]",onClick:l,children:"OK"})]}),n&&s.jsx(S.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,X,J,w)=>{y({width:Number.parseInt(c)+w.width,height:Number.parseInt(o)+w.height})},children:s.jsx("div",{className:u.clsx(v.wrap,"render-wrapper"),children:s.jsx("div",{className:v.innerWrap,style:{pointerEvents:r?"none":"auto"},children:s.jsx("iframe",{className:"richtext-my-[12px] ",src:n})})})})]})}function O(){const e=g.useButtonProps(f.name),{icon:t=void 0,tooltip:i=void 0,shortcutKeys:r=void 0,tooltipOptions:n={},action:c=void 0,isActive:o=void 0}=(e==null?void 0:e.componentProps)??{},{editorDisabled:a,update:p}=g.useToggleActive(o),l=()=>{a||c&&(c(),p())};return e?s.jsx(x.ActionButton,{action:l,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const f=u.Node3.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"iframe"},button:({editor:t,extension:i,t:r})=>({componentProps:{action:n=>t.commands.setIframe(n),upload:i.options.upload,icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:h.getDatasetAttribute("width")},height:{default:300,parseHTML:h.getDatasetAttribute("height")},src:{default:null,parseHTML:h.getDatasetAttribute("src")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",u.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:i,chain:r})=>{var c,o,a;if(((a=(o=(c=t.selection)==null?void 0:c.node)==null?void 0:o.type)==null?void 0:a.name)==this.name)return i.updateAttributes(this.name,e);const n=e||{url:""};return r().insertContent({type:this.name,attrs:n}).run()}}},addInputRules(){return[u.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return u.ReactNodeViewRenderer(K)}});exports.Iframe=f;exports.RichTextIframe=O;exports.getServiceSrc=k;
1
+ "use strict";const u=require("./index-BBNITgNi.cjs"),s=require("react/jsx-runtime"),b=require("react"),S=require("re-resizable"),I=require("./button-wt49IYwP.cjs"),P=require("./input-BeD5GdMv.cjs"),x=require("./index-BvIJKpX1.cjs"),h=require("./dom-dataset-BqoJhJXt.cjs"),g=require("./useButtonProps-DEtmDVPr.cjs"),m={youtube:{example:"https://www.youtube.com/watch?v=I4sMhHbHYXM",src:"https://www.youtube.com/embed/I4sMhHbHYXM",srcPrefix:"https://www.youtube.com/embed",linkRule:[/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\s/]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[&?]v=)|youtu\.be\/)([\w-]{11})/]},youku:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html?spm=a2h0c.8166622.PhoneSokuUgc_4.dtitle",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"https://player.youku.com/embed",linkRule:[String.raw`v.youku.com\/v_show\/id_\w+\=*`],idRule:String.raw`id_\w+\=*`},bilibili:{example:"https://www.bilibili.com/video/BV1EJ411u7DN",src:"https://player.bilibili.com/player.html?bvid=BV1EJ411u7DN",srcPrefix:"https://player.bilibili.com/player.html?bvid",linkRule:[String.raw`www.bilibili.com\/video\/\w+`]},qqvideo:{example:"https://v.qq.com/x/cover/mzc0020006aw1mn/u0033nvzb5v.html",src:"https://v.qq.com/txp/iframe/player.html?vid=u0033nvzb5v",srcPrefix:"https://v.qq.com/txp/iframe/player.html?vid",linkRule:[String.raw`v.qq.com\/x\/cover\/\w+\/\w+`]},amap:{example:"https://ditu.amap.com/",src:"https://www.amap.com/place/B000A45467",srcPrefix:"",linkRule:[String.raw`\.amap\.com`]},baidu_map:{example:"https://j.map.baidu.com/15/fo",src:"https://j.map.baidu.com/15/fo",srcPrefix:"",linkRule:[String.raw`map\.baidu\.com`]},modao:{example:"https://free.modao.cc/app/2cd26580a6717a147454df7470e7ec464093cba3/embed/v2#screen=sk71k6d1dfxulzx",src:"https://free.modao.cc/app/6UkpAxcGE3nPz52GLqhnOZgC7MATBSy/embed/v2",srcPrefix:"",linkRule:[String.raw`https:\/\/\w+.modao.cc\/app\/\w+\/embed\/v2`],tips:"Modao > More > Share > Embed > COPY"},lanhu:{example:"https://lanhuapp.com/link/#/invite?sid=evP7L",src:"https://lanhuapp.com/url/evP7L",srcPrefix:"",linkRule:[String.raw`https:\/\/lanhuapp.com\/url\/\w+`],tips:"Lanhu > Project > Share > Copy Link"},figma:{example:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",src:"https://www.figma.com/file/aS9uSgPXoNpaPkzbjNcK8v/Demo?node-id=0%3A1",srcPrefix:"https://www.figma.com/embed?embed_host=share&url",linkRule:[String.raw`https:\/\/www.figma.com\/file\/\w+`]},canva:{example:"https://www.canva.cn/design/DAD61-t29UI/view",src:"https://www.canva.cn/design/DAD61-t29UI/view",srcPrefix:"",linkRule:[String.raw`https:\/\/www.canva.cn\/design\/.+\/view`]},processon:{example:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",src:"https://www.processon.com/embed/5ea99d8607912948b0e6fe78",srcPrefix:"",linkRule:[String.raw`https:\/\/www.processon.com\/embed\/\w+`]},codepen:{example:"https://codepen.io/mekery/embed/YzyrKOJ",src:"https://codepen.io/mekery/embed/YzyrKOJ",srcPrefix:"",linkRule:[String.raw`https:\/\/codepen.io\/.+\/embed\/\w+`]},jinshuju:{example:"https://jinshuju.net/f/q9YvVf",src:"https://jinshuju.net/f/q9YvVf",srcPrefix:"",linkRule:[String.raw`https:\/\/jinshuju.net\/f\/\w+`]},iframe:{example:"https://v.youku.com/v_show/id_XNDM0NDM4MTcy.html",src:"https://player.youku.com/embed/XNDM0NDM4MTcy",srcPrefix:"",linkRule:[".+"]},googlemaps:{example:"https://goo.gl/maps/8Ys8b4K1ZJY2",src:"https://www.google.com/maps/embed?pb=https://goo.gl/maps/8Ys8b4K1ZJY2",srcPrefix:"",linkRule:[String.raw`https:\/\/goo.gl\/maps\/\w+`]}};function R(e){const t=m.youtube,i=e.matchedUrl;e.validLink=!0;const r=i.split("="),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}/${c}`,e.validId=!0}return e}function j(e){const t=m.youku,i=e.matchedUrl,r=t.idRule,n=new RegExp(r),c=i.match(n);if(c&&c.length>0){const o=c[0].slice(3);e.validId=!0,e.src=`${t.srcPrefix}/${o}`}else e.validId=!1;return e}function M(e){const t=m.bilibili,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function q(e){const t=m.qqvideo,r=e.matchedUrl.split("/"),n=r.length;if(n>0){const c=r[n-1];e.src=`${t.srcPrefix}=${c}`,e.validId=!0}return e}function N(e,t){return t.src=e,t.validId=!0,t}function U(e,t){return t.src=e,t.validId=!0,t}function A(e,t){return t.src=e,t.validId=!0,t.originalLink=e,t}function D(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function L(e){return e.src=e.matchedUrl,e.validId=!0,e.originalLink=e.src,e}function $(e){const t=m.figma;return e.src=`${t.srcPrefix}=${encodeURIComponent(e.matchedUrl)}`,e.validId=!0,e.originalLink=e.matchedUrl,e}function _(e,t){return t.src=`${t.matchedUrl}?embed`,t.validId=!0,t.originalLink=e,t}function T(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function z(e){return e.src=`${e.matchedUrl}`,e.validId=!0,e.originalLink=e.src,e}function Y(e,t){return t.src=`${t.matchedUrl}?background=white&banner=show&embedded=true`,t.validId=!0,t.originalLink=e,t}function C(e,t){return t.src=`${t.matchedUrl}`,t.validId=!0,t.originalLink=e,t}function E(e,t,i){if(e==="googlemaps")return i.validLink=!0,i.matchedUrl=t,i;const n=m[e].linkRule;for(const c of n){const o=new RegExp(c),a=t.match(o);if(a&&a.length>0)return i.validLink=!0,i.matchedUrl=e==="youtube"?a[1]:a[0],i}return i}function H(e){var i,r;let t="iframe";return((i=e.includes)!=null&&i.call(e,"youtube")||(r=e.includes)!=null&&r.call(e,"youtu.be"))&&(t="youtube"),e.includes("youku")&&(t="youku"),e.includes("bilibili")&&(t="bilibili"),e.includes("qq")&&(t="qqvideo"),e.includes("amap")&&(t="amap"),e.includes("map.baidu")&&(t="baidu_map"),(e.includes("google.com/maps")||e.includes("maps.app.goo.gl"))&&(t="googlemaps"),e.includes("modao")&&(t="modao"),e.includes("lanhuapp")&&(t="lanhu"),e.includes("figma")&&(t="figma"),e.includes("canva")&&(t="canva"),e.includes("processon")&&(t="processon"),e.includes("codepen")&&(t="codepen"),e.includes("jinshuju")&&(t="jinshuju"),e.includes("iframe")&&(t="iframe"),t}function k(e){let t={validLink:!1,validId:!1,matchedUrl:"",originalLink:e,src:""};const i=H(e);if(t=E(i,e,t),!t.validLink)return t;switch(i){case"youtube":return R(t);case"youku":return j(t);case"bilibili":return M(t);case"qqvideo":return q(t);case"amap":return N(e,t);case"baidu_map":return U(e,t);case"googlemaps":return A(e,t);case"modao":return D(t);case"lanhu":return L(t);case"figma":return $(t);case"canva":return _(e,t);case"processon":return T(e,t);case"codepen":return z(t);case"jinshuju":return Y(e,t);case"iframe":return C(e,t);default:return e}}const B="_wrap_5y04w_1",V="_innerWrap_5y04w_15",v={wrap:B,innerWrap:V};function K({editor:e,node:t,updateAttributes:i}){const r=x.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,p]=b.useState("");function l(){if(!a)return;const d=k(a);e.chain().updateAttributes(f.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const y=b.useCallback(d=>{i({width:d.width,height:d.height})},[i]);return s.jsxs(u.NodeViewWrapper,{children:[!n&&s.jsxs("div",{className:"richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-border richtext-p-[10px]",children:[s.jsx(P.Input,{autoFocus:!0,className:"richtext-flex-1",onInput:d=>p(d.target.value),placeholder:"Enter link",type:"url",value:a}),s.jsx(I.Button,{className:"richtext-w-[60px]",onClick:l,children:"OK"})]}),n&&s.jsx(S.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,X,J,w)=>{y({width:Number.parseInt(c)+w.width,height:Number.parseInt(o)+w.height})},children:s.jsx("div",{className:u.clsx(v.wrap,"render-wrapper"),children:s.jsx("div",{className:v.innerWrap,style:{pointerEvents:r?"none":"auto"},children:s.jsx("iframe",{className:"richtext-my-[12px] ",src:n})})})})]})}function O(){const e=g.useButtonProps(f.name),{icon:t=void 0,tooltip:i=void 0,shortcutKeys:r=void 0,tooltipOptions:n={},action:c=void 0,isActive:o=void 0}=(e==null?void 0:e.componentProps)??{},{editorDisabled:a,update:p}=g.useToggleActive(o),l=()=>{a||c&&(c(),p())};return e?s.jsx(x.ActionButton,{action:l,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const f=u.Node3.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"iframe"},button:({editor:t,extension:i,t:r})=>({componentProps:{action:n=>t.commands.setIframe(n),upload:i.options.upload,icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:h.getDatasetAttribute("width")},height:{default:300,parseHTML:h.getDatasetAttribute("height")},src:{default:null,parseHTML:h.getDatasetAttribute("src")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",u.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:i,chain:r})=>{var c,o,a;if(((a=(o=(c=t.selection)==null?void 0:c.node)==null?void 0:o.type)==null?void 0:a.name)==this.name)return i.updateAttributes(this.name,e);const n=e||{url:""};return r().insertContent({type:this.name,attrs:n}).run()}}},addInputRules(){return[u.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return u.ReactNodeViewRenderer(K)}});exports.Iframe=f;exports.RichTextIframe=O;exports.getServiceSrc=k;
@@ -1,12 +1,12 @@
1
- import { s as v, C as x, N as k, R as y, n as S, m as I } from "./index-CbIQPoF6.js";
1
+ import { q as v, C as x, N as k, u as y, n as S, m as I } from "./index-sVScpCFG.js";
2
2
  import { jsxs as f, jsx as d, Fragment as P } from "react/jsx-runtime";
3
- import { useState as R, useCallback as M } from "react";
3
+ import { useState as M, useCallback as R } from "react";
4
4
  import { Resizable as N } from "re-resizable";
5
+ import { B as j } from "./button-CBO-WDXK.js";
6
+ import { I as U } from "./input-Bx4uo4gO.js";
7
+ import { k as q, A } from "./index-BIqaogQg.js";
5
8
  import { g as l } from "./dom-dataset-CIEeltF6.js";
6
- import { k as j, A as U } from "./index-4pRt5Vqu.js";
7
- import { u as q, a as A } from "./useButtonProps-DTngjZge.js";
8
- import { I as L } from "./input-C5zU49Q1.js";
9
- import { B as D } from "./button-D8SI-g7p.js";
9
+ import { u as L, a as D } from "./useButtonProps-C_bqxmHi.js";
10
10
  const m = {
11
11
  youtube: {
12
12
  example: "https://www.youtube.com/watch?v=I4sMhHbHYXM",
@@ -240,7 +240,7 @@ const Q = "_wrap_5y04w_1", ee = "_innerWrap_5y04w_15", w = {
240
240
  innerWrap: ee
241
241
  };
242
242
  function te({ editor: e, node: t, updateAttributes: i }) {
243
- const r = j(), { src: n, width: c, height: o } = t.attrs, [a, p] = R("");
243
+ const r = q(), { src: n, width: c, height: o } = t.attrs, [a, p] = M("");
244
244
  function u() {
245
245
  if (!a)
246
246
  return;
@@ -249,7 +249,7 @@ function te({ editor: e, node: t, updateAttributes: i }) {
249
249
  src: (s == null ? void 0 : s.src) || a
250
250
  }).setNodeSelection(e.state.selection.from).focus().run();
251
251
  }
252
- const g = M(
252
+ const g = R(
253
253
  (s) => {
254
254
  i({ width: s.width, height: s.height });
255
255
  },
@@ -258,7 +258,7 @@ function te({ editor: e, node: t, updateAttributes: i }) {
258
258
  return /* @__PURE__ */ f(v, { children: [
259
259
  !n && /* @__PURE__ */ f("div", { className: "richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-border richtext-p-[10px]", children: [
260
260
  /* @__PURE__ */ d(
261
- L,
261
+ U,
262
262
  {
263
263
  autoFocus: !0,
264
264
  className: "richtext-flex-1",
@@ -269,7 +269,7 @@ function te({ editor: e, node: t, updateAttributes: i }) {
269
269
  }
270
270
  ),
271
271
  /* @__PURE__ */ d(
272
- D,
272
+ j,
273
273
  {
274
274
  className: "richtext-w-[60px]",
275
275
  onClick: u,
@@ -306,18 +306,18 @@ function te({ editor: e, node: t, updateAttributes: i }) {
306
306
  ] });
307
307
  }
308
308
  function le() {
309
- const e = q(b.name), {
309
+ const e = L(b.name), {
310
310
  icon: t = void 0,
311
311
  tooltip: i = void 0,
312
312
  shortcutKeys: r = void 0,
313
313
  tooltipOptions: n = {},
314
314
  action: c = void 0,
315
315
  isActive: o = void 0
316
- } = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: a, update: p } = A(o), u = () => {
316
+ } = (e == null ? void 0 : e.componentProps) ?? {}, { editorDisabled: a, update: p } = D(o), u = () => {
317
317
  a || c && (c(), p());
318
318
  };
319
319
  return e ? /* @__PURE__ */ d(
320
- U,
320
+ A,
321
321
  {
322
322
  action: u,
323
323
  disabled: a,
package/lib/Iframe.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-BBNITgNi.cjs");const e=require("./Iframe-CUrXCDxj.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Iframe=e.Iframe;exports.RichTextIframe=e.RichTextIframe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-BBNITgNi.cjs");const e=require("./Iframe-BmXO2c65.cjs");require("./dom-dataset-BqoJhJXt.cjs");exports.Iframe=e.Iframe;exports.RichTextIframe=e.RichTextIframe;
package/lib/Iframe.js CHANGED
@@ -1,5 +1,5 @@
1
- import "./index-CbIQPoF6.js";
2
- import { I as o, R as t } from "./Iframe-De88TYvj.js";
1
+ import "./index-sVScpCFG.js";
2
+ import { I as o, R as t } from "./Iframe-DwhclppJ.js";
3
3
  import "./dom-dataset-CIEeltF6.js";
4
4
  export {
5
5
  o as Iframe,
package/lib/Image.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("./index-BBNITgNi.cjs"),W=require("./throttle-BM3Bmbf_.cjs"),n=require("react/jsx-runtime"),o=require("react"),F=require("./index-FSRjMsxW.cjs"),Y=require("./isNumber-Bv1Qhmw8.cjs"),ie=require("./index-DvvMf6Wu.cjs"),z=require("./dialog-DgnnVCfv.cjs"),ae=require("react-image-crop"),B=require("./button-U6XpZt2X.cjs"),Z=require("./file-i7e4nQY2.cjs"),U=require("./useButtonProps-BqBGuqoP.cjs"),ee=require("./use-toast-Bz3QCOtE.cjs"),P=require("./Icon-b6HQAURz.cjs"),re=require("./store-BSCjQxMK.cjs"),J=require("./events.constant-DQYeJpu5.cjs"),q=require("./tabs-CHy82_rs.cjs"),se=require("./checkbox-DaIBNthL.cjs"),K=require("./label-C8BonzOY.cjs"),Q=require("./input-BtDj0NeF.cjs"),H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function le(e){var O,d,E;const[t,a]=o.useState({width:F.IMAGE_MAX_SIZE,height:F.IMAGE_MAX_SIZE}),[c,f]=o.useState({width:0,height:0}),[h]=o.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[x,T]=o.useState(!1),[g,b]=o.useState({x:0,y:0,w:0,h:0,dir:""}),{align:A,inline:j}=(O=e==null?void 0:e.node)==null?void 0:O.attrs,L=j&&(A==="left"||A==="right"),M=o.useMemo(()=>{var V;const{src:r,alt:I,width:i,height:s,flipX:m,flipY:l}=(V=e==null?void 0:e.node)==null?void 0:V.attrs,y=Y.isNumber(i)?`${i}px`:i,w=Y.isNumber(s)?`${s}px`:s,X=[];m&&X.push("rotateX(180deg)"),l&&X.push("rotateY(180deg)");const ne=X.join(" ");return{src:r||void 0,alt:I||void 0,style:{width:y||void 0,height:w||void 0,transform:ne||"none",...L?{float:A}:{}}}},[(d=e==null?void 0:e.node)==null?void 0:d.attrs]),R=o.useMemo(()=>{const{style:{width:r}}=M;return{width:r==="100%"?r:void 0}},[M]);function _(r){f({width:r.target.width,height:r.target.height})}function C(){const{editor:r,getPos:I}=e;r.commands.setNodeSelection(I())}const S=o.useCallback(W.throttle(()=>{const{editor:r}=e,{width:I}=getComputedStyle(r.view.dom);a(i=>({...i,width:Number.parseInt(I,10)}))},F.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function N(r,I){r.preventDefault(),r.stopPropagation();const i=c.width,s=c.height,m=i/s;let l=Number(e.node.attrs.width),y=Number(e.node.attrs.height);const w=t.width;l&&!y?(l=l>w?w:l,y=Math.round(l/m)):y&&!l?(l=Math.round(y*m),l=l>w?w:l):!l&&!y?(l=i>w?w:i,y=Math.round(l/m)):l=l>w?w:l,T(!0),b({x:r.clientX,y:r.clientY,w:l,h:y,dir:I})}const v=o.useCallback(W.throttle(r=>{if(r.preventDefault(),r.stopPropagation(),!x)return;const{x:I,w:i,dir:s}=g,m=(r.clientX-I)*(/l/.test(s)?-1:1),l=Y.clamp(i+m,F.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:l,height:null})},F.IMAGE_THROTTLE_WAIT_TIME),[x,g,t,e.updateAttributes]),p=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),x&&(b({x:0,y:0,w:0,h:0,dir:""}),T(!1),C())},[x,C]),u=o.useCallback(()=>{document==null||document.addEventListener("mousemove",v,!0),document==null||document.addEventListener("mouseup",p,!0)},[v,p]),k=o.useCallback(()=>{document==null||document.removeEventListener("mousemove",v,!0),document==null||document.removeEventListener("mouseup",p,!0)},[v,p]);o.useEffect(()=>(x?u():k(),()=>{k()}),[x,u,k]);const D=o.useMemo(()=>new ResizeObserver(()=>S()),[S]);return o.useEffect(()=>(D.observe(e.editor.view.dom),()=>{D.disconnect()}),[e.editor.view.dom,D]),n.jsx(G.NodeViewWrapper,{as:j?"span":"div",className:"image-view",style:{float:L?A:void 0,margin:L?A==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:j?"inline":"block",textAlign:L?void 0:A,width:((E=M.style)==null?void 0:E.width)??"auto",...L?{}:R},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:R,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${x?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:M.alt,className:"image-view__body__image block",height:"auto",onClick:C,onLoad:_,src:M.src,style:M.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||x)&&n.jsx("div",{className:"image-resizer",children:h==null?void 0:h.map(r=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${r}`,onMouseDown:I=>N(I,r)},`image-dir-${r}`))})]})})}function oe(e,t){const a=e.type,c=e.name.toLowerCase(),f=c.split(".").pop();if(!f)return!1;const x=a||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[f];return t.some(T=>{if(T.startsWith("."))return c.endsWith(T);if(T.endsWith("/*")){const g=T.split("/")[0];return x==null?void 0:x.startsWith(g+"/")}return x===T})}function te(e,t){const{acceptMimes:a,maxSize:c,t:f,toast:h}=t,x=[];return(Array.isArray(e)?e:Object.values(e)).forEach(g=>{if(!oe(g,a)){t.onError?t.onError({type:"type",message:f("editor.upload.fileTypeNotSupported",{fileName:g.name}),file:g}):h({variant:"default",title:f("editor.upload.fileTypeNotSupported",{fileName:g.name})});return}if(g.size>c){const b=(c/1024/1024).toFixed(2);t.onError?t.onError({type:"size",message:f("editor.upload.fileSizeTooBig",{fileName:g.name,size:b}),file:g}):h({variant:"default",title:f("editor.upload.fileSizeTooBig",{fileName:g.name,size:b})});return}x.push(g)}),x}function ce({editor:e,imageInline:t,onClose:a,disabled:c,alt:f}){var r,I;const{t:h}=F.useLocale(),{toast:x}=ee.useToast(),[T,g]=o.useState(!1),[b,A]=o.useState(!1),j=o.useRef(null),[L,M]=o.useState(),[R,_]=o.useState(""),C=o.useRef(null),[S,N]=o.useState({src:"",file:null}),v=U.useExtension($.name),p=o.useMemo(()=>(v==null?void 0:v.options)??{},[v]);function u(i){if(j.current&&i.width&&i.height){const s=k(j.current,i);_(s)}}function k(i,s){const m=document.createElement("canvas"),l=i.naturalWidth/i.width,y=i.naturalHeight/i.height;m.width=s.width*l,m.height=s.height*y;const w=m.getContext("2d");return w&&(w.imageSmoothingEnabled=!1,w.drawImage(i,s.x*l,s.y*y,s.width*l,s.height*y,0,0,s.width*l,s.height*y)),m.toDataURL("image/png",1)}const D=o.useCallback(async()=>{var i;if(!b){A(!0);try{const s=Z.dataURLtoFile(R,((i=S==null?void 0:S.file)==null?void 0:i.name)||"image.png");let m="";p.upload?m=await p.upload(s):m=URL.createObjectURL(s),e.chain().focus().setImageInline({src:m,inline:t,alt:f}).run(),g(!1),N({src:"",file:null}),E(),a()}catch(s){console.log("Error cropping image",s)}finally{A(!1)}}},[R,e,t,b,a,(r=S==null?void 0:S.file)==null?void 0:r.name,p]);function O(i){var s;i.preventDefault(),(s=C.current)==null||s.click()}const d=async i=>{var w;const s=(w=i==null?void 0:i.target)==null?void 0:w.files;if(!e||e.isDestroyed||s.length===0){i.target.value="";return}const m=te(s,{acceptMimes:p==null?void 0:p.acceptMimes,maxSize:p==null?void 0:p.maxSize,t:h,toast:x,onError:p.onError});if(m.length<=0){i.target.value="";return}const l=m[0],y=await Z.readImageAsBase64(l);g(!0),N({src:y.src,file:l})},E=()=>{C.current&&(C.current.value="")};return n.jsxs(n.Fragment,{children:[n.jsx(B.Button,{className:"richtext-mt-1 richtext-w-full",disabled:c,onClick:O,size:"sm",children:h("editor.image.dialog.tab.uploadCrop")}),n.jsxs(z.Dialog,{open:T,onOpenChange:i=>{g(i),i||(N({src:"",file:null}),E())},children:[n.jsx(z.DialogTrigger,{}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:h("editor.image.dialog.tab.uploadCrop")}),n.jsx("div",{children:S.src&&n.jsx(ae,{className:"richtext-w-full",crop:L,onChange:i=>M(i),onComplete:i=>u(i),children:n.jsx("img",{alt:"Crop me",ref:j,src:S.src})})}),n.jsxs(z.DialogFooter,{children:[n.jsxs(B.Button,{disabled:b,onClick:()=>{g(!1),N({src:"",file:null}),E()},children:[h("editor.imageUpload.cancel"),n.jsx(P.IconComponent,{className:"richtext-ml-1",name:"Trash2"})]}),n.jsx(B.Button,{className:"richtext-w-fit",disabled:b||!L,onClick:D,children:b?n.jsxs(n.Fragment,{children:[h("editor.imageUpload.uploading"),n.jsx(P.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):n.jsxs(n.Fragment,{children:[h("editor.imageUpload.crop"),n.jsx(P.IconComponent,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),n.jsx("input",{accept:((I=p==null?void 0:p.acceptMimes)==null?void 0:I.join(","))||"image/*",multiple:!1,onChange:d,ref:C,style:{display:"none"},type:"file"})]})}function ue(){const{t:e}=F.useLocale(),{toast:t}=ee.useToast(),a=U.useEditorInstance(),c=U.useButtonProps($.name),{icon:f,tooltip:h}=(c==null?void 0:c.componentProps)??{},{editorDisabled:x}=U.useToggleActive(),[T,g]=o.useState(!1),[b,A]=o.useState(!1),j=U.useExtension($.name),L=d=>{g(d.detail)},[M,R]=o.useState(""),[_,C]=o.useState(""),S=o.useRef(null),N=(j==null?void 0:j.options.defaultInline)||!1,[v,p]=o.useState(N),u=o.useMemo(()=>j==null?void 0:j.options,[j]);o.useEffect(()=>{const d=J.listenEvent(J.EVENTS.UPLOAD_IMAGE(a.id),L);return()=>{d()}},[]);async function k(d){var I;const E=(I=d==null?void 0:d.target)==null?void 0:I.files;if(!a||a.isDestroyed||E.length===0||b){d.target.value="";return}const r=te(E,{acceptMimes:u==null?void 0:u.acceptMimes,maxSize:u==null?void 0:u.maxSize,t:e,toast:t,onError:u.onError});if(r.length<=0){d.target.value="";return}A(!0);try{if(u!=null&&u.multiple){const i=r.map(async m=>{let l="";return u.upload?l=await u.upload(m):l=URL.createObjectURL(m),l});(await Promise.all(i)).forEach(m=>{a.chain().focus().setImageInline({src:m,inline:v,alt:_}).run()})}else{const i=r[0];let s="";u.upload?s=await u.upload(i):s=URL.createObjectURL(i),a.chain().focus().setImageInline({src:s,inline:v,alt:_}).run()}g(!1),C(""),p(N)}catch(i){console.error("Error uploading image",i),u.onError?u.onError({type:"upload",message:e("editor.upload.error")}):t({variant:"destructive",title:e("editor.upload.error")})}finally{A(!1),d.target.value=""}}function D(d){d.preventDefault(),d.stopPropagation(),a.chain().focus().setImageInline({src:M,inline:v,alt:_}).run(),g(!1),p(N),R(""),C("")}function O(d){var E;d.preventDefault(),(E=S.current)==null||E.click()}return c?n.jsxs(z.Dialog,{onOpenChange:g,open:T,children:[n.jsx(z.DialogTrigger,{asChild:!0,children:n.jsx(ie.ActionButton,{disabled:x,icon:f,tooltip:h,action:()=>{x||g(!0)}})}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:e("editor.image.dialog.title")}),n.jsxs(q.Tabs,{activationMode:"manual",defaultValue:u.resourceImage==="both"||u.resourceImage==="upload"?"upload":"link",children:[u.resourceImage==="both"&&n.jsxs(q.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[n.jsx(q.TabsTrigger,{value:"upload",children:e("editor.image.dialog.tab.upload")}),n.jsx(q.TabsTrigger,{value:"link",children:e("editor.image.dialog.tab.url")})]}),n.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[n.jsx(se.Checkbox,{checked:v,onCheckedChange:d=>{p(d)}}),n.jsx(K.Label,{children:e("editor.link.dialog.inline")})]}),u.enableAlt&&n.jsxs("div",{className:"richtext-my-[10px] ",children:[n.jsx(K.Label,{className:"mb-[6px]",children:e("editor.imageUpload.alt")}),n.jsx(Q.Input,{onChange:d=>C(d.target.value),required:!0,type:"text",value:_})]}),n.jsxs(q.TabsContent,{value:"upload",children:[n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[n.jsx(B.Button,{className:"richtext-mt-1 richtext-w-full",disabled:b,onClick:O,size:"sm",children:b?n.jsxs(n.Fragment,{children:[e("editor.imageUpload.uploading"),n.jsx(P.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):e("editor.image.dialog.tab.upload")}),n.jsx(ce,{alt:_,disabled:b,editor:a,imageInline:v,onClose:()=>{re.actionDialogImage.setOpen(a.id,!1),C("")}})]}),n.jsx("input",{accept:u.acceptMimes.join(",")||"image/*",multiple:u.multiple,onChange:k,ref:S,style:{display:"none"},type:"file"})]}),n.jsx(q.TabsContent,{value:"link",children:n.jsx("form",{onSubmit:D,children:n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[n.jsx(Q.Input,{autoFocus:!0,onChange:d=>R(d.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:M}),n.jsx(B.Button,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]}):n.jsx(n.Fragment,{})}const de={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},$=W.index_default.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...de,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:a,t:c})=>{var f,h;return{componentProps:{action:()=>!0,upload:a.options.upload,disabled:!((h=(f=t.can()).setImage)!=null&&h.call(f,{})),icon:"ImageUp",tooltip:c("editor.image.tooltip")}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const a=t.style.width||t.getAttribute("width")||null;return a?Number.parseInt(a,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})},alt:{default:"",parseHTML:t=>t.getAttribute("alt"),renderHTML:t=>({alt:t.alt})}}},addNodeView(){return G.ReactNodeViewRenderer(le)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:a})=>a.insertContent({type:this.name,attrs:{...t,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:a})=>a.updateAttributes(this.name,t),setAlignImage:t=>({commands:a})=>a.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:a,align:c,inline:f}=e,h=f&&(c==="left"||c==="right"),x=t||a?`transform: rotateX(${t?"180":"0"}deg) rotateY(${a?"180":"0"}deg);`:"",T=h?"":`text-align: ${c};`,A=`${h?`float: ${c};`:""}${h?c==="left"?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${x}`;return[f?"span":"div",{style:T,class:"image"},["img",G.mergeAttributes({height:"auto",style:A},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var h;const t=e==null?void 0:e.parentElement,a=e==null?void 0:e.getAttribute("width"),c=(e==null?void 0:e.getAttribute("flipx"))||!1,f=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||((h=t==null?void 0:t.style)==null?void 0:h.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:c==="true",flipY:f==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),a=t==null?void 0:t.getAttribute("width"),c=(t==null?void 0:t.getAttribute("flipx"))||!1,f=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:a?Number.parseInt(a,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:c==="true",flipY:f==="true"}}},{tag:'img[src]:not([src^="data:"])'}]}});exports.Image=$;exports.RichTextImage=ue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("./index-BBNITgNi.cjs"),W=require("./throttle-BM3Bmbf_.cjs"),n=require("react/jsx-runtime"),o=require("react"),F=require("./index-FSRjMsxW.cjs"),Y=require("./isNumber-Bv1Qhmw8.cjs"),ie=require("./index-BvIJKpX1.cjs"),B=require("./button-wt49IYwP.cjs"),Z=require("./input-BeD5GdMv.cjs"),J=require("./label--161UPH6.cjs"),q=require("./tabs-DOasUMDU.cjs"),ee=require("./use-toast-Bz3QCOtE.cjs"),ae=require("./checkbox-DUcLSGZD.cjs"),z=require("./dialog-DY868Uji.cjs"),re=require("react-image-crop"),K=require("./file-i7e4nQY2.cjs"),U=require("./useButtonProps-DEtmDVPr.cjs"),P=require("./Icon-gtc3g-VK.cjs"),se=require("./store-B8IkVz1J.cjs"),Q=require("./events.constant-DQYeJpu5.cjs"),H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function le(e){var O,d,E;const[t,a]=o.useState({width:F.IMAGE_MAX_SIZE,height:F.IMAGE_MAX_SIZE}),[c,f]=o.useState({width:0,height:0}),[h]=o.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[x,T]=o.useState(!1),[g,b]=o.useState({x:0,y:0,w:0,h:0,dir:""}),{align:A,inline:j}=(O=e==null?void 0:e.node)==null?void 0:O.attrs,L=j&&(A==="left"||A==="right"),M=o.useMemo(()=>{var V;const{src:r,alt:I,width:i,height:s,flipX:m,flipY:l}=(V=e==null?void 0:e.node)==null?void 0:V.attrs,y=Y.isNumber(i)?`${i}px`:i,w=Y.isNumber(s)?`${s}px`:s,X=[];m&&X.push("rotateX(180deg)"),l&&X.push("rotateY(180deg)");const ne=X.join(" ");return{src:r||void 0,alt:I||void 0,style:{width:y||void 0,height:w||void 0,transform:ne||"none",...L?{float:A}:{}}}},[(d=e==null?void 0:e.node)==null?void 0:d.attrs]),R=o.useMemo(()=>{const{style:{width:r}}=M;return{width:r==="100%"?r:void 0}},[M]);function _(r){f({width:r.target.width,height:r.target.height})}function C(){const{editor:r,getPos:I}=e;r.commands.setNodeSelection(I())}const S=o.useCallback(W.throttle(()=>{const{editor:r}=e,{width:I}=getComputedStyle(r.view.dom);a(i=>({...i,width:Number.parseInt(I,10)}))},F.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function N(r,I){r.preventDefault(),r.stopPropagation();const i=c.width,s=c.height,m=i/s;let l=Number(e.node.attrs.width),y=Number(e.node.attrs.height);const w=t.width;l&&!y?(l=l>w?w:l,y=Math.round(l/m)):y&&!l?(l=Math.round(y*m),l=l>w?w:l):!l&&!y?(l=i>w?w:i,y=Math.round(l/m)):l=l>w?w:l,T(!0),b({x:r.clientX,y:r.clientY,w:l,h:y,dir:I})}const v=o.useCallback(W.throttle(r=>{if(r.preventDefault(),r.stopPropagation(),!x)return;const{x:I,w:i,dir:s}=g,m=(r.clientX-I)*(/l/.test(s)?-1:1),l=Y.clamp(i+m,F.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:l,height:null})},F.IMAGE_THROTTLE_WAIT_TIME),[x,g,t,e.updateAttributes]),p=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),x&&(b({x:0,y:0,w:0,h:0,dir:""}),T(!1),C())},[x,C]),u=o.useCallback(()=>{document==null||document.addEventListener("mousemove",v,!0),document==null||document.addEventListener("mouseup",p,!0)},[v,p]),k=o.useCallback(()=>{document==null||document.removeEventListener("mousemove",v,!0),document==null||document.removeEventListener("mouseup",p,!0)},[v,p]);o.useEffect(()=>(x?u():k(),()=>{k()}),[x,u,k]);const D=o.useMemo(()=>new ResizeObserver(()=>S()),[S]);return o.useEffect(()=>(D.observe(e.editor.view.dom),()=>{D.disconnect()}),[e.editor.view.dom,D]),n.jsx(G.NodeViewWrapper,{as:j?"span":"div",className:"image-view",style:{float:L?A:void 0,margin:L?A==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:j?"inline":"block",textAlign:L?void 0:A,width:((E=M.style)==null?void 0:E.width)??"auto",...L?{}:R},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:R,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${x?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:M.alt,className:"image-view__body__image block",height:"auto",onClick:C,onLoad:_,src:M.src,style:M.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||x)&&n.jsx("div",{className:"image-resizer",children:h==null?void 0:h.map(r=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${r}`,onMouseDown:I=>N(I,r)},`image-dir-${r}`))})]})})}function oe(e,t){const a=e.type,c=e.name.toLowerCase(),f=c.split(".").pop();if(!f)return!1;const x=a||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[f];return t.some(T=>{if(T.startsWith("."))return c.endsWith(T);if(T.endsWith("/*")){const g=T.split("/")[0];return x==null?void 0:x.startsWith(g+"/")}return x===T})}function te(e,t){const{acceptMimes:a,maxSize:c,t:f,toast:h}=t,x=[];return(Array.isArray(e)?e:Object.values(e)).forEach(g=>{if(!oe(g,a)){t.onError?t.onError({type:"type",message:f("editor.upload.fileTypeNotSupported",{fileName:g.name}),file:g}):h({variant:"default",title:f("editor.upload.fileTypeNotSupported",{fileName:g.name})});return}if(g.size>c){const b=(c/1024/1024).toFixed(2);t.onError?t.onError({type:"size",message:f("editor.upload.fileSizeTooBig",{fileName:g.name,size:b}),file:g}):h({variant:"default",title:f("editor.upload.fileSizeTooBig",{fileName:g.name,size:b})});return}x.push(g)}),x}function ce({editor:e,imageInline:t,onClose:a,disabled:c,alt:f}){var r,I;const{t:h}=F.useLocale(),{toast:x}=ee.useToast(),[T,g]=o.useState(!1),[b,A]=o.useState(!1),j=o.useRef(null),[L,M]=o.useState(),[R,_]=o.useState(""),C=o.useRef(null),[S,N]=o.useState({src:"",file:null}),v=U.useExtension($.name),p=o.useMemo(()=>(v==null?void 0:v.options)??{},[v]);function u(i){if(j.current&&i.width&&i.height){const s=k(j.current,i);_(s)}}function k(i,s){const m=document.createElement("canvas"),l=i.naturalWidth/i.width,y=i.naturalHeight/i.height;m.width=s.width*l,m.height=s.height*y;const w=m.getContext("2d");return w&&(w.imageSmoothingEnabled=!1,w.drawImage(i,s.x*l,s.y*y,s.width*l,s.height*y,0,0,s.width*l,s.height*y)),m.toDataURL("image/png",1)}const D=o.useCallback(async()=>{var i;if(!b){A(!0);try{const s=K.dataURLtoFile(R,((i=S==null?void 0:S.file)==null?void 0:i.name)||"image.png");let m="";p.upload?m=await p.upload(s):m=URL.createObjectURL(s),e.chain().focus().setImageInline({src:m,inline:t,alt:f}).run(),g(!1),N({src:"",file:null}),E(),a()}catch(s){console.log("Error cropping image",s)}finally{A(!1)}}},[R,e,t,b,a,(r=S==null?void 0:S.file)==null?void 0:r.name,p]);function O(i){var s;i.preventDefault(),(s=C.current)==null||s.click()}const d=async i=>{var w;const s=(w=i==null?void 0:i.target)==null?void 0:w.files;if(!e||e.isDestroyed||s.length===0){i.target.value="";return}const m=te(s,{acceptMimes:p==null?void 0:p.acceptMimes,maxSize:p==null?void 0:p.maxSize,t:h,toast:x,onError:p.onError});if(m.length<=0){i.target.value="";return}const l=m[0],y=await K.readImageAsBase64(l);g(!0),N({src:y.src,file:l})},E=()=>{C.current&&(C.current.value="")};return n.jsxs(n.Fragment,{children:[n.jsx(B.Button,{className:"richtext-mt-1 richtext-w-full",disabled:c,onClick:O,size:"sm",children:h("editor.image.dialog.tab.uploadCrop")}),n.jsxs(z.Dialog,{open:T,onOpenChange:i=>{g(i),i||(N({src:"",file:null}),E())},children:[n.jsx(z.DialogTrigger,{}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:h("editor.image.dialog.tab.uploadCrop")}),n.jsx("div",{children:S.src&&n.jsx(re,{className:"richtext-w-full",crop:L,onChange:i=>M(i),onComplete:i=>u(i),children:n.jsx("img",{alt:"Crop me",ref:j,src:S.src})})}),n.jsxs(z.DialogFooter,{children:[n.jsxs(B.Button,{disabled:b,onClick:()=>{g(!1),N({src:"",file:null}),E()},children:[h("editor.imageUpload.cancel"),n.jsx(P.IconComponent,{className:"richtext-ml-1",name:"Trash2"})]}),n.jsx(B.Button,{className:"richtext-w-fit",disabled:b||!L,onClick:D,children:b?n.jsxs(n.Fragment,{children:[h("editor.imageUpload.uploading"),n.jsx(P.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):n.jsxs(n.Fragment,{children:[h("editor.imageUpload.crop"),n.jsx(P.IconComponent,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),n.jsx("input",{accept:((I=p==null?void 0:p.acceptMimes)==null?void 0:I.join(","))||"image/*",multiple:!1,onChange:d,ref:C,style:{display:"none"},type:"file"})]})}function ue(){const{t:e}=F.useLocale(),{toast:t}=ee.useToast(),a=U.useEditorInstance(),c=U.useButtonProps($.name),{icon:f,tooltip:h}=(c==null?void 0:c.componentProps)??{},{editorDisabled:x}=U.useToggleActive(),[T,g]=o.useState(!1),[b,A]=o.useState(!1),j=U.useExtension($.name),L=d=>{g(d.detail)},[M,R]=o.useState(""),[_,C]=o.useState(""),S=o.useRef(null),N=(j==null?void 0:j.options.defaultInline)||!1,[v,p]=o.useState(N),u=o.useMemo(()=>j==null?void 0:j.options,[j]);o.useEffect(()=>{const d=Q.listenEvent(Q.EVENTS.UPLOAD_IMAGE(a.id),L);return()=>{d()}},[]);async function k(d){var I;const E=(I=d==null?void 0:d.target)==null?void 0:I.files;if(!a||a.isDestroyed||E.length===0||b){d.target.value="";return}const r=te(E,{acceptMimes:u==null?void 0:u.acceptMimes,maxSize:u==null?void 0:u.maxSize,t:e,toast:t,onError:u.onError});if(r.length<=0){d.target.value="";return}A(!0);try{if(u!=null&&u.multiple){const i=r.map(async m=>{let l="";return u.upload?l=await u.upload(m):l=URL.createObjectURL(m),l});(await Promise.all(i)).forEach(m=>{a.chain().focus().setImageInline({src:m,inline:v,alt:_}).run()})}else{const i=r[0];let s="";u.upload?s=await u.upload(i):s=URL.createObjectURL(i),a.chain().focus().setImageInline({src:s,inline:v,alt:_}).run()}g(!1),C(""),p(N)}catch(i){console.error("Error uploading image",i),u.onError?u.onError({type:"upload",message:e("editor.upload.error")}):t({variant:"destructive",title:e("editor.upload.error")})}finally{A(!1),d.target.value=""}}function D(d){d.preventDefault(),d.stopPropagation(),a.chain().focus().setImageInline({src:M,inline:v,alt:_}).run(),g(!1),p(N),R(""),C("")}function O(d){var E;d.preventDefault(),(E=S.current)==null||E.click()}return c?n.jsxs(z.Dialog,{onOpenChange:g,open:T,children:[n.jsx(z.DialogTrigger,{asChild:!0,children:n.jsx(ie.ActionButton,{disabled:x,icon:f,tooltip:h,action:()=>{x||g(!0)}})}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:e("editor.image.dialog.title")}),n.jsxs(q.Tabs,{activationMode:"manual",defaultValue:u.resourceImage==="both"||u.resourceImage==="upload"?"upload":"link",children:[u.resourceImage==="both"&&n.jsxs(q.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[n.jsx(q.TabsTrigger,{value:"upload",children:e("editor.image.dialog.tab.upload")}),n.jsx(q.TabsTrigger,{value:"link",children:e("editor.image.dialog.tab.url")})]}),n.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[n.jsx(ae.Checkbox,{checked:v,onCheckedChange:d=>{p(d)}}),n.jsx(J.Label,{children:e("editor.link.dialog.inline")})]}),u.enableAlt&&n.jsxs("div",{className:"richtext-my-[10px] ",children:[n.jsx(J.Label,{className:"mb-[6px]",children:e("editor.imageUpload.alt")}),n.jsx(Z.Input,{onChange:d=>C(d.target.value),required:!0,type:"text",value:_})]}),n.jsxs(q.TabsContent,{value:"upload",children:[n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[n.jsx(B.Button,{className:"richtext-mt-1 richtext-w-full",disabled:b,onClick:O,size:"sm",children:b?n.jsxs(n.Fragment,{children:[e("editor.imageUpload.uploading"),n.jsx(P.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):e("editor.image.dialog.tab.upload")}),n.jsx(ce,{alt:_,disabled:b,editor:a,imageInline:v,onClose:()=>{se.actionDialogImage.setOpen(a.id,!1),C("")}})]}),n.jsx("input",{accept:u.acceptMimes.join(",")||"image/*",multiple:u.multiple,onChange:k,ref:S,style:{display:"none"},type:"file"})]}),n.jsx(q.TabsContent,{value:"link",children:n.jsx("form",{onSubmit:D,children:n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[n.jsx(Z.Input,{autoFocus:!0,onChange:d=>R(d.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:M}),n.jsx(B.Button,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]}):n.jsx(n.Fragment,{})}const de={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},$=W.index_default.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...de,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:a,t:c})=>{var f,h;return{componentProps:{action:()=>!0,upload:a.options.upload,disabled:!((h=(f=t.can()).setImage)!=null&&h.call(f,{})),icon:"ImageUp",tooltip:c("editor.image.tooltip")}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const a=t.style.width||t.getAttribute("width")||null;return a?Number.parseInt(a,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})},alt:{default:"",parseHTML:t=>t.getAttribute("alt"),renderHTML:t=>({alt:t.alt})}}},addNodeView(){return G.ReactNodeViewRenderer(le)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:a})=>a.insertContent({type:this.name,attrs:{...t,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:a})=>a.updateAttributes(this.name,t),setAlignImage:t=>({commands:a})=>a.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:a,align:c,inline:f}=e,h=f&&(c==="left"||c==="right"),x=t||a?`transform: rotateX(${t?"180":"0"}deg) rotateY(${a?"180":"0"}deg);`:"",T=h?"":`text-align: ${c};`,A=`${h?`float: ${c};`:""}${h?c==="left"?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${x}`;return[f?"span":"div",{style:T,class:"image"},["img",G.mergeAttributes({height:"auto",style:A},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var h;const t=e==null?void 0:e.parentElement,a=e==null?void 0:e.getAttribute("width"),c=(e==null?void 0:e.getAttribute("flipx"))||!1,f=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||((h=t==null?void 0:t.style)==null?void 0:h.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:c==="true",flipY:f==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),a=t==null?void 0:t.getAttribute("width"),c=(t==null?void 0:t.getAttribute("flipx"))||!1,f=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:a?Number.parseInt(a,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:c==="true",flipY:f==="true"}}},{tag:'img[src]:not([src^="data:"])'}]}});exports.Image=$;exports.RichTextImage=ue;