Upgrade note-editor schema to v4:

- Set `annotation.attachmentURI` instead of `annotation.uri` when inserting annotations
- Migrate `annotation.uri` to `annotation.attachmentURI`
- Add `annotation.annotationKey` that references to the original annotation
This commit is contained in:
Martynas Bagdonas 2021-08-06 10:53:28 +03:00
parent a065d477ed
commit 6472321000
3 changed files with 8 additions and 7 deletions

View file

@ -44,7 +44,7 @@ const DOWNLOADED_IMAGE_TYPE = [
];
// Schema version here has to be the same as in note-editor!
const SCHEMA_VERSION = 3;
const SCHEMA_VERSION = 4;
class EditorInstance {
constructor() {
@ -335,7 +335,8 @@ class EditorInstance {
let commentHTML = '';
let storedAnnotation = {
uri: Zotero.URI.getItemURI(attachmentItem),
attachmentURI: Zotero.URI.getItemURI(attachmentItem),
annotationKey: annotation.id,
color: annotation.color,
pageLabel: annotation.pageLabel,
position: annotation.position
@ -571,14 +572,14 @@ class EditorInstance {
return;
}
case 'openAnnotation': {
let { uri, position } = message;
let { attachmentURI, position } = message;
if (this.onNavigate) {
this.onNavigate(uri, { position });
this.onNavigate(attachmentURI, { position });
}
else {
let zp = Zotero.getActiveZoteroPane();
if (zp) {
let item = await Zotero.URI.getURIItem(uri);
let item = await Zotero.URI.getURIItem(attachmentURI);
if (item) {
zp.viewPDF(item.id, { position });
}

@ -1 +1 @@
Subproject commit f2caf422755f256af82cab5eba534bb0fd1f65a4
Subproject commit a644874dcef4fea355a6310a95413a74db935141

@ -1 +1 @@
Subproject commit 06cef9ac89dbd51ecaed311dcc06f74f5e3d82d0
Subproject commit 05da34b95a12c6aad2fe28699e3e41a65a6825d4