feat: MVP-5 Sprint 4 - External Capture via Bookmarklet
- Add bookmarklet for capturing web content from any page - Add capture confirmation page with edit before save - Add secure /api/capture endpoint with rate limiting - Add bookmarklet instructions component with drag-and-drop
This commit is contained in:
25
src/lib/external-capture.ts
Normal file
25
src/lib/external-capture.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export interface CapturePayload {
|
||||
title: string
|
||||
url: string
|
||||
selection: string
|
||||
}
|
||||
|
||||
export function encodeCapturePayload(payload: CapturePayload): string {
|
||||
const params = new URLSearchParams({
|
||||
title: payload.title,
|
||||
url: payload.url,
|
||||
selection: payload.selection,
|
||||
})
|
||||
return params.toString()
|
||||
}
|
||||
|
||||
export function generateBookmarklet(): string {
|
||||
const code = `
|
||||
var title = document.title;
|
||||
var url = location.href;
|
||||
var selection = window.getSelection().toString();
|
||||
var params = new URLSearchParams({title, url, selection});
|
||||
window.open('/capture?' + params.toString(), '_blank');
|
||||
`.replace(/\s+/g, ' ').trim()
|
||||
return `javascript:${code}`
|
||||
}
|
||||
Reference in New Issue
Block a user