@remarkablejames/editor 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/lib/{ActionMenuButton-Bmn3RME4.js → ActionMenuButton-D5HLfRzv.js} +9 -10
  2. package/lib/ActionMenuButton-DN6VHLkp.cjs +1 -0
  3. package/lib/Attachment.cjs +2 -2
  4. package/lib/Attachment.js +31 -33
  5. package/lib/Blockquote.cjs +2 -2
  6. package/lib/Blockquote.js +13 -12
  7. package/lib/Bold.cjs +1 -1
  8. package/lib/Bold.js +11 -10
  9. package/lib/BulletList.cjs +1 -1
  10. package/lib/BulletList.js +9 -8
  11. package/lib/Callout.cjs +1 -1
  12. package/lib/Callout.js +41 -45
  13. package/lib/Clear.cjs +1 -1
  14. package/lib/Clear.js +13 -14
  15. package/lib/Code.cjs +1 -1
  16. package/lib/Code.js +6 -5
  17. package/lib/CodeBlock.cjs +1 -1
  18. package/lib/CodeBlock.js +30 -31
  19. package/lib/CodeView.cjs +1 -1
  20. package/lib/CodeView.js +9 -8
  21. package/lib/Color.cjs +1 -1
  22. package/lib/Color.js +18 -19
  23. package/lib/Column.cjs +1 -1
  24. package/lib/Column.js +9 -8
  25. package/lib/{Drawer-DvGh9aXG.js → Drawer-B9l1SoRJ.js} +41 -47
  26. package/lib/Drawer-BN0lYcnJ.cjs +2 -0
  27. package/lib/Drawer.cjs +1 -1
  28. package/lib/Drawer.js +3 -3
  29. package/lib/Emoji.cjs +1 -1
  30. package/lib/Emoji.js +14 -15
  31. package/lib/Excalidraw.cjs +1 -1
  32. package/lib/Excalidraw.js +24 -28
  33. package/lib/ExportPdf.cjs +3 -3
  34. package/lib/ExportPdf.js +14 -13
  35. package/lib/ExportWord.cjs +1 -1
  36. package/lib/ExportWord.js +6 -6
  37. package/lib/FontFamily.cjs +1 -1
  38. package/lib/FontFamily.js +7 -6
  39. package/lib/FontSize.cjs +1 -1
  40. package/lib/FontSize.js +15 -14
  41. package/lib/Heading.cjs +1 -1
  42. package/lib/Heading.js +26 -26
  43. package/lib/Highlight.cjs +1 -1
  44. package/lib/Highlight.js +22 -23
  45. package/lib/History.cjs +1 -1
  46. package/lib/History.js +11 -11
  47. package/lib/HorizontalRule.cjs +1 -1
  48. package/lib/HorizontalRule.js +10 -9
  49. package/lib/Iframe-CXFk3GEq.cjs +1 -0
  50. package/lib/{Iframe-CnnvV6cK.js → Iframe-MjeJ2OOI.js} +11 -13
  51. package/lib/Iframe.cjs +1 -1
  52. package/lib/Iframe.js +2 -2
  53. package/lib/Image.cjs +1 -1
  54. package/lib/Image.js +4 -5
  55. package/lib/ImageGif.cjs +1 -1
  56. package/lib/ImageGif.js +79 -82
  57. package/lib/ImportWord.cjs +1 -1
  58. package/lib/ImportWord.js +25 -26
  59. package/lib/Indent-BPX9XRos.cjs +1 -0
  60. package/lib/{Indent-Bsj8gKvT.js → Indent-CgwDItIf.js} +31 -30
  61. package/lib/Indent.cjs +1 -1
  62. package/lib/Indent.js +2 -2
  63. package/lib/Italic.cjs +1 -1
  64. package/lib/Italic.js +12 -11
  65. package/lib/{Katex-CilGTz7u.js → Katex-CZ4g3vA9.js} +19 -22
  66. package/lib/Katex-DIgsR_dS.cjs +4 -0
  67. package/lib/Katex.cjs +1 -1
  68. package/lib/Katex.js +2 -2
  69. package/lib/LineHeight.cjs +1 -1
  70. package/lib/LineHeight.js +19 -20
  71. package/lib/Link.cjs +1 -1
  72. package/lib/Link.js +2 -2
  73. package/lib/LinkEditBlock-B2bU0Mcr.cjs +5 -0
  74. package/lib/{LinkEditBlock-BD_WvA3r.js → LinkEditBlock-CaDV3Vq5.js} +19 -24
  75. package/lib/Mention.js +3 -3
  76. package/lib/Mermaid-B9h7XKFo.cjs +2 -0
  77. package/lib/{Mermaid-BrjU75Bs.js → Mermaid-EhYj_ICn.js} +45 -48
  78. package/lib/Mermaid.cjs +1 -1
  79. package/lib/Mermaid.js +2 -2
  80. package/lib/MoreMark.cjs +1 -1
  81. package/lib/MoreMark.js +26 -28
  82. package/lib/OrderedList.cjs +1 -1
  83. package/lib/OrderedList.js +11 -10
  84. package/lib/SearchAndReplace.cjs +1 -1
  85. package/lib/SearchAndReplace.js +37 -42
  86. package/lib/SlashCommand.cjs +1 -1
  87. package/lib/SlashCommand.js +5 -5
  88. package/lib/SlashCommandNodeView-COlWSlnE.cjs +1 -0
  89. package/lib/{SlashCommandNodeView-COx5qZ2y.js → SlashCommandNodeView-CY3peX5x.js} +39 -41
  90. package/lib/Strike.cjs +1 -1
  91. package/lib/Strike.js +12 -11
  92. package/lib/{Table-BlM8yMhr.js → Table-Bw7rLue7.js} +46 -46
  93. package/lib/Table-DLrtX6T7.cjs +5 -0
  94. package/lib/Table.cjs +1 -1
  95. package/lib/Table.js +1 -1
  96. package/lib/TaskList.cjs +1 -1
  97. package/lib/TaskList.js +12 -11
  98. package/lib/TextAlign.cjs +1 -1
  99. package/lib/TextAlign.js +26 -27
  100. package/lib/TextDirection.cjs +1 -1
  101. package/lib/TextDirection.js +18 -19
  102. package/lib/TextUnderline.cjs +1 -1
  103. package/lib/TextUnderline.js +9 -8
  104. package/lib/Twitter-Ck6vGefg.cjs +1 -0
  105. package/lib/{Twitter-BP8sYXX7.js → Twitter-pM0y5Z-L.js} +18 -22
  106. package/lib/Twitter.cjs +1 -1
  107. package/lib/Twitter.js +2 -2
  108. package/lib/Video.cjs +1 -1
  109. package/lib/Video.js +4 -5
  110. package/lib/bubble.cjs +3 -3
  111. package/lib/bubble.js +77 -86
  112. package/lib/{clsx-m_C5j3RU.js → clsx-CDyrfCnw.js} +24 -24
  113. package/lib/{dropdown-menu-CkHN04Mx.cjs → dropdown-menu-DwR8tTs9.cjs} +1 -1
  114. package/lib/{dropdown-menu-C1hdPLCZ.js → dropdown-menu-nX-u8e2w.js} +1 -1
  115. package/lib/extensions/Image/Image.d.ts +11 -0
  116. package/lib/extensions/Image/components/ImageCropper.d.ts +1 -1
  117. package/lib/{index-B3Ijnbxs.js → index-C-tDsIKJ.js} +1 -1
  118. package/lib/{index-C1KQsOcg.js → index-C1WCZhyA.js} +1 -1
  119. package/lib/{index-C8FjP66D.js → index-CsSfYR30.js} +1 -1
  120. package/lib/index-Dib4cXXf.cjs +10 -0
  121. package/lib/{index-s3l5RdyW.js → index-DjDf4BK8.js} +1 -1
  122. package/lib/index-_WrFM-Fk.js +5054 -0
  123. package/lib/index.cjs +4 -4
  124. package/lib/index.js +147 -392
  125. package/lib/{popover-B05Fd8lC.cjs → popover-BY7j9SiD.cjs} +1 -1
  126. package/lib/{popover-CsSXh7w6.js → popover-CSvY4C-l.js} +1 -1
  127. package/lib/{renderNodeView-C_hPIdEs.js → renderNodeView-BJSrgyGj.js} +2 -2
  128. package/lib/{select-B3-5wTqn.js → select-BelNLNvT.js} +1 -1
  129. package/lib/{select-7ubC1NF0.cjs → select-Bu-5iIA9.cjs} +1 -1
  130. package/lib/{separator-CYCA8tSn.js → separator-Br5kcIJa.js} +12 -13
  131. package/lib/separator-Cp9Lg3HU.cjs +1 -0
  132. package/lib/style.css +1 -1
  133. package/lib/{textarea-1FhpmBkP.js → textarea-Ceev4t42.js} +1 -1
  134. package/lib/{textarea-Bjhcpp76.cjs → textarea-DfqvYaA6.cjs} +1 -1
  135. package/lib/theme/theme.d.ts +1 -1
  136. package/lib/{updatePosition-DvfTZHcH.js → updatePosition-e90ZrFWW.js} +2 -2
  137. package/package.json +1 -1
  138. package/lib/ActionMenuButton-C5P0Kzrb.cjs +0 -1
  139. package/lib/Drawer-gz9U5ArC.cjs +0 -2
  140. package/lib/Icon-CKM0tYbW.js +0 -15
  141. package/lib/Icon-CQyFgXeo.cjs +0 -1
  142. package/lib/Iframe-Ds6gG2YO.cjs +0 -1
  143. package/lib/ImageCropper-BKhXlnXN.cjs +0 -1
  144. package/lib/ImageCropper-DUzu_9-6.js +0 -896
  145. package/lib/Indent-D_7HOYYd.cjs +0 -1
  146. package/lib/Katex-lL3bHXJd.cjs +0 -4
  147. package/lib/LinkEditBlock-D3HSHmsU.cjs +0 -5
  148. package/lib/Mermaid-BfeLPzoS.cjs +0 -2
  149. package/lib/SlashCommandNodeView-DD-nlhM-.cjs +0 -1
  150. package/lib/Table-C21AlUrh.cjs +0 -5
  151. package/lib/Twitter-D46MnvPr.cjs +0 -1
  152. package/lib/Video-Bpd8W8l6.js +0 -231
  153. package/lib/Video-BwrHx6B1.cjs +0 -1
  154. package/lib/button-BmTP96NR.cjs +0 -1
  155. package/lib/button-CDIxPURh.js +0 -35
  156. package/lib/checkbox-7sfSdzy9.js +0 -29
  157. package/lib/checkbox-DyVlLWHv.cjs +0 -1
  158. package/lib/dialog-B-jOQ5i3.cjs +0 -1
  159. package/lib/dialog-QWWUWOGP.js +0 -95
  160. package/lib/events.constant-Bh2uzJud.js +0 -71
  161. package/lib/events.constant-ELn21EzG.cjs +0 -1
  162. package/lib/file-BLas99n7.js +0 -43
  163. package/lib/file-i7e4nQY2.cjs +0 -1
  164. package/lib/index-CAiZY1nx.js +0 -2741
  165. package/lib/index-DWSAk_9a.cjs +0 -1
  166. package/lib/input-qvpuOf-3.js +0 -21
  167. package/lib/input-s0JD5kf2.cjs +0 -1
  168. package/lib/isNumber-BTYSVlKo.cjs +0 -1
  169. package/lib/isNumber-WaBzl_0s.js +0 -15
  170. package/lib/label-CFax-gzo.cjs +0 -1
  171. package/lib/label-DC37f2RQ.js +0 -11
  172. package/lib/separator-ncbdw4oq.cjs +0 -1
  173. package/lib/tabs-BeHxylKH.js +0 -46
  174. package/lib/tabs-DBqNpGAq.cjs +0 -1
  175. package/lib/throttle-CRNq0z-O.js +0 -249
  176. package/lib/throttle-gTTvqDTW.cjs +0 -1
  177. package/lib/toggle-DoJTBdvy.js +0 -89
  178. package/lib/toggle-oFwBZC4x.cjs +0 -1
  179. package/lib/useButtonProps-BE10eHkG.js +0 -165
  180. package/lib/useButtonProps-CFu0GHzW.cjs +0 -1
