Initial annotation support
This commit is contained in:
parent
92ba393488
commit
1c366de546
15 changed files with 1109 additions and 28 deletions
|
@ -689,7 +689,7 @@ function generateAllTypesAndFieldsData() {
|
|||
};
|
||||
|
||||
// Item types that should not be included in sample data
|
||||
let excludeItemTypes = ['note', 'attachment'];
|
||||
let excludeItemTypes = ['note', 'attachment', 'annotation'];
|
||||
|
||||
for (let i = 0; i < itemTypes.length; i++) {
|
||||
if (excludeItemTypes.indexOf(itemTypes[i].name) != -1) continue;
|
||||
|
@ -921,6 +921,28 @@ function importHTMLAttachment() {
|
|||
}
|
||||
|
||||
|
||||
async function createAnnotation(type, parentItem) {
|
||||
var annotation = new Zotero.Item('annotation');
|
||||
annotation.parentID = parentItem.id;
|
||||
annotation.annotationType = type;
|
||||
if (type == 'highlight') {
|
||||
annotation.annotationText = Zotero.Utilities.randomString();
|
||||
}
|
||||
annotation.annotationComment = Zotero.Utilities.randomString();
|
||||
var page = Zotero.Utilities.rand(1, 100).toString().padStart(6, '0');
|
||||
var pos = Zotero.Utilities.rand(1, 10000).toString().padStart(7, '0');
|
||||
annotation.annotationSortIndex = `${page}|${pos}|000000.000`;
|
||||
annotation.annotationPosition = {
|
||||
pageIndex: 123,
|
||||
rects: [
|
||||
[314.4, 412.8, 556.2, 609.6]
|
||||
]
|
||||
};
|
||||
await annotation.saveTx();
|
||||
return annotation;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the fake XHR server to response to a given response
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue