add open note in option

This commit is contained in:
Teven Feng 2023-04-28 07:10:51 +00:00
parent 81ca4f3309
commit 8068710597
5 changed files with 42 additions and 6 deletions

View File

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

View File

@ -19,6 +19,7 @@ import EtapiOptions from "./options/etapi.js";
import BackupOptions from "./options/backup.js";
import SyncOptions from "./options/sync.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 NoteRevisionsSnapshotIntervalOptions from "./options/other/note_revisions_snapshot_interval.js";
import NetworkConnectionsOptions from "./options/other/network_connections.js";
@ -78,7 +79,8 @@ const CONTENT_WIDGETS = {
TrayOptions,
NoteErasureTimeoutOptions,
NoteRevisionsSnapshotIntervalOptions,
NetworkConnectionsOptions
NetworkConnectionsOptions,
OpenNoteInOptions
],
_optionsAdvanced: [
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

@ -61,7 +61,8 @@ const ALLOWED_OPTIONS = new Set([
'downloadImagesAutomatically',
'minTocHeadings',
'checkForUpdates',
'disableTray'
'disableTray',
'openNoteIn'
]);
function getOptions() {

View File

@ -89,6 +89,7 @@ const defaultOptions = [
{ name: 'minTocHeadings', value: '5', isSynced: true },
{ name: 'checkForUpdates', value: 'true', isSynced: true },
{ name: 'disableTray', value: 'false', isSynced: false },
{ name: 'openNoteIn', value: 'curtab', isSynced: true },
];
function initStartupOptions() {