sykpcomposer 0.0.103 → 0.0.105

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.
Files changed (37) hide show
  1. package/dist/ImageComponent-e1234939.js +402 -0
  2. package/dist/ImageComponent-e1234939.js.map +1 -0
  3. package/dist/InlineImageComponent-bfeb4b99.js +249 -0
  4. package/dist/InlineImageComponent-bfeb4b99.js.map +1 -0
  5. package/dist/Placeholder-7d1203f2.js +97 -0
  6. package/dist/Placeholder-7d1203f2.js.map +1 -0
  7. package/dist/favicon.ico +0 -0
  8. package/dist/index-476bdf57.js +49728 -0
  9. package/dist/index-476bdf57.js.map +1 -0
  10. package/dist/index.es.js +4 -48730
  11. package/dist/index.es.js.map +1 -1
  12. package/dist/index.html +43 -0
  13. package/dist/index.umd.js +178 -178
  14. package/dist/index.umd.js.map +1 -1
  15. package/dist/logo192.png +0 -0
  16. package/dist/logo512.png +0 -0
  17. package/dist/manifest.json +25 -0
  18. package/dist/robots.txt +3 -0
  19. package/dist/src/components/hooks/useModal.d.ts +12 -0
  20. package/dist/src/components/nodes/ImageComponent.d.ts +22 -0
  21. package/dist/src/components/nodes/ImageNode.d.ts +49 -0
  22. package/dist/src/components/nodes/InlineImageComponent.d.ts +18 -0
  23. package/dist/src/components/nodes/InlineImageNode.d.ts +65 -0
  24. package/dist/src/components/plugins/ImagePlugin.d.ts +24 -0
  25. package/dist/src/components/plugins/InlineImagePlugin.d.ts +16 -0
  26. package/dist/src/components/ui/Button.d.ts +17 -0
  27. package/dist/src/components/ui/ContentEditable.d.ts +12 -0
  28. package/dist/src/components/ui/Dialog.d.ts +15 -0
  29. package/dist/src/components/ui/FileInput.d.ts +16 -0
  30. package/dist/src/components/ui/ImageResizer.d.ts +24 -0
  31. package/dist/src/components/ui/Modal.d.ts +14 -0
  32. package/dist/src/components/ui/Placeholder.d.ts +12 -0
  33. package/dist/src/components/ui/Select.d.ts +14 -0
  34. package/dist/src/components/ui/TextInput.d.ts +19 -0
  35. package/dist/src/utils/joinClasses.d.ts +8 -0
  36. package/dist/style.css +1 -1
  37. package/package.json +1 -2
