diff --git a/src/public/javascripts/services/note_detail_render.js b/src/public/javascripts/services/note_detail_render.js index 24357e0af..5b1dec521 100644 --- a/src/public/javascripts/services/note_detail_render.js +++ b/src/public/javascripts/services/note_detail_render.js @@ -13,7 +13,7 @@ let codeEditorInitialized; async function show() { codeEditorInitialized = false; - $noteDetailRender.show(); + $noteDetailRender.empty().show(); await render(); } diff --git a/src/services/notes.js b/src/services/notes.js index 32a55d18e..488bcb9cf 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -272,6 +272,13 @@ async function deleteNote(branch) { attribute.isDeleted = true; await attribute.save(); } + + const targetAttributes = await repository.getEntities("SELECT * FROM attributes WHERE type = 'relation' AND isDeleted = 0 AND value = ?", [note.noteId]); + + for (const attribute of targetAttributes) { + attribute.isDeleted = true; + await attribute.save(); + } } } diff --git a/src/services/script.js b/src/services/script.js index f5fbb4d15..47364fb97 100644 --- a/src/services/script.js +++ b/src/services/script.js @@ -129,7 +129,9 @@ async function getScriptBundle(note, root = true, scriptEnv = null, includedNote apiContext.modules['${note.noteId}'] = {}; ${root ? 'return ' : ''}await (async function(exports, module, require, api` + (modules.length > 0 ? ', ' : '') + modules.map(child => sanitizeVariableName(child.title)).join(', ') + `) { -try {${note.content};} catch (e) { throw new Error("Load of script note \\"${note.title}\\" (${note.noteId}) failed with: " + e.message); } +try { +${note.content}; +} catch (e) { throw new Error("Load of script note \\"${note.title}\\" (${note.noteId}) failed with: " + e.message); } if (!module.exports) module.exports = {}; for (const exportKey in exports) module.exports[exportKey] = exports[exportKey]; })({}, apiContext.modules['${note.noteId}'], apiContext.require(${JSON.stringify(moduleNoteIds)}), apiContext.apis['${note.noteId}']` + (modules.length > 0 ? ', ' : '') +