diff --git a/public/site/plugins/classes/Position.php b/public/site/plugins/classes/Position.php index 3e95783..29c8dca 100644 --- a/public/site/plugins/classes/Position.php +++ b/public/site/plugins/classes/Position.php @@ -22,7 +22,7 @@ class Position public function toArray() { $array = []; - if (isset($this->pageIndex)) { + if ($this->pageIndex) { $array["pageIndex"] = $this->pageIndex; } diff --git a/src/components/comments/Comment.vue b/src/components/comments/Comment.vue index 273386a..5803e9b 100644 --- a/src/components/comments/Comment.vue +++ b/src/components/comments/Comment.vue @@ -101,7 +101,7 @@ const route = useRoute(); const userStore = useUserStore(); const api = useApiStore(); const dialog = useDialogStore(); -const { activeTracks, openedComment, vpvRef } = storeToRefs(useDialogStore()); +const { activeTracks, openedComment } = storeToRefs(useDialogStore()); const draftText = ref(comment.text); const editField = ref(null); const commentNode = useTemplateRef("comment-node"); @@ -157,15 +157,11 @@ async function read() { } function scrollTo() { - vpvRef.value.goToPage(comment.position.pageIndex); - setTimeout(() => { - const correspondingMarker = document.querySelector( - `.comment-marker[href="#comment-${comment.id}"]` - ); - console.log(correspondingMarker); - if (!correspondingMarker) return; - correspondingMarker.scrollIntoView(); - }, 1000); + const correspondingMarker = document.querySelector( + `.comment-marker[href="#comment-${comment.id}"]` + ); + if (!correspondingMarker) return; + correspondingMarker.scrollIntoView(); } async function deleteComment(event) { diff --git a/src/components/comments/Comments.vue b/src/components/comments/Comments.vue index 5a947b0..24501cf 100644 --- a/src/components/comments/Comments.vue +++ b/src/components/comments/Comments.vue @@ -219,7 +219,6 @@ async function addComment(newComment) { /projects\/.*?(?=\/[^/]+\/[^/]+$)/ ); newComment.fileParentUri = matchFileParentUri ? matchFileParentUri[0] : null; - console.log(newComment); const newFile = await api.addComment(newComment); resetDraftComment(); isAddOpen.value = false; @@ -272,7 +271,10 @@ function prepareDraftCommentInPdf(event) { const pageContainer = event.target.closest(".page-inner-container"); if (!pageContainer || !viewContainer) return; - const pageIndex = parseInt(pageContainer.dataset.pageIndex) + 1; + const pageLabel = pageContainer + .closest(".vpv-page-inner-container") + .getAttribute("aria-label"); + const pageIndex = pageLabel.charAt(pageLabel.length - 1); const viewRect = viewContainer.getBoundingClientRect(); const pageRect = pageContainer.getBoundingClientRect(); @@ -285,6 +287,8 @@ function prepareDraftCommentInPdf(event) { const relativeX = (x / pageRect.width) * 100; const relativeY = (y / pageRect.height) * 100; + console.log(pageIndex); + draftComment.value.position = { x: relativeX, y: relativeY, diff --git a/src/components/project/PdfViewer.vue b/src/components/project/PdfViewer.vue index 72f7aef..82c872c 100644 --- a/src/components/project/PdfViewer.vue +++ b/src/components/project/PdfViewer.vue @@ -6,7 +6,6 @@ :src="openedFile.url" local="fr_FR" @loaded="onPdfLoaded" - ref="vpvRef" />