add context menus

This commit is contained in:
Gabe Yuan
2023-11-21 11:20:05 +08:00
parent df4cfc0fbc
commit 433e811821
12 changed files with 156 additions and 29 deletions

View File

@@ -2,6 +2,7 @@ import { browser } from "./libs/browser";
import {
MSG_TRANS_TOGGLE,
MSG_TRANS_TOGGLE_STYLE,
MSG_TRANSLATE_SELECTED,
MSG_TRANS_GETRULE,
MSG_TRANS_PUTRULE,
} from "./config";
@@ -35,6 +36,9 @@ function runtimeListener(translator) {
translator.updateRule(args);
sendIframeMsg(MSG_TRANS_PUTRULE, args);
break;
case MSG_TRANSLATE_SELECTED:
window.dispatchEvent(new CustomEvent(MSG_TRANSLATE_SELECTED));
break;
default:
return { error: `message action is unavailable: ${action}` };
}