@uipath/apollo-react 4.63.0 → 4.65.0

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 (46) hide show
  1. package/dist/canvas/components/BaseCanvas/BaseCanvas.cjs +2 -1
  2. package/dist/canvas/components/BaseCanvas/BaseCanvas.d.ts.map +1 -1
  3. package/dist/canvas/components/BaseCanvas/BaseCanvas.js +2 -1
  4. package/dist/canvas/components/BaseCanvas/BaseCanvas.types.d.ts +2 -0
  5. package/dist/canvas/components/BaseCanvas/BaseCanvas.types.d.ts.map +1 -1
  6. package/dist/canvas/components/BaseCanvas/CanvasProviders.cjs +8 -4
  7. package/dist/canvas/components/BaseCanvas/CanvasProviders.d.ts +3 -1
  8. package/dist/canvas/components/BaseCanvas/CanvasProviders.d.ts.map +1 -1
  9. package/dist/canvas/components/BaseCanvas/CanvasProviders.js +8 -4
  10. package/dist/canvas/components/ProbeCard/ProbeCard.cjs +5 -5
  11. package/dist/canvas/components/ProbeCard/ProbeCard.d.ts.map +1 -1
  12. package/dist/canvas/components/ProbeCard/ProbeCard.js +2 -2
  13. package/dist/canvas/components/ProbeCard/useDragSession.cjs +2 -2
  14. package/dist/canvas/components/ProbeCard/useDragSession.js +1 -1
  15. package/dist/canvas/components/StickyNoteNode/StickyNoteCanvasOptionsContext.cjs +61 -0
  16. package/dist/canvas/components/StickyNoteNode/StickyNoteCanvasOptionsContext.d.ts +11 -0
  17. package/dist/canvas/components/StickyNoteNode/StickyNoteCanvasOptionsContext.d.ts.map +1 -0
  18. package/dist/canvas/components/StickyNoteNode/StickyNoteCanvasOptionsContext.js +24 -0
  19. package/dist/canvas/components/StickyNoteNode/StickyNoteMedia.cjs +449 -0
  20. package/dist/canvas/components/StickyNoteNode/StickyNoteMedia.d.ts +45 -0
  21. package/dist/canvas/components/StickyNoteNode/StickyNoteMedia.d.ts.map +1 -0
  22. package/dist/canvas/components/StickyNoteNode/StickyNoteMedia.js +394 -0
  23. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaDialog.cjs +379 -0
  24. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaDialog.d.ts +8 -0
  25. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaDialog.d.ts.map +1 -0
  26. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaDialog.js +345 -0
  27. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaMarkdown.cjs +279 -0
  28. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaMarkdown.d.ts +18 -0
  29. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaMarkdown.d.ts.map +1 -0
  30. package/dist/canvas/components/StickyNoteNode/StickyNoteMediaMarkdown.js +242 -0
  31. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.cjs +193 -41
  32. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts +2 -1
  33. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts.map +1 -1
  34. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.js +193 -41
  35. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts +4 -0
  36. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts.map +1 -1
  37. package/dist/canvas/hooks/useLatestRef.d.ts.map +1 -0
  38. package/dist/canvas/locales/en.cjs +1 -1
  39. package/dist/canvas/locales/en.d.ts.map +1 -1
  40. package/dist/canvas/locales/en.js +1 -1
  41. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  42. package/package.json +1 -1
  43. package/dist/canvas/components/ProbeCard/useLatestRef.d.ts.map +0 -1
  44. /package/dist/canvas/{components/ProbeCard → hooks}/useLatestRef.cjs +0 -0
  45. /package/dist/canvas/{components/ProbeCard → hooks}/useLatestRef.d.ts +0 -0
  46. /package/dist/canvas/{components/ProbeCard → hooks}/useLatestRef.js +0 -0
