Skip to content

Commit 75a66cb

Browse files
authored
Merge pull request #707 from n4ze3m/next
v1.5.30
2 parents 499660c + dbc1fc0 commit 75a66cb

File tree

13 files changed

+208
-97
lines changed

13 files changed

+208
-97
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Page Assist supports various keyboard shortcuts to enhance your productivity:
123123
| New Chat | `Ctrl+Shift+O` | Starts a new chat conversation |
124124
| Toggle Sidebar | `Ctrl+B` | Opens/closes the chat history sidebar |
125125
| Focus Textarea | `Shift+Esc` | Focuses the message input field |
126+
| Toggle Chat Mode | `Ctrl+E` | Toggles between normal chat and chat with current page |
126127

127128

128129

docs/shortcuts.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@ Page Assist supports the following shortcut keys:
99

1010
You can change the keyboard shortcuts from the extension settings on the Chrome Extension Management page.
1111

12-
## Changing Keyboard Shortcuts
12+
## Application Shortcuts
13+
14+
| Action | Shortcut | Description |
15+
|--------|----------|-------------|
16+
| New Chat | `Ctrl+Shift+O` | Starts a new chat conversation |
17+
| Toggle Sidebar | `Ctrl+B` | Opens/closes the chat history sidebar |
18+
| Focus Textarea | `Shift+Esc` | Focuses the message input field |
19+
| Toggle Chat Mode | `Ctrl+E` | Toggles between normal chat and chat with current page |
20+
21+
## Changing Keyboard Shortcuts (Browser Specific)
1322

1423
To change the keyboard shortcuts, follow these steps:
1524

src/assets/locale/en/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
},
7373
"sidepanelTemporaryChat": {
7474
"label": "Enable Temporary Chat in SidePanel by default"
75+
},
76+
"removeReasoningTagFromCopy": {
77+
"label": "Remove Reasoning Tag from Copied Text"
7578
}
7679
},
7780
"sidepanelRag": {

src/components/Common/CodeBlock.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,20 @@ export const CodeBlock: FC<Props> = ({ language, value }) => {
6868
const code = previewValue || ""
6969
if ((language || "").toLowerCase() === "svg") {
7070
const hasSvgTag = /<svg[\s>]/i.test(code)
71-
const svgMarkup = hasSvgTag
71+
let svgMarkup = hasSvgTag
7272
? code
7373
: `<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>${code}</svg>`
74-
return `<!doctype html><html><head><meta charset='utf-8'/><style>html,body{margin:0;padding:0;display:flex;align-items:center;justify-content:center;background:#fff;height:100%;}</style></head><body>${svgMarkup}</body></html>`
74+
75+
const hasWidthHeight = /\s(width|height)\s*=/.test(svgMarkup)
76+
77+
if (!hasWidthHeight && hasSvgTag) {
78+
svgMarkup = svgMarkup.replace(
79+
/<svg([^>]*?)>/i,
80+
'<svg$1 width="100%" height="100%" style="max-width: 100%; max-height: 100%;">'
81+
)
82+
}
83+
84+
return `<!doctype html><html><head><meta charset='utf-8'/><style>html,body{margin:0;padding:0;display:flex;align-items:center;justify-content:center;background:#fff;height:100%;overflow:hidden;}svg{max-width:100%;max-height:100%;}</style></head><body>${svgMarkup}</body></html>`
7585
}
7686
return `<!doctype html><html><head><meta charset='utf-8'/></head><body>${code}</body></html>`
7787
}, [previewValue, language])

