# EmbedNode
Class Inherits LinkCardNode
## About
`EmbedNode` shows a card for content from a known provider, such as a video, a song, or a code sandbox: its thumbnail with a play symbol, its title, and its provider and author. It is built on `LinkCardNode`, which describes when metadata is fetched and how it is stored. The editor never shows live third-party content.
```xojo
Editor.NodeTypes.Add(New GraffitiProEditor.EmbedNode)
Var embed As New GraffitiProEditor.EmbedNode("https://www.youtube.com/watch?v=…")
Editor.AddNode(embed)
embed.FetchMetadata
```
**Providers.** Only sites on the allowlist are embedded. The built-in providers are YouTube, Vimeo, Spotify, SoundCloud, and CodePen. `AddProvider` adds an `EmbedProvider`, `RemoveProvider` removes one by name or instance, `Providers` lists them, and `ProviderFor` finds the one that serves an address. The allowlist is shared by every editor.
Metadata comes from the provider's oEmbed endpoint: title, author, provider name, thumbnail, frame size, and frame address. The toolbar item adds an address no provider serves as a `BookmarkNode` instead and says so.
**Viewing.** Clicking the card with Ctrl on Windows and Linux, or Command on macOS, raises `Editor.LinkPressed` with its address, so the application can open it in the browser.
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| CanImportHTML | element As GraffitiProEditor.HTMLSupport.HTMLElement | Boolean | Returns whether the element is an embed this node type exported. |
| Constructor | url As String = "" | (None) | Creates an embed for the supplied address without fetching its metadata. |
| CopyPropertiesTo | target As Node | (None) | Copies the embed's address, metadata, and frame to another embed. |
| Duplicate | (None) | Node | Returns an independent copy of this embed. |
| FromHTML | element As GraffitiProEditor.HTMLSupport.HTMLElement | Boolean | Imports an embed this node type exported to HTML. |
| FromJSON | data As JSONItem | Boolean | Restores the embed's address, metadata, and frame from JSON without fetching anything. |
| HTMLImportPriority | element As GraffitiProEditor.HTMLSupport.HTMLElement | Integer | Returns a high priority so other figure handlers do not claim exported embeds. |
| HTMLTags | (None) | String | Returns the HTML tag names supported by this node type. |
| LocalizeToolbarItem | strings As GraffitiProEditor.Editor | (None) | Sets this node type's toolbar item text from the supplied editor's localization properties. |
| MetadataRequestURL | (None) | String | Returns the provider's oEmbed request address, or an empty string when no provider serves the address. |
| PerformToolbarAction | editor As Editor <br> selectedItem As DesktopMenuItem | (None) | Asks for an address and adds an embed for it, or a bookmark when no provider serves it. |
| PreferredHeight | g As Graphics <br> availableWidth As Double | Double | Returns the card's height from the frame's proportions. |
| Render | g As Graphics <br> bounds As Rect <br> selected As Boolean | (None) | Draws the embed card: the thumbnail with a play symbol, title, and provider, or the address while there is no metadata. |
| ShowsDescription | (None) | Boolean | Returns False: oEmbed responses have no description. |
| ToHTML | (None) | String | Returns the embed as a figure with the provider's sandboxed frame, or its thumbnail as a link when the frame is not allowed. |
| ToJSON | (None) | JSONItem | Returns the embed's address, metadata, and frame. |
| ToMarkdown | (None) | String | Returns the embed as a Markdown link, with the thumbnail as its image when there is one. |
| TypeName | (None) | String | Returns the display name for this node type. |
## Shared Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| AddProvider | provider As EmbedProvider | (None) | Adds a site to the embed allowlist, replacing a provider with the same name. |
| ProviderFor | url As String | EmbedProvider | Returns the provider that serves the supplied address, or Nil when none does. |
| Providers | (None) | EmbedProvider | Returns the providers on the embed allowlist. |
| RemoveProvider | provider As EmbedProvider | (None) | Removes the supplied provider from the embed allowlist. |
| RemoveProvider | name As String | (None) | Removes the provider with the supplied name from the embed allowlist. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| AuthorName | String | (None) | Gets or sets the content's author or channel, shown after the provider. |
| EmbedSource | String | (None) | Gets or sets the provider's frame address. HTML export writes an iframe only when the provider allows it. |
| Provider | EmbedProvider | (None) | Returns the provider that serves the embed's address, or Nil when none does. |
## Notes
### JSON HTML and Markdown
JSON stores the `LinkCardNode` keys, with the thumbnail in `image` and its address in `imageURL`, and adds `author`, `embedSource`, `embedWidth`, and `embedHeight`.
HTML is a `figure` marked with `data-graffiti-embed`. When the frame address is HTTPS and on one of its provider's embed hosts, the figure holds the provider's `iframe` with `sandbox` and `referrerpolicy` attributes. Otherwise it holds the thumbnail as a link, and no other embed markup is ever written out. The metadata is repeated in `data-` attributes, so the embed imports again without fetching anything, and import keeps a frame only when its provider still allows it.
Markdown is a link to the content with the thumbnail as its image, or a plain link without one.