@@ -0,0 +1,242 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { CanvasIcon } from "../../index.js";
3
+ import { createContext, createElement, useContext, useState } from "react";
4
+ import { useSafeLingui } from "../../../i18n/index.js";
5
+ import { parseStickyNoteMediaMarker, parseStickyNoteMediaSource } from "./StickyNoteMedia.js";
6
+ const StickyNoteMediaMarkdownContext = /*#__PURE__*/ createContext({
7
+ editable: false
8
+ });
9
+ function StickyNoteMediaMarkdownProvider({ value, children }) {
10
+ return /*#__PURE__*/ jsx(StickyNoteMediaMarkdownContext.Provider, {
11
+ value: value,
12
+ children: children
13
+ });
14
+ }
15
+ function sourceRange(node) {
16
+ const start = node?.position?.start?.offset;
17
+ const end = node?.position?.end?.offset;
18
+ return 'number' == typeof start && 'number' == typeof end ? {
19
+ start,
20
+ end
21
+ } : null;
22
+ }
23
+ function stopNodeDrag(event) {
24
+ event.stopPropagation();
25
+ }
26
+ function MediaContainer({ fullWidth, children }) {
27
+ return /*#__PURE__*/ jsx("span", {
28
+ className: "relative my-2 block max-w-full overflow-hidden rounded-md",
29
+ style: {
30
+ width: fullWidth ? '100%' : 'min(320px, 100%)'
31
+ },
32
+ "data-sticky-media": true,
33
+ "data-sticky-full-width": fullWidth,
34
+ children: children
35
+ });
36
+ }
37
+ function MediaEditButton({ onClick }) {
38
+ const { _ } = useSafeLingui();
39
+ const label = _({
40
+ id: 'sticky-note.media.edit',
41
+ message: 'Edit media'
42
+ });
43
+ return /*#__PURE__*/ jsx("button", {
44
+ type: "button",
45
+ "data-sticky-media-control": true,
46
+ "aria-label": label,
47
+ title: label,
48
+ className: "nodrag nopan absolute right-1 top-1 z-10 inline-flex h-7 w-7 items-center justify-center rounded bg-surface-raised/95 text-foreground opacity-80 shadow-sm transition-opacity hover:bg-surface-hover hover:opacity-100 focus-visible:opacity-100",
49
+ onClick: (event)=>{
50
+ event.preventDefault();
51
+ event.stopPropagation();
52
+ onClick();
53
+ },
54
+ onDoubleClick: (event)=>event.stopPropagation(),
55
+ onPointerDown: stopNodeDrag,
56
+ onMouseDown: stopNodeDrag,
57
+ children: /*#__PURE__*/ jsx(CanvasIcon, {
58
+ icon: "pencil",
59
+ size: 14
60
+ })
61
+ });
62
+ }
63
+ function StickyNoteMediaImage({ src, alt = '', title, node, fallbackImage, ...imageProps }) {
64
+ const { _ } = useSafeLingui();
65
+ const { editable, onEditMedia } = useContext(StickyNoteMediaMarkdownContext);
66
+ const [failedImageUrl, setFailedImageUrl] = useState(null);
67
+ const [loadedYouTubeId, setLoadedYouTubeId] = useState(null);
68
+ const mediaMarker = parseStickyNoteMediaMarker(title);
69
+ const media = 'string' == typeof src ? parseStickyNoteMediaSource(src, alt, title) : null;
70
+ const range = sourceRange(node);
71
+ if (!media) {
72
+ if (mediaMarker) {
73
+ const unavailableLabel = _({
74
+ id: 'sticky-note.media.unavailable',
75
+ message: 'Media unavailable'
76
+ });
77
+ return /*#__PURE__*/ jsx(MediaContainer, {
78
+ fullWidth: mediaMarker.fullWidth,
79
+ children: /*#__PURE__*/ jsx("span", {
80
+ role: "img",
81
+ "aria-label": alt || unavailableLabel,
82
+ className: "flex min-h-20 items-center justify-center bg-black/10 px-3 text-center text-xs text-foreground-muted",
83
+ children: unavailableLabel
84
+ })
85
+ });
86
+ }
87
+ if (fallbackImage) {
88
+ const fallbackProps = {
89
+ ...imageProps,
90
+ src,
91
+ alt,
92
+ title
93
+ };
94
+ return 'string' == typeof fallbackImage ? /*#__PURE__*/ createElement(fallbackImage, fallbackProps) : /*#__PURE__*/ createElement(fallbackImage, {
95
+ ...fallbackProps,
96
+ node
97
+ });
98
+ }
99
+ return /*#__PURE__*/ jsx("img", {
100
+ ...imageProps,
101
+ src: src,
102
+ alt: alt,
103
+ title: title
104
+ });
105
+ }
106
+ const editButton = editable && range && onEditMedia && /*#__PURE__*/ jsx(MediaEditButton, {
107
+ onClick: ()=>onEditMedia(media, range)
108
+ });
109
+ if ('youtube' === media.kind) {
110
+ const playLabel = _({
111
+ id: 'sticky-note.media.play-video',
112
+ message: 'Play video'
113
+ });
114
+ const youtubeLoaded = loadedYouTubeId === media.videoId;
115
+ return /*#__PURE__*/ jsxs(MediaContainer, {
116
+ fullWidth: media.fullWidth,
117
+ children: [
118
+ youtubeLoaded ? /*#__PURE__*/ jsx("iframe", {
119
+ src: `https://www.youtube-nocookie.com/embed/${media.videoId}?autoplay=1`,
120
+ title: _({
121
+ id: 'sticky-note.media.youtube-title',
122
+ message: 'YouTube video'
123
+ }),
124
+ loading: "lazy",
125
+ referrerPolicy: "strict-origin-when-cross-origin",
126
+ sandbox: "allow-scripts allow-same-origin allow-presentation",
127
+ allow: "autoplay; encrypted-media; fullscreen; picture-in-picture",
128
+ allowFullScreen: true,
129
+ className: "nodrag nopan block aspect-video w-full border-0",
130
+ onPointerDown: stopNodeDrag,
131
+ onMouseDown: stopNodeDrag
132
+ }) : /*#__PURE__*/ jsxs("button", {
133
+ type: "button",
134
+ "data-sticky-media-control": true,
135
+ "aria-label": playLabel,
136
+ className: "nodrag nopan group relative flex aspect-video w-full items-center justify-center overflow-hidden bg-black text-sm font-medium text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-white",
137
+ onClick: (event)=>{
138
+ event.preventDefault();
139
+ event.stopPropagation();
140
+ setLoadedYouTubeId(media.videoId);
141
+ },
142
+ onDoubleClick: (event)=>event.stopPropagation(),
143
+ onPointerDown: stopNodeDrag,
144
+ onMouseDown: stopNodeDrag,
145
+ children: [
146
+ /*#__PURE__*/ jsx("img", {
147
+ src: `https://i.ytimg.com/vi/${media.videoId}/hqdefault.jpg`,
148
+ alt: "",
149
+ draggable: false,
150
+ loading: "lazy",
151
+ decoding: "async",
152
+ referrerPolicy: "no-referrer",
153
+ className: "absolute inset-0 h-full w-full object-cover opacity-80 transition-opacity group-hover:opacity-70"
154
+ }),
155
+ /*#__PURE__*/ jsxs("span", {
156
+ className: "relative z-10 inline-flex items-center gap-2 rounded-full bg-black/70 px-4 py-2 shadow-sm",
157
+ children: [
158
+ /*#__PURE__*/ jsx(CanvasIcon, {
159
+ icon: "play",
160
+ size: 18
161
+ }),
162
+ playLabel
163
+ ]
164
+ })
165
+ ]
166
+ }),
167
+ editButton
168
+ ]
169
+ });
170
+ }
171
+ if ('publicVideo' === media.kind) {
172
+ const videoLabel = alt || _({
173
+ id: 'sticky-note.media.video-label',
174
+ message: 'Embedded video'
175
+ });
176
+ return /*#__PURE__*/ jsxs(MediaContainer, {
177
+ fullWidth: media.fullWidth,
178
+ children: [
179
+ /*#__PURE__*/ jsx("video", {
180
+ src: media.url,
181
+ "aria-label": videoLabel,
182
+ controls: true,
183
+ preload: "metadata",
184
+ playsInline: true,
185
+ className: "nodrag nopan block h-auto w-full bg-black",
186
+ onClick: (event)=>event.stopPropagation(),
187
+ onDoubleClick: (event)=>event.stopPropagation(),
188
+ onPointerDown: stopNodeDrag,
189
+ onMouseDown: stopNodeDrag,
190
+ children: _({
191
+ id: 'sticky-note.media.video-unavailable',
192
+ message: 'Video playback is unavailable.'
193
+ })
194
+ }),
195
+ editButton
196
+ ]
197
+ });
198
+ }
199
+ const imageFailed = failedImageUrl === media.url;
200
+ return /*#__PURE__*/ jsxs(MediaContainer, {
201
+ fullWidth: media.fullWidth,
202
+ children: [
203
+ imageFailed ? /*#__PURE__*/ jsx("span", {
204
+ role: "img",
205
+ "aria-label": alt || _({
206
+ id: 'sticky-note.media.image-unavailable-label',
207
+ message: 'Image unavailable'
208
+ }),
209
+ className: "flex min-h-20 items-center justify-center bg-black/10 px-3 text-center text-xs text-foreground-muted",
210
+ children: _({
211
+ id: 'sticky-note.media.image-unavailable',
212
+ message: 'Image unavailable'
213
+ })
214
+ }) : /*#__PURE__*/ jsx("img", {
215
+ ...imageProps,
216
+ src: media.url,
217
+ alt: alt,
218
+ draggable: false,
219
+ loading: "lazy",
220
+ decoding: "async",
221
+ referrerPolicy: "no-referrer",
222
+ style: {
223
+ display: 'block',
224
+ maxWidth: '100%',
225
+ width: media.fullWidth ? '100%' : 'auto',
226
+ height: 'auto'
227
+ },
228
+ onError: ()=>setFailedImageUrl(media.url)
229
+ }),
230
+ editButton
231
+ ]
232
+ });
233
+ }
234
+ function createStickyNoteMediaMarkdownComponents(fallbackImage) {
235
+ return {
236
+ img: (props)=>/*#__PURE__*/ jsx(StickyNoteMediaImage, {
237
+ ...props,
238
+ fallbackImage: fallbackImage
239
+ })
240
+ };
241
+ }
242
+ export { StickyNoteMediaMarkdownProvider, createStickyNoteMediaMarkdownComponents };
@@ -50,12 +50,17 @@ const external_remark_gfm_namespaceObject = require("remark-gfm");
50
50
  var external_remark_gfm_default = /*#__PURE__*/ __webpack_require__.n(external_remark_gfm_namespaceObject);