src/components/Layouts/MoreOptions.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,11 @@ export const MoreOptions = ({
9696
key: "copy-text",
9797
label: t("more.copy.asText"),
9898
icon: <FileText className="w-4 h-4" />,
99-
onClick: () => {
100-
navigator.clipboard.writeText(formatAsText(messages))
99+
onClick: async () => {
100+
await copyToClipboard({
101+
text: formatAsText(messages),
102+
formatted: false
103+
})
101104
message.success(t("more.copy.success"))
102105
}
103106
},
@@ -113,16 +116,18 @@ export const MoreOptions = ({
113116
text: mkd,
114117
formatted: true
115118
})
116-
// navigator.clipboard.writeText(formatAsMarkdown(messages))
117119
message.success(t("more.copy.success"))
118120
}
119121
},
120122
{
121123
key: "copy-markdown",
122124
label: t("more.copy.asMarkdown"),
123125
icon: <FileCode className="w-4 h-4" />,
124-
onClick: () => {
125-
navigator.clipboard.writeText(formatAsMarkdown(messages))
126+
onClick: async () => {
127+
await copyToClipboard({
128+
text: formatAsMarkdown(messages),
129+
formatted: false
130+
})
126131
message.success(t("more.copy.success"))
127132
}
128133
}

src/components/Option/Settings/general-settings.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export const GeneralSettings = () => {
8282
false
8383
)
8484

85+
const [removeReasoningTagFromCopy, setRemoveReasoningTagFromCopy] =
86+
useStorage("removeReasoningTagFromCopy", true)
87+
8588
const { mode, toggleDarkMode } = useDarkMode()
8689
const { t } = useTranslation("settings")
8790
const { changeLocale, locale, supportLanguage } = useI18n()
@@ -349,6 +352,17 @@ export const GeneralSettings = () => {
349352
/>
350353
</div>
351354

355+
<div className="flex flex-row justify-between">
356+
<span className="text-gray-700 dark:text-neutral-50 ">
357+
{t("generalSettings.settings.removeReasoningTagFromCopy.label")}
358+
</span>
359+
360+
<Switch
361+
checked={removeReasoningTagFromCopy}
362+
onChange={(checked) => setRemoveReasoningTagFromCopy(checked)}
363+
/>
364+
</div>
365+
352366
<div className="flex flex-row justify-between">
353367
<span className="text-gray-700 dark:text-neutral-50 ">
354368
{t("generalSettings.settings.darkMode.label")}

src/components/Option/Settings/system-settings.tsx

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ export const SystemSettings = () => {
126126
</h2>
127127
<div className="border border-b border-gray-200 dark:border-gray-600 mt-3"></div>
128128
</div>
129-
<div className="flex flex-row mb-3 justify-between items-center">
129+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
130130
<span className="text-black dark:text-white font-medium">
131131
<BetaTag />
132132
{t("generalSettings.system.fontSize.label")}
133133
</span>
134-
<div className="flex flex-row items-center gap-3">
134+
<div className="flex flex-row items-center gap-3 justify-center sm:justify-end">
135135
<button
136136
onClick={decrease}
137137
className="bg-black hover:bg-gray-800 dark:bg-white dark:hover:bg-gray-200 text-white dark:text-black px-3 py-1.5 rounded-lg transition-colors duration-200 font-medium text-sm">
@@ -148,8 +148,8 @@ export const SystemSettings = () => {
148148
</div>
149149
</div>
150150

151-
<div className="flex flex-row mb-3 justify-between">
152-
<span className="text-gray-700 dark:text-neutral-50 ">
151+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
152+
<span className="text-gray-700 dark:text-neutral-50">
153153
<BetaTag />
154154
{t("generalSettings.system.actionIcon.label")}
155155
</span>
@@ -165,14 +165,14 @@ export const SystemSettings = () => {
165165
}
166166
]}
167167
value={actionIconClick}
168-
className="w-full mt-4 sm:mt-0 sm:w-[200px]"
168+
className="w-full sm:w-[200px]"
169169
onChange={(value) => {
170170
setActionIconClick(value)
171171
}}
172172
/>
173173
</div>
174-
<div className="flex flex-row mb-3 justify-between">
175-
<span className="text-gray-700 dark:text-neutral-50 ">
174+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
175+
<span className="text-gray-700 dark:text-neutral-50">
176176
<BetaTag />
177177
{t("generalSettings.system.contextMenu.label")}
178178
</span>
@@ -188,15 +188,15 @@ export const SystemSettings = () => {
188188
}
189189
]}
190190
value={contextMenuClick}
191-
className="w-full mt-4 sm:mt-0 sm:w-[200px]"
191+
className="w-full sm:w-[200px]"
192192
onChange={(value) => {
193193
setContextMenuClick(value)
194194
}}
195195
/>
196196
</div>
197197
{isFireFox && !isFireFoxPrivateMode && (
198-
<div className="flex flex-row mb-3 justify-between">
199-
<span className="text-gray-700 dark:text-neutral-50 ">
198+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
199+
<span className="text-gray-700 dark:text-neutral-50">
200200
<BetaTag />
201201
{t("generalSettings.system.firefoxPrivateModeSync.label", {
202202
defaultValue:
@@ -208,7 +208,7 @@ export const SystemSettings = () => {
208208
syncFirefoxData.mutate()
209209
}}
210210
disabled={syncFirefoxData.isPending}
211-
className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer">
211+
className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer w-full sm:w-auto">
212212
{syncFirefoxData.isPending ? (
213213
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
214214
) : (
@@ -219,30 +219,32 @@ export const SystemSettings = () => {
219219
</button>
220220
</div>
221221
)}
222-
<div className="flex flex-row mb-3 justify-between">
223-
<span className="text-gray-700 dark:text-neutral-50 ">
222+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
223+
<span className="text-gray-700 dark:text-neutral-50">
224224
{t("generalSettings.system.webuiBtnSidePanel.label")}
225225
</span>
226-
<Switch
226+
<div>
227+
<Switch
227228
checked={webuiBtnSidePanel}
228229
onChange={(checked) => {
229230
setWebuiBtnSidePanel(checked)
230231
}}
231232
/>
233+
</div>
232234
</div>
233235

234-
<div className="flex flex-row mb-3 justify-between">
235-
<span className="text-gray-700 dark:text-neutral-50 ">
236+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
237+
<span className="text-gray-700 dark:text-neutral-50">
236238
<BetaTag />
237239
{t("generalSettings.system.chatBackgroundImage.label")}
238240
</span>
239-
<div className="flex items-center gap-2">
241+
<div className="flex items-center gap-2 justify-center sm:justify-end">
240242
{chatBackgroundImage ? (
241243
<button
242244
onClick={() => {
243245
setChatBackgroundImage(null)
244246
}}
245-
className=" text-gray-800 dark:text-white">
247+
className="text-gray-800 dark:text-white">
246248
<RotateCcw className="size-4" />
247249
</button>
248250
) : null}
@@ -262,23 +264,23 @@ export const SystemSettings = () => {
262264
</div>
263265
</div>
264266

265-
<div className="flex flex-row mb-3 justify-between">
266-
<span className="text-gray-700 dark:text-neutral-50 ">
267+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
268+
<span className="text-gray-700 dark:text-neutral-50">
267269
{t("generalSettings.system.export.label")}
268270
</span>
269271
<button
270272
onClick={exportPageAssistData}
271-
className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer">
273+
className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer w-full sm:w-auto">
272274
{t("generalSettings.system.export.button")}
273275
</button>
274276
</div>
275-
<div className="flex flex-row mb-3 justify-between">
276-
<span className="text-gray-700 dark:text-neutral-50 ">
277+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
278+
<span className="text-gray-700 dark:text-neutral-50">
277279
{t("generalSettings.system.import.label")}
278280
</span>
279281
<label
280282
htmlFor="import"
281-
className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer flex items-center">
283+
className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer flex items-center justify-center w-full sm:w-auto">
282284
{importDataMutation.isPending ? (
283285
<>
284286
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
@@ -301,8 +303,8 @@ export const SystemSettings = () => {
301303
/>
302304
</div>
303305

304-
<div className="flex flex-row mb-3 justify-between">
305-
<span className="text-gray-700 dark:text-neutral-50 ">
306+
<div className="flex flex-col sm:flex-row mb-3 gap-3 sm:gap-0 sm:justify-between sm:items-center">
307+
<span className="text-gray-700 dark:text-neutral-50">
306308
{t("generalSettings.system.deleteChatHistory.label")}
307309
</span>
308310

@@ -328,7 +330,7 @@ export const SystemSettings = () => {
328330
}
329331
}
330332
}}
331-
className="bg-red-500 dark:bg-red-600 text-white dark:text-gray-200 px-4 py-2 rounded-md">
333+
className="bg-red-500 dark:bg-red-600 text-white dark:text-gray-200 px-4 py-2 rounded-md w-full sm:w-auto">
332334
{t("generalSettings.system.deleteChatHistory.button")}
333335
</button>
334336
</div>

src/hooks/keyboard/useKeyboardShortcuts.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,35 @@ export const useSidebarShortcuts = (
174174
shortcuts
175175
}
176176
}
177+
178+
/**
179+
* Hook specifically for chat mode shortcuts
180+
* @param toggleChatMode Function to toggle chat mode between normal and rag
181+
* @param enabled Whether the shortcuts are enabled
182+
*/
183+
export const useChatModeShortcuts = (
184+
toggleChatMode: () => void,
185+
enabled: boolean = true
186+
) => {
187+
const { shortcuts: configuredShortcuts } = useShortcutConfig()
188+
189+
const toggleChatModeAction = useCallback(() => {
190+
toggleChatMode()
191+
}, [toggleChatMode])
192+
193+
const shortcuts: KeyboardShortcutConfig[] = [
194+
{
195+
shortcut: configuredShortcuts.toggleChatMode,
196+
action: toggleChatModeAction,
197+
enabled,
198+
description: 'Toggle chat with current page'
199+
}
200+
]
201+
202+
useKeyboardShortcuts(shortcuts)
203+
204+
return {
205+
toggleChatMode: toggleChatModeAction,
206+
shortcuts
207+
}
208+
}

src/hooks/keyboard/useShortcutConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface ShortcutConfig {
55
focusTextarea: KeyboardShortcut
66
newChat: KeyboardShortcut
77
toggleSidebar: KeyboardShortcut
8+
toggleChatMode: KeyboardShortcut
89
}
910

1011
export const defaultShortcuts: ShortcutConfig = {
@@ -26,6 +27,12 @@ export const defaultShortcuts: ShortcutConfig = {
2627
ctrlKey: true,
2728
preventDefault: true,
2829
stopPropagation: true
30+
},
31+
toggleChatMode: {
32+
key: 'e',
33+
ctrlKey: true,
34+
preventDefault: true,
35+
stopPropagation: true
2936
}
3037
}
3138

src/routes/sidepanel-chat.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import {
66
import useBackgroundMessage from "@/hooks/useBackgroundMessage"
77
import { useMigration } from "@/hooks/useMigration"
88
import { useSmartScroll } from "@/hooks/useSmartScroll"
9-
import { useChatShortcuts, useSidebarShortcuts } from "@/hooks/keyboard/useKeyboardShortcuts"
9+
import {
10+
useChatShortcuts,
11+
useSidebarShortcuts,
12+
useChatModeShortcuts
13+
} from "@/hooks/keyboard/useKeyboardShortcuts"
1014
import { copilotResumeLastChat } from "@/services/app"
1115
import { Storage } from "@plasmohq/storage"
1216
import { useStorage } from "@plasmohq/storage/hook"
@@ -37,6 +41,7 @@ const SidepanelChat = () => {
3741
setMessages,
3842
selectedModel,
3943
defaultChatWithWebsite,
44+
chatMode,
4045
setChatMode,
4146
setTemporaryChat,
4247
sidepanelTemporaryChat,
@@ -46,11 +51,16 @@ const SidepanelChat = () => {
4651
useSmartScroll(messages, streaming, 100)
4752

4853
const toggleSidebar = () => {
49-
setSidebarOpen(prev => !prev)
54+
setSidebarOpen((prev) => !prev)
55+
}
56+
57+
const toggleChatMode = () => {
58+
setChatMode(chatMode === "rag" ? "normal" : "rag")
5059
}
5160

5261
useChatShortcuts(clearChat, true)
5362
useSidebarShortcuts(toggleSidebar, true)
63+
useChatModeShortcuts(toggleChatMode, true)
5464

5565
const [chatBackgroundImage] = useStorage({
5666
key: "chatBackgroundImage",
@@ -165,7 +175,7 @@ const SidepanelChat = () => {
165175
<div className="flex h-full w-full">
166176
<main className="relative h-dvh w-full">
167177
<div className="relative z-20 w-full">
168-
<SidepanelHeader
178+
<SidepanelHeader
169179
sidebarOpen={sidebarOpen}
170180
setSidebarOpen={setSidebarOpen}
171181
/>

0 commit comments

Comments
 (0)