Fix open Note in New Window doesn't focus existing window

fix: #5687
This commit is contained in:
windingwind 2026-01-03 11:37:27 +08:00
parent 46385b06fa
commit 47e6a0f7ab
3 changed files with 24 additions and 2 deletions

View file

@ -73,12 +73,18 @@ Zotero.Notes = new function () {
if (noteEditor.viewMode === 'tab') {
win.Zotero_Tabs.select(noteEditor.tabID, true);
}
else {
noteEditor.focus();
}
if (location) {
// TODO: implement this
noteEditor.navigate(location);
}
return noteEditor;
}
else if (openInWindow) {
if (openInWindow) {
let name = null;
if (itemID) {

View file

@ -49,6 +49,18 @@ class EditorInstance {
this.instanceID = Zotero.Utilities.randomString();
}
get itemID() {
return this._item.id;
}
get viewMode() {
return this._viewMode;
}
set viewMode(mode) {
this._viewMode = mode;
}
async init(options) {
Zotero.Notes.registerEditorInstance(this);
this.onNavigate = options.onNavigate;
@ -250,6 +262,7 @@ class EditorInstance {
}
focus() {
this._iframeWindow.focus();
this._postMessage({ action: 'focus' });
}
@ -322,6 +335,9 @@ class EditorInstance {
preserveSelection
});
}
// TODO: implement navigating to note editor location
navigate(_location) {}
_postMessage(message) {
this._iframeWindow.postMessage({ instanceID: this.instanceID, message }, '*');

View file

@ -4655,7 +4655,7 @@ var ZoteroPane = new function () {
openInWindow = Zotero.Prefs.get('openNoteInNewWindow');
}
return Zotero.Notes.open(itemID, {}, {
return Zotero.Notes.open(itemID, undefined, {
openInWindow,
});
};