Merge ef5374554deb5099809f13401f074d2f9ff34859 into dc0a0dcf094f904bff4da3abc18f405470b38b37

This commit is contained in:
Teven Feng 2023-07-20 13:21:33 -06:00 committed by GitHub
commit b6b4541292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 2 deletions

View File

@ -293,6 +293,15 @@ export default class TabManager extends Component {
const hoistedNoteId = opts.hoistedNoteId || 'root'; const hoistedNoteId = opts.hoistedNoteId || 'root';
const viewMode = opts.viewMode || "default"; const viewMode = opts.viewMode || "default";
const targetNoteId = await treeService.getNoteIdFromNotePath(notePath);
for (const openedNoteContext of this.getNoteContexts()) {
if (openedNoteContext.note && openedNoteContext.note.noteId === targetNoteId) {
this.activateNoteContext(openedNoteContext.ntxId, true);
return;
}
}
const noteContext = await this.openEmptyTab(ntxId, hoistedNoteId, mainNtxId); const noteContext = await this.openEmptyTab(ntxId, hoistedNoteId, mainNtxId);
if (notePath) { if (notePath) {

View File

@ -366,7 +366,18 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
this.tree.reactivate(true); this.tree.reactivate(true);
} }
else { else {
const openNoteIn = options.get("openNoteIn")
if (openNoteIn === 'curtab') {
node.setActive(); node.setActive();
} else {
const noteId = node.data.noteId;
const notePath = treeService.getNotePath(node);
if (noteId.startsWith('_')) {
node.setActive();
} else {
appContext.tabManager.openTabWithNoteWithHoisting(notePath, true);
}
}
} }
return false; return false;

View File

@ -21,6 +21,7 @@ import BackupOptions from "./options/backup.js";
import SyncOptions from "./options/sync.js"; import SyncOptions from "./options/sync.js";
import SearchEngineOptions from "./options/other/search_engine.js"; import SearchEngineOptions from "./options/other/search_engine.js";
import TrayOptions from "./options/other/tray.js"; import TrayOptions from "./options/other/tray.js";
import OpenNoteInOptions from "./options/other/open_note_in.js"
import NoteErasureTimeoutOptions from "./options/other/note_erasure_timeout.js"; import NoteErasureTimeoutOptions from "./options/other/note_erasure_timeout.js";
import NoteRevisionsSnapshotIntervalOptions from "./options/other/note_revisions_snapshot_interval.js"; import NoteRevisionsSnapshotIntervalOptions from "./options/other/note_revisions_snapshot_interval.js";
import NetworkConnectionsOptions from "./options/other/network_connections.js"; import NetworkConnectionsOptions from "./options/other/network_connections.js";
@ -82,7 +83,8 @@ const CONTENT_WIDGETS = {
TrayOptions, TrayOptions,
NoteErasureTimeoutOptions, NoteErasureTimeoutOptions,
NoteRevisionsSnapshotIntervalOptions, NoteRevisionsSnapshotIntervalOptions,
NetworkConnectionsOptions NetworkConnectionsOptions,
OpenNoteInOptions
], ],
_optionsAdvanced: [ _optionsAdvanced: [
DatabaseIntegrityCheckOptions, DatabaseIntegrityCheckOptions,

View File

@ -0,0 +1,27 @@
import OptionsWidget from "../options_widget.js";
const TPL = `
<div class="options-section">
<h4>Open Note In</h4>
<select class="open-note-in form-control">
<option value="curtab">Current Tab</option>
<option value="newtab">New Tab</option>
</select>
</div>`;
export default class OpenNoteInOptions extends OptionsWidget {
doRender() {
this.$widget = $(TPL);
this.$body = $("body");
this.$openNoteIn = this.$widget.find(".open-note-in");
this.$openNoteIn.on('change', () => {
const newopenNoteIn = this.$openNoteIn.val();
this.updateOption('openNoteIn', newopenNoteIn);
});
}
async optionsLoaded(options) {
this.$openNoteIn.val(options.openNoteIn);
}
}

View File

@ -65,6 +65,7 @@ const ALLOWED_OPTIONS = new Set([
'disableTray', 'disableTray',
'customSearchEngineName', 'customSearchEngineName',
'customSearchEngineUrl', 'customSearchEngineUrl',
'openNoteIn',
]); ]);
function getOptions() { function getOptions() {

View File

@ -92,6 +92,7 @@ const defaultOptions = [
{ name: 'disableTray', value: 'false', isSynced: false }, { name: 'disableTray', value: 'false', isSynced: false },
{ name: 'customSearchEngineName', value: 'Duckduckgo', isSynced: false }, { name: 'customSearchEngineName', value: 'Duckduckgo', isSynced: false },
{ name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: false }, { name: 'customSearchEngineUrl', value: 'https://duckduckgo.com/?q={keyword}', isSynced: false },
{ name: 'openNoteIn', value: 'curtab', isSynced: true },
]; ];
function initStartupOptions() { function initStartupOptions() {