Use isPDFBuild for editor switch, fix merge dialog

This commit is contained in:
Martynas Bagdonas 2021-02-16 11:05:45 +02:00 committed by Dan Stillman
parent bb9237e82d
commit 1a4b2e8c7d
5 changed files with 32 additions and 28 deletions

View file

@ -362,13 +362,14 @@
var type = Zotero.Libraries.get(this.item.libraryID).libraryType; var type = Zotero.Libraries.get(this.item.libraryID).libraryType;
var switherDeck = this._id('attachment-note-editor-switcher'); var switherDeck = this._id('attachment-note-editor-switcher');
switherDeck.selectedIndex = type == 'user' ? 1 : 0;
// Note editor // Note editor
if (type == 'user') { if (type == 'group' || !Zotero.isPDFBuild) {
var noteEditor = this._id('attachment-note-editor'); var noteEditor = this._id('attachment-note-editor-old');
switherDeck.selectedIndex = 0;
} }
else { else {
var noteEditor = this._id('attachment-note-editor-old'); var noteEditor = this._id('attachment-note-editor');
switherDeck.selectedIndex = 1;
} }
if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) { if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) {

View file

@ -335,7 +335,9 @@
break; break;
case 'note': case 'note':
elementName = 'zoteronoteeditor'; var type = Zotero.Libraries.get(this.libraryID).libraryType;
var useOld = type == 'group' || !Zotero.isPDFBuild;
elementName = useOld ? 'oldzoteronoteeditor' : 'zoteronoteeditor';
break; break;
default: default:

View file

@ -255,9 +255,9 @@ var ZoteroItemPane = new function() {
} }
this.switchEditorEngine = function (type) { this.switchEditorEngine = function (useOld) {
var switherDeck = document.getElementById('zotero-note-editor-switcher'); var switherDeck = document.getElementById('zotero-note-editor-switcher');
switherDeck.selectedIndex = type == 'user' ? 1 : 0; switherDeck.selectedIndex = useOld ? 0 : 1;
}; };
@ -265,14 +265,7 @@ var ZoteroItemPane = new function() {
_selectedNoteID = item.id; _selectedNoteID = item.id;
var type = Zotero.Libraries.get(item.libraryID).libraryType; var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (type == 'user') { if (type == 'group' || !Zotero.isPDFBuild) {
var noteEditor = document.getElementById('zotero-note-editor');
noteEditor.mode = editable ? 'edit' : 'view';
noteEditor.parent = null;
noteEditor.item = item;
}
else {
// If an external note window is open for this item, don't show the editor // If an external note window is open for this item, don't show the editor
if (ZoteroPane.findNoteWindow(item.id)) { if (ZoteroPane.findNoteWindow(item.id)) {
this.showNoteWindowMessage(); this.showNoteWindowMessage();
@ -294,6 +287,12 @@ var ZoteroItemPane = new function() {
noteEditor.clearUndo(); noteEditor.clearUndo();
} }
} }
else {
var noteEditor = document.getElementById('zotero-note-editor');
noteEditor.mode = editable ? 'edit' : 'view';
noteEditor.parent = null;
noteEditor.item = item;
}
document.getElementById('zotero-view-note-button').hidden = !editable; document.getElementById('zotero-view-note-button').hidden = !editable;
document.getElementById('zotero-item-pane-content').selectedIndex = 2; document.getElementById('zotero-item-pane-content').selectedIndex = 2;
@ -312,7 +311,7 @@ var ZoteroItemPane = new function() {
var selectedNote = Zotero.Items.get(_selectedNoteID); var selectedNote = Zotero.Items.get(_selectedNoteID);
var type = Zotero.Libraries.get(selectedNote.libraryID).libraryType; var type = Zotero.Libraries.get(selectedNote.libraryID).libraryType;
if (type == 'group') { if (type == 'group' || !Zotero.isPDFBuild) {
// We don't want to show the note in two places, since it causes unnecessary UI updates // We don't want to show the note in two places, since it causes unnecessary UI updates
// and can result in weird bugs where note content gets lost. // and can result in weird bugs where note content gets lost.
// //

View file

@ -27,9 +27,9 @@ var noteEditor;
var notifierUnregisterID; var notifierUnregisterID;
var type; var type;
function switchEditorEngine(type) { function switchEditorEngine(useOld) {
var switherDeck = document.getElementById('zotero-note-editor-switcher'); var switherDeck = document.getElementById('zotero-note-editor-switcher');
switherDeck.selectedIndex = type === 'user' ? 1 : 0; switherDeck.selectedIndex = useOld ? 0 : 1;
} }
async function onLoad() { async function onLoad() {
@ -58,8 +58,8 @@ async function onLoad() {
} }
} }
type = Zotero.Libraries.get(libraryID).libraryType; type = Zotero.Libraries.get(libraryID).libraryType;
switchEditorEngine(type); switchEditorEngine(type == 'group' || !Zotero.isPDFBuild);
if (type === 'group') { if (type == 'group' || !Zotero.isPDFBuild) {
noteEditor = document.getElementById('zotero-note-editor-old'); noteEditor = document.getElementById('zotero-note-editor-old');
} }
else { else {
@ -106,14 +106,14 @@ function onError() {
function onUnload() { function onUnload() {
Zotero.Notifier.unregisterObserver(notifierUnregisterID); Zotero.Notifier.unregisterObserver(notifierUnregisterID);
if (type == 'user') { if (type == 'group' || !Zotero.isPDFBuild) {
noteEditor.saveSync();
}
else {
if (noteEditor.item) { if (noteEditor.item) {
window.opener.ZoteroPane.onNoteWindowClosed(noteEditor.item.id, noteEditor.value); window.opener.ZoteroPane.onNoteWindowClosed(noteEditor.item.id, noteEditor.value);
} }
} }
else {
noteEditor.saveSync();
}
} }
var NotifyCallback = { var NotifyCallback = {

View file

@ -1207,7 +1207,9 @@ var ZoteroPane = new function()
if (Zotero.isPDFBuild) { if (Zotero.isPDFBuild) {
Zotero_Tabs.rename('zotero-pane', collectionTreeRow.getName()); Zotero_Tabs.rename('zotero-pane', collectionTreeRow.getName());
} }
ZoteroItemPane.switchEditorEngine(Zotero.Libraries.get(collectionTreeRow.ref.libraryID).libraryType);
let type = Zotero.Libraries.get(collectionTreeRow.ref.libraryID).libraryType;
ZoteroItemPane.switchEditorEngine(type == 'group' || !Zotero.isPDFBuild);
// Clear quick search and tag selector when switching views // Clear quick search and tag selector when switching views
document.getElementById('zotero-tb-search').value = ""; document.getElementById('zotero-tb-search').value = "";