@uipath/apollo-react 4.61.1 → 4.62.1

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 (21) hide show
  1. package/dist/canvas/components/StickyNoteNode/FormattingToolbar.cjs +29 -8
  2. package/dist/canvas/components/StickyNoteNode/FormattingToolbar.d.ts +7 -3
  3. package/dist/canvas/components/StickyNoteNode/FormattingToolbar.d.ts.map +1 -1
  4. package/dist/canvas/components/StickyNoteNode/FormattingToolbar.js +30 -9
  5. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.cjs +105 -20
  6. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts +5 -2
  7. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.d.ts.map +1 -1
  8. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.js +106 -21
  9. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.cjs +1 -0
  10. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.d.ts.map +1 -1
  11. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.styles.js +1 -0
  12. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts +15 -0
  13. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.types.d.ts.map +1 -1
  14. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.cjs +10 -2
  15. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.d.ts +2 -0
  16. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.d.ts.map +1 -1
  17. package/dist/canvas/components/StickyNoteNode/StickyNoteNode.utils.js +6 -1
  18. package/dist/canvas/utils/createPreviewNode.cjs +2 -2
  19. package/dist/canvas/utils/createPreviewNode.d.ts.map +1 -1
  20. package/dist/canvas/utils/createPreviewNode.js +2 -2
  21. package/package.json +1 -1
@@ -34,19 +34,14 @@ const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs
34
34
  const external_markdown_formatting_index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
35
35
  const external_StickyNoteNode_styles_cjs_namespaceObject = require("./StickyNoteNode.styles.cjs");
36
36
  const external_StickyNoteNode_utils_cjs_namespaceObject = require("./StickyNoteNode.utils.cjs");
37
- const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, onFormat })=>{
37
+ const FormattingToolbarComponent = ({ containerRef, textAreaRef, borderColor, activeFormats, onFormat, onBlur, actions = [], onAction })=>{
38
38
  const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
39
39
  const mod = (0, external_StickyNoteNode_utils_cjs_namespaceObject.getModifierKey)();
40
40
  const shift = (0, external_StickyNoteNode_utils_cjs_namespaceObject.isMac)() ? '⇧' : '+Shift+';
41
41
  const applyFormat = (0, external_react_namespaceObject.useCallback)((formatFn)=>{
42
42
  const textarea = textAreaRef.current;
43
43
  if (!textarea) return;
44
- const input = {
45
- value: textarea.value,
46
- selectionStart: textarea.selectionStart,
47
- selectionEnd: textarea.selectionEnd
48
- };
49
- onFormat(formatFn(input));
44
+ onFormat(formatFn((0, external_StickyNoteNode_utils_cjs_namespaceObject.readTextSelection)(textarea)));
50
45
  textarea.focus();
51
46
  }, [
52
47
  textAreaRef,
@@ -101,10 +96,12 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
101
96
  message: 'Text formatting'
102
97
  });
103
98
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingToolbarContainer, {
99
+ ref: containerRef,
104
100
  role: "toolbar",
105
101
  "aria-label": toolbarLabel,
106
102
  borderColor: borderColor,
107
103
  onMouseDown: (e)=>e.preventDefault(),
104
+ onBlur: onBlur,
108
105
  className: "nodrag nowheel",
109
106
  children: [
110
107
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
@@ -112,9 +109,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
112
109
  placement: "top",
113
110
  delay: true,
114
111
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
112
+ type: "button",
115
113
  isActive: activeFormats.bold,
116
114
  onClick: handleBold,
117
115
  "aria-label": boldLabel,
116
+ "aria-pressed": activeFormats.bold,
118
117
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
119
118
  icon: "bold",
120
119
  size: 14
@@ -126,9 +125,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
126
125
  placement: "top",
127
126
  delay: true,
128
127
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
128
+ type: "button",
129
129
  isActive: activeFormats.italic,
130
130
  onClick: handleItalic,
131
131
  "aria-label": italicLabel,
132
+ "aria-pressed": activeFormats.italic,
132
133
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
133
134
  icon: "italic",
134
135
  size: 14
@@ -140,9 +141,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
140
141
  placement: "top",
141
142
  delay: true,
142
143
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
144
+ type: "button",
143
145
  isActive: activeFormats.strikethrough,
144
146
  onClick: handleStrikethrough,
145
147
  "aria-label": strikethroughLabel,
148
+ "aria-pressed": activeFormats.strikethrough,
146
149
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
147
150
  icon: "strikethrough",
148
151
  size: 14
@@ -155,9 +158,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
155
158
  placement: "top",
156
159
  delay: true,
157
160
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
161
+ type: "button",
158
162
  isActive: activeFormats.bulletList,
159
163
  onClick: handleBulletList,
160
164
  "aria-label": bulletListLabel,
165
+ "aria-pressed": activeFormats.bulletList,
161
166
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
162
167
  icon: "list",
163
168
  size: 14
@@ -169,15 +174,31 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
169
174
  placement: "top",
170
175
  delay: true,
171
176
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
177
+ type: "button",
172
178
  isActive: activeFormats.numberedList,
173
179
  onClick: handleNumberedList,
174
180
  "aria-label": numberedListLabel,
181
+ "aria-pressed": activeFormats.numberedList,
175
182
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
176
183
  icon: "list-ordered",
177
184
  size: 14
178
185
  })
179
186
  })
180
- })
187
+ }),
188
+ actions.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ToolbarSeparator, {}),
189
+ actions.map((action)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
190
+ content: action.label,
191
+ placement: "top",
192
+ delay: true,
193
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
194
+ type: "button",
195
+ isActive: false,
196
+ disabled: action.disabled || !onAction,
197
+ onClick: (event)=>onAction?.(action, event.currentTarget.getBoundingClientRect()),
198
+ "aria-label": action.label,
199
+ children: action.icon
200
+ })
201
+ }, action.id))
181
202
  ]
182
203
  });
183
204
  };
@@ -1,12 +1,16 @@
1
- import { type RefObject } from 'react';
1
+ import { type FocusEvent, type RefObject } from 'react';
2
2
  import type { ActiveFormats } from './markdown-formatting';
