Skip to content

Commit

Permalink
Merge pull request #14993 from Snuffleupagus/editor-AnnotationStorage…
Browse files Browse the repository at this point in the history
…-hash

[editor] Update the `AnnotationStorage.hash`-getter to support editing
  • Loading branch information
calixteman committed Jun 5, 2022
2 parents 87fdb0e + 51c47ac commit 1816b5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions src/display/annotation_storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,8 @@ class AnnotationStorage {

const clone = new Map();
for (const [key, value] of this._storage) {
if (value instanceof AnnotationEditor) {
clone.set(key, value.serialize());
} else {
clone.set(key, value);
}
const val = value instanceof AnnotationEditor ? value.serialize() : value;
clone.set(key, val);
}
return clone;
}
Expand All @@ -159,7 +156,8 @@ class AnnotationStorage {
const hash = new MurmurHash3_64();

for (const [key, value] of this._storage) {
hash.update(`${key}:${JSON.stringify(value)}`);
const val = value instanceof AnnotationEditor ? value.serialize() : value;
hash.update(`${key}:${JSON.stringify(val)}`);
}
return hash.hexdigest();
}
Expand Down
4 changes: 2 additions & 2 deletions src/display/editor/freetext.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ class FreeTextEditor extends AnnotationEditor {
const rect = this.div.getBoundingClientRect();
const [x1, y1] = Util.applyTransform(
[this.x, this.y + rect.height],
this.parent.viewport.inverseTransform
this.parent.inverseViewportTransform
);

const [x2, y2] = Util.applyTransform(
[this.x + rect.width, this.y],
this.parent.viewport.inverseTransform
this.parent.inverseViewportTransform
);

return {
Expand Down

0 comments on commit 1816b5e

Please sign in to comment.