Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions docs/dev/web/embed-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ By default, the `postMessage` method does not specify the `targetOrigin` paramet

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

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

### Example

Expand All @@ -47,7 +48,22 @@ To maintain uniformity and ease of handling, each event encapsulates the same st
doSomethingWithSelectedResources(resources);
}

function shareLinksEventHandler(event) {
if (event.data?.name !== 'opencloud-embed:share-links') {
return;
}

const links = event.data.data; // Array<{ url: string, password?: string }>

links.forEach((link) => {
console.log('Shared link:', link.url, link.password);
});

doSomethingWithSharedLinks(links);
}

window.addEventListener('message', selectEventHandler);
window.addEventListener('message', shareLinksEventHandler);
</script>
```

Expand Down