@@ -1,2 +0,0 @@
1
- "use strict";const I=require("./clsx-CXbNJWDD.cjs"),$=require("./throttle-gTTvqDTW.cjs"),e=require("react/jsx-runtime"),g=require("react"),B=require("./index-bVGIXhRg.cjs"),O=require("./useButtonProps-CFu0GHzW.cjs"),m=require("easydrawer"),re=require("./toggle-oFwBZC4x.cjs"),P=require("./dialog-B-jOQ5i3.cjs"),p=require("./index-DWSAk_9a.cjs"),oe=require("./file-i7e4nQY2.cjs"),le=require("./button-BmTP96NR.cjs"),W={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ne({editor:t,node:r,updateAttributes:o,getPos:n,selected:v}){const[j,S]=g.useState({width:B.IMAGE_MAX_SIZE,height:B.IMAGE_MAX_SIZE}),[u,a]=g.useState({width:0,height:0}),[M]=g.useState([W.TOP_LEFT,W.TOP_RIGHT,W.BOTTOM_LEFT,W.BOTTOM_RIGHT]),[b,_]=g.useState(!1),[c,h]=g.useState({x:0,y:0,w:0,h:0,dir:""}),{align:T}=r==null?void 0:r.attrs,f=g.useMemo(()=>{const{src:d,alt:E,width:H,height:k}=r==null?void 0:r.attrs,A=I.isNumber(H)?`${H}px`:H,C=I.isNumber(k)?`${k}px`:k;return{src:d||void 0,alt:E||void 0,style:{width:A||void 0,height:C||void 0}}},[r==null?void 0:r.attrs]),s=g.useMemo(()=>{const{style:{width:d}}=f;return{width:d==="100%"?d:void 0}},[f]);function V(d){a({width:d.target.width,height:d.target.height})}const z=g.useCallback(()=>{t.commands.setNodeSelection(n())},[]),D=g.useCallback($.throttle(()=>{const{width:d}=getComputedStyle(t.view.dom);S(E=>({...E,width:Number.parseInt(d,10)}))},B.IMAGE_THROTTLE_WAIT_TIME),[t]);function G(d,E){d.preventDefault(),d.stopPropagation();const H=u.width,k=u.height,A=H/k;let C=Number(r.attrs.width),N=Number(r.attrs.height);const y=j.width;C&&!N?(C=C>y?y:C,N=Math.round(C/A)):N&&!C?(C=Math.round(N*A),C=C>y?y:C):!C&&!N?(C=H>y?y:H,N=Math.round(C/A)):C=C>y?y:C,_(!0),h({x:d.clientX,y:d.clientY,w:C,h:N,dir:E})}const x=g.useCallback($.throttle(d=>{if(d.preventDefault(),d.stopPropagation(),!b)return;const{x:E,w:H,dir:k}=c,A=(d.clientX-E)*(/l/.test(k)?-1:1),{width:C,height:N}=r==null?void 0:r.attrs,y=C/N,Z=O.clamp(H+A,B.IMAGE_MIN_SIZE,j.width),te=Math.round(Z/y);o({width:Z,height:te})},B.IMAGE_THROTTLE_WAIT_TIME),[b,c,j,o,r==null?void 0:r.attrs]),i=g.useCallback(d=>{d.preventDefault(),d.stopPropagation(),b&&(h({x:0,y:0,w:0,h:0,dir:""}),_(!1),z())},[b,z]),w=g.useCallback(()=>{document==null||document.addEventListener("mousemove",x,!0),document==null||document.addEventListener("mouseup",i,!0)},[x,i]),L=g.useCallback(()=>{document==null||document.removeEventListener("mousemove",x,!0),document==null||document.removeEventListener("mouseup",i,!0)},[x,i]);g.useEffect(()=>(b?w():L(),()=>{L()}),[b,w,L]);const q=g.useMemo(()=>new ResizeObserver(()=>D()),[D]);return g.useEffect(()=>(q.observe(t.view.dom),()=>{q.disconnect()}),[t.view.dom,q]),e.jsx(I.NodeViewWrapper,{className:"image-view",style:{...s,width:"100%",textAlign:T},children:e.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...s,background:"#fff"},className:`image-view__body ${v?"image-view__body--focused":""} ${b?"image-view__body--resizing":""}`,children:[e.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:z,onLoad:V,src:f.src,style:f.style}),t.view.editable&&(v||b)&&e.jsx("div",{className:"image-resizer",children:M==null?void 0:M.map(d=>e.jsx("span",{className:`image-resizer__handler image-resizer__handler--${d}`,onMouseDown:E=>G(E,d)},`image-dir-${d}`))})]})})}const F="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",se=t=>{t=t.replace(/\r\n/g,`
2
- `);let r=0,o="";for(;r<t.length;r++){const n=t.charCodeAt(r);n<128?o+=String.fromCharCode(n):n>127&&n<2048?(o+=String.fromCharCode(n>>6|192),o+=String.fromCharCode(63&n|128)):(o+=String.fromCharCode(n>>12|224),o+=String.fromCharCode(n>>6&63|128),o+=String.fromCharCode(63&n|128))}return o},ie=t=>{let r,o,n,v,j,S,u,a=0,M="";for(t=se(t);a<t.length;)r=t.charCodeAt(a++),o=t.charCodeAt(a++),n=t.charCodeAt(a++),v=r>>2,j=(3&r)<<4|o>>4,S=(15&o)<<2|n>>6,u=63&n,isNaN(o)?S=u=64:isNaN(n)&&(u=64),M=M+F.charAt(v)+F.charAt(j)+F.charAt(S)+F.charAt(u);return M},ae=t=>typeof t=="string"?"string":typeof SVGElement<"u"&&t instanceof SVGElement?"element":void 0,K=t=>"data:image/svg+xml;base64,"+ie(t),ce=t=>K(new XMLSerializer().serializeToString(t)),Q=t=>{switch(ae(t)){case"string":return K(t);case"element":return ce(t);default:return t}};function he(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{color:"currentColor",d:"M2 9.2v3.6M12.8 2H9.2M7.5 20H9M20 7.5V9M2.133 4.699c.155-.727.415-1.274.854-1.712c.426-.426.954-.684 1.652-.84m15.228 2.552c-.155-.727-.415-1.274-.854-1.712c-.417-.417-.932-.673-1.608-.83M4.64 19.853c-.698-.156-1.226-.414-1.652-.84c-.43-.43-.69-.965-.845-1.673m11.638 3.626c-1.812.125-3.607-8.326-2.374-9.559s9.684.561 9.559 2.373c-.087 1.187-2.095 1.656-2.037 2.711c.018.309.408.59 1.188 1.154c.543.39 1.096.77 1.629 1.175a.66.66 0 0 1 .234.687a3.35 3.35 0 0 1-2.472 2.473a.66.66 0 0 1-.688-.235c-.404-.533-.784-1.086-1.175-1.628c-.563-.78-.844-1.17-1.153-1.188c-1.055-.059-1.524 1.95-2.71 2.037",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}function ue(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M20.06 18a4 4 0 0 1-.2-.89c-.67.7-1.48 1.05-2.41 1.05c-.83 0-1.52-.24-2.05-.71c-.53-.45-.8-1.06-.8-1.79c0-.88.33-1.56 1-2.05s1.61-.73 2.83-.73h1.4v-.64q0-.735-.45-1.17c-.3-.29-.75-.43-1.33-.43c-.52 0-.95.12-1.3.36c-.35.25-.52.54-.52.89h-1.46c0-.43.15-.84.45-1.24c.28-.4.71-.71 1.22-.94c.51-.21 1.06-.35 1.69-.35c.98 0 1.74.24 2.29.73s.84 1.16.86 2.02V16c0 .8.1 1.42.3 1.88V18zm-2.4-1.12c.45 0 .88-.11 1.29-.32c.4-.21.7-.49.88-.83v-1.57H18.7c-1.77 0-2.66.47-2.66 1.41c0 .43.15.73.46.96c.3.23.68.35 1.16.35m-12.2-3.17h4.07L7.5 8.29zM6.64 6h1.72l4.71 12h-1.93l-.97-2.57H4.82L3.86 18H1.93z",fill:"currentColor"})})}function de(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 21v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM17.6 7.8L19 6.4L17.6 5l-1.4 1.4z",fill:"currentColor"})})}function ge(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M253.66 106.34a8 8 0 0 0-11.32 0L192 156.69L107.31 72l50.35-50.34a8 8 0 1 0-11.32-11.32L96 60.69a16 16 0 0 0-2.82 18.81L72 100.69a16 16 0 0 0 0 22.62l4.69 4.69l-58.35 58.34a8 8 0 0 0 3.13 13.25l72 24A7.9 7.9 0 0 0 96 224a8 8 0 0 0 5.66-2.34L136 187.31l4.69 4.69a16 16 0 0 0 22.62 0l21.19-21.18a16 16 0 0 0 18.81-2.82l50.35-50.34a8 8 0 0 0 0-11.32M93.84 206.85l-55-18.35L88 139.31L124.69 176ZM152 180.69L83.31 112L104 91.31L172.69 160Z",fill:"currentColor"})})}function me(t){return e.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:[e.jsx("path",{d:"m2.648 9.937l7.29-7.288a2.21 2.21 0 0 1 3.124 0l2.29 2.288a2.21 2.21 0 0 1 0 3.126L10.413 13H12.5a.5.5 0 0 1 0 1H4.501a2.2 2.2 0 0 1-1.563-.647l.707-.707c.227.226.535.354.856.354h4.005a1.2 1.2 0 0 0 .848-.354l1.292-1.293l-4-4l-3.29 3.291a1.21 1.21 0 0 0 0 1.712l.29.29l-.708.707l-.29-.29a2.21 2.21 0 0 1 0-3.126M8 6h6.89a1.2 1.2 0 0 0-.246-.356L14 5H9zm2-2h3l-.645-.644a1.21 1.21 0 0 0-1.71 0zm4.89 3H7.708l1 1H14l.644-.644A1.2 1.2 0 0 0 14.891 7zM9.708 9l1.646 1.646L13 9z",fill:"currentColor"}),e.jsx("path",{d:"M14 11.5a.5.5 0 1 1-1 0a.5.5 0 0 1 1 0m1.5-.5a.5.5 0 1 0 0-1a.5.5 0 0 0 0 1m-1 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z",fill:"currentColor"})]})}function pe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function xe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function we(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8",fill:"currentColor"})})}function ve(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M10.363 3.591L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function Ce(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m6.8 21l-5.2-9l5.2-9h10.4l5.2 9l-5.2 9zm1.15-2h8.1l4.025-7l-4.025-7h-8.1L3.9 12zM12 12",fill:"currentColor"})})}function fe(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsxs("g",{fill:"none",fillRule:"evenodd",children:[e.jsx("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),e.jsx("path",{d:"M10.586 2.807a2 2 0 0 1 2.828 0l7.778 7.779a2 2 0 0 1 0 2.828l-7.778 7.778a2 2 0 0 1-2.828 0l-7.778-7.778a2 2 0 0 1 0-2.828zM12 4.222L4.222 12L12 19.778L19.778 12z",fill:"currentColor"})]})})}function Te(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function je(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M7.53 3.47a.75.75 0 0 1 0 1.06L5.81 6.25H15a5.75 5.75 0 0 1 0 11.5H8a.75.75 0 0 1 0-1.5h7a4.25 4.25 0 0 0 0-8.5H5.81l1.72 1.72a.75.75 0 1 1-1.06 1.06l-3-3a.75.75 0 0 1 0-1.06l3-3a.75.75 0 0 1 1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function be(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{clipRule:"evenodd",d:"M16.47 3.47a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a4.25 4.25 0 0 0 0 8.5h7a.75.75 0 0 1 0 1.5H9a5.75 5.75 0 0 1 0-11.5h9.19l-1.72-1.72a.75.75 0 0 1 0-1.06",fill:"currentColor",fillRule:"evenodd"})})}function Se(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function Me(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M211.81 83.79a28 28 0 0 1-33.12 4.83l-90.07 90.07a28 28 0 1 1-44.43-6.48a28 28 0 0 1 33.12-4.83l90.07-90.07a28 28 0 1 1 44.43 6.48",fill:"currentColor"})})}function ye(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12 20.325q-.35 0-.712-.125t-.638-.4l-1.725-1.575q-2.65-2.425-4.788-4.812T2 8.15Q2 5.8 3.575 4.225T7.5 2.65q1.325 0 2.5.562t2 1.538q.825-.975 2-1.537t2.5-.563q2.35 0 3.925 1.575T22 8.15q0 2.875-2.125 5.275T15.05 18.25l-1.7 1.55q-.275.275-.637.4t-.713.125M11.05 6.75q-.725-1.025-1.55-1.563t-2-.537q-1.5 0-2.5 1t-1 2.5q0 1.3.925 2.763t2.213 2.837t2.65 2.575T12 18.3q.85-.775 2.213-1.975t2.65-2.575t2.212-2.837T20 8.15q0-1.5-1-2.5t-2.5-1q-1.175 0-2 .538T12.95 6.75q-.175.25-.425.375T12 7.25t-.525-.125t-.425-.375m.95 4.725",fill:"currentColor"})})}function Ee(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"m7.625 6.4l2.8-3.625q.3-.4.713-.587T12 2t.863.188t.712.587l2.8 3.625l4.25 1.425q.65.2 1.025.738t.375 1.187q0 .3-.088.6t-.287.575l-2.75 3.9l.1 4.1q.025.875-.575 1.475t-1.4.6q-.05 0-.55-.075L12 19.675l-4.475 1.25q-.125.05-.275.063T6.975 21q-.8 0-1.4-.6T5 18.925l.1-4.125l-2.725-3.875q-.2-.275-.288-.575T2 9.75q0-.625.363-1.162t1.012-.763zM8.85 8.125L4 9.725L7.1 14.2L7 18.975l5-1.375l5 1.4l-.1-4.8L20 9.775l-4.85-1.65L12 4zM12 11.5",fill:"currentColor"})})}function He(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M12.01 6c2.61 0 4.89 1.86 5.4 4.43l.3 1.5l1.52.11c1.56.11 2.78 1.41 2.78 2.96c0 1.65-1.35 3-3 3h-13c-2.21 0-4-1.79-4-4c0-2.05 1.53-3.76 3.56-3.97l1.07-.11l.5-.95A5.46 5.46 0 0 1 12.01 6m0-2C9.12 4 6.6 5.64 5.35 8.04C2.35 8.36.01 10.91.01 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.64-4.96C18.68 6.59 15.65 4 12.01 4",fill:"currentColor"})})}function Ne(t){return e.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...t,children:e.jsx("path",{d:"M5.586 6.45A2 2 0 0 1 7.509 5h11.84a2 2 0 0 1 1.923 2.55l-2.858 10A2 2 0 0 1 16.491 19H4.651a2 2 0 0 1-1.923-2.55z",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}const Le="_wrapper_pva9d_1",ke="_tool_pva9d_17",Ae="_active_pva9d_37",_e="_pen_pva9d_41",ze="_line_pva9d_48",qe="_options_pva9d_56",Be="_colorWrap_pva9d_66",Pe="_color_pva9d_66",Re="_colorActive_pva9d_83",l={wrapper:Le,tool:ke,active:Ae,pen:_e,line:ze,options:qe,colorWrap:Be,color:Pe,colorActive:Re},Ie=[m.Color4.blackHighlight,m.Color4.ofRGBA(166/255,81/255,167/255,.3),m.Color4.ofRGBA(247/255,78/255,158/255,.3),m.Color4.ofRGBA(166/255,83/255,88/255,.3),m.Color4.ofRGBA(246/255,130/255,28/255,.3),m.Color4.ofRGBA(166/255,198/255,0,.3),m.Color4.ofRGBA(98/255,186/255,70/255,.3)],X=[m.Color4.black,m.Color4.fromHex("#007AFF"),m.Color4.fromHex("#A651A7"),m.Color4.fromHex("#F74E9E"),m.Color4.fromHex("#FF5358"),m.Color4.fromHex("#F6821C"),m.Color4.fromHex("#FFC600"),m.Color4.fromHex("#62BA46"),m.Color4.fromHex("#E6BFE8"),m.Color4.fromHex("#FEA3D2"),m.Color4.fromHex("#FFA0A3"),m.Color4.fromHex("#FBC276"),m.Color4.fromHex("#FFFB85"),m.Color4.fromHex("#AADC99")];function De({onChange:t}){const[r,o]=g.useState(m.Color4.blackHighlight);return e.jsx("div",{className:l.colorWrap,children:Ie.map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:p.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})}function U({onChange:t}){const[r,o]=g.useState(m.Color4.black);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:l.colorWrap,children:X.slice(0,7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:p.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))}),e.jsx("div",{className:l.colorWrap,children:X.slice(7).map((n,v)=>e.jsx("button",{style:{backgroundColor:n.toHexString()},className:p.cn(l.color,{[l.colorActive]:r.toHexString()===n.toHexString()}),onClick:()=>{o(n),t(n)}},v))})]})}function We({setColorPen:t,setThicknessPen:r}){const[o,n]=g.useState(2);return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(U,{onChange:v=>t(v)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{max:10,min:1,step:.1,type:"range",value:o,onChange:v=>{r(Number.parseFloat(v.target.value)),n(Number.parseFloat(v.target.value))}})})]})}function Fe({setColorHighlight:t}){return e.jsx("div",{className:l.options,children:e.jsx(De,{onChange:r=>t(r)})})}function Oe({changeColorShape:t,changeBorderColorShape:r,onThicknessChange:o}){return e.jsxs("div",{className:l.options,children:[e.jsx("div",{children:e.jsx(U,{onChange:n=>t(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx(U,{onChange:n=>r(n)})}),e.jsx("div",{className:l.line}),e.jsx("div",{children:e.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:n=>{o(Number.parseFloat(n.target.value))}})})]})}function Y(t){const{setColorPen:r,refEditor:o,setThicknessPen:n,setColorHighlight:v,changeBorderColorShape:j,onUndo:S,changeColorShape:u,changeShape:a,onThicknessChange:M,onRedo:b,onClear:_}=t,[c,h]=g.useState(null),[T,f]=g.useState(0);return e.jsx(e.Fragment,{children:e.jsxs("div",{className:l.wrapper,children:[e.jsxs("div",{className:l.pen,children:[e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="select"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(c==="select"){h(null),s[0].setEnabled(!1);return}h("select"),s[0].setEnabled(!0)},children:e.jsx(he,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="text"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(o.current.toolController.setToolEnabled(s[1]),c==="text"){s[1].setEnabled(!1),h(null);return}h("text"),s[1].setEnabled(!0)},children:e.jsx(ue,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="pencil"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(c==="pencil"){h(null),s[2].setEnabled(!1);return}h("pencil"),s[2].setEnabled(!0)},children:e.jsx(de,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="highlighter"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(c==="highlighter"){h(null),s[3].setEnabled(!1);return}h("highlighter"),s[3].setEnabled(!0)},children:e.jsx(ge,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="eraser"}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();if(c==="eraser"){h(null),s[4].setEnabled(!1);return}h("eraser"),s[4].setEnabled(!0)},children:e.jsx(me,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===0}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(0),f(0)},children:e.jsx(pe,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===1}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(1),f(1)},children:e.jsx(xe,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===2}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(2),f(2)},children:e.jsx(we,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===3}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(3),f(3)},children:e.jsx(ve,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===4}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(4),f(4)},children:e.jsx(Ce,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===5}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(5),f(5)},children:e.jsx(fe,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===6}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(6),f(6)},children:e.jsx(Te,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===7}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(7),f(7)},children:e.jsx(Me,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===8}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(8),f(8)},children:e.jsx(ye,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===9}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(9),f(9)},children:e.jsx(Ee,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===10}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(10),f(10)},children:e.jsx(He,{})}),e.jsx("button",{className:p.cn(l.tool,{[l.active]:c==="shapes"&&T===11}),onClick:()=>{const s=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(s[5]),h("shapes"),s[5].setEnabled(!0),a(11),f(11)},children:e.jsx(Ne,{})}),e.jsx("div",{className:l.line}),e.jsx("button",{className:p.cn(l.tool),onClick:S,children:e.jsx(je,{})}),e.jsx("button",{className:p.cn(l.tool),onClick:b,children:e.jsx(be,{})}),e.jsx("button",{className:p.cn(l.tool),onClick:_,children:e.jsx(Se,{})})]}),e.jsxs("div",{className:l.optionsWrap,children:[c==="pencil"&&e.jsx(We,{setColorPen:r,setThicknessPen:n}),c==="highlighter"&&e.jsx(Fe,{setColorHighlight:v}),c==="shapes"&&e.jsx(Oe,{changeBorderColorShape:j,changeColorShape:u,changeShape:a,onThicknessChange:M})]})]})})}function J(t=8){return Math.random().toString(36).substring(2,t+2)}let R=!1;function Ve(){const t=O.useEditorInstance(),r=O.useButtonProps(ee.name),{isActive:o=void 0,upload:n}=(r==null?void 0:r.componentProps)??{},{editorDisabled:v}=O.useToggleActive(o),[j,S]=g.useState(!1),u=g.useRef(null),a=g.useRef(null),M=()=>{(async()=>{const i=document.querySelector("#easydrawer");i&&(u.current=new m.Editor(i,{wheelEventsEnabled:!1,disableZoom:!0}),a.current=m.makeDropdownToolbar(u.current),a.current.addDefaultToolWidgets())})()};g.useEffect(()=>{j&&setTimeout(()=>{M()},200)},[j]);const b=async()=>{if(u.current){const x=u.current.toSVG(),i=x.outerHTML,w=`drawer-${J()}.svg`;let L=Q(x.outerHTML);if(n){const q=oe.dataURLtoFile(L,w);L=await n(q)}t==null||t.chain().focus().setDrawer({type:"drawer",src:L,alt:encodeURIComponent(i),width:426,height:212},!!i).run()}S(!1)},_=x=>{const i=u.current.toolController.getPrimaryTools()[2],w=a.current.getWidgetById("pen-1");i&&w&&(i.setColor(x),w.serializeState())},c=x=>{const i=u.current.toolController.getPrimaryTools()[2],w=a.current.getWidgetById("pen-1");i&&w&&(i.setThickness(x),w.serializeState())},h=x=>{const i=u.current.toolController.getPrimaryTools()[3],w=a.current.getWidgetById("pen-2");i&&w&&(i.setColor(x),w.serializeState())},T=x=>{const i=a.current.getWidgetById("shape");i&&i.setShapeType(x)},f=x=>{const i=u.current.toolController.getPrimaryTools()[5],w=a.current.getWidgetById("shape");i&&w&&(i.setColor(x),w.serializeState())},s=x=>{const i=u.current.toolController.getPrimaryTools()[5],w=a.current.getWidgetById("shape");i&&w&&(i.setThickness(x),w.serializeState())},V=x=>{const i=u.current.toolController.getPrimaryTools()[5],w=a.current.getWidgetById("shape");i&&w&&(i.setBorderColor(x),w.serializeState())},z=()=>{if(R){for(;u.current.history.redoStackSize>0;)u.current.history.redo();R=!1;return}u.current.history.undo()},D=()=>{R||u.current.history.redo()},G=()=>{if(!R){for(;u.current.history.undoStackSize>0;)z();R=!0}};return r?e.jsxs(P.Dialog,{onOpenChange:S,open:j,children:[e.jsx(P.DialogTrigger,{asChild:!0,children:e.jsx(re.ActionButton,{disabled:v,action:()=>{v||S(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),e.jsxs(P.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[e.jsx(P.DialogTitle,{children:"Drawer"}),e.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[e.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),e.jsx(Y,{changeBorderColorShape:V,changeColorShape:f,changeShape:T,onClear:G,onRedo:D,onThicknessChange:s,onUndo:z,refEditor:u,setColorHighlight:h,setColorPen:_,setThicknessPen:c})]}),e.jsx(P.DialogFooter,{children:e.jsx(le.Button,{onClick:b,type:"button",children:"Save changes"})})]})]}):e.jsx(e.Fragment,{})}const ee=$.index_default.extend({name:"richTextDrawer",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({t:r,extension:o})=>{var n;return{componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:r("editor.drawer.tooltip"),upload:(n=o==null?void 0:o.options)==null?void 0:n.upload}}}}},addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),width:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("width");return n?Number.parseInt(n,10):320},renderHTML:r=>({width:r.width})},height:{default:null,parseHTML:r=>{const o=r.querySelector("img"),n=o==null?void 0:o.getAttribute("height");return n?Number.parseInt(n,10):212},renderHTML:r=>({height:r.height})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})}}},addNodeView(){return I.ReactNodeViewRenderer(ne)},addCommands(){return{setDrawer:(t,r)=>({commands:o,editor:n})=>r?o.insertContent({type:this.name,attrs:t}):o.insertContentAt(n.state.selection.anchor,{type:this.name,attrs:t}),setAlignImageDrawer:t=>({commands:r})=>r.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:t}){const{align:r}=t;return["div",{style:r?`text-align: ${r};`:"",class:"imageDrawer"},["img",I.mergeAttributes(this.options.HTMLAttributes,t)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:t=>{const r=t.querySelector("img"),o=r==null?void 0:r.getAttribute("width"),n=r==null?void 0:r.getAttribute("height");return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),width:o?Number.parseInt(o,10):null,height:n?Number.parseInt(n,10):null,align:(r==null?void 0:r.getAttribute("align"))||t.style.textAlign||null}}}]}});exports.ControlDrawer=Y;exports.Drawer=ee;exports.RichTextDrawer=Ve;exports.i=Q;exports.shortId=J;
@@ -1,15 +0,0 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { i } from "./index-CAiZY1nx.js";
3
- function a(n) {
4
- const c = i[n.name];
5
- return c ? /* @__PURE__ */ t(
6
- c,
7
- {
8
- onClick: n == null ? void 0 : n.onClick,
9
- className: `richtext-h-4 richtext-w-4 ${(n == null ? void 0 : n.className) || ""}`
10
- }
11
- ) : null;
12
- }
13
- export {
14
- a as I
15
- };
@@ -1 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),t=require("./index-DWSAk_9a.cjs");function i(n){const c=t.icons[n.name];return c?e.jsx(c,{onClick:n==null?void 0:n.onClick,className:`richtext-h-4 richtext-w-4 ${(n==null?void 0:n.className)||""}`}):null}exports.IconComponent=i;
@@ -1 +0,0 @@
1
- "use strict";const u=require("./clsx-CXbNJWDD.cjs"),s=require("react/jsx-runtime"),y=require("re-resizable"),g=require("react"),h=require("./dom-dataset-BqoJhJXt.cjs"),S=require("./toggle-oFwBZC4x.cjs"),f=require("./useButtonProps-CFu0GHzW.cjs"),I=require("./input-s0JD5kf2.cjs"),P=require("./button-BmTP96NR.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 x(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=f.useEditableEditor(),{src:n,width:c,height:o}=t.attrs,[a,p]=g.useState("");function l(){if(!a)return;const d=x(a);e.chain().updateAttributes(w.name,{src:(d==null?void 0:d.src)||a}).setNodeSelection(e.state.selection.from).focus().run()}const k=g.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(y.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(o)},onResizeStop:(d,X,J,b)=>{k({width:Number.parseInt(c)+b.width,height:Number.parseInt(o)+b.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=f.useButtonProps(w.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}=f.useToggleActive(o),l=()=>{a||c&&(c(),p())};return e?s.jsx(S.ActionButton,{action:l,disabled:a,icon:t,shortcutKeys:r,tooltip:i,tooltipOptions:n}):s.jsx(s.Fragment,{})}const w=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=w;exports.RichTextIframe=O;exports.getServiceSrc=x;
@@ -1 +0,0 @@
1
- "use strict";const i=require("react/jsx-runtime"),c=require("react"),ue=require("react-image-crop"),H=require("./button-BmTP96NR.cjs"),O=require("./dialog-B-jOQ5i3.cjs"),J=require("./clsx-CXbNJWDD.cjs"),K=require("./throttle-gTTvqDTW.cjs"),k=require("./index-bVGIXhRg.cjs"),V=require("./isNumber-BTYSVlKo.cjs"),de=require("./toggle-oFwBZC4x.cjs"),q=require("./useButtonProps-CFu0GHzW.cjs"),ie=require("./file-i7e4nQY2.cjs"),X=require("./Icon-CQyFgXeo.cjs"),U=require("./tabs-DBqNpGAq.cjs"),ge=require("./checkbox-DyVlLWHv.cjs"),ae=require("./label-CFax-gzo.cjs"),re=require("./input-s0JD5kf2.cjs");function he(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const se=he(c),me=1,fe=1e6;let Z=0;function pe(){return Z=(Z+1)%Number.MAX_SAFE_INTEGER,Z.toString()}const Q=new Map;function le(e){if(Q.has(e))return;const t=setTimeout(()=>{Q.delete(e),P({type:"REMOVE_TOAST",toastId:e})},fe);Q.set(e,t)}function xe(e,t){switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,me)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?le(n):e.toasts.forEach(s=>{le(s.id)}),{...e,toasts:e.toasts.map(s=>s.id===n||n===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}}const $=[];let Y={toasts:[]};function P(e){Y=xe(Y,e),$.forEach(t=>{t(Y)})}function be({...e}){const t=pe(),n=d=>P({type:"UPDATE_TOAST",toast:{...d,id:t}}),s=()=>P({type:"DISMISS_TOAST",toastId:t});return P({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:d=>{d||s()}}}),{id:t,dismiss:s,update:n}}function ee(){const[e,t]=se.useState(Y);return se.useEffect(()=>($.push(t),()=>{const n=$.indexOf(t);n>-1&&$.splice(n,1)}),[e]),{...e,toast:be,dismiss:n=>P({type:"DISMISS_TOAST",toastId:n})}}const B={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Ie(e){var p,L,N;const[t,n]=c.useState({width:k.IMAGE_MAX_SIZE,height:k.IMAGE_MAX_SIZE}),[s,d]=c.useState({width:0,height:0}),[h]=c.useState([B.TOP_LEFT,B.TOP_RIGHT,B.BOTTOM_LEFT,B.BOTTOM_RIGHT]),[f,y]=c.useState(!1),[m,b]=c.useState({x:0,y:0,w:0,h:0,dir:""}),{align:A,inline:S}=(p=e==null?void 0:e.node)==null?void 0:p.attrs,E=S&&(A==="left"||A==="right"),M=c.useMemo(()=>{var ne;const{src:o,alt:x,width:a,height:l,flipX:g,flipY:u}=(ne=e==null?void 0:e.node)==null?void 0:ne.attrs,I=V.isNumber(a)?`${a}px`:a,T=V.isNumber(l)?`${l}px`:l,W=[];g&&W.push("rotateX(180deg)"),u&&W.push("rotateY(180deg)");const ce=W.join(" ");return{src:o||void 0,alt:x||void 0,style:{width:I||void 0,height:T||void 0,transform:ce||"none",...E?{float:A}:{}}}},[(L=e==null?void 0:e.node)==null?void 0:L.attrs]),C=c.useMemo(()=>{const{style:{width:o}}=M;return{width:o==="100%"?o:void 0}},[M]);function R(o){d({width:o.target.width,height:o.target.height})}function _(){const{editor:o,getPos:x}=e;o.commands.setNodeSelection(x())}const w=c.useCallback(K.throttle(()=>{const{editor:o}=e,{width:x}=getComputedStyle(o.view.dom);n(a=>({...a,width:Number.parseInt(x,10)}))},k.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function j(o,x){o.preventDefault(),o.stopPropagation();const a=s.width,l=s.height,g=a/l;let u=Number(e.node.attrs.width),I=Number(e.node.attrs.height);const T=t.width;u&&!I?(u=u>T?T:u,I=Math.round(u/g)):I&&!u?(u=Math.round(I*g),u=u>T?T:u):!u&&!I?(u=a>T?T:a,I=Math.round(u/g)):u=u>T?T:u,y(!0),b({x:o.clientX,y:o.clientY,w:u,h:I,dir:x})}const v=c.useCallback(K.throttle(o=>{if(o.preventDefault(),o.stopPropagation(),!f)return;const{x,w:a,dir:l}=m,g=(o.clientX-x)*(/l/.test(l)?-1:1),u=V.clamp(a+g,k.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:u,height:null})},k.IMAGE_THROTTLE_WAIT_TIME),[f,m,t,e.updateAttributes]),r=c.useCallback(o=>{o.preventDefault(),o.stopPropagation(),f&&(b({x:0,y:0,w:0,h:0,dir:""}),y(!1),_())},[f,_]),F=c.useCallback(()=>{document==null||document.addEventListener("mousemove",v,!0),document==null||document.addEventListener("mouseup",r,!0)},[v,r]),D=c.useCallback(()=>{document==null||document.removeEventListener("mousemove",v,!0),document==null||document.removeEventListener("mouseup",r,!0)},[v,r]);c.useEffect(()=>(f?F():D(),()=>{D()}),[f,F,D]);const z=c.useMemo(()=>new ResizeObserver(()=>w()),[w]);return c.useEffect(()=>(z.observe(e.editor.view.dom),()=>{z.disconnect()}),[e.editor.view.dom,z]),i.jsx(J.NodeViewWrapper,{as:S?"span":"div",className:"image-view",style:{float:E?A:void 0,margin:E?A==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:S?"inline":"block",textAlign:E?void 0:A,width:((N=M.style)==null?void 0:N.width)??"auto",...E?{}:C},children:i.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:C,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${f?"image-view__body--resizing":""}`,children:[i.jsx("img",{alt:M.alt,className:"image-view__body__image block",height:"auto",onClick:_,onLoad:R,src:M.src,style:M.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||f)&&i.jsx("div",{className:"image-resizer",children:h==null?void 0:h.map(o=>i.jsx("span",{className:`image-resizer__handler image-resizer__handler--${o}`,onMouseDown:x=>j(x,o)},`image-dir-${o}`))})]})})}function Te(e,t){const n=e.type,s=e.name.toLowerCase(),d=s.split(".").pop();if(!d)return!1;const f=n||{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"}[d];return t.some(y=>{if(y.startsWith("."))return s.endsWith(y);if(y.endsWith("/*")){const m=y.split("/")[0];return f==null?void 0:f.startsWith(m+"/")}return f===y})}function te(e,t){const{acceptMimes:n,maxSize:s,t:d,toast:h}=t,f=[];return(Array.isArray(e)?e:Object.values(e)).forEach(m=>{if(!Te(m,n)){t.onError?t.onError({type:"type",message:d("editor.upload.fileTypeNotSupported",{fileName:m.name}),file:m}):h({variant:"destructive",title:d("editor.upload.fileTypeNotSupported",{fileName:m.name})});return}if(m.size>s){const b=(s/1024/1024).toFixed(2);t.onError?t.onError({type:"size",message:d("editor.upload.fileSizeTooBig",{fileName:m.name,size:b}),file:m}):h({variant:"destructive",title:d("editor.upload.fileSizeTooBig",{fileName:m.name,size:b})});return}f.push(m)}),f}function ye(){const{t:e}=k.useLocale(),{toast:t}=ee(),n=q.useEditorInstance(),s=q.useButtonProps(G.name),{icon:d,tooltip:h}=(s==null?void 0:s.componentProps)??{},{editorDisabled:f}=q.useToggleActive(),[y,m]=c.useState(!1),[b,A]=c.useState(!1),S=q.useExtension(G.name),[E,M]=c.useState(""),[C,R]=c.useState(""),_=c.useRef(null),w=(S==null?void 0:S.options.defaultInline)||!1,[j,v]=c.useState(w),r=c.useMemo(()=>S==null?void 0:S.options,[S]);async function F(p){var o;const L=(o=p==null?void 0:p.target)==null?void 0:o.files;if(!n||n.isDestroyed||L.length===0||b){p.target.value="";return}const N=te(L,{acceptMimes:r==null?void 0:r.acceptMimes,maxSize:r==null?void 0:r.maxSize,t:e,toast:t,onError:r.onError});if(N.length<=0){p.target.value="";return}A(!0);try{if(r!=null&&r.multiple){const x=N.map(async l=>{if(r.upload){const g=await r.upload(l);return{imageId:g.imageId,src:g.cdnUrl}}else return{imageId:void 0,src:URL.createObjectURL(l)}});(await Promise.all(x)).forEach(({imageId:l,src:g})=>{n.chain().focus().setImageInline({imageId:l,src:g,inline:j,alt:C}).run()})}else{const x=N[0];let a,l="";if(r.upload){const g=await r.upload(x);a=g.imageId,l=g.cdnUrl}else l=URL.createObjectURL(x);n.chain().focus().setImageInline({imageId:a,src:l,inline:j,alt:C}).run()}m(!1),R(""),v(w)}catch(x){console.error("Error uploading image",x),r.onError?r.onError({type:"upload",message:e("editor.upload.error")}):t({variant:"destructive",title:e("editor.upload.error")})}finally{A(!1),p.target.value=""}}function D(p){p.preventDefault(),p.stopPropagation(),n.chain().focus().setImageInline({src:E,inline:j,alt:C}).run(),m(!1),v(w),M(""),R("")}function z(p){var L;p.preventDefault(),(L=_.current)==null||L.click()}return s?i.jsxs(O.Dialog,{onOpenChange:m,open:y,children:[i.jsx(O.DialogTrigger,{asChild:!0,children:i.jsx(de.ActionButton,{disabled:f,icon:d,tooltip:h,action:()=>{f||m(!0)}})}),i.jsxs(O.DialogContent,{children:[i.jsx(O.DialogTitle,{children:e("editor.image.dialog.title")}),i.jsxs(U.Tabs,{activationMode:"manual",defaultValue:r.resourceImage==="both"||r.resourceImage==="upload"?"upload":"link",children:[r.resourceImage==="both"&&i.jsxs(U.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[i.jsx(U.TabsTrigger,{value:"upload",children:e("editor.image.dialog.tab.upload")}),i.jsx(U.TabsTrigger,{value:"link",children:e("editor.image.dialog.tab.url")})]}),i.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[i.jsx(ge.Checkbox,{checked:j,onCheckedChange:p=>{v(p)}}),i.jsx(ae.Label,{children:e("editor.link.dialog.inline")})]}),r.enableAlt&&i.jsxs("div",{className:"richtext-my-[10px]",children:[i.jsx(ae.Label,{className:"mb-[6px]",children:e("editor.imageUpload.alt")}),i.jsx(re.Input,{onChange:p=>R(p.target.value),required:!0,type:"text",value:C})]}),i.jsxs(U.TabsContent,{value:"upload",children:[i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[i.jsx(H.Button,{className:"richtext-mt-1 richtext-w-full",disabled:b,onClick:z,size:"sm",children:b?i.jsxs(i.Fragment,{children:[e("editor.imageUpload.uploading"),i.jsx(X.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):e("editor.image.dialog.tab.upload")}),i.jsx(oe,{alt:C,disabled:b,editor:n,imageInline:j,onClose:()=>{R("")}})]}),i.jsx("input",{accept:r.acceptMimes.join(",")||"image/*",multiple:r.multiple,onChange:F,ref:_,style:{display:"none"},type:"file"})]}),i.jsx(U.TabsContent,{value:"link",children:i.jsx("form",{onSubmit:D,children:i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[i.jsx(re.Input,{autoFocus:!0,onChange:p=>M(p.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:E}),i.jsx(H.Button,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]}):i.jsx(i.Fragment,{})}const Se={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},G=K.index_default.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...Se,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:n,t:s})=>{var d,h;return{componentProps:{action:()=>!0,upload:n.options.upload,disabled:!((h=(d=t.can()).setImage)!=null&&h.call(d,{})),icon:"ImageUp",tooltip:s("editor.image.tooltip")}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),imageId:{default:null,parseHTML:t=>t.getAttribute("data-image-id"),renderHTML:t=>t.imageId?{"data-image-id":t.imageId}:{}},flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const n=t.style.width||t.getAttribute("width")||null;return n?Number.parseInt(n,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 J.ReactNodeViewRenderer(Ie)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:n})=>n.insertContent({type:this.name,attrs:{...t,imageId:t.imageId??null,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:n})=>n.updateAttributes(this.name,t),setAlignImage:t=>({commands:n})=>n.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:n,align:s,inline:d}=e,h=d&&(s==="left"||s==="right"),f=t||n?`transform: rotateX(${t?"180":"0"}deg) rotateY(${n?"180":"0"}deg);`:"",y=h?"":`text-align: ${s};`,A=`${h?`float: ${s};`:""}${h?s==="left"?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${f}`;return[d?"span":"div",{style:y,class:"image"},["img",J.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,n=e==null?void 0:e.getAttribute("width"),s=(e==null?void 0:e.getAttribute("flipx"))||!1,d=(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:n?Number.parseInt(n,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:s==="true",flipY:d==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width"),s=(t==null?void 0:t.getAttribute("flipx"))||!1,d=(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:n?Number.parseInt(n,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:s==="true",flipY:d==="true"}}},{tag:'img[src]:not([src^="data:"])'}]}});function oe({editor:e,imageInline:t,onClose:n,disabled:s,alt:d}){var o,x;const{t:h}=k.useLocale(),{toast:f}=ee(),[y,m]=c.useState(!1),[b,A]=c.useState(!1),S=c.useRef(null),[E,M]=c.useState(),[C,R]=c.useState(""),_=c.useRef(null),[w,j]=c.useState({src:"",file:null}),v=q.useExtension(G.name),r=c.useMemo(()=>(v==null?void 0:v.options)??{},[v]);function F(a){if(S.current&&a.width&&a.height){const l=D(S.current,a);R(l)}}function D(a,l){const g=document.createElement("canvas"),u=a.naturalWidth/a.width,I=a.naturalHeight/a.height;g.width=l.width*u,g.height=l.height*I;const T=g.getContext("2d");return T&&(T.imageSmoothingEnabled=!1,T.drawImage(a,l.x*u,l.y*I,l.width*u,l.height*I,0,0,l.width*u,l.height*I)),g.toDataURL("image/png",1)}const z=c.useCallback(async()=>{var a;if(!b){A(!0);try{const l=ie.dataURLtoFile(C,((a=w==null?void 0:w.file)==null?void 0:a.name)||"image.png");let g="";r.upload?g=await r.upload(l):g=URL.createObjectURL(l),e.chain().focus().setImageInline({src:g,inline:t,alt:d}).run(),m(!1),j({src:"",file:null}),N(),n()}catch(l){console.error("Error cropping image",l)}finally{A(!1)}}},[C,e,t,b,n,(o=w==null?void 0:w.file)==null?void 0:o.name,r]);function p(a){var l;a.preventDefault(),(l=_.current)==null||l.click()}const L=async a=>{var T;const l=(T=a==null?void 0:a.target)==null?void 0:T.files;if(!e||e.isDestroyed||l.length===0){a.target.value="";return}const g=te(l,{acceptMimes:r==null?void 0:r.acceptMimes,maxSize:r==null?void 0:r.maxSize,t:h,toast:f,onError:r.onError});if(g.length<=0){a.target.value="";return}const u=g[0],I=await ie.readImageAsBase64(u);m(!0),j({src:I.src,file:u})},N=()=>{_.current&&(_.current.value="")};return i.jsxs(i.Fragment,{children:[i.jsx(H.Button,{className:"richtext-mt-1 richtext-w-full",disabled:s,onClick:p,size:"sm",children:h("editor.image.dialog.tab.uploadCrop")}),i.jsxs(O.Dialog,{open:y,onOpenChange:a=>{m(a),a||(j({src:"",file:null}),N())},children:[i.jsx(O.DialogTrigger,{}),i.jsxs(O.DialogContent,{children:[i.jsx(O.DialogTitle,{children:h("editor.image.dialog.tab.uploadCrop")}),i.jsx("div",{children:w.src&&i.jsx(ue,{className:"richtext-w-full",crop:E,onChange:a=>M(a),onComplete:a=>F(a),children:i.jsx("img",{alt:"Crop me",ref:S,src:w.src})})}),i.jsxs(O.DialogFooter,{children:[i.jsxs(H.Button,{disabled:b,onClick:()=>{m(!1),j({src:"",file:null}),N()},children:[h("editor.imageUpload.cancel"),i.jsx(X.IconComponent,{className:"richtext-ml-1",name:"Trash2"})]}),i.jsx(H.Button,{className:"richtext-w-fit",disabled:b||!E,onClick:z,children:b?i.jsxs(i.Fragment,{children:[h("editor.imageUpload.uploading"),i.jsx(X.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):i.jsxs(i.Fragment,{children:[h("editor.imageUpload.crop"),i.jsx(X.IconComponent,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),i.jsx("input",{accept:((x=r==null?void 0:r.acceptMimes)==null?void 0:x.join(","))||"image/*",multiple:!1,onChange:L,ref:_,style:{display:"none"},type:"file"})]})}exports.Image=G;exports.ImageCropper=oe;exports.RichTextImage=ye;exports.useToast=ee;exports.validateFiles=te;