mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-24 18:50:56 +08:00
fix(SelectionAssistant): shortcut in mac and running handling (#7084)
fix(SelectionService): enhance selection and clipboard handling - Updated processSelectTextByShortcut to include a check for the 'started' state before processing. - Modified writeToClipboard to ensure it only attempts to write if the selectionHook is available and 'started'. - Adjusted ShortcutSettings to filter out additional shortcuts when not on Windows, improving platform compatibility.
This commit is contained in:
parent
8a23c0378d
commit
1f2c467fd4
@ -591,7 +591,7 @@ export class SelectionService {
|
||||
* it's a public method used by shortcut service
|
||||
*/
|
||||
public processSelectTextByShortcut(): void {
|
||||
if (!this.selectionHook || this.triggerMode !== TriggerMode.Shortcut) return
|
||||
if (!this.selectionHook || !this.started || this.triggerMode !== TriggerMode.Shortcut) return
|
||||
|
||||
const selectionData = this.selectionHook.getCurrentSelection()
|
||||
|
||||
@ -1189,7 +1189,8 @@ export class SelectionService {
|
||||
}
|
||||
|
||||
public writeToClipboard(text: string): boolean {
|
||||
return this.selectionHook?.writeToClipboard(text) ?? false
|
||||
if (!this.selectionHook || !this.started) return false
|
||||
return this.selectionHook.writeToClipboard(text)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,11 +22,12 @@ const ShortcutSettings: FC = () => {
|
||||
const inputRefs = useRef<Record<string, InputRef>>({})
|
||||
const [editingKey, setEditingKey] = useState<string | null>(null)
|
||||
|
||||
//TODO: if shortcut is not available on all the platforms, block the shortcut here
|
||||
//if shortcut is not available on all the platforms, block the shortcut here
|
||||
let shortcuts = originalShortcuts
|
||||
if (!isWindows) {
|
||||
//Selection Assistant only available on Windows now
|
||||
shortcuts = shortcuts.filter((s) => s.key !== 'selection_assistant_toggle')
|
||||
const excludedShortcuts = ['selection_assistant_toggle', 'selection_assistant_select_text']
|
||||
shortcuts = shortcuts.filter((s) => !excludedShortcuts.includes(s.key))
|
||||
}
|
||||
|
||||
const handleClear = (record: Shortcut) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user