mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 20:06:08 +01:00
fix preserving original sourceId after running script notes, fixes #2224
This commit is contained in:
@@ -30,11 +30,12 @@ function executeBundle(bundle, apiParams = {}) {
|
||||
apiParams.startNote = bundle.note;
|
||||
}
|
||||
|
||||
const originalSourceId = cls.get('sourceId');
|
||||
|
||||
cls.set('sourceId', 'script');
|
||||
|
||||
// last \r\n is necessary if script contains line comment on its last line
|
||||
const script = "function() {\r\n" + bundle.script + "\r\n}";
|
||||
|
||||
const ctx = new ScriptContext(bundle.allNotes, apiParams);
|
||||
|
||||
try {
|
||||
@@ -45,6 +46,9 @@ function executeBundle(bundle, apiParams = {}) {
|
||||
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
cls.set('sourceId', originalSourceId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user