Skip to content

Commit 6329354

Browse files
authored
feat: add keyboard event handling and double-click copying (#409)
* feat: add keyboard event handling and double-click copying * docs: delete duplicate release note entries
1 parent 3ef5226 commit 6329354

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

docs/content.en/docs/release-notes/_index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Information about release notes of Coco Server is provided here.
2525
- feat: add keyboard-only operation to history list #385
2626
- feat: add error notification #386
2727
- feat: add support for AI assistant #394
28-
- feat: add support for AI assistant #394
2928
- feat: add support for calculator function #399
3029

3130
### Bug fix

src/components/Search/Calculator.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ChevronsRight } from "lucide-react";
22
import { FC } from "react";
33
import clsx from "clsx";
44
import { useTranslation } from "react-i18next";
5+
import { copyToClipboard } from "@/utils";
56

67
interface CalculatorProps {
78
item: any;
@@ -36,7 +37,12 @@ const Calculator: FC<CalculatorProps> = (props) => {
3637
};
3738

3839
return (
39-
<div className="flex items-center gap-1 w-full children:flex">
40+
<div
41+
className="flex items-center gap-1 w-full children:flex"
42+
onDoubleClick={() => {
43+
copyToClipboard(result.value);
44+
}}
45+
>
4046
{renderItem(query.value, t(`calculator.${query.type}`))}
4147

4248
<ChevronsRight className="text-[#999999] size-5" />

src/components/Search/ContextMenu.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { useClickAway, useCreation, useReactive } from "ahooks";
1+
import {
2+
useClickAway,
3+
useCreation,
4+
useEventListener,
5+
useReactive,
6+
} from "ahooks";
27
import clsx from "clsx";
38
import { isNil, noop } from "lodash-es";
49
import { Copy, Link, SquareArrowOutUpRight } from "lucide-react";
@@ -152,6 +157,12 @@ const ContextMenu = ({ hideCoco }: ContextMenuProps) => {
152157
handleClick(item?.clickEvent);
153158
});
154159

160+
useEventListener("keydown", (event) => {
161+
if (!visibleContextMenu) return;
162+
163+
event.stopImmediatePropagation();
164+
});
165+
155166
const handleClick = (click = noop) => {
156167
click?.();
157168

0 commit comments

Comments
 (0)