Shared utilities for converting external service URLs (Google Sheets, Figma) into embeddable iframe-compatible formats. Used by embed components in the lib and the admin document editor in the hub. ## Key Components | Export | Description | |---|---| | `toGoogleSheetsEmbedUrl` | Converts a Google Sheets URL to the `htmlembed` format, preserving the `gid` (sheet tab) parameter | | `toGoogleSheetsOriginalUrl` | Normalizes a Sheets URL back to the standard `/edit#gid=` format | | `toFigmaEmbedUrl` | Converts any Figma URL (design, proto, slides/deck, board) to `embed.figma.com`, injecting `embed-host` and optional `client-id` params | | `isFigmaSlidesUrl` | Returns `true` if the URL points to a Figma Slides or Deck resource | | `toFigmaOriginalUrl` | Strips embed-specific domain and query string to recover the original Figma URL | ## Usage Example ```typescript import { toGoogleSheetsEmbedUrl, toFigmaEmbedUrl, isFigmaSlidesUrl, } from './embed-url-converters' // Google Sheets — converts to htmlembed with tab preserved const sheetsEmbed = toGoogleSheetsEmbedUrl( 'https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms/edit#gid=0' ) // → https://docs.google.com/spreadsheets/d/1Bxi.../htmlembed?widget=true&chrome=false&headers=false&gid=0 // Figma design const figmaEmbed = toFigmaEmbedUrl( 'https://www.figma.com/design/ABC123/My-Component' ) // → https://embed.figma.com/design/ABC123/My-Component?embed-host=flamingo // Figma slides — browse mode const slidesEmbed = toFigmaEmbedUrl( 'https://www.figma.com/slides/ABC123/Deck', { slidesView: 'browse' } ) // → https://embed.figma.com/slides/ABC123/Deck?embed-host=flamingo // Type guard isFigmaSlidesUrl('https://www.figma.com/deck/ABC123/Q3-Review') // → true ``` ## Notes - `toFigmaEmbedUrl` reads `NEXT_PUBLIC_FIGMA_CLIENT_ID` from the environment and injects it as a `client-id` query param when present. - Already-embedded URLs (containing `embed.figma.com` or `/htmlembed`) are returned unchanged — all converters are idempotent. - Figma `slides` and `deck` URL types both map to the `deck` embed view by default; pass `{ slidesView: 'browse' }` to switch to the `slides` browse view. **Source:** [`embed-url-converters.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/embed-url-converters.ts)