This commit is contained in:
zadam
2020-02-29 16:26:46 +01:00
parent 3ab2b41e8c
commit 95d1952896
7 changed files with 37 additions and 37 deletions

View File

@@ -69,9 +69,7 @@ export default class Entrypoints extends Component {
await treeService.expandToNote(note.noteId);
const tabContext = appContext.tabManager.openEmptyTab();
appContext.tabManager.activateTab(tabContext.tabId);
await tabContext.setNote(note.noteId);
const tabContext = await appContext.tabManager.openTabWithNote(note.noteId, true);
appContext.triggerCommand('focusAndSelectTitle');
}

View File

@@ -77,8 +77,7 @@ function goToLink(e) {
if (notePath) {
if ((e.which === 1 && e.ctrlKey) || e.which === 2) {
const tabContext = appContext.tabManager.openEmptyTab();
tabContext.setNote(notePath);
appContext.tabManager.openTabWithNote(notePath);
}
else if (e.which === 1) {
const activeTabContext = appContext.tabManager.getActiveTabContext();
@@ -118,8 +117,7 @@ function newTabContextMenu(e) {
],
selectMenuItemHandler: ({command}) => {
if (command === 'openNoteInNewTab') {
const tabContext = appContext.tabManager.openEmptyTab();
tabContext.setNote(notePath);
appContext.tabManager.openTabWithNote(notePath);
}
}
});
@@ -139,8 +137,7 @@ $(document).on('mousedown', '.note-detail-text a', function (e) {
e.preventDefault();
if (notePath) {
const tabContext = appContext.tabManager.openEmptyTab();
tabContext.setNote(notePath);
appContext.tabManager.openTabWithNote(notePath, false);
}
else {
const address = $link.attr('href');

View File

@@ -163,31 +163,31 @@ export default class TabManager extends Component {
async switchToTab(tabId, notePath) {
const tabContext = this.tabContexts.find(tc => tc.tabId === tabId)
|| this.openEmptyTab();
|| await this.openEmptyTab();
this.activateTab(tabContext.tabId);
await tabContext.setNote(notePath);
}
async openAndActivateEmptyTab() {
const tabContext = this.openEmptyTab();
const tabContext = await this.openEmptyTab();
await this.activateTab(tabContext.tabId);
await tabContext.setEmpty();
}
openEmptyTab(tabId) {
async openEmptyTab(tabId) {
const tabContext = new TabContext(tabId);
this.child(tabContext);
this.triggerEvent('newTabOpened', {tabId: tabContext.tabId});
await this.triggerEvent('newTabOpened', {tabId: tabContext.tabId});
return tabContext;
}
async openTabWithNote(notePath, activate, tabId = null) {
const tabContext = this.openEmptyTab(tabId);
const tabContext = await this.openEmptyTab(tabId);
await tabContext.setNote(notePath, !activate); // if activate is false then send normal noteSwitched event
@@ -211,8 +211,7 @@ export default class TabManager extends Component {
// if no tab with this note has been found we'll create new tab
const tabContext = this.openEmptyTab();
await tabContext.setNote(noteId);
await this.openTabWithNote(noteId);
}
activateTab(tabId, triggerEvent = true) {

View File

@@ -108,8 +108,7 @@ class TreeContextMenu {
const notePath = treeService.getNotePath(this.node);
if (command === 'openInTab') {
const tabContext = appContext.tabManager.openEmptyTab();
tabContext.setNote(notePath);
appContext.tabManager.openTabWithNote(notePath);
}
else if (command === "insertNoteAfter") {
const parentNoteId = this.node.data.parentNoteId;