Use old editor in group libraries
This commit is contained in:
parent
66bed2529c
commit
04c64fe9fc
6 changed files with 131 additions and 42 deletions
|
@ -360,8 +360,17 @@
|
||||||
indexStatusRow.hidden = true;
|
indexStatusRow.hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// Note editor
|
||||||
|
if (type == 'user') {
|
||||||
var noteEditor = this._id('attachment-note-editor');
|
var noteEditor = this._id('attachment-note-editor');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var noteEditor = this._id('attachment-note-editor-old');
|
||||||
|
}
|
||||||
|
|
||||||
if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) {
|
if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) {
|
||||||
noteEditor.linksOnTop = true;
|
noteEditor.linksOnTop = true;
|
||||||
noteEditor.hidden = false;
|
noteEditor.hidden = false;
|
||||||
|
@ -624,7 +633,10 @@
|
||||||
</grid>
|
</grid>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
||||||
|
<deck id="attachment-note-editor-switcher" flex="1">
|
||||||
|
<oldzoteronoteeditor id="attachment-note-editor-old" notitle="1" flex="1"/>
|
||||||
<zoteronoteeditor id="attachment-note-editor" notitle="1" flex="1"/>
|
<zoteronoteeditor id="attachment-note-editor" notitle="1" flex="1"/>
|
||||||
|
</deck>
|
||||||
|
|
||||||
<button id="select-button" hidden="true"/>
|
<button id="select-button" hidden="true"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
|
|
|
@ -255,29 +255,45 @@ var ZoteroItemPane = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.switchEditorEngine = function (type) {
|
||||||
|
var switherDeck = document.getElementById('zotero-note-editor-switcher');
|
||||||
|
switherDeck.selectedIndex = type == 'user' ? 1 : 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.onNoteSelected = function (item, editable) {
|
this.onNoteSelected = function (item, editable) {
|
||||||
_selectedNoteID = item.id;
|
_selectedNoteID = item.id;
|
||||||
|
|
||||||
// If an external note window is open for this item, don't show the editor
|
var type = Zotero.Libraries.get(item.libraryID).libraryType;
|
||||||
// if (ZoteroPane.findNoteWindow(item.id)) {
|
if (type == 'user') {
|
||||||
// this.showNoteWindowMessage();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
var noteEditor = document.getElementById('zotero-note-editor');
|
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 (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
|
// 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
|
// 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.
|
// undo content from another note into the current one.
|
||||||
// var clearUndo = noteEditor.item ? noteEditor.item.id != item.id : false;
|
var clearUndo = noteEditor.item ? noteEditor.item.id != item.id : false;
|
||||||
|
|
||||||
noteEditor.mode = editable ? 'edit' : 'view';
|
noteEditor.mode = editable ? 'edit' : 'view';
|
||||||
noteEditor.parent = null;
|
noteEditor.parent = null;
|
||||||
noteEditor.item = item;
|
noteEditor.item = item;
|
||||||
|
|
||||||
// if (clearUndo) {
|
if (clearUndo) {
|
||||||
// noteEditor.clearUndo();
|
noteEditor.clearUndo();
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
@ -285,7 +301,7 @@ var ZoteroItemPane = new function() {
|
||||||
|
|
||||||
|
|
||||||
this.showNoteWindowMessage = function () {
|
this.showNoteWindowMessage = function () {
|
||||||
// ZoteroPane.setItemPaneMessage(Zotero.getString('pane.item.notes.editingInWindow'));
|
ZoteroPane.setItemPaneMessage(Zotero.getString('pane.item.notes.editingInWindow'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,6 +311,8 @@ var ZoteroItemPane = new function() {
|
||||||
this.openNoteWindow = async function () {
|
this.openNoteWindow = async function () {
|
||||||
var selectedNote = Zotero.Items.get(_selectedNoteID);
|
var selectedNote = Zotero.Items.get(_selectedNoteID);
|
||||||
|
|
||||||
|
var type = Zotero.Libraries.get(selectedNote.libraryID).libraryType;
|
||||||
|
if (type == 'group') {
|
||||||
// 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.
|
||||||
//
|
//
|
||||||
|
@ -306,6 +324,7 @@ var ZoteroItemPane = new function() {
|
||||||
else {
|
else {
|
||||||
this.showNoteWindowMessage();
|
this.showNoteWindowMessage();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ZoteroPane.openNoteWindow(selectedNote.id);
|
ZoteroPane.openNoteWindow(selectedNote.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,13 @@
|
||||||
'onerror' handler crashes the app on a save error to prevent typing in notes
|
'onerror' handler crashes the app on a save error to prevent typing in notes
|
||||||
while they're not being saved
|
while they're not being saved
|
||||||
-->
|
-->
|
||||||
|
<deck id="zotero-note-editor-switcher" flex="1">
|
||||||
|
<oldzoteronoteeditor id="zotero-note-editor-old" flex="1" notitle="1"
|
||||||
|
previousfocus="zotero-items-tree"
|
||||||
|
onerror="ZoteroPane.displayErrorMessage(); this.mode = 'view'"/>
|
||||||
<zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1"
|
<zoteronoteeditor id="zotero-note-editor" flex="1" notitle="1"
|
||||||
previousfocus="zotero-items-tree"/>
|
previousfocus="zotero-items-tree"/>
|
||||||
|
</deck>
|
||||||
<button id="zotero-view-note-button"
|
<button id="zotero-view-note-button"
|
||||||
label="&zotero.notes.separate;"
|
label="&zotero.notes.separate;"
|
||||||
oncommand="ZoteroItemPane.openNoteWindow()"/>
|
oncommand="ZoteroItemPane.openNoteWindow()"/>
|
||||||
|
|
|
@ -25,14 +25,14 @@
|
||||||
|
|
||||||
var noteEditor;
|
var noteEditor;
|
||||||
var notifierUnregisterID;
|
var notifierUnregisterID;
|
||||||
|
var type;
|
||||||
|
|
||||||
|
function switchEditorEngine(type) {
|
||||||
|
var switherDeck = document.getElementById('zotero-note-editor-switcher');
|
||||||
|
switherDeck.selectedIndex = type === 'user' ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
async function onLoad() {
|
async function onLoad() {
|
||||||
noteEditor = document.getElementById('zotero-note-editor');
|
|
||||||
noteEditor.mode = 'edit';
|
|
||||||
|
|
||||||
// Set font size from pref
|
|
||||||
Zotero.setFontSize(noteEditor);
|
|
||||||
|
|
||||||
if (window.arguments) {
|
if (window.arguments) {
|
||||||
var io = window.arguments[0];
|
var io = window.arguments[0];
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,35 @@ async function onLoad() {
|
||||||
var collectionID = parseInt(io.collectionID);
|
var collectionID = parseInt(io.collectionID);
|
||||||
var parentItemKey = io.parentItemKey;
|
var parentItemKey = io.parentItemKey;
|
||||||
|
|
||||||
|
if (itemID) {
|
||||||
|
var ref = await Zotero.Items.getAsync(itemID);
|
||||||
|
var libraryID = ref.libraryID;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (parentItemKey) {
|
||||||
|
var ref = Zotero.Items.getByLibraryAndKey(parentItemKey);
|
||||||
|
var libraryID = ref.libraryID;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (collectionID && collectionID != '' && collectionID != 'undefined') {
|
||||||
|
var collection = Zotero.Collections.get(collectionID);
|
||||||
|
var libraryID = collection.libraryID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type = Zotero.Libraries.get(libraryID).libraryType;
|
||||||
|
switchEditorEngine(type);
|
||||||
|
if (type === 'group') {
|
||||||
|
noteEditor = document.getElementById('zotero-note-editor-old');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
noteEditor = document.getElementById('zotero-note-editor');
|
||||||
|
}
|
||||||
|
noteEditor.mode = 'edit';
|
||||||
|
|
||||||
|
// Set font size from pref
|
||||||
|
Zotero.setFontSize(noteEditor);
|
||||||
|
|
||||||
if (itemID) {
|
if (itemID) {
|
||||||
var ref = await Zotero.Items.getAsync(itemID);
|
var ref = await Zotero.Items.getAsync(itemID);
|
||||||
noteEditor.item = ref;
|
noteEditor.item = ref;
|
||||||
|
@ -77,7 +106,14 @@ function onError() {
|
||||||
|
|
||||||
function onUnload() {
|
function onUnload() {
|
||||||
Zotero.Notifier.unregisterObserver(notifierUnregisterID);
|
Zotero.Notifier.unregisterObserver(notifierUnregisterID);
|
||||||
|
if (type == 'user') {
|
||||||
noteEditor.saveSync();
|
noteEditor.saveSync();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (noteEditor.item) {
|
||||||
|
window.opener.ZoteroPane.onNoteWindowClosed(noteEditor.item.id, noteEditor.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var NotifyCallback = {
|
var NotifyCallback = {
|
||||||
|
|
|
@ -22,5 +22,8 @@
|
||||||
</keyset>
|
</keyset>
|
||||||
<command id="cmd_close" oncommand="window.close();"/>
|
<command id="cmd_close" oncommand="window.close();"/>
|
||||||
|
|
||||||
|
<deck id="zotero-note-editor-switcher" flex="1">
|
||||||
|
<oldzoteronoteeditor id="zotero-note-editor-old" flex="1" onerror="onError()"/>
|
||||||
<zoteronoteeditor id="zotero-note-editor" flex="1" onerror="return;onError()"/>
|
<zoteronoteeditor id="zotero-note-editor" flex="1" onerror="return;onError()"/>
|
||||||
|
</deck>
|
||||||
</window>
|
</window>
|
||||||
|
|
|
@ -1198,6 +1198,7 @@ var ZoteroPane = new function()
|
||||||
|
|
||||||
// Rename tab
|
// Rename tab
|
||||||
Zotero_Tabs.rename('zotero-pane', collectionTreeRow.getName());
|
Zotero_Tabs.rename('zotero-pane', collectionTreeRow.getName());
|
||||||
|
ZoteroItemPane.switchEditorEngine(Zotero.Libraries.get(collectionTreeRow.ref.libraryID).libraryType);
|
||||||
|
|
||||||
// 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 = "";
|
||||||
|
@ -3556,6 +3557,19 @@ var ZoteroPane = new function()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
this.onNoteWindowClosed = async function (itemID, noteText) {
|
||||||
|
var item = Zotero.Items.get(itemID);
|
||||||
|
item.setNote(noteText);
|
||||||
|
await item.saveTx();
|
||||||
|
|
||||||
|
// If note is still selected, show the editor again when the note window closes
|
||||||
|
var selectedItems = this.getSelectedItems(true);
|
||||||
|
if (selectedItems.length == 1 && itemID == selectedItems[0]) {
|
||||||
|
ZoteroItemPane.onNoteSelected(item, this.collectionsView.editable);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.openBackupNoteWindow = function (itemID) {
|
this.openBackupNoteWindow = function (itemID) {
|
||||||
if (!this.canEdit()) {
|
if (!this.canEdit()) {
|
||||||
this.displayCannotEditLibraryMessage();
|
this.displayCannotEditLibraryMessage();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue