Skip to content

Commit dcf9b3d

Browse files
committed
feat: hold shift to bypass file creation on long text paste
1 parent 6ef2bd6 commit dcf9b3d

File tree

8 files changed

+46
-29
lines changed

8 files changed

+46
-29
lines changed

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Consider giving a star ⭐ on [Github](https://github.com/pnd280/complexity).
66

77
💖 Support the development via [Ko-fi](https://ko-fi.com/pnd280) or [Paypal](https://paypal.me/pnd280).
88

9+
## v0.0.3.11
10+
11+
_Release date: 8th Oct, 2024_
12+
13+
- **IMPROVE**: `Ctrl (Cmd) + Shift + V` to bypass file creation on long text paste. Normal paste will still create a file.
14+
915
## v0.0.3.6
1016

1117
_Release date: 23rd Sep, 2024_

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "complexity",
33
"displayName": "Complexity - Perplexity.ai supercharged",
4-
"version": "0.0.3.10",
4+
"version": "0.0.3.11",
55
"author": "pnd280",
66
"description": "⚡ Supercharge your Perplexity.ai",
77
"type": "module",

src/content-script/hooks/useQueryBoxObserver.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,25 @@ function interceptPasteEvent() {
201201

202202
$textarea.attr("data-paste-event-intercepted", "true");
203203

204+
$(document).off("keydown.interceptPasteEvent keyup.interceptPasteEvent");
205+
206+
let isShiftKeyPressed = false;
207+
208+
const handleKeyDown = (e: JQuery.TriggeredEvent) => {
209+
if (e.key === "Shift") isShiftKeyPressed = true;
210+
};
211+
212+
const handleKeyUp = (e: JQuery.TriggeredEvent) => {
213+
if (e.key === "Shift") isShiftKeyPressed = false;
214+
};
215+
216+
$(document).on("keydown.interceptPasteEvent", handleKeyDown);
217+
$(document).on("keyup.interceptPasteEvent", handleKeyUp);
218+
204219
$textarea.on("paste", (e) => {
205220
const clipboardEvent = e.originalEvent as ClipboardEvent;
206221

207-
if (clipboardEvent.clipboardData) {
222+
if (clipboardEvent.clipboardData && isShiftKeyPressed) {
208223
if (clipboardEvent.clipboardData.types.includes("text/plain")) {
209224
e.stopImmediatePropagation();
210225
}

src/content-script/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ function initUiUxTweaks() {
4242
UiTweaks.correctColorScheme();
4343

4444
UxTweaks.restoreLogoContextMenu();
45-
UxTweaks.removeConflictedMobileOverlay();
4645

4746
const observe = (url: string) => {
4847
const location = whereAmI(url);

src/cplx-user-settings/GeneralSettings.ts renamed to src/cplx-user-settings/GeneralSettings.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import { ReactNode } from "react";
2+
13
import { CplxUserSettings } from "@/cplx-user-settings/types/cplx-user-settings.types";
4+
import KeyCombo from "@/shared/components/KeyCombo";
25

36
export type PopupSetting<T> = {
47
id: string;
58
label: string;
6-
description?: string;
9+
description?: ReactNode;
710
settingKey?: T;
811
versionRelease?: string;
912
experimental?: boolean;
@@ -63,7 +66,7 @@ export default class GeneralSettings {
6366
id: "custom-markdown-block",
6467
label: "Custom markdown block",
6568
description:
66-
"Precisely display the language of your code and enable syntax highlighting for natively unsupported languages. e.g. `gdscript`, `blade`, etc.",
69+
"Precisely display the language of your code and enable syntax highlighting for natively unsupported languages. e.g. `vue`, `gdscript`, `blade`, etc.",
6770
settingKey: "customMarkdownBlock",
6871
},
6972
{
@@ -93,7 +96,15 @@ export default class GeneralSettings {
9396
id: "no-file-creation-on-paste",
9497
label: "No file creation on long text paste",
9598
settingKey: "noFileCreationOnPaste",
96-
description: "Pasting long text no longer creates a file.",
99+
description: (
100+
<span>
101+
<KeyCombo
102+
className="tw-inline"
103+
keys={["Control (⌘)", "Shift", "V"]}
104+
/>{" "}
105+
to paste long text without creating a file.
106+
</span>
107+
),
97108
versionRelease: "0.0.1.0",
98109
},
99110
{

src/cplx-user-settings/components/GeneralSettings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function SettingGroup<
173173
key={id}
174174
id={id}
175175
className={cn({
176-
"tw-items-start": !!description,
176+
"tw-items-start": description != null,
177177
})}
178178
textLabel={
179179
<div className="tw-flex tw-flex-col tw-gap-1">
@@ -194,7 +194,7 @@ function SettingGroup<
194194
</span>
195195
<span>{label}</span>
196196
</div>
197-
{description && (
197+
{description != null && (
198198
<div className="tw-ml-2 tw-text-xs tw-text-muted-foreground">
199199
{description}
200200
</div>

src/shared/components/KeyCombo.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
export default function KeyCombo({ keys }: { keys: string[] }) {
1+
import { HTMLProps } from "react";
2+
3+
export default function KeyCombo({
4+
keys,
5+
...props
6+
}: HTMLProps<HTMLSpanElement> & { keys: string[] }) {
27
return (
3-
<span className="tw-flex tw-gap-1">
8+
<span className={cn("tw-flex tw-gap-1")} {...props}>
49
{keys.map((key) => (
510
<span
611
key={key}

src/utils/UxTweaks.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { throttle } from "lodash-es";
2-
31
import CplxUserSettings from "@/cplx-user-settings/CplxUserSettings";
42
import UiUtils from "@/utils/UiUtils";
53
import { whereAmI } from "@/utils/utils";
@@ -65,21 +63,4 @@ export default class UxTweaks {
6563
e.stopPropagation();
6664
});
6765
}
68-
69-
static removeConflictedMobileOverlay() {
70-
const handler = throttle(function () {
71-
if (window.innerWidth < 768) {
72-
const $navs = $(".h-mobileNavHeight");
73-
74-
if ($navs.length < 2) return;
75-
76-
$navs.first().remove();
77-
}
78-
}, 200);
79-
80-
requestIdleCallback(() => {
81-
handler();
82-
$(window).on("resize", handler);
83-
});
84-
}
8566
}

0 commit comments

Comments
 (0)