3
- import type { TextSelection } from './StickyNoteNode.types';
3
+ import type { StickyNoteFormattingAction, TextSelection } from './StickyNoteNode.types';
4
4
  interface FormattingToolbarProps {
5
+ containerRef?: RefObject<HTMLDivElement | null>;
5
6
  textAreaRef: RefObject<HTMLTextAreaElement | null>;
6
7
  borderColor: string;
7
8
  activeFormats: ActiveFormats;
8
9
  onFormat: (result: TextSelection) => void;
10
+ onBlur?: (event: FocusEvent<HTMLDivElement>) => void;
11
+ actions?: readonly StickyNoteFormattingAction[];
12
+ onAction?: (action: StickyNoteFormattingAction, anchorRect: DOMRectReadOnly) => void;
9
13
  }
10
- export declare const FormattingToolbar: import("react").MemoExoticComponent<({ textAreaRef, borderColor, activeFormats, onFormat, }: FormattingToolbarProps) => import("react/jsx-runtime").JSX.Element>;
14
+ export declare const FormattingToolbar: import("react").MemoExoticComponent<({ containerRef, textAreaRef, borderColor, activeFormats, onFormat, onBlur, actions, onAction, }: FormattingToolbarProps) => import("react/jsx-runtime").JSX.Element>;
11
15
  export {};
12
16
  //# sourceMappingURL=FormattingToolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FormattingToolbar.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/FormattingToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AAG1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAa3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,UAAU,sBAAsB;IAC9B,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C;AAwHD,eAAO,MAAM,iBAAiB,+FAjH3B,sBAAsB,6CAiHwC,CAAC"}
1
+ {"version":3,"file":"FormattingToolbar.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/FormattingToolbar.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAQ,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AAG3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAa3D,OAAO,KAAK,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGxF,UAAU,sBAAsB;IAC9B,YAAY,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAChD,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACrD,OAAO,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;IAChD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,0BAA0B,EAAE,UAAU,EAAE,eAAe,KAAK,IAAI,CAAC;CACtF;AAqJD,eAAO,MAAM,iBAAiB,wIA1I3B,sBAAsB,6CA0IwC,CAAC"}
@@ -5,20 +5,15 @@ import { useSafeLingui } from "../../../i18n/index.js";
5
5
  import { CanvasTooltip } from "../CanvasTooltip.js";
6
6
  import { toggleBold, toggleBulletList, toggleItalic, toggleNumberedList, toggleStrikethrough } from "./markdown-formatting/index.js";
7
7
  import { FormattingButton, FormattingToolbarContainer, ToolbarSeparator } from "./StickyNoteNode.styles.js";
