Skip to content

Commit 1381747

Browse files
committed
feat: base force copy connection
1 parent 80a28be commit 1381747

20 files changed

Lines changed: 385 additions & 257 deletions

File tree

packages/copy/src/constant/event.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ export const SELECT_START = "selectstart";
1313
export const CONTEXT_MENU = "contextmenu";
1414
export const KEY_DOWN = "keydown";
1515
export const TOUCH_START = "touchstart";
16+
export const FOCUS = "focus";
17+
export const BLUR = "blur";
18+
export const FOCUS_IN = "focusin";
19+
export const FOCUS_OUT = "focusout";

packages/force-copy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "force-copy",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"author": "Czy",
55
"license": "MIT",
66
"sideEffects": false,

packages/force-copy/src/inject/utils/bus.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ const EVENTS_TYPE = [
1616
"CONTEXT_MENU_CAPTURE",
1717
"SELECT_START_CAPTURE",
1818
"TOUCH_START_CAPTURE",
19+
"FOCUS_CAPTURE",
20+
"BLUR_CAPTURE",
1921
] as const;
2022

2123
export const EVENTS_ENUM = EVENTS_TYPE.reduce(
@@ -38,6 +40,8 @@ interface EventBusParams {
3840
[EVENTS_ENUM.CONTEXT_MENU_CAPTURE]: Event;
3941
[EVENTS_ENUM.SELECT_START_CAPTURE]: Event;
4042
[EVENTS_ENUM.TOUCH_START_CAPTURE]: TouchEvent;
43+
[EVENTS_ENUM.FOCUS_CAPTURE]: FocusEvent;
44+
[EVENTS_ENUM.BLUR_CAPTURE]: FocusEvent;
4145
}
4246

4347
declare module "laser-utils/dist/es/event-bus" {

packages/force-copy/src/inject/utils/events.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import {
2+
BLUR,
23
CONTEXT_MENU,
34
COPY,
45
DOM_READY,
6+
FOCUS,
7+
FOCUS_IN,
8+
FOCUS_OUT,
59
KEY_DOWN,
610
MOUSE_DOWN,
711
MOUSE_UP,
@@ -35,6 +39,10 @@ export const initBaseEvents = () => {
3539
);
3640
window.addEventListener(DOM_READY, e => EventBus.emit(EVENTS_ENUM.DOM_LOADED, e), true);
3741
window.addEventListener(PAGE_LOADED, e => EventBus.emit(EVENTS_ENUM.PAGE_LOADED, e), true);
42+
window.addEventListener(FOCUS, e => EventBus.emit(EVENTS_ENUM.FOCUS_CAPTURE, e), true);
43+
window.addEventListener(FOCUS_IN, e => EventBus.emit(EVENTS_ENUM.FOCUS_CAPTURE, e), true);
44+
window.addEventListener(BLUR, e => EventBus.emit(EVENTS_ENUM.BLUR_CAPTURE, e), true);
45+
window.addEventListener(FOCUS_OUT, e => EventBus.emit(EVENTS_ENUM.FOCUS_CAPTURE, e), true);
3846
};
3947

4048
export const stopNativePropagation = (event: Event) => event.stopImmediatePropagation();

packages/force-copy/src/popup/components/app.tsx

Lines changed: 0 additions & 184 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
body {
2+
user-select: none;
3+
background-color: var(--color-bg-3);
4+
}
5+
6+
.container {
7+
padding: 10px;
8+
width: 270px;
9+
color: var(--color-text-1);
10+
}
11+
12+
.hr {
13+
margin: 5px 0;
14+
height: 1px;
15+
background-color: var(--color-border-3);
16+
width: 100%;
17+
}
18+
19+
.console {
20+
position: relative;
21+
> div {
22+
margin: 10px 5px;
23+
display: flex;
24+
align-items: center;
25+
}
26+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { FC } from "react";
2+
import styles from "./index.module.scss";
3+
import { cs } from "laser-utils";
4+
import { I18n } from "../../i18n";
5+
import { cross } from "@/utils/global";
6+
import { Console } from "../console";
7+
import { Header } from "../header";
8+
import { Footer } from "../footer";
9+
10+
const i18n = new I18n(cross.i18n.getUILanguage());
11+
12+
export const App: FC = () => {
13+
return (
14+
<div className={cs(styles.container)}>
15+
<Header i18n={i18n}></Header>
16+
17+
<div className={styles.hr}></div>
18+
19+
<div className={styles.console}>
20+
<Console i18n={i18n}></Console>
21+
</div>
22+
23+
<div className={styles.hr}></div>
24+
25+
<Footer i18n={i18n}></Footer>
26+
</div>
27+
);
28+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.switch {
2+
display: flex;
3+
justify-content: center;
4+
}

0 commit comments

Comments
 (0)