sleep mouseup
This commit is contained in:
@@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
|
|||||||
import TranBtn from "./TranBtn";
|
import TranBtn from "./TranBtn";
|
||||||
import TranBox from "./TranBox";
|
import TranBox from "./TranBox";
|
||||||
import { shortcutRegister } from "../../libs/shortcut";
|
import { shortcutRegister } from "../../libs/shortcut";
|
||||||
|
import { sleep } from "../../libs/utils";
|
||||||
|
|
||||||
export default function Slection({ tranboxSetting, transApis }) {
|
export default function Slection({ tranboxSetting, transApis }) {
|
||||||
const [showBox, setShowBox] = useState(false);
|
const [showBox, setShowBox] = useState(false);
|
||||||
@@ -15,7 +16,9 @@ export default function Slection({ tranboxSetting, transApis }) {
|
|||||||
y: (window.innerHeight - 400) / 2,
|
y: (window.innerHeight - 400) / 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleMouseup(e) {
|
async function handleMouseup(e) {
|
||||||
|
await sleep(10);
|
||||||
|
|
||||||
const selectedText = window.getSelection()?.toString()?.trim() || "";
|
const selectedText = window.getSelection()?.toString()?.trim() || "";
|
||||||
if (!selectedText) {
|
if (!selectedText) {
|
||||||
setShowBtn(false);
|
setShowBtn(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user