mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-05-03 10:50:17 -05:00
layout fixes
This commit is contained in:
@@ -8,8 +8,8 @@ async function getAndExecuteBundle(noteId, originEntity = null) {
|
||||
return await executeBundle(bundle, originEntity);
|
||||
}
|
||||
|
||||
async function executeBundle(bundle, originEntity, tabContext, $container) {
|
||||
const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity, tabContext, $container);
|
||||
async function executeBundle(bundle, originEntity, $container) {
|
||||
const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity, $container);
|
||||
|
||||
try {
|
||||
return await (function () {
|
||||
|
||||
@@ -18,7 +18,7 @@ import appContext from "./app_context.js";
|
||||
* @constructor
|
||||
* @hideconstructor
|
||||
*/
|
||||
function FrontendScriptApi(startNote, currentNote, originEntity = null, tabContext = null, $container = null) {
|
||||
function FrontendScriptApi(startNote, currentNote, originEntity = null, $container = null) {
|
||||
const $pluginButtons = $("#plugin-buttons");
|
||||
|
||||
/** @property {jQuery} container of all the rendered script content */
|
||||
@@ -34,9 +34,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
|
||||
// to keep consistency with backend API
|
||||
this.dayjs = dayjs;
|
||||
|
||||
/** @property {TabContext|null} - experimental! */
|
||||
this.tabContext = tabContext;
|
||||
|
||||
/** @property {CollapsibleWidget} */
|
||||
this.CollapsibleWidget = CollapsibleWidget;
|
||||
|
||||
@@ -301,19 +298,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
|
||||
*/
|
||||
this.getActiveTabNotePath = appContext.tabManager.getActiveTabNotePath;
|
||||
|
||||
/**
|
||||
* This method checks whether user navigated away from the note from which the scripts has been started.
|
||||
* This is necessary because script execution is async and by the time it is finished, the user might have
|
||||
* already navigated away from this page - the end result would be that script might return data for the wrong
|
||||
* note.
|
||||
*
|
||||
* @method
|
||||
* @return {boolean} returns true if the original note is still loaded, false if user switched to another
|
||||
*/
|
||||
this.isNoteStillActive = () => {
|
||||
return tabContext.note && this.originEntity.noteId === tabContext.note.noteId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {object} $el - jquery object on which to setup the tooltip
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import server from "./server.js";
|
||||
import bundleService from "./bundle.js";
|
||||
|
||||
async function render(note, $el, tabContext) {
|
||||
async function render(note, $el) {
|
||||
const relations = await note.getRelations('renderNote');
|
||||
const renderNoteIds = relations
|
||||
.map(rel => rel.value)
|
||||
@@ -18,7 +18,7 @@ async function render(note, $el, tabContext) {
|
||||
$scriptContainer.append(bundle.html);
|
||||
|
||||
// async so that scripts cannot block trilium execution
|
||||
bundleService.executeBundle(bundle, note, tabContext, $scriptContainer);
|
||||
bundleService.executeBundle(bundle, note, $scriptContainer);
|
||||
}
|
||||
|
||||
return renderNoteIds.length > 0;
|
||||
|
||||
@@ -2,7 +2,7 @@ import FrontendScriptApi from './frontend_script_api.js';
|
||||
import utils from './utils.js';
|
||||
import treeCache from './tree_cache.js';
|
||||
|
||||
async function ScriptContext(startNoteId, allNoteIds, originEntity = null, tabContext = null, $container = null) {
|
||||
async function ScriptContext(startNoteId, allNoteIds, originEntity = null, $container = null) {
|
||||
const modules = {};
|
||||
|
||||
const startNote = await treeCache.getNote(startNoteId);
|
||||
@@ -11,7 +11,7 @@ async function ScriptContext(startNoteId, allNoteIds, originEntity = null, tabCo
|
||||
return {
|
||||
modules: modules,
|
||||
notes: utils.toObject(allNotes, note => [note.noteId, note]),
|
||||
apis: utils.toObject(allNotes, note => [note.noteId, new FrontendScriptApi(startNote, note, originEntity, tabContext, $container)]),
|
||||
apis: utils.toObject(allNotes, note => [note.noteId, new FrontendScriptApi(startNote, note, originEntity, $container)]),
|
||||
require: moduleNoteIds => {
|
||||
return moduleName => {
|
||||
const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId));
|
||||
|
||||
Reference in New Issue
Block a user