51
51
  const index_cjs_namespaceObject = require("../../../i18n/index.cjs");
52
52
  const external_constants_cjs_namespaceObject = require("../../constants.cjs");
53
+ const useLatestRef_cjs_namespaceObject = require("../../hooks/useLatestRef.cjs");
53
54
  const nodePropsEqual_cjs_namespaceObject = require("../../utils/nodePropsEqual.cjs");
54
55
  const SelectionStateContext_cjs_namespaceObject = require("../BaseCanvas/SelectionStateContext.cjs");
55
56
  const external_NodeViewportOverlay_cjs_namespaceObject = require("../NodeViewportOverlay.cjs");
56
57
  const external_Toolbar_index_cjs_namespaceObject = require("../Toolbar/index.cjs");
57
58
  const external_FormattingToolbar_cjs_namespaceObject = require("./FormattingToolbar.cjs");
58
59
  const external_markdown_formatting_index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
60
+ const external_StickyNoteCanvasOptionsContext_cjs_namespaceObject = require("./StickyNoteCanvasOptionsContext.cjs");
61
+ const external_StickyNoteMedia_cjs_namespaceObject = require("./StickyNoteMedia.cjs");
62
+ const external_StickyNoteMediaDialog_cjs_namespaceObject = require("./StickyNoteMediaDialog.cjs");
63
+ const external_StickyNoteMediaMarkdown_cjs_namespaceObject = require("./StickyNoteMediaMarkdown.cjs");
59
64
  const external_StickyNoteNode_styles_cjs_namespaceObject = require("./StickyNoteNode.styles.cjs");
