Skip to content

Commit ee3c1f1

Browse files
committed
feat: auto selection
1 parent 427f6ae commit ee3c1f1

File tree

8 files changed

+18
-57
lines changed

8 files changed

+18
-57
lines changed

packages/force-copy/src/inject/modules/basic.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { CONTEXT_MENU_TYPE, COPY_TYPE, KEYBOARD_TYPE } from "@/utils/constant";
33
import type { WebSite } from "../types/website";
44
import { EVENTS_ENUM, EventBus } from "../utils/bus";
55
import { onCopyKeyboardHandler, stopNativePropagation } from "../utils/events";
6-
import { STYLE_ID, AUTO_USER_SELECT } from "../utils/styles";
6+
import { STYLE_ID, AUTO_USER_SELECT, AUTO_SELECTION } from "../utils/styles";
77

88
export const Basic: WebSite = {
99
regexp: /.*/,
1010
start(type) {
1111
if (type === COPY_TYPE) {
12-
styles.insertCSS(STYLE_ID, AUTO_USER_SELECT);
12+
styles.insertCSS(STYLE_ID, AUTO_USER_SELECT + AUTO_SELECTION);
1313
EventBus.on(EVENTS_ENUM.COPY_CAPTURE, stopNativePropagation);
1414
EventBus.on(EVENTS_ENUM.KEY_BOARD_CAPTURE, onCopyKeyboardHandler);
1515
EventBus.on(EVENTS_ENUM.SELECT_START_CAPTURE, stopNativePropagation);

packages/force-copy/src/inject/modules/boke.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/force-copy/src/inject/modules/doc88.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ const onMouseUpCapture = () => {
2323
};
2424
const init = () => {
2525
try {
26-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
27-
// @ts-ignore
26+
// @ts-expect-error global
2827
window.Config && (window.Config.vip = 1) && (window.Config.logined = 1);
2928
const hook = () => {
30-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
31-
// @ts-ignore
29+
// @ts-expect-error global
3230
const api = window.Core.Annotation.api;
3331
const keys = Object.keys(api).filter(key => isString(api[key]));
3432
const duplication: Record<string, unknown> = {};
@@ -47,12 +45,10 @@ const init = () => {
4745
});
4846
});
4947
};
50-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
51-
// @ts-ignore
48+
// @ts-expect-error global
5249
if (window.Core) {
5350
hook();
54-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
55-
// @ts-ignore
51+
// @ts-expect-error global
5652
} else if (window.Core === null) {
5753
delayExecute(PAGE_LOADED).then(hook);
5854
} else {
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type { WebSite } from "../types/website";
22
import { Basic } from "./basic";
3-
import { Boke } from "./boke";
43
import { Doc88 } from "./doc88";
54
import { DocIn } from "./docin";
65
import { QQDoc } from "./qq-doc";
76
import { QQPpt } from "./qq-ppt";
87
import { Wenku } from "./wenku";
98
import { Zhihu } from "./zhihu";
109

11-
export const websites: WebSite[] = [Wenku, Doc88, QQDoc, DocIn, Boke, Zhihu, QQPpt, Basic];
10+
export const websites: WebSite[] = [Wenku, Doc88, QQDoc, DocIn, Zhihu, QQPpt, Basic];

packages/force-copy/src/inject/modules/wenku.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const onMouseUp = (event: MouseEvent) => {
1717
try {
1818
const elements = document.querySelectorAll("#app > div");
1919
for (const item of elements) {
20-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
21-
// @ts-ignore
20+
// @ts-expect-error __vue__
2221
const vue = item.__vue__;
2322
if (vue) {
2423
const text = vue.$store.getters["readerPlugin/selectedTextTrim"];

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ export const ALLOW_PAINT = "@media print{body{display:block !important;}} ";
88
export const COPY_BUTTON_STYLE =
99
".__copy-button {width: 60px; height: 30px; background: #4C98F7;color: #fff;position: absolute;" +
1010
"z-index: -1000;opacity: 0;display: flex;justify-content: center;align-items: center;border-radius: 3px;" +
11-
"font-size: 13px;cursor: pointer;transition: opacity 0.3s;}";
11+
"font-size: 13px;cursor: pointer;transition: opacity 0.3s;} ";
1212

1313
export const AUTO_SELECTION =
1414
":not(input):not(textarea)::selection {" +
15-
" background-color: #BEDAFF !important;" +
16-
" }" +
17-
" " +
15+
" background-color: #BEDAFF !important;" +
16+
" background-color: highlight !important;" +
17+
"} " +
1818
":not(input):not(textarea)::-moz-selection {" +
19-
" background-color: #BEDAFF !important;" +
20-
"}";
19+
" background-color: #BEDAFF !important;" +
20+
" background-color: highlight !important;" +
21+
"} ";

packages/water-mark/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { common } from "./modules/common";
1+
import { basic } from "./modules/basic";
22
import type { Website } from "./types/website";
33

4-
const websites: Website[] = [common];
4+
const websites: Website[] = [basic];
55
const web = websites.find(item => item.regexp.test(location.href));
66
web && web.init();
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FALLBACK_CLASS, OPACITY_BACKGROUND_PROPERTY, OPACITY_PROPERTY } from ".
33
import { inspectWaterMarkDOM } from "../utils/dom";
44
import { injectCSSEarly } from "../utils/styles";
55

6-
export const common: Website = {
6+
export const basic: Website = {
77
regexp: /.*/,
88
init: () => {
99
const observer = MutationObserver.prototype.observe;

0 commit comments

Comments
 (0)