@layers-app/editor 0.0.20 → 0.0.21

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.
@@ -1,7 +1,7 @@
1
1
  import { jsx as o, jsxs as G } from "react/jsx-runtime";
2
2
  import { useRef as V, useState as I, useContext as q, useEffect as w } from "react";
3
3
  import { useTranslation as J } from "react-i18next";
4
- import { l as Q, u as X, C as Y, a as Z, b as K, c as C, $ as E, t as ee, I as te, E as ie, d as oe, R as ne, F as ae } from "./layers.BIzQNpIe.js";
4
+ import { l as Q, u as X, C as Y, a as Z, b as K, c as C, $ as E, t as ee, I as te, E as ie, d as oe, R as ne, F as ae } from "./layers.CFJiIrku.js";
5
5
  import { LoadingOverlay as H, Flex as se, Alert as re } from "@mantine/core";
6
6
  import { IconInfoCircle as le } from "@tabler/icons-react";
7
7
  const T = (t) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),r=require("react"),t=require("./layers.BSW9244N.js"),M=require("@mantine/core");function P(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var F=P(function(e){const l=new URLSearchParams;l.append("code",e);for(let a=1;a<arguments.length;a++)l.append("v",arguments[a]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${l} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function R(e){const l=e.transform();return l!==null?new Set([l]):new Set}function K({initialEditor:e,children:l,initialNodes:a,initialTheme:d,skipCollabChecks:i}){const c=r.useRef(!1),o=r.useContext(t.l$1);o==null&&F(9);const[g,{getTheme:S}]=o,_=r.useMemo(()=>{const m=d||S()||void 0,h=t.o(o,m);if(m!==void 0&&(e._config.theme=m),e._parentEditor=g,a)for(let s of a){let w=null,x=null;if(typeof s!="function"){const C=s;s=C.replace,w=C.with,x=C.withKlass||null}const E=e._nodes.get(s.getType());e._nodes.set(s.getType(),{exportDOM:E?E.exportDOM:void 0,klass:s,replace:w,replaceWithKlass:x,transforms:R(s)})}else{const s=e._nodes=new Map(g._nodes);for(const[w,x]of s)e._nodes.set(w,{exportDOM:x.exportDOM,klass:x.klass,replace:x.replace,replaceWithKlass:x.replaceWithKlass,transforms:R(x.klass)})}return e._config.namespace=g._config.namespace,e._editable=g._editable,[e,h]},[]),{isCollabActive:b,yjsDocMap:v}=t.l(),f=i||c.current||v.has(e.getKey());return r.useEffect(()=>{f&&(c.current=!0)},[f]),r.useEffect(()=>g.registerEditableListener(m=>{e.setEditable(m)}),[e,g]),n.jsx(t.l$1.Provider,{value:_,children:!b||f?l:null})}function L({"data-test-id":e,children:l,className:a,onClick:d,disabled:i,small:c,title:o}){return n.jsx(M.Button,{onClick:d,disabled:i,variant:"filled",children:l})}function O({children:e,className:l}){return n.jsx("div",{className:l||"Placeholder__root",children:e})}function $({children:e,label:l,className:a,...d}){return n.jsxs("div",{className:"Input__wrapper",children:[n.jsx("label",{style:{marginTop:"-1em"},className:"Input__label",children:l}),n.jsx("select",{...d,className:a||"select",children:e})]})}function B({label:e,value:l,onChange:a,placeholder:d="","data-test-id":i,type:c="text"}){return n.jsx(M.TextInput,{type:c,placeholder:d,value:l,onChange:o=>{a(o.target.value)},label:e,"data-test-id":i,mb:10})}const y=new Set;function U(e){if(!y.has(e))throw new Promise(l=>{const a=new Image;a.src=e,a.onload=()=>{y.add(e),l(null)}})}function q({altText:e,className:l,imageRef:a,src:d,width:i,height:c,position:o}){return U(d),n.jsx("img",{className:l||void 0,src:d,alt:e,ref:a,"data-position":o,style:{display:"block",height:c,width:i},draggable:"false"})}function T({activeEditor:e,nodeKey:l,onClose:a}){const i=e.getEditorState().read(()=>t.Ct(l)),[c,o]=r.useState(i.getAltText()),[g,S]=r.useState(i.getShowCaption()),[_,b]=r.useState(i.getPosition()),v=h=>{S(h.target.checked)},f=h=>{b(h.target.value)},m=()=>{const h={altText:c,position:_,showCaption:g};i&&e.update(()=>{i.update(h)}),a()};return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{marginBottom:"1em"},children:n.jsx(B,{label:"Alt-текст",placeholder:"Альтернативный текст",onChange:o,value:c,"data-test-id":"image-modal-alt-text-input"})}),n.jsxs($,{style:{marginBottom:"1em",width:"208px"},value:_,label:"Position",name:"position",id:"position-select",onChange:f,children:[n.jsx("option",{value:"left",children:"Left"}),n.jsx("option",{value:"right",children:"Right"}),n.jsx("option",{value:"full",children:"Full Width"})]}),n.jsxs("div",{className:"Input__wrapper",children:[n.jsx("input",{id:"caption",type:"checkbox",checked:g,onChange:v}),n.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),n.jsx(L,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>m(),children:"Применить"})]})}function A({src:e,altText:l,nodeKey:a,width:d,height:i,showCaption:c,caption:o,position:g}){const[S,_]=t.useModal(),b=r.useRef(null),v=r.useRef(null),[f,m,h]=t.u$1(a),[s]=t.u(),[w,x]=r.useState(null),E=r.useRef(null),C=r.useCallback(p=>{if(f&&t.wi(t.Ri())){p.preventDefault();const u=t.Ct(a);t.$isInlineImageNode(u)&&u.remove()}return!1},[f,a]),k=r.useCallback(p=>{const j=t.Ri(),u=v.current;if(f&&t.wi(j)&&j.getNodes().length===1){if(c)return t.Ft(null),p.preventDefault(),o.focus(),!0;if(u!==null&&u!==document.activeElement)return p.preventDefault(),u.focus(),!0}return!1},[o,f,c]),N=r.useCallback(p=>E.current===o||v.current===p.target?(t.Ft(null),s.update(()=>{m(!0);const j=s.getRootElement();j!==null&&j.focus()}),!0):!1,[o,s,m]);r.useEffect(()=>{let p=!0;const j=t.N(s.registerUpdateListener(({editorState:u})=>{p&&x(u.read(()=>t.Ri()))}),s.registerCommand(t.t,(u,I)=>(E.current=I,!1),t.Ks),s.registerCommand(t.r,u=>{const I=u;return I.target===b.current?(I.shiftKey?m(!f):(h(),m(!0)),!0):!1},t.Ks),s.registerCommand(t.D,u=>u.target===b.current?(u.preventDefault(),!0):!1,t.Ks),s.registerCommand(t.w,C,t.Ks),s.registerCommand(t.k,C,t.Ks),s.registerCommand(t.C,k,t.Ks),s.registerCommand(t.b,N,t.Ks));return()=>{p=!1,j()}},[h,s,f,a,C,k,N,m]);const D=f;return n.jsxs(r.Suspense,{fallback:null,children:[n.jsxs(n.Fragment,{children:[n.jsxs("div",{draggable:!1,children:[n.jsx("button",{className:"image-edit-button",ref:v,onClick:()=>{_("Update Inline Image",p=>n.jsx(T,{activeEditor:s,nodeKey:a,onClose:p}))},children:"Edit"}),n.jsx(q,{className:D?`focused ${t.wi(w)?"draggable":""}`:null,src:e,altText:l,imageRef:b,width:d,height:i,position:g})]}),c&&n.jsx("div",{className:"image-caption-container",children:n.jsxs(K,{initialEditor:o,children:[n.jsx(t.LinkPlugin,{}),n.jsx(t.FloatingTextFormatToolbarPlugin,{}),n.jsx(t.h,{contentEditable:n.jsx(t.LexicalContentEditable,{className:"InlineImageNode__contentEditable"}),placeholder:n.jsx(O,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:t.a})]})})]}),S]})}exports.UpdateInlineImageDialog=T;exports.default=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),r=require("react"),t=require("./layers.F7W7VvW1.js"),M=require("@mantine/core");function P(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var F=P(function(e){const l=new URLSearchParams;l.append("code",e);for(let a=1;a<arguments.length;a++)l.append("v",arguments[a]);throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${l} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function R(e){const l=e.transform();return l!==null?new Set([l]):new Set}function K({initialEditor:e,children:l,initialNodes:a,initialTheme:d,skipCollabChecks:i}){const c=r.useRef(!1),o=r.useContext(t.l$1);o==null&&F(9);const[g,{getTheme:S}]=o,_=r.useMemo(()=>{const m=d||S()||void 0,h=t.o(o,m);if(m!==void 0&&(e._config.theme=m),e._parentEditor=g,a)for(let s of a){let w=null,x=null;if(typeof s!="function"){const C=s;s=C.replace,w=C.with,x=C.withKlass||null}const E=e._nodes.get(s.getType());e._nodes.set(s.getType(),{exportDOM:E?E.exportDOM:void 0,klass:s,replace:w,replaceWithKlass:x,transforms:R(s)})}else{const s=e._nodes=new Map(g._nodes);for(const[w,x]of s)e._nodes.set(w,{exportDOM:x.exportDOM,klass:x.klass,replace:x.replace,replaceWithKlass:x.replaceWithKlass,transforms:R(x.klass)})}return e._config.namespace=g._config.namespace,e._editable=g._editable,[e,h]},[]),{isCollabActive:b,yjsDocMap:v}=t.l(),f=i||c.current||v.has(e.getKey());return r.useEffect(()=>{f&&(c.current=!0)},[f]),r.useEffect(()=>g.registerEditableListener(m=>{e.setEditable(m)}),[e,g]),n.jsx(t.l$1.Provider,{value:_,children:!b||f?l:null})}function L({"data-test-id":e,children:l,className:a,onClick:d,disabled:i,small:c,title:o}){return n.jsx(M.Button,{onClick:d,disabled:i,variant:"filled",children:l})}function O({children:e,className:l}){return n.jsx("div",{className:l||"Placeholder__root",children:e})}function $({children:e,label:l,className:a,...d}){return n.jsxs("div",{className:"Input__wrapper",children:[n.jsx("label",{style:{marginTop:"-1em"},className:"Input__label",children:l}),n.jsx("select",{...d,className:a||"select",children:e})]})}function B({label:e,value:l,onChange:a,placeholder:d="","data-test-id":i,type:c="text"}){return n.jsx(M.TextInput,{type:c,placeholder:d,value:l,onChange:o=>{a(o.target.value)},label:e,"data-test-id":i,mb:10})}const y=new Set;function U(e){if(!y.has(e))throw new Promise(l=>{const a=new Image;a.src=e,a.onload=()=>{y.add(e),l(null)}})}function q({altText:e,className:l,imageRef:a,src:d,width:i,height:c,position:o}){return U(d),n.jsx("img",{className:l||void 0,src:d,alt:e,ref:a,"data-position":o,style:{display:"block",height:c,width:i},draggable:"false"})}function T({activeEditor:e,nodeKey:l,onClose:a}){const i=e.getEditorState().read(()=>t.Ct(l)),[c,o]=r.useState(i.getAltText()),[g,S]=r.useState(i.getShowCaption()),[_,b]=r.useState(i.getPosition()),v=h=>{S(h.target.checked)},f=h=>{b(h.target.value)},m=()=>{const h={altText:c,position:_,showCaption:g};i&&e.update(()=>{i.update(h)}),a()};return n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{marginBottom:"1em"},children:n.jsx(B,{label:"Alt-текст",placeholder:"Альтернативный текст",onChange:o,value:c,"data-test-id":"image-modal-alt-text-input"})}),n.jsxs($,{style:{marginBottom:"1em",width:"208px"},value:_,label:"Position",name:"position",id:"position-select",onChange:f,children:[n.jsx("option",{value:"left",children:"Left"}),n.jsx("option",{value:"right",children:"Right"}),n.jsx("option",{value:"full",children:"Full Width"})]}),n.jsxs("div",{className:"Input__wrapper",children:[n.jsx("input",{id:"caption",type:"checkbox",checked:g,onChange:v}),n.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),n.jsx(L,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>m(),children:"Применить"})]})}function A({src:e,altText:l,nodeKey:a,width:d,height:i,showCaption:c,caption:o,position:g}){const[S,_]=t.useModal(),b=r.useRef(null),v=r.useRef(null),[f,m,h]=t.u$1(a),[s]=t.u(),[w,x]=r.useState(null),E=r.useRef(null),C=r.useCallback(p=>{if(f&&t.wi(t.Ri())){p.preventDefault();const u=t.Ct(a);t.$isInlineImageNode(u)&&u.remove()}return!1},[f,a]),k=r.useCallback(p=>{const j=t.Ri(),u=v.current;if(f&&t.wi(j)&&j.getNodes().length===1){if(c)return t.Ft(null),p.preventDefault(),o.focus(),!0;if(u!==null&&u!==document.activeElement)return p.preventDefault(),u.focus(),!0}return!1},[o,f,c]),N=r.useCallback(p=>E.current===o||v.current===p.target?(t.Ft(null),s.update(()=>{m(!0);const j=s.getRootElement();j!==null&&j.focus()}),!0):!1,[o,s,m]);r.useEffect(()=>{let p=!0;const j=t.N(s.registerUpdateListener(({editorState:u})=>{p&&x(u.read(()=>t.Ri()))}),s.registerCommand(t.t,(u,I)=>(E.current=I,!1),t.Ks),s.registerCommand(t.r,u=>{const I=u;return I.target===b.current?(I.shiftKey?m(!f):(h(),m(!0)),!0):!1},t.Ks),s.registerCommand(t.D,u=>u.target===b.current?(u.preventDefault(),!0):!1,t.Ks),s.registerCommand(t.w,C,t.Ks),s.registerCommand(t.k,C,t.Ks),s.registerCommand(t.C,k,t.Ks),s.registerCommand(t.b,N,t.Ks));return()=>{p=!1,j()}},[h,s,f,a,C,k,N,m]);const D=f;return n.jsxs(r.Suspense,{fallback:null,children:[n.jsxs(n.Fragment,{children:[n.jsxs("div",{draggable:!1,children:[n.jsx("button",{className:"image-edit-button",ref:v,onClick:()=>{_("Update Inline Image",p=>n.jsx(T,{activeEditor:s,nodeKey:a,onClose:p}))},children:"Edit"}),n.jsx(q,{className:D?`focused ${t.wi(w)?"draggable":""}`:null,src:e,altText:l,imageRef:b,width:d,height:i,position:g})]}),c&&n.jsx("div",{className:"image-caption-container",children:n.jsxs(K,{initialEditor:o,children:[n.jsx(t.LinkPlugin,{}),n.jsx(t.FloatingTextFormatToolbarPlugin,{}),n.jsx(t.h,{contentEditable:n.jsx(t.LexicalContentEditable,{className:"InlineImageNode__contentEditable"}),placeholder:n.jsx(O,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:t.a})]})})]}),S]})}exports.UpdateInlineImageDialog=T;exports.default=A;
@@ -1,6 +1,6 @@
1
1
  import { jsx as a, jsxs as v, Fragment as j } from "react/jsx-runtime";
2
2
  import { useRef as k, useContext as K, useMemo as U, useEffect as P, useState as T, useCallback as y, Suspense as W } from "react";
3
- import { e as R, o as q, l as z, f as G, g as H, u as J, w as M, h as D, c as A, i as Q, F as $, N as V, j as X, K as w, k as Y, m as Z, n as ee, D as te, r as ne, p as ae, L as le, q as re, s as oe, v as ie, x as se } from "./layers.BIzQNpIe.js";
3
+ import { e as R, o as q, l as z, f as G, g as H, u as J, w as M, h as D, c as A, i as Q, F as $, N as V, j as X, K as w, k as Y, m as Z, n as ee, D as te, r as ne, p as ae, L as le, q as re, s as oe, v as ie, x as se } from "./layers.CFJiIrku.js";
4
4
  import { Button as ce, TextInput as ue } from "@mantine/core";
5
5
  function de(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;