@layers-app/editor 0.0.15-swagger → 0.0.16

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
- };
@@ -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.D1A3jNDb.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;
@@ -1,288 +0,0 @@
1
- import { jsxs as f, jsx as e, Fragment as L } from "react/jsx-runtime";
2
- import { useRef as w, useState as E, useCallback as _, useEffect as A, Suspense as M } from "react";
3
- import { e as U, f as q, u as z, w as k, g as F, c as B, h as O, F as D, N as W, i as G, K as h, j as H, k as J, m as Q, D as V, r as X, n as Y, L as Z, o as K, p as ee, q as te, s as ne, B as ae } from "./layers.36_3ol3v.js";
4
- import { d as le, P as oe } from "./layers.Di1ekcMX.js";
5
- import { TextInput as re } from "@mantine/core";
6
- function ie({
7
- children: n,
8
- label: o,
9
- className: t,
10
- ...u
11
- }) {
12
- return /* @__PURE__ */ f("div", { className: "Input__wrapper", children: [
13
- /* @__PURE__ */ e("label", { style: { marginTop: "-1em" }, className: "Input__label", children: o }),
14
- /* @__PURE__ */ e("select", { ...u, className: t || "select", children: n })
15
- ] });
16
- }
17
- function se({
18
- label: n,
19
- value: o,
20
- onChange: t,
21
- placeholder: u = "",
22
- "data-test-id": r,
23
- type: c = "text"
24
- }) {
25
- return /* @__PURE__ */ e(
26
- re,
27
- {
28
- type: c,
29
- placeholder: u,
30
- value: o,
31
- onChange: (i) => {
32
- t(i.target.value);
33
- },
34
- label: n,
35
- "data-test-id": r,
36
- mb: 10
37
- }
38
- );
39
- }
40
- const y = /* @__PURE__ */ new Set();
41
- function ce(n) {
42
- if (!y.has(n))
43
- throw new Promise((o) => {
44
- const t = new Image();
45
- t.src = n, t.onload = () => {
46
- y.add(n), o(null);
47
- };
48
- });
49
- }
50
- function ue({
51
- altText: n,
52
- className: o,
53
- imageRef: t,
54
- src: u,
55
- width: r,
56
- height: c,
57
- position: i
58
- }) {
59
- return ce(u), /* @__PURE__ */ e(
60
- "img",
61
- {
62
- className: o || void 0,
63
- src: u,
64
- alt: n,
65
- ref: t,
66
- "data-position": i,
67
- style: {
68
- display: "block",
69
- height: c,
70
- width: r
71
- },
72
- draggable: "false"
73
- }
74
- );
75
- }
76
- function de({
77
- activeEditor: n,
78
- nodeKey: o,
79
- onClose: t
80
- }) {
81
- const r = n.getEditorState().read(
82
- () => B(o)
83
- ), [c, i] = E(r.getAltText()), [I, x] = E(r.getShowCaption()), [v, C] = E(r.getPosition()), b = (m) => {
84
- x(m.target.checked);
85
- }, d = (m) => {
86
- C(m.target.value);
87
- }, p = () => {
88
- const m = { altText: c, position: v, showCaption: I };
89
- r && n.update(() => {
90
- r.update(m);
91
- }), t();
92
- };
93
- return /* @__PURE__ */ f(L, { children: [
94
- /* @__PURE__ */ e("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ e(
95
- se,
96
- {
97
- label: "Alt-текст",
98
- placeholder: "Альтернативный текст",
99
- onChange: i,
100
- value: c,
101
- "data-test-id": "image-modal-alt-text-input"
102
- }
103
- ) }),
104
- /* @__PURE__ */ f(
105
- ie,
106
- {
107
- style: { marginBottom: "1em", width: "208px" },
108
- value: v,
109
- label: "Position",
110
- name: "position",
111
- id: "position-select",
112
- onChange: d,
113
- children: [
114
- /* @__PURE__ */ e("option", { value: "left", children: "Left" }),
115
- /* @__PURE__ */ e("option", { value: "right", children: "Right" }),
116
- /* @__PURE__ */ e("option", { value: "full", children: "Full Width" })
117
- ]
118
- }
119
- ),
120
- /* @__PURE__ */ f("div", { className: "Input__wrapper", children: [
121
- /* @__PURE__ */ e(
122
- "input",
123
- {
124
- id: "caption",
125
- type: "checkbox",
126
- checked: I,
127
- onChange: b
128
- }
129
- ),
130
- /* @__PURE__ */ e("label", { htmlFor: "caption", children: "Show Caption" })
131
- ] }),
132
- /* @__PURE__ */ e(
133
- ae,
134
- {
135
- "data-test-id": "image-modal-file-upload-btn",
136
- onClick: () => p(),
137
- children: "Применить"
138
- }
139
- )
140
- ] });
141
- }
142
- function be({
143
- src: n,
144
- altText: o,
145
- nodeKey: t,
146
- width: u,
147
- height: r,
148
- showCaption: c,
149
- caption: i,
150
- position: I
151
- }) {
152
- const [x, v] = U(), C = w(null), b = w(null), [d, p, m] = q(t), [l] = z(), [$, j] = E(null), P = w(null), N = _(
153
- (s) => {
154
- if (d && k(F())) {
155
- s.preventDefault();
156
- const a = B(t);
157
- O(a) && a.remove();
158
- }
159
- return !1;
160
- },
161
- [d, t]
162
- ), T = _(
163
- (s) => {
164
- const g = F(), a = b.current;
165
- if (d && k(g) && g.getNodes().length === 1) {
166
- if (c)
167
- return D(null), s.preventDefault(), i.focus(), !0;
168
- if (a !== null && a !== document.activeElement)
169
- return s.preventDefault(), a.focus(), !0;
170
- }
171
- return !1;
172
- },
173
- [i, d, c]
174
- ), R = _(
175
- (s) => P.current === i || b.current === s.target ? (D(null), l.update(() => {
176
- p(!0);
177
- const g = l.getRootElement();
178
- g !== null && g.focus();
179
- }), !0) : !1,
180
- [i, l, p]
181
- );
182
- return A(() => {
183
- let s = !0;
184
- const g = W(
185
- l.registerUpdateListener(({ editorState: a }) => {
186
- s && j(a.read(() => F()));
187
- }),
188
- l.registerCommand(
189
- Y,
190
- (a, S) => (P.current = S, !1),
191
- h
192
- ),
193
- l.registerCommand(
194
- X,
195
- (a) => {
196
- const S = a;
197
- return S.target === C.current ? (S.shiftKey ? p(!d) : (m(), p(!0)), !0) : !1;
198
- },
199
- h
200
- ),
201
- l.registerCommand(
202
- V,
203
- (a) => a.target === C.current ? (a.preventDefault(), !0) : !1,
204
- h
205
- ),
206
- l.registerCommand(
207
- Q,
208
- N,
209
- h
210
- ),
211
- l.registerCommand(
212
- J,
213
- N,
214
- h
215
- ),
216
- l.registerCommand(H, T, h),
217
- l.registerCommand(
218
- G,
219
- R,
220
- h
221
- )
222
- );
223
- return () => {
224
- s = !1, g();
225
- };
226
- }, [
227
- m,
228
- l,
229
- d,
230
- t,
231
- N,
232
- T,
233
- R,
234
- p
235
- ]), /* @__PURE__ */ f(M, { fallback: null, children: [
236
- /* @__PURE__ */ f(L, { children: [
237
- /* @__PURE__ */ f("div", { draggable: !1, children: [
238
- /* @__PURE__ */ e(
239
- "button",
240
- {
241
- className: "image-edit-button",
242
- ref: b,
243
- onClick: () => {
244
- v("Update Inline Image", (s) => /* @__PURE__ */ e(
245
- de,
246
- {
247
- activeEditor: l,
248
- nodeKey: t,
249
- onClose: s
250
- }
251
- ));
252
- },
253
- children: "Edit"
254
- }
255
- ),
256
- /* @__PURE__ */ e(
257
- ue,
258
- {
259
- className: d ? `focused ${k($) ? "draggable" : ""}` : null,
260
- src: n,
261
- altText: o,
262
- imageRef: C,
263
- width: u,
264
- height: r,
265
- position: I
266
- }
267
- )
268
- ] }),
269
- c && /* @__PURE__ */ e("div", { className: "image-caption-container", children: /* @__PURE__ */ f(le, { initialEditor: i, children: [
270
- /* @__PURE__ */ e(Z, {}),
271
- /* @__PURE__ */ e(K, {}),
272
- /* @__PURE__ */ e(
273
- ee,
274
- {
275
- contentEditable: /* @__PURE__ */ e(ne, { className: "InlineImageNode__contentEditable" }),
276
- placeholder: /* @__PURE__ */ e(oe, { className: "InlineImageNode__placeholder", children: "Enter a caption..." }),
277
- ErrorBoundary: te
278
- }
279
- )
280
- ] }) })
281
- ] }),
282
- x
283
- ] });
284
- }
285
- export {
286
- de as UpdateInlineImageDialog,
287
- be as default
288
- };