@layers-app/editor 0.0.13 → 0.0.15-swagger

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),i=require("react"),e=require("./layers.D1A3jNDb.js"),R=require("./layers.B073B28e.js"),y=require("@mantine/core");function D({children:a,label:r,className:n,...m}){return t.jsxs("div",{className:"Input__wrapper",children:[t.jsx("label",{style:{marginTop:"-1em"},className:"Input__label",children:r}),t.jsx("select",{...m,className:n||"select",children:a})]})}function q({label:a,value:r,onChange:n,placeholder:m="","data-test-id":o,type:d="text"}){return t.jsx(y.TextInput,{type:d,placeholder:m,value:r,onChange:c=>{n(c.target.value)},label:a,"data-test-id":o,mb:10})}const k=new Set;function L(a){if(!k.has(a))throw new Promise(r=>{const n=new Image;n.src=a,n.onload=()=>{k.add(a),r(null)}})}function B({altText:a,className:r,imageRef:n,src:m,width:o,height:d,position:c}){return L(m),t.jsx("img",{className:r||void 0,src:m,alt:a,ref:n,"data-position":c,style:{display:"block",height:d,width:o},draggable:"false"})}function _({activeEditor:a,nodeKey:r,onClose:n}){const o=a.getEditorState().read(()=>e.Ct(r)),[d,c]=i.useState(o.getAltText()),[C,S]=i.useState(o.getShowCaption()),[b,x]=i.useState(o.getPosition()),j=f=>{S(f.target.checked)},g=f=>{x(f.target.value)},p=()=>{const f={altText:d,position:b,showCaption:C};o&&a.update(()=>{o.update(f)}),n()};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{marginBottom:"1em"},children:t.jsx(q,{label:"Alt-текст",placeholder:"Альтернативный текст",onChange:c,value:d,"data-test-id":"image-modal-alt-text-input"})}),t.jsxs(D,{style:{marginBottom:"1em",width:"208px"},value:b,label:"Position",name:"position",id:"position-select",onChange:g,children:[t.jsx("option",{value:"left",children:"Left"}),t.jsx("option",{value:"right",children:"Right"}),t.jsx("option",{value:"full",children:"Full Width"})]}),t.jsxs("div",{className:"Input__wrapper",children:[t.jsx("input",{id:"caption",type:"checkbox",checked:C,onChange:j}),t.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),t.jsx(e.Button,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>p(),children:"Применить"})]})}function K({src:a,altText:r,nodeKey:n,width:m,height:o,showCaption:d,caption:c,position:C}){const[S,b]=e.useModal(),x=i.useRef(null),j=i.useRef(null),[g,p,f]=e.u$1(n),[l]=e.u(),[P,F]=i.useState(null),E=i.useRef(null),v=i.useCallback(u=>{if(g&&e.wi(e.Ri())){u.preventDefault();const s=e.Ct(n);e.$isInlineImageNode(s)&&s.remove()}return!1},[g,n]),w=i.useCallback(u=>{const h=e.Ri(),s=j.current;if(g&&e.wi(h)&&h.getNodes().length===1){if(d)return e.Ft(null),u.preventDefault(),c.focus(),!0;if(s!==null&&s!==document.activeElement)return u.preventDefault(),s.focus(),!0}return!1},[c,g,d]),N=i.useCallback(u=>E.current===c||j.current===u.target?(e.Ft(null),l.update(()=>{p(!0);const h=l.getRootElement();h!==null&&h.focus()}),!0):!1,[c,l,p]);i.useEffect(()=>{let u=!0;const h=e.N(l.registerUpdateListener(({editorState:s})=>{u&&F(s.read(()=>e.Ri()))}),l.registerCommand(e.t,(s,I)=>(E.current=I,!1),e.Ks),l.registerCommand(e.r,s=>{const I=s;return I.target===x.current?(I.shiftKey?p(!g):(f(),p(!0)),!0):!1},e.Ks),l.registerCommand(e.D,s=>s.target===x.current?(s.preventDefault(),!0):!1,e.Ks),l.registerCommand(e.w,v,e.Ks),l.registerCommand(e.k,v,e.Ks),l.registerCommand(e.C,w,e.Ks),l.registerCommand(e.b,N,e.Ks));return()=>{u=!1,h()}},[f,l,g,n,v,w,N,p]);const T=g;return t.jsxs(i.Suspense,{fallback:null,children:[t.jsxs(t.Fragment,{children:[t.jsxs("div",{draggable:!1,children:[t.jsx("button",{className:"image-edit-button",ref:j,onClick:()=>{b("Update Inline Image",u=>t.jsx(_,{activeEditor:l,nodeKey:n,onClose:u}))},children:"Edit"}),t.jsx(B,{className:T?`focused ${e.wi(P)?"draggable":""}`:null,src:a,altText:r,imageRef:x,width:m,height:o,position:C})]}),d&&t.jsx("div",{className:"image-caption-container",children:t.jsxs(R.d,{initialEditor:c,children:[t.jsx(e.LinkPlugin,{}),t.jsx(e.FloatingTextFormatToolbarPlugin,{}),t.jsx(e.h,{contentEditable:t.jsx(e.LexicalContentEditable,{className:"InlineImageNode__contentEditable"}),placeholder:t.jsx(R.Placeholder,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:e.a})]})})]}),S]})}exports.UpdateInlineImageDialog=_;exports.default=K;
@@ -1,4 +1,4 @@
1
- import { ad as p, ae as k, l as E } from "./layers.BI3mGLaL.js";
1
+ import { ad as p, ae as k, l as E } from "./layers.36_3ol3v.js";
2
2
  import { useRef as O, useContext as P, useMemo as D, useEffect as h } from "react";
3
3
  import { jsx as _ } from "react/jsx-runtime";
4
4
  function K(e) {