Allow read-only note editing in a separate window in PDF build

This commit is contained in:
Martynas Bagdonas 2021-06-30 16:26:14 +03:00
parent ee9ebc6152
commit 26d784ca0f
2 changed files with 24 additions and 4 deletions

View file

@ -57,7 +57,7 @@ class EditorInstance {
// TODO: Consider to use only itemID instead of loaded item
this._item = options.item;
this._viewMode = options.viewMode;
this._readOnly = options.readOnly;
this._readOnly = options.readOnly || this._isReadOnly();
this._disableUI = options.disableUI;
this._onReturn = options.onReturn;
this._iframeWindow = options.iframeWindow;
@ -199,6 +199,21 @@ class EditorInstance {
this._iframeWindow.postMessage({ instanceID: this.instanceID, message }, '*');
}
_isReadOnly() {
let item = this._item;
if (item.deleted || item.parentItem && item.parentItem.deleted) {
return true;
}
let { libraryID } = item;
var type = Zotero.Libraries.get(libraryID).libraryType;
if (type === 'group') {
var groupID = Zotero.Groups.getGroupIDFromLibraryID(libraryID);
var group = Zotero.Groups.get(groupID);
return !group.editable;
}
return false;
}
_getFont() {
let fontSize = Zotero.Prefs.get('note.fontSize');
// Fix empty old font prefs before a value was enforced

View file

@ -3560,7 +3560,9 @@ var ZoteroPane = new function()
this.openNoteWindow = function (itemID, col, parentKey) {
if (!this.canEdit()) {
var item = Zotero.Items.get(itemID);
var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (!this.canEdit() && (type == 'group' || !Zotero.isPDFBuild)) {
this.displayCannotEditLibraryMessage();
return;
}
@ -3613,7 +3615,9 @@ var ZoteroPane = new function()
this.openBackupNoteWindow = function (itemID) {
if (!this.canEdit()) {
var item = Zotero.Items.get(itemID);
var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (!this.canEdit() && (type == 'group' || !Zotero.isPDFBuild)) {
this.displayCannotEditLibraryMessage();
return;
}
@ -4095,7 +4099,8 @@ var ZoteroPane = new function()
}
}
else if (item.isNote()) {
if (!this.collectionsView.editable) {
var type = Zotero.Libraries.get(item.libraryID).libraryType;
if (!this.collectionsView.editable && (type == 'group' || !Zotero.isPDFBuild)) {
continue;
}
document.getElementById('zotero-view-note-button').doCommand();