Skip to content

Commit dbe94a7

Browse files
committed
feat: add cursor in copy page option
1 parent c3aeac1 commit dbe94a7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/components/CopyPageDropdown.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ function ChatGPTIcon({ className }: { className?: string }) {
4747
)
4848
}
4949

50+
// Cursor icon
51+
function CursorIcon({ className }: { className?: string }) {
52+
return (
53+
<svg viewBox="0 0 24 24" fill="currentColor" className={className}>
54+
<path d="M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"></path>
55+
</svg>
56+
)
57+
}
58+
5059
// Cache for fetched markdown content
5160
const markdownCache = new Map<string, string>()
5261

@@ -153,6 +162,17 @@ export function CopyPageDropdown({
153162
window.open(`https://chatgpt.com/?q=${prompt}`, '_blank')
154163
}
155164

165+
const handleOpenInCursor = () => {
166+
const pageUrl = window.location.href
167+
const prompt = `Read from this URL:\n${pageUrl}\nand explain it to me`
168+
window.open(
169+
`cursor://anysphere.cursor-deeplink/prompt?text=${encodeURIComponent(
170+
prompt,
171+
)}`,
172+
'_blank',
173+
)
174+
}
175+
156176
const menuItems = [
157177
{
158178
icon: MarkdownIcon,
@@ -172,6 +192,12 @@ export function CopyPageDropdown({
172192
description: 'Ask questions about this page',
173193
onSelect: handleOpenInChatGPT,
174194
},
195+
{
196+
icon: CursorIcon,
197+
label: 'Open in Cursor',
198+
description: 'Ask questions about this page',
199+
onSelect: handleOpenInCursor,
200+
},
175201
]
176202

177203
return (

0 commit comments

Comments
 (0)