60
65
  const external_StickyNoteNode_types_cjs_namespaceObject = require("./StickyNoteNode.types.cjs");
61
66
  const external_StickyNoteNode_utils_cjs_namespaceObject = require("./StickyNoteNode.utils.cjs");
@@ -63,18 +68,36 @@ const external_useMarkdownShortcuts_cjs_namespaceObject = require("./useMarkdown
63
68
  const external_useScrollCapture_cjs_namespaceObject = require("./useScrollCapture.cjs");
64
69
  const minWidth = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
65
70
  const minHeight = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
66
- const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, formattingActions, markdownComponents: customMarkdownComponents })=>{
71
+ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly: readOnlyProp, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, enableMediaEmbedding: enableMediaEmbeddingProp, formattingActions, markdownComponents: customMarkdownComponents })=>{
67
72
  const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
73
+ const canvasOptions = (0, external_StickyNoteCanvasOptionsContext_cjs_namespaceObject.useStickyNoteCanvasOptions)();
74
+ const readOnly = readOnlyProp ?? canvasOptions.readOnly;
75
+ const enableMediaEmbedding = enableMediaEmbeddingProp ?? canvasOptions.enableMediaEmbedding;
68
76
  const { updateNodeData, deleteElements } = (0, react_cjs_namespaceObject.useReactFlow)();
69
77
  const { multipleNodesSelected } = (0, SelectionStateContext_cjs_namespaceObject.useSelectionState)();
70
78
  const [isEditing, setIsEditing] = (0, external_react_namespaceObject.useState)(!readOnly && (data.autoFocus ?? false));
71
79
  const [isResizing, setIsResizing] = (0, external_react_namespaceObject.useState)(false);
72
80
  const [isColorPickerOpen, setIsColorPickerOpen] = (0, external_react_namespaceObject.useState)(false);
81
+ const [mediaDialog, setMediaDialog] = (0, external_react_namespaceObject.useState)(null);
73
82
  const [localContent, setLocalContent] = (0, external_react_namespaceObject.useState)(data.content || '');
74
83
  const latestContentRef = (0, external_react_namespaceObject.useRef)(localContent);
75
84
  const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
76
85
  const formattingToolbarRef = (0, external_react_namespaceObject.useRef)(null);
77
86
  const skipBlurRef = (0, external_react_namespaceObject.useRef)(null);
87
+ const resizeActiveRef = (0, external_react_namespaceObject.useRef)(false);
88
+ const resizeLifecycle = {
89
+ content: data.content,
90
+ id,
91
+ isEditing,
92
+ localContent,
93
+ onContentChange,
94
+ onResize,
95
+ onResizeEnd,
96
+ onResizeStart,
97
+ readOnly,
98
+ updateNodeData
99
+ };
100
+ const resizeLifecycleRef = (0, useLatestRef_cjs_namespaceObject.useLatestRef)(resizeLifecycle);
78
101
  const { ref: markdownRef, scrollCaptureProps } = (0, external_useScrollCapture_cjs_namespaceObject.useScrollCapture)();
79
102
  const colorButtonRef = (0, external_react_namespaceObject.useRef)(null);
80
103
  const [activeFormats, setActiveFormats] = (0, external_react_namespaceObject.useState)({
@@ -87,6 +110,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
87
110
  const colorKey = data.color || 'yellow';
88
111
  const color = external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS[colorKey] ?? external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS.yellow;
89
112
  const colorWithAlpha = (0, external_StickyNoteNode_types_cjs_namespaceObject.withAlpha)(color);
113
+ const endResizeLifecycle = (0, external_react_namespaceObject.useCallback)(()=>{
114
+ if (!resizeActiveRef.current) return;
115
+ resizeActiveRef.current = false;
116
+ setIsResizing(false);
117
+ const latestOnResizeEnd = resizeLifecycleRef.current.onResizeEnd;
118
+ if (latestOnResizeEnd) queueMicrotask(latestOnResizeEnd);
119
+ }, [
120
+ resizeLifecycleRef
121
+ ]);
90
122
  const updateLocalContent = (0, external_react_namespaceObject.useCallback)((content)=>{
91
123
  latestContentRef.current = content;
92
124
  setLocalContent(content);
@@ -244,6 +276,92 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
244
276
  updateLocalContent,
245
277
  updateNodeData
246
278
  ]);
279
+ const openMediaDialog = (0, external_react_namespaceObject.useCallback)((context)=>{
280
+ const { selection } = context;
281
+ setMediaDialog({
282
+ source: 'editor',
283
+ context,
284
+ token: (0, external_StickyNoteMedia_cjs_namespaceObject.findStickyNoteMediaAtSelection)(selection.value, selection.selectionStart, selection.selectionEnd)
285
+ });
286
+ }, []);
287
+ const mediaFormattingAction = (0, external_react_namespaceObject.useMemo)(()=>({
288
+ id: 'sticky-note-embed-media',
289
+ icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
290
+ icon: "image-plus",
291
+ size: 14
292
+ }),
293
+ label: _({
294
+ id: 'sticky-note.media.embed-action',
295
+ message: 'Embed image or video'
296
+ }),
297
+ onAction: openMediaDialog
298
+ }), [
299
+ _,
300
+ openMediaDialog
301
+ ]);
302
+ const effectiveFormattingActions = (0, external_react_namespaceObject.useMemo)(()=>enableMediaEmbedding ? [
303
+ mediaFormattingAction,
304
+ ...formattingActions ?? []
305
+ ] : formattingActions ?? [], [
306
+ enableMediaEmbedding,
307
+ formattingActions,
308
+ mediaFormattingAction
309
+ ]);
310
+ const handleEditRenderedMedia = (0, external_react_namespaceObject.useCallback)((media, range)=>{
311
+ const sourceContent = latestContentRef.current;
312
+ const renderedTokens = (0, external_StickyNoteMedia_cjs_namespaceObject.parseStickyNoteMediaTokens)((0, external_StickyNoteNode_utils_cjs_namespaceObject.preserveNewlines)(sourceContent));
313
+ const renderedIndex = renderedTokens.findIndex((token)=>token.start === range.start && token.end === range.end);
314
+ const sourceToken = renderedIndex >= 0 ? (0, external_StickyNoteMedia_cjs_namespaceObject.parseStickyNoteMediaTokens)(sourceContent)[renderedIndex] : void 0;
315
+ setMediaDialog({
316
+ source: 'rendered',
317
+ token: sourceToken ?? {
318
+ media,
319
+ ...range
320
+ }
321
+ });
322
+ }, []);
323
+ const cancelMediaDialog = (0, external_react_namespaceObject.useCallback)(()=>{
324
+ const current = mediaDialog;
325
+ setMediaDialog(null);
326
+ if (current?.source === 'editor') current.context.resume();
327
+ }, [
328
+ mediaDialog
329
+ ]);
330
+ (0, external_react_namespaceObject.useEffect)(()=>{
331
+ if (!mediaDialog || enableMediaEmbedding && !readOnly) return;
332
+ setMediaDialog(null);
333
+ skipBlurRef.current = null;
334
+ if (!readOnly && 'editor' === mediaDialog.source) mediaDialog.context.resume();
335
+ }, [
336
+ enableMediaEmbedding,
337
+ mediaDialog,
338
+ readOnly
339
+ ]);
340
+ const submitMediaDialog = (0, external_react_namespaceObject.useCallback)((media)=>{
341
+ if (!mediaDialog) return;
342
+ const block = (0, external_StickyNoteMedia_cjs_namespaceObject.serializeStickyNoteMedia)(media);
343
+ if ('editor' === mediaDialog.source) {
344
+ const currentValue = mediaDialog.context.currentValue();
345
+ const next = mediaDialog.token ? (0, external_StickyNoteMedia_cjs_namespaceObject.replaceStickyNoteMedia)(currentValue, mediaDialog.token, block) ?? (0, external_StickyNoteMedia_cjs_namespaceObject.insertStickyNoteMedia)(currentValue, block, null) : (0, external_StickyNoteMedia_cjs_namespaceObject.insertStickyNoteMedia)(currentValue, block, mediaDialog.context.selection);
346
+ setMediaDialog(null);
347
+ mediaDialog.context.commit(next);
348
+ return;
349
+ }
350
+ const currentValue = latestContentRef.current;
351
+ const next = (0, external_StickyNoteMedia_cjs_namespaceObject.replaceStickyNoteMedia)(currentValue, mediaDialog.token, block) ?? (0, external_StickyNoteMedia_cjs_namespaceObject.insertStickyNoteMedia)(currentValue, block, null);
352
+ setMediaDialog(null);
353
+ updateLocalContent(next.value);
354
+ onContentChange?.(next.value);
355
+ updateNodeData(id, {
356
+ content: next.value
357
+ });
358
+ }, [
359
+ id,
360
+ mediaDialog,
361
+ onContentChange,
362
+ updateLocalContent,
363
+ updateNodeData
364
+ ]);
247
365
  const updateActiveFormats = (0, external_react_namespaceObject.useCallback)(()=>{
248
366
  if (!textAreaRef.current) return;
249
367
  const next = (0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)({
@@ -286,13 +404,16 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
286
404
  updateLocalContent
287
405
  ]);
288
406
  const handleResizeStart = (0, external_react_namespaceObject.useCallback)(()=>{
289
- if (isEditing) {
290
- const content = textAreaRef.current?.value ?? localContent;
291
- if (!readOnly && content !== data.content) {
407
+ if (resizeActiveRef.current) return;
408
+ resizeActiveRef.current = true;
409
+ const lifecycle = resizeLifecycleRef.current;
410
+ if (lifecycle.isEditing) {
411
+ const content = textAreaRef.current?.value ?? lifecycle.localContent;
412
+ if (!lifecycle.readOnly && content !== lifecycle.content) {
292
413
  skipBlurRef.current = content;
293
414
  (0, external_react_dom_namespaceObject.flushSync)(()=>{
294
- onContentChange?.(content);
295
- updateNodeData(id, {
415
+ lifecycle.onContentChange?.(content);
416
+ lifecycle.updateNodeData(lifecycle.id, {
296
417
  content
297
418
  });
298
419
  });
@@ -300,24 +421,20 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
300
421
  textAreaRef.current?.blur();
301
422
  }
302
423
  setIsResizing(true);
303
- onResizeStart?.();
424
+ lifecycle.onResizeStart?.();
304
425
  }, [
305
- data.content,
306
- id,
307
- isEditing,
308
- localContent,
309
- onContentChange,
310
- onResizeStart,
311
- readOnly,
312
- updateNodeData
426
+ resizeLifecycleRef
313
427
  ]);
314
428
  const handleResizeEnd = (0, external_react_namespaceObject.useCallback)((_event, params)=>{
315
- setIsResizing(false);
316
- onResize?.(params.width, params.height);
317
- if (onResizeEnd) queueMicrotask(onResizeEnd);
429
+ if (!resizeActiveRef.current) return;
430
+ try {
431
+ resizeLifecycleRef.current.onResize?.(params.width, params.height);
432
+ } finally{
433
+ endResizeLifecycle();
434
+ }
318
435
  }, [
319
- onResize,
320
- onResizeEnd
436
+ endResizeLifecycle,
437
+ resizeLifecycleRef
321
438
  ]);
322
439
  const handleColorChange = (0, external_react_namespaceObject.useCallback)((newColor)=>{
323
440
  onColorChange?.(newColor);
@@ -360,9 +477,16 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
360
477
  const builtInMarkdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
361
478
  a: ({ node: _node, href, children, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
362
479
  ...props,
480
+ className: [
481
+ 'nodrag',
482
+ 'nopan',
483
+ props.className
484
+ ].filter(Boolean).join(' '),
363
485
  href: href,
364
486
  target: "_blank",
365
487
  rel: "noopener noreferrer",
488
+ onPointerDown: (event)=>event.stopPropagation(),
489
+ onMouseDown: (event)=>event.stopPropagation(),
366
490
  onClick: (e)=>{
367
491
  e.stopPropagation();
368
492
  },
@@ -372,12 +496,27 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
372
496
  children: children
373
497
  })
374
498
  }), []);
499
+ const mediaMarkdownComponents = (0, external_react_namespaceObject.useMemo)(()=>(0, external_StickyNoteMediaMarkdown_cjs_namespaceObject.createStickyNoteMediaMarkdownComponents)(customMarkdownComponents?.img), [
500
+ customMarkdownComponents?.img
501
+ ]);
375
502
  const markdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
376
503
  ...customMarkdownComponents,
504
+ ...enableMediaEmbedding ? mediaMarkdownComponents : {},
377
505
  ...builtInMarkdownComponents
378
506
  }), [
379
507
  builtInMarkdownComponents,
380
- customMarkdownComponents
508
+ customMarkdownComponents,
509
+ enableMediaEmbedding,
510
+ mediaMarkdownComponents
511
+ ]);
512
+ const mediaMarkdownOptions = (0, external_react_namespaceObject.useMemo)(()=>({
513
+ editable: enableMediaEmbedding && selected && !readOnly,
514
+ onEditMedia: handleEditRenderedMedia
515
+ }), [
516
+ enableMediaEmbedding,
517
+ handleEditRenderedMedia,
518
+ readOnly,
519
+ selected
381
520
  ]);
382
521
  const toolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>{
383
522
  const actions = [
@@ -442,6 +581,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
442
581
  handleDelete
443
582
  ]);
444
583
  const shouldRenderToolbarOverlay = !readOnly && selected && !dragging && !isResizing && !multipleNodesSelected;
584
+ const shouldRenderResizeControls = !readOnly || isResizing;
445
585
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
446
586
  children: [
447
587
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.Global, {
@@ -450,12 +590,13 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
450
590
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteWrapper, {
451
591
  "data-sticky-note": true,
452
592
  children: [
453
- !readOnly && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
593
+ shouldRenderResizeControls && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
454
594
  children: [
455
595
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_cjs_namespaceObject.NodeResizeControl, {
456
596
  style: {
457
597
  background: 'transparent',
458
598
  border: 'none',
599
+ pointerEvents: readOnly ? 'none' : void 0,
459
600
  zIndex: external_StickyNoteNode_styles_cjs_namespaceObject.RESIZE_CONTROL_Z_INDEX
460
601
  },
461
602
  position: "top-left",
@@ -464,7 +605,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
464
605
  onResizeStart: handleResizeStart,
465
606
  onResizeEnd: handleResizeEnd,
466
607
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ResizeHandle, {
467
- selected: selected,
608
+ selected: selected && !readOnly,
468
609
  cursor: "nwse-resize"
469
610
  })
470
611
  }),
@@ -472,6 +613,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
472
613
  style: {
473
614
  background: 'transparent',
474
615
  border: 'none',
616
+ pointerEvents: readOnly ? 'none' : void 0,
475
617
  zIndex: external_StickyNoteNode_styles_cjs_namespaceObject.RESIZE_CONTROL_Z_INDEX
476
618
  },
477
619
  position: "top-right",
@@ -480,7 +622,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
480
622
  onResizeStart: handleResizeStart,
481
623
  onResizeEnd: handleResizeEnd,
482
624
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ResizeHandle, {
483
- selected: selected,
625
+ selected: selected && !readOnly,
484
626
  cursor: "nesw-resize"
485
627
  })
486
628
  }),
@@ -488,6 +630,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
488
630
  style: {
489
631
  background: 'transparent',
490
632
  border: 'none',
633
+ pointerEvents: readOnly ? 'none' : void 0,
491
634
  zIndex: external_StickyNoteNode_styles_cjs_namespaceObject.RESIZE_CONTROL_Z_INDEX
492
635
  },
493
636
  position: "bottom-left",
@@ -496,7 +639,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
496
639
  onResizeStart: handleResizeStart,
497
640
  onResizeEnd: handleResizeEnd,
498
641
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ResizeHandle, {
499
- selected: selected,
642
+ selected: selected && !readOnly,
500
643
  cursor: "nesw-resize"
501
644
  })
502
645
  }),
@@ -504,6 +647,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
504
647
  style: {
505
648
  background: 'transparent',
506
649
  border: 'none',
650
+ pointerEvents: readOnly ? 'none' : void 0,
507
651
  zIndex: external_StickyNoteNode_styles_cjs_namespaceObject.RESIZE_CONTROL_Z_INDEX
508
652
  },
509
653
  position: "bottom-right",
@@ -512,7 +656,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
512
656
  onResizeStart: handleResizeStart,
513
657
  onResizeEnd: handleResizeEnd,
514
658
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ResizeHandle, {
515
- selected: selected,
659
+ selected: selected && !readOnly,
516
660
  cursor: "nwse-resize"
517
661
  })
