@layers-app/editor 0.0.17-editor-02 → 0.0.17-editor-03
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/README.md +11 -11
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +6 -9
- package/dist/index.js +2 -2
- package/dist/layers.23l5B1nW.js +1 -0
- package/dist/{layers.Ck8c0KB8.js → layers.8vBcoTVc.js} +10196 -9395
- package/dist/{layers.8IsVFZzu.js → layers.BA3gbnvD.js} +36 -36
- package/dist/layers.Bi7BfxD7.js +164 -0
- package/dist/{layers.DeVO3cbn.js → layers.Bs9ZX2Jw.js} +1 -1
- package/dist/{layers.mZsUCWha.js → layers.DmXwnZA5.js} +1 -1
- package/package.json +9 -7
- package/dist/layers.BNEO_yBt.js +0 -164
- package/dist/layers.CXZ1fGx2.js +0 -1
package/dist/layers.CXZ1fGx2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react"),D=require("react-i18next"),t=require("./layers.BNEO_yBt.js"),E=require("@mantine/core"),U=require("@tabler/icons-react"),F=i=>{const{width:g,height:r,isLoading:l,isError:u,src:f,id:m,altText:p,imageRef:j,maxWidth:v}=i;return n.jsxs("div",{className:"media-wrapper",style:{width:g,height:r,display:"inline-flex",position:"relative"},children:[n.jsx(E.LoadingOverlay,{visible:l,zIndex:1e3,overlayProps:{backgroundOpacity:.5},loaderProps:{size:24,color:"black"}}),n.jsx(E.LoadingOverlay,{visible:u,zIndex:1e3,overlayProps:{backgroundOpacity:.5},loaderProps:{children:n.jsx(E.Flex,{bg:"white",maw:300,justify:"center",children:n.jsx(E.Alert,{variant:"light",color:"red",title:"Ошибка загрузки",icon:n.jsx(U.IconInfoCircle,{}),children:"Попробуйте загрузить заново."})})}}),n.jsx(B,{className:null,src:f,altText:p,imageRef:j,width:"inherit",height:"inherit",maxWidth:v||"auto",id:m})]})};function B({altText:i,className:g,imageRef:r,src:l,width:u,height:f,maxWidth:m,id:p}){return n.jsx("img",{className:g||void 0,src:l,alt:i,ref:r,style:{height:f,maxWidth:m,width:u},draggable:"false","data-id":p})}function G({src:i,altText:g,nodeKey:r,width:l,height:u,maxWidth:f,showCaption:m,caption:p,id:j,create:v,alignment:H}){const W=s.useRef(null),[P,S]=s.useState(!0),[R,M]=s.useState(!1),{isCollabActive:O}=t.l(),[h]=t.u(),[x,b]=s.useState(!0),[d,w]=s.useState({width:0,height:0}),{fetchUploadImage:z,fetchDeleteImage:L}=s.useContext(t.Context),{t:y}=D.useTranslation();s.useEffect(()=>{if(!i||i.startsWith("data:image/")){S(!1);return}const e=new Image;e.src=i,e.onload=()=>S(!1),e.onerror=()=>{S(!1),M(!0)}},[i]);const T=(e,a)=>{h.update(()=>{t.Ft(null);const c=t.Ct(r);t.$isImageNode(c)&&c.setWidthAndHeight(e,a)})},{historyState:k}=t.useSharedHistoryContext(),{settings:{showNestedEditorTreeView:q}}=t.useSettings(),[C,I]=s.useState(!1);function $(e){return e.endsWith(".svg")||e.includes("image/svg+xml")}function _(e){return new Promise((a,c)=>{if($(e)){a(0);return}const o=new Image;o.src=e,o.onload=()=>{a(o.width)},o.onerror=()=>{c(new Error("Failed to load image"))}})}return s.useEffect(()=>{v&&I(!0)},[v]),s.useEffect(()=>{let e=l,a=u,c=100;i&&_(i).then(o=>{typeof e=="number"&&e<c&&o<c?(b(!0),w({width:e,height:a})):o<c?(b(!0),w({width:"auto",height:"auto"})):(w({width:o,height:o}),b(!1))})},[i]),s.useEffect(()=>{d.width&&d.height&&x&&h.update(()=>{const e=t.Ct(r);t.$isImageNode(e)&&e.setWidthAndHeight(d.width,d.height)})},[d.width,d.height,x]),s.useEffect(()=>{const e=document.documentElement;t.toggleLockScroll(C,e)},[C]),i?x?n.jsx(F,{width:d.width,height:d.height,isLoading:P,isError:R,isIcon:x,src:i,id:j,editor:h,nodeKey:r,fetchDeleteImage:L,altText:g,imageRef:W,maxWidth:f,showCaption:m,caption:p,isCollabActive:O,historyState:k,showNestedEditorTreeView:q,t:y}):n.jsx(t.ResizableContainer,{editor:h,isIcon:x,width:typeof l=="string"&&l.includes("%")?parseFloat(l):l,height:typeof u=="string"&&u.includes("%")?parseFloat(u):l,initialWidth:d.width||"",initialHeight:d.height||"",onResizeEnd:T,alignment:H,children:n.jsx(F,{width:"inherit",height:"inherit",isLoading:P,isError:R,isIcon:x,src:i,id:j,editor:h,nodeKey:r,fetchDeleteImage:L,altText:g,imageRef:W,maxWidth:f,showCaption:m,caption:p,isCollabActive:O,historyState:k,showNestedEditorTreeView:q,t:y})}):n.jsx(t.ImagePicker,{uploading:!1,onUpload:e=>{!z||!e.length||(e.forEach((a,c)=>{z(a,(o,A)=>{c===0?h.update(()=>{const N=t.Ct(r);t.$isImageNode(N)&&(N.setSrc(o),N.setId(A))}):h.dispatchCommand(t.INSERT_IMAGE_COMMAND,{altText:"",src:o,id:A})})}),I(!1))},popoverProps:{opened:C,position:"bottom",onChange:I},onChange:e=>{I(!1),h.update(()=>{const a=t.Ct(r);t.$isImageNode(a)&&a.setSrc(e)})},children:n.jsx(t.EmptyNodeButton,{title:y("editor.image.add_photo"),icon:"photo",onClick:()=>I(!C)})})}exports.default=G;
|