mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 05:46:10 +01:00
various widget refactorings
This commit is contained in:
@@ -2,11 +2,10 @@ import server from "./server.js";
|
||||
import bundleService from "./bundle.js";
|
||||
|
||||
async function render(note, $el, ctx) {
|
||||
const attributes = await note.getAttributes();
|
||||
const renderNoteIds = attributes.filter(attr =>
|
||||
attr.type === 'relation'
|
||||
&& attr.name === 'renderNote'
|
||||
&& !!attr.value).map(rel => rel.value);
|
||||
const relations = await note.getRelations('renderNote');
|
||||
const renderNoteIds = relations
|
||||
.map(rel => rel.value)
|
||||
.filter(noteId => noteId);
|
||||
|
||||
$el.empty().toggle(renderNoteIds.length > 0);
|
||||
|
||||
@@ -18,11 +17,8 @@ async function render(note, $el, ctx) {
|
||||
|
||||
$scriptContainer.append(bundle.html);
|
||||
|
||||
const $result = await bundleService.executeBundle(bundle, note, ctx, $scriptContainer);
|
||||
|
||||
if ($result) {
|
||||
$scriptContainer.append($result);
|
||||
}
|
||||
// async so that scripts cannot block trilium execution
|
||||
bundleService.executeBundle(bundle, note, ctx, $scriptContainer);
|
||||
}
|
||||
|
||||
return renderNoteIds.length > 0;
|
||||
|
||||
Reference in New Issue
Block a user