mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 00:05:50 +01:00
refactoring of note detail API
This commit is contained in:
@@ -4,6 +4,7 @@ import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||
import treeCache from "../services/tree_cache.js";
|
||||
import server from "../services/server.js";
|
||||
import SpacedUpdate from "../services/spaced_update.js";
|
||||
import appContext from "../services/app_context.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="note-title-container">
|
||||
@@ -107,4 +108,18 @@ export default class NoteTitleWidget extends TabAwareWidget {
|
||||
await this.spacedUpdate.updateNowIfNecessary();
|
||||
}
|
||||
}
|
||||
|
||||
focusOnTitleListener() {
|
||||
if (this.tabContext && this.tabContext.isActive()) {
|
||||
this.$noteTitle.trigger('focus');
|
||||
}
|
||||
}
|
||||
|
||||
focusAndSelectTitleListener() {
|
||||
if (this.tabContext && this.tabContext.isActive()) {
|
||||
this.$noteTitle
|
||||
.trigger('focus')
|
||||
.trigger('select');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
|
||||
treeUtils.getNotePath(node).then(notePath => {
|
||||
if (notePath) {
|
||||
noteDetailService.openInTab(notePath, false);
|
||||
const tabContext = appContext.openEmptyTab();
|
||||
tabContext.setNote(notePath);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -87,7 +88,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
node.setFocus(true);
|
||||
}
|
||||
else if (event.ctrlKey) {
|
||||
noteDetailService.loadNoteDetail(node.data.noteId, { newTab: true });
|
||||
const tabContext = appContext.openEmptyTab();
|
||||
treeUtils.getNotePath(node).then(notePath => tabContext.setNote(notePath));
|
||||
appContext.activateTab(tabContext.tabId);
|
||||
}
|
||||
else {
|
||||
node.setActive();
|
||||
|
||||
@@ -130,9 +130,6 @@ export default class NoteTypeWidget extends TabAwareWidget {
|
||||
|
||||
await noteDetailService.reload();
|
||||
|
||||
// for the note icon to be updated in the tree
|
||||
await treeService.reload();
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ export default class SearchBoxWidget extends BasicWidget {
|
||||
|
||||
this.$saveSearchButton.on('click', () => this.saveSearch());
|
||||
|
||||
this.$closeSearchButton.on('click', () => this.hideSearchListener());
|
||||
this.$closeSearchButton.on('click', () => this.trigger('hideSearch'));
|
||||
|
||||
return this.$widget;
|
||||
}
|
||||
@@ -159,6 +159,8 @@ export default class SearchBoxWidget extends BasicWidget {
|
||||
this.resetSearchListener();
|
||||
|
||||
this.$searchBox.slideUp();
|
||||
|
||||
this.trigger('hideSearchResults');
|
||||
}
|
||||
|
||||
toggleSearchListener() {
|
||||
@@ -167,7 +169,6 @@ export default class SearchBoxWidget extends BasicWidget {
|
||||
}
|
||||
else {
|
||||
this.hideSearchListener();
|
||||
this.trigger('hideSearchResults');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ export default class SearchResultsWidget extends BasicWidget {
|
||||
this.$searchResults = this.$widget;
|
||||
this.$searchResultsInner = this.$widget.find(".search-results-inner");
|
||||
|
||||
this.toggle(false);
|
||||
|
||||
return this.$widget;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@ export default class TabCachingWidget extends TabAwareWidget {
|
||||
widget.toggle(false);
|
||||
}
|
||||
|
||||
if (!this.tabContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
let widget = this.widgets[this.tabContext.tabId];
|
||||
|
||||
if (!widget) {
|
||||
@@ -31,8 +35,6 @@ export default class TabCachingWidget extends TabAwareWidget {
|
||||
}
|
||||
|
||||
widget.toggle(true);
|
||||
|
||||
return false; // stop propagation to children
|
||||
}
|
||||
|
||||
tabRemovedListener({tabId}) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import contextMenuWidget from "../../services/context_menu.js";
|
||||
import toastService from "../../services/toast.js";
|
||||
import attributeAutocompleteService from "../../services/attribute_autocomplete.js";
|
||||
import TypeWidget from "./type_widget.js";
|
||||
import appContext from "../../services/app_context.js";
|
||||
|
||||
const uniDirectionalOverlays = [
|
||||
[ "Arrow", {
|
||||
@@ -196,7 +197,8 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
||||
const noteId = this.idToNoteId($noteBox.prop("id"));
|
||||
|
||||
if (cmd === "open-in-new-tab") {
|
||||
noteDetailService.openInTab(noteId, false);
|
||||
const tabContext = appContext.openEmptyTab();
|
||||
tabContext.setNote(noteId);
|
||||
}
|
||||
else if (cmd === "remove") {
|
||||
const confirmDialog = await import('../../dialogs/confirm.js');
|
||||
|
||||
Reference in New Issue
Block a user