@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.
@@ -0,0 +1,343 @@
1
+ import { jsx as a, jsxs as v, Fragment as j } from "react/jsx-runtime";
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 oe, s as re, v as ie, x as se } from "./layers.DKTSDVNR.js";
4
+ import { Button as ce, TextInput as ue } from "@mantine/core";
5
+ function de(e) {
6
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
+ }
8
+ var me = de(function(e) {
9
+ const t = new URLSearchParams();
10
+ t.append("code", e);
11
+ for (let n = 1; n < arguments.length; n++) t.append("v", arguments[n]);
12
+ 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.`);
13
+ });
14
+ function O(e) {
15
+ const t = e.transform();
16
+ return t !== null ? /* @__PURE__ */ new Set([t]) : /* @__PURE__ */ new Set();
17
+ }
18
+ function fe({ initialEditor: e, children: t, initialNodes: n, initialTheme: c, skipCollabChecks: r }) {
19
+ const i = k(!1), o = K(R);
20
+ o == null && me(9);
21
+ const [m, { getTheme: E }] = o, x = U(() => {
22
+ const d = c || E() || void 0, p = q(o, d);
23
+ if (d !== void 0 && (e._config.theme = d), e._parentEditor = m, n) for (let l of n) {
24
+ let I = null, g = null;
25
+ if (typeof l != "function") {
26
+ const _ = l;
27
+ l = _.replace, I = _.with, g = _.withKlass || null;
28
+ }
29
+ const S = e._nodes.get(l.getType());
30
+ e._nodes.set(l.getType(), { exportDOM: S ? S.exportDOM : void 0, klass: l, replace: I, replaceWithKlass: g, transforms: O(l) });
31
+ }
32
+ else {
33
+ const l = e._nodes = new Map(m._nodes);
34
+ for (const [I, g] of l) e._nodes.set(I, { exportDOM: g.exportDOM, klass: g.klass, replace: g.replace, replaceWithKlass: g.replaceWithKlass, transforms: O(g.klass) });
35
+ }
36
+ return e._config.namespace = m._config.namespace, e._editable = m._editable, [e, p];
37
+ }, []), { isCollabActive: b, yjsDocMap: C } = z(), u = r || i.current || C.has(e.getKey());
38
+ return P(() => {
39
+ u && (i.current = !0);
40
+ }, [u]), P(() => m.registerEditableListener((d) => {
41
+ e.setEditable(d);
42
+ }), [e, m]), a(R.Provider, { value: x, children: !b || u ? t : null });
43
+ }
44
+ function pe({
45
+ "data-test-id": e,
46
+ children: t,
47
+ className: n,
48
+ onClick: c,
49
+ disabled: r,
50
+ small: i,
51
+ title: o
52
+ }) {
53
+ return /* @__PURE__ */ a(ce, { onClick: c, disabled: r, variant: "filled", children: t });
54
+ }
55
+ function ge({
56
+ children: e,
57
+ className: t
58
+ }) {
59
+ return /* @__PURE__ */ a("div", { className: t || "Placeholder__root", children: e });
60
+ }
61
+ function he({
62
+ children: e,
63
+ label: t,
64
+ className: n,
65
+ ...c
66
+ }) {
67
+ return /* @__PURE__ */ v("div", { className: "Input__wrapper", children: [
68
+ /* @__PURE__ */ a("label", { style: { marginTop: "-1em" }, className: "Input__label", children: t }),
69
+ /* @__PURE__ */ a("select", { ...c, className: n || "select", children: e })
70
+ ] });
71
+ }
72
+ function ve({
73
+ label: e,
74
+ value: t,
75
+ onChange: n,
76
+ placeholder: c = "",
77
+ "data-test-id": r,
78
+ type: i = "text"
79
+ }) {
80
+ return /* @__PURE__ */ a(
81
+ ue,
82
+ {
83
+ type: i,
84
+ placeholder: c,
85
+ value: t,
86
+ onChange: (o) => {
87
+ n(o.target.value);
88
+ },
89
+ label: e,
90
+ "data-test-id": r,
91
+ mb: 10
92
+ }
93
+ );
94
+ }
95
+ const B = /* @__PURE__ */ new Set();
96
+ function be(e) {
97
+ if (!B.has(e))
98
+ throw new Promise((t) => {
99
+ const n = new Image();
100
+ n.src = e, n.onload = () => {
101
+ B.add(e), t(null);
102
+ };
103
+ });
104
+ }
105
+ function Ce({
106
+ altText: e,
107
+ className: t,
108
+ imageRef: n,
109
+ src: c,
110
+ width: r,
111
+ height: i,
112
+ position: o
113
+ }) {
114
+ return be(c), /* @__PURE__ */ a(
115
+ "img",
116
+ {
117
+ className: t || void 0,
118
+ src: c,
119
+ alt: e,
120
+ ref: n,
121
+ "data-position": o,
122
+ style: {
123
+ display: "block",
124
+ height: i,
125
+ width: r
126
+ },
127
+ draggable: "false"
128
+ }
129
+ );
130
+ }
131
+ function _e({
132
+ activeEditor: e,
133
+ nodeKey: t,
134
+ onClose: n
135
+ }) {
136
+ const r = e.getEditorState().read(
137
+ () => A(t)
138
+ ), [i, o] = T(r.getAltText()), [m, E] = T(r.getShowCaption()), [x, b] = T(r.getPosition()), C = (p) => {
139
+ E(p.target.checked);
140
+ }, u = (p) => {
141
+ b(p.target.value);
142
+ }, d = () => {
143
+ const p = { altText: i, position: x, showCaption: m };
144
+ r && e.update(() => {
145
+ r.update(p);
146
+ }), n();
147
+ };
148
+ return /* @__PURE__ */ v(j, { children: [
149
+ /* @__PURE__ */ a("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ a(
150
+ ve,
151
+ {
152
+ label: "Alt-текст",
153
+ placeholder: "Альтернативный текст",
154
+ onChange: o,
155
+ value: i,
156
+ "data-test-id": "image-modal-alt-text-input"
157
+ }
158
+ ) }),
159
+ /* @__PURE__ */ v(
160
+ he,
161
+ {
162
+ style: { marginBottom: "1em", width: "208px" },
163
+ value: x,
164
+ label: "Position",
165
+ name: "position",
166
+ id: "position-select",
167
+ onChange: u,
168
+ children: [
169
+ /* @__PURE__ */ a("option", { value: "left", children: "Left" }),
170
+ /* @__PURE__ */ a("option", { value: "right", children: "Right" }),
171
+ /* @__PURE__ */ a("option", { value: "full", children: "Full Width" })
172
+ ]
173
+ }
174
+ ),
175
+ /* @__PURE__ */ v("div", { className: "Input__wrapper", children: [
176
+ /* @__PURE__ */ a(
177
+ "input",
178
+ {
179
+ id: "caption",
180
+ type: "checkbox",
181
+ checked: m,
182
+ onChange: C
183
+ }
184
+ ),
185
+ /* @__PURE__ */ a("label", { htmlFor: "caption", children: "Show Caption" })
186
+ ] }),
187
+ /* @__PURE__ */ a(
188
+ pe,
189
+ {
190
+ "data-test-id": "image-modal-file-upload-btn",
191
+ onClick: () => d(),
192
+ children: "Применить"
193
+ }
194
+ )
195
+ ] });
196
+ }
197
+ function Ne({
198
+ src: e,
199
+ altText: t,
200
+ nodeKey: n,
201
+ width: c,
202
+ height: r,
203
+ showCaption: i,
204
+ caption: o,
205
+ position: m
206
+ }) {
207
+ const [E, x] = G(), b = k(null), C = k(null), [u, d, p] = H(n), [l] = J(), [I, g] = T(null), S = k(null), _ = y(
208
+ (f) => {
209
+ if (u && M(D())) {
210
+ f.preventDefault();
211
+ const s = A(n);
212
+ Q(s) && s.remove();
213
+ }
214
+ return !1;
215
+ },
216
+ [u, n]
217
+ ), F = y(
218
+ (f) => {
219
+ const h = D(), s = C.current;
220
+ if (u && M(h) && h.getNodes().length === 1) {
221
+ if (i)
222
+ return $(null), f.preventDefault(), o.focus(), !0;
223
+ if (s !== null && s !== document.activeElement)
224
+ return f.preventDefault(), s.focus(), !0;
225
+ }
226
+ return !1;
227
+ },
228
+ [o, u, i]
229
+ ), L = y(
230
+ (f) => S.current === o || C.current === f.target ? ($(null), l.update(() => {
231
+ d(!0);
232
+ const h = l.getRootElement();
233
+ h !== null && h.focus();
234
+ }), !0) : !1,
235
+ [o, l, d]
236
+ );
237
+ return P(() => {
238
+ let f = !0;
239
+ const h = V(
240
+ l.registerUpdateListener(({ editorState: s }) => {
241
+ f && g(s.read(() => D()));
242
+ }),
243
+ l.registerCommand(
244
+ ae,
245
+ (s, N) => (S.current = N, !1),
246
+ w
247
+ ),
248
+ l.registerCommand(
249
+ ne,
250
+ (s) => {
251
+ const N = s;
252
+ return N.target === b.current ? (N.shiftKey ? d(!u) : (p(), d(!0)), !0) : !1;
253
+ },
254
+ w
255
+ ),
256
+ l.registerCommand(
257
+ te,
258
+ (s) => s.target === b.current ? (s.preventDefault(), !0) : !1,
259
+ w
260
+ ),
261
+ l.registerCommand(
262
+ ee,
263
+ _,
264
+ w
265
+ ),
266
+ l.registerCommand(
267
+ Z,
268
+ _,
269
+ w
270
+ ),
271
+ l.registerCommand(Y, F, w),
272
+ l.registerCommand(
273
+ X,
274
+ L,
275
+ w
276
+ )
277
+ );
278
+ return () => {
279
+ f = !1, h();
280
+ };
281
+ }, [
282
+ p,
283
+ l,
284
+ u,
285
+ n,
286
+ _,
287
+ F,
288
+ L,
289
+ d
290
+ ]), /* @__PURE__ */ v(W, { fallback: null, children: [
291
+ /* @__PURE__ */ v(j, { children: [
292
+ /* @__PURE__ */ v("div", { draggable: !1, children: [
293
+ /* @__PURE__ */ a(
294
+ "button",
295
+ {
296
+ className: "image-edit-button",
297
+ ref: C,
298
+ onClick: () => {
299
+ x("Update Inline Image", (f) => /* @__PURE__ */ a(
300
+ _e,
301
+ {
302
+ activeEditor: l,
303
+ nodeKey: n,
304
+ onClose: f
305
+ }
306
+ ));
307
+ },
308
+ children: "Edit"
309
+ }
310
+ ),
311
+ /* @__PURE__ */ a(
312
+ Ce,
313
+ {
314
+ className: u ? `focused ${M(I) ? "draggable" : ""}` : null,
315
+ src: e,
316
+ altText: t,
317
+ imageRef: b,
318
+ width: c,
319
+ height: r,
320
+ position: m
321
+ }
322
+ )
323
+ ] }),
324
+ i && /* @__PURE__ */ a("div", { className: "image-caption-container", children: /* @__PURE__ */ v(fe, { initialEditor: o, children: [
325
+ /* @__PURE__ */ a(le, {}),
326
+ /* @__PURE__ */ a(oe, {}),
327
+ /* @__PURE__ */ a(
328
+ re,
329
+ {
330
+ contentEditable: /* @__PURE__ */ a(se, { className: "InlineImageNode__contentEditable" }),
331
+ placeholder: /* @__PURE__ */ a(ge, { className: "InlineImageNode__placeholder", children: "Enter a caption..." }),
332
+ ErrorBoundary: ie
333
+ }
334
+ )
335
+ ] }) })
336
+ ] }),
337
+ E
338
+ ] });
339
+ }
340
+ export {
341
+ _e as UpdateInlineImageDialog,
342
+ Ne as default
343
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),s=require("react"),D=require("react-i18next"),t=require("./layers.BK2HDr2t.js"),E=require("@mantine/core"),U=require("@tabler/icons-react"),F=i=>{const{width:g,height:r,isLoading:l,isError:h,src:f,id:m,altText:p,imageRef:v,maxWidth:j}=i;return o.jsxs("div",{className:"media-wrapper",style:{width:g,height:r,display:"inline-flex",position:"relative"},children:[o.jsx(E.LoadingOverlay,{visible:l,zIndex:1e3,overlayProps:{backgroundOpacity:.5},loaderProps:{size:24,color:"black"}}),o.jsx(E.LoadingOverlay,{visible:h,zIndex:1e3,overlayProps:{backgroundOpacity:.5},loaderProps:{children:o.jsx(E.Flex,{bg:"white",maw:300,justify:"center",children:o.jsx(E.Alert,{variant:"light",color:"red",title:"Ошибка загрузки",icon:o.jsx(U.IconInfoCircle,{}),children:"Попробуйте загрузить заново."})})}}),o.jsx(B,{className:null,src:f,altText:p,imageRef:v,width:"inherit",height:"inherit",maxWidth:j||"auto",id:m})]})};function B({altText:i,className:g,imageRef:r,src:l,width:h,height:f,maxWidth:m,id:p}){return o.jsx("img",{className:g||void 0,src:l,alt:i,ref:r,style:{height:f,maxWidth:m,width:h},draggable:"false","data-id":p})}function G({src:i,altText:g,nodeKey:r,width:l,height:h,maxWidth:f,showCaption:m,caption:p,id:v,create:j,alignment:H}){const W=s.useRef(null),[P,S]=s.useState(!0),[R,M]=s.useState(!1),{isCollabActive:O}=t.l(),[u]=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)=>{u.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 n=new Image;n.src=e,n.onload=()=>{a(n.width)},n.onerror=()=>{c(new Error("Failed to load image"))}})}return s.useEffect(()=>{j&&I(!0)},[j]),s.useEffect(()=>{let e=l,a=h,c=100;i&&_(i).then(n=>{typeof e=="number"&&e<c&&n<c?(b(!0),w({width:e,height:a})):n<c?(b(!0),w({width:"auto",height:"auto"})):(w({width:n,height:n}),b(!1))})},[i]),s.useEffect(()=>{d.width&&d.height&&x&&u.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?o.jsx(F,{width:d.width,height:d.height,isLoading:P,isError:R,isIcon:x,src:i,id:v,editor:u,nodeKey:r,fetchDeleteImage:L,altText:g,imageRef:W,maxWidth:f,showCaption:m,caption:p,isCollabActive:O,historyState:k,showNestedEditorTreeView:q,t:y}):o.jsx(t.ResizableContainer,{editor:u,isIcon:x,width:typeof l=="string"&&l.includes("%")?parseFloat(l):l,height:typeof h=="string"&&h.includes("%")?parseFloat(h):l,initialWidth:d.width||"",initialHeight:d.height||"",onResizeEnd:T,alignment:H,children:o.jsx(F,{width:"inherit",height:"inherit",isLoading:P,isError:R,isIcon:x,src:i,id:v,editor:u,nodeKey:r,fetchDeleteImage:L,altText:g,imageRef:W,maxWidth:f,showCaption:m,caption:p,isCollabActive:O,historyState:k,showNestedEditorTreeView:q,t:y})}):o.jsx(t.ImagePicker,{uploading:!1,onUpload:e=>{!z||!e.length||(e.forEach((a,c)=>{z(a,(n,A)=>{c===0?u.update(()=>{const N=t.Ct(r);t.$isImageNode(N)&&(N.setSrc(n),N.setId(A))}):u.dispatchCommand(t.INSERT_IMAGE_COMMAND,{altText:"",src:n,id:A})})}),I(!1))},popoverProps:{opened:C,position:"bottom",onChange:I},onChange:e=>{I(!1),u.update(()=>{const a=t.Ct(r);t.$isImageNode(a)&&a.setSrc(e)})},children:o.jsx(t.EmptyNodeButton,{title:y("editor.image.add_photo"),icon:"photo",onClick:()=>I(!C)})})}exports.default=G;
@@ -1,7 +1,7 @@
1
1
  import { jsx as o, jsxs as G } from "react/jsx-runtime";
2
- import { useRef as V, useState as I, useContext as q, useEffect as w } from "react";
2
+ import { useRef as V, useState as I, useContext as q, useEffect as v } 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.36_3ol3v.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.DKTSDVNR.js";
5
5
  import { LoadingOverlay as T, Flex as se, Alert as re } from "@mantine/core";
6
6
  import { IconInfoCircle as le } from "@tabler/icons-react";
7
7
  const j = (t) => {
@@ -13,8 +13,8 @@ const j = (t) => {
13
13
  src: g,
14
14
  id: f,
15
15
  altText: u,
16
- imageRef: b,
17
- maxWidth: v
16
+ imageRef: w,
17
+ maxWidth: b
18
18
  } = t;
19
19
  return /* @__PURE__ */ G(
20
20
  "div",
@@ -62,10 +62,10 @@ const j = (t) => {
62
62
  className: null,
63
63
  src: g,
64
64
  altText: u,
65
- imageRef: b,
65
+ imageRef: w,
66
66
  width: "inherit",
67
67
  height: "inherit",
68
- maxWidth: v || "auto",
68
+ maxWidth: b || "auto",
69
69
  id: f
70
70
  }
71
71
  )
@@ -109,15 +109,15 @@ function pe({
109
109
  maxWidth: g,
110
110
  showCaption: f,
111
111
  caption: u,
112
- id: b,
113
- create: v,
112
+ id: w,
113
+ create: b,
114
114
  alignment: _
115
115
  }) {
116
116
  const z = V(null), [R, y] = I(!0), [k, D] = I(!1), { isCollabActive: A } = Q(), [h] = X(), [m, S] = I(!0), [r, W] = I({
117
117
  width: 0,
118
118
  height: 0
119
119
  }), { fetchUploadImage: F, fetchDeleteImage: L } = q(Y), { t: N } = J();
120
- w(() => {
120
+ v(() => {
121
121
  if (!t || t.startsWith("data:image/")) {
122
122
  y(!1);
123
123
  return;
@@ -153,9 +153,9 @@ function pe({
153
153
  };
154
154
  });
155
155
  }
156
- return w(() => {
157
- v && p(!0);
158
- }, [v]), w(() => {
156
+ return v(() => {
157
+ b && p(!0);
158
+ }, [b]), v(() => {
159
159
  let e = s, n = d, l = 100;
160
160
  t && B(t).then((i) => {
161
161
  typeof e == "number" && e < l && i < l ? (S(!0), W({
@@ -169,12 +169,12 @@ function pe({
169
169
  height: i
170
170
  }), S(!1));
171
171
  });
172
- }, [t]), w(() => {
172
+ }, [t]), v(() => {
173
173
  r.width && r.height && m && h.update(() => {
174
174
  const e = C(a);
175
175
  E(e) && e.setWidthAndHeight(r.width, r.height);
176
176
  });
177
- }, [r.width, r.height, m]), w(() => {
177
+ }, [r.width, r.height, m]), v(() => {
178
178
  const e = document.documentElement;
179
179
  ee(x, e);
180
180
  }, [x]), t ? m ? /* @__PURE__ */ o(
@@ -186,7 +186,7 @@ function pe({
186
186
  isError: k,
187
187
  isIcon: m,
188
188
  src: t,
189
- id: b,
189
+ id: w,
190
190
  editor: h,
191
191
  nodeKey: a,
192
192
  fetchDeleteImage: L,
@@ -220,7 +220,7 @@ function pe({
220
220
  isError: k,
221
221
  isIcon: m,
222
222
  src: t,
223
- id: b,
223
+ id: w,
224
224
  editor: h,
225
225
  nodeKey: a,
226
226
  fetchDeleteImage: L,