layout fixes

This commit is contained in:
zadam 2020-02-25 19:19:10 +01:00
parent 7270bf287d
commit 3752cf8cba
8 changed files with 14 additions and 29 deletions

View file

@ -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 () {

View file

@ -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

View file

@ -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;

View file

@ -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));

View file

@ -35,7 +35,7 @@ export default class Layout {
parent => new TitleBarButtonsWidget(parent)
]),
parent => new StandardTopWidget(parent),
parent => new FlexContainer(parent, { 'flex-direction': 'row', 'overflow': 'hidden' }, [
parent => new FlexContainer(parent, { 'flex-direction': 'row', 'min-height': '0' }, [
parent => new SidePaneContainer(parent, 'left', [
parent => new GlobalButtonsWidget(parent),
parent => new SearchBoxWidget(parent),

View file

@ -23,6 +23,7 @@ const TPL = `
<style>
.note-detail {
height: 100%;
min-height: 0;
}
</style>
</div>
@ -164,8 +165,6 @@ export default class NoteDetailWidget extends TabAwareWidget {
const noteComplement = await this.tabContext.getNoteComplement();
console.log(note, noteComplement);
if (utils.isHtmlEmpty(noteComplement.content)) {
type = 'book';
}

View file

@ -20,7 +20,7 @@ class NoteRevisionsWidget extends CollapsibleWidget {
const $showFullButton = $("<a>").append("show dialog").addClass('widget-header-action');
$showFullButton.on('click', async () => {
const attributesDialog = await import("../dialogs/note_revisions.js");
attributesDialog.showCurrentNoteRevisions(this.ctx.note.noteId);
attributesDialog.showCurrentNoteRevisions(this.noteId);
});
return [$showFullButton];

View file

@ -21,7 +21,7 @@ export default class RenderTypeWidget extends TypeWidget {
this.$noteDetailRenderContent = this.$widget.find('.note-detail-render-content');
this.$renderButton = this.$widget.find('.render-button');
this.$renderButton.on('click', () => this.render()); // long form!
this.$renderButton.on('click', () => this.refresh());
return this.$widget;
}
@ -30,7 +30,9 @@ export default class RenderTypeWidget extends TypeWidget {
this.$widget.show();
this.$noteDetailRenderHelp.hide();
const renderNotesFound = await renderService.render(note, this.$noteDetailRenderContent, this.tabContext);
const renderNotesFound = await renderService.render(note, this.$noteDetailRenderContent);
console.log("render", this.$noteDetailRenderContent);
if (!renderNotesFound) {
this.$noteDetailRenderHelp.show();