Skip to content

Commit e4a04e0

Browse files
committed
Add parentEvent parameters to onSave and onClose events
1 parent 3c92f1b commit e4a04e0

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.1.6
2+
- Added `parentEvent` parameters to `onSave` and `onClose` events when the callbacks are triggered by another event.
3+
14
# 0.1.5
25
- Fixed `urlParameters` which has a value of `false` or `0` but didn't show up
36
- Added ability to have a custom baseUrl - thanks to @sabinayakc

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-drawio",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"type": "module",
55
"description": "React component for integrating the Diagrams (draw.io) embed iframe",
66
"main": "index.js",

src/DrawIoEmbed.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export const DrawIoEmbed = forwardRef<DrawIoEmbedRef, DrawIoEmbedProps>(
7575
if (onSave) {
7676
onSave({
7777
event: 'save',
78-
xml: data.data
78+
xml: data.data,
79+
parentEvent: 'export'
7980
});
8081
}
8182

@@ -87,7 +88,8 @@ export const DrawIoEmbed = forwardRef<DrawIoEmbedRef, DrawIoEmbedProps>(
8788
if (data.message.exit && onClose) {
8889
onClose({
8990
event: 'exit',
90-
modified: true
91+
modified: true,
92+
parentEvent: 'export'
9193
});
9294
}
9395
},

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,15 @@ type EventSave = {
108108
event: 'save';
109109
exit?: boolean;
110110
xml: string;
111+
/** Is set when the event was triggered by anything other than the save action */
112+
parentEvent?: string;
111113
};
112114

113115
type EventExit = {
114116
event: 'exit';
115117
modified: boolean;
118+
/** Is set when the event was triggered by anything other than the save action */
119+
parentEvent?: string;
116120
};
117121

118122
type EventConfigure = {

0 commit comments

Comments
 (0)