mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
small fixes
This commit is contained in:
parent
34bc02965f
commit
8651e47118
@ -8,8 +8,6 @@ import treeUtils from "./tree_utils.js";
|
||||
import tabRow from "../widgets/tab_row.js";
|
||||
import appContext from "./app_context.js";
|
||||
|
||||
const $savedIndicator = $(".saved-indicator");
|
||||
|
||||
let detailLoadedListeners = [];
|
||||
|
||||
async function reload() {
|
||||
@ -32,10 +30,6 @@ async function switchToNote(notePath) {
|
||||
appContext.openTabsChanged();
|
||||
}
|
||||
|
||||
function onNoteChange(func) {
|
||||
return appContext.getActiveTabContext().getComponent().onNoteChange(func);
|
||||
}
|
||||
|
||||
function getActiveEditor() {
|
||||
const activeTabContext = appContext.getActiveTabContext();
|
||||
|
||||
@ -212,7 +206,6 @@ export default {
|
||||
loadNoteDetail,
|
||||
focusOnTitle,
|
||||
focusAndSelectTitle,
|
||||
onNoteChange,
|
||||
addDetailLoadedListener,
|
||||
getActiveEditor,
|
||||
activateOrOpenNote,
|
||||
|
@ -205,7 +205,7 @@ export default class BookTypeWidget extends TypeWidget {
|
||||
this.$content.append($('<div class="note-book-auto-message"></div>')
|
||||
.append(`This note doesn't have any content so we display its children. Click `)
|
||||
.append($addTextLink)
|
||||
.append(' if you want to add some text.'))
|
||||
.append(' if you want to add some text.'));
|
||||
}
|
||||
|
||||
const zoomLevel = parseInt(await note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel();
|
||||
|
@ -71,12 +71,12 @@ export default class CodeTypeWidget extends TypeWidget {
|
||||
//this.onNoteChange(() => this.tabContext.noteChanged());
|
||||
}
|
||||
|
||||
doRefresh() {
|
||||
doRefresh(note) {
|
||||
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
|
||||
// we provide fallback
|
||||
this.codeEditor.setValue(this.tabContext.note.content || "");
|
||||
this.codeEditor.setValue(note.content || "");
|
||||
|
||||
const info = CodeMirror.findModeByMIME(this.tabContext.note.mime);
|
||||
const info = CodeMirror.findModeByMIME(note.mime);
|
||||
|
||||
if (info) {
|
||||
this.codeEditor.setOption("mode", info.mime);
|
||||
|
@ -117,27 +117,27 @@ export default class FileTypeWidget extends TypeWidget {
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
async doRefresh() {
|
||||
const attributes = await server.get('notes/' + this.tabContext.note.noteId + '/attributes');
|
||||
async doRefresh(note) {
|
||||
const attributes = await server.get('notes/' + note.noteId + '/attributes');
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
this.$widget.show();
|
||||
|
||||
this.$fileNoteId.text(this.tabContext.note.noteId);
|
||||
this.$fileNoteId.text(note.noteId);
|
||||
this.$fileName.text(attributeMap.originalFileName || "?");
|
||||
this.$fileSize.text(this.tabContext.note.contentLength + " bytes");
|
||||
this.$fileType.text(this.tabContext.note.mime);
|
||||
this.$fileSize.text(note.contentLength + " bytes");
|
||||
this.$fileType.text(note.mime);
|
||||
|
||||
if (this.tabContext.note.content) {
|
||||
if (note.content) {
|
||||
this.$previewContent.show();
|
||||
this.$previewContent.text(this.tabContext.note.content);
|
||||
this.$previewContent.text(note.content);
|
||||
}
|
||||
else {
|
||||
this.$previewContent.empty().hide();
|
||||
}
|
||||
|
||||
// open doesn't work for protected notes since it works through browser which isn't in protected session
|
||||
this.$openButton.toggle(!this.tabContext.note.isProtected);
|
||||
this.$openButton.toggle(!note.isProtected);
|
||||
}
|
||||
|
||||
getFileUrl() {
|
||||
|
@ -122,8 +122,7 @@ class NoteDetailImage extends TypeWidget {
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
async doRefresh() {
|
||||
const note = this.tabContext.note;
|
||||
async doRefresh(note) {
|
||||
const attributes = await server.get('notes/' + note.noteId + '/attributes');
|
||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||
|
||||
|
@ -40,10 +40,6 @@ export default class ProtectedSessionTypeWidget extends TypeWidget {
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
render() {
|
||||
this.$widget.show();
|
||||
}
|
||||
|
||||
show() {}
|
||||
|
||||
getContent() {}
|
||||
|
@ -181,6 +181,12 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
||||
this.$widget.on("drop", ev => this.dropNoteOntoRelationMapHandler(ev));
|
||||
this.$widget.on("dragover", ev => ev.preventDefault());
|
||||
|
||||
this.initialized = new Promise(async res => {
|
||||
await libraryLoader.requireLibrary(libraryLoader.RELATION_MAP);
|
||||
|
||||
jsPlumb.ready(res);
|
||||
});
|
||||
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
@ -264,24 +270,14 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
||||
return id.substr(13);
|
||||
}
|
||||
|
||||
async doRefresh() {
|
||||
this.$widget.show();
|
||||
async doRefresh(note) {
|
||||
this.loadMapData();
|
||||
|
||||
await libraryLoader.requireLibrary(libraryLoader.RELATION_MAP);
|
||||
this.initJsPlumbInstance();
|
||||
|
||||
jsPlumb.ready(() => {
|
||||
// lazy loading above can take time and tab might have been already switched to another note
|
||||
if (this.tabContext.note && this.tabContext.note.type === 'relation-map') {
|
||||
this.loadMapData();
|
||||
|
||||
this.initJsPlumbInstance();
|
||||
|
||||
this.initPanZoom();
|
||||
|
||||
this.loadNotesAndRelations();
|
||||
}
|
||||
});
|
||||
this.initPanZoom();
|
||||
|
||||
this.loadNotesAndRelations();
|
||||
}
|
||||
|
||||
clearMap() {
|
||||
|
@ -26,11 +26,12 @@ export default class RenderTypeWidget extends TypeWidget {
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
async doRefresh() {
|
||||
async doRefresh(note) {
|
||||
this.$widget.show();
|
||||
this.$noteDetailRenderHelp.hide();
|
||||
|
||||
const renderNotesFound = await renderService.render(this.ctx.note, this.$noteDetailRenderContent, this.ctx);
|
||||
// FIXME this.ctx
|
||||
const renderNotesFound = await renderService.render(note, this.$noteDetailRenderContent, this.ctx);
|
||||
|
||||
if (!renderNotesFound) {
|
||||
this.$noteDetailRenderHelp.show();
|
||||
|
@ -39,13 +39,13 @@ export default class SearchTypeWidget extends TypeWidget {
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
doRefresh() {
|
||||
doRefresh(note) {
|
||||
this.$help.html(searchNotesService.getHelpText());
|
||||
|
||||
this.$component.show();
|
||||
|
||||
try {
|
||||
const json = JSON.parse(this.ctx.note.content);
|
||||
const json = JSON.parse(note.content);
|
||||
|
||||
this.$searchString.val(json.searchString);
|
||||
}
|
||||
@ -54,7 +54,7 @@ export default class SearchTypeWidget extends TypeWidget {
|
||||
this.$searchString.val('');
|
||||
}
|
||||
|
||||
this.$searchString.on('input', () => this.ctx.noteChanged());
|
||||
this.$searchString.on('input', () => this.noteChanged());
|
||||
}
|
||||
|
||||
getContent() {
|
||||
|
@ -134,12 +134,12 @@ export default class TextTypeWidget extends TypeWidget {
|
||||
}
|
||||
}
|
||||
|
||||
async doRefresh() {
|
||||
async doRefresh(note) {
|
||||
this.textEditor.isReadOnly = await this.isReadOnly();
|
||||
|
||||
this.$widget.show();
|
||||
|
||||
this.textEditor.setData(this.tabContext.note.content);
|
||||
this.textEditor.setData(note.content);
|
||||
}
|
||||
|
||||
getContent() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user