react-reason-editor 1.0.24 → 1.0.26

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 (99) hide show
  1. package/README.md +24 -0
  2. package/dist/{Attachment-DGzsbPZZ.js → Attachment-FN0H4pdR.js} +2 -2
  3. package/dist/Attachment.js +1 -1
  4. package/dist/BulletList.cjs +1 -1
  5. package/dist/{Callout-heY7R-Zu.js → Callout-C6kKHIbW.js} +2 -2
  6. package/dist/Callout.js +1 -1
  7. package/dist/{CodeBlock-B7Wklup8.js → CodeBlock-DLhI2Guf.js} +1 -1
  8. package/dist/{CodeBlock-D2OKvGCF.cjs → CodeBlock-zh4cX5EA.cjs} +1 -1
  9. package/dist/CodeBlock.cjs +1 -1
  10. package/dist/CodeBlock.js +1 -1
  11. package/dist/CodeView.cjs +1 -1
  12. package/dist/CodeView.js +1 -1
  13. package/dist/{Color-BxzxtvJH.cjs → Color-D5zLljFV.cjs} +1 -1
  14. package/dist/Color.cjs +1 -1
  15. package/dist/{Drawer-DxCO6TBr.cjs → Drawer-B0QvuSOf.cjs} +1 -1
  16. package/dist/{Drawer-Dunw22Q1.js → Drawer-bqo2XUCW.js} +12 -12
  17. package/dist/Drawer.cjs +1 -1
  18. package/dist/Drawer.js +1 -1
  19. package/dist/{Drawio-eqEGDkwW.js → Drawio-CIXM-WGy.js} +4 -4
  20. package/dist/Drawio.js +1 -1
  21. package/dist/{Emoji-BU-itkPp.js → Emoji-CTvSFbHz.js} +3 -3
  22. package/dist/Emoji.js +1 -1
  23. package/dist/FontFamily.js +2 -2
  24. package/dist/{Highlight-BeqLxfbY.cjs → Highlight-DQxtCrNN.cjs} +1 -1
  25. package/dist/Highlight.cjs +1 -1
  26. package/dist/{History-C6yBYB2w.js → History-PbMa-usl.js} +1 -1
  27. package/dist/History.js +1 -1
  28. package/dist/Image.js +1 -1
  29. package/dist/{ImageCropper-Dlz4nJQu.js → ImageCropper-CN_GzBBG.js} +5 -5
  30. package/dist/{ImageGif-D5Qw_Xf-.js → ImageGif-D9goI48J.js} +3 -3
  31. package/dist/ImageGif.js +1 -1
  32. package/dist/{ImportWord-BCcs3dYp.js → ImportWord-Bux3L57d.js} +1 -1
  33. package/dist/ImportWord.js +1 -1
  34. package/dist/{Indent-DpTPoZMk.js → Indent-fBwkYx_q.js} +1 -1
  35. package/dist/Indent.js +1 -1
  36. package/dist/{Katex-D_vF5gsD.cjs → Katex-B1xls7hE.cjs} +1 -1
  37. package/dist/{Katex-Bo_vfXrd.js → Katex-D2g86C-B.js} +3 -3
  38. package/dist/Katex.cjs +1 -1
  39. package/dist/Katex.js +1 -1
  40. package/dist/LineHeight.js +1 -1
  41. package/dist/{Link-C0cNnjXo.js → Link-Dpaom2jX.js} +1 -1
  42. package/dist/Link.js +1 -1
  43. package/dist/{Mention-DEkbeL04.js → Mention-D0HVk1SC.js} +1 -1
  44. package/dist/Mention.js +1 -1
  45. package/dist/{Mermaid-BB15qd24.cjs → Mermaid-3vSlkOlc.cjs} +1 -1
  46. package/dist/Mermaid-B3KGZMBo.js +5 -0
  47. package/dist/Mermaid.cjs +1 -1
  48. package/dist/Mermaid.js +1 -1
  49. package/dist/MoreMark.js +1 -1
  50. package/dist/OrderedList.cjs +1 -1
  51. package/dist/SearchAndReplace.cjs +1 -1
  52. package/dist/SearchAndReplace.js +1 -1
  53. package/dist/{SlashCommand-8LkH8bHy.js → SlashCommand-ZFZhrxKb.js} +1 -1
  54. package/dist/SlashCommand.js +1 -1
  55. package/dist/{Table-C9t-k9Qu.js → Table-6kM52sUH.js} +2 -2
  56. package/dist/Table.js +1 -1
  57. package/dist/TaskList.cjs +1 -1
  58. package/dist/{TextAlign-C75gn_OM.js → TextAlign-BKo82ocx.js} +1 -1
  59. package/dist/TextAlign.js +1 -1
  60. package/dist/TextDirection.js +1 -1
  61. package/dist/{Twitter-DyrQT0n4.cjs → Twitter-3yCP2UdP.cjs} +1 -1
  62. package/dist/{Twitter-D5UNfT-K.js → Twitter-D38giVew.js} +2 -2
  63. package/dist/Twitter.cjs +1 -1
  64. package/dist/Twitter.js +1 -1
  65. package/dist/{Video-_YlAC2R_.js → Video-DcfPDZLP.js} +3 -3
  66. package/dist/Video.js +1 -1
  67. package/dist/WordCount.js +1 -1
  68. package/dist/{bubble---c27x7L.js → bubble-4RecyKlX.js} +1 -1
  69. package/dist/bubble.cjs +1 -1
  70. package/dist/bubble.js +1 -1
  71. package/dist/editor-kit.cjs +1 -0
  72. package/dist/editor-kit.d.ts +13 -0
  73. package/dist/editor-kit.js +1 -0
  74. package/dist/editor-views/components/AlignToolbar.d.ts +4 -0
  75. package/dist/editor-views/components/BubbleMenus.d.ts +4 -0
  76. package/dist/editor-views/components/EditorContainer.d.ts +10 -0
  77. package/dist/editor-views/components/Header.d.ts +8 -0
  78. package/dist/editor-views/components/Toolbar.d.ts +26 -0
  79. package/dist/editor-views/components/constants.d.ts +14 -0
  80. package/dist/editor-views/components/extensions.d.ts +8 -0
  81. package/dist/editor-views/components/index.d.ts +9 -0
  82. package/dist/editor-views/config/baseKit.d.ts +7 -0
  83. package/dist/editor-views/config/editorConfig.d.ts +37 -0
  84. package/dist/editor-views/config/pluginRegistry.d.ts +43 -0
  85. package/dist/editorConfig-Cgs4P8O5.js +184 -0
  86. package/dist/editorConfig-CnzPmOCy.cjs +1 -0
  87. package/dist/html-to-docx.esm-DkztZsL5-BqrjWkoQ.cjs +1 -0
  88. package/dist/index.cjs +1 -1
  89. package/dist/index.js +1 -1
  90. package/dist/reason-docs.cjs +1 -1
  91. package/dist/reason-docs.js +1 -1
  92. package/dist/{separator-BHN46aj5.cjs → separator-CXjMk9dM.cjs} +1 -1
  93. package/dist/src-73l1pSjp.js +463 -0
  94. package/dist/src-CF0U82SA.cjs +1 -0
  95. package/package.json +12 -2
  96. package/dist/Mermaid-DxpFRVu0.js +0 -5
  97. package/dist/html-to-docx.esm-DkztZsL5-DQYdhD3B.cjs +0 -1
  98. package/dist/src-C7k3RYxJ.js +0 -646
  99. package/dist/src-DYbBlAjR.cjs +0 -1
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./dist-Cn_OUKh6.cjs"),r=require("./toggle-CRftKzl0.cjs"),o=require("./locales-Dg9XL0yP.cjs"),l=require("./button-CYMsgP3Y.cjs"),n=require("./dialog-CxZ2oxD2.cjs"),s=require("./throttle-COe5rswR.cjs"),i=require("./useButtonProps-D2Hd5DbR.cjs"),a=require("./file-B1Z0XcVJ.cjs"),c=require("./shortId-B25DIOpW.cjs");let h=require("@tiptap/react"),d=require("react");d=e.__toESM(d,1);let u=require("react/jsx-runtime"),g=require("@tiptap/core"),m=require("easydrawer");var x="tl",p="tr",w="bl",v="br";function C({editor:e,node:t,updateAttributes:r,getPos:l,selected:n}){const[a,c]=(0,d.useState)({width:o.IMAGE_MAX_SIZE,height:o.IMAGE_MAX_SIZE}),[g,m]=(0,d.useState)({width:0,height:0}),[C]=(0,d.useState)([x,p,w,v]),[j,b]=(0,d.useState)(!1),[f,T]=(0,d.useState)({x:0,y:0,w:0,h:0,dir:""}),{align:y}=t.attrs,k=(0,d.useMemo)(()=>{const{src:e,alt:r,width:o,height:l}=t.attrs;return{src:e||void 0,alt:r||void 0,style:{width:((0,h.isNumber)(o)?`${o}px`:o)||void 0,height:((0,h.isNumber)(l)?`${l}px`:l)||void 0}}},[t?.attrs]),N=(0,d.useMemo)(()=>{const{style:{width:e}}=k;return{width:"100%"===e?e:void 0}},[k]);const H=(0,d.useCallback)(()=>{e.commands.setNodeSelection(l())},[]),M=(0,d.useCallback)(s.throttle(()=>{const{width:t}=getComputedStyle(e.view.dom);c(e=>({...e,width:Number.parseInt(t,10)}))},16),[e]);const E=(0,d.useCallback)(s.throttle(e=>{if(e.preventDefault(),e.stopPropagation(),!j)return;const{x:o,w:l,dir:n}=f,s=(e.clientX-o)*(/l/.test(n)?-1:1),{width:c,height:h}=t.attrs,d=c/h,u=i.clamp(l+s,20,a.width);r({width:u,height:Math.round(u/d)})},16),[j,f,a,r,t?.attrs]),L=(0,d.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j&&(T({x:0,y:0,w:0,h:0,dir:""}),b(!1),H())},[j,H]),q=(0,d.useCallback)(()=>{document?.addEventListener("mousemove",E,!0),document?.addEventListener("mouseup",L,!0)},[E,L]),A=(0,d.useCallback)(()=>{document?.removeEventListener("mousemove",E,!0),document?.removeEventListener("mouseup",L,!0)},[E,L]);(0,d.useEffect)(()=>(j?q():A(),()=>{A()}),[j,q,A]);const S=(0,d.useMemo)(()=>new ResizeObserver(()=>M()),[M]);return(0,d.useEffect)(()=>(S.observe(e.view.dom),()=>{S.disconnect()}),[e.view.dom,S]),(0,u.jsx)(h.NodeViewWrapper,{className:"image-view",style:{...N,width:"100%",textAlign:y},children:(0,u.jsxs)("div",{"data-drag-handle":!0,draggable:"true",style:{...N,background:"#fff"},className:`image-view__body ${n?"image-view__body--focused":""} ${j?"image-view__body--resizing":""}`,children:[(0,u.jsx)("img",{alt:k.alt,className:"image-view__body__image block",height:"auto",onClick:H,onLoad:function(e){m({width:e.target.width,height:e.target.height})},src:k.src,style:k.style}),e.view.editable&&(n||j)&&(0,u.jsx)("div",{className:"image-resizer",children:C?.map(e=>(0,u.jsx)("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:r=>function(e,r){e.preventDefault(),e.stopPropagation();const o=g.width,l=o/g.height;let n=Number(t.attrs.width),s=Number(t.attrs.height);const i=a.width;n&&!s?(n=n>i?i:n,s=Math.round(n/l)):s&&!n?(n=Math.round(s*l),n=n>i?i:n):n||s?n=n>i?i:n:(n=o>i?i:o,s=Math.round(n/l)),b(!0),T({x:e.clientX,y:e.clientY,w:n,h:s,dir:r})}(r,e)},`image-dir-${e}`))})]})})}function j(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 b(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 f(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 T(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 y(e){return(0,u.jsxs)("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,u.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"}),(0,u.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 k(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function N(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function H(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 M(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 E(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 L(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,u.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"}),(0,u.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 q(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function A(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 S(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 _(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function B(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 P(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 z(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 D(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 F(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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"})})}var R={wrapper:"_wrapper_pva9d_1",tool:"_tool_pva9d_17",active:"_active_pva9d_37",pen:"_pen_pva9d_41",line:"_line_pva9d_48",options:"_options_pva9d_56",colorWrap:"_colorWrap_pva9d_66",color:"_color_pva9d_66",colorActive:"_colorActive_pva9d_83"},I=[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)],W=[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 V({onChange:e}){const[r,o]=(0,d.useState)(m.Color4.blackHighlight);return(0,u.jsx)("div",{className:R.colorWrap,children:I.map((l,n)=>(0,u.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))})}function G({onChange:e}){const[r,o]=(0,d.useState)(m.Color4.black);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:R.colorWrap,children:W.slice(0,7).map((l,n)=>(0,u.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))}),(0,u.jsx)("div",{className:R.colorWrap,children:W.slice(7).map((l,n)=>(0,u.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))})]})}function $({setColorPen:e,setThicknessPen:t}){const[r,o]=(0,d.useState)(2);return(0,u.jsxs)("div",{className:R.options,children:[(0,u.jsx)("div",{children:(0,u.jsx)(G,{onChange:t=>e(t)})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("div",{children:(0,u.jsx)("input",{max:10,min:1,step:.1,type:"range",value:r,onChange:e=>{t(Number.parseFloat(e.target.value)),o(Number.parseFloat(e.target.value))}})})]})}function O({setColorHighlight:e}){return(0,u.jsx)("div",{className:R.options,children:(0,u.jsx)(V,{onChange:t=>e(t)})})}function Z({changeColorShape:e,changeBorderColorShape:t,onThicknessChange:r}){return(0,u.jsxs)("div",{className:R.options,children:[(0,u.jsx)("div",{children:(0,u.jsx)(G,{onChange:t=>e(t)})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("div",{children:(0,u.jsx)(G,{onChange:e=>t(e)})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("div",{children:(0,u.jsx)("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:e=>{r(Number.parseFloat(e.target.value))}})})]})}function U(e){const{setColorPen:r,refEditor:o,setThicknessPen:l,setColorHighlight:n,changeBorderColorShape:s,onUndo:i,changeColorShape:a,changeShape:c,onThicknessChange:h,onRedo:g,onClear:m}=e,[x,p]=(0,d.useState)(null),[w,v]=(0,d.useState)(0);return(0,u.jsx)(u.Fragment,{children:(0,u.jsxs)("div",{className:R.wrapper,children:[(0,u.jsxs)("div",{className:R.pen,children:[(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"select"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("select"===x)return p(null),void e[0].setEnabled(!1);p("select"),e[0].setEnabled(!0)},children:(0,u.jsx)(j,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"text"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if(o.current.toolController.setToolEnabled(e[1]),"text"===x)return e[1].setEnabled(!1),void p(null);p("text"),e[1].setEnabled(!0)},children:(0,u.jsx)(b,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"pencil"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("pencil"===x)return p(null),void e[2].setEnabled(!1);p("pencil"),e[2].setEnabled(!0)},children:(0,u.jsx)(f,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"highlighter"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("highlighter"===x)return p(null),void e[3].setEnabled(!1);p("highlighter"),e[3].setEnabled(!0)},children:(0,u.jsx)(T,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"eraser"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("eraser"===x)return p(null),void e[4].setEnabled(!1);p("eraser"),e[4].setEnabled(!0)},children:(0,u.jsx)(y,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&0===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(0),v(0)},children:(0,u.jsx)(k,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&1===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(1),v(1)},children:(0,u.jsx)(N,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&2===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(2),v(2)},children:(0,u.jsx)(H,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&3===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(3),v(3)},children:(0,u.jsx)(M,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&4===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(4),v(4)},children:(0,u.jsx)(E,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&5===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(5),v(5)},children:(0,u.jsx)(L,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&6===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(6),v(6)},children:(0,u.jsx)(q,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&7===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(7),v(7)},children:(0,u.jsx)(B,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&8===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(8),v(8)},children:(0,u.jsx)(P,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&9===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(9),v(9)},children:(0,u.jsx)(z,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&10===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(10),v(10)},children:(0,u.jsx)(D,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&11===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(11),v(11)},children:(0,u.jsx)(F,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool),onClick:i,children:(0,u.jsx)(A,{})}),(0,u.jsx)("button",{className:t.cn(R.tool),onClick:g,children:(0,u.jsx)(S,{})}),(0,u.jsx)("button",{className:t.cn(R.tool),onClick:m,children:(0,u.jsx)(_,{})})]}),(0,u.jsxs)("div",{className:R.optionsWrap,children:["pencil"===x&&(0,u.jsx)($,{setColorPen:r,setThicknessPen:l}),"highlighter"===x&&(0,u.jsx)(O,{setColorHighlight:n}),"shapes"===x&&(0,u.jsx)(Z,{changeBorderColorShape:s,changeColorShape:a,changeShape:c,onThicknessChange:h})]})]})})}var X=!1;function Q(){const e=i.useEditorInstance(),t=i.useButtonProps(Y.name),{isActive:o,upload:s}=t?.componentProps??{},{editorDisabled:h}=i.useToggleActive(o),[g,x]=(0,d.useState)(!1),p=(0,d.useRef)(null),w=(0,d.useRef)(null);(0,d.useEffect)(()=>{g&&setTimeout(()=>{(async()=>{const e=document.querySelector("#easydrawer");e&&(p.current=new m.Editor(e,{wheelEventsEnabled:!1,disableZoom:!0}),w.current=(0,m.makeDropdownToolbar)(p.current),w.current.addDefaultToolWidgets())})()},200)},[g]);const v=()=>{if(X){for(;p.current.history.redoStackSize>0;)p.current.history.redo();X=!1}else p.current.history.undo()};return t?(0,u.jsxs)(n.Dialog,{onOpenChange:x,open:g,children:[(0,u.jsx)(n.DialogTrigger,{asChild:!0,children:(0,u.jsx)(r.ActionButton,{disabled:h,action:()=>{h||x(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),(0,u.jsxs)(n.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,u.jsx)(n.DialogTitle,{children:"Drawer"}),(0,u.jsxs)("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[(0,u.jsx)("div",{className:"richtext-size-full",id:"easydrawer"}),(0,u.jsx)(U,{changeBorderColorShape:e=>{const t=p.current.toolController.getPrimaryTools()[5],r=w.current.getWidgetById("shape");t&&r&&(t.setBorderColor(e),r.serializeState())},changeColorShape:e=>{const t=p.current.toolController.getPrimaryTools()[5],r=w.current.getWidgetById("shape");t&&r&&(t.setColor(e),r.serializeState())},changeShape:e=>{const t=w.current.getWidgetById("shape");t&&t.setShapeType(e)},onClear:()=>{if(!X){for(;p.current.history.undoStackSize>0;)v();X=!0}},onRedo:()=>{X||p.current.history.redo()},onThicknessChange:e=>{const t=p.current.toolController.getPrimaryTools()[5],r=w.current.getWidgetById("shape");t&&r&&(t.setThickness(e),r.serializeState())},onUndo:v,refEditor:p,setColorHighlight:e=>{const t=p.current.toolController.getPrimaryTools()[3],r=w.current.getWidgetById("pen-2");t&&r&&(t.setColor(e),r.serializeState())},setColorPen:e=>{const t=p.current.toolController.getPrimaryTools()[2],r=w.current.getWidgetById("pen-1");t&&r&&(t.setColor(e),r.serializeState())},setThicknessPen:e=>{const t=p.current.toolController.getPrimaryTools()[2],r=w.current.getWidgetById("pen-1");t&&r&&(t.setThickness(e),r.serializeState())}})]}),(0,u.jsx)(n.DialogFooter,{children:(0,u.jsx)(l.Button,{onClick:async()=>{if(p.current){const t=p.current.toSVG(),r=t.outerHTML,o=`drawer-${c.shortId()}.svg`;let l=c.i(t.outerHTML);if(s){const e=a.dataURLtoFile(l,o);l=await s(e)}e?.chain().focus().setDrawer({type:"drawer",src:l,alt:encodeURIComponent(r),width:426,height:212},!!r).run()}x(!1)},type:"button",children:"Save changes"})})]})]}):(0,u.jsx)(u.Fragment,{})}var Y=s.index_default.extend({name:"richTextDrawer",addOptions(){return{...this.parent?.(),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({t:e,extension:t})=>({componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:e("editor.drawer.tooltip"),upload:t?.options?.upload}})}},addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{const t=e.querySelector("img")?.getAttribute("width");return t?Number.parseInt(t,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const t=e.querySelector("img")?.getAttribute("height");return t?Number.parseInt(t,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView:()=>(0,h.ReactNodeViewRenderer)(C),addCommands(){return{setDrawer:(e,t)=>({commands:r,editor:o})=>t?r.insertContent({type:this.name,attrs:e}):r.insertContentAt(o.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageDrawer:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageDrawer"},["img",(0,g.mergeAttributes)(this.options.HTMLAttributes,e)]]},parseHTML:()=>[{tag:"div[class=imageDrawer]",getAttrs:e=>{const t=e.querySelector("img"),r=t?.getAttribute("width"),o=t?.getAttribute("height");return{src:t?.getAttribute("src"),alt:t?.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:o?Number.parseInt(o,10):null,align:t?.getAttribute("align")||e.style.textAlign||null}}}]});Object.defineProperty(exports,"ControlDrawer",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"Drawer",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"RichTextDrawer",{enumerable:!0,get:function(){return Q}});
1
+ const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./dist-Cn_OUKh6.cjs"),r=require("./toggle-CRftKzl0.cjs"),o=require("./locales-Dg9XL0yP.cjs"),l=require("./button-CYMsgP3Y.cjs"),n=require("./dialog-CxZ2oxD2.cjs"),s=require("./throttle-COe5rswR.cjs"),i=require("./useButtonProps-D2Hd5DbR.cjs"),a=require("./file-B1Z0XcVJ.cjs"),c=require("./shortId-B25DIOpW.cjs");let h=require("@tiptap/react"),d=require("react");d=e.__toESM(d,1);let u=require("react/jsx-runtime"),g=require("@tiptap/core"),m=require("easydrawer");var x="tl",p="tr",w="bl",v="br";function C({editor:e,node:t,updateAttributes:r,getPos:l,selected:n}){const[a,c]=(0,d.useState)({width:o.IMAGE_MAX_SIZE,height:o.IMAGE_MAX_SIZE}),[g,m]=(0,d.useState)({width:0,height:0}),[C]=(0,d.useState)([x,p,w,v]),[j,b]=(0,d.useState)(!1),[f,T]=(0,d.useState)({x:0,y:0,w:0,h:0,dir:""}),{align:y}=t.attrs,k=(0,d.useMemo)(()=>{const{src:e,alt:r,width:o,height:l}=t.attrs;return{src:e||void 0,alt:r||void 0,style:{width:((0,h.isNumber)(o)?`${o}px`:o)||void 0,height:((0,h.isNumber)(l)?`${l}px`:l)||void 0}}},[t?.attrs]),H=(0,d.useMemo)(()=>{const{style:{width:e}}=k;return{width:"100%"===e?e:void 0}},[k]);const N=(0,d.useCallback)(()=>{e.commands.setNodeSelection(l())},[]),M=(0,d.useCallback)(s.throttle(()=>{const{width:t}=getComputedStyle(e.view.dom);c(e=>({...e,width:Number.parseInt(t,10)}))},16),[e]);const E=(0,d.useCallback)(s.throttle(e=>{if(e.preventDefault(),e.stopPropagation(),!j)return;const{x:o,w:l,dir:n}=f,s=(e.clientX-o)*(/l/.test(n)?-1:1),{width:c,height:h}=t.attrs,d=c/h,u=i.clamp(l+s,20,a.width);r({width:u,height:Math.round(u/d)})},16),[j,f,a,r,t?.attrs]),L=(0,d.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),j&&(T({x:0,y:0,w:0,h:0,dir:""}),b(!1),N())},[j,N]),q=(0,d.useCallback)(()=>{document?.addEventListener("mousemove",E,!0),document?.addEventListener("mouseup",L,!0)},[E,L]),A=(0,d.useCallback)(()=>{document?.removeEventListener("mousemove",E,!0),document?.removeEventListener("mouseup",L,!0)},[E,L]);(0,d.useEffect)(()=>(j?q():A(),()=>{A()}),[j,q,A]);const S=(0,d.useMemo)(()=>new ResizeObserver(()=>M()),[M]);return(0,d.useEffect)(()=>(S.observe(e.view.dom),()=>{S.disconnect()}),[e.view.dom,S]),(0,u.jsx)(h.NodeViewWrapper,{className:"image-view",style:{...H,width:"100%",textAlign:y},children:(0,u.jsxs)("div",{"data-drag-handle":!0,draggable:"true",style:{...H,background:"#fff"},className:`image-view__body ${n?"image-view__body--focused":""} ${j?"image-view__body--resizing":""}`,children:[(0,u.jsx)("img",{alt:k.alt,className:"image-view__body__image block",height:"auto",onClick:N,onLoad:function(e){m({width:e.target.width,height:e.target.height})},src:k.src,style:k.style}),e.view.editable&&(n||j)&&(0,u.jsx)("div",{className:"image-resizer",children:C?.map(e=>(0,u.jsx)("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:r=>function(e,r){e.preventDefault(),e.stopPropagation();const o=g.width,l=o/g.height;let n=Number(t.attrs.width),s=Number(t.attrs.height);const i=a.width;n&&!s?(n=n>i?i:n,s=Math.round(n/l)):s&&!n?(n=Math.round(s*l),n=n>i?i:n):n||s?n=n>i?i:n:(n=o>i?i:o,s=Math.round(n/l)),b(!0),T({x:e.clientX,y:e.clientY,w:n,h:s,dir:r})}(r,e)},`image-dir-${e}`))})]})})}function j(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 b(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 f(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 T(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 y(e){return(0,u.jsxs)("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,u.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"}),(0,u.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 k(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function H(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function N(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 M(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 E(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 L(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,u.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"}),(0,u.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 q(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function A(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 S(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 _(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.jsx)("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function B(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 P(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 z(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 D(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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 F(e){return(0,u.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,u.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"})})}var R={wrapper:"_wrapper_pva9d_1",tool:"_tool_pva9d_17",active:"_active_pva9d_37",pen:"_pen_pva9d_41",line:"_line_pva9d_48",options:"_options_pva9d_56",colorWrap:"_colorWrap_pva9d_66",color:"_color_pva9d_66",colorActive:"_colorActive_pva9d_83"},I=[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)],W=[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 V({onChange:e}){const[r,o]=(0,d.useState)(m.Color4.blackHighlight);return(0,u.jsx)("div",{className:R.colorWrap,children:I.map((l,n)=>(0,u.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))})}function G({onChange:e}){const[r,o]=(0,d.useState)(m.Color4.black);return(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:R.colorWrap,children:W.slice(0,7).map((l,n)=>(0,u.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))}),(0,u.jsx)("div",{className:R.colorWrap,children:W.slice(7).map((l,n)=>(0,u.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))})]})}function $({setColorPen:e,setThicknessPen:t}){const[r,o]=(0,d.useState)(2);return(0,u.jsxs)("div",{className:R.options,children:[(0,u.jsx)("div",{children:(0,u.jsx)(G,{onChange:t=>e(t)})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("div",{children:(0,u.jsx)("input",{max:10,min:1,step:.1,type:"range",value:r,onChange:e=>{t(Number.parseFloat(e.target.value)),o(Number.parseFloat(e.target.value))}})})]})}function O({setColorHighlight:e}){return(0,u.jsx)("div",{className:R.options,children:(0,u.jsx)(V,{onChange:t=>e(t)})})}function Z({changeColorShape:e,changeBorderColorShape:t,onThicknessChange:r}){return(0,u.jsxs)("div",{className:R.options,children:[(0,u.jsx)("div",{children:(0,u.jsx)(G,{onChange:t=>e(t)})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("div",{children:(0,u.jsx)(G,{onChange:e=>t(e)})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("div",{children:(0,u.jsx)("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:e=>{r(Number.parseFloat(e.target.value))}})})]})}function U(e){const{setColorPen:r,refEditor:o,setThicknessPen:l,setColorHighlight:n,changeBorderColorShape:s,onUndo:i,changeColorShape:a,changeShape:c,onThicknessChange:h,onRedo:g,onClear:m}=e,[x,p]=(0,d.useState)(null),[w,v]=(0,d.useState)(0);return(0,u.jsx)(u.Fragment,{children:(0,u.jsxs)("div",{className:R.wrapper,children:[(0,u.jsxs)("div",{className:R.pen,children:[(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"select"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("select"===x)return p(null),void e[0].setEnabled(!1);p("select"),e[0].setEnabled(!0)},children:(0,u.jsx)(j,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"text"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if(o.current.toolController.setToolEnabled(e[1]),"text"===x)return e[1].setEnabled(!1),void p(null);p("text"),e[1].setEnabled(!0)},children:(0,u.jsx)(b,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"pencil"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("pencil"===x)return p(null),void e[2].setEnabled(!1);p("pencil"),e[2].setEnabled(!0)},children:(0,u.jsx)(f,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"highlighter"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("highlighter"===x)return p(null),void e[3].setEnabled(!1);p("highlighter"),e[3].setEnabled(!0)},children:(0,u.jsx)(T,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"eraser"===x}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();if("eraser"===x)return p(null),void e[4].setEnabled(!1);p("eraser"),e[4].setEnabled(!0)},children:(0,u.jsx)(y,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&0===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(0),v(0)},children:(0,u.jsx)(k,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&1===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(1),v(1)},children:(0,u.jsx)(H,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&2===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(2),v(2)},children:(0,u.jsx)(N,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&3===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(3),v(3)},children:(0,u.jsx)(M,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&4===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(4),v(4)},children:(0,u.jsx)(E,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&5===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(5),v(5)},children:(0,u.jsx)(L,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&6===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(6),v(6)},children:(0,u.jsx)(q,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&7===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(7),v(7)},children:(0,u.jsx)(B,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&8===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(8),v(8)},children:(0,u.jsx)(P,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&9===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(9),v(9)},children:(0,u.jsx)(z,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&10===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(10),v(10)},children:(0,u.jsx)(D,{})}),(0,u.jsx)("button",{className:t.cn(R.tool,{[R.active]:"shapes"===x&&11===w}),onClick:()=>{const e=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(e[5]),p("shapes"),e[5].setEnabled(!0),c(11),v(11)},children:(0,u.jsx)(F,{})}),(0,u.jsx)("div",{className:R.line}),(0,u.jsx)("button",{className:t.cn(R.tool),onClick:i,children:(0,u.jsx)(A,{})}),(0,u.jsx)("button",{className:t.cn(R.tool),onClick:g,children:(0,u.jsx)(S,{})}),(0,u.jsx)("button",{className:t.cn(R.tool),onClick:m,children:(0,u.jsx)(_,{})})]}),(0,u.jsxs)("div",{className:R.optionsWrap,children:["pencil"===x&&(0,u.jsx)($,{setColorPen:r,setThicknessPen:l}),"highlighter"===x&&(0,u.jsx)(O,{setColorHighlight:n}),"shapes"===x&&(0,u.jsx)(Z,{changeBorderColorShape:s,changeColorShape:a,changeShape:c,onThicknessChange:h})]})]})})}var X=!1;function Q(){const e=i.useEditorInstance(),t=i.useButtonProps(Y.name),{isActive:o,upload:s}=t?.componentProps??{},{editorDisabled:h}=i.useToggleActive(o),[g,x]=(0,d.useState)(!1),p=(0,d.useRef)(null),w=(0,d.useRef)(null);(0,d.useEffect)(()=>{g&&setTimeout(()=>{(async()=>{const e=document.querySelector("#easydrawer");e&&(p.current=new m.Editor(e,{wheelEventsEnabled:!1,disableZoom:!0}),w.current=(0,m.makeDropdownToolbar)(p.current),w.current.addDefaultToolWidgets())})()},200)},[g]);const v=()=>{if(X){for(;p.current.history.redoStackSize>0;)p.current.history.redo();X=!1}else p.current.history.undo()};return t?(0,u.jsxs)(n.Dialog,{onOpenChange:x,open:g,children:[(0,u.jsx)(n.DialogTrigger,{asChild:!0,children:(0,u.jsx)(r.ActionButton,{disabled:h,action:()=>{h||x(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),(0,u.jsxs)(n.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,u.jsx)(n.DialogTitle,{children:"Drawer"}),(0,u.jsxs)("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[(0,u.jsx)("div",{className:"richtext-size-full",id:"easydrawer"}),(0,u.jsx)(U,{changeBorderColorShape:e=>{const t=p.current.toolController.getPrimaryTools()[5],r=w.current.getWidgetById("shape");t&&r&&(t.setBorderColor(e),r.serializeState())},changeColorShape:e=>{const t=p.current.toolController.getPrimaryTools()[5],r=w.current.getWidgetById("shape");t&&r&&(t.setColor(e),r.serializeState())},changeShape:e=>{const t=w.current.getWidgetById("shape");t&&t.setShapeType(e)},onClear:()=>{if(!X){for(;p.current.history.undoStackSize>0;)v();X=!0}},onRedo:()=>{X||p.current.history.redo()},onThicknessChange:e=>{const t=p.current.toolController.getPrimaryTools()[5],r=w.current.getWidgetById("shape");t&&r&&(t.setThickness(e),r.serializeState())},onUndo:v,refEditor:p,setColorHighlight:e=>{const t=p.current.toolController.getPrimaryTools()[3],r=w.current.getWidgetById("pen-2");t&&r&&(t.setColor(e),r.serializeState())},setColorPen:e=>{const t=p.current.toolController.getPrimaryTools()[2],r=w.current.getWidgetById("pen-1");t&&r&&(t.setColor(e),r.serializeState())},setThicknessPen:e=>{const t=p.current.toolController.getPrimaryTools()[2],r=w.current.getWidgetById("pen-1");t&&r&&(t.setThickness(e),r.serializeState())}})]}),(0,u.jsx)(n.DialogFooter,{children:(0,u.jsx)(l.Button,{onClick:async()=>{if(p.current){const t=p.current.toSVG(),r=t.outerHTML,o=`drawer-${c.shortId()}.svg`;let l=c.i(t.outerHTML);if(s){const e=a.dataURLtoFile(l,o);l=await s(e)}e?.chain().focus().setDrawer({type:"drawer",src:l,alt:encodeURIComponent(r),width:426,height:212},!!r).run()}x(!1)},type:"button",children:"Save changes"})})]})]}):(0,u.jsx)(u.Fragment,{})}var Y=s.index_default.extend({name:"richTextDrawer",addOptions(){return{...this.parent?.(),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({t:e,extension:t})=>({componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:e("editor.drawer.tooltip"),upload:t?.options?.upload}})}},addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{const t=e.querySelector("img")?.getAttribute("width");return t?Number.parseInt(t,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const t=e.querySelector("img")?.getAttribute("height");return t?Number.parseInt(t,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView:()=>(0,h.ReactNodeViewRenderer)(C),addCommands(){return{setDrawer:(e,t)=>({commands:r,editor:o})=>t?r.insertContent({type:this.name,attrs:e}):r.insertContentAt(o.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageDrawer:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageDrawer"},["img",(0,g.mergeAttributes)(this.options.HTMLAttributes,e)]]},parseHTML:()=>[{tag:"div[class=imageDrawer]",getAttrs:e=>{const t=e.querySelector("img"),r=t?.getAttribute("width"),o=t?.getAttribute("height");return{src:t?.getAttribute("src"),alt:t?.getAttribute("alt"),width:r?Number.parseInt(r,10):null,height:o?Number.parseInt(o,10):null,align:t?.getAttribute("align")||e.style.textAlign||null}}}]});Object.defineProperty(exports,"ControlDrawer",{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,"Drawer",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,"RichTextDrawer",{enumerable:!0,get:function(){return Q}});
@@ -1,16 +1,16 @@
1
- import{o as e}from"./dist-CsCFCV4K.js";import{n as t}from"./toggle-BXl_NYYh.js";import{g as o}from"./locales-DfkG6-1b.js";import{t as r}from"./button-CXcuJkiM.js";import{a as l,n,o as i,r as a,t as s}from"./dialog-DgdVbRUv.js";import{o as c,t as h}from"./throttle-BpbN7uB1.js";import{c as d,d as u,n as m,t as g}from"./useButtonProps-DSIajp_B.js";import{t as p}from"./file-aBzFF1LO.js";import{n as v,t as w}from"./shortId-COE42cHb.js";import{NodeViewWrapper as C,ReactNodeViewRenderer as f,isNumber as b}from"@tiptap/react";import T,{useCallback as x,useEffect as y,useMemo as H,useRef as k,useState as N}from"react";import{Fragment as L,jsx as M,jsxs as E}from"react/jsx-runtime";import{mergeAttributes as A}from"@tiptap/core";import{Color4 as z,Editor as B,makeDropdownToolbar as q}from"easydrawer";var _="tl",P="tr",S="bl",F="br";function W({editor:e,node:t,updateAttributes:r,getPos:l,selected:n}){const[i,a]=N({width:o,height:o}),[s,c]=N({width:0,height:0}),[d]=N([_,P,S,F]),[u,g]=N(!1),[p,v]=N({x:0,y:0,w:0,h:0,dir:""}),{align:w}=t.attrs,f=H(()=>{const{src:e,alt:o,width:r,height:l}=t.attrs;return{src:e||void 0,alt:o||void 0,style:{width:(b(r)?`${r}px`:r)||void 0,height:(b(l)?`${l}px`:l)||void 0}}},[t?.attrs]),T=H(()=>{const{style:{width:e}}=f;return{width:"100%"===e?e:void 0}},[f]);const k=x(()=>{e.commands.setNodeSelection(l())},[]),L=x(h(()=>{const{width:t}=getComputedStyle(e.view.dom);a(e=>({...e,width:Number.parseInt(t,10)}))},16),[e]);const A=x(h(e=>{if(e.preventDefault(),e.stopPropagation(),!u)return;const{x:o,w:l,dir:n}=p,a=(e.clientX-o)*(/l/.test(n)?-1:1),{width:s,height:c}=t.attrs,h=s/c,d=m(l+a,20,i.width);r({width:d,height:Math.round(d/h)})},16),[u,p,i,r,t?.attrs]),z=x(e=>{e.preventDefault(),e.stopPropagation(),u&&(v({x:0,y:0,w:0,h:0,dir:""}),g(!1),k())},[u,k]),B=x(()=>{document?.addEventListener("mousemove",A,!0),document?.addEventListener("mouseup",z,!0)},[A,z]),q=x(()=>{document?.removeEventListener("mousemove",A,!0),document?.removeEventListener("mouseup",z,!0)},[A,z]);y(()=>(u?B():q(),()=>{q()}),[u,B,q]);const W=H(()=>new ResizeObserver(()=>L()),[L]);return y(()=>(W.observe(e.view.dom),()=>{W.disconnect()}),[e.view.dom,W]),/* @__PURE__ */M(C,{className:"image-view",style:{...T,width:"100%",textAlign:w},children:/* @__PURE__ */E("div",{"data-drag-handle":!0,draggable:"true",style:{...T,background:"#fff"},className:`image-view__body ${n?"image-view__body--focused":""} ${u?"image-view__body--resizing":""}`,children:[/* @__PURE__ */M("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:k,onLoad:function(e){c({width:e.target.width,height:e.target.height})},src:f.src,style:f.style}),e.view.editable&&(n||u)&&/* @__PURE__ */M("div",{className:"image-resizer",children:d?.map(e=>/* @__PURE__ */M("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:o=>function(e,o){e.preventDefault(),e.stopPropagation();const r=s.width,l=r/s.height;let n=Number(t.attrs.width),a=Number(t.attrs.height);const c=i.width;n&&!a?(n=n>c?c:n,a=Math.round(n/l)):a&&!n?(n=Math.round(a*l),n=n>c?c:n):n||a?n=n>c?c:n:(n=r>c?c:r,a=Math.round(n/l)),g(!0),v({x:e.clientX,y:e.clientY,w:n,h:a,dir:o})}(o,e)},`image-dir-${e}`))})]})})}function R(e){/* @__PURE__ */
1
+ import{o as e}from"./dist-CsCFCV4K.js";import{n as t}from"./toggle-BXl_NYYh.js";import{g as o}from"./locales-DfkG6-1b.js";import{t as r}from"./button-CXcuJkiM.js";import{a as l,n,o as i,r as a,t as s}from"./dialog-DgdVbRUv.js";import{o as c,t as h}from"./throttle-BpbN7uB1.js";import{c as d,d as u,n as m,t as g}from"./useButtonProps-DSIajp_B.js";import{t as p}from"./file-aBzFF1LO.js";import{n as v,t as w}from"./shortId-COE42cHb.js";import{NodeViewWrapper as C,ReactNodeViewRenderer as f,isNumber as b}from"@tiptap/react";import T,{useCallback as x,useEffect as y,useMemo as H,useRef as k,useState as N}from"react";import{Fragment as L,jsx as M,jsxs as E}from"react/jsx-runtime";import{mergeAttributes as A}from"@tiptap/core";import{Color4 as z,Editor as B,makeDropdownToolbar as _}from"easydrawer";var q="tl",P="tr",S="bl",F="br";function W({editor:e,node:t,updateAttributes:r,getPos:l,selected:n}){const[i,a]=N({width:o,height:o}),[s,c]=N({width:0,height:0}),[d]=N([q,P,S,F]),[u,g]=N(!1),[p,v]=N({x:0,y:0,w:0,h:0,dir:""}),{align:w}=t.attrs,f=H(()=>{const{src:e,alt:o,width:r,height:l}=t.attrs;return{src:e||void 0,alt:o||void 0,style:{width:(b(r)?`${r}px`:r)||void 0,height:(b(l)?`${l}px`:l)||void 0}}},[t?.attrs]),T=H(()=>{const{style:{width:e}}=f;return{width:"100%"===e?e:void 0}},[f]);const k=x(()=>{e.commands.setNodeSelection(l())},[]),L=x(h(()=>{const{width:t}=getComputedStyle(e.view.dom);a(e=>({...e,width:Number.parseInt(t,10)}))},16),[e]);const A=x(h(e=>{if(e.preventDefault(),e.stopPropagation(),!u)return;const{x:o,w:l,dir:n}=p,a=(e.clientX-o)*(/l/.test(n)?-1:1),{width:s,height:c}=t.attrs,h=s/c,d=m(l+a,20,i.width);r({width:d,height:Math.round(d/h)})},16),[u,p,i,r,t?.attrs]),z=x(e=>{e.preventDefault(),e.stopPropagation(),u&&(v({x:0,y:0,w:0,h:0,dir:""}),g(!1),k())},[u,k]),B=x(()=>{document?.addEventListener("mousemove",A,!0),document?.addEventListener("mouseup",z,!0)},[A,z]),_=x(()=>{document?.removeEventListener("mousemove",A,!0),document?.removeEventListener("mouseup",z,!0)},[A,z]);y(()=>(u?B():_(),()=>{_()}),[u,B,_]);const W=H(()=>new ResizeObserver(()=>L()),[L]);return y(()=>(W.observe(e.view.dom),()=>{W.disconnect()}),[e.view.dom,W]),/* @__PURE__ */M(C,{className:"image-view",style:{...T,width:"100%",textAlign:w},children:/* @__PURE__ */E("div",{"data-drag-handle":!0,draggable:"true",style:{...T,background:"#fff"},className:`image-view__body ${n?"image-view__body--focused":""} ${u?"image-view__body--resizing":""}`,children:[/* @__PURE__ */M("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:k,onLoad:function(e){c({width:e.target.width,height:e.target.height})},src:f.src,style:f.style}),e.view.editable&&(n||u)&&/* @__PURE__ */M("div",{className:"image-resizer",children:d?.map(e=>/* @__PURE__ */M("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:o=>function(e,o){e.preventDefault(),e.stopPropagation();const r=s.width,l=r/s.height;let n=Number(t.attrs.width),a=Number(t.attrs.height);const c=i.width;n&&!a?(n=n>c?c:n,a=Math.round(n/l)):a&&!n?(n=Math.round(a*l),n=n>c?c:n):n||a?n=n>c?c:n:(n=r>c?c:r,a=Math.round(n/l)),g(!0),v({x:e.clientX,y:e.clientY,w:n,h:a,dir:o})}(o,e)},`image-dir-${e}`))})]})})}function R(e){/* @__PURE__ */
2
2
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 D(e){/* @__PURE__ */
3
3
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 I(e){/* @__PURE__ */
4
4
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 V(e){/* @__PURE__ */
5
5
  return M("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 j(e){/* @__PURE__ */
6
6
  return E("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[/* @__PURE__ */M("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"}),/* @__PURE__ */M("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 $(e){/* @__PURE__ */
7
7
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function G(e){/* @__PURE__ */
8
- return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function O(e){/* @__PURE__ */
9
- return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 U(e){/* @__PURE__ */
10
- return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 Z(e){/* @__PURE__ */
8
+ return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function Z(e){/* @__PURE__ */
9
+ return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 O(e){/* @__PURE__ */
10
+ return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 U(e){/* @__PURE__ */
11
11
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 X(e){/* @__PURE__ */
12
- return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */E("g",{fill:"none",fillRule:"evenodd",children:[/* @__PURE__ */M("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"}),/* @__PURE__ */M("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 Y(e){/* @__PURE__ */
13
- return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function Q(e){/* @__PURE__ */
12
+ return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */E("g",{fill:"none",fillRule:"evenodd",children:[/* @__PURE__ */M("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"}),/* @__PURE__ */M("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 Q(e){/* @__PURE__ */
13
+ return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function Y(e){/* @__PURE__ */
14
14
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 J(e){/* @__PURE__ */
15
15
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("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 K(e){/* @__PURE__ */
16
16
  return M("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */M("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function ee(e){/* @__PURE__ */
@@ -44,20 +44,20 @@ return M(L,{children:/* @__PURE__ */E("div",{className:ne.wrapper,children:[/* @
44
44
  /* @__PURE__ */M("div",{className:ne.line}),
45
45
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&0===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(0),v(0)},children:/* @__PURE__ */M($,{})}),
46
46
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&1===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(1),v(1)},children:/* @__PURE__ */M(G,{})}),
47
- /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&2===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(2),v(2)},children:/* @__PURE__ */M(O,{})}),
48
- /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&3===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(3),v(3)},children:/* @__PURE__ */M(U,{})}),
49
- /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&4===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(4),v(4)},children:/* @__PURE__ */M(Z,{})}),
47
+ /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&2===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(2),v(2)},children:/* @__PURE__ */M(Z,{})}),
48
+ /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&3===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(3),v(3)},children:/* @__PURE__ */M(O,{})}),
49
+ /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&4===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(4),v(4)},children:/* @__PURE__ */M(U,{})}),
50
50
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&5===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(5),v(5)},children:/* @__PURE__ */M(X,{})}),
51
- /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&6===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(6),v(6)},children:/* @__PURE__ */M(Y,{})}),
51
+ /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&6===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(6),v(6)},children:/* @__PURE__ */M(Q,{})}),
52
52
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&7===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(7),v(7)},children:/* @__PURE__ */M(ee,{})}),
53
53
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&8===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(8),v(8)},children:/* @__PURE__ */M(te,{})}),
54
54
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&9===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(9),v(9)},children:/* @__PURE__ */M(oe,{})}),
55
55
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&10===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(10),v(10)},children:/* @__PURE__ */M(re,{})}),
56
56
  /* @__PURE__ */M("button",{className:e(ne.tool,{[ne.active]:"shapes"===m&&11===p}),onClick:()=>{const e=r.current.toolController.getPrimaryTools();r.current.toolController.setToolEnabled(e[5]),g("shapes"),e[5].setEnabled(!0),c(11),v(11)},children:/* @__PURE__ */M(le,{})}),
