mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
"move to new window" respects note hoisting of original tab
This commit is contained in:
parent
cd5be59413
commit
bed7bdfd00
@ -184,11 +184,15 @@ export default class Entrypoints extends Component {
|
|||||||
|
|
||||||
createTopLevelNoteCommand() { noteCreateService.createNewTopLevelNote(); }
|
createTopLevelNoteCommand() { noteCreateService.createNewTopLevelNote(); }
|
||||||
|
|
||||||
async openInWindowCommand({notePath}) {
|
async openInWindowCommand({notePath, hoistedNoteId}) {
|
||||||
|
if (!hoistedNoteId) {
|
||||||
|
hoistedNoteId = 'root';
|
||||||
|
}
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
const {ipcRenderer} = utils.dynamicRequire('electron');
|
const {ipcRenderer} = utils.dynamicRequire('electron');
|
||||||
|
|
||||||
ipcRenderer.send('create-extra-window', {notePath});
|
ipcRenderer.send('create-extra-window', {notePath, hoistedNoteId});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?extra=1#' + notePath;
|
const url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?extra=1#' + notePath;
|
||||||
@ -198,7 +202,7 @@ export default class Entrypoints extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async openNewWindowCommand() {
|
async openNewWindowCommand() {
|
||||||
this.openInWindowCommand({notePath: ''});
|
this.openInWindowCommand({notePath: '', hoistedNoteId: 'root'});
|
||||||
}
|
}
|
||||||
|
|
||||||
async runActiveNoteCommand() {
|
async runActiveNoteCommand() {
|
||||||
|
@ -39,7 +39,7 @@ async function checkNoteAccess(notePath, tabContext) {
|
|||||||
|
|
||||||
if (hoistedNoteId !== 'root' && !resolvedNotePath.includes(hoistedNoteId)) {
|
if (hoistedNoteId !== 'root' && !resolvedNotePath.includes(hoistedNoteId)) {
|
||||||
const confirmDialog = await import('../dialogs/confirm.js');
|
const confirmDialog = await import('../dialogs/confirm.js');
|
||||||
console.trace("HI!", hoistedNoteId, notePath);
|
|
||||||
if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) {
|
if (!await confirmDialog.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ function linkContextMenu(e) {
|
|||||||
appContext.tabManager.openTabWithNoteWithHoisting(notePath);
|
appContext.tabManager.openTabWithNoteWithHoisting(notePath);
|
||||||
}
|
}
|
||||||
else if (command === 'openNoteInNewWindow') {
|
else if (command === 'openNoteInNewWindow') {
|
||||||
appContext.triggerCommand('openInWindow', {notePath});
|
appContext.triggerCommand('openInWindow', {notePath, hoistedNoteId: 'root'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -145,6 +145,10 @@ class TabContext extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setHoistedNoteId(noteIdToHoist) {
|
async setHoistedNoteId(noteIdToHoist) {
|
||||||
|
if (this.notePathArray && !this.notePathArray.includes(noteIdToHoist)) {
|
||||||
|
await this.setNote(noteIdToHoist);
|
||||||
|
}
|
||||||
|
|
||||||
this.hoistedNoteId = noteIdToHoist;
|
this.hoistedNoteId = noteIdToHoist;
|
||||||
|
|
||||||
await this.triggerEvent('hoistedNoteChanged', {
|
await this.triggerEvent('hoistedNoteChanged', {
|
||||||
|
@ -58,7 +58,8 @@ export default class TabManager extends Component {
|
|||||||
else {
|
else {
|
||||||
tabsToOpen.push({
|
tabsToOpen.push({
|
||||||
notePath: notePath,
|
notePath: notePath,
|
||||||
active: true
|
active: true,
|
||||||
|
hoistedNoteId: glob.extraHoistedNoteId || 'root'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,7 +84,8 @@ export default class TabManager extends Component {
|
|||||||
if (filteredTabs.length === 0) {
|
if (filteredTabs.length === 0) {
|
||||||
filteredTabs.push({
|
filteredTabs.push({
|
||||||
notePath: this.isMainWindow ? 'root' : '',
|
notePath: this.isMainWindow ? 'root' : '',
|
||||||
active: true
|
active: true,
|
||||||
|
extraHoistedNoteId: glob.extraHoistedNoteId || 'root'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +93,8 @@ export default class TabManager extends Component {
|
|||||||
filteredTabs[0].active = true;
|
filteredTabs[0].active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("filteredTabs", filteredTabs);
|
||||||
|
|
||||||
await this.tabsUpdate.allowUpdateWithoutChange(async () => {
|
await this.tabsUpdate.allowUpdateWithoutChange(async () => {
|
||||||
for (const tab of filteredTabs) {
|
for (const tab of filteredTabs) {
|
||||||
await this.openTabWithNote(tab.notePath, tab.active, tab.tabId, tab.hoistedNoteId);
|
await this.openTabWithNote(tab.notePath, tab.active, tab.tabId, tab.hoistedNoteId);
|
||||||
@ -348,11 +352,11 @@ export default class TabManager extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveTabToNewWindowCommand({tabId}) {
|
moveTabToNewWindowCommand({tabId}) {
|
||||||
const notePath = this.getTabContextById(tabId).notePath;
|
const {notePath, hoistedNoteId} = this.getTabContextById(tabId);
|
||||||
|
|
||||||
this.removeTab(tabId);
|
this.removeTab(tabId);
|
||||||
|
|
||||||
this.triggerCommand('openInWindow', {notePath});
|
this.triggerCommand('openInWindow', {notePath, hoistedNoteId});
|
||||||
}
|
}
|
||||||
|
|
||||||
hoistedNoteChangedEvent() {
|
hoistedNoteChangedEvent() {
|
||||||
|
@ -680,4 +680,14 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
this.updateTab($tab, tabContext.note);
|
this.updateTab($tab, tabContext.note);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hoistedNoteChangedEvent({tabId}) {
|
||||||
|
const $tab = this.getTabById(tabId);
|
||||||
|
|
||||||
|
if ($tab) {
|
||||||
|
const tabContext = appContext.tabManager.getTabContextById(tabId);
|
||||||
|
|
||||||
|
this.updateTab($tab, tabContext.note);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@ function index(req, res) {
|
|||||||
instanceName: config.General ? config.General.instanceName : null,
|
instanceName: config.General ? config.General.instanceName : null,
|
||||||
appCssNoteIds: getAppCssNoteIds(),
|
appCssNoteIds: getAppCssNoteIds(),
|
||||||
isDev: env.isDev(),
|
isDev: env.isDev(),
|
||||||
isMainWindow: !req.query.extra
|
isMainWindow: !req.query.extra,
|
||||||
|
extraHoistedNoteId: req.query.extraHoistedNoteId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ let mainWindow;
|
|||||||
/** @type {Electron.BrowserWindow} */
|
/** @type {Electron.BrowserWindow} */
|
||||||
let setupWindow;
|
let setupWindow;
|
||||||
|
|
||||||
async function createExtraWindow(notePath) {
|
async function createExtraWindow(notePath, hoistedNoteId = 'root') {
|
||||||
const {BrowserWindow} = require('electron');
|
const {BrowserWindow} = require('electron');
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 1000,
|
width: 1000,
|
||||||
@ -31,11 +31,11 @@ async function createExtraWindow(notePath) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
win.setMenuBarVisibility(false);
|
win.setMenuBarVisibility(false);
|
||||||
win.loadURL('http://127.0.0.1:' + await port + '/?extra=1#' + notePath);
|
win.loadURL('http://127.0.0.1:' + await port + '/?extra=1&extraHoistedNoteId=' + hoistedNoteId + '#' + notePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcMain.on('create-extra-window', (event, arg) => {
|
ipcMain.on('create-extra-window', (event, arg) => {
|
||||||
createExtraWindow(arg.notePath);
|
createExtraWindow(arg.notePath, arg.hoistedNoteId);
|
||||||
});
|
});
|
||||||
|
|
||||||
async function createMainWindow() {
|
async function createMainWindow() {
|
||||||
|
@ -51,7 +51,8 @@
|
|||||||
csrfToken: '<%= csrfToken %>',
|
csrfToken: '<%= csrfToken %>',
|
||||||
isDev: <%= isDev %>,
|
isDev: <%= isDev %>,
|
||||||
appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>,
|
appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>,
|
||||||
isMainWindow: <%= isMainWindow %>
|
isMainWindow: <%= isMainWindow %>,
|
||||||
|
extraHoistedNoteId: '<%= extraHoistedNoteId %>',
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user