eventListener is not running

I am making an extension in which a user can make notes by taking screenshots and then download his notes in pdf format.
In this extension I made my custom context menu and it will only be visible when the user right clicks on the image tag, else the default context menu will appear.
In this extension I made an text editor, and used execcommand() method to bold, italic, undeline the text, or to generate link, insert unordered list etc.

Problem :- So, my problem is when the user right clicks on the image it shows my custom context menu, but when I center, align right or justify this image in my text editor and then right click on it, it do not show my custom context menu, it shows default context menu. Why is this happening, can anyone help me.

function showContextMenu(e){
    e.preventDefault();
    
        const {clientX: mouseX, clientY: mouseY} = e;
    
        const {normalizedX, normalizedY} = normalizePosition(mouseX, mouseY);
    
        contextMenu.style.top = `${normalizedY}px`;
        contextMenu.style.left = `${normalizedX}px`;
    
        contextMenu.classList.remove("visible");
    
        setTimeout(() => {
            contextMenu.classList.add("visible");
        });
}

// Hide the custom context menu when left or right clicked outside the contexet menu
scope.addEventListener("click", (e) => {
    if(e.target.offsetParent != contextMenu) {
        contextMenu.classList.remove("visible");
    }
});
scope.addEventListener("contextmenu", (e) => {
    if(e.target.offsetParent != contextMenu) {
        contextMenu.classList.remove("visible");
    }
});

//Function for the context menu's option;
function executingOptions(e) {
    for(let i = 0; i < options.length; i++){
        if(options[i].innerHTML == "Crop"){
            options[i].onclick = () => {
                /////////////////////////////////////////////////////////////////
                contextMenu.classList.remove("visible")
            }
            continue;
        }
        if(options[i].innerHTML == "Download"){
            options[i].onclick = () => {
                console.log(e.target.src);
                options[i].setAttribute("href", e.target.src);
                contextMenu.classList.remove("visible")
            }
            continue;
        }
        
        options[i].onclick = () => {
            e.target.setAttribute("width", options[i].innerHTML);
            contextMenu.classList.remove("visible")
        }
    }
}

//This code is adding event listener to every image in the text editor {this is only part of big function not entire code}
    newImage.addEventListener("contextmenu", () => {
        showContextMenu(event);
        executingOptions(event);
    });

//This code will center the content in text editor {part of the code not entire code}
button.onclick = () => {
        document.execCommand("justifyCenter");
        textEditor.focus();
}