#125, basic infrastructure for scripts attached to notes via relations

This commit is contained in:
azivner
2018-07-29 16:06:13 +02:00
parent ededc063df
commit 170d317589
8 changed files with 43 additions and 17 deletions

View File

@@ -1,13 +1,13 @@
import ScriptApi from './script_api.js';
import utils from './utils.js';
function ScriptContext(startNote, allNotes) {
function ScriptContext(startNote, allNotes, targetNote = null) {
const modules = {};
return {
modules: modules,
notes: utils.toObject(allNotes, note => [note.noteId, note]),
apis: utils.toObject(allNotes, note => [note.noteId, ScriptApi(startNote, note)]),
apis: utils.toObject(allNotes, note => [note.noteId, ScriptApi(startNote, note, targetNote)]),
require: moduleNoteIds => {
return moduleName => {
const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId));