This commit is contained in:
parent
cd04c232a6
commit
32b01f4c98
3 changed files with 87 additions and 18 deletions
|
|
@ -30,6 +30,7 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
const isCommentsOpen = ref(
|
||||
route.query.hasOwnProperty("comments") ? true : false
|
||||
);
|
||||
const openedComment = ref(null);
|
||||
|
||||
const draftComment = ref({});
|
||||
watch(
|
||||
|
|
@ -84,10 +85,17 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
}
|
||||
}, 100);
|
||||
});
|
||||
|
||||
function setCommentMarkers() {
|
||||
if (!comments.value) return;
|
||||
comments.value.forEach((comment) => {
|
||||
const correspondingMarker = document.querySelector(
|
||||
`.comment-marker[href="#comment-${comment.id}"]`
|
||||
);
|
||||
if (comment.location.file.uuid !== openedFile.value.uuid) return;
|
||||
if (comment.type === "comment-reply") return;
|
||||
if (correspondingMarker) return;
|
||||
|
||||
const bubble = document.createElement("a");
|
||||
|
||||
bubble.classList.add("comment-marker");
|
||||
|
|
@ -109,17 +117,23 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
)
|
||||
: document.querySelector(".track");
|
||||
|
||||
container.appendChild(bubble);
|
||||
|
||||
setTimeout(() => {
|
||||
bubble.addEventListener("mouseenter", () => highlight(comment));
|
||||
bubble.addEventListener("mouseleave", () => unhighlight(comment));
|
||||
}, 100);
|
||||
try {
|
||||
container.appendChild(bubble);
|
||||
setTimeout(() => {
|
||||
bubble.addEventListener("mouseenter", () => highlight(comment));
|
||||
bubble.addEventListener("mouseleave", () => unhighlight(comment));
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Impossible de monter la bulle du commentaire ${comment.id}. La page n°${comment.position.pageIndex} n'existe pas dans le DOM.`
|
||||
);
|
||||
}
|
||||
}, timeOut);
|
||||
});
|
||||
}
|
||||
|
||||
function removeCommentMarkers() {
|
||||
console.log("remove comment markers");
|
||||
document.querySelectorAll(".comment-marker").forEach((bubble) => {
|
||||
bubble.parentNode.removeChild(bubble);
|
||||
});
|
||||
|
|
@ -143,5 +157,6 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
isCommentsOpen,
|
||||
isCommentPanelEnabled,
|
||||
updateFile,
|
||||
openedComment,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue