react-text-forge 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -205,7 +205,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),be=A,de=F),Z===void 0&
205
205
  * along with ReactTextForge. If not, see <https://opensource.org/licenses/MIT>.
206
206
  *
207
207
  * For any questions or suggestions, please contact: administrateur@nhumeria.fr
208
- */function fi(t){const[e,n]=J.useState(""),[r,a]=J.useState(""),[i,o]=J.useState(!1),[s,l]=J.useState(""),[c,_]=J.useState(""),[d,m]=J.useState("paragraph"),[E,u]=J.useState(!1),[S,T]=J.useState(""),[b,f]=J.useState(!1),N=()=>{f(!b)},h=()=>{u(!E)};return{activeBlock:d,colorMode:r,setColorMode:a,openInNewTab:i,setOpenInNewTab:o,selectedBackgroundColor:c,setSelectedBackgroundColor:_,selectedColor:s,setSelectedColor:l,selectedLanguage:S,setSelectedLanguage:T,selectedLink:e,setSelectedLink:n,showColorPicker:E,showLinkForm:b,setShowLinkForm:f,detectCurrentLanguage:()=>{const{selection:L}=t;if(L){const[V]=C.Editor.nodes(t,{match:w=>w.type==="code"});T(V?V[0].language:null)}},toggleLinkForm:N,toggleColorPicker:h,handleColorChange:L=>{G.applyTextColor(t,L),h()},handleBackgroundColorChange:L=>{G.applyBackgroundTextColor(t,L),h()},handleBlockTypeChange:L=>{G.toggleBlock(t,L),m(L)}}}function em({selectedColor:t,onSelectColor:e,onClose:n}){const[r,a]=J.useState("#ffffff"),{backgroundColor:i,borderColor:o,imageColor:s}=ye(),l={backgroundColor:i,color:s},c={backgroundColor:`color-mix(in srgb, ${i} 80%, ${we(i)?"white":"black"})`,color:we(i)?"#FFF":"#000"},_={backgroundColor:i!=="#6c757d"?"#6c757d":"color-mix(in srgb, #6c757d 30%, black)",color:we(i)?"#FFF":"#000"},d={default:{picker:{background:i,color:s,border:o}}},m=S=>{a(S.hex)},E=()=>{r&&(e(r),n())},u=()=>{e(""),n()};return J.useEffect(()=>{t&&a(t)},[t]),g.jsxs("div",{onMouseLeave:n,className:"color-picker-popup",children:[g.jsx(kc.SketchPicker,{styles:d,color:r,onChangeComplete:m}),g.jsxs("div",{style:l,className:"link-form-actions",children:[g.jsx("button",{style:c,onClick:E,disabled:!r,children:"Appliquer"}),g.jsx("button",{style:_,onClick:u,children:"Annuler"})]})]})}const tm=({activeMarks:t,format:e,isActive:n})=>{const[r,a]=J.useState(""),{backgroundColor:i,editor:o,imageColor:s}=ye(),{activeBlock:l,colorMode:c,setColorMode:_,openInNewTab:d,detectCurrentLanguage:m,handleColorChange:E,handleBackgroundColorChange:u,setOpenInNewTab:S,selectedBackgroundColor:T,setSelectedBackgroundColor:b,selectedColor:f,setSelectedColor:N,selectedLink:h,setSelectedLink:v,showColorPicker:I,showLinkForm:P,setShowLinkForm:M,toggleColorPicker:L,toggleLinkForm:V}=fi(o),w=l==="h1"||l==="h2",K=["left","center","right"],ce=H=>{G.applyFontSize(o,H)},ie=H=>{G.applyFontFamily(o,H),a(H)};return J.useEffect(()=>{m();const{selection:H}=o;if(H){const[Q]=C.Editor.nodes(o,{match:te=>te.type==="link"});Q?(S(Q[0].target==="_blank"),v(Q[0].href)):(S(!1),v(""))}},[o.selection]),e==="indent"||e==="outdent"?g.jsx("div",{children:g.jsx("button",{className:"tool",onClick:()=>e==="indent"?G.handleIndent(o):G.handleOutdent(o),disabled:!n,children:g.jsx(ke,{format:e,imageColor:n?s:`color-mix(in srgb, ${s} 40%, black)`})})}):e==="fontSize"?g.jsx(Zp,{disabled:w,onSelectSize:ce,sizeSelected:n}):e==="fontFamily"?g.jsx(Jp,{fontFamilySelected:r,onSelectFontFamily:ie}):e==="bulletList"||e==="numberedList"?g.jsx("div",{className:"dropdown",children:g.jsx(Xp,{format:e,isActive:n,onMouseDown:()=>{e=e==="bulletList"?"bullet-list":"numbered-list",G.toggleBlock(o,e)}})}):e==="href"?g.jsxs("div",{className:"dropdown",children:[g.jsx("button",{onMouseDown:H=>{H.preventDefault(),V()},className:`tool tool--${n?"active":"inactive"}`,children:g.jsx(ke,{format:e,imageColor:s})}),P&&g.jsx(jp,{onClose:()=>M(!1),initialUrl:h,isOpenInNewTab:d})]}):e==="color"||e==="bgColor"?g.jsxs("div",{className:"dropdown",children:[g.jsx("button",{onMouseDown:H=>{H.preventDefault(),e==="color"?(N(t[e]),_("color"),L()):(b(t[e]),_("bgColor"),L())},className:`tool tool--${n?"active":"inactive"}`,children:g.jsx(ke,{format:e,imageColor:s})}),I&&g.jsx(em,{selectedColor:c==="color"?f:T,onSelectColor:c==="color"?E:u,onClose:L})]}):g.jsx("button",{onMouseDown:H=>{H.preventDefault(),K.includes(e)?G.toggleAlign(o,e):G.toggleMark(o,e)},style:{backgroundColor:n?`color-mix(in srgb, ${i} 80%, ${we(i)?"white":"black"})`:""},className:"tool",children:g.jsx(ke,{format:e,imageColor:s})})},nm=()=>{const{backgroundColor:t,imageColor:e}=ye(),{editor:n}=ye(),{activeBlock:r,handleBlockTypeChange:a}=fi(n),i=[{type:"paragraph",name:"Paragraphe"},{type:"h1",name:"Titre"},{type:"h2",name:"Sous-titre"}],o={backgroundColor:t,color:e},s=l=>{const c=l.target.value;a(c)};return g.jsx("select",{value:r,onChange:s,style:o,children:i.map(l=>g.jsx("option",{value:l.type,children:l.name},l.type))})},rm=()=>{const[t,e]=J.useState(!1),{backgroundColor:n,editor:r,imageColor:a}=ye(),{selectedLanguage:i,setSelectedLanguage:o}=fi(r),s={backgroundColor:n,color:a},l={cs:"C#",cpp:"C++",css:"CSS",diff:"Diff",html:"HTML",java:"Java",javascript:"JavaScript",php:"PHP",python:"Python",ruby:"Ruby",typescript:"TypeScript",xml:"XML"},c=()=>{e(!t)},_=d=>{o(d),G.handleCode(r,d),e(!1)};return g.jsxs("div",{className:`dropdown tool ${i&&i!=="init"&&i!==""?"tool--active":""}`,children:[g.jsx("button",{className:"dropdown-toggle",onClick:c,children:g.jsx(ke,{format:"blockCode",imageColor:a})}),t&&g.jsxs("ul",{style:s,onMouseLeave:c,className:"dropdown-menu",children:[i&&g.jsx("li",{onClick:()=>_("init"),children:"Réinitialiser"}),Object.keys(l).map(d=>g.jsx("li",{onClick:()=>_(d),style:{cursor:"pointer",padding:"5px 10px",backgroundColor:i&&d===i?`color-mix(in srgb, ${n} 80%, ${we(n)?"white":"black"})`:n},children:l[d]},d))]})]})},am=()=>{const{editor:t,imageColor:e}=ye();return g.jsxs("div",{className:"tool image-upload-container",children:[g.jsx("input",{id:"file-input",type:"file",accept:"image/*",onChange:n=>G.handleFileChange(n,t),className:"hidden-file-input"}),g.jsx("label",{htmlFor:"file-input",className:"image-upload-label",children:g.jsx(ke,{format:"image",imageColor:e})})]})};function im(){const{editor:t,imageColor:e}=ye();return g.jsxs(g.Fragment,{children:[g.jsx("button",{className:"tool",onMouseDown:n=>{n.preventDefault(),t.undo()},children:g.jsx(ke,{format:"undo",imageColor:t.history.undos.length===0?`color-mix(in srgb, ${e} 40%, black)`:e})}),g.jsx("button",{className:"tool",onMouseDown:n=>{n.preventDefault(),t.redo()},children:g.jsx(ke,{format:"redo",imageColor:t.history.redos.length===0?`color-mix(in srgb, ${e} 40%, black)`:e})})]})}const om=({activeMarks:t})=>g.jsxs("div",{className:"toolbar",children:[g.jsx(nm,{}),Object.keys(t).map((e,n)=>g.jsx("div",{children:g.jsx(tm,{activeMarks:t,format:e,isActive:t[e]})},n)),g.jsx(am,{}),g.jsx(rm,{}),g.jsx(im,{})]});/**
208
+ */function fi(t){const[e,n]=J.useState(""),[r,a]=J.useState(""),[i,o]=J.useState(!1),[s,l]=J.useState(""),[c,_]=J.useState(""),[d,m]=J.useState("paragraph"),[E,u]=J.useState(!1),[S,T]=J.useState(""),[b,f]=J.useState(!1),N=()=>{f(!b)},h=()=>{u(!E)};return{activeBlock:d,colorMode:r,setColorMode:a,openInNewTab:i,setOpenInNewTab:o,selectedBackgroundColor:c,setSelectedBackgroundColor:_,selectedColor:s,setSelectedColor:l,selectedLanguage:S,setSelectedLanguage:T,selectedLink:e,setSelectedLink:n,showColorPicker:E,showLinkForm:b,setShowLinkForm:f,detectCurrentLanguage:()=>{const{selection:L}=t;if(L){const[V]=C.Editor.nodes(t,{match:w=>w.type==="code"});T(V?V[0].language:null)}},toggleLinkForm:N,toggleColorPicker:h,handleColorChange:L=>{G.applyTextColor(t,L),h()},handleBackgroundColorChange:L=>{G.applyBackgroundTextColor(t,L),h()},handleBlockTypeChange:L=>{G.toggleBlock(t,L),m(L)}}}function em({selectedColor:t,onSelectColor:e,onClose:n}){const[r,a]=J.useState("#ffffff"),{backgroundColor:i,borderColor:o,imageColor:s}=ye(),l={backgroundColor:i,color:s},c={backgroundColor:`color-mix(in srgb, ${i} 80%, ${we(i)?"white":"black"})`,color:we(i)?"#FFF":"#000"},_={backgroundColor:i!=="#6c757d"?"#6c757d":"color-mix(in srgb, #6c757d 30%, black)",color:we(i)?"#FFF":"#000"},d={default:{picker:{background:i,color:s,border:o}}},m=S=>{a(S.hex)},E=()=>{r&&(e(r),n())},u=()=>{e(""),n()};return J.useEffect(()=>{t&&a(t)},[t]),g.jsxs("div",{onMouseLeave:n,className:"color-picker-popup",children:[g.jsx(kc.SketchPicker,{styles:d,color:r,onChangeComplete:m}),g.jsxs("div",{style:l,className:"link-form-actions",children:[g.jsx("button",{style:c,onClick:E,disabled:!r,children:"Appliquer"}),g.jsx("button",{style:_,onClick:u,children:"Annuler"})]})]})}const tm=({activeMarks:t,format:e,isActive:n})=>{const[r,a]=J.useState(""),{backgroundColor:i,editor:o,imageColor:s}=ye(),{activeBlock:l,colorMode:c,setColorMode:_,openInNewTab:d,detectCurrentLanguage:m,handleColorChange:E,handleBackgroundColorChange:u,setOpenInNewTab:S,selectedBackgroundColor:T,setSelectedBackgroundColor:b,selectedColor:f,setSelectedColor:N,selectedLink:h,setSelectedLink:v,showColorPicker:I,showLinkForm:P,setShowLinkForm:M,toggleColorPicker:L,toggleLinkForm:V}=fi(o),w=l==="h1"||l==="h2",K=["left","center","right"],ce=H=>{G.applyFontSize(o,H)},ie=H=>{G.applyFontFamily(o,H),a(H)};return J.useEffect(()=>{m();const{selection:H}=o;if(H){const[Q]=C.Editor.nodes(o,{match:te=>te.type==="link"});Q?(S(Q[0].target==="_blank"),v(Q[0].href)):(S(!1),v(""))}},[o.selection]),e==="indent"||e==="outdent"?g.jsx("div",{children:g.jsx("button",{className:"tool",onClick:()=>e==="indent"?G.handleIndent(o):G.handleOutdent(o),disabled:!n,children:g.jsx(ke,{format:e,imageColor:n?s:`color-mix(in srgb, ${s} 40%, black)`})})}):e==="fontSize"?g.jsx(Zp,{disabled:w,onSelectSize:ce,sizeSelected:n}):e==="fontFamily"?g.jsx(Jp,{fontFamilySelected:r,onSelectFontFamily:ie}):e==="bulletList"||e==="numberedList"?g.jsx("div",{className:"dropdown",children:g.jsx(Xp,{format:e,isActive:n,onMouseDown:()=>{e=e==="bulletList"?"bullet-list":"numbered-list",G.toggleBlock(o,e)}})}):e==="href"?g.jsxs("div",{className:"dropdown",children:[g.jsx("button",{onMouseDown:H=>{H.preventDefault(),V()},className:`tool tool--${n?"active":"inactive"}`,children:g.jsx(ke,{format:e,imageColor:s})}),P&&g.jsx(jp,{onClose:()=>M(!1),initialUrl:h,isOpenInNewTab:d})]}):e==="color"||e==="bgColor"?g.jsxs("div",{className:"dropdown",children:[g.jsx("button",{onMouseDown:H=>{H.preventDefault(),e==="color"?(N(t[e]),_("color"),L()):(b(t[e]),_("bgColor"),L())},className:`tool tool--${n?"active":"inactive"}`,children:g.jsx(ke,{format:e,imageColor:s})}),I&&g.jsx(em,{selectedColor:c==="color"?f:T,onSelectColor:c==="color"?E:u,onClose:L})]}):g.jsx("button",{onMouseDown:H=>{H.preventDefault(),K.includes(e)?G.toggleAlign(o,e):G.toggleMark(o,e)},style:{backgroundColor:n?`color-mix(in srgb, ${i} 80%, ${we(i)?"white":"black"})`:""},className:"tool",children:g.jsx(ke,{format:e,imageColor:s})})},nm=()=>{const{backgroundColor:t,imageColor:e}=ye(),{editor:n}=ye(),{activeBlock:r,handleBlockTypeChange:a}=fi(n),i=[{type:"paragraph",name:"Paragraphe"},{type:"h1",name:"Titre"},{type:"h2",name:"Sous-titre"}],o={backgroundColor:t,color:e},s=l=>{const c=l.target.value;a(c)};return g.jsx("select",{value:r,onChange:s,style:o,children:i.map(l=>g.jsx("option",{value:l.type,children:l.name},l.type))})},rm=()=>{const[t,e]=J.useState(!1),{backgroundColor:n,editor:r,imageColor:a}=ye(),{selectedLanguage:i,setSelectedLanguage:o}=fi(r),s={backgroundColor:n,color:a},l={cs:"C#",cpp:"C++",css:"CSS",diff:"Diff",html:"HTML",java:"Java",javascript:"JavaScript",php:"PHP",python:"Python",ruby:"Ruby",typescript:"TypeScript",xml:"XML"},c=()=>{e(!t)},_=d=>{o(d),G.handleCode(r,d),e(!1)};return g.jsxs("div",{className:`dropdown tool ${i&&i!=="init"&&i!==""?"tool--active":""}`,children:[g.jsx("button",{className:"dropdown-toggle",onClick:c,children:g.jsx(ke,{format:"blockCode",imageColor:a})}),t&&g.jsxs("ul",{style:s,onMouseLeave:c,className:"dropdown-menu",children:[i&&g.jsx("li",{onClick:()=>_("init"),children:"Réinitialiser"}),Object.keys(l).map(d=>g.jsx("li",{onClick:()=>_(d),style:{cursor:"pointer",padding:"5px 10px",backgroundColor:i&&d===i?`color-mix(in srgb, ${n} 80%, ${we(n)?"white":"black"})`:n},children:l[d]},d))]})]})},am=()=>{const{editor:t,imageColor:e}=ye();return g.jsxs("div",{className:"tool image-upload-container",children:[g.jsx("input",{id:"file-input",type:"file",accept:"image/*",onChange:n=>G.handleFileChange(n,t),className:"hidden-file-input"}),g.jsx("label",{htmlFor:"file-input",className:"image-upload-label",children:g.jsx(ke,{format:"image",imageColor:e})})]})};function im(){const{editor:t,imageColor:e}=ye();return g.jsxs(g.Fragment,{children:[g.jsx("button",{className:"tool",onMouseDown:n=>{n.preventDefault(),t.undo()},children:g.jsx(ke,{format:"undo",imageColor:t.history.undos.length===0?`color-mix(in srgb, ${e} 40%, black)`:e})}),g.jsx("button",{className:"tool",onMouseDown:n=>{n.preventDefault(),t.redo()},children:g.jsx(ke,{format:"redo",imageColor:t.history.redos.length===0?`color-mix(in srgb, ${e} 40%, black)`:e})})]})}const om=({activeMarks:t})=>{const e=()=>{document.querySelector(".toolbar").blur()};return g.jsxs("div",{className:"toolbar",onClick:e,children:[g.jsx(nm,{}),Object.keys(t).map((n,r)=>g.jsx("div",{children:g.jsx(tm,{activeMarks:t,format:n,isActive:t[n]})},r)),g.jsx(am,{}),g.jsx(rm,{}),g.jsx(im,{})]})};/**
209
209
  * @license
210
210
  * Copyright (c) 2025 Jahylis
211
211
  *