Skip to content

Commit

Permalink
Fix the editing of the annotations after a rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
jcougnaud committed Mar 11, 2024
1 parent fa043d5 commit 9a780fd
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 113 deletions.
4 changes: 3 additions & 1 deletion frontend/DocumentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class="viewerContainer"
tabindex="0"
>
<div class="pdfViewer" />
<div class="pdfViewer" ref="pdfViewer" />
</div>
</div>

Expand Down Expand Up @@ -229,6 +229,7 @@ export default defineComponent({
const viewer = new PDFViewer({
container: this.$refs.viewerContainer as HTMLDivElement,
eventBus: new EventBus(),
viewer: this.$refs.pdfViewer as HTMLDivElement,
});
viewer.setDocument(pdfDocument);

Expand Down Expand Up @@ -258,6 +259,7 @@ export default defineComponent({
rotate(rotation: number) {
// @ts-ignore bad typing from lib, see https://github.com/mozilla/pdf.js/pull/16362
(this.viewer?.getPageView(this.currentPage - 1) as PDFPageView).update({rotation});
this.viewer?.update(); // To correctly display annotation layers after a rotation
if (rotation !== 0) {
this.rotations[this.currentPage - 1] = rotation;
} else {
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/ToolbarRotation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
<button
type="button"
class="btn btn-default"
@click="$emit('onRotate', (currentRotation - 90) % 360)"
@click="$emit('onRotate', ((currentRotation - 90) % 360 + 360) % 360)"
>
<span class="fas fa-rotate-left" />
</button>
<button
type="button"
class="btn btn-default"
@click="$emit('onRotate', (currentRotation + 90) % 360)"
@click="$emit('onRotate', ((currentRotation + 90) % 360 + 360) % 360)"
>
<span class="fas fa-rotate-right" />
</button>
Expand Down

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions osis_document/static/osis_document/osis-document-editor.umd.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion osis_document/static/pdfjs/pdf.worker.min.js

Large diffs are not rendered by default.

237 changes: 142 additions & 95 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"vue-tsc": "^1.0.24"
},
"dependencies": {
"pdfjs-dist": "^3.5.141",
"pdfjs-dist": "3.6.172",
"tiny-emitter": "^2.1.0",
"vue-uuid": "^3.0.0"
}
Expand Down

0 comments on commit 9a780fd

Please sign in to comment.