diff --git a/docs/dev/web/embed-mode.md b/docs/dev/web/embed-mode.md index 083dbc47..ad0b3283 100644 --- a/docs/dev/web/embed-mode.md +++ b/docs/dev/web/embed-mode.md @@ -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 @@ -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); ```