# BookmarkNode
Class Inherits LinkCardNode
## About
`BookmarkNode` shows a card for a web page: its title, description, site name and icon, and its preview image on the trailing side. It is built on `LinkCardNode`, which describes when metadata is fetched and how it is stored.
```xojo
Editor.NodeTypes.Add(New GraffitiProEditor.BookmarkNode)
Var bookmark As New GraffitiProEditor.BookmarkNode("https://www.xojo.com")
Editor.AddNode(bookmark)
bookmark.FetchMetadata
```
The toolbar item asks for an address, adds the bookmark, and fetches its metadata. The page is read until the end of its `head`: the title comes from `og:title`, `twitter:title`, or the `title` element; the description from `og:description`, `twitter:description`, or `description`; the site name from `og:site_name`; the image from `og:image` or `twitter:image`; and the icon from an `apple-touch-icon` or `icon` link. Relative addresses are resolved against the page.
Without metadata, the card shows the address as a plain link.
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| CanImportHTML | element As GraffitiProEditor.HTMLSupport.HTMLElement | Boolean | Returns whether the element is a bookmark this node type exported. |
| Constructor | url As String = "" | (None) | Creates a bookmark for the supplied address without fetching its metadata. |
| Duplicate | (None) | Node | Returns an independent copy of this bookmark. |
| FromHTML | element As GraffitiProEditor.HTMLSupport.HTMLElement | Boolean | Imports a bookmark this node type exported to HTML. |
| HTMLImportPriority | element As GraffitiProEditor.HTMLSupport.HTMLElement | Integer | Returns a high priority so other div handlers do not claim exported bookmarks. |
| 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. |
| PerformToolbarAction | editor As Editor <br> selectedItem As DesktopMenuItem | (None) | Asks for an address, adds a bookmark for it, and fetches its metadata. |
| PreferredHeight | g As Graphics <br> availableWidth As Double | Double | Returns the card's height, which does not depend on its width. |
| Render | g As Graphics <br> bounds As Rect <br> selected As Boolean | (None) | Draws the bookmark card: title, description, site, and preview image, or the address while there is no metadata. |
| ToHTML | (None) | String | Returns the bookmark as a link card, with its metadata in data attributes for import. |
| ToMarkdown | (None) | String | Returns the bookmark as a Markdown link. |
| TypeName | (None) | String | Returns the display name for this node type. |
## Notes
### JSON HTML and Markdown
JSON stores `url`, `title`, `description`, `siteName`, `imageURL`, `iconURL`, and the pictures as data URIs in `image` and `icon`.
HTML is a `div` marked with `data-graffiti-bookmark` that holds a link card. The metadata is repeated in `data-` attributes and the pictures are `img` elements with `data-role="image"` and `data-role="icon"`, so the bookmark imports again without fetching anything.
Markdown is a link to the page with the title as its text, or the address in angle brackets when there is no title.