Don't copy/import/delete note images if library files aren't editable
#2364
This commit is contained in:
parent
9ca617a6a9
commit
04fa89ffc8
3 changed files with 31 additions and 24 deletions
|
@ -1632,7 +1632,9 @@ var CollectionTree = class CollectionTree extends LibraryTree {
|
|||
await newItem.addLinkedItem(item);
|
||||
|
||||
if (item.isNote()) {
|
||||
if (Zotero.Libraries.get(newItem.libraryID).filesEditable) {
|
||||
await Zotero.Notes.copyEmbeddedImages(item, newItem);
|
||||
}
|
||||
return newItemID;
|
||||
}
|
||||
|
||||
|
@ -1649,7 +1651,9 @@ var CollectionTree = class CollectionTree extends LibraryTree {
|
|||
skipSelect: true
|
||||
})
|
||||
|
||||
if (Zotero.Libraries.get(newNote.libraryID).filesEditable) {
|
||||
await Zotero.Notes.copyEmbeddedImages(note, newNote);
|
||||
}
|
||||
await newNote.addLinkedItem(note);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ class EditorInstance {
|
|||
this._reloaded = options.reloaded;
|
||||
this._viewMode = options.viewMode;
|
||||
this._readOnly = options.readOnly || this._isReadOnly();
|
||||
this._filesReadOnly = !Zotero.Libraries.get(this._item.libraryID).filesEditable;
|
||||
this._disableUI = options.disableUI;
|
||||
this._onReturn = options.onReturn;
|
||||
this._iframeWindow = options.iframeWindow;
|
||||
|
@ -131,7 +132,7 @@ class EditorInstance {
|
|||
this._iframeWindow.removeEventListener('message', this._messageHandler);
|
||||
this.saveSync();
|
||||
await Zotero.Notes.unregisterEditorInstance(this);
|
||||
if (!this._item.isAttachment()) {
|
||||
if (!this._item.isAttachment() && !this._filesReadOnly) {
|
||||
await Zotero.Notes.deleteUnusedEmbeddedImages(this._item);
|
||||
}
|
||||
}
|
||||
|
@ -370,7 +371,7 @@ class EditorInstance {
|
|||
}
|
||||
|
||||
// Image
|
||||
if (annotation.image) {
|
||||
if (annotation.image && !this._filesReadOnly) {
|
||||
// We assume that annotation.image is always PNG
|
||||
let imageAttachmentKey = await this._importImage(annotation.image);
|
||||
delete annotation.image;
|
||||
|
@ -517,6 +518,7 @@ class EditorInstance {
|
|||
}
|
||||
|
||||
// Clone all note image attachments and replace keys in the new note
|
||||
if (!this._filesReadOnly) {
|
||||
let attachments = Zotero.Items.get(item.getAttachments());
|
||||
for (let attachment of attachments) {
|
||||
if (!await attachment.fileExists()) {
|
||||
|
@ -538,6 +540,7 @@ class EditorInstance {
|
|||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
html += `<p></p>${doc.body.innerHTML}<p></p>`;
|
||||
}
|
||||
|
@ -736,7 +739,7 @@ class EditorInstance {
|
|||
}
|
||||
case 'importImages': {
|
||||
let { images } = message;
|
||||
if (this._readOnly) {
|
||||
if (this._readOnly || this._filesReadOnly) {
|
||||
return;
|
||||
}
|
||||
if (this._item.isAttachment()) {
|
||||
|
|
|
@ -1665,7 +1665,7 @@ var ZoteroPane = new function()
|
|||
newItem.setCollections([self.getCollectionTreeRow().ref.id]);
|
||||
}
|
||||
yield newItem.save();
|
||||
if (item.isNote()) {
|
||||
if (item.isNote() && Zotero.Libraries.get(newItem.libraryID).filesEditable) {
|
||||
yield Zotero.Notes.copyEmbeddedImages(item, newItem);
|
||||
}
|
||||
for (let relItemKey of item.relatedItems) {
|
||||
|
|
Loading…
Reference in a new issue