mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
refactored targetNote to workNote in the ScriptContext which was very confusing with relation's targetNote
This commit is contained in:
@@ -14,7 +14,7 @@ async function executeNote(note, targetNote) {
|
||||
await executeBundle(bundle, note, targetNote);
|
||||
}
|
||||
|
||||
async function executeBundle(bundle, startNote, targetNote = null) {
|
||||
async function executeBundle(bundle, startNote, workNote = null) {
|
||||
if (!startNote) {
|
||||
// this is the default case, the only exception is when we want to preserve frontend startNote
|
||||
startNote = bundle.note;
|
||||
@@ -23,7 +23,7 @@ async function executeBundle(bundle, startNote, targetNote = null) {
|
||||
// last \r\n is necessary if script contains line comment on its last line
|
||||
const script = "async function() {\r\n" + bundle.script + "\r\n}";
|
||||
|
||||
const ctx = new ScriptContext(startNote, bundle.allNotes, targetNote);
|
||||
const ctx = new ScriptContext(startNote, bundle.allNotes, workNote);
|
||||
|
||||
if (await bundle.note.hasLabel('manualTransactionHandling')) {
|
||||
return await execute(ctx, script, '');
|
||||
|
||||
@@ -10,10 +10,10 @@ const config = require('./config');
|
||||
const repository = require('./repository');
|
||||
const axios = require('axios');
|
||||
|
||||
function ScriptContext(startNote, allNotes, targetNote = null) {
|
||||
function ScriptContext(startNote, allNotes, workNote = null) {
|
||||
this.modules = {};
|
||||
this.notes = utils.toObject(allNotes, note => [note.noteId, note]);
|
||||
this.apis = utils.toObject(allNotes, note => [note.noteId, new ScriptApi(startNote, note, targetNote)]);
|
||||
this.apis = utils.toObject(allNotes, note => [note.noteId, new ScriptApi(startNote, note, workNote)]);
|
||||
this.require = moduleNoteIds => {
|
||||
return moduleName => {
|
||||
const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId));
|
||||
@@ -28,10 +28,10 @@ function ScriptContext(startNote, allNotes, targetNote = null) {
|
||||
};
|
||||
}
|
||||
|
||||
function ScriptApi(startNote, currentNote, targetNote) {
|
||||
function ScriptApi(startNote, currentNote, workNote) {
|
||||
this.startNote = startNote;
|
||||
this.currentNote = currentNote;
|
||||
this.targetNote = targetNote;
|
||||
this.workNote = workNote;
|
||||
|
||||
this.axios = axios;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user