fix: firefox bugs
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import { CLIENT_EXTS, CLIENT_USERSCRIPT, CLIENT_WEB } from "../config";
|
||||
import {
|
||||
CLIENT_EXTS,
|
||||
CLIENT_USERSCRIPT,
|
||||
CLIENT_WEB,
|
||||
CLIENT_FIREFOX,
|
||||
} from "../config";
|
||||
|
||||
export const client = process.env.REACT_APP_CLIENT;
|
||||
export const isExt = CLIENT_EXTS.includes(client);
|
||||
export const isGm = client === CLIENT_USERSCRIPT;
|
||||
export const isWeb = client === CLIENT_WEB;
|
||||
export const isFirefox = client === CLIENT_FIREFOX;
|
||||
|
||||
@@ -15,12 +15,20 @@ export const shortcutListener = (
|
||||
const pressedKeys = new Set();
|
||||
|
||||
const handleKeyDown = (e) => {
|
||||
if (!e.code) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pressedKeys.has(e.code)) return;
|
||||
pressedKeys.add(e.code);
|
||||
onKeyDown(new Set(pressedKeys), e);
|
||||
};
|
||||
|
||||
const handleKeyUp = (e) => {
|
||||
if (!e.code) {
|
||||
return;
|
||||
}
|
||||
|
||||
// onKeyUp 应该在 key 从集合中移除前触发,以便判断组合键
|
||||
onKeyUp(new Set(pressedKeys), e);
|
||||
pressedKeys.delete(e.code);
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
OPT_STYLE_HIGHLIGHT,
|
||||
OPT_STYLE_BLOCKQUOTE,
|
||||
OPT_STYLE_DIY,
|
||||
DEFAULT_DIY_STYLE,
|
||||
DEFAULT_COLOR,
|
||||
} from "../config";
|
||||
|
||||
@@ -32,7 +33,10 @@ const genLineStyle = (style, color) => `
|
||||
}
|
||||
`;
|
||||
|
||||
const genStyles = ({ textDiyStyle, bgColor = DEFAULT_COLOR }) => ({
|
||||
export const genStyles = ({
|
||||
textDiyStyle = DEFAULT_DIY_STYLE,
|
||||
bgColor = DEFAULT_COLOR,
|
||||
}) => ({
|
||||
// 无样式
|
||||
[OPT_STYLE_NONE]: ``,
|
||||
// 下划线
|
||||
@@ -46,9 +50,8 @@ const genStyles = ({ textDiyStyle, bgColor = DEFAULT_COLOR }) => ({
|
||||
// 虚线框
|
||||
[OPT_STYLE_DASHBOX]: `
|
||||
border: 1px dashed ${bgColor || DEFAULT_COLOR};
|
||||
background: transparent;
|
||||
display: inline-block;
|
||||
padding: 0.2em 0.5em;
|
||||
padding: 0.2em 0.4em;
|
||||
box-sizing: border-box;
|
||||
`,
|
||||
// 模糊
|
||||
|
||||
Reference in New Issue
Block a user