diff --git a/doc/description.md b/doc/description.md index c9bd214d..4b959fc9 100644 --- a/doc/description.md +++ b/doc/description.md @@ -22,6 +22,7 @@ English, Russian, Japanese, Chinese and so on - 0.1.134 - English AU locale (contributed by CreeperYeeter2) - fix RTL UI + - fix edge select conflict - 0.1.133 - fix youtube subtitle conflict - 0.1.132 diff --git a/src/contentScript.js b/src/contentScript.js index badbedda..ff82e5be 100644 --- a/src/contentScript.js +++ b/src/contentScript.js @@ -451,6 +451,7 @@ function loadEventListener() { addEventHandler("keyup", handleKeyup); addEventHandler("mousedown", handleMouseKeyDown); addEventHandler("mouseup", handleMouseKeyUp); + addEventHandler("mouseup", disableEdgeMiniMenu, false); //detect tab switching to reset env addEventHandler("blur", resetTooltipStatus); @@ -499,7 +500,7 @@ function handleMouseKeyUp(e) { } function holdKeydownList(key) { - if (key && !keyDownList[key] && !isCharKey(key)) { + if (key && !keyDownList[key] && !util.isCharKey(key)) { keyDownList[key] = true; restartWordProcess(); translateWriting(); @@ -507,23 +508,18 @@ function holdKeydownList(key) { stopTTSbyCombKey(key); } -async function stopTTSbyCombKey(key) { - if (!isCharKey(key) || !keyDownList[setting["TTSWhen"]]) { - return; +function disableEdgeMiniMenu(e) { + //prevent mouse tooltip overlap with edge mini menu + if (util.isEdge() && mouseKeyMap[e.button] == "ClickLeft") { + e.preventDefault(); } - // stop tts if combination key ex crtl+c - util.requestStopTTS(Date.now() + 500); } -function isCharKey(key) { - return /Key|Digit|Numpad/.test(key); -} -function isStageKey(key) { - return [ - setting["TTSWhen"], - setting["showTooltipWhen"], - setting["keyDownMouseoverTextSwap"], - ].includes(key); +async function stopTTSbyCombKey(key) { + // stop tts if char key like crtl +c + if (util.isCharKey(key)) { + util.requestStopTTS(Date.now() + 500); + } } function releaseKeydownList(key) { @@ -859,10 +855,10 @@ function destructor() { controller.abort(); //clear all event Listener by controller signal } -function addEventHandler(eventName, callbackFunc) { +function addEventHandler(eventName, callbackFunc, capture = true) { //record event for later event signal kill return window.addEventListener(eventName, callbackFunc, { - capture: true, + capture: capture, signal, }); } diff --git a/src/util/index.js b/src/util/index.js index fff7dd81..ab2ac423 100644 --- a/src/util/index.js +++ b/src/util/index.js @@ -675,6 +675,14 @@ export function isLocalFileUrl(url) { return /^file:\/\//.test(url); } +export function isCharKey(key) { + return /Key|Digit|Numpad/.test(key); +} + +export function isEdge() { + return /Edg\//.test(window.navigator.userAgent); +} + //send to background.js for background processing =========================================================================== export async function requestTranslate(