mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	layout fixes
This commit is contained in:
		@@ -8,8 +8,8 @@ async function getAndExecuteBundle(noteId, originEntity = null) {
 | 
				
			|||||||
    return await executeBundle(bundle, originEntity);
 | 
					    return await executeBundle(bundle, originEntity);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function executeBundle(bundle, originEntity, tabContext, $container) {
 | 
					async function executeBundle(bundle, originEntity, $container) {
 | 
				
			||||||
    const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity, tabContext, $container);
 | 
					    const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity, $container);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
        return await (function () {
 | 
					        return await (function () {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ import appContext from "./app_context.js";
 | 
				
			|||||||
 * @constructor
 | 
					 * @constructor
 | 
				
			||||||
 * @hideconstructor
 | 
					 * @hideconstructor
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
function FrontendScriptApi(startNote, currentNote, originEntity = null, tabContext = null, $container = null) {
 | 
					function FrontendScriptApi(startNote, currentNote, originEntity = null, $container = null) {
 | 
				
			||||||
    const $pluginButtons = $("#plugin-buttons");
 | 
					    const $pluginButtons = $("#plugin-buttons");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** @property {jQuery} container of all the rendered script content */
 | 
					    /** @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
 | 
					    // to keep consistency with backend API
 | 
				
			||||||
    this.dayjs = dayjs;
 | 
					    this.dayjs = dayjs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /** @property {TabContext|null} - experimental! */
 | 
					 | 
				
			||||||
    this.tabContext = tabContext;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** @property {CollapsibleWidget} */
 | 
					    /** @property {CollapsibleWidget} */
 | 
				
			||||||
    this.CollapsibleWidget = CollapsibleWidget;
 | 
					    this.CollapsibleWidget = CollapsibleWidget;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -301,19 +298,6 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    this.getActiveTabNotePath = appContext.tabManager.getActiveTabNotePath;
 | 
					    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
 | 
					     * @method
 | 
				
			||||||
     * @param {object} $el - jquery object on which to setup the tooltip
 | 
					     * @param {object} $el - jquery object on which to setup the tooltip
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,7 @@
 | 
				
			|||||||
import server from "./server.js";
 | 
					import server from "./server.js";
 | 
				
			||||||
import bundleService from "./bundle.js";
 | 
					import bundleService from "./bundle.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async function render(note, $el, tabContext) {
 | 
					async function render(note, $el) {
 | 
				
			||||||
    const relations = await note.getRelations('renderNote');
 | 
					    const relations = await note.getRelations('renderNote');
 | 
				
			||||||
    const renderNoteIds = relations
 | 
					    const renderNoteIds = relations
 | 
				
			||||||
        .map(rel => rel.value)
 | 
					        .map(rel => rel.value)
 | 
				
			||||||
@@ -18,7 +18,7 @@ async function render(note, $el, tabContext) {
 | 
				
			|||||||
        $scriptContainer.append(bundle.html);
 | 
					        $scriptContainer.append(bundle.html);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // async so that scripts cannot block trilium execution
 | 
					        // async so that scripts cannot block trilium execution
 | 
				
			||||||
        bundleService.executeBundle(bundle, note, tabContext, $scriptContainer);
 | 
					        bundleService.executeBundle(bundle, note, $scriptContainer);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return renderNoteIds.length > 0;
 | 
					    return renderNoteIds.length > 0;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@ import FrontendScriptApi from './frontend_script_api.js';
 | 
				
			|||||||
import utils from './utils.js';
 | 
					import utils from './utils.js';
 | 
				
			||||||
import treeCache from './tree_cache.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 modules = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const startNote = await treeCache.getNote(startNoteId);
 | 
					    const startNote = await treeCache.getNote(startNoteId);
 | 
				
			||||||
@@ -11,7 +11,7 @@ async function ScriptContext(startNoteId, allNoteIds, originEntity = null, tabCo
 | 
				
			|||||||
    return {
 | 
					    return {
 | 
				
			||||||
        modules: modules,
 | 
					        modules: modules,
 | 
				
			||||||
        notes: utils.toObject(allNotes, note => [note.noteId, note]),
 | 
					        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 => {
 | 
					        require: moduleNoteIds => {
 | 
				
			||||||
            return moduleName => {
 | 
					            return moduleName => {
 | 
				
			||||||
                const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId));
 | 
					                const candidates = allNotes.filter(note => moduleNoteIds.includes(note.noteId));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,7 +35,7 @@ export default class Layout {
 | 
				
			|||||||
                parent => new TitleBarButtonsWidget(parent)
 | 
					                parent => new TitleBarButtonsWidget(parent)
 | 
				
			||||||
            ]),
 | 
					            ]),
 | 
				
			||||||
            parent => new StandardTopWidget(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 SidePaneContainer(parent, 'left', [
 | 
				
			||||||
                    parent => new GlobalButtonsWidget(parent),
 | 
					                    parent => new GlobalButtonsWidget(parent),
 | 
				
			||||||
                    parent => new SearchBoxWidget(parent),
 | 
					                    parent => new SearchBoxWidget(parent),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,6 +23,7 @@ const TPL = `
 | 
				
			|||||||
    <style>
 | 
					    <style>
 | 
				
			||||||
    .note-detail {
 | 
					    .note-detail {
 | 
				
			||||||
        height: 100%;
 | 
					        height: 100%;
 | 
				
			||||||
 | 
					        min-height: 0;
 | 
				
			||||||
    }  
 | 
					    }  
 | 
				
			||||||
    </style>
 | 
					    </style>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
@@ -164,8 +165,6 @@ export default class NoteDetailWidget extends TabAwareWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            const noteComplement = await this.tabContext.getNoteComplement();
 | 
					            const noteComplement = await this.tabContext.getNoteComplement();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            console.log(note, noteComplement);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (utils.isHtmlEmpty(noteComplement.content)) {
 | 
					            if (utils.isHtmlEmpty(noteComplement.content)) {
 | 
				
			||||||
                type = 'book';
 | 
					                type = 'book';
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,7 @@ class NoteRevisionsWidget extends CollapsibleWidget {
 | 
				
			|||||||
        const $showFullButton = $("<a>").append("show dialog").addClass('widget-header-action');
 | 
					        const $showFullButton = $("<a>").append("show dialog").addClass('widget-header-action');
 | 
				
			||||||
        $showFullButton.on('click', async () => {
 | 
					        $showFullButton.on('click', async () => {
 | 
				
			||||||
            const attributesDialog = await import("../dialogs/note_revisions.js");
 | 
					            const attributesDialog = await import("../dialogs/note_revisions.js");
 | 
				
			||||||
            attributesDialog.showCurrentNoteRevisions(this.ctx.note.noteId);
 | 
					            attributesDialog.showCurrentNoteRevisions(this.noteId);
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return [$showFullButton];
 | 
					        return [$showFullButton];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,7 @@ export default class RenderTypeWidget extends TypeWidget {
 | 
				
			|||||||
        this.$noteDetailRenderContent = this.$widget.find('.note-detail-render-content');
 | 
					        this.$noteDetailRenderContent = this.$widget.find('.note-detail-render-content');
 | 
				
			||||||
        this.$renderButton = this.$widget.find('.render-button');
 | 
					        this.$renderButton = this.$widget.find('.render-button');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$renderButton.on('click', () => this.render()); // long form!
 | 
					        this.$renderButton.on('click', () => this.refresh());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return this.$widget;
 | 
					        return this.$widget;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -30,7 +30,9 @@ export default class RenderTypeWidget extends TypeWidget {
 | 
				
			|||||||
        this.$widget.show();
 | 
					        this.$widget.show();
 | 
				
			||||||
        this.$noteDetailRenderHelp.hide();
 | 
					        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) {
 | 
					        if (!renderNotesFound) {
 | 
				
			||||||
            this.$noteDetailRenderHelp.show();
 | 
					            this.$noteDetailRenderHelp.show();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user