react-reason-editor 1.0.76 → 1.0.78
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.
- package/dist/Ai-CfgczVyp.cjs +1 -0
- package/dist/Ai-DsWeNKXF.js +1 -0
- package/dist/Ai.cjs +1 -1
- package/dist/Ai.js +1 -1
- package/dist/{Attachment-bBEf8uOc.js → Attachment-BmQoshq_.js} +1 -1
- package/dist/Attachment.cjs +1 -1
- package/dist/Attachment.js +1 -1
- package/dist/{Blockquote-Cw5Zty9X.js → Blockquote-cNS4L62L.js} +1 -1
- package/dist/Blockquote.cjs +1 -1
- package/dist/Blockquote.js +1 -1
- package/dist/{Bold-BwuX7fZs.js → Bold-DiKXbC2z.js} +1 -1
- package/dist/Bold.cjs +1 -1
- package/dist/Bold.js +1 -1
- package/dist/BubbleMenus-CIOMgQ-M.js +216 -0
- package/dist/BubbleMenus-vqNuXWlm.cjs +1 -0
- package/dist/BulletList.cjs +1 -1
- package/dist/BulletList.js +1 -1
- package/dist/{Callout-CJofZEpX.js → Callout-BLkbFKjv.js} +1 -1
- package/dist/{Callout-wjo2BYZi.cjs → Callout-CpkjGEBS.cjs} +1 -1
- package/dist/Callout.cjs +1 -1
- package/dist/Callout.js +1 -1
- package/dist/Clear.cjs +1 -1
- package/dist/Clear.js +1 -1
- package/dist/{Code-CtIvf6_L.js → Code-DvYJ892R.js} +1 -1
- package/dist/Code.cjs +1 -1
- package/dist/Code.js +1 -1
- package/dist/{CodeBlock-DoIb7GC2.js → CodeBlock-B3dLyClh.js} +1 -1
- package/dist/CodeBlock.cjs +1 -1
- package/dist/CodeBlock.js +1 -1
- package/dist/CodeView.cjs +1 -1
- package/dist/CodeView.js +1 -1
- package/dist/{Color-DSs2MkQU.js → Color-Cng09GRR.js} +1 -1
- package/dist/{Color-B9PloDr5.cjs → Color-ZjBs7t7J.cjs} +1 -1
- package/dist/Color.cjs +1 -1
- package/dist/Color.js +1 -1
- package/dist/{Column-BXSoMVXw.cjs → Column-BaMOYvoO.cjs} +1 -1
- package/dist/{Column-CrT9596v.js → Column-DO6MfrOQ.js} +1 -1
- package/dist/Column.cjs +1 -1
- package/dist/Column.js +1 -1
- package/dist/{Drawer-CfcCPGCn.cjs → Drawer-CC24iVYp.cjs} +1 -1
- package/dist/{Drawer-DuQ5tw2t.js → Drawer-CL5Rhqw4.js} +1 -1
- package/dist/Drawer.cjs +1 -1
- package/dist/Drawer.js +1 -1
- package/dist/{Drawio-DQEgw3du.cjs → Drawio-CD_Tea_o.cjs} +1 -1
- package/dist/{Drawio-P620K_Ps.js → Drawio-LEtUoVAY.js} +1 -1
- package/dist/Drawio.cjs +1 -1
- package/dist/Drawio.js +1 -1
- package/dist/{Emoji-CYM4tY7s.js → Emoji-DN3yfwz_.js} +1 -1
- package/dist/Emoji.cjs +1 -1
- package/dist/Emoji.js +1 -1
- package/dist/{ExportPdf-BoD_D91q.js → ExportPdf-CrQVmD4l.js} +1 -1
- package/dist/ExportPdf.cjs +1 -1
- package/dist/ExportPdf.js +1 -1
- package/dist/{ExportWord-Bj9q_cyK.js → ExportWord-BM4ogH_i.js} +1 -1
- package/dist/ExportWord.cjs +1 -1
- package/dist/ExportWord.js +1 -1
- package/dist/FontFamily.cjs +1 -1
- package/dist/FontFamily.js +1 -1
- package/dist/FontSize.cjs +1 -1
- package/dist/FontSize.js +1 -1
- package/dist/{Heading-BHOPoy3X.js → Heading-Bcrl3eKU.js} +1 -1
- package/dist/Heading.cjs +1 -1
- package/dist/Heading.js +1 -1
- package/dist/{Highlight-BxKQNHmT.cjs → Highlight-cO9V18Me.cjs} +1 -1
- package/dist/{Highlight-3SpxpGDw.js → Highlight-uXDlNgw3.js} +1 -1
- package/dist/Highlight.cjs +1 -1
- package/dist/Highlight.js +1 -1
- package/dist/{History-CmI6jUTV.js → History-BoHiw0Bn.js} +1 -1
- package/dist/History.cjs +1 -1
- package/dist/History.js +1 -1
- package/dist/{HorizontalRule-BeLfU92F.js → HorizontalRule-C7mAKdzL.js} +1 -1
- package/dist/HorizontalRule.cjs +1 -1
- package/dist/HorizontalRule.js +1 -1
- package/dist/{Iframe-D-WaYtdF.cjs → Iframe-DGL_MOLf.cjs} +1 -1
- package/dist/{Iframe-C0ozlEX4.js → Iframe-D_IjezyZ.js} +1 -1
- package/dist/Iframe.cjs +1 -1
- package/dist/Iframe.js +1 -1
- package/dist/Image.cjs +1 -1
- package/dist/Image.js +1 -1
- package/dist/{ImageCropper-BVl7AuRL.js → ImageCropper-ChOGJuHZ.js} +1 -1
- package/dist/{ImageCropper-DqHxEOtN.cjs → ImageCropper-DDWnFI2-.cjs} +1 -1
- package/dist/{ImageGif-BSVyqEv6.cjs → ImageGif-3dik7FeU.cjs} +1 -1
- package/dist/{ImageGif-BvthT-Lc.js → ImageGif-D_kKkBU5.js} +1 -1
- package/dist/ImageGif.cjs +1 -1
- package/dist/ImageGif.js +1 -1
- package/dist/{ImportWord-C6EnXbyR.js → ImportWord-CtFBb_n4.js} +1 -1
- package/dist/ImportWord.cjs +1 -1
- package/dist/ImportWord.js +1 -1
- package/dist/{Indent-BuzxHbMb.js → Indent-BIk98fDV.js} +1 -1
- package/dist/{Indent-eL-WNEF4.cjs → Indent-BVMl9zKV.cjs} +1 -1
- package/dist/Indent.cjs +1 -1
- package/dist/Indent.js +1 -1
- package/dist/{Italic-D8ZI09FZ.js → Italic-3mlmsxqN.js} +1 -1
- package/dist/Italic.cjs +1 -1
- package/dist/Italic.js +1 -1
- package/dist/{Katex-46mDLDuw.cjs → Katex-C2AcX_Un.cjs} +1 -1
- package/dist/{Katex-B-lo5eMz.js → Katex-DRPWO2AM.js} +1 -1
- package/dist/Katex.cjs +1 -1
- package/dist/Katex.js +1 -1
- package/dist/LineHeight.cjs +1 -1
- package/dist/LineHeight.js +1 -1
- package/dist/{Link-CDtipqwb.js → Link-D5y_0ekP.js} +1 -1
- package/dist/Link.cjs +1 -1
- package/dist/Link.js +1 -1
- package/dist/{LinkEditBlock-D0V9PwbF.cjs → LinkEditBlock-D78J06F7.cjs} +1 -1
- package/dist/MarkdownPaste.cjs +1 -1
- package/dist/MarkdownPaste.js +1 -1
- package/dist/{Mermaid-DDV93CBT.cjs → Mermaid-B6SL3cf5.cjs} +1 -1
- package/dist/{Mermaid-Cb8MiE1N.js → Mermaid-BaTtCsrD.js} +1 -1
- package/dist/Mermaid.cjs +1 -1
- package/dist/Mermaid.js +1 -1
- package/dist/{MoreMark-CJ3nTD1T.js → MoreMark-Bfsa3STU.js} +1 -1
- package/dist/MoreMark.cjs +1 -1
- package/dist/MoreMark.js +1 -1
- package/dist/OrderedList.cjs +1 -1
- package/dist/OrderedList.js +1 -1
- package/dist/{ReasonDocs-BliNN1Tt.cjs → ReasonDocs-Bjefr26w.cjs} +1 -1
- package/dist/{ReasonDocs-4vxZ3zY7.js → ReasonDocs-_hTAa8-q.js} +1 -1
- package/dist/{RichTextProvider-Dl77gVJI.cjs → RichTextProvider-BuTrDlZY.cjs} +1 -1
- package/dist/{RichTextProvider-E6rbc_J2.js → RichTextProvider-D9EtjDKS.js} +1 -1
- package/dist/SearchAndReplace.cjs +1 -1
- package/dist/SearchAndReplace.js +1 -1
- package/dist/{SlashCommand-DtlUkwyM.js → SlashCommand-Cg-Rvv3o.js} +1 -1
- package/dist/SlashCommand.js +1 -1
- package/dist/{Strike-CWYl45VK.js → Strike-CSxbYwpk.js} +1 -1
- package/dist/Strike.cjs +1 -1
- package/dist/Strike.js +1 -1
- package/dist/{Table-DCLsW5DJ.js → Table-CFcOg-4n.js} +1 -1
- package/dist/{Table-C9RAHNEk.cjs → Table-Do_kTawS.cjs} +1 -1
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/TaskList.cjs +1 -1
- package/dist/TaskList.js +1 -1
- package/dist/{TextAlign-D4UgbJ7F.cjs → TextAlign-CcsTIs-9.cjs} +1 -1
- package/dist/{TextAlign-9ezg8E99.js → TextAlign-Dun3_Ozv.js} +1 -1
- package/dist/TextAlign.cjs +1 -1
- package/dist/TextAlign.js +1 -1
- package/dist/TextDirection.cjs +1 -1
- package/dist/TextDirection.js +1 -1
- package/dist/{TextUnderline-C5A078R0.js → TextUnderline-Cqm5NQVW.js} +1 -1
- package/dist/TextUnderline.cjs +1 -1
- package/dist/TextUnderline.js +1 -1
- package/dist/{Twitter-D7ulyHFD.cjs → Twitter-B4IYTs3E.cjs} +1 -1
- package/dist/{Twitter-ByGJ4v1K.js → Twitter-CZHAICpz.js} +1 -1
- package/dist/Twitter.cjs +1 -1
- package/dist/Twitter.js +1 -1
- package/dist/{Video-hhw77FP4.js → Video-5nw_Zeob.js} +1 -1
- package/dist/{Video-ConJGjxP.cjs → Video-CtGR5VVD.cjs} +1 -1
- package/dist/Video.cjs +1 -1
- package/dist/Video.js +1 -1
- package/dist/WordCount.cjs +1 -1
- package/dist/WordCount.js +1 -1
- package/dist/bubble-BhkjoWdo.js +79 -0
- package/dist/bubble.cjs +1 -1
- package/dist/bubble.js +1 -1
- package/dist/{cdn-loader-BGIuN138-wkFA6jnE.cjs → cdn-loader-BGIuN138-7PrAg-Ef.cjs} +1 -1
- package/dist/docs-agent.cjs +1 -1
- package/dist/docs-agent.js +1 -1
- package/dist/editor-kit.cjs +1 -1
- package/dist/editor-kit.js +1 -1
- package/dist/editorConfig-BR7z-P0e.js +18 -0
- package/dist/editorConfig-CHBSp2KG.cjs +1 -0
- package/dist/extensions/Ai/Ai.d.ts +22 -5
- package/dist/extensions/Ai/commands.d.ts +6 -1
- package/dist/extensions/Ai/components/AiMenu.d.ts +6 -5
- package/dist/extensions/Ai/components/RichTextAi.d.ts +12 -0
- package/dist/extensions/Ai/index.d.ts +9 -3
- package/dist/extensions/Ai/lib/completionToContent.d.ts +35 -0
- package/dist/extensions/Ai/lib/createStreamingCompletion.d.ts +27 -0
- package/dist/extensions/Ai/lib/prompt.d.ts +38 -0
- package/dist/extensions/Ai/lib/sanitizeCompletion.d.ts +37 -0
- package/dist/extensions/Ai/types.d.ts +47 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/marked.esm-B7mQ2Kzc.cjs +1 -0
- package/dist/marked.esm-CNm6O672.js +1 -0
- package/dist/{react-BQVDEMs2.cjs → react-Bfe0Tko8.cjs} +1 -1
- package/dist/reason-docs.cjs +1 -1
- package/dist/reason-docs.js +1 -1
- package/dist/{reason-toolbar-skin-9xQLtzeK.js → reason-toolbar-skin-BNYK97ET.js} +1 -1
- package/dist/{reason-toolbar-skin-DyYu9ywU.cjs → reason-toolbar-skin-CD4T53He.cjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/useButtonProps-BBiR6DPI.cjs +1 -0
- package/dist/useButtonProps-Codtb0k0.js +1 -0
- package/package.json +1 -1
- package/dist/Ai-BGpnAE8s.js +0 -1
- package/dist/Ai-CORhNCSN.cjs +0 -1
- package/dist/BubbleMenus-QlttKSIN.cjs +0 -1
- package/dist/BubbleMenus-mwxYB3IU.js +0 -195
- package/dist/MarkdownPaste-C5jQ33SR.js +0 -1
- package/dist/bubble-CpeBzXMe.js +0 -78
- package/dist/editorConfig-D-Tlrdwj.js +0 -18
- package/dist/editorConfig-Du7YaEDm.cjs +0 -1
- package/dist/useButtonProps-BFfsKvCi.cjs +0 -1
- package/dist/useButtonProps-BZwO1Of-.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./dist-2-kjLBhJ.cjs"),r=require("./toggle-JU5XOZYT.cjs"),o=require("./locales-DRkmn37v.cjs"),l=require("./button-5s-zJAUQ.cjs"),n=require("./dialog-DbI7mYml.cjs"),s=require("./throttle-COe5rswR.cjs"),i=require("./useButtonProps-BFfsKvCi.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("@tiptap/core"),g=require("react/jsx-runtime"),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}),[u,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,g.jsx)(h.NodeViewWrapper,{className:"image-view",style:{...N,width:"100%",textAlign:y},children:(0,g.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,g.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,g.jsx)("div",{className:"image-resizer",children:C?.map(e=>(0,g.jsx)("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:r=>function(e,r){e.preventDefault(),e.stopPropagation();const o=u.width,l=o/u.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsxs)("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,g.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,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsx)("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function N(e){return(0,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsx)("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function H(e){return(0,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,g.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,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsx)("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function A(e){return(0,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("div",{className:R.colorWrap,children:I.map((l,n)=>(0,g.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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:R.colorWrap,children:W.slice(0,7).map((l,n)=>(0,g.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))}),(0,g.jsx)("div",{className:R.colorWrap,children:W.slice(7).map((l,n)=>(0,g.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,g.jsxs)("div",{className:R.options,children:[(0,g.jsx)("div",{children:(0,g.jsx)(G,{onChange:t=>e(t)})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("div",{children:(0,g.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,g.jsx)("div",{className:R.options,children:(0,g.jsx)(V,{onChange:t=>e(t)})})}function Z({changeColorShape:e,changeBorderColorShape:t,onThicknessChange:r}){return(0,g.jsxs)("div",{className:R.options,children:[(0,g.jsx)("div",{children:(0,g.jsx)(G,{onChange:t=>e(t)})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("div",{children:(0,g.jsx)(G,{onChange:e=>t(e)})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("div",{children:(0,g.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:u,onClear:m}=e,[x,p]=(0,d.useState)(null),[w,v]=(0,d.useState)(0);return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)("div",{className:R.wrapper,children:[(0,g.jsxs)("div",{className:R.pen,children:[(0,g.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,g.jsx)(j,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(b,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(f,{})}),(0,g.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,g.jsx)(T,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(y,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(k,{})}),(0,g.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,g.jsx)(N,{})}),(0,g.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,g.jsx)(H,{})}),(0,g.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,g.jsx)(M,{})}),(0,g.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,g.jsx)(E,{})}),(0,g.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,g.jsx)(L,{})}),(0,g.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,g.jsx)(q,{})}),(0,g.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,g.jsx)(B,{})}),(0,g.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,g.jsx)(P,{})}),(0,g.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,g.jsx)(z,{})}),(0,g.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,g.jsx)(D,{})}),(0,g.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,g.jsx)(F,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("button",{className:t.cn(R.tool),onClick:i,children:(0,g.jsx)(A,{})}),(0,g.jsx)("button",{className:t.cn(R.tool),onClick:u,children:(0,g.jsx)(S,{})}),(0,g.jsx)("button",{className:t.cn(R.tool),onClick:m,children:(0,g.jsx)(_,{})})]}),(0,g.jsxs)("div",{className:R.optionsWrap,children:["pencil"===x&&(0,g.jsx)($,{setColorPen:r,setThicknessPen:l}),"highlighter"===x&&(0,g.jsx)(O,{setColorHighlight:n}),"shapes"===x&&(0,g.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),[u,x]=(0,d.useState)(!1),p=(0,d.useRef)(null),w=(0,d.useRef)(null);(0,d.useEffect)(()=>{u&&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)},[u]);const v=()=>{if(X){for(;p.current.history.redoStackSize>0;)p.current.history.redo();X=!1}else p.current.history.undo()};return t?(0,g.jsxs)(n.Dialog,{onOpenChange:x,open:u,children:[(0,g.jsx)(n.DialogTrigger,{asChild:!0,children:(0,g.jsx)(r.ActionButton,{disabled:h,action:()=>{h||x(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),(0,g.jsxs)(n.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,g.jsx)(n.DialogTitle,{children:"Drawer"}),(0,g.jsxs)("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[(0,g.jsx)("div",{className:"richtext-size-full",id:"easydrawer"}),(0,g.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,g.jsx)(n.DialogFooter,{children:(0,g.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,g.jsx)(g.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,u.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-2-kjLBhJ.cjs"),r=require("./toggle-JU5XOZYT.cjs"),o=require("./locales-DRkmn37v.cjs"),l=require("./button-5s-zJAUQ.cjs"),n=require("./dialog-DbI7mYml.cjs"),s=require("./throttle-COe5rswR.cjs"),i=require("./useButtonProps-BBiR6DPI.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("@tiptap/core"),g=require("react/jsx-runtime"),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}),[u,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,g.jsx)(h.NodeViewWrapper,{className:"image-view",style:{...N,width:"100%",textAlign:y},children:(0,g.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,g.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,g.jsx)("div",{className:"image-resizer",children:C?.map(e=>(0,g.jsx)("span",{className:`image-resizer__handler image-resizer__handler--${e}`,onMouseDown:r=>function(e,r){e.preventDefault(),e.stopPropagation();const o=u.width,l=o/u.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsxs)("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,g.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,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsx)("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function N(e){return(0,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsx)("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function H(e){return(0,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[(0,g.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,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.jsx)("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function A(e){return(0,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,g.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,g.jsx)("div",{className:R.colorWrap,children:I.map((l,n)=>(0,g.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,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("div",{className:R.colorWrap,children:W.slice(0,7).map((l,n)=>(0,g.jsx)("button",{style:{backgroundColor:l.toHexString()},className:t.cn(R.color,{[R.colorActive]:r.toHexString()===l.toHexString()}),onClick:()=>{o(l),e(l)}},n))}),(0,g.jsx)("div",{className:R.colorWrap,children:W.slice(7).map((l,n)=>(0,g.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,g.jsxs)("div",{className:R.options,children:[(0,g.jsx)("div",{children:(0,g.jsx)(G,{onChange:t=>e(t)})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("div",{children:(0,g.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,g.jsx)("div",{className:R.options,children:(0,g.jsx)(V,{onChange:t=>e(t)})})}function Z({changeColorShape:e,changeBorderColorShape:t,onThicknessChange:r}){return(0,g.jsxs)("div",{className:R.options,children:[(0,g.jsx)("div",{children:(0,g.jsx)(G,{onChange:t=>e(t)})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("div",{children:(0,g.jsx)(G,{onChange:e=>t(e)})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("div",{children:(0,g.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:u,onClear:m}=e,[x,p]=(0,d.useState)(null),[w,v]=(0,d.useState)(0);return(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)("div",{className:R.wrapper,children:[(0,g.jsxs)("div",{className:R.pen,children:[(0,g.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,g.jsx)(j,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(b,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(f,{})}),(0,g.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,g.jsx)(T,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(y,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.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,g.jsx)(k,{})}),(0,g.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,g.jsx)(N,{})}),(0,g.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,g.jsx)(H,{})}),(0,g.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,g.jsx)(M,{})}),(0,g.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,g.jsx)(E,{})}),(0,g.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,g.jsx)(L,{})}),(0,g.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,g.jsx)(q,{})}),(0,g.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,g.jsx)(B,{})}),(0,g.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,g.jsx)(P,{})}),(0,g.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,g.jsx)(z,{})}),(0,g.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,g.jsx)(D,{})}),(0,g.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,g.jsx)(F,{})}),(0,g.jsx)("div",{className:R.line}),(0,g.jsx)("button",{className:t.cn(R.tool),onClick:i,children:(0,g.jsx)(A,{})}),(0,g.jsx)("button",{className:t.cn(R.tool),onClick:u,children:(0,g.jsx)(S,{})}),(0,g.jsx)("button",{className:t.cn(R.tool),onClick:m,children:(0,g.jsx)(_,{})})]}),(0,g.jsxs)("div",{className:R.optionsWrap,children:["pencil"===x&&(0,g.jsx)($,{setColorPen:r,setThicknessPen:l}),"highlighter"===x&&(0,g.jsx)(O,{setColorHighlight:n}),"shapes"===x&&(0,g.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),[u,x]=(0,d.useState)(!1),p=(0,d.useRef)(null),w=(0,d.useRef)(null);(0,d.useEffect)(()=>{u&&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)},[u]);const v=()=>{if(X){for(;p.current.history.redoStackSize>0;)p.current.history.redo();X=!1}else p.current.history.undo()};return t?(0,g.jsxs)(n.Dialog,{onOpenChange:x,open:u,children:[(0,g.jsx)(n.DialogTrigger,{asChild:!0,children:(0,g.jsx)(r.ActionButton,{disabled:h,action:()=>{h||x(!0)},icon:"PencilRuler",tooltip:"Drawer"})}),(0,g.jsxs)(n.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[(0,g.jsx)(n.DialogTitle,{children:"Drawer"}),(0,g.jsxs)("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[(0,g.jsx)("div",{className:"richtext-size-full",id:"easydrawer"}),(0,g.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,g.jsx)(n.DialogFooter,{children:(0,g.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,g.jsx)(g.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,u.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,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./dist-DmY5xFkC.js";import{n as t}from"./toggle-BnR5VE66.js";import{g as o}from"./locales-rT_qjKW9.js";import{t as r}from"./button-D_m2J53A.js";import{a as l,n,o as i,r as a,t as s}from"./dialog-B9I9biS2.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-
|
|
1
|
+
import{o as e}from"./dist-DmY5xFkC.js";import{n as t}from"./toggle-BnR5VE66.js";import{g as o}from"./locales-rT_qjKW9.js";import{t as r}from"./button-D_m2J53A.js";import{a as l,n,o as i,r as a,t as s}from"./dialog-B9I9biS2.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-Codtb0k0.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{mergeAttributes as L}from"@tiptap/core";import{Fragment as M,jsx as E,jsxs as A}from"react/jsx-runtime";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 M=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",M,!0),document?.addEventListener("mouseup",z,!0)},[M,z]),_=x(()=>{document?.removeEventListener("mousemove",M,!0),document?.removeEventListener("mouseup",z,!0)},[M,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__ */E(C,{className:"image-view",style:{...T,width:"100%",textAlign:w},children:/* @__PURE__ */A("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__ */E("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__ */E("div",{className:"image-resizer",children:d?.map(e=>/* @__PURE__ */E("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 E("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */E("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 E("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */E("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 E("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:/* @__PURE__ */E("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__ */
|
package/dist/Drawer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const r=require("./Drawer-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const r=require("./Drawer-CC24iVYp.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-
|
|
1
|
+
import{n as r,t as a}from"./Drawer-CL5Rhqw4.js";export{a as Drawer,r as RichTextDrawer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./toggle-JU5XOZYT.cjs"),i=require("./button-5s-zJAUQ.cjs"),r=require("./dialog-DbI7mYml.cjs"),n=require("./events.constant-BkYOoqSk.cjs"),a=require("./useButtonProps-
|
|
1
|
+
const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./toggle-JU5XOZYT.cjs"),i=require("./button-5s-zJAUQ.cjs"),r=require("./dialog-DbI7mYml.cjs"),n=require("./events.constant-BkYOoqSk.cjs"),a=require("./useButtonProps-BBiR6DPI.cjs"),s=require("./dom-dataset-w2ZYeuXJ.cjs"),o=require("./externalLibsMode-Dm8a-Jd9.cjs");let d=require("@tiptap/react"),l=require("react");l=e.__toESM(l,1);let u=require("clsx");u=e.__toESM(u,1);let c=require("@tiptap/core"),m=require("react/jsx-runtime"),p=require("re-resizable");var h="_wrap_x15sz_1",w="_renderWrap_x15sz_7",g="_handlerWrap_x15sz_30",x="_disabled_x15sz_40",b="_active_x15sz_44",f={width:"100%",height:"100%",maxWidth:"100%"};function j({editor:e,node:i,updateAttributes:r}){(0,l.useRef)(null);const n=a.useEditableEditor(),s=e.isActive(D.name),{data:o,width:c,height:j}=i.attrs,[v,y]=(0,l.useState)(null),[E,S]=(0,l.useState)(!0),[T,_]=(0,l.useState)(null),[A,N]=(0,l.useState)(100),L=(0,l.useCallback)(e=>()=>{N(t=>a.clamp("minus"===e?t-15:t+15,10,200))},[]);(0,l.useEffect)(()=>{if(!o?.xml)return void S(!1);S(!0),_(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?y(i.data):_(new Error("Unable to render diagram preview")),S(!1))};window.addEventListener("message",t);const i=window.setTimeout(()=>{_(new Error("Timed out loading diagram preview")),S(!1)},15e3);return()=>{window.clearTimeout(i),window.removeEventListener("message",t),document.body.removeChild(e)}},[o]);return(0,m.jsx)(d.NodeViewWrapper,{className:(0,u.default)(h,{[b]:s,[x]:!n}),children:(0,m.jsx)(p.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(j)},onResizeStop:(e,t,i,n)=>{var a;a={width:Number.parseInt(c)+n.width,height:Number.parseInt(j)+n.height},r({width:a.width,height:a.height})},children:(0,m.jsxs)("div",{className:(0,u.default)(w,"render-wrapper"),style:{...f,overflow:"hidden"},children:[T&&(0,m.jsx)("div",{style:f,children:(0,m.jsx)("p",{children:T.message||T})}),E&&(0,m.jsx)("p",{children:"Loading diagram..."}),!E&&!T&&v&&(0,m.jsx)("div",{style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${A/100})`,transition:"all ease-in-out .3s"},children:(0,m.jsx)("img",{alt:"Diagram preview",src:v,style:{maxWidth:"100%",maxHeight:"100%"}})}),!E&&!T&&!v&&o?.xml&&(0,m.jsx)("div",{style:f,children:(0,m.jsx)("p",{children:"Diagram data present but unable to render preview"})}),(0,m.jsxs)("div",{className:g,children:[(0,m.jsx)(t.ActionButton,{action:L("minus"),disabled:!n,icon:"ZoomOut",tooltip:"Zoom Out"}),(0,m.jsx)(t.ActionButton,{action:L("plus"),disabled:!n,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}function v(){const e=a.useEditorInstance(),s=a.useButtonProps(D.name),d=a.useExtension(D.name),{tooltipOptions:u={},isActive:c}=s?.componentProps??{},{editorDisabled:p}=a.useToggleActive(c);(0,l.useMemo)(()=>d?.options||{},[d]);const h=o.useExternalLibsMode(),[w,g]=(0,l.useState)(null),[x,b]=(0,l.useState)(""),[f,j]=(0,l.useState)(!1),[v,y]=(0,l.useState)(!0),[E,S]=(0,l.useState)(null),[T,_]=(0,l.useState)(0),A=(0,l.useRef)(null),N=(0,l.useCallback)(()=>{if(w)try{w.contentWindow?.postMessage(JSON.stringify({action:"export",format:"xml"}),"*")}catch(e){S(e)}else j(!1)},[w]),L=(0,l.useCallback)(t=>{if(!w||t.source!==w.contentWindow||"string"!=typeof t.data)return;let i;try{i=JSON.parse(t.data)}catch{return}if("init"===i.event)A.current&&(window.clearTimeout(A.current),A.current=null),y(!1),x&&w.contentWindow?.postMessage(JSON.stringify({action:"load",xml:x,autosave:1}),"*");else if("export"===i.event){const t=i.xml||i.data;t?(b(t),e.chain().focus().setDrawio({data:{xml:t}}).run(),j(!1)):S(new Error("Unable to export diagram"))}},[e,x,w]),M=n.EVENTS.DRAWIO?.(e.id)||`drawio-${e.id}`;n.useListener(e=>{j(!0),S(null),b(e?.data?.xml?e.data.xml:"")},[M]),(0,l.useEffect)(()=>(window.addEventListener("message",L),()=>{window.removeEventListener("message",L)}),[L]),(0,l.useEffect)(()=>{if(f)return y(!0),S(null),A.current=window.setTimeout(()=>{S(new Error("Timed out waiting for the Draw.io editor to load. Check your network connection and try again.")),y(!1)},15e3),()=>{A.current&&(window.clearTimeout(A.current),A.current=null)}},[f,T]);const C=(0,l.useCallback)(()=>{S(null),_(e=>e+1)},[]);return(0,m.jsxs)(r.Dialog,{onOpenChange:j,open:f,children:[(0,m.jsx)(r.DialogTrigger,{asChild:!0,children:(0,m.jsx)(t.ActionButton,{disabled:p,icon:"Drawio",tooltip:"Draw.io",tooltipOptions:u,action:()=>{p||j(!0)}})}),(0,m.jsxs)(r.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1400px]",children:[(0,m.jsx)(r.DialogTitle,{children:"Draw.io Diagram"}),(0,m.jsxs)("div",{style:{height:"100%",borderWidth:1},children:[v&&(0,m.jsx)("p",{children:"Loading editor..."}),E&&(0,m.jsxs)("div",{children:[(0,m.jsx)("p",{children:E&&E.message||"Error loading editor"}),(0,m.jsx)(i.Button,{onClick:C,type:"button",children:"Retry"})]}),"bundled"===h&&(v||E)&&(0,m.jsx)("p",{style:{opacity:.7,fontSize:12},children:'Draw.io always loads diagrams.net in an embedded frame and needs network access, even with "Bundled (offline)" library loading enabled — that setting only applies to KaTeX and Mermaid.'}),!E&&(0,m.jsx)("iframe",{ref:g,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:v?"none":"block"},title:"Draw.io Editor",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms allow-modals"},T)]}),(0,m.jsx)(r.DialogFooter,{children:(0,m.jsx)(i.Button,{disabled:v,onClick:N,type:"button",children:"Save Diagram"})})]})]})}var y={xml:""},D=c.Node.create({name:"drawio",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes:()=>({defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:s.getDatasetAttribute("width")},height:{default:400,parseHTML:s.getDatasetAttribute("height")},data:{default:y,parseHTML:s.getDatasetAttribute("data",!0)}}),addOptions(){return{...this.parent?.(),HTMLAttributes:{class:"drawio"},drawioProps:{},button:()=>({componentProps:{}})}},parseHTML:()=>[{tag:"div[class=drawio]"}],renderHTML({HTMLAttributes:e,node:t}){return["div",(0,c.mergeAttributes)(this.options.HTMLAttributes,e,s.nodeAttrsToDataset(t))]},addCommands(){return{setDrawio:e=>({tr:t,commands:i,chain:r})=>((e=e||{}).data=e.data||y,t.selection?.node?.type?.name==this.name?i.updateAttributes(this.name,e):r().insertContent({type:this.name,attrs:e}).run())}},addNodeView:()=>(0,d.ReactNodeViewRenderer)(j),addInputRules(){return[(0,c.nodeInputRule)({find:/^\$drawio\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});Object.defineProperty(exports,"Drawio",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"RichTextDrawio",{enumerable:!0,get:function(){return v}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./toggle-BnR5VE66.js";import{t}from"./button-D_m2J53A.js";import{a as i,n as r,o as n,r as a,t as o}from"./dialog-B9I9biS2.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 u,t as h}from"./useButtonProps-
|
|
1
|
+
import{n as e}from"./toggle-BnR5VE66.js";import{t}from"./button-D_m2J53A.js";import{a as i,n as r,o as n,r as a,t as o}from"./dialog-B9I9biS2.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 u,t as h}from"./useButtonProps-Codtb0k0.js";import{n as w,t as g}from"./dom-dataset-D3Nz0h73.js";import{r as f}from"./externalLibsMode-DEDBnK98.js";import{NodeViewWrapper as b,ReactNodeViewRenderer as v}from"@tiptap/react";import x,{useCallback as y,useEffect as T,useMemo as L,useRef as _,useState as D}from"react";import N from"clsx";import{Node as M,mergeAttributes as E,nodeInputRule as O}from"@tiptap/core";import{jsx as j,jsxs as W}from"react/jsx-runtime";import{Resizable as z}from"re-resizable";var A="_wrap_x15sz_1",C="_renderWrap_x15sz_7",H="_handlerWrap_x15sz_30",I="_disabled_x15sz_40",S="_active_x15sz_44",k={width:"100%",height:"100%",maxWidth:"100%"};function J({editor:t,node:i,updateAttributes:r}){_(null);const n=c(),a=t.isActive(R.name),{data:o,width:s,height:d}=i.attrs,[l,m]=D(null),[u,h]=D(!0),[w,g]=D(null),[f,v]=D(100),x=y(e=>()=>{v(t=>p("minus"===e?t-15:t+15,10,200))},[]);T(()=>{if(!o?.xml)return void h(!1);h(!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")),h(!1))};window.addEventListener("message",t);const i=window.setTimeout(()=>{g(/* @__PURE__ */new Error("Timed out loading diagram preview")),h(!1)},15e3);return()=>{window.clearTimeout(i),window.removeEventListener("message",t),document.body.removeChild(e)}},[o]);/* @__PURE__ */
|
|
2
2
|
return j(b,{className:N(A,{[S]:a,[I]:!n}),children:/* @__PURE__ */j(z,{size:{width:Number.parseInt(s),height:Number.parseInt(d)},onResizeStop:(e,t,i,n)=>{var a;a={width:Number.parseInt(s)+n.width,height:Number.parseInt(d)+n.height},r({width:a.width,height:a.height})},children:/* @__PURE__ */W("div",{className:N(C,"render-wrapper"),style:{...k,overflow:"hidden"},children:[w&&/* @__PURE__ */j("div",{style:k,children:/* @__PURE__ */j("p",{children:w.message||w})}),u&&/* @__PURE__ */j("p",{children:"Loading diagram..."}),!u&&!w&&l&&/* @__PURE__ */j("div",{style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${f/100})`,transition:"all ease-in-out .3s"},children:/* @__PURE__ */j("img",{alt:"Diagram preview",src:l,style:{maxWidth:"100%",maxHeight:"100%"}})}),!u&&!w&&!l&&o?.xml&&/* @__PURE__ */j("div",{style:k,children:/* @__PURE__ */j("p",{children:"Diagram data present but unable to render preview"})}),
|
|
3
3
|
/* @__PURE__ */W("div",{className:H,children:[/* @__PURE__ */j(e,{action:x("minus"),disabled:!n,icon:"ZoomOut",tooltip:"Zoom Out"}),/* @__PURE__ */j(e,{action:x("plus"),disabled:!n,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}function P(){const c=m(),p=h(R.name),w=u(R.name),{tooltipOptions:g={},isActive:b}=p?.componentProps??{},{editorDisabled:v}=l(b);L(()=>w?.options||{},[w]);const x=f(),[N,M]=D(null),[E,O]=D(""),[z,A]=D(!1),[C,H]=D(!0),[I,S]=D(null),[k,J]=D(0),P=_(null),$=y(()=>{if(N)try{N.contentWindow?.postMessage(JSON.stringify({action:"export",format:"xml"}),"*")}catch(e){S(e)}else A(!1)},[N]),Z=y(e=>{if(!N||e.source!==N.contentWindow||"string"!=typeof e.data)return;let t;try{t=JSON.parse(e.data)}catch{return}if("init"===t.event)P.current&&(window.clearTimeout(P.current),P.current=null),H(!1),E&&N.contentWindow?.postMessage(JSON.stringify({action:"load",xml:E,autosave:1}),"*");else if("export"===t.event){const e=t.xml||t.data;e?(O(e),c.chain().focus().setDrawio({data:{xml:e}}).run(),A(!1)):S(/* @__PURE__ */new Error("Unable to export diagram"))}},[c,E,N]),B=d.DRAWIO?.(c.id)||`drawio-${c.id}`;s(e=>{A(!0),S(null),O(e?.data?.xml?e.data.xml:"")},[B]),T(()=>(window.addEventListener("message",Z),()=>{window.removeEventListener("message",Z)}),[Z]),T(()=>{if(z)return H(!0),S(null),P.current=window.setTimeout(()=>{S(/* @__PURE__ */new Error("Timed out waiting for the Draw.io editor to load. Check your network connection and try again.")),H(!1)},15e3),()=>{P.current&&(window.clearTimeout(P.current),P.current=null)}},[z,k]);const U=y(()=>{S(null),J(e=>e+1)},[]);/* @__PURE__ */
|
|
4
4
|
return W(o,{onOpenChange:A,open:z,children:[/* @__PURE__ */j(n,{asChild:!0,children:/* @__PURE__ */j(e,{disabled:v,icon:"Drawio",tooltip:"Draw.io",tooltipOptions:g,action:()=>{v||A(!0)}})}),/* @__PURE__ */W(r,{className:"richtext-z-[99999] !richtext-max-w-[1400px]",children:[
|
package/dist/Drawio.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const r=require("./Drawio-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const r=require("./Drawio-CD_Tea_o.cjs");exports.Drawio=r.Drawio,exports.RichTextDrawio=r.RichTextDrawio;
|
package/dist/Drawio.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as o,t as r}from"./Drawio-
|
|
1
|
+
import{n as o,t as r}from"./Drawio-LEtUoVAY.js";export{r as Drawio,o as RichTextDrawio};
|