mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fixes
This commit is contained in:
parent
08687b76ea
commit
18ee239362
@ -13,7 +13,7 @@ class AppContext {
|
|||||||
constructor(layout) {
|
constructor(layout) {
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
this.tabManager = new TabManager(this);
|
this.tabManager = new TabManager(this);
|
||||||
this.components = [this.tabManager];
|
this.components = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
@ -32,6 +32,7 @@ class AppContext {
|
|||||||
$("body").append(rootContainer.render());
|
$("body").append(rootContainer.render());
|
||||||
|
|
||||||
this.components = [
|
this.components = [
|
||||||
|
this.tabManager,
|
||||||
rootContainer,
|
rootContainer,
|
||||||
new Entrypoints(this),
|
new Entrypoints(this),
|
||||||
new DialogEventComponent(this)
|
new DialogEventComponent(this)
|
||||||
@ -112,7 +113,7 @@ $(window).on('hashchange', function() {
|
|||||||
if (isNotePathInAddress()) {
|
if (isNotePathInAddress()) {
|
||||||
const [notePath, tabId] = getHashValueFromAddress();
|
const [notePath, tabId] = getHashValueFromAddress();
|
||||||
|
|
||||||
appContext.switchToTab(tabId, notePath);
|
appContext.tabManager.switchToTab(tabId, notePath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ export default class LinkMap {
|
|||||||
.addClass('link-' + edge.target.id);
|
.addClass('link-' + edge.target.id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.debug(`connection not created for`, edge);
|
//console.debug(`connection not created for`, edge);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class TabContext extends Component {
|
|||||||
this.tabId = state.tabId || utils.randomString(4);
|
this.tabId = state.tabId || utils.randomString(4);
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
|
||||||
this.trigger('tabOpened', {tabId: this.tabId});
|
this.trigger('newTabOpened', {tabId: this.tabId});
|
||||||
}
|
}
|
||||||
|
|
||||||
async setNote(inputNotePath) {
|
async setNote(inputNotePath) {
|
||||||
|
@ -201,10 +201,6 @@ export default class TabManager extends Component {
|
|||||||
this.trigger('activeTabChanged', { oldActiveTabId, newActiveTabId: tabId });
|
this.trigger('activeTabChanged', { oldActiveTabId, newActiveTabId: tabId });
|
||||||
}
|
}
|
||||||
|
|
||||||
newTabListener() {
|
|
||||||
this.openAndActivateEmptyTab();
|
|
||||||
}
|
|
||||||
|
|
||||||
async removeTab(tabId) {
|
async removeTab(tabId) {
|
||||||
const tabContextToRemove = this.tabContexts.find(tc => tc.tabId === tabId);
|
const tabContextToRemove = this.tabContexts.find(tc => tc.tabId === tabId);
|
||||||
|
|
||||||
@ -258,6 +254,10 @@ export default class TabManager extends Component {
|
|||||||
this.removeTab(this.activeTabId);
|
this.removeTab(this.activeTabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeUnloadListener() {
|
||||||
|
this.tabsUpdate.updateNowIfNecessary();
|
||||||
|
}
|
||||||
|
|
||||||
openNewTabListener() {
|
openNewTabListener() {
|
||||||
this.openAndActivateEmptyTab();
|
this.openAndActivateEmptyTab();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import TabAwareWidget from "./tab_aware_widget.js";
|
import TabAwareWidget from "./tab_aware_widget.js";
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
|
||||||
import server from "../services/server.js";
|
import server from "../services/server.js";
|
||||||
import SpacedUpdate from "../services/spaced_update.js";
|
import SpacedUpdate from "../services/spaced_update.js";
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ export default class NoteTitleWidget extends TabAwareWidget {
|
|||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
this.$noteTitle = this.$widget.find(".note-title");
|
this.$noteTitle = this.$widget.find(".note-title");
|
||||||
|
|
||||||
this.$noteTitle.on('input', () => this.titleChanged());
|
this.$noteTitle.on('input', () => this.spacedUpdate.scheduleUpdate());
|
||||||
|
|
||||||
utils.bindElShortcut(this.$noteTitle, 'return', () => {
|
utils.bindElShortcut(this.$noteTitle, 'return', () => {
|
||||||
this.trigger('focusOnDetail', {tabId: this.tabContext.tabId});
|
this.trigger('focusOnDetail', {tabId: this.tabContext.tabId});
|
||||||
@ -49,27 +48,6 @@ export default class NoteTitleWidget extends TabAwareWidget {
|
|||||||
return this.$widget;
|
return this.$widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
async titleChanged() {
|
|
||||||
const {note} = this.tabContext;
|
|
||||||
|
|
||||||
if (!note) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
note.title = this.$noteTitle.val();
|
|
||||||
|
|
||||||
this.spacedUpdate.scheduleUpdate();
|
|
||||||
|
|
||||||
const noteFromCache = await treeCache.getNote(note.noteId);
|
|
||||||
noteFromCache.title = note.title;
|
|
||||||
|
|
||||||
this.trigger(`noteTitleChanged`, {
|
|
||||||
tabId: this.tabContext.tabId, // used to identify that the event comes from this tab so we should not update this tab's input
|
|
||||||
title: note.title,
|
|
||||||
noteId: note.noteId
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
this.$noteTitle.val(note.title);
|
this.$noteTitle.val(note.title);
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import BasicWidget from "./basic_widget.js";
|
import BasicWidget from "./basic_widget.js";
|
||||||
import protectedSessionService from "../services/protected_session.js";
|
import protectedSessionService from "../services/protected_session.js";
|
||||||
import protectedSessionHolder from "../services/protected_session_holder.js";
|
import protectedSessionHolder from "../services/protected_session_holder.js";
|
||||||
|
import TabAwareWidget from "./tab_aware_widget.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="btn-group btn-group-xs" style="margin-left: 10px; margin-right: 10px;">
|
<div class="btn-group btn-group-xs" style="margin-left: 10px; margin-right: 10px;">
|
||||||
@ -15,7 +16,7 @@ const TPL = `
|
|||||||
</button>
|
</button>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
export default class ProtectedNoteSwitchWidget extends BasicWidget {
|
export default class ProtectedNoteSwitchWidget extends TabAwareWidget {
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
|
@ -8,6 +8,10 @@ export default class TabCachingWidget extends TabAwareWidget {
|
|||||||
this.widgets = {};
|
this.widgets = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async isEnabled() {
|
||||||
|
return this.tabContext.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(`<div class="marker" style="display: none;">`);
|
this.$widget = $(`<div class="marker" style="display: none;">`);
|
||||||
return this.$widget;
|
return this.$widget;
|
||||||
@ -53,9 +57,12 @@ export default class TabCachingWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(show) {
|
async toggle(show) {
|
||||||
for (const tabId in this.widgets) {
|
for (const tabId in this.widgets) {
|
||||||
this.widgets[tabId].toggle(show && this.tabContext && tabId === this.tabContext.tabId);
|
this.widgets[tabId].toggle(
|
||||||
|
show
|
||||||
|
&& this.tabContext && tabId === this.tabContext.tabId
|
||||||
|
&& await this.widgets[tabId].isEnabled());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -421,7 +421,7 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
tabEl.setAttribute('active', '');
|
tabEl.setAttribute('active', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
tabOpenedListener({tabId}) {
|
newTabOpenedListener({tabId}) {
|
||||||
this.addTab(tabId);
|
this.addTab(tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
|
|
||||||
this.$tabContainer.append(this.$newTab);
|
this.$tabContainer.append(this.$newTab);
|
||||||
|
|
||||||
this.$newTab.on('click', _ => this.trigger('newTab'));
|
this.$newTab.on('click', _ => this.trigger('openNewTab'));
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFiller() {
|
setupFiller() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user