@layers-app/editor 0.0.15-swagger → 0.0.17-editor

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 +0,0 @@
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,52 +0,0 @@
1
- import { ad as p, ae as k, l as E } from "./layers.36_3ol3v.js";
2
- import { useRef as O, useContext as P, useMemo as D, useEffect as h } from "react";
3
- import { jsx as _ } from "react/jsx-runtime";
4
- function K(e) {
5
- return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
- }
7
- var C = K(function(e) {
8
- const t = new URLSearchParams();
9
- t.append("code", e);
10
- for (let o = 1; o < arguments.length; o++) t.append("v", arguments[o]);
11
- throw Error(`Minified Lexical error #${e}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
12
- });
13
- function m(e) {
14
- const t = e.transform();
15
- return t !== null ? /* @__PURE__ */ new Set([t]) : /* @__PURE__ */ new Set();
16
- }
17
- function S({ initialEditor: e, children: t, initialNodes: o, initialTheme: g, skipCollabChecks: v }) {
18
- const f = O(!1), i = P(p);
19
- i == null && C(9);
20
- const [l, { getTheme: w }] = i, x = D(() => {
21
- const a = g || w() || void 0, y = k(i, a);
22
- if (a !== void 0 && (e._config.theme = a), e._parentEditor = l, o) for (let r of o) {
23
- let s = null, n = null;
24
- if (typeof r != "function") {
25
- const d = r;
26
- r = d.replace, s = d.with, n = d.withKlass || null;
27
- }
28
- const u = e._nodes.get(r.getType());
29
- e._nodes.set(r.getType(), { exportDOM: u ? u.exportDOM : void 0, klass: r, replace: s, replaceWithKlass: n, transforms: m(r) });
30
- }
31
- else {
32
- const r = e._nodes = new Map(l._nodes);
33
- for (const [s, n] of r) e._nodes.set(s, { exportDOM: n.exportDOM, klass: n.klass, replace: n.replace, replaceWithKlass: n.replaceWithKlass, transforms: m(n.klass) });
34
- }
35
- return e._config.namespace = l._config.namespace, e._editable = l._editable, [e, y];
36
- }, []), { isCollabActive: M, yjsDocMap: b } = E(), c = v || f.current || b.has(e.getKey());
37
- return h(() => {
38
- c && (f.current = !0);
39
- }, [c]), h(() => l.registerEditableListener((a) => {
40
- e.setEditable(a);
41
- }), [e, l]), _(p.Provider, { value: x, children: !M || c ? t : null });
42
- }
43
- function W({
44
- children: e,
45
- className: t
46
- }) {
47
- return /* @__PURE__ */ _("div", { className: t || "Placeholder__root", children: e });
48
- }
49
- export {
50
- W as P,
51
- S as d
52
- };