Revert "improve comments system"

This reverts commit e55eb48f45.
This commit is contained in:
isUnknown 2025-01-28 09:47:58 +01:00
parent e55eb48f45
commit 1ae2964d58
5 changed files with 41 additions and 63 deletions

View file

@ -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) {

View file

@ -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,

View file

@ -6,7 +6,6 @@
:src="openedFile.url"
local="fr_FR"
@loaded="onPdfLoaded"
ref="vpvRef"
/>
<button
id="toggle-comments"
@ -24,17 +23,18 @@
<script setup>
import Comments from "../comments/Comments.vue";
import { computed, ref, watch } from "vue";
import { ref, watch } from "vue";
import { useDialogStore } from "../../stores/dialog";
import { storeToRefs } from "pinia";
import { VPdfViewer, useLicense } from "@vue-pdf-viewer/viewer";
import { useRoute, useRouter } from "vue-router";
const licenseKey =
import.meta.env.VITE_VPV_LICENSE ?? "d0ab730a-ebba-4060-856c-76d322565645";
const licenseKey = import.meta.env.VITE_VPV_LICENSE ?? 'd0ab730a-ebba-4060-856c-76d322565645';
useLicense({ licenseKey });
const { openedFile, isCommentsOpen, vpvRef } = storeToRefs(useDialogStore());
const { resetCommentMarkers } = useDialogStore();
const { openedFile, isCommentsOpen, comments, draftComment } = storeToRefs(
useDialogStore()
);
const currentPageIndex = ref(1);
@ -46,9 +46,6 @@ const onPdfLoaded = () => {
(entries) => {
entries.forEach((entry, index) => {
if (entry.intersectionRatio > 0.5) {
if (isCommentsOpen.value) {
resetCommentMarkers();
}
currentPageIndex.value = parseInt(
entry.target.getAttribute("aria-label").split(" ")[1]
);