518
662
  })
@@ -553,27 +697,30 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
553
697
  activeFormats: activeFormats,
554
698
  onFormat: handleFormat,
555
699
  onBlur: handleBlur,
556
- actions: formattingActions,
700
+ actions: effectiveFormattingActions,
557
701
  onAction: handleFormattingAction
558
702
  })
559
703
  ]
560
704
  }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteMarkdown, {
561
705
  ref: markdownRef,
562
706
  ...scrollCaptureProps,
563
- children: localContent ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_markdown_default(), {
564
- remarkPlugins: [
565
- external_remark_gfm_default(),
566
- external_remark_breaks_default()
567
- ],
568
- components: markdownComponents,
569
- children: (0, external_StickyNoteNode_utils_cjs_namespaceObject.preserveNewlines)(localContent)
570
- }) : renderPlaceholderOnSelect && selected && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_markdown_default(), {
571
- remarkPlugins: [
572
- external_remark_gfm_default(),
573
- external_remark_breaks_default()
574
- ],
575
- components: markdownComponents,
576
- children: placeholder
707
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteMediaMarkdown_cjs_namespaceObject.StickyNoteMediaMarkdownProvider, {
708
+ value: mediaMarkdownOptions,
709
+ children: localContent ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_markdown_default(), {
710
+ remarkPlugins: [
711
+ external_remark_gfm_default(),
712
+ external_remark_breaks_default()
713
+ ],
714
+ components: markdownComponents,
715
+ children: (0, external_StickyNoteNode_utils_cjs_namespaceObject.preserveNewlines)(localContent)
716
+ }) : renderPlaceholderOnSelect && selected && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_markdown_default(), {
717
+ remarkPlugins: [
718
+ external_remark_gfm_default(),
719
+ external_remark_breaks_default()
720
+ ],
721
+ components: markdownComponents,
722
+ children: placeholder
723
+ })
577
724
  })
