fix setup of new document, closes #966

This commit is contained in:
zadam
2020-04-14 21:57:42 +02:00
parent 48aadc8309
commit 29cec8112e
149 changed files with 194 additions and 181 deletions

View File

@@ -0,0 +1,29 @@
import server from "./server.js";
import bundleService from "./bundle.js";
async function render(note, $el) {
const relations = note.getRelations('renderNote');
const renderNoteIds = relations
.map(rel => rel.value)
.filter(noteId => noteId);
$el.empty().toggle(renderNoteIds.length > 0);
for (const renderNoteId of renderNoteIds) {
const bundle = await server.get('script/bundle/' + renderNoteId);
const $scriptContainer = $('<div>');
$el.append($scriptContainer);
$scriptContainer.append(bundle.html);
// async so that scripts cannot block trilium execution
bundleService.executeBundle(bundle, note, $scriptContainer);
}
return renderNoteIds.length > 0;
}
export default {
render
}