Use isPDFBuild for editor switch, fix merge dialog
This commit is contained in:
parent
bb9237e82d
commit
1a4b2e8c7d
5 changed files with 32 additions and 28 deletions
|
@ -362,13 +362,14 @@
|
|||
|
||||
var type = Zotero.Libraries.get(this.item.libraryID).libraryType;
|
||||
var switherDeck = this._id('attachment-note-editor-switcher');
|
||||
switherDeck.selectedIndex = type == 'user' ? 1 : 0;
|
||||
// Note editor
|
||||
if (type == 'user') {
|
||||
var noteEditor = this._id('attachment-note-editor');
|
||||
if (type == 'group' || !Zotero.isPDFBuild) {
|
||||
var noteEditor = this._id('attachment-note-editor-old');
|
||||
switherDeck.selectedIndex = 0;
|
||||
}
|
||||
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 != '')) {
|
||||
|
|
|
@ -335,7 +335,9 @@
|
|||
break;
|
||||
|
||||
case 'note':
|
||||
elementName = 'zoteronoteeditor';
|
||||
var type = Zotero.Libraries.get(this.libraryID).libraryType;
|
||||
var useOld = type == 'group' || !Zotero.isPDFBuild;
|
||||
elementName = useOld ? 'oldzoteronoteeditor' : 'zoteronoteeditor';
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -255,9 +255,9 @@ var ZoteroItemPane = new function() {
|
|||
}
|
||||
|
||||
|
||||
this.switchEditorEngine = function (type) {
|
||||
this.switchEditorEngine = function (useOld) {
|
||||
var switherDeck = document.getElementById('zotero-note-editor-switcher');
|
||||
switherDeck.selectedIndex = type == 'user' ? 1 : 0;
|
||||
switherDeck.selectedIndex = useOld ? 0 : 1;
|
||||
};
|
||||
|
||||
|
||||
|
@ -265,27 +265,20 @@ var ZoteroItemPane = new function() {
|
|||
_selectedNoteID = item.id;
|
||||
|
||||
var type = Zotero.Libraries.get(item.libraryID).libraryType;
|
||||
if (type == 'user') {
|
||||
var noteEditor = document.getElementById('zotero-note-editor');
|
||||
|
||||
noteEditor.mode = editable ? 'edit' : 'view';
|
||||
noteEditor.parent = null;
|
||||
noteEditor.item = item;
|
||||
}
|
||||
else {
|
||||
if (type == 'group' || !Zotero.isPDFBuild) {
|
||||
// If an external note window is open for this item, don't show the editor
|
||||
if (ZoteroPane.findNoteWindow(item.id)) {
|
||||
this.showNoteWindowMessage();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var noteEditor = document.getElementById('zotero-note-editor-old');
|
||||
|
||||
|
||||
// If loading new or different note, disable undo while we repopulate the text field
|
||||
// so Undo doesn't end up clearing the field. This also ensures that Undo doesn't
|
||||
// undo content from another note into the current one.
|
||||
var clearUndo = noteEditor.item ? noteEditor.item.id != item.id : false;
|
||||
|
||||
|
||||
noteEditor.mode = editable ? 'edit' : 'view';
|
||||
noteEditor.parent = null;
|
||||
noteEditor.item = item;
|
||||
|
@ -294,6 +287,12 @@ var ZoteroItemPane = new function() {
|
|||
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-item-pane-content').selectedIndex = 2;
|
||||
|
@ -312,7 +311,7 @@ var ZoteroItemPane = new function() {
|
|||
var selectedNote = Zotero.Items.get(_selectedNoteID);
|
||||
|
||||
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
|
||||
// and can result in weird bugs where note content gets lost.
|
||||
//
|
||||
|
|
|
@ -27,9 +27,9 @@ var noteEditor;
|
|||
var notifierUnregisterID;
|
||||
var type;
|
||||
|
||||
function switchEditorEngine(type) {
|
||||
function switchEditorEngine(useOld) {
|
||||
var switherDeck = document.getElementById('zotero-note-editor-switcher');
|
||||
switherDeck.selectedIndex = type === 'user' ? 1 : 0;
|
||||
switherDeck.selectedIndex = useOld ? 0 : 1;
|
||||
}
|
||||
|
||||
async function onLoad() {
|
||||
|
@ -58,8 +58,8 @@ async function onLoad() {
|
|||
}
|
||||
}
|
||||
type = Zotero.Libraries.get(libraryID).libraryType;
|
||||
switchEditorEngine(type);
|
||||
if (type === 'group') {
|
||||
switchEditorEngine(type == 'group' || !Zotero.isPDFBuild);
|
||||
if (type == 'group' || !Zotero.isPDFBuild) {
|
||||
noteEditor = document.getElementById('zotero-note-editor-old');
|
||||
}
|
||||
else {
|
||||
|
@ -106,14 +106,14 @@ function onError() {
|
|||
|
||||
function onUnload() {
|
||||
Zotero.Notifier.unregisterObserver(notifierUnregisterID);
|
||||
if (type == 'user') {
|
||||
noteEditor.saveSync();
|
||||
}
|
||||
else {
|
||||
if (type == 'group' || !Zotero.isPDFBuild) {
|
||||
if (noteEditor.item) {
|
||||
window.opener.ZoteroPane.onNoteWindowClosed(noteEditor.item.id, noteEditor.value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
noteEditor.saveSync();
|
||||
}
|
||||
}
|
||||
|
||||
var NotifyCallback = {
|
||||
|
|
|
@ -1207,7 +1207,9 @@ var ZoteroPane = new function()
|
|||
if (Zotero.isPDFBuild) {
|
||||
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
|
||||
document.getElementById('zotero-tb-search').value = "";
|
||||
|
|
Loading…
Reference in a new issue