578
725
  })
579
726
  ]
@@ -635,6 +782,11 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
635
782
  })
636
783
  })
637
784
  ]
785
+ }),
786
+ enableMediaEmbedding && mediaDialog && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteMediaDialog_cjs_namespaceObject.StickyNoteMediaDialog, {
787
+ initialMedia: mediaDialog.token?.media,
788
+ onCancel: cancelMediaDialog,
789
+ onSubmit: submitMediaDialog
638
790
  })
639
791
  ]
640
792
  });
@@ -11,8 +11,9 @@ export interface StickyNoteNodeProps extends NodeProps {
11
11
  onResize?: (width: number, height: number) => void;
12
12
  onResizeStart?: () => void;
13
13
  onResizeEnd?: () => void;
14
+ enableMediaEmbedding?: boolean;
14
15
  formattingActions?: readonly StickyNoteFormattingAction[];
15
16
  markdownComponents?: Omit<Components, 'a'>;
16
17
  }
17
- export declare const StickyNoteNode: import("react").MemoExoticComponent<({ id, data, selected, dragging, placeholder, renderPlaceholderOnSelect, readOnly, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, formattingActions, markdownComponents: customMarkdownComponents, }: StickyNoteNodeProps) => import("react/jsx-runtime").JSX.Element>;
18
+ export declare const StickyNoteNode: import("react").MemoExoticComponent<({ id, data, selected, dragging, placeholder, renderPlaceholderOnSelect, readOnly: readOnlyProp, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, enableMediaEmbedding: enableMediaEmbeddingProp, formattingActions, markdownComponents: customMarkdownComponents, }: StickyNoteNodeProps) => import("react/jsx-runtime").JSX.Element>;
18
19
  //# sourceMappingURL=StickyNoteNode.d.ts.map