Replace occurrences of .getNote() with .note

This commit is contained in:
Dan Stillman 2020-08-25 14:22:23 -04:00
parent ebc53a2bbc
commit 4142f4b316
12 changed files with 36 additions and 36 deletions

View file

@ -362,7 +362,7 @@
// Note editor // Note editor
var noteEditor = this._id('attachment-note-editor'); var noteEditor = this._id('attachment-note-editor');
if (this.displayNote && (this.displayNoteIfEmpty || this.item.getNote() != '')) { if (this.displayNote && (this.displayNoteIfEmpty || this.item.note != '')) {
noteEditor.linksOnTop = true; noteEditor.linksOnTop = true;
noteEditor.hidden = false; noteEditor.hidden = false;

View file

@ -101,12 +101,12 @@
} }
} }
else { else {
let curValue = this.item.getNote(); let curValue = this.item.note;
if (curValue !== this._lastHtmlValue) { if (curValue !== this._lastHtmlValue) {
this.initEditor(); this.initEditor();
} }
} }
this._lastHtmlValue = this.item.getNote(); this._lastHtmlValue = this.item.note;
} }
this._id('links-container').hidden = !(this.displayTags && this.displayRelated); this._id('links-container').hidden = !(this.displayTags && this.displayRelated);
@ -192,7 +192,7 @@
if (!val) this._item = null; if (!val) this._item = null;
if (this._item && this._item.id === val.id) return; if (this._item && this._item.id === val.id) return;
this._lastHtmlValue = val.getNote(); this._lastHtmlValue = val.note;
this._editor = new Zotero.NoteEditor(); this._editor = new Zotero.NoteEditor();
this._editor.init({ this._editor.init({

View file

@ -31,7 +31,7 @@ class NoteEditor {
this.window.addEventListener('message', this.listener); this.window.addEventListener('message', this.listener);
this.quickFormatWindow = null; this.quickFormatWindow = null;
let data = this.state ? { state: this.state } : { html: this.item.getNote() }; let data = this.state ? { state: this.state } : { html: this.item.note };
this.postMessage({ this.postMessage({
op: 'init', ...data, op: 'init', ...data,
libraryId: this.item.libraryID, libraryId: this.item.libraryID,

View file

@ -2019,7 +2019,7 @@ Zotero.Item.prototype.numNotes = function(includeTrashed, includeEmbedded) {
if (includeEmbedded) { if (includeEmbedded) {
// Include embedded attachment notes that aren't empty // Include embedded attachment notes that aren't empty
num += Zotero.Items.get(this.getAttachments(includeTrashed)) num += Zotero.Items.get(this.getAttachments(includeTrashed))
.filter(x => x.getNote() !== '').length; .filter(x => x.note !== '').length;
} }
return num; return num;
} }
@ -2073,7 +2073,7 @@ Zotero.Item.prototype.hasNote = Zotero.Promise.coroutine(function* () {
Zotero.defineProperty(Zotero.Item.prototype, 'note', { Zotero.defineProperty(Zotero.Item.prototype, 'note', {
get: function () { get: function () {
if (!this.isNote() && !this.isAttachment()) { if (!this.isNote() && !this.isAttachment()) {
throw new Error("getNote() can only be called on notes and attachments " throw new Error(".note can only be accessed on notes and attachments "
+ `(${this.libraryID}/${this.key} is a ${Zotero.ItemTypes.getName(this.itemTypeID)})`); + `(${this.libraryID}/${this.key} is a ${Zotero.ItemTypes.getName(this.itemTypeID)})`);
} }

View file

@ -80,7 +80,7 @@ Zotero.Notes = new function() {
* @returns {Promise} * @returns {Promise}
*/ */
this.updateURIs = async (item) => { this.updateURIs = async (item) => {
let html = item.getNote(); let html = item.note;
let num = 0; let num = 0;
// "uri":"http://zotero.org/users/local/(.+?)/items/(.+?)" // "uri":"http://zotero.org/users/local/(.+?)/items/(.+?)"
let regex = new RegExp(/%22uri%22%3A%22http%3A%2F%2Fzotero.org%2Fusers%2Flocal%2F(.+?)%2Fitems%2F(.+?)%22/g); let regex = new RegExp(/%22uri%22%3A%22http%3A%2F%2Fzotero.org%2Fusers%2Flocal%2F(.+?)%2Fitems%2F(.+?)%22/g);

View file

@ -3509,7 +3509,7 @@ Zotero.ItemTreeRow.prototype.numNotes = function() {
return 0; return 0;
} }
if (this.ref.isAttachment()) { if (this.ref.isAttachment()) {
return this.ref.getNote() !== '' ? 1 : 0; return this.ref.note !== '' ? 1 : 0;
} }
return this.ref.numNotes(false, true) || 0; return this.ref.numNotes(false, true) || 0;
} }

View file

@ -292,7 +292,7 @@ Zotero.QuickCopy = new function() {
div.className = "zotero-note"; div.className = "zotero-note";
// AMO reviewer: This documented is never rendered (and the inserted markup // AMO reviewer: This documented is never rendered (and the inserted markup
// is sanitized anyway) // is sanitized anyway)
div.insertAdjacentHTML('afterbegin', notes[i].getNote()); div.insertAdjacentHTML('afterbegin', notes[i].note);
container.appendChild(div); container.appendChild(div);
textContainer.appendChild(textDoc.importNode(div, true)); textContainer.appendChild(textDoc.importNode(div, true));
} }

View file

@ -3490,7 +3490,7 @@ var ZoteroPane = new function()
var items = this.getSelectedItems(); var items = this.getSelectedItems();
if (this.itemsView.selection.count == 1 && items[0] && items[0].isNote()) { if (this.itemsView.selection.count == 1 && items[0] && items[0].isNote()) {
var note = items[0].getNote() var note = items[0].note;
items[0].setNote(note + text); items[0].setNote(note + text);
yield items[0].saveTx(); yield items[0].saveTx();

View file

@ -1327,7 +1327,7 @@ describe("Zotero.Attachments", function() {
assert.equal(newAttachment.attachmentContentType, 'application/pdf'); assert.equal(newAttachment.attachmentContentType, 'application/pdf');
assert.isTrue(await newAttachment.fileExists()); assert.isTrue(await newAttachment.fileExists());
assert.equal(newAttachment.getField('title'), 'Title'); assert.equal(newAttachment.getField('title'), 'Title');
assert.equal(newAttachment.getNote(), 'Note'); assert.equal(newAttachment.note, 'Note');
assert.sameDeepMembers(newAttachment.getTags(), [{ tag: 'Tag' }]); assert.sameDeepMembers(newAttachment.getTags(), [{ tag: 'Tag' }]);
assert.sameMembers(newAttachment.relatedItems, [relatedItem.key]); assert.sameMembers(newAttachment.relatedItems, [relatedItem.key]);
assert.sameMembers(relatedItem.relatedItems, [newAttachment.key]); assert.sameMembers(relatedItem.relatedItems, [newAttachment.key]);

View file

@ -227,21 +227,21 @@ describe("Zotero.DataObject", function() {
var item = new Zotero.Item('book'); var item = new Zotero.Item('book');
var id = yield item.saveTx(); var id = yield item.saveTx();
yield item.loadAllData(); yield item.loadAllData();
assert.throws(item.getNote.bind(item), 'getNote() can only be called on notes and attachments'); assert.throws(item.getNote.bind(item), 'note can only be called on notes and attachments');
}) })
it("should load data on an attachment item", function* () { it("should load data on an attachment item", function* () {
var item = new Zotero.Item('attachment'); var item = new Zotero.Item('attachment');
var id = yield item.saveTx(); var id = yield item.saveTx();
yield item.loadAllData(); yield item.loadAllData();
assert.equal(item.getNote(), ''); assert.equal(item.note, '');
}) })
it("should load data on a note item", function* () { it("should load data on a note item", function* () {
var item = new Zotero.Item('note'); var item = new Zotero.Item('note');
var id = yield item.saveTx(); var id = yield item.saveTx();
yield item.loadAllData(); yield item.loadAllData();
assert.equal(item.getNote(), ''); assert.equal(item.note, '');
}) })
}) })

View file

@ -339,7 +339,7 @@ describe("Zotero.Sync.Data.Engine", function () {
yield assertInCache(obj); yield assertInCache(obj);
obj = yield Zotero.Items.getByLibraryAndKeyAsync(userLibraryID, "BBBBBBBB"); obj = yield Zotero.Items.getByLibraryAndKeyAsync(userLibraryID, "BBBBBBBB");
assert.equal(obj.getNote(), 'This is a note.'); assert.equal(obj.note, 'This is a note.');
assert.equal(obj.parentItemID, parentItemID); assert.equal(obj.parentItemID, parentItemID);
assert.equal(obj.version, 3); assert.equal(obj.version, 3);
assert.isTrue(obj.synced); assert.isTrue(obj.synced);
@ -513,7 +513,7 @@ describe("Zotero.Sync.Data.Engine", function () {
yield assertInCache(obj); yield assertInCache(obj);
obj = Zotero.Items.getByLibraryAndKey(libraryID, "BBBBBBBB"); obj = Zotero.Items.getByLibraryAndKey(libraryID, "BBBBBBBB");
assert.equal(obj.getNote(), 'This is a note.'); assert.equal(obj.note, 'This is a note.');
assert.equal(obj.parentItemID, parentItemID); assert.equal(obj.parentItemID, parentItemID);
assert.equal(obj.version, 3); assert.equal(obj.version, 3);
assert.isTrue(obj.synced); assert.isTrue(obj.synced);
@ -3487,7 +3487,7 @@ describe("Zotero.Sync.Data.Engine", function () {
await obj.saveTx({ await obj.saveTx({
skipDateModifiedUpdate: true skipDateModifiedUpdate: true
}); });
values[i].left.note = obj.getNote(); values[i].left.note = obj.note;
values[i].left.version = obj.getField('version'); values[i].left.version = obj.getField('version');
} }
@ -3529,8 +3529,8 @@ describe("Zotero.Sync.Data.Engine", function () {
await engine._downloadObjects('item', objects.map(o => o.key)); await engine._downloadObjects('item', objects.map(o => o.key));
await crPromise; await crPromise;
assert.equal(objects[0].getNote(), values[0].right.note); assert.equal(objects[0].note, values[0].right.note);
assert.equal(objects[1].getNote(), values[1].left.note); assert.equal(objects[1].note, values[1].left.note);
assert.equal(objects[0].version, values[0].right.version); assert.equal(objects[0].version, values[0].right.version);
assert.equal(objects[1].version, values[1].right.version); assert.equal(objects[1].version, values[1].right.version);
assert.isTrue(objects[0].synced); assert.isTrue(objects[0].synced);

View file

@ -213,13 +213,13 @@ describe("Zotero.Translate", function() {
let noteIDs = newItems["Test Item"].getNotes(); let noteIDs = newItems["Test Item"].getNotes();
let note1 = yield Zotero.Items.getAsync(noteIDs[0]); let note1 = yield Zotero.Items.getAsync(noteIDs[0]);
assert.equal(Zotero.ItemTypes.getName(note1.itemTypeID), "note"); assert.equal(Zotero.ItemTypes.getName(note1.itemTypeID), "note");
assert.equal(note1.getNote(), "1 note as string"); assert.equal(note1.note, "1 note as string");
let note2 = yield Zotero.Items.getAsync(noteIDs[1]); let note2 = yield Zotero.Items.getAsync(noteIDs[1]);
assert.equal(Zotero.ItemTypes.getName(note2.itemTypeID), "note"); assert.equal(Zotero.ItemTypes.getName(note2.itemTypeID), "note");
assert.equal(note2.getNote(), "2 note as object"); assert.equal(note2.note, "2 note as object");
checkTestTags(note2); checkTestTags(note2);
let note3 = newItems["standalone note"]; let note3 = newItems["standalone note"];
assert.equal(note3.getNote(), "standalone note"); assert.equal(note3.note, "standalone note");
checkTestTags(note3); checkTestTags(note3);
}); });
@ -323,20 +323,20 @@ describe("Zotero.Translate", function() {
for (let savedAttachments of [[newItems["Empty PDF"], newItems["Link to zotero.org"]], for (let savedAttachments of [[newItems["Empty PDF"], newItems["Link to zotero.org"]],
[containedAttachments[0], containedAttachments[1]]]) { [containedAttachments[0], containedAttachments[1]]]) {
assert.equal(savedAttachments[0].getField("title"), "Empty PDF"); assert.equal(savedAttachments[0].getField("title"), "Empty PDF");
assert.equal(savedAttachments[0].getNote(), "attachment note"); assert.equal(savedAttachments[0].note, "attachment note");
assert.equal(savedAttachments[0].attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_FILE); assert.equal(savedAttachments[0].attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_FILE);
checkTestTags(savedAttachments[0]); checkTestTags(savedAttachments[0]);
assert.equal(savedAttachments[1].getField("title"), "Link to zotero.org"); assert.equal(savedAttachments[1].getField("title"), "Link to zotero.org");
assert.equal(savedAttachments[1].getField("url"), "http://www.zotero.org/"); assert.equal(savedAttachments[1].getField("url"), "http://www.zotero.org/");
assert.equal(savedAttachments[1].getNote(), "attachment 2 note"); assert.equal(savedAttachments[1].note, "attachment 2 note");
assert.equal(savedAttachments[1].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL); assert.equal(savedAttachments[1].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL);
checkTestTags(savedAttachments[1]); checkTestTags(savedAttachments[1]);
} }
assert.equal(containedAttachments[2].getField("title"), "Snapshot"); assert.equal(containedAttachments[2].getField("title"), "Snapshot");
assert.equal(containedAttachments[2].getField("url"), "http://www.example.com/"); assert.equal(containedAttachments[2].getField("url"), "http://www.example.com/");
assert.equal(containedAttachments[2].getNote(), "attachment 3 note"); assert.equal(containedAttachments[2].note, "attachment 3 note");
assert.equal(containedAttachments[2].attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(containedAttachments[2].attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
checkTestTags(containedAttachments[2]); checkTestTags(containedAttachments[2]);
}); });
@ -371,7 +371,7 @@ describe("Zotero.Translate", function() {
assert.equal(containedAttachments[0].getField("title"), "Snapshot with missing file"); assert.equal(containedAttachments[0].getField("title"), "Snapshot with missing file");
assert.equal(containedAttachments[0].getField("url"), "http://www.example.com/"); assert.equal(containedAttachments[0].getField("url"), "http://www.example.com/");
assert.equal(containedAttachments[0].getNote(), "attachment note"); assert.equal(containedAttachments[0].note, "attachment note");
assert.equal(containedAttachments[0].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL); assert.equal(containedAttachments[0].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL);
checkTestTags(containedAttachments[0]); checkTestTags(containedAttachments[0]);
}); });
@ -548,7 +548,7 @@ describe("Zotero.Translate", function() {
assert.equal(attachments[1].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_FILE); assert.equal(attachments[1].attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_FILE);
assert.equal(attachments[1].attachmentContentType, 'text/html'); assert.equal(attachments[1].attachmentContentType, 'text/html');
assert.equal(attachments[1].attachmentCharset, 'utf-8'); assert.equal(attachments[1].attachmentCharset, 'utf-8');
assert.equal(attachments[1].getNote(), file2URL); assert.equal(attachments[1].note, file2URL);
}); });
it("import translators shouldn't save linked-file attachment with linkFiles: true if path is within current storage directory", async function () { it("import translators shouldn't save linked-file attachment with linkFiles: true if path is within current storage directory", async function () {
@ -648,20 +648,20 @@ describe("Zotero.Translate", function() {
let link = containedAttachments["Link to zotero.org"]; let link = containedAttachments["Link to zotero.org"];
assert.equal(link.getField("url"), "http://www.zotero.org/"); assert.equal(link.getField("url"), "http://www.zotero.org/");
assert.equal(link.getNote(), "attachment note"); assert.equal(link.note, "attachment note");
assert.equal(link.attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL); assert.equal(link.attachmentLinkMode, Zotero.Attachments.LINK_MODE_LINKED_URL);
checkTestTags(link, true); checkTestTags(link, true);
let snapshot = containedAttachments["Test Snapshot"]; let snapshot = containedAttachments["Test Snapshot"];
assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html"); assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html");
assert.equal(snapshot.getNote(), "attachment 2 note"); assert.equal(snapshot.note, "attachment 2 note");
assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
assert.equal(snapshot.attachmentContentType, "text/html"); assert.equal(snapshot.attachmentContentType, "text/html");
checkTestTags(snapshot, true); checkTestTags(snapshot, true);
let pdf = containedAttachments["Test PDF"]; let pdf = containedAttachments["Test PDF"];
assert.equal(pdf.getField("url"), "http://127.0.0.1:23119/test/translate/test.pdf"); assert.equal(pdf.getField("url"), "http://127.0.0.1:23119/test/translate/test.pdf");
assert.equal(pdf.getNote(), "attachment 3 note"); assert.equal(pdf.note, "attachment 3 note");
assert.equal(pdf.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(pdf.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
assert.equal(pdf.attachmentContentType, "application/pdf"); assert.equal(pdf.attachmentContentType, "application/pdf");
checkTestTags(pdf, true); checkTestTags(pdf, true);
@ -700,7 +700,7 @@ describe("Zotero.Translate", function() {
let snapshot = containedAttachments[0]; let snapshot = containedAttachments[0];
assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html"); assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html");
assert.equal(snapshot.getNote(), "attachment note"); assert.equal(snapshot.note, "attachment note");
assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
assert.equal(snapshot.attachmentContentType, "text/html"); assert.equal(snapshot.attachmentContentType, "text/html");
checkTestTags(snapshot, true); checkTestTags(snapshot, true);
@ -734,7 +734,7 @@ describe("Zotero.Translate", function() {
let snapshot = containedAttachments[0]; let snapshot = containedAttachments[0];
assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html"); assert.equal(snapshot.getField("url"), "http://127.0.0.1:23119/test/translate/test.html");
assert.equal(snapshot.getNote(), "attachment note"); assert.equal(snapshot.note, "attachment note");
assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
assert.equal(snapshot.attachmentContentType, "text/html"); assert.equal(snapshot.attachmentContentType, "text/html");
checkTestTags(snapshot, true); checkTestTags(snapshot, true);
@ -798,7 +798,7 @@ describe("Zotero.Translate", function() {
let pdf = containedAttachments[0]; let pdf = containedAttachments[0];
assert.equal(pdf.getField("title"), "Test PDF"); assert.equal(pdf.getField("title"), "Test PDF");
assert.equal(pdf.getField("url"), "http://127.0.0.1:23119/test/translate/test.pdf"); assert.equal(pdf.getField("url"), "http://127.0.0.1:23119/test/translate/test.pdf");
assert.equal(pdf.getNote(), "attachment note"); assert.equal(pdf.note, "attachment note");
assert.equal(pdf.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(pdf.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
checkTestTags(pdf, true); checkTestTags(pdf, true);
}); });
@ -901,7 +901,7 @@ describe("Zotero.Translate", function() {
var snapshot = containedAttachments[0]; var snapshot = containedAttachments[0];
assert.equal(snapshot.getField("url"), url + '?t'); assert.equal(snapshot.getField("url"), url + '?t');
assert.equal(snapshot.getNote(), "attachment note"); assert.equal(snapshot.note, "attachment note");
assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
assert.equal(snapshot.attachmentContentType, "text/html"); assert.equal(snapshot.attachmentContentType, "text/html");
checkTestTags(snapshot, true); checkTestTags(snapshot, true);
@ -951,7 +951,7 @@ describe("Zotero.Translate", function() {
var snapshot = containedAttachments[0]; var snapshot = containedAttachments[0];
assert.equal(snapshot.getField("url"), url); assert.equal(snapshot.getField("url"), url);
assert.equal(snapshot.getNote(), "attachment note"); assert.equal(snapshot.note, "attachment note");
assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL); assert.equal(snapshot.attachmentLinkMode, Zotero.Attachments.LINK_MODE_IMPORTED_URL);
assert.equal(snapshot.attachmentContentType, "text/html"); assert.equal(snapshot.attachmentContentType, "text/html");
checkTestTags(snapshot, true); checkTestTags(snapshot, true);