parent
e55eb48f45
commit
1ae2964d58
5 changed files with 41 additions and 63 deletions
|
|
@ -6,7 +6,6 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
const content = ref(null);
|
||||
const openedFile = ref(null);
|
||||
const activeTracks = ref(null);
|
||||
const vpvRef = ref(null);
|
||||
|
||||
const comments = computed(() => {
|
||||
if (activeTracks.value?.length > 0) {
|
||||
|
|
@ -36,6 +35,23 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
},
|
||||
{ deep: true }
|
||||
);
|
||||
function showDraftMarker(draftComment) {
|
||||
const bubble = document.createElement("a");
|
||||
|
||||
bubble.classList.add("comment-marker");
|
||||
bubble.classList.add("comment-marker--draft");
|
||||
bubble.style.left = draftComment.position.x + "%";
|
||||
bubble.style.top = draftComment.position.y + "%";
|
||||
bubble.href = "#comment-" + draftComment.id;
|
||||
|
||||
const container = draftComment.position.pageIndex
|
||||
? document.querySelector(
|
||||
`.vpv-page-inner-container[aria-label="page ${draftComment.position.pageIndex}"] .page-inner-container`
|
||||
)
|
||||
: document.querySelector(".track");
|
||||
|
||||
container.appendChild(bubble);
|
||||
}
|
||||
|
||||
const isViewerDisabled = ref(false);
|
||||
watch(isCommentsOpen, (newVal) => {
|
||||
|
|
@ -65,43 +81,14 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
}, 100);
|
||||
});
|
||||
|
||||
function resetCommentMarkers() {
|
||||
removeCommentMarkers();
|
||||
setCommentMarkers();
|
||||
}
|
||||
|
||||
function showDraftMarker(draftComment) {
|
||||
const bubble = document.createElement("a");
|
||||
|
||||
bubble.classList.add("comment-marker");
|
||||
bubble.classList.add("comment-marker--draft");
|
||||
bubble.style.left = draftComment.position.x + "%";
|
||||
bubble.style.top = draftComment.position.y + "%";
|
||||
bubble.href = "#comment-" + draftComment.id;
|
||||
|
||||
const container = draftComment.position.pageIndex
|
||||
? document.querySelector(
|
||||
`.vpv-page-inner-container[aria-label="page ${draftComment.position.pageIndex}"] .page-inner-container`
|
||||
)
|
||||
: document.querySelector(".track");
|
||||
|
||||
try {
|
||||
container.appendChild(bubble);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
`Can't show draft comment on page ${draftComment.position.pageIndex} : `,
|
||||
error
|
||||
);
|
||||
}
|
||||
}
|
||||
function setCommentMarkers() {
|
||||
if (!comments.value) return;
|
||||
comments.value.forEach((comment) => {
|
||||
if (comment.location.file.uuid !== openedFile.value.uuid) return;
|
||||
if (comment.type === "comment-reply") return;
|
||||
let correspondingMarker = document.querySelector(
|
||||
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");
|
||||
|
|
@ -119,24 +106,20 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
|
||||
const timeOut = container ? 0 : 500;
|
||||
setTimeout(() => {
|
||||
container = comment.position?.hasOwnProperty("pageIndex")
|
||||
container = comment.position?.pageIndex
|
||||
? document.querySelector(
|
||||
`.vpv-page-inner-container[aria-label="page ${comment.position.pageIndex}"] .page-inner-container`
|
||||
)
|
||||
: document.querySelector(".track");
|
||||
|
||||
try {
|
||||
correspondingMarker = document.querySelector(
|
||||
`.comment-marker[href="#comment-${comment.id}"]`
|
||||
);
|
||||
if (correspondingMarker) return;
|
||||
container.appendChild(bubble);
|
||||
setTimeout(() => {
|
||||
bubble.addEventListener("mouseenter", () => highlight(comment));
|
||||
bubble.addEventListener("mouseleave", () => unhighlight(comment));
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
console.error(
|
||||
`Impossible de monter la bulle du commentaire ${comment.id}. La page n°${comment.position.pageIndex} n'existe pas dans le DOM.`
|
||||
);
|
||||
}
|
||||
|
|
@ -170,7 +153,5 @@ export const useDialogStore = defineStore("dialog", () => {
|
|||
isCommentPanelEnabled,
|
||||
updateFile,
|
||||
openedComment,
|
||||
resetCommentMarkers,
|
||||
vpvRef,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue