improve comments system

This commit is contained in:
isUnknown 2025-01-28 09:37:33 +01:00
parent 8bb4f552cd
commit e55eb48f45
5 changed files with 63 additions and 41 deletions

View file

@ -101,7 +101,7 @@ const route = useRoute();
const userStore = useUserStore();
const api = useApiStore();
const dialog = useDialogStore();
const { activeTracks, openedComment } = storeToRefs(useDialogStore());
const { activeTracks, openedComment, vpvRef } = storeToRefs(useDialogStore());
const draftText = ref(comment.text);
const editField = ref(null);
const commentNode = useTemplateRef("comment-node");
@ -157,11 +157,15 @@ async function read() {
}
function scrollTo() {
const correspondingMarker = document.querySelector(
`.comment-marker[href="#comment-${comment.id}"]`
);
if (!correspondingMarker) return;
correspondingMarker.scrollIntoView();
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);
}
async function deleteComment(event) {

View file

@ -219,6 +219,7 @@ async function addComment(newComment) {
/projects\/.*?(?=\/[^/]+\/[^/]+$)/
);
newComment.fileParentUri = matchFileParentUri ? matchFileParentUri[0] : null;
console.log(newComment);
const newFile = await api.addComment(newComment);
resetDraftComment();
isAddOpen.value = false;
@ -271,10 +272,7 @@ function prepareDraftCommentInPdf(event) {
const pageContainer = event.target.closest(".page-inner-container");
if (!pageContainer || !viewContainer) return;
const pageLabel = pageContainer
.closest(".vpv-page-inner-container")
.getAttribute("aria-label");
const pageIndex = pageLabel.charAt(pageLabel.length - 1);
const pageIndex = parseInt(pageContainer.dataset.pageIndex) + 1;
const viewRect = viewContainer.getBoundingClientRect();
const pageRect = pageContainer.getBoundingClientRect();
@ -287,8 +285,6 @@ 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,