Skip to content

Commit

Permalink
feat: base force copy connection
Browse files Browse the repository at this point in the history
  • Loading branch information
WindRunnerMax committed Jul 28, 2024
1 parent 80a28be commit 1381747
Show file tree
Hide file tree
Showing 20 changed files with 385 additions and 257 deletions.
4 changes: 4 additions & 0 deletions packages/copy/src/constant/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ export const SELECT_START = "selectstart";
export const CONTEXT_MENU = "contextmenu";
export const KEY_DOWN = "keydown";
export const TOUCH_START = "touchstart";
export const FOCUS = "focus";
export const BLUR = "blur";
export const FOCUS_IN = "focusin";
export const FOCUS_OUT = "focusout";
2 changes: 1 addition & 1 deletion packages/force-copy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "force-copy",
"version": "1.0.7",
"version": "1.0.8",
"author": "Czy",
"license": "MIT",
"sideEffects": false,
Expand Down
4 changes: 4 additions & 0 deletions packages/force-copy/src/inject/utils/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const EVENTS_TYPE = [
"CONTEXT_MENU_CAPTURE",
"SELECT_START_CAPTURE",
"TOUCH_START_CAPTURE",
"FOCUS_CAPTURE",
"BLUR_CAPTURE",
] as const;

export const EVENTS_ENUM = EVENTS_TYPE.reduce(
Expand All @@ -38,6 +40,8 @@ interface EventBusParams {
[EVENTS_ENUM.CONTEXT_MENU_CAPTURE]: Event;
[EVENTS_ENUM.SELECT_START_CAPTURE]: Event;
[EVENTS_ENUM.TOUCH_START_CAPTURE]: TouchEvent;
[EVENTS_ENUM.FOCUS_CAPTURE]: FocusEvent;
[EVENTS_ENUM.BLUR_CAPTURE]: FocusEvent;
}

declare module "laser-utils/dist/es/event-bus" {
Expand Down
8 changes: 8 additions & 0 deletions packages/force-copy/src/inject/utils/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {
BLUR,
CONTEXT_MENU,
COPY,
DOM_READY,
FOCUS,
FOCUS_IN,
FOCUS_OUT,
KEY_DOWN,
MOUSE_DOWN,
MOUSE_UP,
Expand Down Expand Up @@ -35,6 +39,10 @@ export const initBaseEvents = () => {
);
window.addEventListener(DOM_READY, e => EventBus.emit(EVENTS_ENUM.DOM_LOADED, e), true);
window.addEventListener(PAGE_LOADED, e => EventBus.emit(EVENTS_ENUM.PAGE_LOADED, e), true);
window.addEventListener(FOCUS, e => EventBus.emit(EVENTS_ENUM.FOCUS_CAPTURE, e), true);
window.addEventListener(FOCUS_IN, e => EventBus.emit(EVENTS_ENUM.FOCUS_CAPTURE, e), true);
window.addEventListener(BLUR, e => EventBus.emit(EVENTS_ENUM.BLUR_CAPTURE, e), true);
window.addEventListener(FOCUS_OUT, e => EventBus.emit(EVENTS_ENUM.FOCUS_CAPTURE, e), true);
};

export const stopNativePropagation = (event: Event) => event.stopImmediatePropagation();
Expand Down
184 changes: 0 additions & 184 deletions packages/force-copy/src/popup/components/app.tsx

This file was deleted.

26 changes: 26 additions & 0 deletions packages/force-copy/src/popup/components/app/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
body {
user-select: none;
background-color: var(--color-bg-3);
}

.container {
padding: 10px;
width: 270px;
color: var(--color-text-1);
}

.hr {
margin: 5px 0;
height: 1px;
background-color: var(--color-border-3);
width: 100%;
}

.console {
position: relative;
> div {
margin: 10px 5px;
display: flex;
align-items: center;
}
}
28 changes: 28 additions & 0 deletions packages/force-copy/src/popup/components/app/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { FC } from "react";
import styles from "./index.module.scss";
import { cs } from "laser-utils";
import { I18n } from "../../i18n";
import { cross } from "@/utils/global";
import { Console } from "../console";
import { Header } from "../header";
import { Footer } from "../footer";

const i18n = new I18n(cross.i18n.getUILanguage());

export const App: FC = () => {
return (
<div className={cs(styles.container)}>
<Header i18n={i18n}></Header>

<div className={styles.hr}></div>

<div className={styles.console}>
<Console i18n={i18n}></Console>
</div>

<div className={styles.hr}></div>

<Footer i18n={i18n}></Footer>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.switch {
display: flex;
justify-content: center;
}
Loading

0 comments on commit 1381747

Please sign in to comment.