From 03c83f863ce97dce6c2da34be50d0e4eecb0f90c Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 14 Nov 2025 09:31:09 +0100 Subject: [PATCH 1/2] embed-mode: add documentation for new owncloud-embed:share-links event --- docs/dev/web/embed-mode.md | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/dev/web/embed-mode.md b/docs/dev/web/embed-mode.md index 083dbc47..aa523bf7 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); ``` From ea231f79a3953e28f312b0175b3bc62c6fba9ef9 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Fri, 28 Nov 2025 17:27:32 +0100 Subject: [PATCH 2/2] style: make linter happy --- docs/dev/web/embed-mode.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/dev/web/embed-mode.md b/docs/dev/web/embed-mode.md index aa523bf7..ad0b3283 100644 --- a/docs/dev/web/embed-mode.md +++ b/docs/dev/web/embed-mode.md @@ -25,12 +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-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 | +| 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 @@ -55,7 +55,7 @@ To maintain uniformity and ease of handling, each event encapsulates the same st const links = event.data.data; // Array<{ url: string, password?: string }> - links.forEach(link => { + links.forEach((link) => { console.log('Shared link:', link.url, link.password); });