Skip to content

Commit 7919dae

Browse files
dschmidtmicbar
andauthored
embed-mode: add documentation for new opencloud-embed:share-links event (#510)
* embed-mode: add documentation for new owncloud-embed:share-links event * style: make linter happy --------- Co-authored-by: Michael Barz <michael.barz@zeitgestalten.eu>
1 parent 1093e94 commit 7919dae

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

docs/dev/web/embed-mode.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ By default, the `postMessage` method does not specify the `targetOrigin` paramet
2525

2626
To maintain uniformity and ease of handling, each event encapsulates the same structure within its payload: `{ name: string, data: any }`.
2727

28-
| Name | Data | Description |
29-
| -------------------------- | ------------ | ------------------------------------------------------------------------------------- |
30-
| **opencloud-embed:select** | `Resource[]` | Gets emitted when user selects resources or location via the select action |
31-
| **opencloud-embed:share** | `string[]` | Gets emitted when user selects resources and shares them via the "Share links" action |
32-
| **opencloud-embed:cancel** | `null` | Gets emitted when user attempts to close the embedded instance via "Cancel" action |
28+
| Name | Data | Description |
29+
| ------------------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
30+
| **opencloud-embed:select** | `Resource[]` | Gets emitted when user selects resources or location via the select action |
31+
| **opencloud-embed:share-links** | `Array<{ url: string, password?: string }>` | Gets emitted when user shares resources via the "Share links" action. Includes passwords when applicable. |
32+
| **opencloud-embed:share** | `string[]` | **(Deprecated)** Gets emitted when user shares resources. Use `opencloud-embed:share-links` for password support. |
33+
| **opencloud-embed:cancel** | `null` | Gets emitted when user attempts to close the embedded instance via "Cancel" action |
3334

3435
### Example
3536

@@ -47,7 +48,22 @@ To maintain uniformity and ease of handling, each event encapsulates the same st
4748
doSomethingWithSelectedResources(resources);
4849
}
4950
51+
function shareLinksEventHandler(event) {
52+
if (event.data?.name !== 'opencloud-embed:share-links') {
53+
return;
54+
}
55+
56+
const links = event.data.data; // Array<{ url: string, password?: string }>
57+
58+
links.forEach((link) => {
59+
console.log('Shared link:', link.url, link.password);
60+
});
61+
62+
doSomethingWithSharedLinks(links);
63+
}
64+
5065
window.addEventListener('message', selectEventHandler);
66+
window.addEventListener('message', shareLinksEventHandler);
5167
</script>
5268
```
5369

0 commit comments

Comments
 (0)