@layers-app/editor 0.5.8-optimization → 0.5.10-optimization
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.
- package/README.md +0 -19
- package/dist/ExcalidrawComponent-D7Z_2awF.cjs +1 -0
- package/dist/ExcalidrawComponent-Re4zFgLg.js +283 -0
- package/dist/InlineImageComponent-DHgCaPNk.cjs +1 -0
- package/dist/InlineImageComponent-kXhZcmF6.js +265 -0
- package/dist/collaboration-C7xVk0Zj.cjs +4 -0
- package/dist/collaboration-Cn7KizEJ.js +5997 -0
- package/dist/excalidraw-C-6bid_P.js +16497 -0
- package/dist/excalidraw-DpwKTNBz.cjs +574 -0
- package/dist/index-B4yOqKUQ.cjs +1 -0
- package/dist/index-BZu8Qnrg.cjs +1 -0
- package/dist/index-CFA9Drk2.cjs +16 -0
- package/dist/index-CX5msaMB.js +296 -0
- package/dist/index-CbQX0N2c.js +136 -0
- package/dist/index-DEC5JR_F.js +60 -0
- package/dist/index-Dan3tqoj.cjs +1 -0
- package/dist/index-WCOc4LNL.js +16600 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +12 -13
- package/dist/lexical-2rxs76dr.cjs +41 -0
- package/dist/lexical-C60GkwxR.js +13122 -0
- package/dist/lexical-code-DKIWiZdJ.js +604 -0
- package/dist/lexical-code-VafvPacU.cjs +9 -0
- package/dist/lexical-collab-1tX9tFVC.js +1025 -0
- package/dist/lexical-collab-Nk2LVpJv.cjs +1 -0
- package/dist/lexical-file-C52Mze5k.cjs +1 -0
- package/dist/lexical-file-DjHP4vVw.js +43 -0
- package/dist/lexical-markdown-BSl_ahWw.cjs +12 -0
- package/dist/lexical-markdown-DcEwQQba.js +488 -0
- package/dist/lodash-3PEMjFQT.cjs +1 -0
- package/dist/lodash-jftOdrxX.js +711 -0
- package/dist/stats.html +4949 -0
- package/dist/vendor-BrXDSyZX.js +136433 -0
- package/dist/vendor-Bt6Lma3y.cjs +2469 -0
- package/package.json +42 -74
- package/dist/layers.8yssqxrI.js +0 -6774
- package/dist/layers.B8z-e4Vg.js +0 -7
- package/dist/layers.BQLznd92.js +0 -4
- package/dist/layers.BVRvG1mv.js +0 -3
- package/dist/layers.BjCQNcdJ.js +0 -341
- package/dist/layers.BnVn2uMi.js +0 -7723
- package/dist/layers.CLcioDq5.js +0 -2511
- package/dist/layers.CTSBFg3j.js +0 -1
- package/dist/layers.CoCZDINv.js +0 -864
- package/dist/layers.D0ZtUpST.js +0 -2
- package/dist/layers.D2zjLyjP.js +0 -6
- package/dist/layers.DNCgFYS7.js +0 -27
- package/dist/layers.Dt_Jdn4Y.js +0 -2227
- package/dist/layers.DwX5sVtx.js +0 -1
- package/dist/layers.QjAkD17S.js +0 -3677
- package/dist/layers.pre7B8K-.js +0 -530
package/README.md
CHANGED
|
@@ -715,22 +715,3 @@ editorRef?: { current: EditorType | null } - Reference to the editor.
|
|
|
715
715
|
```
|
|
716
716
|
|
|
717
717
|
</details>
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
---
|
|
723
|
-
|
|
724
|
-
## 🚀 Integration Guide for other Projects
|
|
725
|
-
|
|
726
|
-
### Step 1: Install Required Dependencies
|
|
727
|
-
|
|
728
|
-
```bash
|
|
729
|
-
npm install lexical @lexical/react @lexical/file @lexical/headless @lexical/markdown @layers-app/shared @tanstack/react-query react-selecto @mantine/core @mantine/hooks @mantine/form @mantine/dropzone @mantine/modals @mantine/notifications @tabler/icons-react i18next react-i18next lodash-es
|
|
730
|
-
```
|
|
731
|
-
|
|
732
|
-
### Step 2: Add Collaboration if needed
|
|
733
|
-
|
|
734
|
-
```tsx
|
|
735
|
-
npm install yjs y-websocket
|
|
736
|
-
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),n=require("./lexical-2rxs76dr.cjs"),m=require("./index-CFA9Drk2.cjs"),q=require("react-i18next"),c=require("@mantine/core"),$=require("@tabler/icons-react"),y=require("./index-BZu8Qnrg.cjs"),F=({isCloseModal:t,setCloseModalOpen:a,confirmClose:d})=>{const{t:o}=q.useTranslation();return e.jsx(c.Modal,{opened:t,onClose:()=>{a(!1)},centered:!0,title:o("editor.unsavedChanges.title"),closeOnClickOutside:!0,closeOnEscape:!0,size:"500",zIndex:999,children:e.jsxs("div",{children:[e.jsx(c.Text,{mb:"md",children:o("editor.unsavedChanges.message")}),e.jsxs(c.Flex,{justify:"flex-end",gap:"sm",children:[e.jsx(c.Button,{variant:"default",onClick:()=>{a(!1)},fullWidth:!0,children:o("editor.unsavedChanges.cancel")}),e.jsx(c.Button,{color:"red",onClick:d,fullWidth:!0,children:o("editor.unsavedChanges.closeWithoutSaving")})]})]})})},H=t=>{var o;const a=(o=t==null?void 0:t.firstElementChild)==null?void 0:o.firstElementChild,d=t.getAttribute("viewBox");if(d!=null){const u=d.split(" ");t.setAttribute("width",u[2]),t.setAttribute("height",u[3])}a&&a.tagName==="style"&&a.remove()};function W({elements:t,files:a,imageContainerRef:d,appState:o,editor:u,rootClassName:i=null,width:v="inherit",height:A="inherit",nodeKey:f,alignment:k,setModalOpen:j}){const[b,M]=l.useState(null),[S,h]=l.useState(!1);c.useMantineTheme();const{t:p}=q.useTranslation();l.useEffect(()=>{(async()=>{const r=await y.exportExcalidrawToSvg({appState:o,elements:t,files:a});H(r),r.setAttribute("width","100%"),r.setAttribute("height","100%"),r.setAttribute("display","block"),r.classList.add("excalidraw-svg"),M(r)})()},[t,a,o]);const w=(g,r)=>{u.update(()=>{n.wo(null);const O=n.xo(f);return m.$isExcalidrawNode(O)&&O.setWidthAndHeight(g,r),!0})},z=g=>{m.deleteNode(u,f)};return e.jsx(m.ResizableContainer,{editor:u,isIcon:!1,isEmbed:!0,width:m.parseContainerSize(v),height:m.parseContainerSize(A),onResizeEnd:w,alignment:k,children:e.jsxs(c.Box,{className:"media-wrapper excaildraw",children:[e.jsxs("div",{className:"media-actions",children:[e.jsx(c.Tooltip,{label:p("editor.link.edit"),children:e.jsx(c.ActionIcon,{color:"gray","aria-label":"Settings",className:"media-action",variant:"default",size:24,onClick:()=>{j(!0)},children:e.jsx($.IconEdit,{size:14})})}),e.jsx(m.AlignmentImage,{opened:S,setOpened:h,t:p,editor:u,nodeKey:f}),e.jsx(c.Tooltip,{label:p("editor.actions.delete"),children:e.jsx(c.ActionIcon,{color:"gray","aria-label":"Settings",className:"media-action",variant:"default",size:24,onClick:z,children:e.jsx(m.Icon,{name:"trash",size:"14"})})})]}),e.jsx(c.Box,{w:"100%",ref:g=>{g&&d&&(d.current=g)},className:i??"",dangerouslySetInnerHTML:{__html:(b==null?void 0:b.outerHTML)??""}})]})})}function L({nodeKey:t,data:a,width:d,height:o,alignment:u}){const[i]=n.o(),v=n.a$2(),[A,f]=l.useState(a==="[]"&&i.isEditable()),[k,j]=l.useState(!1),b=l.useRef(null),M=l.useRef(null),S=l.useRef(null),[h,p,w]=n.u(t),[z,g]=l.useState(!1),r=l.useCallback(s=>(h&&(s.preventDefault(),i.update(()=>{const x=n.xo(t);x&&x.remove()})),!1),[i,h,t]);l.useEffect(()=>{if(!v){h&&w();return}return n.U(i.registerCommand(n.se,s=>{const x=M.current,C=s.target;return z?!0:x!==null&&x.contains(C)?(s.shiftKey||w(),p(!h),s.detail>1&&f(!0),!0):!1},n.zi),i.registerCommand(n.Oe,r,n.zi),i.registerCommand(n.we,r,n.zi))},[w,i,h,z,r,p,v]);const O=l.useCallback(()=>(f(!1),i.update(()=>{const s=n.xo(t);s&&s.remove()})),[i,t]),B=(s,x,C)=>i.update(()=>{const N=n.xo(t);m.$isExcalidrawNode(N)&&(s&&s.length>0||Object.keys(C).length>0?N.setData(JSON.stringify({appState:x,elements:s,files:C})):N.remove())}),{elements:E=[],files:T={},appState:I={}}=l.useMemo(()=>JSON.parse(a),[a]),R=l.useCallback(()=>{f(!1),j(!1),S.current=!1,E.length===0&&i.update(()=>{const s=n.xo(t);s&&s.remove()})},[i,t,E.length]),D=l.useCallback(()=>{S.current?j(!0):R()},[]);return e.jsxs(e.Fragment,{children:[e.jsx(F,{isCloseModal:k,confirmClose:R,setCloseModalOpen:j}),e.jsx(y.ExcalidrawModal,{initialElements:E,isEdited:S,initialFiles:T,initialAppState:I,isShown:A,onDelete:O,onClose:D,onSave:(s,x,C)=>{B(s,x,C),f(!1)},closeOnClickOutside:!1}),E.length>0&&e.jsx("div",{style:{display:"flex",justifyContent:u},children:e.jsx(W,{imageContainerRef:b,className:"image",elements:E,files:T,appState:I,width:d,height:o,editor:i,nodeKey:t,alignment:u,setModalOpen:f})})]})}exports.default=L;
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { jsx as i, jsxs as E, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useEffect as _, useRef as T, useCallback as z, useMemo as P } from "react";
|
|
3
|
+
import { av as Q, x as w, a1 as V, c4 as X, aK as Y, U as Z, aM as K, z as D, aN as ee, aD as te } from "./lexical-C60GkwxR.js";
|
|
4
|
+
import { R as ie, p as B, A as se, I as ne, a as J, d as ae } from "./index-WCOc4LNL.js";
|
|
5
|
+
import { useTranslation as $ } from "react-i18next";
|
|
6
|
+
import { Modal as le, Text as oe, Flex as re, Button as F, useMantineTheme as ce, Box as H, Tooltip as W, ActionIcon as L } from "@mantine/core";
|
|
7
|
+
import { IconEdit as de } from "@tabler/icons-react";
|
|
8
|
+
import { e as ue, E as fe } from "./index-CbQX0N2c.js";
|
|
9
|
+
const me = ({
|
|
10
|
+
isCloseModal: e,
|
|
11
|
+
setCloseModalOpen: n,
|
|
12
|
+
confirmClose: r
|
|
13
|
+
}) => {
|
|
14
|
+
const { t: a } = $();
|
|
15
|
+
return /* @__PURE__ */ i(
|
|
16
|
+
le,
|
|
17
|
+
{
|
|
18
|
+
opened: e,
|
|
19
|
+
onClose: () => {
|
|
20
|
+
n(!1);
|
|
21
|
+
},
|
|
22
|
+
centered: !0,
|
|
23
|
+
title: a("editor.unsavedChanges.title"),
|
|
24
|
+
closeOnClickOutside: !0,
|
|
25
|
+
closeOnEscape: !0,
|
|
26
|
+
size: "500",
|
|
27
|
+
zIndex: 999,
|
|
28
|
+
children: /* @__PURE__ */ E("div", { children: [
|
|
29
|
+
/* @__PURE__ */ i(oe, { mb: "md", children: a("editor.unsavedChanges.message") }),
|
|
30
|
+
/* @__PURE__ */ E(re, { justify: "flex-end", gap: "sm", children: [
|
|
31
|
+
/* @__PURE__ */ i(
|
|
32
|
+
F,
|
|
33
|
+
{
|
|
34
|
+
variant: "default",
|
|
35
|
+
onClick: () => {
|
|
36
|
+
n(!1);
|
|
37
|
+
},
|
|
38
|
+
fullWidth: !0,
|
|
39
|
+
children: a("editor.unsavedChanges.cancel")
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ i(F, { color: "red", onClick: r, fullWidth: !0, children: a("editor.unsavedChanges.closeWithoutSaving") })
|
|
43
|
+
] })
|
|
44
|
+
] })
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}, he = (e) => {
|
|
48
|
+
var a;
|
|
49
|
+
const n = (a = e == null ? void 0 : e.firstElementChild) == null ? void 0 : a.firstElementChild, r = e.getAttribute("viewBox");
|
|
50
|
+
if (r != null) {
|
|
51
|
+
const o = r.split(" ");
|
|
52
|
+
e.setAttribute("width", o[2]), e.setAttribute("height", o[3]);
|
|
53
|
+
}
|
|
54
|
+
n && n.tagName === "style" && n.remove();
|
|
55
|
+
};
|
|
56
|
+
function pe({
|
|
57
|
+
elements: e,
|
|
58
|
+
files: n,
|
|
59
|
+
imageContainerRef: r,
|
|
60
|
+
appState: a,
|
|
61
|
+
editor: o,
|
|
62
|
+
rootClassName: s = null,
|
|
63
|
+
width: S = "inherit",
|
|
64
|
+
height: M = "inherit",
|
|
65
|
+
nodeKey: c,
|
|
66
|
+
alignment: N,
|
|
67
|
+
setModalOpen: p
|
|
68
|
+
}) {
|
|
69
|
+
const [g, k] = v(null), [C, u] = v(!1);
|
|
70
|
+
ce();
|
|
71
|
+
const { t: m } = $();
|
|
72
|
+
_(() => {
|
|
73
|
+
(async () => {
|
|
74
|
+
const l = await ue({
|
|
75
|
+
appState: a,
|
|
76
|
+
elements: e,
|
|
77
|
+
files: n
|
|
78
|
+
});
|
|
79
|
+
he(l), l.setAttribute("width", "100%"), l.setAttribute("height", "100%"), l.setAttribute("display", "block"), l.classList.add("excalidraw-svg"), k(l);
|
|
80
|
+
})();
|
|
81
|
+
}, [e, n, a]);
|
|
82
|
+
const x = (f, l) => {
|
|
83
|
+
o.update(() => {
|
|
84
|
+
Q(null);
|
|
85
|
+
const O = w(c);
|
|
86
|
+
return J(O) && O.setWidthAndHeight(f, l), !0;
|
|
87
|
+
});
|
|
88
|
+
}, A = (f) => {
|
|
89
|
+
ae(o, c);
|
|
90
|
+
};
|
|
91
|
+
return /* @__PURE__ */ i(
|
|
92
|
+
ie,
|
|
93
|
+
{
|
|
94
|
+
editor: o,
|
|
95
|
+
isIcon: !1,
|
|
96
|
+
isEmbed: !0,
|
|
97
|
+
width: B(S),
|
|
98
|
+
height: B(M),
|
|
99
|
+
onResizeEnd: x,
|
|
100
|
+
alignment: N,
|
|
101
|
+
children: /* @__PURE__ */ E(H, { className: "media-wrapper excaildraw", children: [
|
|
102
|
+
/* @__PURE__ */ E("div", { className: "media-actions", children: [
|
|
103
|
+
/* @__PURE__ */ i(W, { label: m("editor.link.edit"), children: /* @__PURE__ */ i(
|
|
104
|
+
L,
|
|
105
|
+
{
|
|
106
|
+
color: "gray",
|
|
107
|
+
"aria-label": "Settings",
|
|
108
|
+
className: "media-action",
|
|
109
|
+
variant: "default",
|
|
110
|
+
size: 24,
|
|
111
|
+
onClick: () => {
|
|
112
|
+
p(!0);
|
|
113
|
+
},
|
|
114
|
+
children: /* @__PURE__ */ i(de, { size: 14 })
|
|
115
|
+
}
|
|
116
|
+
) }),
|
|
117
|
+
/* @__PURE__ */ i(
|
|
118
|
+
se,
|
|
119
|
+
{
|
|
120
|
+
opened: C,
|
|
121
|
+
setOpened: u,
|
|
122
|
+
t: m,
|
|
123
|
+
editor: o,
|
|
124
|
+
nodeKey: c
|
|
125
|
+
}
|
|
126
|
+
),
|
|
127
|
+
/* @__PURE__ */ i(W, { label: m("editor.actions.delete"), children: /* @__PURE__ */ i(
|
|
128
|
+
L,
|
|
129
|
+
{
|
|
130
|
+
color: "gray",
|
|
131
|
+
"aria-label": "Settings",
|
|
132
|
+
className: "media-action",
|
|
133
|
+
variant: "default",
|
|
134
|
+
size: 24,
|
|
135
|
+
onClick: A,
|
|
136
|
+
children: /* @__PURE__ */ i(ne, { name: "trash", size: "14" })
|
|
137
|
+
}
|
|
138
|
+
) })
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ i(
|
|
141
|
+
H,
|
|
142
|
+
{
|
|
143
|
+
w: "100%",
|
|
144
|
+
ref: (f) => {
|
|
145
|
+
f && r && (r.current = f);
|
|
146
|
+
},
|
|
147
|
+
className: s ?? "",
|
|
148
|
+
dangerouslySetInnerHTML: { __html: (g == null ? void 0 : g.outerHTML) ?? "" }
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
] })
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function Ae({
|
|
156
|
+
nodeKey: e,
|
|
157
|
+
data: n,
|
|
158
|
+
width: r,
|
|
159
|
+
height: a,
|
|
160
|
+
alignment: o
|
|
161
|
+
}) {
|
|
162
|
+
const [s] = V(), S = X(), [M, c] = v(
|
|
163
|
+
n === "[]" && s.isEditable()
|
|
164
|
+
), [N, p] = v(!1), g = T(null), k = T(null), C = T(null), [u, m, x] = Y(e), [A, f] = v(!1), l = z(
|
|
165
|
+
(t) => (u && (t.preventDefault(), s.update(() => {
|
|
166
|
+
const d = w(e);
|
|
167
|
+
d && d.remove();
|
|
168
|
+
})), !1),
|
|
169
|
+
[s, u, e]
|
|
170
|
+
);
|
|
171
|
+
_(() => {
|
|
172
|
+
if (!S) {
|
|
173
|
+
u && x();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
return Z(
|
|
177
|
+
s.registerCommand(
|
|
178
|
+
te,
|
|
179
|
+
(t) => {
|
|
180
|
+
const d = k.current, h = t.target;
|
|
181
|
+
return A ? !0 : d !== null && d.contains(h) ? (t.shiftKey || x(), m(!u), t.detail > 1 && c(!0), !0) : !1;
|
|
182
|
+
},
|
|
183
|
+
D
|
|
184
|
+
),
|
|
185
|
+
s.registerCommand(
|
|
186
|
+
ee,
|
|
187
|
+
l,
|
|
188
|
+
D
|
|
189
|
+
),
|
|
190
|
+
s.registerCommand(
|
|
191
|
+
K,
|
|
192
|
+
l,
|
|
193
|
+
D
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
}, [
|
|
197
|
+
x,
|
|
198
|
+
s,
|
|
199
|
+
u,
|
|
200
|
+
A,
|
|
201
|
+
l,
|
|
202
|
+
m,
|
|
203
|
+
S
|
|
204
|
+
]);
|
|
205
|
+
const O = z(() => (c(!1), s.update(() => {
|
|
206
|
+
const t = w(e);
|
|
207
|
+
t && t.remove();
|
|
208
|
+
})), [s, e]), U = (t, d, h) => s.update(() => {
|
|
209
|
+
const I = w(e);
|
|
210
|
+
J(I) && (t && t.length > 0 || Object.keys(h).length > 0 ? I.setData(
|
|
211
|
+
JSON.stringify({
|
|
212
|
+
appState: d,
|
|
213
|
+
elements: t,
|
|
214
|
+
files: h
|
|
215
|
+
})
|
|
216
|
+
) : I.remove());
|
|
217
|
+
}), {
|
|
218
|
+
elements: b = [],
|
|
219
|
+
files: R = {},
|
|
220
|
+
appState: j = {}
|
|
221
|
+
} = P(() => JSON.parse(n), [n]), y = z(() => {
|
|
222
|
+
c(!1), p(!1), C.current = !1, b.length === 0 && s.update(() => {
|
|
223
|
+
const t = w(e);
|
|
224
|
+
t && t.remove();
|
|
225
|
+
});
|
|
226
|
+
}, [s, e, b.length]), q = z(() => {
|
|
227
|
+
C.current ? p(!0) : y();
|
|
228
|
+
}, []);
|
|
229
|
+
return /* @__PURE__ */ E(G, { children: [
|
|
230
|
+
/* @__PURE__ */ i(
|
|
231
|
+
me,
|
|
232
|
+
{
|
|
233
|
+
isCloseModal: N,
|
|
234
|
+
confirmClose: y,
|
|
235
|
+
setCloseModalOpen: p
|
|
236
|
+
}
|
|
237
|
+
),
|
|
238
|
+
/* @__PURE__ */ i(
|
|
239
|
+
fe,
|
|
240
|
+
{
|
|
241
|
+
initialElements: b,
|
|
242
|
+
isEdited: C,
|
|
243
|
+
initialFiles: R,
|
|
244
|
+
initialAppState: j,
|
|
245
|
+
isShown: M,
|
|
246
|
+
onDelete: O,
|
|
247
|
+
onClose: q,
|
|
248
|
+
onSave: (t, d, h) => {
|
|
249
|
+
U(t, d, h), c(!1);
|
|
250
|
+
},
|
|
251
|
+
closeOnClickOutside: !1
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
b.length > 0 && /* @__PURE__ */ i(
|
|
255
|
+
"div",
|
|
256
|
+
{
|
|
257
|
+
style: {
|
|
258
|
+
display: "flex",
|
|
259
|
+
justifyContent: o
|
|
260
|
+
},
|
|
261
|
+
children: /* @__PURE__ */ i(
|
|
262
|
+
pe,
|
|
263
|
+
{
|
|
264
|
+
imageContainerRef: g,
|
|
265
|
+
className: "image",
|
|
266
|
+
elements: b,
|
|
267
|
+
files: R,
|
|
268
|
+
appState: j,
|
|
269
|
+
width: r,
|
|
270
|
+
height: a,
|
|
271
|
+
editor: s,
|
|
272
|
+
nodeKey: e,
|
|
273
|
+
alignment: o,
|
|
274
|
+
setModalOpen: c
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
)
|
|
279
|
+
] });
|
|
280
|
+
}
|
|
281
|
+
export {
|
|
282
|
+
Ae as default
|
|
283
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),l=require("react"),e=require("./lexical-2rxs76dr.cjs"),h=require("./index-CFA9Drk2.cjs"),T=require("@mantine/core");function D({children:n,className:o}){return t.jsx("div",{className:o||"Placeholder__root",children:n})}function y({label:n,value:o,onChange:a,placeholder:x="","data-test-id":i,type:d="text"}){return t.jsx(T.TextInput,{type:d,placeholder:x,value:o,onChange:c=>{a(c.target.value)},label:n,"data-test-id":i,mb:10})}const R=new Set;function F(n){if(!R.has(n))throw new Promise(o=>{const a=new Image;a.src=n,a.onload=()=>{R.add(n),o(null)}})}function q({altText:n,className:o,imageRef:a,src:x,width:i,height:d,position:c}){return F(x),t.jsx("img",{className:o||void 0,src:x,alt:n,ref:a,"data-position":c,style:{display:"block",height:d,width:i},draggable:"false"})}function _({activeEditor:n,nodeKey:o,onClose:a}){const i=n.getEditorState().read(()=>e.xo(o)),[d,c]=l.useState(i.getAltText()),[j,I]=l.useState(i.getShowCaption()),[S,b]=l.useState(i.getPosition()),p=g=>{I(g.target.checked)},m=()=>{const g={altText:d,position:S,showCaption:j};i&&n.update(()=>{i.update(g)}),a()};return t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{marginBottom:"1em"},children:t.jsx(y,{label:"Alt-текст",placeholder:"Альтернативный текст",onChange:c,value:d,"data-test-id":"image-modal-alt-text-input"})}),t.jsxs("div",{className:"Input__wrapper",children:[t.jsx("input",{id:"caption",type:"checkbox",checked:j,onChange:p}),t.jsx("label",{htmlFor:"caption",children:"Show Caption"})]}),t.jsx(h.Button,{"data-test-id":"image-modal-file-upload-btn",onClick:()=>m(),children:"Применить"})]})}function U({src:n,altText:o,nodeKey:a,width:x,height:i,showCaption:d,caption:c,position:j}){const[I,S]=h.useModal(),b=l.useRef(null),p=l.useRef(null),[m,g,E]=e.u(a),[s]=e.o(),[z,L]=l.useState(null),N=l.useRef(null),v=l.useCallback(u=>{if(m&&e.xr(e.Lr())){u.preventDefault();const r=e.xo(a);h.$isInlineImageNode(r)&&r.remove()}return!1},[m,a]),w=l.useCallback(u=>{const f=e.Lr(),r=p.current;if(m&&e.xr(f)&&f.getNodes().length===1){if(d)return e.wo(null),u.preventDefault(),c.focus(),!0;if(r!==null&&r!==document.activeElement)return u.preventDefault(),r.focus(),!0}return!1},[c,m,d]),k=l.useCallback(u=>N.current===c||p.current===u.target?(e.wo(null),s.update(()=>{g(!0);const f=s.getRootElement();f!==null&&f.focus()}),!0):!1,[c,s,g]);l.useEffect(()=>{let u=!0;const f=e.U(s.registerUpdateListener(({editorState:r})=>{u&&L(r.read(()=>e.Lr()))}),s.registerCommand(e.ie,(r,C)=>(N.current=C,!1),e.zi),s.registerCommand(e.se,r=>{const C=r;return C.target===b.current?(C.shiftKey?g(!m):(E(),g(!0)),!0):!1},e.zi),s.registerCommand(e.Ie,r=>r.target===b.current?(r.preventDefault(),!0):!1,e.zi),s.registerCommand(e.Oe,v,e.zi),s.registerCommand(e.we,v,e.zi),s.registerCommand(e.Ne,w,e.zi),s.registerCommand(e.Ee$1,k,e.zi));return()=>{u=!1,f()}},[E,s,m,a,v,w,k,g]);const P=m;return t.jsxs(l.Suspense,{fallback:null,children:[t.jsxs(t.Fragment,{children:[t.jsxs("div",{draggable:!1,children:[t.jsx("button",{className:"image-edit-button",ref:p,onClick:()=>{S("Update Inline Image",u=>t.jsx(_,{activeEditor:s,nodeKey:a,onClose:u}))},children:"Edit"}),t.jsx(q,{className:P?`focused ${e.xr(z)?"draggable":""}`:null,src:n,altText:o,imageRef:b,width:x,height:i,position:j})]}),d&&t.jsx("div",{className:"image-caption-container",children:t.jsxs(e.m$3,{initialEditor:c,children:[t.jsx(h.LinkPlugin,{}),t.jsx(h.FloatingTextFormatToolbarPlugin,{}),t.jsx(e.L,{contentEditable:t.jsx(h.LexicalContentEditable,{className:"InlineImageNode__contentEditable"}),placeholder:t.jsx(D,{className:"InlineImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:e.n$1})]})})]}),I]})}exports.UpdateInlineImageDialog=_;exports.default=U;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { jsx as e, jsxs as p, Fragment as y } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as N, useState as v, useCallback as w, useEffect as j, Suspense as z } from "react";
|
|
3
|
+
import { aK as A, a1 as $, aL as k, g as _, x as B, av as P, U as O, c3 as J, z as f, cS as Y, aM as Z, aN as q, cY as G, aD as H, b9 as Q, cZ as V, cJ as W, cK as X } from "./lexical-C60GkwxR.js";
|
|
4
|
+
import { i as K, j as ee, L as te, F as ne, k as ae, B as oe } from "./index-WCOc4LNL.js";
|
|
5
|
+
import { TextInput as re } from "@mantine/core";
|
|
6
|
+
function le({
|
|
7
|
+
children: t,
|
|
8
|
+
className: r
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ e("div", { className: r || "Placeholder__root", children: t });
|
|
11
|
+
}
|
|
12
|
+
function se({
|
|
13
|
+
label: t,
|
|
14
|
+
value: r,
|
|
15
|
+
onChange: n,
|
|
16
|
+
placeholder: g = "",
|
|
17
|
+
"data-test-id": l,
|
|
18
|
+
type: c = "text"
|
|
19
|
+
}) {
|
|
20
|
+
return /* @__PURE__ */ e(
|
|
21
|
+
re,
|
|
22
|
+
{
|
|
23
|
+
type: c,
|
|
24
|
+
placeholder: g,
|
|
25
|
+
value: r,
|
|
26
|
+
onChange: (s) => {
|
|
27
|
+
n(s.target.value);
|
|
28
|
+
},
|
|
29
|
+
label: t,
|
|
30
|
+
"data-test-id": l,
|
|
31
|
+
mb: 10
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const R = /* @__PURE__ */ new Set();
|
|
36
|
+
function ie(t) {
|
|
37
|
+
if (!R.has(t))
|
|
38
|
+
throw new Promise((r) => {
|
|
39
|
+
const n = new Image();
|
|
40
|
+
n.src = t, n.onload = () => {
|
|
41
|
+
R.add(t), r(null);
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function ce({
|
|
46
|
+
altText: t,
|
|
47
|
+
className: r,
|
|
48
|
+
imageRef: n,
|
|
49
|
+
src: g,
|
|
50
|
+
width: l,
|
|
51
|
+
height: c,
|
|
52
|
+
position: s
|
|
53
|
+
}) {
|
|
54
|
+
return ie(g), /* @__PURE__ */ e(
|
|
55
|
+
"img",
|
|
56
|
+
{
|
|
57
|
+
className: r || void 0,
|
|
58
|
+
src: g,
|
|
59
|
+
alt: t,
|
|
60
|
+
ref: n,
|
|
61
|
+
"data-position": s,
|
|
62
|
+
style: {
|
|
63
|
+
display: "block",
|
|
64
|
+
height: c,
|
|
65
|
+
width: l
|
|
66
|
+
},
|
|
67
|
+
draggable: "false"
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
function ue({
|
|
72
|
+
activeEditor: t,
|
|
73
|
+
nodeKey: r,
|
|
74
|
+
onClose: n
|
|
75
|
+
}) {
|
|
76
|
+
const l = t.getEditorState().read(
|
|
77
|
+
() => B(r)
|
|
78
|
+
), [c, s] = v(l.getAltText()), [C, x] = v(l.getShowCaption()), [E, b] = v(l.getPosition()), h = (d) => {
|
|
79
|
+
x(d.target.checked);
|
|
80
|
+
}, u = () => {
|
|
81
|
+
const d = { altText: c, position: E, showCaption: C };
|
|
82
|
+
l && t.update(() => {
|
|
83
|
+
l.update(d);
|
|
84
|
+
}), n();
|
|
85
|
+
};
|
|
86
|
+
return /* @__PURE__ */ p(y, { children: [
|
|
87
|
+
/* @__PURE__ */ e("div", { style: { marginBottom: "1em" }, children: /* @__PURE__ */ e(
|
|
88
|
+
se,
|
|
89
|
+
{
|
|
90
|
+
label: "Alt-текст",
|
|
91
|
+
placeholder: "Альтернативный текст",
|
|
92
|
+
onChange: s,
|
|
93
|
+
value: c,
|
|
94
|
+
"data-test-id": "image-modal-alt-text-input"
|
|
95
|
+
}
|
|
96
|
+
) }),
|
|
97
|
+
/* @__PURE__ */ p("div", { className: "Input__wrapper", children: [
|
|
98
|
+
/* @__PURE__ */ e(
|
|
99
|
+
"input",
|
|
100
|
+
{
|
|
101
|
+
id: "caption",
|
|
102
|
+
type: "checkbox",
|
|
103
|
+
checked: C,
|
|
104
|
+
onChange: h
|
|
105
|
+
}
|
|
106
|
+
),
|
|
107
|
+
/* @__PURE__ */ e("label", { htmlFor: "caption", children: "Show Caption" })
|
|
108
|
+
] }),
|
|
109
|
+
/* @__PURE__ */ e(
|
|
110
|
+
oe,
|
|
111
|
+
{
|
|
112
|
+
"data-test-id": "image-modal-file-upload-btn",
|
|
113
|
+
onClick: () => u(),
|
|
114
|
+
children: "Применить"
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] });
|
|
118
|
+
}
|
|
119
|
+
function Ce({
|
|
120
|
+
src: t,
|
|
121
|
+
altText: r,
|
|
122
|
+
nodeKey: n,
|
|
123
|
+
width: g,
|
|
124
|
+
height: l,
|
|
125
|
+
showCaption: c,
|
|
126
|
+
caption: s,
|
|
127
|
+
position: C
|
|
128
|
+
}) {
|
|
129
|
+
const [x, E] = K(), b = N(null), h = N(null), [u, d, L] = A(n), [o] = $(), [M, U] = v(null), T = N(null), S = w(
|
|
130
|
+
(i) => {
|
|
131
|
+
if (u && k(_())) {
|
|
132
|
+
i.preventDefault();
|
|
133
|
+
const a = B(n);
|
|
134
|
+
ee(a) && a.remove();
|
|
135
|
+
}
|
|
136
|
+
return !1;
|
|
137
|
+
},
|
|
138
|
+
[u, n]
|
|
139
|
+
), D = w(
|
|
140
|
+
(i) => {
|
|
141
|
+
const m = _(), a = h.current;
|
|
142
|
+
if (u && k(m) && m.getNodes().length === 1) {
|
|
143
|
+
if (c)
|
|
144
|
+
return P(null), i.preventDefault(), s.focus(), !0;
|
|
145
|
+
if (a !== null && a !== document.activeElement)
|
|
146
|
+
return i.preventDefault(), a.focus(), !0;
|
|
147
|
+
}
|
|
148
|
+
return !1;
|
|
149
|
+
},
|
|
150
|
+
[s, u, c]
|
|
151
|
+
), F = w(
|
|
152
|
+
(i) => T.current === s || h.current === i.target ? (P(null), o.update(() => {
|
|
153
|
+
d(!0);
|
|
154
|
+
const m = o.getRootElement();
|
|
155
|
+
m !== null && m.focus();
|
|
156
|
+
}), !0) : !1,
|
|
157
|
+
[s, o, d]
|
|
158
|
+
);
|
|
159
|
+
return j(() => {
|
|
160
|
+
let i = !0;
|
|
161
|
+
const m = O(
|
|
162
|
+
o.registerUpdateListener(({ editorState: a }) => {
|
|
163
|
+
i && U(a.read(() => _()));
|
|
164
|
+
}),
|
|
165
|
+
o.registerCommand(
|
|
166
|
+
Q,
|
|
167
|
+
(a, I) => (T.current = I, !1),
|
|
168
|
+
f
|
|
169
|
+
),
|
|
170
|
+
o.registerCommand(
|
|
171
|
+
H,
|
|
172
|
+
(a) => {
|
|
173
|
+
const I = a;
|
|
174
|
+
return I.target === b.current ? (I.shiftKey ? d(!u) : (L(), d(!0)), !0) : !1;
|
|
175
|
+
},
|
|
176
|
+
f
|
|
177
|
+
),
|
|
178
|
+
o.registerCommand(
|
|
179
|
+
G,
|
|
180
|
+
(a) => a.target === b.current ? (a.preventDefault(), !0) : !1,
|
|
181
|
+
f
|
|
182
|
+
),
|
|
183
|
+
o.registerCommand(
|
|
184
|
+
q,
|
|
185
|
+
S,
|
|
186
|
+
f
|
|
187
|
+
),
|
|
188
|
+
o.registerCommand(
|
|
189
|
+
Z,
|
|
190
|
+
S,
|
|
191
|
+
f
|
|
192
|
+
),
|
|
193
|
+
o.registerCommand(Y, D, f),
|
|
194
|
+
o.registerCommand(
|
|
195
|
+
J,
|
|
196
|
+
F,
|
|
197
|
+
f
|
|
198
|
+
)
|
|
199
|
+
);
|
|
200
|
+
return () => {
|
|
201
|
+
i = !1, m();
|
|
202
|
+
};
|
|
203
|
+
}, [
|
|
204
|
+
L,
|
|
205
|
+
o,
|
|
206
|
+
u,
|
|
207
|
+
n,
|
|
208
|
+
S,
|
|
209
|
+
D,
|
|
210
|
+
F,
|
|
211
|
+
d
|
|
212
|
+
]), /* @__PURE__ */ p(z, { fallback: null, children: [
|
|
213
|
+
/* @__PURE__ */ p(y, { children: [
|
|
214
|
+
/* @__PURE__ */ p("div", { draggable: !1, children: [
|
|
215
|
+
/* @__PURE__ */ e(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
className: "image-edit-button",
|
|
219
|
+
ref: h,
|
|
220
|
+
onClick: () => {
|
|
221
|
+
E("Update Inline Image", (i) => /* @__PURE__ */ e(
|
|
222
|
+
ue,
|
|
223
|
+
{
|
|
224
|
+
activeEditor: o,
|
|
225
|
+
nodeKey: n,
|
|
226
|
+
onClose: i
|
|
227
|
+
}
|
|
228
|
+
));
|
|
229
|
+
},
|
|
230
|
+
children: "Edit"
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ e(
|
|
234
|
+
ce,
|
|
235
|
+
{
|
|
236
|
+
className: u ? `focused ${k(M) ? "draggable" : ""}` : null,
|
|
237
|
+
src: t,
|
|
238
|
+
altText: r,
|
|
239
|
+
imageRef: b,
|
|
240
|
+
width: g,
|
|
241
|
+
height: l,
|
|
242
|
+
position: C
|
|
243
|
+
}
|
|
244
|
+
)
|
|
245
|
+
] }),
|
|
246
|
+
c && /* @__PURE__ */ e("div", { className: "image-caption-container", children: /* @__PURE__ */ p(V, { initialEditor: s, children: [
|
|
247
|
+
/* @__PURE__ */ e(te, {}),
|
|
248
|
+
/* @__PURE__ */ e(ne, {}),
|
|
249
|
+
/* @__PURE__ */ e(
|
|
250
|
+
W,
|
|
251
|
+
{
|
|
252
|
+
contentEditable: /* @__PURE__ */ e(ae, { className: "InlineImageNode__contentEditable" }),
|
|
253
|
+
placeholder: /* @__PURE__ */ e(le, { className: "InlineImageNode__placeholder", children: "Enter a caption..." }),
|
|
254
|
+
ErrorBoundary: X
|
|
255
|
+
}
|
|
256
|
+
)
|
|
257
|
+
] }) })
|
|
258
|
+
] }),
|
|
259
|
+
x
|
|
260
|
+
] });
|
|
261
|
+
}
|
|
262
|
+
export {
|
|
263
|
+
ue as UpdateInlineImageDialog,
|
|
264
|
+
Ce as default
|
|
265
|
+
};
|