reactjs-tiptap-editor 1.0.14 → 1.0.16
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/lib/{ActionMenuButton-DNj0f_A4.cjs → ActionMenuButton-BYu0NyVo.cjs} +1 -1
- package/lib/{ActionMenuButton-l5rSmAO_.js → ActionMenuButton-a8LhmHXe.js} +5 -5
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +6 -6
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +4 -4
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +4 -4
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +4 -4
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +36 -40
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +3 -3
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +4 -4
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +6 -6
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +4 -4
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +6 -6
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +4 -4
- package/lib/{Drawer-Cbi_MURj.js → Drawer-CbOJ1Igo.js} +8 -8
- package/lib/{Drawer-DKU32YW_.cjs → Drawer-DNaDMoAk.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +3 -3
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +212 -2076
- package/lib/{Excalidraw-CWrVL5hs.js → Excalidraw-DnHTVOj8.js} +6 -6
- package/lib/{Excalidraw-Kb-TRcWY.cjs → Excalidraw-DxfO1lQ_.cjs} +1 -1
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +2 -2
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +4 -4
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +4 -4
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +6 -6
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +6 -6
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +6 -6
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +6 -6
- package/lib/History.cjs +1 -1
- package/lib/History.js +22 -22
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +4 -4
- package/lib/{Icon-Ctva8VeB.js → Icon-C0TJMAOm.js} +2 -2
- package/lib/{Icon-yqCglrdK.cjs → Icon-DzK0_ztP.cjs} +1 -1
- package/lib/{Iframe-BczF8Hex.cjs → Iframe-BSNCsofW.cjs} +1 -1
- package/lib/{Iframe-C942bNjs.js → Iframe-CmjbQQcz.js} +6 -6
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +2 -2
- package/lib/Image-BZEFuS0P.js +925 -0
- package/lib/Image-iKsGKjvg.cjs +1 -0
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +5 -828
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +9 -9
- package/lib/ImportWord.cjs +1 -231
- package/lib/ImportWord.js +91 -16623
- package/lib/{Indent-C_O5WdyR.js → Indent-BoG-vpIE.js} +4 -4
- package/lib/{Indent-CkEC7x36.cjs → Indent-Bou16OcB.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +4 -4
- package/lib/Katex-BqDocr3a.cjs +4 -0
- package/lib/{Katex-D3PEWimM.js → Katex-ByL9snce.js} +369 -347
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +2 -2
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +7 -7
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-DL1e2ILk.cjs → LinkEditBlock-B0I0EUrt.cjs} +1 -1
- package/lib/{LinkEditBlock-h5054QDo.js → LinkEditBlock-Ckih17pU.js} +11 -11
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +41 -63
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +16 -16
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +7 -7
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +4 -4
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +11 -11
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +9 -9
- package/lib/{SlashCommandNodeView-DXUqkx82.js → SlashCommandNodeView-B2g1MbgN.js} +76 -83
- package/lib/SlashCommandNodeView-BEJhEzba.cjs +1 -0
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +4 -4
- package/lib/{Table-DdrY4jcM.js → Table-BEwrZVup.js} +22 -22
- package/lib/{Table-kY0nbqJo.cjs → Table-BclWwp6P.cjs} +1 -1
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +4 -4
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +7 -7
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +7 -7
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +4 -4
- package/lib/{Twitter-B-JQ3ZJ1.js → Twitter-4U_ZBhpv.js} +10 -10
- package/lib/{Twitter-DjZcVa3l.cjs → Twitter-Dtq6PEMC.cjs} +1 -1
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +2 -2
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +9 -9
- package/lib/bubble.cjs +1 -1
- package/lib/bubble.js +27 -27
- package/lib/{button-Uv01FNnd.js → button-Bwn6gUuS.js} +2 -2
- package/lib/{button-BS3n6_Aq.cjs → button-CqJztfH2.cjs} +1 -1
- package/lib/{checkbox-C8ByRi7-.cjs → checkbox-BAzbZY2Y.cjs} +1 -1
- package/lib/{checkbox-DEFNwGwb.js → checkbox-B_rpz5Xq.js} +1 -1
- package/lib/{clsx-BWSGDJNJ.js → clsx-DSzxBzvL.js} +11 -11
- package/lib/{dialog-DwTMZSt6.js → dialog-CJvpoeMm.js} +1 -1
- package/lib/{dialog-Bt5zwGYB.cjs → dialog-CWYTvz5J.cjs} +1 -1
- package/lib/{dropdown-menu-BetI14G6.js → dropdown-menu-CW3Kthwy.js} +1 -1
- package/lib/{dropdown-menu-Bo68IEOT.cjs → dropdown-menu-eUeBXQeA.cjs} +1 -1
- package/lib/extensions/Emoji/Emoji.d.ts +3 -1
- package/lib/extensions/Emoji/components/EmojiList/EmojiNodeView.d.ts +9 -1
- package/lib/{index-CHKWG6E8.js → index-4bHF5ovf.js} +1 -1
- package/lib/index-BG0kQamI.js +285 -0
- package/lib/{index-Doks9cbR.cjs → index-BsFvo9PG.cjs} +1 -1
- package/lib/{index-Dujzr6bY.js → index-C07N8gA1.js} +69 -73
- package/lib/{index-CcoWj0mF.js → index-CL7JP-Xz.js} +1 -1
- package/lib/index-Cn-t3Zxw.cjs +1 -0
- package/lib/{index-mR8PNv5P.js → index-CpTykZBR.js} +1 -1
- package/lib/{index-BDKHXe7R.js → index-D8li6EQ4.js} +1 -1
- package/lib/{index-DJbmnBzK.js → index-DR5tIdL7.js} +1 -1
- package/lib/{index-DF5ZPtWM.js → index-DoiuU6VA.js} +54 -56
- package/lib/index-NsYff_Ni.cjs +1 -0
- package/lib/index.cjs +2 -2
- package/lib/index.js +4 -4
- package/lib/{input-DUBdJD3L.js → input-B1egKb-t.js} +1 -1
- package/lib/{input-Dt_BA_9B.cjs → input-ZGRt7lWR.cjs} +1 -1
- package/lib/{isNumber-CIgubz2e.js → isNumber-ClwLypY2.js} +1 -1
- package/lib/{label-topD46-u.js → label-Cjrzc5H2.js} +2 -2
- package/lib/{label-JNOksCA-.cjs → label-tzSPdqui.cjs} +1 -1
- package/lib/locale-bundle.cjs +1 -1
- package/lib/locale-bundle.js +1 -1
- package/lib/locales/index.d.ts +5 -1
- package/lib/{popover-mL-2sX5r.cjs → popover-C6Cya3Cz.cjs} +1 -1
- package/lib/{popover-LfNBhRyz.js → popover-CeY3RbI5.js} +1 -1
- package/lib/renderNodeView-CSazLrKF.js +28 -0
- package/lib/renderNodeView-DfLmGrgA.cjs +1 -0
- package/lib/{select-CwGYPsPq.cjs → select-Doa_-jkZ.cjs} +1 -1
- package/lib/{select-DctYuHLH.js → select-F0ZZ3VZB.js} +1 -1
- package/lib/{separator-NoH_SLRW.cjs → separator-CUh5Y7Rh.cjs} +1 -1
- package/lib/{separator-Ddfrhn4D.js → separator-Cjn4YH8a.js} +5 -5
- package/lib/store/commandList.d.ts +1 -1
- package/lib/store/store.d.ts +7 -6
- package/lib/{store-DNpS8vXA.js → store-BsJz5QRC.js} +1 -1
- package/lib/{store-CkjKIgjQ.cjs → store-DjkMIIEN.cjs} +1 -1
- package/lib/{tabs-DRSwUeKP.cjs → tabs-BP8ypR_m.cjs} +1 -1
- package/lib/{tabs-BT3AeqQQ.js → tabs-CBDjOLl_.js} +1 -1
- package/lib/{textarea-BDO6XQoF.cjs → textarea-BAolHF_W.cjs} +1 -1
- package/lib/{textarea-DZzMEDfZ.js → textarea-tOsPnxHf.js} +1 -1
- package/lib/theme.cjs +1 -1
- package/lib/theme.js +21 -27
- package/lib/{throttle-IERhwcLa.js → throttle-D040PfWL.js} +1 -1
- package/lib/{toggle-BQHMh_Q-.cjs → toggle-C_SSvDRy.cjs} +1 -1
- package/lib/{toggle-DKHg5sLm.js → toggle-DEerYRil.js} +4 -4
- package/lib/{tooltip-DNKq7zgN.js → tooltip-BJIvosho.js} +1 -1
- package/lib/{tooltip-BYtGp6FM.cjs → tooltip-FS1rsvd3.cjs} +1 -1
- package/lib/{updatePosition-Bie75EFq.js → updatePosition-CDK7OR0i.js} +2 -2
- package/lib/{useButtonProps-DVP4s_ER.js → useButtonProps-CtZCbMQu.js} +5 -5
- package/lib/{useButtonProps-DBJkNDS2.cjs → useButtonProps-Cz4W5dC8.cjs} +1 -1
- package/lib/utils/renderNodeView.d.ts +6 -0
- package/package.json +4 -4
- package/lib/Katex-DW_HjgNM.cjs +0 -4
- package/lib/SlashCommandNodeView-BqrmHCpu.cjs +0 -1
- package/lib/_commonjsHelpers-BItOPCY9.js +0 -28
- package/lib/_commonjsHelpers-BTDuMlIz.cjs +0 -1
- package/lib/extensions/Emoji/components/EmojiList/emojis.d.ts +0 -4
- package/lib/index-D3RLYf-J.cjs +0 -1
- package/lib/react-BEoMZB61.cjs +0 -1
- package/lib/react-c9FSfB30.js +0 -27
- package/lib/use-toast-Bz3QCOtE.cjs +0 -1
- package/lib/use-toast-Crf7-q5H.js +0 -98
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const J=require("./clsx-CXbNJWDD.cjs"),K=require("./throttle-gTTvqDTW.cjs"),i=require("react/jsx-runtime"),c=require("react"),k=require("./index-BsFvo9PG.cjs"),V=require("./isNumber-BTYSVlKo.cjs"),ue=require("./toggle-C_SSvDRy.cjs");require("./index-Cn-t3Zxw.cjs");require("./theme.cjs");const O=require("./dialog-CWYTvz5J.cjs"),de=require("react-image-crop"),P=require("./button-CqJztfH2.cjs"),q=require("./useButtonProps-Cz4W5dC8.cjs"),ne=require("./file-i7e4nQY2.cjs"),X=require("./Icon-DzK0_ztP.cjs"),he=require("./store-DjkMIIEN.cjs"),ie=require("./events.constant-Dq21NPdV.cjs"),U=require("./tabs-BP8ypR_m.cjs"),ge=require("./checkbox-BAzbZY2Y.cjs"),ae=require("./label-tzSPdqui.cjs"),re=require("./input-ZGRt7lWR.cjs");function fe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const se=fe(c),me=1,pe=1e6;let Z=0;function xe(){return Z=(Z+1)%Number.MAX_SAFE_INTEGER,Z.toString()}const Q=new Map;function le(e){if(Q.has(e))return;const t=setTimeout(()=>{Q.delete(e),B({type:"REMOVE_TOAST",toastId:e})},pe);Q.set(e,t)}function be(e,t){switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,me)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===t.toast.id?{...n,...t.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=t;return n?le(n):e.toasts.forEach(r=>{le(r.id)}),{...e,toasts:e.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==t.toastId)}}}const $=[];let Y={toasts:[]};function B(e){Y=be(Y,e),$.forEach(t=>{t(Y)})}function Te({...e}){const t=xe(),n=u=>B({type:"UPDATE_TOAST",toast:{...u,id:t}}),r=()=>B({type:"DISMISS_TOAST",toastId:t});return B({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:u=>{u||r()}}}),{id:t,dismiss:r,update:n}}function ee(){const[e,t]=se.useState(Y);return se.useEffect(()=>($.push(t),()=>{const n=$.indexOf(t);n>-1&&$.splice(n,1)}),[e]),{...e,toast:Te,dismiss:n=>B({type:"DISMISS_TOAST",toastId:n})}}const H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Ie(e){var F,h,M;const[t,n]=c.useState({width:k.IMAGE_MAX_SIZE,height:k.IMAGE_MAX_SIZE}),[r,u]=c.useState({width:0,height:0}),[g]=c.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[p,S]=c.useState(!1),[f,b]=c.useState({x:0,y:0,w:0,h:0,dir:""}),{align:j,inline:w}=(F=e==null?void 0:e.node)==null?void 0:F.attrs,C=w&&(j==="left"||j==="right"),_=c.useMemo(()=>{var te;const{src:s,alt:T,width:a,height:l,flipX:m,flipY:o}=(te=e==null?void 0:e.node)==null?void 0:te.attrs,I=V.isNumber(a)?`${a}px`:a,y=V.isNumber(l)?`${l}px`:l,W=[];m&&W.push("rotateX(180deg)"),o&&W.push("rotateY(180deg)");const ce=W.join(" ");return{src:s||void 0,alt:T||void 0,style:{width:I||void 0,height:y||void 0,transform:ce||"none",...C?{float:j}:{}}}},[(h=e==null?void 0:e.node)==null?void 0:h.attrs]),D=c.useMemo(()=>{const{style:{width:s}}=_;return{width:s==="100%"?s:void 0}},[_]);function L(s){u({width:s.target.width,height:s.target.height})}function v(){const{editor:s,getPos:T}=e;s.commands.setNodeSelection(T())}const E=c.useCallback(K.throttle(()=>{const{editor:s}=e,{width:T}=getComputedStyle(s.view.dom);n(a=>({...a,width:Number.parseInt(T,10)}))},k.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function N(s,T){s.preventDefault(),s.stopPropagation();const a=r.width,l=r.height,m=a/l;let o=Number(e.node.attrs.width),I=Number(e.node.attrs.height);const y=t.width;o&&!I?(o=o>y?y:o,I=Math.round(o/m)):I&&!o?(o=Math.round(I*m),o=o>y?y:o):!o&&!I?(o=a>y?y:a,I=Math.round(o/m)):o=o>y?y:o,S(!0),b({x:s.clientX,y:s.clientY,w:o,h:I,dir:T})}const A=c.useCallback(K.throttle(s=>{if(s.preventDefault(),s.stopPropagation(),!p)return;const{x:T,w:a,dir:l}=f,m=(s.clientX-T)*(/l/.test(l)?-1:1),o=V.clamp(a+m,k.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:o,height:null})},k.IMAGE_THROTTLE_WAIT_TIME),[p,f,t,e.updateAttributes]),x=c.useCallback(s=>{s.preventDefault(),s.stopPropagation(),p&&(b({x:0,y:0,w:0,h:0,dir:""}),S(!1),v())},[p,v]),d=c.useCallback(()=>{document==null||document.addEventListener("mousemove",A,!0),document==null||document.addEventListener("mouseup",x,!0)},[A,x]),R=c.useCallback(()=>{document==null||document.removeEventListener("mousemove",A,!0),document==null||document.removeEventListener("mouseup",x,!0)},[A,x]);c.useEffect(()=>(p?d():R(),()=>{R()}),[p,d,R]);const z=c.useMemo(()=>new ResizeObserver(()=>E()),[E]);return c.useEffect(()=>(z.observe(e.editor.view.dom),()=>{z.disconnect()}),[e.editor.view.dom,z]),i.jsx(J.NodeViewWrapper,{as:w?"span":"div",className:"image-view",style:{float:C?j:void 0,margin:C?j==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:w?"inline":"block",textAlign:C?void 0:j,width:((M=_.style)==null?void 0:M.width)??"auto",...C?{}:D},children:i.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:D,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${p?"image-view__body--resizing":""}`,children:[i.jsx("img",{alt:_.alt,className:"image-view__body__image block",height:"auto",onClick:v,onLoad:L,src:_.src,style:_.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||p)&&i.jsx("div",{className:"image-resizer",children:g==null?void 0:g.map(s=>i.jsx("span",{className:`image-resizer__handler image-resizer__handler--${s}`,onMouseDown:T=>N(T,s)},`image-dir-${s}`))})]})})}function ye(e,t){const n=e.type,r=e.name.toLowerCase(),u=r.split(".").pop();if(!u)return!1;const p=n||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[u];return t.some(S=>{if(S.startsWith("."))return r.endsWith(S);if(S.endsWith("/*")){const f=S.split("/")[0];return p==null?void 0:p.startsWith(f+"/")}return p===S})}function oe(e,t){const{acceptMimes:n,maxSize:r,t:u,toast:g}=t,p=[];return(Array.isArray(e)?e:Object.values(e)).forEach(f=>{if(!ye(f,n)){t.onError?t.onError({type:"type",message:u("editor.upload.fileTypeNotSupported",{fileName:f.name}),file:f}):g({variant:"default",title:u("editor.upload.fileTypeNotSupported",{fileName:f.name})});return}if(f.size>r){const b=(r/1024/1024).toFixed(2);t.onError?t.onError({type:"size",message:u("editor.upload.fileSizeTooBig",{fileName:f.name,size:b}),file:f}):g({variant:"default",title:u("editor.upload.fileSizeTooBig",{fileName:f.name,size:b})});return}p.push(f)}),p}function Se({editor:e,imageInline:t,onClose:n,disabled:r,alt:u}){var s,T;const{t:g}=k.useLocale(),{toast:p}=ee(),[S,f]=c.useState(!1),[b,j]=c.useState(!1),w=c.useRef(null),[C,_]=c.useState(),[D,L]=c.useState(""),v=c.useRef(null),[E,N]=c.useState({src:"",file:null}),A=q.useExtension(G.name),x=c.useMemo(()=>(A==null?void 0:A.options)??{},[A]);function d(a){if(w.current&&a.width&&a.height){const l=R(w.current,a);L(l)}}function R(a,l){const m=document.createElement("canvas"),o=a.naturalWidth/a.width,I=a.naturalHeight/a.height;m.width=l.width*o,m.height=l.height*I;const y=m.getContext("2d");return y&&(y.imageSmoothingEnabled=!1,y.drawImage(a,l.x*o,l.y*I,l.width*o,l.height*I,0,0,l.width*o,l.height*I)),m.toDataURL("image/png",1)}const z=c.useCallback(async()=>{var a;if(!b){j(!0);try{const l=ne.dataURLtoFile(D,((a=E==null?void 0:E.file)==null?void 0:a.name)||"image.png");let m="";x.upload?m=await x.upload(l):m=URL.createObjectURL(l),e.chain().focus().setImageInline({src:m,inline:t,alt:u}).run(),f(!1),N({src:"",file:null}),M(),n()}catch(l){console.error("Error cropping image",l)}finally{j(!1)}}},[D,e,t,b,n,(s=E==null?void 0:E.file)==null?void 0:s.name,x]);function F(a){var l;a.preventDefault(),(l=v.current)==null||l.click()}const h=async a=>{var y;const l=(y=a==null?void 0:a.target)==null?void 0:y.files;if(!e||e.isDestroyed||l.length===0){a.target.value="";return}const m=oe(l,{acceptMimes:x==null?void 0:x.acceptMimes,maxSize:x==null?void 0:x.maxSize,t:g,toast:p,onError:x.onError});if(m.length<=0){a.target.value="";return}const o=m[0],I=await ne.readImageAsBase64(o);f(!0),N({src:I.src,file:o})},M=()=>{v.current&&(v.current.value="")};return i.jsxs(i.Fragment,{children:[i.jsx(P.Button,{className:"richtext-mt-1 richtext-w-full",disabled:r,onClick:F,size:"sm",children:g("editor.image.dialog.tab.uploadCrop")}),i.jsxs(O.Dialog,{open:S,onOpenChange:a=>{f(a),a||(N({src:"",file:null}),M())},children:[i.jsx(O.DialogTrigger,{}),i.jsxs(O.DialogContent,{children:[i.jsx(O.DialogTitle,{children:g("editor.image.dialog.tab.uploadCrop")}),i.jsx("div",{children:E.src&&i.jsx(de,{className:"richtext-w-full",crop:C,onChange:a=>_(a),onComplete:a=>d(a),children:i.jsx("img",{alt:"Crop me",ref:w,src:E.src})})}),i.jsxs(O.DialogFooter,{children:[i.jsxs(P.Button,{disabled:b,onClick:()=>{f(!1),N({src:"",file:null}),M()},children:[g("editor.imageUpload.cancel"),i.jsx(X.IconComponent,{className:"richtext-ml-1",name:"Trash2"})]}),i.jsx(P.Button,{className:"richtext-w-fit",disabled:b||!C,onClick:z,children:b?i.jsxs(i.Fragment,{children:[g("editor.imageUpload.uploading"),i.jsx(X.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):i.jsxs(i.Fragment,{children:[g("editor.imageUpload.crop"),i.jsx(X.IconComponent,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),i.jsx("input",{accept:((T=x==null?void 0:x.acceptMimes)==null?void 0:T.join(","))||"image/*",multiple:!1,onChange:h,ref:v,style:{display:"none"},type:"file"})]})}function we(){const{t:e}=k.useLocale(),{toast:t}=ee(),n=q.useEditorInstance(),r=q.useButtonProps(G.name),{icon:u,tooltip:g}=(r==null?void 0:r.componentProps)??{},{editorDisabled:p}=q.useToggleActive(),[S,f]=c.useState(!1),[b,j]=c.useState(!1),w=q.useExtension(G.name),C=h=>{f(h.detail)},[_,D]=c.useState(""),[L,v]=c.useState(""),E=c.useRef(null),N=(w==null?void 0:w.options.defaultInline)||!1,[A,x]=c.useState(N),d=c.useMemo(()=>w==null?void 0:w.options,[w]);c.useEffect(()=>{const h=ie.listenEvent(ie.EVENTS.UPLOAD_IMAGE(n.id),C);return()=>{h()}},[]);async function R(h){var T;const M=(T=h==null?void 0:h.target)==null?void 0:T.files;if(!n||n.isDestroyed||M.length===0||b){h.target.value="";return}const s=oe(M,{acceptMimes:d==null?void 0:d.acceptMimes,maxSize:d==null?void 0:d.maxSize,t:e,toast:t,onError:d.onError});if(s.length<=0){h.target.value="";return}j(!0);try{if(d!=null&&d.multiple){const a=s.map(async m=>{let o="";return d.upload?o=await d.upload(m):o=URL.createObjectURL(m),o});(await Promise.all(a)).forEach(m=>{n.chain().focus().setImageInline({src:m,inline:A,alt:L}).run()})}else{const a=s[0];let l="";d.upload?l=await d.upload(a):l=URL.createObjectURL(a),n.chain().focus().setImageInline({src:l,inline:A,alt:L}).run()}f(!1),v(""),x(N)}catch(a){console.error("Error uploading image",a),d.onError?d.onError({type:"upload",message:e("editor.upload.error")}):t({variant:"destructive",title:e("editor.upload.error")})}finally{j(!1),h.target.value=""}}function z(h){h.preventDefault(),h.stopPropagation(),n.chain().focus().setImageInline({src:_,inline:A,alt:L}).run(),f(!1),x(N),D(""),v("")}function F(h){var M;h.preventDefault(),(M=E.current)==null||M.click()}return r?i.jsxs(O.Dialog,{onOpenChange:f,open:S,children:[i.jsx(O.DialogTrigger,{asChild:!0,children:i.jsx(ue.ActionButton,{disabled:p,icon:u,tooltip:g,action:()=>{p||f(!0)}})}),i.jsxs(O.DialogContent,{children:[i.jsx(O.DialogTitle,{children:e("editor.image.dialog.title")}),i.jsxs(U.Tabs,{activationMode:"manual",defaultValue:d.resourceImage==="both"||d.resourceImage==="upload"?"upload":"link",children:[d.resourceImage==="both"&&i.jsxs(U.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[i.jsx(U.TabsTrigger,{value:"upload",children:e("editor.image.dialog.tab.upload")}),i.jsx(U.TabsTrigger,{value:"link",children:e("editor.image.dialog.tab.url")})]}),i.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[i.jsx(ge.Checkbox,{checked:A,onCheckedChange:h=>{x(h)}}),i.jsx(ae.Label,{children:e("editor.link.dialog.inline")})]}),d.enableAlt&&i.jsxs("div",{className:"richtext-my-[10px] ",children:[i.jsx(ae.Label,{className:"mb-[6px]",children:e("editor.imageUpload.alt")}),i.jsx(re.Input,{onChange:h=>v(h.target.value),required:!0,type:"text",value:L})]}),i.jsxs(U.TabsContent,{value:"upload",children:[i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[i.jsx(P.Button,{className:"richtext-mt-1 richtext-w-full",disabled:b,onClick:F,size:"sm",children:b?i.jsxs(i.Fragment,{children:[e("editor.imageUpload.uploading"),i.jsx(X.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):e("editor.image.dialog.tab.upload")}),i.jsx(Se,{alt:L,disabled:b,editor:n,imageInline:A,onClose:()=>{he.actionDialogImage.setOpen(n.id,!1),v("")}})]}),i.jsx("input",{accept:d.acceptMimes.join(",")||"image/*",multiple:d.multiple,onChange:R,ref:E,style:{display:"none"},type:"file"})]}),i.jsx(U.TabsContent,{value:"link",children:i.jsx("form",{onSubmit:z,children:i.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[i.jsx(re.Input,{autoFocus:!0,onChange:h=>D(h.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:_}),i.jsx(P.Button,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]}):i.jsx(i.Fragment,{})}const Ae={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},G=K.index_default.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...Ae,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:n,t:r})=>{var u,g;return{componentProps:{action:()=>!0,upload:n.options.upload,disabled:!((g=(u=t.can()).setImage)!=null&&g.call(u,{})),icon:"ImageUp",tooltip:r("editor.image.tooltip")}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const n=t.style.width||t.getAttribute("width")||null;return n?Number.parseInt(n,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})},alt:{default:"",parseHTML:t=>t.getAttribute("alt"),renderHTML:t=>({alt:t.alt})}}},addNodeView(){return J.ReactNodeViewRenderer(Ie)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:n})=>n.insertContent({type:this.name,attrs:{...t,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:n})=>n.updateAttributes(this.name,t),setAlignImage:t=>({commands:n})=>n.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:n,align:r,inline:u}=e,g=u&&(r==="left"||r==="right"),p=t||n?`transform: rotateX(${t?"180":"0"}deg) rotateY(${n?"180":"0"}deg);`:"",S=g?"":`text-align: ${r};`,j=`${g?`float: ${r};`:""}${g?r==="left"?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${p}`;return[u?"span":"div",{style:S,class:"image"},["img",J.mergeAttributes({height:"auto",style:j},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var g;const t=e==null?void 0:e.parentElement,n=e==null?void 0:e.getAttribute("width"),r=(e==null?void 0:e.getAttribute("flipx"))||!1,u=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(e==null?void 0:e.getAttribute("align"))||((g=t==null?void 0:t.style)==null?void 0:g.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:r==="true",flipY:u==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),n=t==null?void 0:t.getAttribute("width"),r=(t==null?void 0:t.getAttribute("flipx"))||!1,u=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:r==="true",flipY:u==="true"}}},{tag:'img[src]:not([src^="data:"])'}]}});exports.Image=G;exports.RichTextImage=we;exports.useToast=ee;
|
package/lib/Image.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("./clsx-CXbNJWDD.cjs"),W=require("./throttle-gTTvqDTW.cjs"),n=require("react/jsx-runtime"),o=require("react"),D=require("./index-Doks9cbR.cjs"),Y=require("./isNumber-BTYSVlKo.cjs"),ie=require("./toggle-BQHMh_Q-.cjs");require("./index-D3RLYf-J.cjs");require("./theme.cjs");const z=require("./dialog-Bt5zwGYB.cjs"),ae=require("react-image-crop"),B=require("./button-BS3n6_Aq.cjs"),U=require("./useButtonProps-DBJkNDS2.cjs"),Z=require("./file-i7e4nQY2.cjs"),ee=require("./use-toast-Bz3QCOtE.cjs"),P=require("./Icon-yqCglrdK.cjs"),re=require("./store-CkjKIgjQ.cjs"),J=require("./events.constant-Dq21NPdV.cjs"),O=require("./tabs-DRSwUeKP.cjs"),se=require("./checkbox-C8ByRi7-.cjs"),K=require("./label-JNOksCA-.cjs"),Q=require("./input-Dt_BA_9B.cjs"),H={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function le(e){var F,d,E;const[t,a]=o.useState({width:D.IMAGE_MAX_SIZE,height:D.IMAGE_MAX_SIZE}),[c,f]=o.useState({width:0,height:0}),[h]=o.useState([H.TOP_LEFT,H.TOP_RIGHT,H.BOTTOM_LEFT,H.BOTTOM_RIGHT]),[x,T]=o.useState(!1),[g,b]=o.useState({x:0,y:0,w:0,h:0,dir:""}),{align:A,inline:j}=(F=e==null?void 0:e.node)==null?void 0:F.attrs,L=j&&(A==="left"||A==="right"),M=o.useMemo(()=>{var V;const{src:r,alt:I,width:i,height:s,flipX:m,flipY:l}=(V=e==null?void 0:e.node)==null?void 0:V.attrs,y=Y.isNumber(i)?`${i}px`:i,w=Y.isNumber(s)?`${s}px`:s,$=[];m&&$.push("rotateX(180deg)"),l&&$.push("rotateY(180deg)");const ne=$.join(" ");return{src:r||void 0,alt:I||void 0,style:{width:y||void 0,height:w||void 0,transform:ne||"none",...L?{float:A}:{}}}},[(d=e==null?void 0:e.node)==null?void 0:d.attrs]),R=o.useMemo(()=>{const{style:{width:r}}=M;return{width:r==="100%"?r:void 0}},[M]);function _(r){f({width:r.target.width,height:r.target.height})}function C(){const{editor:r,getPos:I}=e;r.commands.setNodeSelection(I())}const S=o.useCallback(W.throttle(()=>{const{editor:r}=e,{width:I}=getComputedStyle(r.view.dom);a(i=>({...i,width:Number.parseInt(I,10)}))},D.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function N(r,I){r.preventDefault(),r.stopPropagation();const i=c.width,s=c.height,m=i/s;let l=Number(e.node.attrs.width),y=Number(e.node.attrs.height);const w=t.width;l&&!y?(l=l>w?w:l,y=Math.round(l/m)):y&&!l?(l=Math.round(y*m),l=l>w?w:l):!l&&!y?(l=i>w?w:i,y=Math.round(l/m)):l=l>w?w:l,T(!0),b({x:r.clientX,y:r.clientY,w:l,h:y,dir:I})}const v=o.useCallback(W.throttle(r=>{if(r.preventDefault(),r.stopPropagation(),!x)return;const{x:I,w:i,dir:s}=g,m=(r.clientX-I)*(/l/.test(s)?-1:1),l=Y.clamp(i+m,D.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:l,height:null})},D.IMAGE_THROTTLE_WAIT_TIME),[x,g,t,e.updateAttributes]),p=o.useCallback(r=>{r.preventDefault(),r.stopPropagation(),x&&(b({x:0,y:0,w:0,h:0,dir:""}),T(!1),C())},[x,C]),u=o.useCallback(()=>{document==null||document.addEventListener("mousemove",v,!0),document==null||document.addEventListener("mouseup",p,!0)},[v,p]),k=o.useCallback(()=>{document==null||document.removeEventListener("mousemove",v,!0),document==null||document.removeEventListener("mouseup",p,!0)},[v,p]);o.useEffect(()=>(x?u():k(),()=>{k()}),[x,u,k]);const q=o.useMemo(()=>new ResizeObserver(()=>S()),[S]);return o.useEffect(()=>(q.observe(e.editor.view.dom),()=>{q.disconnect()}),[e.editor.view.dom,q]),n.jsx(G.NodeViewWrapper,{as:j?"span":"div",className:"image-view",style:{float:L?A:void 0,margin:L?A==="left"?"1em 1em 1em 0":"1em 0 1em 1em":void 0,display:j?"inline":"block",textAlign:L?void 0:A,width:((E=M.style)==null?void 0:E.width)??"auto",...L?{}:R},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:R,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${x?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:M.alt,className:"image-view__body__image block",height:"auto",onClick:C,onLoad:_,src:M.src,style:M.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||x)&&n.jsx("div",{className:"image-resizer",children:h==null?void 0:h.map(r=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${r}`,onMouseDown:I=>N(I,r)},`image-dir-${r}`))})]})})}function oe(e,t){const a=e.type,c=e.name.toLowerCase(),f=c.split(".").pop();if(!f)return!1;const x=a||{heif:"image/heif",heic:"image/heic",dng:"image/x-adobe-dng",cr2:"image/x-canon-cr2",nef:"image/x-nikon-nef",arw:"image/x-sony-arw",raf:"image/x-fuji-raf",orf:"image/x-olympus-orf"}[f];return t.some(T=>{if(T.startsWith("."))return c.endsWith(T);if(T.endsWith("/*")){const g=T.split("/")[0];return x==null?void 0:x.startsWith(g+"/")}return x===T})}function te(e,t){const{acceptMimes:a,maxSize:c,t:f,toast:h}=t,x=[];return(Array.isArray(e)?e:Object.values(e)).forEach(g=>{if(!oe(g,a)){t.onError?t.onError({type:"type",message:f("editor.upload.fileTypeNotSupported",{fileName:g.name}),file:g}):h({variant:"default",title:f("editor.upload.fileTypeNotSupported",{fileName:g.name})});return}if(g.size>c){const b=(c/1024/1024).toFixed(2);t.onError?t.onError({type:"size",message:f("editor.upload.fileSizeTooBig",{fileName:g.name,size:b}),file:g}):h({variant:"default",title:f("editor.upload.fileSizeTooBig",{fileName:g.name,size:b})});return}x.push(g)}),x}function ce({editor:e,imageInline:t,onClose:a,disabled:c,alt:f}){var r,I;const{t:h}=D.useLocale(),{toast:x}=ee.useToast(),[T,g]=o.useState(!1),[b,A]=o.useState(!1),j=o.useRef(null),[L,M]=o.useState(),[R,_]=o.useState(""),C=o.useRef(null),[S,N]=o.useState({src:"",file:null}),v=U.useExtension(X.name),p=o.useMemo(()=>(v==null?void 0:v.options)??{},[v]);function u(i){if(j.current&&i.width&&i.height){const s=k(j.current,i);_(s)}}function k(i,s){const m=document.createElement("canvas"),l=i.naturalWidth/i.width,y=i.naturalHeight/i.height;m.width=s.width*l,m.height=s.height*y;const w=m.getContext("2d");return w&&(w.imageSmoothingEnabled=!1,w.drawImage(i,s.x*l,s.y*y,s.width*l,s.height*y,0,0,s.width*l,s.height*y)),m.toDataURL("image/png",1)}const q=o.useCallback(async()=>{var i;if(!b){A(!0);try{const s=Z.dataURLtoFile(R,((i=S==null?void 0:S.file)==null?void 0:i.name)||"image.png");let m="";p.upload?m=await p.upload(s):m=URL.createObjectURL(s),e.chain().focus().setImageInline({src:m,inline:t,alt:f}).run(),g(!1),N({src:"",file:null}),E(),a()}catch(s){console.error("Error cropping image",s)}finally{A(!1)}}},[R,e,t,b,a,(r=S==null?void 0:S.file)==null?void 0:r.name,p]);function F(i){var s;i.preventDefault(),(s=C.current)==null||s.click()}const d=async i=>{var w;const s=(w=i==null?void 0:i.target)==null?void 0:w.files;if(!e||e.isDestroyed||s.length===0){i.target.value="";return}const m=te(s,{acceptMimes:p==null?void 0:p.acceptMimes,maxSize:p==null?void 0:p.maxSize,t:h,toast:x,onError:p.onError});if(m.length<=0){i.target.value="";return}const l=m[0],y=await Z.readImageAsBase64(l);g(!0),N({src:y.src,file:l})},E=()=>{C.current&&(C.current.value="")};return n.jsxs(n.Fragment,{children:[n.jsx(B.Button,{className:"richtext-mt-1 richtext-w-full",disabled:c,onClick:F,size:"sm",children:h("editor.image.dialog.tab.uploadCrop")}),n.jsxs(z.Dialog,{open:T,onOpenChange:i=>{g(i),i||(N({src:"",file:null}),E())},children:[n.jsx(z.DialogTrigger,{}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:h("editor.image.dialog.tab.uploadCrop")}),n.jsx("div",{children:S.src&&n.jsx(ae,{className:"richtext-w-full",crop:L,onChange:i=>M(i),onComplete:i=>u(i),children:n.jsx("img",{alt:"Crop me",ref:j,src:S.src})})}),n.jsxs(z.DialogFooter,{children:[n.jsxs(B.Button,{disabled:b,onClick:()=>{g(!1),N({src:"",file:null}),E()},children:[h("editor.imageUpload.cancel"),n.jsx(P.IconComponent,{className:"richtext-ml-1",name:"Trash2"})]}),n.jsx(B.Button,{className:"richtext-w-fit",disabled:b||!L,onClick:q,children:b?n.jsxs(n.Fragment,{children:[h("editor.imageUpload.uploading"),n.jsx(P.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):n.jsxs(n.Fragment,{children:[h("editor.imageUpload.crop"),n.jsx(P.IconComponent,{className:"richtext-ml-1",name:"Crop"})]})})]})]})]}),n.jsx("input",{accept:((I=p==null?void 0:p.acceptMimes)==null?void 0:I.join(","))||"image/*",multiple:!1,onChange:d,ref:C,style:{display:"none"},type:"file"})]})}function ue(){const{t:e}=D.useLocale(),{toast:t}=ee.useToast(),a=U.useEditorInstance(),c=U.useButtonProps(X.name),{icon:f,tooltip:h}=(c==null?void 0:c.componentProps)??{},{editorDisabled:x}=U.useToggleActive(),[T,g]=o.useState(!1),[b,A]=o.useState(!1),j=U.useExtension(X.name),L=d=>{g(d.detail)},[M,R]=o.useState(""),[_,C]=o.useState(""),S=o.useRef(null),N=(j==null?void 0:j.options.defaultInline)||!1,[v,p]=o.useState(N),u=o.useMemo(()=>j==null?void 0:j.options,[j]);o.useEffect(()=>{const d=J.listenEvent(J.EVENTS.UPLOAD_IMAGE(a.id),L);return()=>{d()}},[]);async function k(d){var I;const E=(I=d==null?void 0:d.target)==null?void 0:I.files;if(!a||a.isDestroyed||E.length===0||b){d.target.value="";return}const r=te(E,{acceptMimes:u==null?void 0:u.acceptMimes,maxSize:u==null?void 0:u.maxSize,t:e,toast:t,onError:u.onError});if(r.length<=0){d.target.value="";return}A(!0);try{if(u!=null&&u.multiple){const i=r.map(async m=>{let l="";return u.upload?l=await u.upload(m):l=URL.createObjectURL(m),l});(await Promise.all(i)).forEach(m=>{a.chain().focus().setImageInline({src:m,inline:v,alt:_}).run()})}else{const i=r[0];let s="";u.upload?s=await u.upload(i):s=URL.createObjectURL(i),a.chain().focus().setImageInline({src:s,inline:v,alt:_}).run()}g(!1),C(""),p(N)}catch(i){console.error("Error uploading image",i),u.onError?u.onError({type:"upload",message:e("editor.upload.error")}):t({variant:"destructive",title:e("editor.upload.error")})}finally{A(!1),d.target.value=""}}function q(d){d.preventDefault(),d.stopPropagation(),a.chain().focus().setImageInline({src:M,inline:v,alt:_}).run(),g(!1),p(N),R(""),C("")}function F(d){var E;d.preventDefault(),(E=S.current)==null||E.click()}return c?n.jsxs(z.Dialog,{onOpenChange:g,open:T,children:[n.jsx(z.DialogTrigger,{asChild:!0,children:n.jsx(ie.ActionButton,{disabled:x,icon:f,tooltip:h,action:()=>{x||g(!0)}})}),n.jsxs(z.DialogContent,{children:[n.jsx(z.DialogTitle,{children:e("editor.image.dialog.title")}),n.jsxs(O.Tabs,{activationMode:"manual",defaultValue:u.resourceImage==="both"||u.resourceImage==="upload"?"upload":"link",children:[u.resourceImage==="both"&&n.jsxs(O.TabsList,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[n.jsx(O.TabsTrigger,{value:"upload",children:e("editor.image.dialog.tab.upload")}),n.jsx(O.TabsTrigger,{value:"link",children:e("editor.image.dialog.tab.url")})]}),n.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[n.jsx(se.Checkbox,{checked:v,onCheckedChange:d=>{p(d)}}),n.jsx(K.Label,{children:e("editor.link.dialog.inline")})]}),u.enableAlt&&n.jsxs("div",{className:"richtext-my-[10px] ",children:[n.jsx(K.Label,{className:"mb-[6px]",children:e("editor.imageUpload.alt")}),n.jsx(Q.Input,{onChange:d=>C(d.target.value),required:!0,type:"text",value:_})]}),n.jsxs(O.TabsContent,{value:"upload",children:[n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[n.jsx(B.Button,{className:"richtext-mt-1 richtext-w-full",disabled:b,onClick:F,size:"sm",children:b?n.jsxs(n.Fragment,{children:[e("editor.imageUpload.uploading"),n.jsx(P.IconComponent,{className:"richtext-ml-1 richtext-animate-spin",name:"Loader"})]}):e("editor.image.dialog.tab.upload")}),n.jsx(ce,{alt:_,disabled:b,editor:a,imageInline:v,onClose:()=>{re.actionDialogImage.setOpen(a.id,!1),C("")}})]}),n.jsx("input",{accept:u.acceptMimes.join(",")||"image/*",multiple:u.multiple,onChange:k,ref:S,style:{display:"none"},type:"file"})]}),n.jsx(O.TabsContent,{value:"link",children:n.jsx("form",{onSubmit:q,children:n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[n.jsx(Q.Input,{autoFocus:!0,onChange:d=>R(d.target.value),placeholder:e("editor.image.dialog.placeholder"),required:!0,type:"url",value:M}),n.jsx(B.Button,{type:"submit",children:e("editor.image.dialog.button.apply")})]})})})]})]})]}):n.jsx(n.Fragment,{})}const de={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,multiple:!0,resourceImage:"both",defaultInline:!1,enableAlt:!0},X=W.index_default.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...de,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:a,t:c})=>{var f,h;return{componentProps:{action:()=>!0,upload:a.options.upload,disabled:!((h=(f=t.can()).setImage)!=null&&h.call(f,{})),icon:"ImageUp",tooltip:c("editor.image.tooltip")}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const a=t.style.width||t.getAttribute("width")||null;return a?Number.parseInt(a,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})},alt:{default:"",parseHTML:t=>t.getAttribute("alt"),renderHTML:t=>({alt:t.alt})}}},addNodeView(){return G.ReactNodeViewRenderer(le)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:a})=>a.insertContent({type:this.name,attrs:{...t,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:a})=>a.updateAttributes(this.name,t),setAlignImage:t=>({commands:a})=>a.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:a,align:c,inline:f}=e,h=f&&(c==="left"||c==="right"),x=t||a?`transform: rotateX(${t?"180":"0"}deg) rotateY(${a?"180":"0"}deg);`:"",T=h?"":`text-align: ${c};`,A=`${h?`float: ${c};`:""}${h?c==="left"?"margin: 1em 1em 1em 0;":"margin: 1em 0 1em 1em;":""}${x}`;return[f?"span":"div",{style:T,class:"image"},["img",G.mergeAttributes({height:"auto",style:A},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var h;const t=e==null?void 0:e.parentElement,a=e==null?void 0:e.getAttribute("width"),c=(e==null?void 0:e.getAttribute("flipx"))||!1,f=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:a?Number.parseInt(a,10):null,align:(e==null?void 0:e.getAttribute("align"))||((h=t==null?void 0:t.style)==null?void 0:h.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:c==="true",flipY:f==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),a=t==null?void 0:t.getAttribute("width"),c=(t==null?void 0:t.getAttribute("flipx"))||!1,f=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:a?Number.parseInt(a,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:c==="true",flipY:f==="true"}}},{tag:'img[src]:not([src^="data:"])'}]}});exports.Image=X;exports.RichTextImage=ue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./clsx-CXbNJWDD.cjs");require("./throttle-gTTvqDTW.cjs");const e=require("./Image-iKsGKjvg.cjs");exports.Image=e.Image;exports.RichTextImage=e.RichTextImage;
|