8
- import { getModifierKey, isMac } from "./StickyNoteNode.utils.js";
9
- const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, onFormat })=>{
8
+ import { getModifierKey, isMac, readTextSelection } from "./StickyNoteNode.utils.js";
9
+ const FormattingToolbarComponent = ({ containerRef, textAreaRef, borderColor, activeFormats, onFormat, onBlur, actions = [], onAction })=>{
10
10
  const { _ } = useSafeLingui();
11
11
  const mod = getModifierKey();
12
12
  const shift = isMac() ? '⇧' : '+Shift+';
13
13
  const applyFormat = useCallback((formatFn)=>{
14
14
  const textarea = textAreaRef.current;
15
15
  if (!textarea) return;
16
- const input = {
17
- value: textarea.value,
18
- selectionStart: textarea.selectionStart,
19
- selectionEnd: textarea.selectionEnd
20
- };
21
- onFormat(formatFn(input));
16
+ onFormat(formatFn(readTextSelection(textarea)));
22
17
  textarea.focus();
23
18
  }, [
24
19
  textAreaRef,
@@ -73,10 +68,12 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
73
68
  message: 'Text formatting'
74
69
  });
75
70
  return /*#__PURE__*/ jsxs(FormattingToolbarContainer, {
71
+ ref: containerRef,
76
72
  role: "toolbar",
77
73
  "aria-label": toolbarLabel,
78
74
  borderColor: borderColor,
79
75
  onMouseDown: (e)=>e.preventDefault(),
76
+ onBlur: onBlur,
80
77
  className: "nodrag nowheel",
81
78
  children: [
82
79
  /*#__PURE__*/ jsx(CanvasTooltip, {
@@ -84,9 +81,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
84
81
  placement: "top",
85
82
  delay: true,
86
83
  children: /*#__PURE__*/ jsx(FormattingButton, {
84
+ type: "button",
87
85
  isActive: activeFormats.bold,
88
86
  onClick: handleBold,
89
87
  "aria-label": boldLabel,
88
+ "aria-pressed": activeFormats.bold,
90
89
  children: /*#__PURE__*/ jsx(CanvasIcon, {
91
90
  icon: "bold",
92
91
  size: 14
@@ -98,9 +97,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
98
97
  placement: "top",
99
98
  delay: true,
100
99
  children: /*#__PURE__*/ jsx(FormattingButton, {
100
+ type: "button",
101
101
  isActive: activeFormats.italic,
102
102
  onClick: handleItalic,
103
103
  "aria-label": italicLabel,
104
+ "aria-pressed": activeFormats.italic,
104
105
  children: /*#__PURE__*/ jsx(CanvasIcon, {
105
106
  icon: "italic",
106
107
  size: 14
@@ -112,9 +113,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
112
113
  placement: "top",
113
114
  delay: true,
114
115
  children: /*#__PURE__*/ jsx(FormattingButton, {
116
+ type: "button",
115
117
  isActive: activeFormats.strikethrough,
116
118
  onClick: handleStrikethrough,
117
119
  "aria-label": strikethroughLabel,
120
+ "aria-pressed": activeFormats.strikethrough,
118
121
  children: /*#__PURE__*/ jsx(CanvasIcon, {
119
122
  icon: "strikethrough",
120
123
  size: 14
@@ -127,9 +130,11 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
127
130
  placement: "top",
128
131
  delay: true,
129
132
  children: /*#__PURE__*/ jsx(FormattingButton, {
133
+ type: "button",
130
134
  isActive: activeFormats.bulletList,
131
135
  onClick: handleBulletList,
132
136
  "aria-label": bulletListLabel,
137
+ "aria-pressed": activeFormats.bulletList,
133
138
  children: /*#__PURE__*/ jsx(CanvasIcon, {
134
139
  icon: "list",
135
140
  size: 14
@@ -141,15 +146,31 @@ const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, o
141
146
  placement: "top",
142
147
  delay: true,
143
148
  children: /*#__PURE__*/ jsx(FormattingButton, {
149
+ type: "button",
144
150
  isActive: activeFormats.numberedList,
145
151
  onClick: handleNumberedList,
146
152
  "aria-label": numberedListLabel,
153
+ "aria-pressed": activeFormats.numberedList,
147
154
  children: /*#__PURE__*/ jsx(CanvasIcon, {
148
155
  icon: "list-ordered",
149
156
  size: 14
150
157
  })
151
158
  })
152
- })
159
+ }),
160
+ actions.length > 0 && /*#__PURE__*/ jsx(ToolbarSeparator, {}),
161
+ actions.map((action)=>/*#__PURE__*/ jsx(CanvasTooltip, {
162
+ content: action.label,
163
+ placement: "top",
164
+ delay: true,
165
+ children: /*#__PURE__*/ jsx(FormattingButton, {
166
+ type: "button",
167
+ isActive: false,
168
+ disabled: action.disabled || !onAction,
169
+ onClick: (event)=>onAction?.(action, event.currentTarget.getBoundingClientRect()),
170
+ "aria-label": action.label,
171
+ children: action.icon
172
+ })
173
+ }, action.id))
153
174
  ]
154
175
  });
155
176
  };
@@ -63,7 +63,7 @@ const external_useMarkdownShortcuts_cjs_namespaceObject = require("./useMarkdown
63
63
  const external_useScrollCapture_cjs_namespaceObject = require("./useScrollCapture.cjs");
64
64
  const minWidth = 8 * external_constants_cjs_namespaceObject.GRID_SPACING;
65
65
  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 })=>{
66
+ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, formattingActions, markdownComponents: customMarkdownComponents })=>{
67
67
  const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
68
68
  const { updateNodeData, deleteElements } = (0, react_cjs_namespaceObject.useReactFlow)();
69
69
  const { multipleNodesSelected } = (0, SelectionStateContext_cjs_namespaceObject.useSelectionState)();
@@ -71,7 +71,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
71
71
  const [isResizing, setIsResizing] = (0, external_react_namespaceObject.useState)(false);
72
72
  const [isColorPickerOpen, setIsColorPickerOpen] = (0, external_react_namespaceObject.useState)(false);
73
73
  const [localContent, setLocalContent] = (0, external_react_namespaceObject.useState)(data.content || '');
74
+ const latestContentRef = (0, external_react_namespaceObject.useRef)(localContent);
74
75
  const textAreaRef = (0, external_react_namespaceObject.useRef)(null);
76
+ const formattingToolbarRef = (0, external_react_namespaceObject.useRef)(null);
75
77
  const skipBlurRef = (0, external_react_namespaceObject.useRef)(null);
76
78
  const { ref: markdownRef, scrollCaptureProps } = (0, external_useScrollCapture_cjs_namespaceObject.useScrollCapture)();
77
79
  const colorButtonRef = (0, external_react_namespaceObject.useRef)(null);
@@ -85,10 +87,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
85
87
  const colorKey = data.color || 'yellow';
86
88
  const color = external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS[colorKey] ?? external_StickyNoteNode_types_cjs_namespaceObject.STICKY_NOTE_COLORS.yellow;
87
89
  const colorWithAlpha = (0, external_StickyNoteNode_types_cjs_namespaceObject.withAlpha)(color);
90
+ const updateLocalContent = (0, external_react_namespaceObject.useCallback)((content)=>{
91
+ latestContentRef.current = content;
92
+ setLocalContent(content);
93
+ }, []);
88
94
  (0, external_react_namespaceObject.useEffect)(()=>{
89
- setLocalContent(data.content || '');
95
+ updateLocalContent(data.content || '');
90
96
  }, [
91
- data.content
97
+ data.content,
98
+ updateLocalContent
92
99
  ]);
93
100
  (0, external_react_namespaceObject.useEffect)(()=>{
94
101
  if (isEditing && textAreaRef.current) {
@@ -116,11 +123,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
116
123
  (0, external_react_namespaceObject.useEffect)(()=>{
117
124
  if (readOnly) {
118
125
  setIsEditing(false);
119
- setLocalContent(data.content || '');
126
+ updateLocalContent(data.content || '');
120
127
  }
121
128
  }, [
122
129
  readOnly,
123
- data.content
130
+ data.content,
131
+ updateLocalContent
124
132
  ]);
125
133
  const handleDoubleClick = (0, external_react_namespaceObject.useCallback)(()=>{
126
134
  if (readOnly || isEditing) return;
@@ -135,7 +143,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
135
143
  isEditing,
136
144
  readOnly
137
145
  ]);
138
- const handleBlur = (0, external_react_namespaceObject.useCallback)(()=>{
146
+ const handleBlur = (0, external_react_namespaceObject.useCallback)((event)=>{
147
+ const nextTarget = event.relatedTarget;
148
+ if (nextTarget instanceof Node && (textAreaRef.current?.contains(nextTarget) || formattingToolbarRef.current?.contains(nextTarget))) return;
139
149
  setIsEditing(false);
140
150
  if (readOnly) return;
141
151
  const content = textAreaRef.current?.value ?? localContent;
@@ -159,10 +169,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
159
169
  ]);
160
170
  const handleChange = (0, external_react_namespaceObject.useCallback)((e)=>{
161
171
  skipBlurRef.current = null;
162
- setLocalContent(e.target.value);
163
- }, []);
172
+ updateLocalContent(e.target.value);
173
+ }, [
174
+ updateLocalContent
175
+ ]);
164
176
  const handleFormat = (0, external_react_namespaceObject.useCallback)((result)=>{
165
- setLocalContent(result.value);
177
+ updateLocalContent(result.value);
166
178
  setActiveFormats((0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)(result));
167
179
  requestAnimationFrame(()=>{
168
180
  if (textAreaRef.current) {
@@ -170,7 +182,68 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
170
182
  textAreaRef.current.selectionEnd = result.selectionEnd;
171
183
  }
172
184
  });
173
- }, []);
185
+ }, [
186
+ updateLocalContent
187
+ ]);
188
+ const handleFormattingAction = (0, external_react_namespaceObject.useCallback)((action, anchorRect)=>{
189
+ const textarea = textAreaRef.current;
190
+ if (!textarea) return;
191
+ const selection = (0, external_StickyNoteNode_utils_cjs_namespaceObject.readTextSelection)(textarea);
192
+ skipBlurRef.current = selection.value;
193
+ let completed = false;
194
+ const restoreSelection = (next)=>{
195
+ setIsEditing(true);
196
+ requestAnimationFrame(()=>{
197
+ const currentTextarea = textAreaRef.current;
198
+ if (!currentTextarea) return;
199
+ const length = next.value.length;
200
+ currentTextarea.focus();
201
+ currentTextarea.selectionStart = Math.max(0, Math.min(length, next.selectionStart));
202
+ currentTextarea.selectionEnd = Math.max(0, Math.min(length, next.selectionEnd));
203
+ });
204
+ };
205
+ const complete = (next, shouldPersist)=>{
206
+ if (completed) return;
207
+ completed = true;
208
+ skipBlurRef.current = shouldPersist ? next.value : null;
209
+ setActiveFormats((0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)(next));
210
+ if (shouldPersist) {
211
+ updateLocalContent(next.value);
212
+ onContentChange?.(next.value);
213
+ updateNodeData(id, {
214
+ content: next.value
215
+ });
216
+ }
217
+ restoreSelection(next);
218
+ };
219
+ try {
220
+ action.onAction({
221
+ selection,
222
+ anchorRect,
223
+ currentValue: ()=>textAreaRef.current?.value ?? latestContentRef.current,
224
+ commit: (next)=>complete(next, true),
225
+ resume: ()=>{
226
+ const currentValue = textAreaRef.current?.value ?? latestContentRef.current;
227
+ complete({
228
+ ...selection,
229
+ value: currentValue
230
+ }, false);
231
+ }
232
+ });
233
+ } catch (error) {
234
+ if (!completed) {
235
+ completed = true;
236
+ skipBlurRef.current = null;
237
+ restoreSelection(selection);
238
+ }
239
+ throw error;
240
+ }
241
+ }, [
242
+ id,
243
+ onContentChange,
244
+ updateLocalContent,
245
+ updateNodeData
246
+ ]);
174
247
  const updateActiveFormats = (0, external_react_namespaceObject.useCallback)(()=>{
175
248
  if (!textAreaRef.current) return;
176
249
  const next = (0, external_markdown_formatting_index_cjs_namespaceObject.detectActiveFormats)({
@@ -185,7 +258,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
185
258
  if ('Escape' === e.key) {
186
259
  skipBlurRef.current = textAreaRef.current?.value ?? localContent;
187
260
  setIsEditing(false);
188
- setLocalContent(data.content || '');
261
+ updateLocalContent(data.content || '');
189
262
  textAreaRef.current?.blur();
190
263
  return;
191
264
  }
@@ -209,7 +282,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
209
282
  data.content,
210
283
  localContent,
211
284
  shortcutKeyDown,
212
- handleFormat
285
+ handleFormat,
286
+ updateLocalContent
213
287
  ]);
214
288
  const handleResizeStart = (0, external_react_namespaceObject.useCallback)(()=>{
215
289
  if (isEditing) {
@@ -283,8 +357,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
283
357
  id,
284
358
  deleteElements
285
359
  ]);
286
- const markdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
287
- a: ({ href, children, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
360
+ const builtInMarkdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
361
+ a: ({ node: _node, href, children, ...props })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
288
362
  ...props,
289
363
  href: href,
290
364
  target: "_blank",
@@ -298,6 +372,13 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
298
372
  children: children
299
373
  })
300
374
  }), []);
375
+ const markdownComponents = (0, external_react_namespaceObject.useMemo)(()=>({
376
+ ...customMarkdownComponents,
377
+ ...builtInMarkdownComponents
378
+ }), [
379
+ builtInMarkdownComponents,
380
+ customMarkdownComponents
381
+ ]);
301
382
  const toolbarConfig = (0, external_react_namespaceObject.useMemo)(()=>{
302
383
  const actions = [
303
384
  {
@@ -453,12 +534,6 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
453
534
  }),
454
535
  isEditing ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
455
536
  children: [
456
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FormattingToolbar_cjs_namespaceObject.FormattingToolbar, {
457
- textAreaRef: textAreaRef,
458
- borderColor: color,
459
- activeFormats: activeFormats,
460
- onFormat: handleFormat
461
- }),
462
537
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteTextArea, {
463
538
  ref: textAreaRef,
464
539
  value: localContent,
@@ -470,6 +545,16 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
470
545
  placeholder: placeholder,
471
546
  isEditing: isEditing,
472
547
  className: "nodrag nowheel"
548
+ }),
549
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FormattingToolbar_cjs_namespaceObject.FormattingToolbar, {
550
+ containerRef: formattingToolbarRef,
551
+ textAreaRef: textAreaRef,
552
+ borderColor: color,
553
+ activeFormats: activeFormats,
554
+ onFormat: handleFormat,
555
+ onBlur: handleBlur,
556
+ actions: formattingActions,
557
+ onAction: handleFormattingAction
473
558
  })
474
559
  ]
475
560
  }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.StickyNoteMarkdown, {
@@ -1,5 +1,6 @@
1
1
  import type { NodeProps } from '../../xyflow/react.ts';
2
- import type { StickyNoteColor, StickyNoteData } from './StickyNoteNode.types';
2
+ import { type Components } from 'react-markdown';
3
+ import type { StickyNoteColor, StickyNoteData, StickyNoteFormattingAction } from './StickyNoteNode.types';
3
4
  export interface StickyNoteNodeProps extends NodeProps {
4
5
  data: StickyNoteData;
5
6
  placeholder?: string;
@@ -10,6 +11,8 @@ export interface StickyNoteNodeProps extends NodeProps {
10
11
  onResize?: (width: number, height: number) => void;
11
12
  onResizeStart?: () => void;
12
13
  onResizeEnd?: () => void;
14
+ formattingActions?: readonly StickyNoteFormattingAction[];
15
+ markdownComponents?: Omit<Components, 'a'>;
13
16
  }
14
- export declare const StickyNoteNode: import("react").MemoExoticComponent<({ id, data, selected, dragging, placeholder, renderPlaceholderOnSelect, readOnly, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, }: StickyNoteNodeProps) => import("react/jsx-runtime").JSX.Element>;
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>;
15
18
  //# sourceMappingURL=StickyNoteNode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAoC1E,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAiB,MAAM,wBAAwB,CAAC;AAM7F,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AA4cD,eAAO,MAAM,cAAc,kMA1bxB,mBAAmB,6CA0bwE,CAAC"}
1
+ {"version":3,"file":"StickyNoteNode.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAM1E,OAAsB,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA8BhE,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,0BAA0B,EAE3B,MAAM,wBAAwB,CAAC;AAMhC,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,iBAAiB,CAAC,EAAE,SAAS,0BAA0B,EAAE,CAAC;IAC1D,kBAAkB,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;CAC5C;AA0iBD,eAAO,MAAM,cAAc,mQAthBxB,mBAAmB,6CAshBwE,CAAC"}
@@ -18,12 +18,12 @@ import { FormattingToolbar } from "./FormattingToolbar.js";
18
18
  import { activeFormatsEqual, continueListOnEnter, detectActiveFormats } from "./markdown-formatting/index.js";
19
19
  import { BottomCornerIndicators, ColorOption, ColorPickerPanel, RESIZE_CONTROL_Z_INDEX, ResizeHandle, StickyNoteContainer, StickyNoteMarkdown, StickyNoteTextArea, StickyNoteWrapper, TopCornerIndicators, stickyNoteGlobalStyles } from "./StickyNoteNode.styles.js";
20
20
  import { STICKY_NOTE_COLORS, withAlpha } from "./StickyNoteNode.types.js";
21
- import { preserveNewlines } from "./StickyNoteNode.utils.js";
21
+ import { preserveNewlines, readTextSelection } from "./StickyNoteNode.utils.js";
22
22
  import { useMarkdownShortcuts } from "./useMarkdownShortcuts.js";
23
23
  import { useScrollCapture } from "./useScrollCapture.js";
24
24
  const minWidth = 8 * GRID_SPACING;
25
25
  const minHeight = 8 * GRID_SPACING;
26
- const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd })=>{
26
+ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = 'Add text', renderPlaceholderOnSelect = false, readOnly = false, onContentChange, onColorChange, onResize, onResizeStart, onResizeEnd, formattingActions, markdownComponents: customMarkdownComponents })=>{
27
27
  const { _ } = useSafeLingui();
28
28
  const { updateNodeData, deleteElements } = useReactFlow();
29
29
  const { multipleNodesSelected } = useSelectionState();
@@ -31,7 +31,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
31
31
  const [isResizing, setIsResizing] = useState(false);
32
32
  const [isColorPickerOpen, setIsColorPickerOpen] = useState(false);
33
33
  const [localContent, setLocalContent] = useState(data.content || '');
34
+ const latestContentRef = useRef(localContent);
34
35
  const textAreaRef = useRef(null);
36
+ const formattingToolbarRef = useRef(null);
35
37
  const skipBlurRef = useRef(null);
36
38
  const { ref: markdownRef, scrollCaptureProps } = useScrollCapture();
37
39
  const colorButtonRef = useRef(null);
@@ -45,10 +47,15 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
45
47
  const colorKey = data.color || 'yellow';
46
48
  const color = STICKY_NOTE_COLORS[colorKey] ?? STICKY_NOTE_COLORS.yellow;
47
49
  const colorWithAlpha = withAlpha(color);
50
+ const updateLocalContent = useCallback((content)=>{
51
+ latestContentRef.current = content;
52
+ setLocalContent(content);
53
+ }, []);
48
54
  useEffect(()=>{
49
- setLocalContent(data.content || '');
55
+ updateLocalContent(data.content || '');
50
56
  }, [
51
- data.content
57
+ data.content,
58
+ updateLocalContent
52
59
  ]);
53
60
  useEffect(()=>{
54
61
  if (isEditing && textAreaRef.current) {
@@ -76,11 +83,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
76
83
  useEffect(()=>{
77
84
  if (readOnly) {
78
85
  setIsEditing(false);
79
- setLocalContent(data.content || '');
86
+ updateLocalContent(data.content || '');
80
87
  }
81
88
  }, [
82
89
  readOnly,
83
- data.content
90
+ data.content,
91
+ updateLocalContent
84
92
  ]);
85
93
  const handleDoubleClick = useCallback(()=>{
86
94
  if (readOnly || isEditing) return;
@@ -95,7 +103,9 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
95
103
  isEditing,
96
104
  readOnly
97
105
  ]);
98
- const handleBlur = useCallback(()=>{
106
+ const handleBlur = useCallback((event)=>{
107
+ const nextTarget = event.relatedTarget;
108
+ if (nextTarget instanceof Node && (textAreaRef.current?.contains(nextTarget) || formattingToolbarRef.current?.contains(nextTarget))) return;
99
109
  setIsEditing(false);
100
110
  if (readOnly) return;
101
111
  const content = textAreaRef.current?.value ?? localContent;
@@ -119,10 +129,12 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
119
129
  ]);
120
130
  const handleChange = useCallback((e)=>{
121
131
  skipBlurRef.current = null;
122
- setLocalContent(e.target.value);
123
- }, []);
132
+ updateLocalContent(e.target.value);
133
+ }, [
134
+ updateLocalContent
135
+ ]);
124
136
  const handleFormat = useCallback((result)=>{
125
- setLocalContent(result.value);
137
+ updateLocalContent(result.value);
126
138
  setActiveFormats(detectActiveFormats(result));
127
139
  requestAnimationFrame(()=>{
128
140
  if (textAreaRef.current) {
@@ -130,7 +142,68 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
130
142
  textAreaRef.current.selectionEnd = result.selectionEnd;
131
143
  }
132
144
  });
133
- }, []);
145
+ }, [
146
+ updateLocalContent
147
+ ]);
148
+ const handleFormattingAction = useCallback((action, anchorRect)=>{
149
+ const textarea = textAreaRef.current;
150
+ if (!textarea) return;
151
+ const selection = readTextSelection(textarea);
152
+ skipBlurRef.current = selection.value;
153
+ let completed = false;
154
+ const restoreSelection = (next)=>{
155
+ setIsEditing(true);
156
+ requestAnimationFrame(()=>{
157
+ const currentTextarea = textAreaRef.current;
158
+ if (!currentTextarea) return;
159
+ const length = next.value.length;
160
+ currentTextarea.focus();
161
+ currentTextarea.selectionStart = Math.max(0, Math.min(length, next.selectionStart));
162
+ currentTextarea.selectionEnd = Math.max(0, Math.min(length, next.selectionEnd));
163
+ });
164
+ };
165
+ const complete = (next, shouldPersist)=>{
166
+ if (completed) return;
167
+ completed = true;
168
+ skipBlurRef.current = shouldPersist ? next.value : null;
169
+ setActiveFormats(detectActiveFormats(next));
170
+ if (shouldPersist) {
171
+ updateLocalContent(next.value);
172
+ onContentChange?.(next.value);
173
+ updateNodeData(id, {
174
+ content: next.value
175
+ });
176
+ }
177
+ restoreSelection(next);
178
+ };
179
+ try {
180
+ action.onAction({
181
+ selection,
182
+ anchorRect,
183
+ currentValue: ()=>textAreaRef.current?.value ?? latestContentRef.current,
184
+ commit: (next)=>complete(next, true),
185
+ resume: ()=>{
186
+ const currentValue = textAreaRef.current?.value ?? latestContentRef.current;
187
+ complete({
188
+ ...selection,
189
+ value: currentValue
190
+ }, false);
191
+ }
192
+ });
193
+ } catch (error) {
194
+ if (!completed) {
195
+ completed = true;
196
+ skipBlurRef.current = null;
197
+ restoreSelection(selection);
198
+ }
199
+ throw error;
200
+ }
201
+ }, [
202
+ id,
203
+ onContentChange,
204
+ updateLocalContent,
205
+ updateNodeData
206
+ ]);
134
207
  const updateActiveFormats = useCallback(()=>{
135
208
  if (!textAreaRef.current) return;
136
209
  const next = detectActiveFormats({
@@ -145,7 +218,7 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
145
218
  if ('Escape' === e.key) {
146
219
  skipBlurRef.current = textAreaRef.current?.value ?? localContent;
147
220
  setIsEditing(false);
148
- setLocalContent(data.content || '');
221
+ updateLocalContent(data.content || '');
149
222
  textAreaRef.current?.blur();
150
223
  return;
151
224
  }
@@ -169,7 +242,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
169
242
  data.content,
170
243
  localContent,
171
244
  shortcutKeyDown,
172
- handleFormat
245
+ handleFormat,
246
+ updateLocalContent
173
247
  ]);
174
248
  const handleResizeStart = useCallback(()=>{
175
249
  if (isEditing) {
@@ -243,8 +317,8 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
243
317
  id,
244
318
  deleteElements
245
319
  ]);
246
- const markdownComponents = useMemo(()=>({
247
- a: ({ href, children, ...props })=>/*#__PURE__*/ jsx("a", {
320
+ const builtInMarkdownComponents = useMemo(()=>({
321
+ a: ({ node: _node, href, children, ...props })=>/*#__PURE__*/ jsx("a", {
248
322
  ...props,
249
323
  href: href,
250
324
  target: "_blank",
@@ -258,6 +332,13 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
258
332
  children: children
259
333
  })
260
334
  }), []);
335
+ const markdownComponents = useMemo(()=>({
336
+ ...customMarkdownComponents,
337
+ ...builtInMarkdownComponents
338
+ }), [
339
+ builtInMarkdownComponents,
340
+ customMarkdownComponents
341
+ ]);
261
342
  const toolbarConfig = useMemo(()=>{
262
343
  const actions = [
263
344
  {
@@ -413,12 +494,6 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
413
494
  }),
414
495
  isEditing ? /*#__PURE__*/ jsxs(Fragment, {
415
496
  children: [
416
- /*#__PURE__*/ jsx(FormattingToolbar, {
417
- textAreaRef: textAreaRef,
418
- borderColor: color,
419
- activeFormats: activeFormats,
420
- onFormat: handleFormat
421
- }),
422
497
  /*#__PURE__*/ jsx(StickyNoteTextArea, {
423
498
  ref: textAreaRef,
424
499
  value: localContent,
@@ -430,6 +505,16 @@ const StickyNoteNodeComponent = ({ id, data, selected, dragging, placeholder = '
430
505
  placeholder: placeholder,
431
506
  isEditing: isEditing,
432
507
  className: "nodrag nowheel"
508
+ }),
509
+ /*#__PURE__*/ jsx(FormattingToolbar, {
510
+ containerRef: formattingToolbarRef,
511
+ textAreaRef: textAreaRef,
512
+ borderColor: color,
513
+ activeFormats: activeFormats,
514
+ onFormat: handleFormat,
515
+ onBlur: handleBlur,
516
+ actions: formattingActions,
517
+ onAction: handleFormattingAction
433
518
  })
434
519
  ]
435
520
  }) : /*#__PURE__*/ jsx(StickyNoteMarkdown, {
@@ -372,6 +372,7 @@ const ColorOption = styled_default().button`
372
372
  }
373
373
  `;
374
374
  const FormattingToolbarContainer = styled_default().div`
375
+ order: -1;
375
376
  display: flex;
376
377
  align-items: center;
377
378
  gap: 1px;
@@ -1 +1 @@
1
- {"version":3,"file":"StickyNoteNode.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,8BAA8B,MAAM,CAAC;AA4BlD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,sBAAsB,2CAOlC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;yGAI7B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;iBACjB,MAAM;qBACF,MAAM;eACZ,OAAO;eACP,OAAO;iBACL,OAAO;yGAuBrB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;eAAgC,OAAO;2HAsBrE,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;yGA8H9B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;eAA2B,OAAO;aAAW,MAAM;yGAW3E,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;cAA0B,OAAO;yGA+BhE,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;cAA0B,OAAO;yGA+BnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;UAa5B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;WAA0B,MAAM;gBAAc,OAAO;qHAkB5E,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;iBAA6B,MAAM;yGAQzE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;cAA6B,OAAO;qHAoBhE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;yGAK5B,CAAC"}
1
+ {"version":3,"file":"StickyNoteNode.styles.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,8BAA8B,MAAM,CAAC;AA4BlD,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,eAAO,MAAM,sBAAsB,2CAOlC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;yGAI7B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;iBACjB,MAAM;qBACF,MAAM;eACZ,OAAO;eACP,OAAO;iBACL,OAAO;yGAuBrB,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;eAAgC,OAAO;2HAsBrE,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;yGA8H9B,CAAC;AAEF,eAAO,MAAM,YAAY;;;;eAA2B,OAAO;aAAW,MAAM;yGAW3E,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;cAA0B,OAAO;yGA+BhE,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;cAA0B,OAAO;yGA+BnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;UAa5B,CAAC;AAEF,eAAO,MAAM,WAAW;;;;WAA0B,MAAM;gBAAc,OAAO;qHAkB5E,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;iBAA6B,MAAM;yGASzE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;cAA6B,OAAO;qHAoBhE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;yGAK5B,CAAC"}
@@ -320,6 +320,7 @@ const ColorOption = styled.button`
320
320
  }
321
321
  `;
322
322
  const FormattingToolbarContainer = styled.div`
323
+ order: -1;
323
324
  display: flex;
324
325
  align-items: center;
325
326
  gap: 1px;
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from 'react';
1
2
  export declare const STICKY_NOTE_COLORS: {
2
3
  readonly blue: "#42A1FF";
3
4
  readonly green: "#6EB84A";
@@ -17,5 +18,19 @@ export type TextSelection = {
17
18
  selectionStart: number;
18
19
  selectionEnd: number;
19
20
  };
21
+ export interface StickyNoteEditorActionContext {
22
+ selection: TextSelection;
23
+ anchorRect: DOMRectReadOnly;
24
+ currentValue(): string;
25
+ commit(next: TextSelection): void;
26
+ resume(): void;
27
+ }
28
+ export interface StickyNoteFormattingAction {
29
+ id: string;
30
+ icon: ReactNode;
31
+ label: string;
32
+ disabled?: boolean;
33
+ onAction(context: StickyNoteEditorActionContext): void;
34
+ }
20
35
  export type FormattingAction = 'bold' | 'italic' | 'strikethrough' | 'bulletList' | 'numberedList';
21
36
  //# sourceMappingURL=StickyNoteNode.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StickyNoteNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.types.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE9D,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAWD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAA6B,GAAG,MAAM,CAyBnF;AAGD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,CAAC"}
1
+ {"version":3,"file":"StickyNoteNode.types.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE9D,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAWD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,GAAE,MAA6B,GAAG,MAAM,CAyBnF;AAGD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF,MAAM,WAAW,6BAA6B;IAE5C,SAAS,EAAE,aAAa,CAAC;IAEzB,UAAU,EAAE,eAAe,CAAC;IAE5B,YAAY,IAAI,MAAM,CAAC;IAEvB,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;IAElC,MAAM,IAAI,IAAI,CAAC;CAChB;AAGD,MAAM,WAAW,0BAA0B;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAAC;CACxD;AAGD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,GAAG,YAAY,GAAG,cAAc,CAAC"}
@@ -26,8 +26,14 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  getModifierKey: ()=>getModifierKey,
28
28
  isMac: ()=>isMac,
29
- preserveNewlines: ()=>preserveNewlines
29
+ preserveNewlines: ()=>preserveNewlines,
30
+ readTextSelection: ()=>readTextSelection
30
31
  });
32
+ const readTextSelection = (textarea)=>({
33
+ value: textarea.value,
34
+ selectionStart: textarea.selectionStart,
35
+ selectionEnd: textarea.selectionEnd
36
+ });
31
37
  const preserveNewlines = (markdown)=>{
32
38
  const codeBlocks = [];
33
39
  let result = markdown.replace(/```[\s\S]*?```/g, (m)=>{
@@ -46,10 +52,12 @@ const getModifierKey = ()=>isMac() ? '⌘' : 'Ctrl';
46
52
  exports.getModifierKey = __webpack_exports__.getModifierKey;
47
53
  exports.isMac = __webpack_exports__.isMac;
48
54
  exports.preserveNewlines = __webpack_exports__.preserveNewlines;
55
+ exports.readTextSelection = __webpack_exports__.readTextSelection;
49
56
  for(var __rspack_i in __webpack_exports__)if (-1 === [
50
57
  "getModifierKey",
51
58
  "isMac",
52
- "preserveNewlines"
59
+ "preserveNewlines",
60
+ "readTextSelection"
53
61
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
54
62
  Object.defineProperty(exports, '__esModule', {
55
63
  value: true
@@ -1,3 +1,5 @@
1
+ import type { TextSelection } from './StickyNoteNode.types';
2
+ export declare const readTextSelection: (textarea: HTMLTextAreaElement) => TextSelection;
1
3
  export declare const preserveNewlines: (markdown: string) => string;
2
4
  export declare const isMac: () => boolean;
3
5
  export declare const getModifierKey: () => string;
@@ -1 +1 @@
1
- {"version":3,"file":"StickyNoteNode.utils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,KAAG,MAqBnD,CAAC;AAOF,eAAO,MAAM,KAAK,QAAO,OAExB,CAAC;AAOF,eAAO,MAAM,cAAc,QAAO,MAEjC,CAAC"}
1
+ {"version":3,"file":"StickyNoteNode.utils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/StickyNoteNode/StickyNoteNode.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,eAAO,MAAM,iBAAiB,GAAI,UAAU,mBAAmB,KAAG,aAIhE,CAAC;AAIH,eAAO,MAAM,gBAAgB,GAAI,UAAU,MAAM,KAAG,MAqBnD,CAAC;AAOF,eAAO,MAAM,KAAK,QAAO,OAExB,CAAC;AAOF,eAAO,MAAM,cAAc,QAAO,MAEjC,CAAC"}
@@ -1,3 +1,8 @@
1
+ const readTextSelection = (textarea)=>({
2
+ value: textarea.value,
3
+ selectionStart: textarea.selectionStart,
4
+ selectionEnd: textarea.selectionEnd
5
+ });
1
6
  const preserveNewlines = (markdown)=>{
2
7
  const codeBlocks = [];
3
8
  let result = markdown.replace(/```[\s\S]*?```/g, (m)=>{
@@ -13,4 +18,4 @@ const preserveNewlines = (markdown)=>{
13
18
  };
14
19
  const isMac = ()=>"u" > typeof navigator && navigator.platform.includes('Mac');
15
20
  const getModifierKey = ()=>isMac() ? '⌘' : 'Ctrl';
16
- export { getModifierKey, isMac, preserveNewlines };
21
+ export { getModifierKey, isMac, preserveNewlines, readTextSelection };
@@ -229,8 +229,8 @@ function applyPreviewToReactFlow(preview, reactFlowInstance) {
229
229
  }, 0);
230
230
  }
231
231
  function removePreviewFromReactFlow(reactFlowInstance) {
232
- reactFlowInstance.setNodes((nodes)=>nodes.filter((n)=>n.id !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID));
233
- reactFlowInstance.setEdges((edges)=>edges.filter((edge)=>!isPreviewEdge(edge)));
232
+ if (reactFlowInstance.getNodes().some((n)=>n.id === external_constants_cjs_namespaceObject.PREVIEW_NODE_ID)) reactFlowInstance.setNodes((nodes)=>nodes.filter((n)=>n.id !== external_constants_cjs_namespaceObject.PREVIEW_NODE_ID));
233
+ if (reactFlowInstance.getEdges().some((edge)=>isPreviewEdge(edge))) reactFlowInstance.setEdges((edges)=>edges.filter((edge)=>!isPreviewEdge(edge)));
234
234
  }
235
235
  exports.PREVIEW_EDGE_STYLE = __webpack_exports__.PREVIEW_EDGE_STYLE;
236
236
  exports.applyPreviewToReactFlow = __webpack_exports__.applyPreviewToReactFlow;
@@ -1 +1 @@
1
- {"version":3,"file":"createPreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAGL,KAAK,sBAAsB,EAG5B,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAK5C,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAM9F;AAMD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAahE;AAqLD,MAAM,WAAW,wBAAwB;IAEvC,YAAY,EAAE,MAAM,CAAC;IAErB,cAAc,EAAE,MAAM,CAAC;IAEvB,iBAAiB,EAAE,iBAAiB,CAAC;IAMrC,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEpC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAM/B,gBAAgB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAKvC,eAAe,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAEpD,cAAc,CAAC,EAAE,QAAQ,CAAC;IAE1B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAM5B,YAAY,CAAC,EAAE,uBAAuB,CAAC;IAOvC,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAOD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAwGnC;AAMD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACnC,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAcN;AAKD,wBAAgB,0BAA0B,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAGrF"}
1
+ {"version":3,"file":"createPreviewNode.d.ts","sourceRoot":"","sources":["../../../src/canvas/utils/createPreviewNode.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EACT,KAAK,IAAI,EACT,QAAQ,EACR,KAAK,iBAAiB,EACvB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAGL,KAAK,sBAAsB,EAG5B,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAExD,eAAO,MAAM,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAK5C,CAAC;AAEF,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAM9F;AAMD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAahE;AAqLD,MAAM,WAAW,wBAAwB;IAEvC,YAAY,EAAE,MAAM,CAAC;IAErB,cAAc,EAAE,MAAM,CAAC;IAEvB,iBAAiB,EAAE,iBAAiB,CAAC;IAMrC,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAEpC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAM/B,gBAAgB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAKvC,eAAe,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAEpD,cAAc,CAAC,EAAE,QAAQ,CAAC;IAE1B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAM5B,YAAY,CAAC,EAAE,uBAAuB,CAAC;IAOvC,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;CAC3C;AAOD,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAwGnC;AAMD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,EACnC,iBAAiB,EAAE,iBAAiB,GACnC,IAAI,CAcN;AAKD,wBAAgB,0BAA0B,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAOrF"}
@@ -196,7 +196,7 @@ function applyPreviewToReactFlow(preview, reactFlowInstance) {
196
196
  }, 0);
197
197
  }
198
198
  function removePreviewFromReactFlow(reactFlowInstance) {
199
- reactFlowInstance.setNodes((nodes)=>nodes.filter((n)=>n.id !== PREVIEW_NODE_ID));
200
- reactFlowInstance.setEdges((edges)=>edges.filter((edge)=>!isPreviewEdge(edge)));
199
+ if (reactFlowInstance.getNodes().some((n)=>n.id === PREVIEW_NODE_ID)) reactFlowInstance.setNodes((nodes)=>nodes.filter((n)=>n.id !== PREVIEW_NODE_ID));
200
+ if (reactFlowInstance.getEdges().some((edge)=>isPreviewEdge(edge))) reactFlowInstance.setEdges((edges)=>edges.filter((edge)=>!isPreviewEdge(edge)));
201
201
  }
202
202
  export { PREVIEW_EDGE_STYLE, applyPreviewToReactFlow, createPreviewNode, getOppositePosition, isPreviewEdge, removePreviewFromReactFlow };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/apollo-react",
3
- "version": "4.61.1",
3
+ "version": "4.62.1",
4
4
  "description": "Apollo Design System - React component library with Material UI theming",
5
5
  "repository": {
6
6
  "type": "git",