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 tabRow from "../widgets/tab_row.js";
|
||||||
import appContext from "./app_context.js";
|
import appContext from "./app_context.js";
|
||||||
|
|
||||||
const $savedIndicator = $(".saved-indicator");
|
|
||||||
|
|
||||||
let detailLoadedListeners = [];
|
let detailLoadedListeners = [];
|
||||||
|
|
||||||
async function reload() {
|
async function reload() {
|
||||||
@ -32,10 +30,6 @@ async function switchToNote(notePath) {
|
|||||||
appContext.openTabsChanged();
|
appContext.openTabsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onNoteChange(func) {
|
|
||||||
return appContext.getActiveTabContext().getComponent().onNoteChange(func);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getActiveEditor() {
|
function getActiveEditor() {
|
||||||
const activeTabContext = appContext.getActiveTabContext();
|
const activeTabContext = appContext.getActiveTabContext();
|
||||||
|
|
||||||
@ -212,7 +206,6 @@ export default {
|
|||||||
loadNoteDetail,
|
loadNoteDetail,
|
||||||
focusOnTitle,
|
focusOnTitle,
|
||||||
focusAndSelectTitle,
|
focusAndSelectTitle,
|
||||||
onNoteChange,
|
|
||||||
addDetailLoadedListener,
|
addDetailLoadedListener,
|
||||||
getActiveEditor,
|
getActiveEditor,
|
||||||
activateOrOpenNote,
|
activateOrOpenNote,
|
||||||
|
@ -205,7 +205,7 @@ export default class BookTypeWidget extends TypeWidget {
|
|||||||
this.$content.append($('<div class="note-book-auto-message"></div>')
|
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(`This note doesn't have any content so we display its children. Click `)
|
||||||
.append($addTextLink)
|
.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();
|
const zoomLevel = parseInt(await note.getLabelValue('bookZoomLevel')) || this.getDefaultZoomLevel();
|
||||||
|
@ -71,12 +71,12 @@ export default class CodeTypeWidget extends TypeWidget {
|
|||||||
//this.onNoteChange(() => this.tabContext.noteChanged());
|
//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)
|
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
|
||||||
// we provide fallback
|
// 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) {
|
if (info) {
|
||||||
this.codeEditor.setOption("mode", info.mime);
|
this.codeEditor.setOption("mode", info.mime);
|
||||||
|
@ -117,27 +117,27 @@ export default class FileTypeWidget extends TypeWidget {
|
|||||||
return this.$widget;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh() {
|
async doRefresh(note) {
|
||||||
const attributes = await server.get('notes/' + this.tabContext.note.noteId + '/attributes');
|
const attributes = await server.get('notes/' + note.noteId + '/attributes');
|
||||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||||
|
|
||||||
this.$widget.show();
|
this.$widget.show();
|
||||||
|
|
||||||
this.$fileNoteId.text(this.tabContext.note.noteId);
|
this.$fileNoteId.text(note.noteId);
|
||||||
this.$fileName.text(attributeMap.originalFileName || "?");
|
this.$fileName.text(attributeMap.originalFileName || "?");
|
||||||
this.$fileSize.text(this.tabContext.note.contentLength + " bytes");
|
this.$fileSize.text(note.contentLength + " bytes");
|
||||||
this.$fileType.text(this.tabContext.note.mime);
|
this.$fileType.text(note.mime);
|
||||||
|
|
||||||
if (this.tabContext.note.content) {
|
if (note.content) {
|
||||||
this.$previewContent.show();
|
this.$previewContent.show();
|
||||||
this.$previewContent.text(this.tabContext.note.content);
|
this.$previewContent.text(note.content);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.$previewContent.empty().hide();
|
this.$previewContent.empty().hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
// open doesn't work for protected notes since it works through browser which isn't in protected session
|
// 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() {
|
getFileUrl() {
|
||||||
|
@ -122,8 +122,7 @@ class NoteDetailImage extends TypeWidget {
|
|||||||
return this.$widget;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh() {
|
async doRefresh(note) {
|
||||||
const note = this.tabContext.note;
|
|
||||||
const attributes = await server.get('notes/' + note.noteId + '/attributes');
|
const attributes = await server.get('notes/' + note.noteId + '/attributes');
|
||||||
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
|
||||||
|
|
||||||
|
@ -40,10 +40,6 @@ export default class ProtectedSessionTypeWidget extends TypeWidget {
|
|||||||
return this.$widget;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
|
||||||
this.$widget.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
show() {}
|
show() {}
|
||||||
|
|
||||||
getContent() {}
|
getContent() {}
|
||||||
|
@ -181,6 +181,12 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
|||||||
this.$widget.on("drop", ev => this.dropNoteOntoRelationMapHandler(ev));
|
this.$widget.on("drop", ev => this.dropNoteOntoRelationMapHandler(ev));
|
||||||
this.$widget.on("dragover", ev => ev.preventDefault());
|
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;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,24 +270,14 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
|||||||
return id.substr(13);
|
return id.substr(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh() {
|
async doRefresh(note) {
|
||||||
this.$widget.show();
|
this.loadMapData();
|
||||||
|
|
||||||
await libraryLoader.requireLibrary(libraryLoader.RELATION_MAP);
|
this.initJsPlumbInstance();
|
||||||
|
|
||||||
jsPlumb.ready(() => {
|
this.initPanZoom();
|
||||||
// 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.loadNotesAndRelations();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearMap() {
|
clearMap() {
|
||||||
|
@ -26,11 +26,12 @@ export default class RenderTypeWidget extends TypeWidget {
|
|||||||
return this.$widget;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh() {
|
async doRefresh(note) {
|
||||||
this.$widget.show();
|
this.$widget.show();
|
||||||
this.$noteDetailRenderHelp.hide();
|
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) {
|
if (!renderNotesFound) {
|
||||||
this.$noteDetailRenderHelp.show();
|
this.$noteDetailRenderHelp.show();
|
||||||
|
@ -39,13 +39,13 @@ export default class SearchTypeWidget extends TypeWidget {
|
|||||||
return this.$widget;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
doRefresh() {
|
doRefresh(note) {
|
||||||
this.$help.html(searchNotesService.getHelpText());
|
this.$help.html(searchNotesService.getHelpText());
|
||||||
|
|
||||||
this.$component.show();
|
this.$component.show();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const json = JSON.parse(this.ctx.note.content);
|
const json = JSON.parse(note.content);
|
||||||
|
|
||||||
this.$searchString.val(json.searchString);
|
this.$searchString.val(json.searchString);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ export default class SearchTypeWidget extends TypeWidget {
|
|||||||
this.$searchString.val('');
|
this.$searchString.val('');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$searchString.on('input', () => this.ctx.noteChanged());
|
this.$searchString.on('input', () => this.noteChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
getContent() {
|
getContent() {
|
||||||
|
@ -134,12 +134,12 @@ export default class TextTypeWidget extends TypeWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh() {
|
async doRefresh(note) {
|
||||||
this.textEditor.isReadOnly = await this.isReadOnly();
|
this.textEditor.isReadOnly = await this.isReadOnly();
|
||||||
|
|
||||||
this.$widget.show();
|
this.$widget.show();
|
||||||
|
|
||||||
this.textEditor.setData(this.tabContext.note.content);
|
this.textEditor.setData(note.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
getContent() {
|
getContent() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user