mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Allow nodes to return additional history entries in onEditSave
This commit is contained in:
@@ -741,9 +741,16 @@ RED.editor = (function() {
|
||||
}
|
||||
|
||||
try {
|
||||
var rc = editing_node._def.oneditsave.call(editing_node);
|
||||
const rc = editing_node._def.oneditsave.call(editing_node);
|
||||
if (rc === true) {
|
||||
editState.changed = true;
|
||||
} else if (typeof rc === 'object' && rc !== null ) {
|
||||
if (rc.changed === true) {
|
||||
editState.changed = true
|
||||
}
|
||||
if (Array.isArray(rc.history) && rc.history.length > 0) {
|
||||
editState.history = rc.history
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
console.warn("oneditsave",editing_node.id,editing_node.type,err.toString());
|
||||
@@ -1015,7 +1022,7 @@ RED.editor = (function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
var historyEvent = {
|
||||
let historyEvent = {
|
||||
t:'edit',
|
||||
node:editing_node,
|
||||
changes:editState.changes,
|
||||
@@ -1031,6 +1038,15 @@ RED.editor = (function() {
|
||||
instances:subflowInstances
|
||||
}
|
||||
}
|
||||
|
||||
if (editState.history) {
|
||||
historyEvent = {
|
||||
t: 'multi',
|
||||
events: [ historyEvent, ...editState.history ],
|
||||
dirty: wasDirty
|
||||
}
|
||||
}
|
||||
|
||||
RED.history.push(historyEvent);
|
||||
}
|
||||
editing_node.dirty = true;
|
||||
|
Reference in New Issue
Block a user