57
57
  /* @__PURE__ */M("div",{className:ne.line}),
58
- /* @__PURE__ */M("button",{className:e(ne.tool),onClick:a,children:/* @__PURE__ */M(Q,{})}),
58
+ /* @__PURE__ */M("button",{className:e(ne.tool),onClick:a,children:/* @__PURE__ */M(Y,{})}),
59
59
  /* @__PURE__ */M("button",{className:e(ne.tool),onClick:d,children:/* @__PURE__ */M(J,{})}),
60
- /* @__PURE__ */M("button",{className:e(ne.tool),onClick:u,children:/* @__PURE__ */M(K,{})})]}),/* @__PURE__ */E("div",{className:ne.optionsWrap,children:["pencil"===m&&/* @__PURE__ */M(he,{setColorPen:o,setThicknessPen:l}),"highlighter"===m&&/* @__PURE__ */M(de,{setColorHighlight:n}),"shapes"===m&&/* @__PURE__ */M(ue,{changeBorderColorShape:i,changeColorShape:s,changeShape:c,onThicknessChange:h})]})]})})}var ge=!1;function pe(){const e=u(),o=g(ve.name),{isActive:c,upload:h}=o?.componentProps??{},{editorDisabled:m}=d(c),[C,f]=N(!1),b=k(null),T=k(null);y(()=>{C&&setTimeout(()=>{(async()=>{const e=document.querySelector("#easydrawer");e&&(b.current=new B(e,{wheelEventsEnabled:!1,disableZoom:!0}),T.current=q(b.current),T.current.addDefaultToolWidgets())})()},200)},[C]);const x=()=>{if(ge){for(;b.current.history.redoStackSize>0;)b.current.history.redo();ge=!1}else b.current.history.undo()};return o?/* @__PURE__ */E(s,{onOpenChange:f,open:C,children:[/* @__PURE__ */M(i,{asChild:!0,children:/* @__PURE__ */M(t,{disabled:m,action:()=>{m||f(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),/* @__PURE__ */E(n,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[
60
+ /* @__PURE__ */M("button",{className:e(ne.tool),onClick:u,children:/* @__PURE__ */M(K,{})})]}),/* @__PURE__ */E("div",{className:ne.optionsWrap,children:["pencil"===m&&/* @__PURE__ */M(he,{setColorPen:o,setThicknessPen:l}),"highlighter"===m&&/* @__PURE__ */M(de,{setColorHighlight:n}),"shapes"===m&&/* @__PURE__ */M(ue,{changeBorderColorShape:i,changeColorShape:s,changeShape:c,onThicknessChange:h})]})]})})}var ge=!1;function pe(){const e=u(),o=g(ve.name),{isActive:c,upload:h}=o?.componentProps??{},{editorDisabled:m}=d(c),[C,f]=N(!1),b=k(null),T=k(null);y(()=>{C&&setTimeout(()=>{(async()=>{const e=document.querySelector("#easydrawer");e&&(b.current=new B(e,{wheelEventsEnabled:!1,disableZoom:!0}),T.current=_(b.current),T.current.addDefaultToolWidgets())})()},200)},[C]);const x=()=>{if(ge){for(;b.current.history.redoStackSize>0;)b.current.history.redo();ge=!1}else b.current.history.undo()};return o?/* @__PURE__ */E(s,{onOpenChange:f,open:C,children:[/* @__PURE__ */M(i,{asChild:!0,children:/* @__PURE__ */M(t,{disabled:m,action:()=>{m||f(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),/* @__PURE__ */E(n,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[
61
61
  /* @__PURE__ */M(l,{children:"Drawer"}),
62
62
  /* @__PURE__ */E("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[/* @__PURE__ */M("div",{className:"richtext-size-full",id:"easydrawer"}),/* @__PURE__ */M(me,{changeBorderColorShape:e=>{const t=b.current.toolController.getPrimaryTools()[5],o=T.current.getWidgetById("shape");t&&o&&(t.setBorderColor(e),o.serializeState())},changeColorShape:e=>{const t=b.current.toolController.getPrimaryTools()[5],o=T.current.getWidgetById("shape");t&&o&&(t.setColor(e),o.serializeState())},changeShape:e=>{const t=T.current.getWidgetById("shape");t&&t.setShapeType(e)},onClear:()=>{if(!ge){for(;b.current.history.undoStackSize>0;)x();ge=!0}},onRedo:()=>{ge||b.current.history.redo()},onThicknessChange:e=>{const t=b.current.toolController.getPrimaryTools()[5],o=T.current.getWidgetById("shape");t&&o&&(t.setThickness(e),o.serializeState())},onUndo:x,refEditor:b,setColorHighlight:e=>{const t=b.current.toolController.getPrimaryTools()[3],o=T.current.getWidgetById("pen-2");t&&o&&(t.setColor(e),o.serializeState())},setColorPen:e=>{const t=b.current.toolController.getPrimaryTools()[2],o=T.current.getWidgetById("pen-1");t&&o&&(t.setColor(e),o.serializeState())},setThicknessPen:e=>{const t=b.current.toolController.getPrimaryTools()[2],o=T.current.getWidgetById("pen-1");t&&o&&(t.setThickness(e),o.serializeState())}})]}),
63
63
  /* @__PURE__ */M(a,{children:/* @__PURE__ */M(r,{onClick:async()=>{if(b.current){const t=b.current.toSVG(),o=t.outerHTML,r=`drawer-${w()}.svg`;let l=v(t.outerHTML);if(h){const e=p(l,r);l=await h(e)}e?.chain().focus().setDrawer({type:"drawer",src:l,alt:encodeURIComponent(o),width:426,height:212},!!o).run()}f(!1)},type:"button",children:"Save changes"})})]})]}):/* @__PURE__ */M(L,{})}var ve=c.extend({name:"richTextDrawer",addOptions(){return{...this.parent?.(),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({t:e,extension:t})=>({componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,icon:"PencilRuler",tooltip:e("editor.drawer.tooltip"),upload:t?.options?.upload}})}},addAttributes(){return{...this.parent?.(),width:{default:null,parseHTML:e=>{const t=e.querySelector("img")?.getAttribute("width");return t?Number.parseInt(t,10):320},renderHTML:e=>({width:e.width})},height:{default:null,parseHTML:e=>{const t=e.querySelector("img")?.getAttribute("height");return t?Number.parseInt(t,10):212},renderHTML:e=>({height:e.height})},align:{default:"center",parseHTML:e=>e.getAttribute("align"),renderHTML:e=>({align:e.align})}}},addNodeView:()=>f(W),addCommands(){return{setDrawer:(e,t)=>({commands:o,editor:r})=>t?o.insertContent({type:this.name,attrs:e}):o.insertContentAt(r.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageDrawer:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageDrawer"},["img",A(this.options.HTMLAttributes,e)]]},parseHTML:()=>[{tag:"div[class=imageDrawer]",getAttrs:e=>{const t=e.querySelector("img"),o=t?.getAttribute("width"),r=t?.getAttribute("height");return{src:t?.getAttribute("src"),alt:t?.getAttribute("alt"),width:o?Number.parseInt(o,10):null,height:r?Number.parseInt(r,10):null,align:t?.getAttribute("align")||e.style.textAlign||null}}}]});export{pe as n,me as r,ve as t};
package/dist/Drawer.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const r=require("./Drawer-DxCO6TBr.cjs");exports.Drawer=r.Drawer,exports.RichTextDrawer=r.RichTextDrawer;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const r=require("./Drawer-B0QvuSOf.cjs");exports.Drawer=r.Drawer,exports.RichTextDrawer=r.RichTextDrawer;
package/dist/Drawer.js CHANGED
@@ -1 +1 @@
1
- import{n as r,t as a}from"./Drawer-Dunw22Q1.js";export{a as Drawer,r as RichTextDrawer};
1
+ import{n as r,t as a}from"./Drawer-bqo2XUCW.js";export{a as Drawer,r as RichTextDrawer};
@@ -1,6 +1,6 @@
1
- import{n as e}from"./toggle-BXl_NYYh.js";import{t}from"./button-CXcuJkiM.js";import{a as i,n as a,o as r,r as n,t as o}from"./dialog-DgdVbRUv.js";import{i as s,t as d}from"./events.constant-DYciHxmk.js";import{c as l,d as m,l as c,n as p,o as h,t as u}from"./useButtonProps-DSIajp_B.js";import{n as w,t as g}from"./dom-dataset-D3Nz0h73.js";import{NodeViewWrapper as f,ReactNodeViewRenderer as b}from"@tiptap/react";import v,{useCallback as x,useEffect as y,useMemo as _,useRef as L,useState as N}from"react";import D from"clsx";import{jsx as O,jsxs as E}from"react/jsx-runtime";import{Node as M,mergeAttributes as T,nodeInputRule as W}from"@tiptap/core";import{Resizable as j}from"re-resizable";var A="_wrap_1cxoc_1",H="_renderWrap_1cxoc_7",I="_handlerWrap_1cxoc_30",C="_disabled_1cxoc_40",S="_active_1cxoc_44",P={width:"100%",height:"100%",maxWidth:"100%"};function J({editor:t,node:i,updateAttributes:a}){L(null);const r=c(),n=t.isActive(z.name),{data:o,width:s,height:d}=i.attrs,[l,m]=N(null),[h,u]=N(!0),[w,g]=N(null),[b,v]=N(100),_=x(e=>()=>{v(t=>p("minus"===e?t-15:t+15,10,200))},[]);y(()=>{if(!o?.xml)return void u(!1);u(!0),g(null);const e=document.createElement("iframe");e.src="https://embed.diagrams.net/?embed=1&ui=minimal&spin=1&proto=json",e.style.display="none",document.body.appendChild(e);const t=t=>{if(t.source!==e.contentWindow||"string"!=typeof t.data)return;let i;try{i=JSON.parse(t.data)}catch{return}"init"===i.event?e.contentWindow?.postMessage(JSON.stringify({action:"export",format:"xmlsvg",xml:o.xml}),"*"):"export"===i.event&&(i.data?m(i.data):g(/* @__PURE__ */new Error("Unable to render diagram preview")),u(!1))};window.addEventListener("message",t);const i=window.setTimeout(()=>{g(/* @__PURE__ */new Error("Timed out loading diagram preview")),u(!1)},15e3);return()=>{window.clearTimeout(i),window.removeEventListener("message",t),document.body.removeChild(e)}},[o]);/* @__PURE__ */
2
- return O(f,{className:D(A,{[S]:n,[C]:!r}),children:/* @__PURE__ */O(j,{size:{width:Number.parseInt(s),height:Number.parseInt(d)},onResizeStop:(e,t,i,r)=>{var n;n={width:Number.parseInt(s)+r.width,height:Number.parseInt(d)+r.height},a({width:n.width,height:n.height})},children:/* @__PURE__ */E("div",{className:D(H,"render-wrapper"),style:{...P,overflow:"hidden"},children:[w&&/* @__PURE__ */O("div",{style:P,children:/* @__PURE__ */O("p",{children:w.message||w})}),h&&/* @__PURE__ */O("p",{children:"Loading diagram..."}),!h&&!w&&l&&/* @__PURE__ */O("div",{style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${b/100})`,transition:"all ease-in-out .3s"},children:/* @__PURE__ */O("img",{alt:"Diagram preview",src:l,style:{maxWidth:"100%",maxHeight:"100%"}})}),!h&&!w&&!l&&o?.xml&&/* @__PURE__ */O("div",{style:P,children:/* @__PURE__ */O("p",{children:"Diagram data present but unable to render preview"})}),
3
- /* @__PURE__ */E("div",{className:I,children:[/* @__PURE__ */O(e,{action:_("minus"),disabled:!r,icon:"ZoomOut",tooltip:"Zoom Out"}),/* @__PURE__ */O(e,{action:_("plus"),disabled:!r,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}function $(){const c=m(),p=u(z.name),w=h(z.name),{tooltipOptions:g={},isActive:f}=p?.componentProps??{},{editorDisabled:b}=l(f);_(()=>w?.options||{},[w]);const[v,L]=N(null),[D,M]=N(""),[T,W]=N(!1),[j,A]=N(!0),[H,I]=N(null),C=x(()=>{if(v)try{v.contentWindow?.postMessage(JSON.stringify({action:"export",format:"xml"}),"*")}catch(e){I(e)}else W(!1)},[v]),S=x(e=>{if(!v||e.source!==v.contentWindow||"string"!=typeof e.data)return;let t;try{t=JSON.parse(e.data)}catch{return}if("init"===t.event)A(!1),D&&v.contentWindow?.postMessage(JSON.stringify({action:"load",xml:D,autosave:1}),"*");else if("export"===t.event){const e=t.xml||t.data;e?(M(e),c.chain().focus().setDrawio({data:{xml:e}}).run(),W(!1)):I(/* @__PURE__ */new Error("Unable to export diagram"))}},[c,D,v]),P=d.DRAWIO?.(c.id)||`drawio-${c.id}`;return s(e=>{W(!0),I(null),M(e?.data?.xml?e.data.xml:"")},[P]),y(()=>(window.addEventListener("message",S),()=>{window.removeEventListener("message",S)}),[S]),y(()=>{T&&(A(!0),I(null))},[T]),/* @__PURE__ */E(o,{onOpenChange:W,open:T,children:[/* @__PURE__ */O(r,{asChild:!0,children:/* @__PURE__ */O(e,{disabled:b,icon:"Drawio",tooltip:"Draw.io",tooltipOptions:g,action:()=>{b||W(!0)}})}),/* @__PURE__ */E(a,{className:"richtext-z-[99999] !richtext-max-w-[1400px]",children:[
1
+ import{n as e}from"./toggle-BXl_NYYh.js";import{t}from"./button-CXcuJkiM.js";import{a as i,n as a,o as r,r as n,t as o}from"./dialog-DgdVbRUv.js";import{i as s,t as d}from"./events.constant-DYciHxmk.js";import{c as l,d as m,l as c,n as p,o as h,t as u}from"./useButtonProps-DSIajp_B.js";import{n as w,t as g}from"./dom-dataset-D3Nz0h73.js";import{NodeViewWrapper as f,ReactNodeViewRenderer as b}from"@tiptap/react";import v,{useCallback as x,useEffect as y,useMemo as _,useRef as L,useState as N}from"react";import D from"clsx";import{jsx as O,jsxs as E}from"react/jsx-runtime";import{Node as M,mergeAttributes as T,nodeInputRule as W}from"@tiptap/core";import{Resizable as j}from"re-resizable";var A="_wrap_1cxoc_1",H="_renderWrap_1cxoc_7",I="_handlerWrap_1cxoc_30",C="_disabled_1cxoc_40",S="_active_1cxoc_44",J={width:"100%",height:"100%",maxWidth:"100%"};function P({editor:t,node:i,updateAttributes:a}){L(null);const r=c(),n=t.isActive(z.name),{data:o,width:s,height:d}=i.attrs,[l,m]=N(null),[h,u]=N(!0),[w,g]=N(null),[b,v]=N(100),_=x(e=>()=>{v(t=>p("minus"===e?t-15:t+15,10,200))},[]);y(()=>{if(!o?.xml)return void u(!1);u(!0),g(null);const e=document.createElement("iframe");e.src="https://embed.diagrams.net/?embed=1&ui=minimal&spin=1&proto=json",e.style.display="none",document.body.appendChild(e);const t=t=>{if(t.source!==e.contentWindow||"string"!=typeof t.data)return;let i;try{i=JSON.parse(t.data)}catch{return}"init"===i.event?e.contentWindow?.postMessage(JSON.stringify({action:"export",format:"xmlsvg",xml:o.xml}),"*"):"export"===i.event&&(i.data?m(i.data):g(/* @__PURE__ */new Error("Unable to render diagram preview")),u(!1))};window.addEventListener("message",t);const i=window.setTimeout(()=>{g(/* @__PURE__ */new Error("Timed out loading diagram preview")),u(!1)},15e3);return()=>{window.clearTimeout(i),window.removeEventListener("message",t),document.body.removeChild(e)}},[o]);/* @__PURE__ */
2
+ return O(f,{className:D(A,{[S]:n,[C]:!r}),children:/* @__PURE__ */O(j,{size:{width:Number.parseInt(s),height:Number.parseInt(d)},onResizeStop:(e,t,i,r)=>{var n;n={width:Number.parseInt(s)+r.width,height:Number.parseInt(d)+r.height},a({width:n.width,height:n.height})},children:/* @__PURE__ */E("div",{className:D(H,"render-wrapper"),style:{...J,overflow:"hidden"},children:[w&&/* @__PURE__ */O("div",{style:J,children:/* @__PURE__ */O("p",{children:w.message||w})}),h&&/* @__PURE__ */O("p",{children:"Loading diagram..."}),!h&&!w&&l&&/* @__PURE__ */O("div",{style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${b/100})`,transition:"all ease-in-out .3s"},children:/* @__PURE__ */O("img",{alt:"Diagram preview",src:l,style:{maxWidth:"100%",maxHeight:"100%"}})}),!h&&!w&&!l&&o?.xml&&/* @__PURE__ */O("div",{style:J,children:/* @__PURE__ */O("p",{children:"Diagram data present but unable to render preview"})}),
3
+ /* @__PURE__ */E("div",{className:I,children:[/* @__PURE__ */O(e,{action:_("minus"),disabled:!r,icon:"ZoomOut",tooltip:"Zoom Out"}),/* @__PURE__ */O(e,{action:_("plus"),disabled:!r,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}function $(){const c=m(),p=u(z.name),w=h(z.name),{tooltipOptions:g={},isActive:f}=p?.componentProps??{},{editorDisabled:b}=l(f);_(()=>w?.options||{},[w]);const[v,L]=N(null),[D,M]=N(""),[T,W]=N(!1),[j,A]=N(!0),[H,I]=N(null),C=x(()=>{if(v)try{v.contentWindow?.postMessage(JSON.stringify({action:"export",format:"xml"}),"*")}catch(e){I(e)}else W(!1)},[v]),S=x(e=>{if(!v||e.source!==v.contentWindow||"string"!=typeof e.data)return;let t;try{t=JSON.parse(e.data)}catch{return}if("init"===t.event)A(!1),D&&v.contentWindow?.postMessage(JSON.stringify({action:"load",xml:D,autosave:1}),"*");else if("export"===t.event){const e=t.xml||t.data;e?(M(e),c.chain().focus().setDrawio({data:{xml:e}}).run(),W(!1)):I(/* @__PURE__ */new Error("Unable to export diagram"))}},[c,D,v]),J=d.DRAWIO?.(c.id)||`drawio-${c.id}`;return s(e=>{W(!0),I(null),M(e?.data?.xml?e.data.xml:"")},[J]),y(()=>(window.addEventListener("message",S),()=>{window.removeEventListener("message",S)}),[S]),y(()=>{T&&(A(!0),I(null))},[T]),/* @__PURE__ */E(o,{onOpenChange:W,open:T,children:[/* @__PURE__ */O(r,{asChild:!0,children:/* @__PURE__ */O(e,{disabled:b,icon:"Drawio",tooltip:"Draw.io",tooltipOptions:g,action:()=>{b||W(!0)}})}),/* @__PURE__ */E(a,{className:"richtext-z-[99999] !richtext-max-w-[1400px]",children:[
4
4
  /* @__PURE__ */O(i,{children:"Draw.io Diagram"}),
5
5
  /* @__PURE__ */E("div",{style:{height:"100%",borderWidth:1},children:[j&&/* @__PURE__ */O("p",{children:"Loading editor..."}),H&&/* @__PURE__ */O("p",{children:H&&H.message||"Error loading editor"}),!H&&/* @__PURE__ */O("iframe",{ref:L,src:"https://embed.diagrams.net/?embed=1&ui=minimal&spin=1&modified=unsaved&noExitBtn=1&proto=json",style:{width:"100%",height:600,border:"none",display:j?"none":"block"},title:"Draw.io Editor",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms allow-modals"})]}),
6
- /* @__PURE__ */O(n,{children:/* @__PURE__ */O(t,{disabled:j,onClick:C,type:"button",children:"Save Diagram"})})]})]})}var k={xml:""},z=M.create({name:"drawio",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes:()=>({defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:g("width")},height:{default:400,parseHTML:g("height")},data:{default:k,parseHTML:g("data",!0)}}),addOptions(){return{...this.parent?.(),HTMLAttributes:{class:"drawio"},drawioProps:{},button:()=>({componentProps:{}})}},parseHTML:()=>[{tag:"div[class=drawio]"}],renderHTML({HTMLAttributes:e,node:t}){return["div",T(this.options.HTMLAttributes,e,w(t))]},addCommands(){return{setDrawio:e=>({tr:t,commands:i,chain:a})=>((e=e||{}).data=e.data||k,t.selection?.node?.type?.name==this.name?i.updateAttributes(this.name,e):a().insertContent({type:this.name,attrs:e}).run())}},addNodeView:()=>b(J),addInputRules(){return[W({find:/^\$drawio\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});export{$ as n,z as t};
6
+ /* @__PURE__ */O(n,{children:/* @__PURE__ */O(t,{disabled:j,onClick:C,type:"button",children:"Save Diagram"})})]})]})}var k={xml:""},z=M.create({name:"drawio",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes:()=>({defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:g("width")},height:{default:400,parseHTML:g("height")},data:{default:k,parseHTML:g("data",!0)}}),addOptions(){return{...this.parent?.(),HTMLAttributes:{class:"drawio"},drawioProps:{},button:()=>({componentProps:{}})}},parseHTML:()=>[{tag:"div[class=drawio]"}],renderHTML({HTMLAttributes:e,node:t}){return["div",T(this.options.HTMLAttributes,e,w(t))]},addCommands(){return{setDrawio:e=>({tr:t,commands:i,chain:a})=>((e=e||{}).data=e.data||k,t.selection?.node?.type?.name==this.name?i.updateAttributes(this.name,e):a().insertContent({type:this.name,attrs:e}).run())}},addNodeView:()=>b(P),addInputRules(){return[W({find:/^\$drawio\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});export{$ as n,z as t};
package/dist/Drawio.js CHANGED
@@ -1 +1 @@
1
- import{n as o,t as r}from"./Drawio-eqEGDkwW.js";export{r as Drawio,o as RichTextDrawio};
1
+ import{n as o,t as r}from"./Drawio-CIXM-WGy.js";export{r as Drawio,o as RichTextDrawio};