You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feathernote supports sharing images (e.g., screenshots) from Android devices directly into the app's 'Shared Inbox' note via the PWA Share Target API.
5
+
6
+
## Manifest Configuration
7
+
The `src/manifest.json` file is configured with a `share_target` block using `multipart/form-data`. The `params` field includes an `image` entry within a `files` array, which tells the browser to accept shared files matching `image/*`.
8
+
9
+
```json
10
+
"share_target": {
11
+
"action": "/share",
12
+
"method": "POST",
13
+
"enctype": "multipart/form-data",
14
+
"params": {
15
+
"title": "title",
16
+
"text": "text",
17
+
"url": "url",
18
+
"files": [
19
+
{
20
+
"name": "image",
21
+
"accept": ["image/*"]
22
+
}
23
+
]
24
+
}
25
+
}
26
+
```
27
+
28
+
## Service Worker Handling (`/share`)
29
+
The `/share` handler in `src/serviceworker.js` processes incoming share requests:
30
+
31
+
1.**Extraction**: It extracts the `FormData` from the POST request.
32
+
2.**File Retrieval**: It retrieves the file using `data.get('image')`.
33
+
3.**Storage**: If a valid `File` object is retrieved:
34
+
* A unique ID is generated via `generateUniqueId('img')`.
35
+
* The file blob is stored in the `IMAGE_STORE` IndexedDB using `addImageDB`.
36
+
* A markdown image reference `` is created.
37
+
4.**Note Integration**:
38
+
* The image reference and existing text/link content are combined into a final string using `filter(Boolean).join('\n\n')`.
39
+
* This content is prepended to the existing 'Shared Inbox' note or used to create a new one if it doesn't exist.
40
+
5.**Backward Compatibility**: The code checks `imageFile instanceof File`. If no image is shared, the reference remains empty and the text/link sharing logic proceeds as it did previously.
0 commit comments