@@ -0,0 +1,402 @@
1
+ import { j as i, u as J, d as M, w as Y, x as A, $ as B, a as T, b as Q, c as Z, e as K, C as b, f as ee, k as te, g as ne, I as re, r as se, h as ie, i as oe, l as ae, t as ce } from "./index-476bdf57.js";
2
+ import { u as le, d as ue, L as de, P as me } from "./Placeholder-7d1203f2.js";
3
+ import { useRef as S, useState as U, useCallback as k, useEffect as ge, Suspense as he } from "react";
4
+ import "react-dom";
5
+ function G(f, w, d) {
6
+ return Math.min(Math.max(f, w), d);
7
+ }
8
+ const n = {
9
+ east: 1,
10
+ north: 8,
11
+ south: 2,
12
+ west: 4
13
+ };
14
+ function fe({
15
+ onResizeStart: f,
16
+ onResizeEnd: w,
17
+ buttonRef: d,
18
+ imageRef: v,
19
+ maxWidth: j,
20
+ editor: C,
21
+ showCaption: P,
22
+ setShowCaption: N,
23
+ captionsEnabled: E
24
+ }) {
25
+ const H = S(null), x = S({
26
+ priority: "",
27
+ value: "default"
28
+ }), R = S({
29
+ currentHeight: 0,
30
+ currentWidth: 0,
31
+ direction: 0,
32
+ isResizing: !1,
33
+ ratio: 0,
34
+ startHeight: 0,
35
+ startWidth: 0,
36
+ startX: 0,
37
+ startY: 0
38
+ }), u = C.getRootElement(), y = j || (u !== null ? u.getBoundingClientRect().width - 20 : 100), I = u !== null ? u.getBoundingClientRect().height - 20 : 100, z = 100, X = 100, s = (e) => {
39
+ const r = e === n.east || e === n.west, t = e === n.north || e === n.south, g = e & n.north && e & n.west || e & n.south && e & n.east, m = r ? "ew" : t ? "ns" : g ? "nwse" : "nesw";
40
+ u !== null && u.style.setProperty(
41
+ "cursor",
42
+ `${m}-resize`,
43
+ "important"
44
+ ), document.body !== null && (document.body.style.setProperty(
45
+ "cursor",
46
+ `${m}-resize`,
47
+ "important"
48
+ ), x.current.value = document.body.style.getPropertyValue(
49
+ "-webkit-user-select"
50
+ ), x.current.priority = document.body.style.getPropertyPriority(
51
+ "-webkit-user-select"
52
+ ), document.body.style.setProperty(
53
+ "-webkit-user-select",
54
+ "none",
55
+ "important"
56
+ ));
57
+ }, W = () => {
58
+ u !== null && u.style.setProperty("cursor", "text"), document.body !== null && (document.body.style.setProperty("cursor", "default"), document.body.style.setProperty(
59
+ "-webkit-user-select",
60
+ x.current.value,
61
+ x.current.priority
62
+ ));
63
+ }, p = (e, r) => {
64
+ if (!C.isEditable())
65
+ return;
66
+ const t = v.current, g = H.current;
67
+ if (t !== null && g !== null) {
68
+ e.preventDefault();
69
+ const { width: m, height: o } = t.getBoundingClientRect(), a = R.current;
70
+ a.startWidth = m, a.startHeight = o, a.ratio = m / o, a.currentWidth = m, a.currentHeight = o, a.startX = e.clientX, a.startY = e.clientY, a.isResizing = !0, a.direction = r, s(r), f(), g.classList.add("image-control-wrapper--resizing"), t.style.height = `${o}px`, t.style.width = `${m}px`, document.addEventListener("pointermove", L), document.addEventListener("pointerup", D);
71
+ }
72
+ }, L = (e) => {
73
+ const r = v.current, t = R.current, g = t.direction & (n.east | n.west), m = t.direction & (n.south | n.north);
74
+ if (r !== null && t.isResizing)
75
+ if (g && m) {
76
+ let o = Math.floor(t.startX - e.clientX);
77
+ o = t.direction & n.east ? -o : o;
78
+ const a = G(
79
+ t.startWidth + o,
80
+ z,
81
+ y
82
+ ), _ = a / t.ratio;
83
+ r.style.width = `${a}px`, r.style.height = `${_}px`, t.currentHeight = _, t.currentWidth = a;
84
+ } else if (m) {
85
+ let o = Math.floor(t.startY - e.clientY);
86
+ o = t.direction & n.south ? -o : o;
87
+ const a = G(
88
+ t.startHeight + o,
89
+ X,
90
+ I
91
+ );
92
+ r.style.height = `${a}px`, t.currentHeight = a;
93
+ } else {
94
+ let o = Math.floor(t.startX - e.clientX);
95
+ o = t.direction & n.east ? -o : o;
96
+ const a = G(
97
+ t.startWidth + o,
98
+ z,
99
+ y
100
+ );
101
+ r.style.width = `${a}px`, t.currentWidth = a;
102
+ }
103
+ }, D = () => {
104
+ const e = v.current, r = R.current, t = H.current;
105
+ if (e !== null && t !== null && r.isResizing) {
106
+ const g = r.currentWidth, m = r.currentHeight;
107
+ r.startWidth = 0, r.startHeight = 0, r.ratio = 0, r.startX = 0, r.startY = 0, r.currentWidth = 0, r.currentHeight = 0, r.isResizing = !1, t.classList.remove("image-control-wrapper--resizing"), W(), w(g, m), document.removeEventListener("pointermove", L), document.removeEventListener("pointerup", D);
108
+ }
109
+ };
110
+ return /* @__PURE__ */ i.jsxs("div", { ref: H, children: [
111
+ !P && E && /* @__PURE__ */ i.jsx(
112
+ "button",
113
+ {
114
+ className: "image-caption-button",
115
+ ref: d,
116
+ onClick: () => {
117
+ N(!P);
118
+ },
119
+ children: "Add Caption"
120
+ }
121
+ ),
122
+ /* @__PURE__ */ i.jsx(
123
+ "div",
124
+ {
125
+ className: "image-resizer image-resizer-n",
126
+ onPointerDown: (e) => {
127
+ p(e, n.north);
128
+ }
129
+ }
130
+ ),
131
+ /* @__PURE__ */ i.jsx(
132
+ "div",
133
+ {
134
+ className: "image-resizer image-resizer-ne",
135
+ onPointerDown: (e) => {
136
+ p(e, n.north | n.east);
137
+ }
138
+ }
139
+ ),
140
+ /* @__PURE__ */ i.jsx(
141
+ "div",
142
+ {
143
+ className: "image-resizer image-resizer-e",
144
+ onPointerDown: (e) => {
145
+ p(e, n.east);
146
+ }
147
+ }
148
+ ),
149
+ /* @__PURE__ */ i.jsx(
150
+ "div",
151
+ {
152
+ className: "image-resizer image-resizer-se",
153
+ onPointerDown: (e) => {
154
+ p(e, n.south | n.east);
155
+ }
156
+ }
157
+ ),
158
+ /* @__PURE__ */ i.jsx(
159
+ "div",
160
+ {
161
+ className: "image-resizer image-resizer-s",
162
+ onPointerDown: (e) => {
163
+ p(e, n.south);
164
+ }
165
+ }
166
+ ),
167
+ /* @__PURE__ */ i.jsx(
168
+ "div",
169
+ {
170
+ className: "image-resizer image-resizer-sw",
171
+ onPointerDown: (e) => {
172
+ p(e, n.south | n.west);
173
+ }
174
+ }
175
+ ),
176
+ /* @__PURE__ */ i.jsx(
177
+ "div",
178
+ {
179
+ className: "image-resizer image-resizer-w",
180
+ onPointerDown: (e) => {
181
+ p(e, n.west);
182
+ }
183
+ }
184
+ ),
185
+ /* @__PURE__ */ i.jsx(
186
+ "div",
187
+ {
188
+ className: "image-resizer image-resizer-nw",
189
+ onPointerDown: (e) => {
190
+ p(e, n.north | n.west);
191
+ }
192
+ }
193
+ )
194
+ ] });
195
+ }
196
+ const V = /* @__PURE__ */ new Set(), O = ce();
197
+ function pe(f) {
198
+ if (!V.has(f))
199
+ throw new Promise((w) => {
200
+ const d = new Image();
201
+ d.src = f, d.onload = () => {
202
+ V.add(f), w(null);
203
+ };
204
+ });
205
+ }
206
+ function we({
207
+ altText: f,
208
+ className: w,
209
+ imageRef: d,
210
+ src: v,
211
+ width: j,
212
+ height: C,
213
+ maxWidth: P
214
+ }) {
215
+ return pe(v), /* @__PURE__ */ i.jsx(
216
+ "img",
217
+ {
218
+ className: w || void 0,
219
+ src: v,
220
+ alt: f,
221
+ ref: d,
222
+ style: {
223
+ height: C,
224
+ maxWidth: P,
225
+ width: j
226
+ },
227
+ draggable: "false"
228
+ }
229
+ );
230
+ }
231
+ function be({
232
+ src: f,
233
+ altText: w,
234
+ nodeKey: d,
235
+ width: v,
236
+ height: j,
237
+ maxWidth: C,
238
+ resizable: P,
239
+ showCaption: N,
240
+ caption: E,
241
+ captionsEnabled: H
242
+ }) {
243
+ const x = S(null), R = S(null), [u, y, I] = le(d), [z, X] = U(!1), [s] = J(), [W, p] = U(null), L = S(null), D = k(
244
+ (l) => {
245
+ if (u && M(Y())) {
246
+ l.preventDefault();
247
+ const h = A(d);
248
+ if (B(h))
249
+ return h.remove(), !0;
250
+ }
251
+ return !1;
252
+ },
253
+ [u, d]
254
+ ), e = k(
255
+ (l) => {
256
+ const c = Y(), h = R.current;
257
+ if (u && M(c) && c.getNodes().length === 1) {
258
+ if (N)
259
+ return T(null), l.preventDefault(), E.focus(), !0;
260
+ if (h !== null && h !== document.activeElement)
261
+ return l.preventDefault(), h.focus(), !0;
262
+ }
263
+ return !1;
264
+ },
265
+ [E, u, N]
266
+ ), r = k(
267
+ (l) => L.current === E || R.current === l.target ? (T(null), s.update(() => {
268
+ y(!0);
269
+ const c = s.getRootElement();
270
+ c !== null && c.focus();
271
+ }), !0) : !1,
272
+ [E, s, y]
273
+ ), t = k(
274
+ (l) => {
275
+ const c = l;
276
+ return z ? !0 : c.target === x.current ? (c.shiftKey ? y(!u) : (I(), y(!0)), !0) : !1;
277
+ },
278
+ [z, u, y, I]
279
+ ), g = k(
280
+ (l) => {
281
+ s.getEditorState().read(() => {
282
+ const c = Y();
283
+ l.target.tagName === "IMG" && Q(c) && c.getNodes().length === 1 && s.dispatchCommand(
284
+ O,
285
+ l
286
+ );
287
+ });
288
+ },
289
+ [s]
290
+ );
291
+ ge(() => {
292
+ let l = !0;
293
+ const c = s.getRootElement(), h = Z(
294
+ s.registerUpdateListener(({ editorState: $ }) => {
295
+ l && p($.read(() => Y()));
296
+ }),
297
+ s.registerCommand(
298
+ ie,
299
+ ($, q) => (L.current = q, !1),
300
+ b
301
+ ),
302
+ s.registerCommand(
303
+ se,
304
+ t,
305
+ b
306
+ ),
307
+ s.registerCommand(
308
+ O,
309
+ t,
310
+ b
311
+ ),
312
+ s.registerCommand(
313
+ re,
314
+ ($) => $.target === x.current ? ($.preventDefault(), !0) : !1,
315
+ b
316
+ ),
317
+ s.registerCommand(
318
+ ne,
319
+ D,
320
+ b
321
+ ),
322
+ s.registerCommand(
323
+ te,
324
+ D,
325
+ b
326
+ ),
327
+ s.registerCommand(ee, e, b),
328
+ s.registerCommand(K, r, b)
329
+ );
330
+ return c == null || c.addEventListener("contextmenu", g), () => {
331
+ l = !1, h(), c == null || c.removeEventListener("contextmenu", g);
332
+ };
333
+ }, [
334
+ I,
335
+ s,
336
+ z,
337
+ u,
338
+ d,
339
+ D,
340
+ e,
341
+ r,
342
+ t,
343
+ g,
344
+ y
345
+ ]);
346
+ const m = () => {
347
+ s.update(() => {
348
+ const l = A(d);
349
+ B(l) && l.setShowCaption(!0);
350
+ });
351
+ }, o = (l, c) => {
352
+ setTimeout(() => {
353
+ X(!1);
354
+ }, 200), s.update(() => {
355
+ const h = A(d);
356
+ B(h) && h.setWidthAndHeight(l, c);
357
+ });
358
+ }, a = () => {
359
+ X(!0);
360
+ }, _ = u && M(W) && !z, F = u || z;
361
+ return /* @__PURE__ */ i.jsx(he, { fallback: null, children: /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
362
+ /* @__PURE__ */ i.jsx("div", { draggable: _, children: /* @__PURE__ */ i.jsx(
363
+ we,
364
+ {
365
+ className: F ? `focused ${M(W) ? "draggable" : ""}` : null,
366
+ src: f,
367
+ altText: w,
368
+ imageRef: x,
369
+ width: v,
370
+ height: j,
371
+ maxWidth: C
372
+ }
373
+ ) }),
374
+ N && /* @__PURE__ */ i.jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ i.jsx(ue, { initialEditor: E, children: /* @__PURE__ */ i.jsx(
375
+ oe,
376
+ {
377
+ contentEditable: /* @__PURE__ */ i.jsx(de, { className: "ImageNode__contentEditable" }),
378
+ placeholder: /* @__PURE__ */ i.jsx(me, { className: "ImageNode__placeholder", children: "Enter a caption..." }),
379
+ ErrorBoundary: ae
380
+ }
381
+ ) }) }),
382
+ P && M(W) && F && /* @__PURE__ */ i.jsx(
383
+ fe,
384
+ {
385
+ showCaption: N,
386
+ setShowCaption: m,
387
+ editor: s,
388
+ buttonRef: R,
389
+ imageRef: x,
390
+ maxWidth: C,
391
+ onResizeStart: a,
392
+ onResizeEnd: o,
393
+ captionsEnabled: H
394
+ }
395
+ )
396
+ ] }) });
397
+ }
398
+ export {
399
+ O as RIGHT_CLICK_IMAGE_COMMAND,
400
+ be as default
401
+ };
402
+ //# sourceMappingURL=ImageComponent-e1234939.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImageComponent-e1234939.js","sources":["../src/components/ui/ImageResizer.tsx","../src/components/nodes/ImageComponent.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type {LexicalEditor} from 'lexical';\n\nimport * as React from 'react';\nimport {useRef} from 'react';\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nconst Direction = {\n east: 1 << 0,\n north: 1 << 3,\n south: 1 << 1,\n west: 1 << 2,\n};\n\nexport default function ImageResizer({\n onResizeStart,\n onResizeEnd,\n buttonRef,\n imageRef,\n maxWidth,\n editor,\n showCaption,\n setShowCaption,\n captionsEnabled,\n}: {\n editor: LexicalEditor;\n buttonRef: {current: null | HTMLButtonElement};\n imageRef: {current: null | HTMLElement};\n maxWidth?: number;\n onResizeEnd: (width: 'inherit' | number, height: 'inherit' | number) => void;\n onResizeStart: () => void;\n setShowCaption: (show: boolean) => void;\n showCaption: boolean;\n captionsEnabled: boolean;\n}): JSX.Element {\n const controlWrapperRef = useRef<HTMLDivElement>(null);\n const userSelect = useRef({\n priority: '',\n value: 'default',\n });\n const positioningRef = useRef<{\n currentHeight: 'inherit' | number;\n currentWidth: 'inherit' | number;\n direction: number;\n isResizing: boolean;\n ratio: number;\n startHeight: number;\n startWidth: number;\n startX: number;\n startY: number;\n }>({\n currentHeight: 0,\n currentWidth: 0,\n direction: 0,\n isResizing: false,\n ratio: 0,\n startHeight: 0,\n startWidth: 0,\n startX: 0,\n startY: 0,\n });\n const editorRootElement = editor.getRootElement();\n // Find max width, accounting for editor padding.\n const maxWidthContainer = maxWidth\n ? maxWidth\n : editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().width - 20\n : 100;\n const maxHeightContainer =\n editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().height - 20\n : 100;\n\n const minWidth = 100;\n const minHeight = 100;\n\n const setStartCursor = (direction: number) => {\n const ew = direction === Direction.east || direction === Direction.west;\n const ns = direction === Direction.north || direction === Direction.south;\n const nwse =\n (direction & Direction.north && direction & Direction.west) ||\n (direction & Direction.south && direction & Direction.east);\n\n const cursorDir = ew ? 'ew' : ns ? 'ns' : nwse ? 'nwse' : 'nesw';\n\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\n 'cursor',\n `${cursorDir}-resize`,\n 'important',\n );\n }\n if (document.body !== null) {\n document.body.style.setProperty(\n 'cursor',\n `${cursorDir}-resize`,\n 'important',\n );\n userSelect.current.value = document.body.style.getPropertyValue(\n '-webkit-user-select',\n );\n userSelect.current.priority = document.body.style.getPropertyPriority(\n '-webkit-user-select',\n );\n document.body.style.setProperty(\n '-webkit-user-select',\n `none`,\n 'important',\n );\n }\n };\n\n const setEndCursor = () => {\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty('cursor', 'text');\n }\n if (document.body !== null) {\n document.body.style.setProperty('cursor', 'default');\n document.body.style.setProperty(\n '-webkit-user-select',\n userSelect.current.value,\n userSelect.current.priority,\n );\n }\n };\n\n const handlePointerDown = (\n event: React.PointerEvent<HTMLDivElement>,\n direction: number,\n ) => {\n if (!editor.isEditable()) {\n return;\n }\n\n const image = imageRef.current;\n const controlWrapper = controlWrapperRef.current;\n\n if (image !== null && controlWrapper !== null) {\n event.preventDefault();\n const {width, height} = image.getBoundingClientRect();\n const positioning = positioningRef.current;\n positioning.startWidth = width;\n positioning.startHeight = height;\n positioning.ratio = width / height;\n positioning.currentWidth = width;\n positioning.currentHeight = height;\n positioning.startX = event.clientX;\n positioning.startY = event.clientY;\n positioning.isResizing = true;\n positioning.direction = direction;\n\n setStartCursor(direction);\n onResizeStart();\n\n controlWrapper.classList.add('image-control-wrapper--resizing');\n image.style.height = `${height}px`;\n image.style.width = `${width}px`;\n\n document.addEventListener('pointermove', handlePointerMove);\n document.addEventListener('pointerup', handlePointerUp);\n }\n };\n const handlePointerMove = (event: PointerEvent) => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n\n const isHorizontal =\n positioning.direction & (Direction.east | Direction.west);\n const isVertical =\n positioning.direction & (Direction.south | Direction.north);\n\n if (image !== null && positioning.isResizing) {\n // Corner cursor\n if (isHorizontal && isVertical) {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(\n positioning.startWidth + diff,\n minWidth,\n maxWidthContainer,\n );\n\n const height = width / positioning.ratio;\n image.style.width = `${width}px`;\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n positioning.currentWidth = width;\n } else if (isVertical) {\n let diff = Math.floor(positioning.startY - event.clientY);\n diff = positioning.direction & Direction.south ? -diff : diff;\n\n const height = clamp(\n positioning.startHeight + diff,\n minHeight,\n maxHeightContainer,\n );\n\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n } else {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(\n positioning.startWidth + diff,\n minWidth,\n maxWidthContainer,\n );\n\n image.style.width = `${width}px`;\n positioning.currentWidth = width;\n }\n }\n };\n const handlePointerUp = () => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n const controlWrapper = controlWrapperRef.current;\n if (image !== null && controlWrapper !== null && positioning.isResizing) {\n const width = positioning.currentWidth;\n const height = positioning.currentHeight;\n positioning.startWidth = 0;\n positioning.startHeight = 0;\n positioning.ratio = 0;\n positioning.startX = 0;\n positioning.startY = 0;\n positioning.currentWidth = 0;\n positioning.currentHeight = 0;\n positioning.isResizing = false;\n\n controlWrapper.classList.remove('image-control-wrapper--resizing');\n\n setEndCursor();\n onResizeEnd(width, height);\n\n document.removeEventListener('pointermove', handlePointerMove);\n document.removeEventListener('pointerup', handlePointerUp);\n }\n };\n return (\n <div ref={controlWrapperRef}>\n {!showCaption && captionsEnabled && (\n <button\n className=\"image-caption-button\"\n ref={buttonRef}\n onClick={() => {\n setShowCaption(!showCaption);\n }}>\n Add Caption\n </button>\n )}\n <div\n className=\"image-resizer image-resizer-n\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.north);\n }}\n />\n <div\n className=\"image-resizer image-resizer-ne\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.north | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-e\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-se\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.south | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-s\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.south);\n }}\n />\n <div\n className=\"image-resizer image-resizer-sw\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.south | Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-w\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-nw\"\n onPointerDown={(event) => {\n handlePointerDown(event, Direction.north | Direction.west);\n }}\n />\n </div>\n );\n}\n","/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n */\r\n\r\nimport type {\r\n BaseSelection,\r\n LexicalCommand,\r\n LexicalEditor,\r\n NodeKey,\r\n } from \"lexical\";\r\n \r\n import \"./ImageNode.css\";\r\n \r\n import { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\r\n import LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\r\n import { LexicalNestedComposer } from \"@lexical/react/LexicalNestedComposer\";\r\n import { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\r\n import { useLexicalNodeSelection } from \"@lexical/react/useLexicalNodeSelection\";\r\n import { mergeRegister } from \"@lexical/utils\";\r\n import {\r\n $getNodeByKey,\r\n $getSelection,\r\n $isNodeSelection,\r\n $isRangeSelection,\r\n $setSelection,\r\n CLICK_COMMAND,\r\n COMMAND_PRIORITY_LOW,\r\n createCommand,\r\n DRAGSTART_COMMAND,\r\n KEY_BACKSPACE_COMMAND,\r\n KEY_DELETE_COMMAND,\r\n KEY_ENTER_COMMAND,\r\n KEY_ESCAPE_COMMAND,\r\n SELECTION_CHANGE_COMMAND,\r\n } from \"lexical\";\r\n import { Suspense, useCallback, useEffect, useRef, useState } from \"react\";\r\n import ContentEditable from \"../ui/ContentEditable\";\r\n import ImageResizer from \"../ui/ImageResizer\";\r\n import Placeholder from \"../ui/Placeholder\";\r\n import { $isImageNode } from \"./ImageNode\";\r\n \r\n const imageCache = new Set();\r\n \r\n export const RIGHT_CLICK_IMAGE_COMMAND: LexicalCommand<MouseEvent> =\r\n createCommand(\"RIGHT_CLICK_IMAGE_COMMAND\");\r\n \r\n function useSuspenseImage(src: string) {\r\n if (!imageCache.has(src)) {\r\n throw new Promise((resolve) => {\r\n const img = new Image();\r\n img.src = src;\r\n img.onload = () => {\r\n imageCache.add(src);\r\n resolve(null);\r\n };\r\n });\r\n }\r\n }\r\n \r\n function LazyImage({\r\n altText,\r\n className,\r\n imageRef,\r\n src,\r\n width,\r\n height,\r\n maxWidth,\r\n }: {\r\n altText: string;\r\n className: string | null;\r\n height: \"inherit\" | number;\r\n imageRef: { current: null | HTMLImageElement };\r\n maxWidth: number;\r\n src: string;\r\n width: \"inherit\" | number;\r\n }): JSX.Element {\r\n useSuspenseImage(src);\r\n return (\r\n <img\r\n className={className || undefined}\r\n src={src}\r\n alt={altText}\r\n ref={imageRef}\r\n style={{\r\n height,\r\n maxWidth,\r\n width,\r\n }}\r\n draggable=\"false\"\r\n />\r\n );\r\n }\r\n \r\n export default function ImageComponent({\r\n src,\r\n altText,\r\n nodeKey,\r\n width,\r\n height,\r\n maxWidth,\r\n resizable,\r\n showCaption,\r\n caption,\r\n captionsEnabled,\r\n }: {\r\n altText: string;\r\n caption: LexicalEditor;\r\n height: \"inherit\" | number;\r\n maxWidth: number;\r\n nodeKey: NodeKey;\r\n resizable: boolean;\r\n showCaption: boolean;\r\n src: string;\r\n width: \"inherit\" | number;\r\n captionsEnabled: boolean;\r\n }): JSX.Element {\r\n const imageRef = useRef<null | HTMLImageElement>(null);\r\n const buttonRef = useRef<HTMLButtonElement | null>(null);\r\n const [isSelected, setSelected, clearSelection] =\r\n useLexicalNodeSelection(nodeKey);\r\n const [isResizing, setIsResizing] = useState<boolean>(false);\r\n const [editor] = useLexicalComposerContext();\r\n const [selection, setSelection] = useState<BaseSelection | null>(null);\r\n const activeEditorRef = useRef<LexicalEditor | null>(null);\r\n \r\n const onDelete = useCallback(\r\n (payload: KeyboardEvent) => {\r\n if (isSelected && $isNodeSelection($getSelection())) {\r\n const event: KeyboardEvent = payload;\r\n event.preventDefault();\r\n const node = $getNodeByKey(nodeKey);\r\n if ($isImageNode(node)) {\r\n node.remove();\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n [isSelected, nodeKey]\r\n );\r\n \r\n const onEnter = useCallback(\r\n (event: KeyboardEvent) => {\r\n const latestSelection = $getSelection();\r\n const buttonElem = buttonRef.current;\r\n if (\r\n isSelected &&\r\n $isNodeSelection(latestSelection) &&\r\n latestSelection.getNodes().length === 1\r\n ) {\r\n if (showCaption) {\r\n // Move focus into nested editor\r\n $setSelection(null);\r\n event.preventDefault();\r\n caption.focus();\r\n return true;\r\n } else if (\r\n buttonElem !== null &&\r\n buttonElem !== document.activeElement\r\n ) {\r\n event.preventDefault();\r\n buttonElem.focus();\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n [caption, isSelected, showCaption]\r\n );\r\n \r\n const onEscape = useCallback(\r\n (event: KeyboardEvent) => {\r\n if (\r\n activeEditorRef.current === caption ||\r\n buttonRef.current === event.target\r\n ) {\r\n $setSelection(null);\r\n editor.update(() => {\r\n setSelected(true);\r\n const parentRootElement = editor.getRootElement();\r\n if (parentRootElement !== null) {\r\n parentRootElement.focus();\r\n }\r\n });\r\n return true;\r\n }\r\n return false;\r\n },\r\n [caption, editor, setSelected]\r\n );\r\n \r\n const onClick = useCallback(\r\n (payload: MouseEvent) => {\r\n const event = payload;\r\n \r\n if (isResizing) {\r\n return true;\r\n }\r\n if (event.target === imageRef.current) {\r\n if (event.shiftKey) {\r\n setSelected(!isSelected);\r\n } else {\r\n clearSelection();\r\n setSelected(true);\r\n }\r\n return true;\r\n }\r\n \r\n return false;\r\n },\r\n [isResizing, isSelected, setSelected, clearSelection]\r\n );\r\n \r\n const onRightClick = useCallback(\r\n (event: MouseEvent): void => {\r\n editor.getEditorState().read(() => {\r\n const latestSelection = $getSelection();\r\n const domElement = event.target as HTMLElement;\r\n if (\r\n domElement.tagName === \"IMG\" &&\r\n $isRangeSelection(latestSelection) &&\r\n latestSelection.getNodes().length === 1\r\n ) {\r\n editor.dispatchCommand(\r\n RIGHT_CLICK_IMAGE_COMMAND,\r\n event as MouseEvent\r\n );\r\n }\r\n });\r\n },\r\n [editor]\r\n );\r\n \r\n useEffect(() => {\r\n let isMounted = true;\r\n const rootElement = editor.getRootElement();\r\n const unregister = mergeRegister(\r\n editor.registerUpdateListener(({ editorState }) => {\r\n if (isMounted) {\r\n setSelection(editorState.read(() => $getSelection()));\r\n }\r\n }),\r\n editor.registerCommand(\r\n SELECTION_CHANGE_COMMAND,\r\n (_, activeEditor) => {\r\n activeEditorRef.current = activeEditor;\r\n return false;\r\n },\r\n COMMAND_PRIORITY_LOW\r\n ),\r\n editor.registerCommand<MouseEvent>(\r\n CLICK_COMMAND,\r\n onClick,\r\n COMMAND_PRIORITY_LOW\r\n ),\r\n editor.registerCommand<MouseEvent>(\r\n RIGHT_CLICK_IMAGE_COMMAND,\r\n onClick,\r\n COMMAND_PRIORITY_LOW\r\n ),\r\n editor.registerCommand(\r\n DRAGSTART_COMMAND,\r\n (event) => {\r\n if (event.target === imageRef.current) {\r\n // TODO This is just a temporary workaround for FF to behave like other browsers.\r\n // Ideally, this handles drag & drop too (and all browsers).\r\n event.preventDefault();\r\n return true;\r\n }\r\n return false;\r\n },\r\n COMMAND_PRIORITY_LOW\r\n ),\r\n editor.registerCommand(\r\n KEY_DELETE_COMMAND,\r\n onDelete,\r\n COMMAND_PRIORITY_LOW\r\n ),\r\n editor.registerCommand(\r\n KEY_BACKSPACE_COMMAND,\r\n onDelete,\r\n COMMAND_PRIORITY_LOW\r\n ),\r\n editor.registerCommand(KEY_ENTER_COMMAND, onEnter, COMMAND_PRIORITY_LOW),\r\n editor.registerCommand(KEY_ESCAPE_COMMAND, onEscape, COMMAND_PRIORITY_LOW)\r\n );\r\n \r\n rootElement?.addEventListener(\"contextmenu\", onRightClick);\r\n \r\n return () => {\r\n isMounted = false;\r\n unregister();\r\n rootElement?.removeEventListener(\"contextmenu\", onRightClick);\r\n };\r\n }, [\r\n clearSelection,\r\n editor,\r\n isResizing,\r\n isSelected,\r\n nodeKey,\r\n onDelete,\r\n onEnter,\r\n onEscape,\r\n onClick,\r\n onRightClick,\r\n setSelected,\r\n ]);\r\n \r\n const setShowCaption = () => {\r\n editor.update(() => {\r\n const node = $getNodeByKey(nodeKey);\r\n if ($isImageNode(node)) {\r\n node.setShowCaption(true);\r\n }\r\n });\r\n };\r\n \r\n const onResizeEnd = (\r\n nextWidth: \"inherit\" | number,\r\n nextHeight: \"inherit\" | number\r\n ) => {\r\n // Delay hiding the resize bars for click case\r\n setTimeout(() => {\r\n setIsResizing(false);\r\n }, 200);\r\n \r\n editor.update(() => {\r\n const node = $getNodeByKey(nodeKey);\r\n if ($isImageNode(node)) {\r\n node.setWidthAndHeight(nextWidth, nextHeight);\r\n }\r\n });\r\n };\r\n \r\n const onResizeStart = () => {\r\n setIsResizing(true);\r\n };\r\n \r\n const draggable = isSelected && $isNodeSelection(selection) && !isResizing;\r\n const isFocused = isSelected || isResizing;\r\n \r\n return (\r\n <Suspense fallback={null}>\r\n <>\r\n <div draggable={draggable}>\r\n <LazyImage\r\n className={\r\n isFocused\r\n ? `focused ${$isNodeSelection(selection) ? \"draggable\" : \"\"}`\r\n : null\r\n }\r\n src={src}\r\n altText={altText}\r\n imageRef={imageRef}\r\n width={width}\r\n height={height}\r\n maxWidth={maxWidth}\r\n />\r\n </div>\r\n \r\n {showCaption && (\r\n <div className=\"image-caption-container\">\r\n <LexicalNestedComposer initialEditor={caption}>\r\n <RichTextPlugin\r\n contentEditable={\r\n <ContentEditable className=\"ImageNode__contentEditable\" />\r\n }\r\n placeholder={\r\n <Placeholder className=\"ImageNode__placeholder\">\r\n Enter a caption...\r\n </Placeholder>\r\n }\r\n ErrorBoundary={LexicalErrorBoundary}\r\n />\r\n </LexicalNestedComposer>\r\n </div>\r\n )}\r\n \r\n {resizable && $isNodeSelection(selection) && isFocused && (\r\n <ImageResizer\r\n showCaption={showCaption}\r\n setShowCaption={setShowCaption}\r\n editor={editor}\r\n buttonRef={buttonRef}\r\n imageRef={imageRef}\r\n maxWidth={maxWidth}\r\n onResizeStart={onResizeStart}\r\n onResizeEnd={onResizeEnd}\r\n captionsEnabled={captionsEnabled}\r\n />\r\n )}\r\n </>\r\n </Suspense>\r\n );\r\n }\r\n "],"names":["clamp","value","min","max","Direction","ImageResizer","onResizeStart","onResizeEnd","buttonRef","imageRef","maxWidth","editor","showCaption","setShowCaption","captionsEnabled","controlWrapperRef","useRef","userSelect","positioningRef","editorRootElement","maxWidthContainer","maxHeightContainer","minWidth","minHeight","setStartCursor","direction","ew","ns","nwse","cursorDir","setEndCursor","handlePointerDown","event","image","controlWrapper","width","height","positioning","handlePointerMove","handlePointerUp","isHorizontal","isVertical","diff","jsxs","jsx","imageCache","RIGHT_CLICK_IMAGE_COMMAND","createCommand","useSuspenseImage","src","resolve","img","LazyImage","altText","className","ImageComponent","nodeKey","resizable","caption","isSelected","setSelected","clearSelection","useLexicalNodeSelection","isResizing","setIsResizing","useState","useLexicalComposerContext","selection","setSelection","activeEditorRef","onDelete","useCallback","payload","$isNodeSelection","$getSelection","node","$getNodeByKey","$isImageNode","onEnter","latestSelection","buttonElem","$setSelection","onEscape","parentRootElement","onClick","onRightClick","$isRangeSelection","useEffect","isMounted","rootElement","unregister","mergeRegister","editorState","SELECTION_CHANGE_COMMAND","_","activeEditor","COMMAND_PRIORITY_LOW","CLICK_COMMAND","DRAGSTART_COMMAND","KEY_DELETE_COMMAND","KEY_BACKSPACE_COMMAND","KEY_ENTER_COMMAND","KEY_ESCAPE_COMMAND","nextWidth","nextHeight","draggable","isFocused","Suspense","Fragment","LexicalNestedComposer","RichTextPlugin","ContentEditable","Placeholder","LexicalErrorBoundary"],"mappings":";;;;AAaA,SAASA,EAAMC,GAAeC,GAAaC,GAAa;AACtD,SAAO,KAAK,IAAI,KAAK,IAAIF,GAAOC,CAAG,GAAGC,CAAG;AAC3C;AAEA,MAAMC,IAAY;AAAA,EAChB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,OAAO;AAAA,EACP,MAAM;AACR;AAEA,SAAwBC,GAAa;AAAA,EACnC,eAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,iBAAAC;AACF,GAUgB;AACR,QAAAC,IAAoBC,EAAuB,IAAI,GAC/CC,IAAaD,EAAO;AAAA,IACxB,UAAU;AAAA,IACV,OAAO;AAAA,EAAA,CACR,GACKE,IAAiBF,EAUpB;AAAA,IACD,eAAe;AAAA,IACf,cAAc;AAAA,IACd,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,aAAa;AAAA,IACb,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,CACT,GACKG,IAAoBR,EAAO,kBAE3BS,IAAoBV,MAEtBS,MAAsB,OACtBA,EAAkB,sBAAwB,EAAA,QAAQ,KAClD,MACEE,IACJF,MAAsB,OAClBA,EAAkB,wBAAwB,SAAS,KACnD,KAEAG,IAAW,KACXC,IAAY,KAEZC,IAAiB,CAACC,MAAsB;AAC5C,UAAMC,IAAKD,MAAcrB,E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