Core
Classes
OrbitParseError
Extends
Error
Constructors
Constructor
new OrbitParseError(
message,
line,
code?
): OrbitParseError;Parameters
| Parameter | Type | Default value |
|---|---|---|
message |
string |
undefined |
line |
number |
undefined |
code |
| "empty-document" | "no-structure" | "synthetic-root" | "invalid-frontmatter" | "unknown-frontmatter-key" | "unsupported-schema-version" | "invalid-attributes" | "unknown-attribute" | "invalid-option-value" | "media-missing-source" | "unknown-content-type" | "caption-without-media" | "unknown-link-target" | "invalid-yaml" | "unknown-yaml-key" | "ignored-node-entry" |
'invalid-yaml' |
Returns
Overrides
Error.constructorProperties
code
readonly code:
| "empty-document"
| "no-structure"
| "synthetic-root"
| "invalid-frontmatter"
| "unknown-frontmatter-key"
| "unsupported-schema-version"
| "invalid-attributes"
| "unknown-attribute"
| "invalid-option-value"
| "media-missing-source"
| "unknown-content-type"
| "caption-without-media"
| "unknown-link-target"
| "invalid-yaml"
| "unknown-yaml-key"
| "ignored-node-entry";line
readonly line: number;OrbitSVGRenderer
Constructors
Constructor
new OrbitSVGRenderer(container, options?): OrbitSVGRenderer;Parameters
| Parameter | Type |
|---|---|
container |
HTMLElement |
options |
RendererOptions |
Returns
Methods
addNode()
addNode(
parentId,
input,
index?
): OrbitNode | null;Adds a node under parentId, at index among its children (default:
last); it flies out of its parent into place. Its id comes from its
text, as when the map is read from markdown. Fires edit. Returns the
new node, or null when there’s no such parent.
Parameters
| Parameter | Type |
|---|---|
parentId |
string |
input |
Partial<Pick<OrbitNode, | "text" | "link" | "image" | "video" | "embed" | "note" | "color" | "icon" | "status" | "priority" | "tags" | "collapsed" | "noteFormat" | "type" | "attrs">> & object |
index? |
number |
Returns
OrbitNode | null
destroy()
destroy(): void;Returns
void
editNewNode()
editNewNode(parentId?, index?): boolean;Adds an idea by typing it on the map: a field opens in the orbit of
parentId (default: the node in focus), at index among its children
(default: after the last), flying there first. Enter adds the idea
where it was typed and opens the next one after it; Escape, or Enter
with nothing typed, stops. Fires editor-open, edit for each idea,
then editor-close. Returns false when there’s no such node.
Parameters
| Parameter | Type |
|---|---|
parentId? |
string |
index? |
number |
Returns
boolean
editNode()
editNode(id): boolean;Opens a field over a node to type its text where it is: Enter saves,
Escape cancels, and leaving the field saves. A moon, or a node out of
view, flies into view first. Fires editor-open, then editor-close.
Returns false when there’s no such node.
Parameters
| Parameter | Type |
|---|---|
id |
string |
Returns
boolean
fit()
fit(): void;Returns the camera to the fitted view.
Returns
void
flyTo()
flyTo(id): boolean;Flies to a node by id, switching to focus mode if needed (fires onFocusChange and onViewModeChange). Returns false when there’s no such node.
Parameters
| Parameter | Type |
|---|---|
id |
string |
Returns
boolean
focusNode()
focusNode(id): boolean;Focuses a node by id and flies to it (fires onFocusChange). In the overview, the camera moves to the node instead. Returns false when the id isn’t in the map.
Parameters
| Parameter | Type |
|---|---|
id |
string |
Returns
boolean
getDocument()
getDocument(): OrbitDocument | null;The map as a document: its tree, and the options its source set in frontmatter. Edits change this tree in place.
Returns
OrbitDocument | null
getFocusedNode()
getFocusedNode(): OrbitNode | null;The node focused in focus mode (the sun).
Returns
OrbitNode | null
getFocusPath()
getFocusPath(): string[];Ids from the root to the focused node.
Returns
string[]
getNodeColor()
getNodeColor(id): string | null;The color a node is drawn with: its own, its type’s, or its branch’s
from the palette and theme. For lists and legends next to the map. A hex
color, or the CSS color as written when Orbit can’t read it; null when
the id isn’t in the map.
Parameters
| Parameter | Type |
|---|---|
id |
string |
Returns
string | null
getSVGElement()
getSVGElement(): SVGSVGElement;Returns
SVGSVGElement
getViewMode()
getViewMode(): ViewMode;Returns
moveNode()
moveNode(
id,
parentId,
index?
): OrbitNode | null;Moves a node, with everything under it, under parentId at index
among its children (default: last). Fires edit. Returns the node,
or null when either node is missing, the node is the root, or
parentId is inside the node.
Parameters
| Parameter | Type |
|---|---|
id |
string |
parentId |
string |
index? |
number |
Returns
OrbitNode | null
on()
on<Name>(name, listener): () => void;Listens for a map event; returns a function that stops listening. The
same events are dispatched on the container as orbit-<name> DOM events.
Type Parameters
| Type Parameter |
|---|
Name extends keyof OrbitEventMap |
Parameters
| Parameter | Type |
|---|---|
name |
Name |
listener |
(detail) => void |
Returns
() => void
overview()
overview(): void;Flies out to the overview of the whole map (fires onViewModeChange).
Returns
void
removeNode()
removeNode(id): OrbitNode | null;Removes a node and everything under it. When the node in focus goes,
the nearest node left takes the focus. The root stays. Fires edit.
Returns the removed node, or null.
Parameters
| Parameter | Type |
|---|---|
id |
string |
Returns
OrbitNode | null
render()
render(input): void;Draws a map: markdown or YAML source (parsed forgivingly), a parsed document, or a node tree. A document’s frontmatter options apply, though options given to the renderer win. Drawing a new version of the same map keeps the reader’s place: the focused node, or its closest ancestor that still exists.
Parameters
| Parameter | Type |
|---|---|
input |
string | OrbitNode | OrbitDocument |
Returns
void
setOptions()
setOptions(options): void;Parameters
| Parameter | Type |
|---|---|
options |
RendererOptions |
Returns
void
setViewMode()
setViewMode(mode): void;Switches between focus mode and the overview (fires onViewModeChange).
Parameters
| Parameter | Type |
|---|---|
mode |
ViewMode |
Returns
void
spin()
spin(speed): void;Flicks the orbit at speed degrees per second; negative speeds turn it
counterclockwise. Only in focus mode.
Parameters
| Parameter | Type |
|---|---|
speed |
number |
Returns
void
stopEditing()
stopEditing(save?): void;Closes the field for typing on the map, keeping what was typed unless save is false.
Parameters
| Parameter | Type | Default value |
|---|---|---|
save |
boolean |
true |
Returns
void
toMarkdown()
toMarkdown(): string;The map as orbit-md, frontmatter included: what to save after an edit.
Returns
string
toSVGString()
toSVGString(): string;The current view as a standalone SVG document: colors resolved, labels as SVG text, nothing that depends on the page’s stylesheet.
Returns
string
unmount()
static unmount(target): boolean;Destroys the renderer drawing into target, if there is one. Returns whether there was.
Parameters
| Parameter | Type |
|---|---|
target |
HTMLElement |
Returns
boolean
updateNode()
updateNode(id, changes): OrbitNode | null;Changes a node’s text or attributes: { text: 'Budget' }, { status: 'done' }, or { color: undefined } to remove one. New text gives the
node a new id when its id came from its text and no link points at it,
so the saved map needs no id attribute. Fires edit. Returns the
node, or null when there’s no such node.
Parameters
| Parameter | Type |
|---|---|
id |
string |
changes |
OrbitNodeInput |
Returns
OrbitNode | null
zoomBy()
zoomBy(factor): void;Zooms by factor around the middle of the map (above 1 zooms in).
Parameters
| Parameter | Type |
|---|---|
factor |
number |
Returns
void
Interfaces
AutoRenderOptions
How a map looks and behaves. Every option is optional; options passed to the renderer win over the document’s frontmatter.
Extends
Properties
| Property | Type | Description | Inherited from |
|---|---|---|---|
actions? |
OrbitAction[] |
Your own buttons under the focused node and in its detail sheet, before the registered ones. | RendererOptions.actions |
ariaLabel? |
string |
The map’s accessible name. Default: the document’s title. |
RendererOptions.ariaLabel |
baseUrl? |
string |
Resolves relative image, video and link URLs. | RendererOptions.baseUrl |
className? |
string |
- | - |
editable? |
boolean |
Build the map on the map: a + in the orbit adds an idea, typed right in its new planet, and a long press, a right click or F2 edits a node’s text where it is. Default false. | RendererOptions.editable |
focus? |
string |
The node in focus when the map first draws, by id: to open a map where the reader left it. Default: the root. Later renders keep the reader’s place. | RendererOptions.focus |
height? |
number |
- | - |
interactive? |
boolean |
false draws a still picture: no clicks, drags, zoom or keyboard. Default true. |
RendererOptions.interactive |
longPressDelay? |
number |
How long (ms) a finger or pen holds still on a node before it counts as a long press (see onNodeContext). Default 500; apps can pass their platform’s own, such as Android’s 400. |
RendererOptions.longPressDelay |
maxDepth? |
number |
Levels below the root to render (1 = root + direct children). | RendererOptions.maxDepth |
nodeTypes? |
Record<string, OrbitNodeType> |
Node types by name: what nodes with type: name look like, draw inside them, show in the detail sheet and offer as actions. They come before the ones registered with registerNodeType. |
RendererOptions.nodeTypes |
noteRenderer? |
(note, context) => string |
Renders a note to HTML yourself. The HTML is used as-is: sanitize untrusted notes. | RendererOptions.noteRenderer |
onAction? |
(event) => false | void |
A button was pressed. Return false to skip what it does (the detail sheet, the link, or your action’s run). |
RendererOptions.onAction |
onEdit? |
(edit) => void |
The map was edited with addNode, updateNode, removeNode or moveNode; save renderer.toMarkdown() to keep it. |
RendererOptions.onEdit |
onEditorClose? |
(event) => void |
The field for typing on the map closed. | RendererOptions.onEditorClose |
onEditorOpen? |
(event) => void |
The field for typing on the map opened. | RendererOptions.onEditorOpen |
onFocusChange? |
(node) => void |
A new node is in focus. | RendererOptions.onFocusChange |
onNodeClick? |
(node) => void |
A node was clicked or activated with the keyboard, before the map reacts. | RendererOptions.onNodeClick |
onNodeContext? |
(event) => void |
A node was long-pressed, right-clicked or chosen with the context menu key: show a menu of things to do with it at (x, y). With this callback or a node-context listener, the press is yours: it doesn’t open the node, and the browser’s own menu stays closed. |
RendererOptions.onNodeContext |
onSpinSettle? |
(planet) => void |
Called when a flicked orbit comes to rest, with the planet nearest the top. | RendererOptions.onSpinSettle |
onViewModeChange? |
(mode) => void |
- | RendererOptions.onViewModeChange |
orbitAnimation? |
boolean |
Keep the orbit turning slowly on its own. | RendererOptions.orbitAnimation |
orbitSpeed? |
number |
Seconds per revolution of orbitAnimation. |
RendererOptions.orbitSpeed |
palette? |
string[] |
Node colors: the first for the root, then one per top-level branch (cycling). Default: the theme’s. | RendererOptions.palette |
selector? |
string |
- | - |
showActionButtons? |
boolean |
Buttons under the focused node for its note, media, link and actions. Default true. | RendererOptions.showActionButtons |
showControls? |
boolean |
Breadcrumbs, the view switch, the list button and zoom buttons. Default true. | RendererOptions.showControls |
showDetailSheet? |
boolean |
Open the built-in detail sheet for notes and media. Default true. | RendererOptions.showDetailSheet |
showRings? |
boolean |
Draw the dashed orbit rings. Default true. | RendererOptions.showRings |
spin? |
OrbitSpinOptions |
How a flicked orbit spins. | RendererOptions.spin |
statuses? |
Record<string, OrbitStatusStyle> |
Status words and how they look: a dot tone (active, done, blocked, todo, neutral) or any CSS color, as in { review: 'active', 'on hold': '#A855F7' }. |
RendererOptions.statuses |
strict? |
boolean |
- | - |
theme? |
| OrbitThemePreset | OrbitRendererTheme | string & object |
A theme name ('night', 'cosmos', or one registered with registerTheme) or a theme object. An object without a preset keeps the document’s theme and changes the tokens it names. |
RendererOptions.theme |
transitionDuration? |
number | "auto" |
Navigation flight length in milliseconds, or auto to scale with the distance travelled. |
RendererOptions.transitionDuration |
viewMode? |
ViewMode |
The first view: focus (default) or all, the overview. |
RendererOptions.viewMode |
zoom? |
OrbitZoomOptions |
How the wheel, trackpads and pinches zoom. | RendererOptions.zoom |
CreateOrbitMapOptions
How a map looks and behaves. Every option is optional; options passed to the renderer win over the document’s frontmatter.
Extends
Properties
| Property | Type | Description | Inherited from |
|---|---|---|---|
actions? |
OrbitAction[] |
Your own buttons under the focused node and in its detail sheet, before the registered ones. | RendererOptions.actions |
ariaLabel? |
string |
The map’s accessible name. Default: the document’s title. |
RendererOptions.ariaLabel |
baseUrl? |
string |
Resolves relative image, video and link URLs. | RendererOptions.baseUrl |
editable? |
boolean |
Build the map on the map: a + in the orbit adds an idea, typed right in its new planet, and a long press, a right click or F2 edits a node’s text where it is. Default false. | RendererOptions.editable |
focus? |
string |
The node in focus when the map first draws, by id: to open a map where the reader left it. Default: the root. Later renders keep the reader’s place. | RendererOptions.focus |
interactive? |
boolean |
false draws a still picture: no clicks, drags, zoom or keyboard. Default true. |
RendererOptions.interactive |
longPressDelay? |
number |
How long (ms) a finger or pen holds still on a node before it counts as a long press (see onNodeContext). Default 500; apps can pass their platform’s own, such as Android’s 400. |
RendererOptions.longPressDelay |
maxDepth? |
number |
Levels below the root to render (1 = root + direct children). | RendererOptions.maxDepth |
nodeTypes? |
Record<string, OrbitNodeType> |
Node types by name: what nodes with type: name look like, draw inside them, show in the detail sheet and offer as actions. They come before the ones registered with registerNodeType. |
RendererOptions.nodeTypes |
noteRenderer? |
(note, context) => string |
Renders a note to HTML yourself. The HTML is used as-is: sanitize untrusted notes. | RendererOptions.noteRenderer |
onAction? |
(event) => false | void |
A button was pressed. Return false to skip what it does (the detail sheet, the link, or your action’s run). |
RendererOptions.onAction |
onEdit? |
(edit) => void |
The map was edited with addNode, updateNode, removeNode or moveNode; save renderer.toMarkdown() to keep it. |
RendererOptions.onEdit |
onEditorClose? |
(event) => void |
The field for typing on the map closed. | RendererOptions.onEditorClose |
onEditorOpen? |
(event) => void |
The field for typing on the map opened. | RendererOptions.onEditorOpen |
onFocusChange? |
(node) => void |
A new node is in focus. | RendererOptions.onFocusChange |
onNodeClick? |
(node) => void |
A node was clicked or activated with the keyboard, before the map reacts. | RendererOptions.onNodeClick |
onNodeContext? |
(event) => void |
A node was long-pressed, right-clicked or chosen with the context menu key: show a menu of things to do with it at (x, y). With this callback or a node-context listener, the press is yours: it doesn’t open the node, and the browser’s own menu stays closed. |
RendererOptions.onNodeContext |
onSpinSettle? |
(planet) => void |
Called when a flicked orbit comes to rest, with the planet nearest the top. | RendererOptions.onSpinSettle |
onViewModeChange? |
(mode) => void |
- | RendererOptions.onViewModeChange |
orbitAnimation? |
boolean |
Keep the orbit turning slowly on its own. | RendererOptions.orbitAnimation |
orbitSpeed? |
number |
Seconds per revolution of orbitAnimation. |
RendererOptions.orbitSpeed |
palette? |
string[] |
Node colors: the first for the root, then one per top-level branch (cycling). Default: the theme’s. | RendererOptions.palette |
showActionButtons? |
boolean |
Buttons under the focused node for its note, media, link and actions. Default true. | RendererOptions.showActionButtons |
showControls? |
boolean |
Breadcrumbs, the view switch, the list button and zoom buttons. Default true. | RendererOptions.showControls |
showDetailSheet? |
boolean |
Open the built-in detail sheet for notes and media. Default true. | RendererOptions.showDetailSheet |
showRings? |
boolean |
Draw the dashed orbit rings. Default true. | RendererOptions.showRings |
spin? |
OrbitSpinOptions |
How a flicked orbit spins. | RendererOptions.spin |
statuses? |
Record<string, OrbitStatusStyle> |
Status words and how they look: a dot tone (active, done, blocked, todo, neutral) or any CSS color, as in { review: 'active', 'on hold': '#A855F7' }. |
RendererOptions.statuses |
strict? |
boolean |
Throw on the first problem in the source instead of working around it. | - |
theme? |
| OrbitThemePreset | OrbitRendererTheme | string & object |
A theme name ('night', 'cosmos', or one registered with registerTheme) or a theme object. An object without a preset keeps the document’s theme and changes the tokens it names. |
RendererOptions.theme |
transitionDuration? |
number | "auto" |
Navigation flight length in milliseconds, or auto to scale with the distance travelled. |
RendererOptions.transitionDuration |
viewMode? |
ViewMode |
The first view: focus (default) or all, the overview. |
RendererOptions.viewMode |
zoom? |
OrbitZoomOptions |
How the wheel, trackpads and pinches zoom. | RendererOptions.zoom |
OrbitAction
A button under the focused node and in its detail sheet.
Properties
OrbitActionDetail
The action event: call preventDefault() to skip what the button does (the detail sheet, the link, or your action’s run).
Extends
Properties
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
action |
public |
string & object | OrbitContentAction |
One of Orbit’s buttons, or the id of one of your actions. |
OrbitActionEvent.action |
defaultPrevented |
readonly |
boolean |
- | - |
node |
public |
OrbitNode |
- | OrbitActionEvent.node |
sourceEvent |
public |
MouseEvent | KeyboardEvent |
- | OrbitActionEvent.sourceEvent |
Methods
preventDefault()
preventDefault(): void;Returns
void
OrbitActionEvent
A button pressed under the focused node or in its detail sheet.
Extended by
Properties
| Property | Type | Description |
|---|---|---|
action |
string & object | OrbitContentAction |
One of Orbit’s buttons, or the id of one of your actions. |
node |
OrbitNode |
- |
sourceEvent |
MouseEvent | KeyboardEvent |
- |
OrbitDiagnostic
Properties
| Property | Type | Description |
|---|---|---|
code |
| "empty-document" | "no-structure" | "synthetic-root" | "invalid-frontmatter" | "unknown-frontmatter-key" | "unsupported-schema-version" | "invalid-attributes" | "unknown-attribute" | "invalid-option-value" | "media-missing-source" | "unknown-content-type" | "caption-without-media" | "unknown-link-target" | "invalid-yaml" | "unknown-yaml-key" | "ignored-node-entry" |
- |
line? |
number |
1-based line in the source passed to the parser, when known. |
message |
string |
- |
severity |
OrbitDiagnosticSeverity |
- |
OrbitDocument
A parsed map: its tree, its options and the problems the parser worked around.
Properties
| Property | Type | Description |
|---|---|---|
diagnostics? |
OrbitDiagnostic[] |
The same problems with a code, line and severity. Always set on parse results. |
options |
OrbitDocumentOptions |
- |
root |
OrbitNode |
- |
warnings |
string[] |
Problems the parser recovered from, one line each (“Line 4: …”). |
OrbitDocumentOptions
Options a document sets in its frontmatter (markdown) or top-level keys (YAML).
Properties
| Property | Type | Description |
|---|---|---|
baseUrl? |
string |
- |
className? |
string |
- |
height? |
number |
Height in pixels, used by <orbit-map>, marked placeholders and the CLI. |
interactive? |
boolean |
- |
maxDepth? |
number |
- |
orbitAnimation? |
boolean |
Written animation: in the document. |
orbitSpeed? |
number |
Written speed: in the document: seconds per turn of the orbit’s drift. |
palette? |
string[] |
- |
schemaVersion? |
number |
The format version the document is written for. |
showRings? |
boolean |
- |
theme? |
string |
A theme name, as written (unknown names are reported and ignored). |
title? |
string |
The map’s accessible name and SVG title. |
viewMode? |
ViewMode |
Written view: in the document. |
OrbitEdit
An edit to the map, as the edit event and onEdit report it.
Properties
| Property | Type | Description |
|---|---|---|
kind |
"remove" | "add" | "update" | "move" |
- |
node |
OrbitNode |
The node added, changed, removed or moved. |
tree |
OrbitNode |
The whole tree after the edit. renderer.toMarkdown() writes it as orbit-md. |
OrbitEditorEvent
The field for typing a node’s text on the map (see editable, editNode and editNewNode).
Properties
| Property | Type | Description |
|---|---|---|
node |
OrbitNode | null |
The node whose text is typed, or null for a new idea. |
parent |
OrbitNode | null |
For a new idea, the node it goes under. |
OrbitEventMap
What a map reports, by event name. Listen with renderer.on(name, listener),
or for orbit-<name> DOM events, which bubble from the map’s container
(and out of <orbit-map>).
Properties
| Property | Type | Description |
|---|---|---|
action |
OrbitActionDetail |
A content button under the focused node was pressed. |
edit |
OrbitEdit |
The map was edited with addNode, updateNode, removeNode or moveNode. |
editor-close |
OrbitEditorEvent |
The field for typing on the map closed. |
editor-open |
OrbitEditorEvent |
The field for typing on the map opened: on a node, or in the orbit for a new idea. |
focus-change |
object |
The focused node changed. path runs from the root to node. |
focus-change.node |
OrbitNode |
- |
focus-change.path |
OrbitNode[] |
- |
node-click |
object |
A node was clicked or activated with the keyboard, before the map reacts. |
node-click.node |
OrbitNode |
- |
node-context |
OrbitNodeContextEvent |
A node was long-pressed, right-clicked, or chosen with the context menu key: the place for a menu of things to do with it. A DOM listener calls preventDefault() to take the press (see onNodeContext). |
spin-settle |
object |
A spun orbit came to rest, with this planet on top. |
spin-settle.planet |
OrbitNode |
- |
view-mode-change |
object |
The map switched between focus mode and the overview. |
view-mode-change.mode |
ViewMode |
- |
OrbitMapElement
The <orbit-map> element’s API, for code that holds a reference to one.
It also dispatches the map’s events (orbit-focus-change,
orbit-view-mode-change, orbit-node-click, orbit-action,
orbit-spin-settle) and orbit-error.
Extends
HTMLElement
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
renderer |
readonly |
OrbitSVGRenderer | null |
The renderer drawing the map, or null before the first render or after an error. |
source |
public |
string |
The markdown or YAML the map is drawn from. Setting it updates the source attribute. |
Methods
flyTo()
flyTo(nodeId): boolean;Flies to a node by id, in focus mode. Returns false when the map has no such node.
Parameters
| Parameter | Type |
|---|---|
nodeId |
string |
Returns
boolean
overview()
overview(): void;Flies out to the overview of the whole map.
Returns
void
refresh()
refresh(): void;Re-reads the source and redraws the map, keeping the reader’s place when it can.
Returns
void
OrbitNode
One node of a map, as the parsers produce it.
Properties
| Property | Type | Description |
|---|---|---|
attrs? |
Record<string, unknown> |
Attributes Orbit doesn’t use itself, kept for your own code (<!-- orbit owner: Ana -->). |
children |
OrbitNode[] |
- |
collapsed? |
boolean |
Hide the node’s children until it is opened. |
color? |
string |
Any CSS color. Without one, the node takes its branch’s color from the theme or palette. |
embed? |
object |
A page shown in a frame in the detail sheet. |
embed.caption? |
string |
- |
embed.src |
string |
- |
icon? |
string |
An emoji (or any short symbol) shown before the text. |
id |
string |
Unique within the map: a slug of the text (Product roadmap → product-roadmap), or the id attribute. |
image? |
object |
A picture shown inside the node and in the detail sheet. |
image.alt? |
string |
- |
image.caption? |
string |
- |
image.src |
string |
- |
level |
number |
Depth in the tree: 0 for the root. |
link? |
string |
A URL the node links to, offered as a button when the node is in focus. #id links to another node of the map: the button flies there. |
note? |
string |
Longer text, shown in the detail sheet: markdown unless noteFormat is plain. |
noteFormat? |
"markdown" | "plain" |
- |
parent? |
OrbitNode |
The parent node. Set by the parsers as a non-enumerable property, so trees stay JSON-serializable. |
priority? |
number |
- |
source? |
object |
Where the node comes from in a markdown source. |
source.line |
number |
- |
source.raw |
string |
- |
status? |
string |
Free text. Some words get a colored dot: active (also doing, in progress), done (complete, shipped), blocked (stuck, at risk), todo (planned, next). |
tags? |
string[] |
- |
text |
string |
The node’s label, without its icon. |
type? |
string |
The node’s type, such as milestone. A type defined in the nodeTypes option or with registerNodeType sets its look, content and actions. |
video? |
object |
A video (YouTube, Vimeo or a file) played in the detail sheet. |
video.caption? |
string |
- |
video.provider? |
"youtube" | "vimeo" | "native" |
- |
video.src |
string |
- |
video.thumbnail? |
string |
- |
OrbitNodeContextEvent
A long press, right click or context menu key on a node.
Properties
| Property | Type | Description |
|---|---|---|
node |
OrbitNode |
- |
x |
number |
Where, in CSS pixels from the map’s top left corner: the press, or the node’s center for the keyboard. |
y |
number |
- |
OrbitNodeType
How nodes of one type look and behave. Nodes pick a type with type: name.
Properties
| Property | Type | Description |
|---|---|---|
actions? |
OrbitAction[] |
Actions only nodes of this type offer, after the map’s own. |
color? |
string |
The color these nodes get unless they set their own; their children take shades of it. |
details? |
(node, element) => void |
Adds a section to the detail sheet, above the note; the node gets a “Details” button. |
icon? |
string |
The icon these nodes get unless they set their own. |
label? |
string |
The type’s name for people, shown in the detail sheet and the tooltip: 'Milestone'. |
render? |
(node, element) => void | (() => void) |
Draws inside the node, the way a picture does: element is a 100 × 100 px box clipped to the node’s circle and scaled with it, and the label moves outside. Return a function to clean up when the node leaves the map. |
tokens? |
Partial<Record< | "font-family" | "label-font" | "display-font" | "label-weight" | "display-weight" | "label-letter-spacing" | "label-shadow" | "surface" | "surface-pattern" | "text" | "muted-text" | "root-text" | "node-text" | "node-text-inverse" | "color-root" | "color-1" | "color-2" | "color-3" | "color-4" | "color-5" | "color-6" | "color-7" | "shade-light" | "shade-dark" | "node-fill-opacity" | "moon-opacity" | "node-highlight" | "node-terminator" | "node-shading" | "node-stroke" | "node-stroke-tint" | "node-stroke-width" | "badge-stroke" | "node-shadow" | "node-shadow-tint" | "node-shadow-opacity" | "node-shadow-offset" | "node-shadow-size" | "sun-shadow-opacity" | "sun-shadow-size" | "sun-halo" | "sun-halo-tint" | "sun-halo-opacity" | "sun-halo-width" | "sun-halo-dash" | "sun-halo-size" | "ring-stroke" | "ring-tint" | "ring-opacity" | "ring-width" | "ring-dash" | "link-stroke" | "link-tint" | "link-opacity" | "link-width" | "link-dash" | "focus-ring" | "note-indicator" | "control-background" | "control-border" | "control-text" | "control-muted-text" | "control-active-background" | "control-active-text" | "control-shadow" | "control-blur" | "tooltip-background" | "tooltip-text" | "action-background" | "action-border" | "action-text" | "action-shadow" | "sheet-background" | "sheet-text" | "sheet-muted-text" | "sheet-border" | "sheet-backdrop" | "sheet-shadow" | "sheet-blur" | "chip-background" | "chip-text" | "link-text" | "status-active" | "status-done" | "status-blocked" | "status-todo" | "status-neutral" | "error-background" | "error-border" | "error-text", string>> |
Theme tokens for these nodes only, without --orbit-: their rim, shadow, glow, label and status colors, such as { 'node-stroke': '#B45309', 'node-stroke-width': '3' }. |
OrbitRenderErrorDetail
Detail of the orbit-error event dispatched on an element whose map couldn’t be drawn.
Properties
| Property | Type |
|---|---|
diagnostics |
OrbitDiagnostic[] |
error |
Error | null |
line? |
number |
message |
string |
OrbitRendererTheme
A theme with your own values: { preset: 'night', tokens: { surface: '#0b1020', 'ring-dash': 'none' } }.
Each token sets the matching --orbit-* CSS custom property on the map,
so a value the page sets in its own CSS still wins.
Properties
| Property | Type | Description |
|---|---|---|
preset? |
OrbitThemePreset | string & object |
The theme to start from: a built-in one or one registered with registerTheme. Without one, the document’s theme (or paper). |
tokens? |
Partial<Record< | "font-family" | "label-font" | "display-font" | "label-weight" | "display-weight" | "label-letter-spacing" | "label-shadow" | "surface" | "surface-pattern" | "text" | "muted-text" | "root-text" | "node-text" | "node-text-inverse" | "color-root" | "color-1" | "color-2" | "color-3" | "color-4" | "color-5" | "color-6" | "color-7" | "shade-light" | "shade-dark" | "node-fill-opacity" | "moon-opacity" | "node-highlight" | "node-terminator" | "node-shading" | "node-stroke" | "node-stroke-tint" | "node-stroke-width" | "badge-stroke" | "node-shadow" | "node-shadow-tint" | "node-shadow-opacity" | "node-shadow-offset" | "node-shadow-size" | "sun-shadow-opacity" | "sun-shadow-size" | "sun-halo" | "sun-halo-tint" | "sun-halo-opacity" | "sun-halo-width" | "sun-halo-dash" | "sun-halo-size" | "ring-stroke" | "ring-tint" | "ring-opacity" | "ring-width" | "ring-dash" | "link-stroke" | "link-tint" | "link-opacity" | "link-width" | "link-dash" | "focus-ring" | "note-indicator" | "control-background" | "control-border" | "control-text" | "control-muted-text" | "control-active-background" | "control-active-text" | "control-shadow" | "control-blur" | "tooltip-background" | "tooltip-text" | "action-background" | "action-border" | "action-text" | "action-shadow" | "sheet-background" | "sheet-text" | "sheet-muted-text" | "sheet-border" | "sheet-backdrop" | "sheet-shadow" | "sheet-blur" | "chip-background" | "chip-text" | "link-text" | "status-active" | "status-done" | "status-blocked" | "status-todo" | "status-neutral" | "error-background" | "error-border" | "error-text", string>> |
Token values by name, as listed in THEME_TOKENS (surface, color-1, ring-dash, …). |
OrbitSpinOptions
How a flicked orbit spins in focus mode.
Properties
OrbitZoomOptions
How the map responds to the wheel, trackpads and pinches.
Properties
ParseOptions
Properties
| Property | Type | Description |
|---|---|---|
strict? |
boolean |
Throw an OrbitParseError on the first problem instead of recording a diagnostic and carrying on. Off by default; orbit validate turns it on. |
ParseYamlOptions
Properties
| Property | Type | Description |
|---|---|---|
strict? |
boolean |
Throw on the first problem instead of recording a diagnostic. Off by default. |
RendererOptions
How a map looks and behaves. Every option is optional; options passed to the renderer win over the document’s frontmatter.
Extended by
Properties
| Property | Type | Description |
|---|---|---|
actions? |
OrbitAction[] |
Your own buttons under the focused node and in its detail sheet, before the registered ones. |
ariaLabel? |
string |
The map’s accessible name. Default: the document’s title. |
baseUrl? |
string |
Resolves relative image, video and link URLs. |
editable? |
boolean |
Build the map on the map: a + in the orbit adds an idea, typed right in its new planet, and a long press, a right click or F2 edits a node’s text where it is. Default false. |
focus? |
string |
The node in focus when the map first draws, by id: to open a map where the reader left it. Default: the root. Later renders keep the reader’s place. |
interactive? |
boolean |
false draws a still picture: no clicks, drags, zoom or keyboard. Default true. |
longPressDelay? |
number |
How long (ms) a finger or pen holds still on a node before it counts as a long press (see onNodeContext). Default 500; apps can pass their platform’s own, such as Android’s 400. |
maxDepth? |
number |
Levels below the root to render (1 = root + direct children). |
nodeTypes? |
Record<string, OrbitNodeType> |
Node types by name: what nodes with type: name look like, draw inside them, show in the detail sheet and offer as actions. They come before the ones registered with registerNodeType. |
noteRenderer? |
(note, context) => string |
Renders a note to HTML yourself. The HTML is used as-is: sanitize untrusted notes. |
onAction? |
(event) => false | void |
A button was pressed. Return false to skip what it does (the detail sheet, the link, or your action’s run). |
onEdit? |
(edit) => void |
The map was edited with addNode, updateNode, removeNode or moveNode; save renderer.toMarkdown() to keep it. |
onEditorClose? |
(event) => void |
The field for typing on the map closed. |
onEditorOpen? |
(event) => void |
The field for typing on the map opened. |
onFocusChange? |
(node) => void |
A new node is in focus. |
onNodeClick? |
(node) => void |
A node was clicked or activated with the keyboard, before the map reacts. |
onNodeContext? |
(event) => void |
A node was long-pressed, right-clicked or chosen with the context menu key: show a menu of things to do with it at (x, y). With this callback or a node-context listener, the press is yours: it doesn’t open the node, and the browser’s own menu stays closed. |
onSpinSettle? |
(planet) => void |
Called when a flicked orbit comes to rest, with the planet nearest the top. |
onViewModeChange? |
(mode) => void |
- |
orbitAnimation? |
boolean |
Keep the orbit turning slowly on its own. |
orbitSpeed? |
number |
Seconds per revolution of orbitAnimation. |
palette? |
string[] |
Node colors: the first for the root, then one per top-level branch (cycling). Default: the theme’s. |
showActionButtons? |
boolean |
Buttons under the focused node for its note, media, link and actions. Default true. |
showControls? |
boolean |
Breadcrumbs, the view switch, the list button and zoom buttons. Default true. |
showDetailSheet? |
boolean |
Open the built-in detail sheet for notes and media. Default true. |
showRings? |
boolean |
Draw the dashed orbit rings. Default true. |
spin? |
OrbitSpinOptions |
How a flicked orbit spins. |
statuses? |
Record<string, OrbitStatusStyle> |
Status words and how they look: a dot tone (active, done, blocked, todo, neutral) or any CSS color, as in { review: 'active', 'on hold': '#A855F7' }. |
theme? |
| OrbitThemePreset | OrbitRendererTheme | string & object |
A theme name ('night', 'cosmos', or one registered with registerTheme) or a theme object. An object without a preset keeps the document’s theme and changes the tokens it names. |
transitionDuration? |
number | "auto" |
Navigation flight length in milliseconds, or auto to scale with the distance travelled. |
viewMode? |
ViewMode |
The first view: focus (default) or all, the overview. |
zoom? |
OrbitZoomOptions |
How the wheel, trackpads and pinches zoom. |
RenderToSVGOptions
Properties
| Property | Type | Description |
|---|---|---|
baseUrl? |
string |
Resolves relative image URLs. |
focus? |
string |
The node at the center in focus mode, by id. Default: the root. |
height? |
number |
Height of the drawing, in pixels. Default 600. |
idPrefix? |
string |
Prefix for the SVG’s ids; give each SVG inlined in one page its own. |
maxDepth? |
number |
- |
nodeTypes? |
Record<string, OrbitNodeType> |
Node types by name, before the registered ones: their icons, colors and tokens. |
palette? |
string[] |
- |
responsive? |
boolean |
Size the SVG to its container (100% wide and tall) instead of in pixels. |
showRings? |
boolean |
- |
statuses? |
Record<string, OrbitStatusStyle> |
Status words and how they look, before the registered ones. |
theme? |
| OrbitThemePreset | OrbitRendererTheme | string & object |
A theme name or an object of theme values. Default: the document’s theme, or paper. |
title? |
string |
The SVG’s title and accessible name. Default: the document’s title, or the root’s text. |
viewMode? |
ViewMode |
focus (default) or all for the overview. |
width? |
number |
Width of the drawing, in pixels. Default 800. |
Type Aliases
OrbitContentAction
type OrbitContentAction = "image" | "video" | "embed" | "note" | "link" | "details";Orbit’s own buttons for a node: its picture, video, embed, note, link, and its type’s details.
OrbitDiagnosticCode
type OrbitDiagnosticCode = typeof DIAGNOSTIC_CODES[number];OrbitDiagnosticSeverity
type OrbitDiagnosticSeverity = "error" | "warning";OrbitEventName
type OrbitEventName = keyof OrbitEventMap;OrbitNodeInput
type OrbitNodeInput = Partial<Pick<OrbitNode,
| "text"
| "icon"
| "color"
| "status"
| "priority"
| "tags"
| "collapsed"
| "link"
| "note"
| "noteFormat"
| "image"
| "video"
| "embed"
| "type"
| "attrs">>;What addNode and updateNode take: a node’s text and attributes.
OrbitStatusStyle
type OrbitStatusStyle = OrbitStatusTone | string & object;How a status word looks: one of the dot tones, or any CSS color.
OrbitStatusTone
type OrbitStatusTone = "active" | "done" | "blocked" | "todo" | "neutral";The colored dots statuses get.
OrbitThemeName
type OrbitThemeName =
| "paper"
| "night"
| "glass"
| "glass-night"
| "cosmos"
| "blueprint"
| "ink"
| "contrast";OrbitThemePreset
type OrbitThemePreset = OrbitThemeName | "auto";A built-in theme, or auto for paper or night following the reader’s light or dark preference.
OrbitThemeToken
type OrbitThemeToken = typeof THEME_TOKENS[number];OrbitThemeTokens
type OrbitThemeTokens = Record<OrbitThemeToken, string>;ViewMode
type ViewMode = "focus" | "all";focus: one node at the center with its children around it. all: the overview of the whole tree.
Variables
DIAGNOSTIC_CODES
const DIAGNOSTIC_CODES: readonly ["empty-document", "no-structure", "synthetic-root", "invalid-frontmatter", "unknown-frontmatter-key", "unsupported-schema-version", "invalid-attributes", "unknown-attribute", "invalid-option-value", "media-missing-source", "unknown-content-type", "caption-without-media", "unknown-link-target", "invalid-yaml", "unknown-yaml-key", "ignored-node-entry"];Every kind of problem the parsers report.
ORBIT_THEME_PRESETS
const ORBIT_THEME_PRESETS: Readonly<Record<OrbitThemeName, Readonly<OrbitThemeTokens>>>;SUPPORTED_SCHEMA_VERSION
const SUPPORTED_SCHEMA_VERSION: 1 = 1;The newest schemaVersion a document may declare. A newer one gets a warning, or an error in strict mode.
THEME_TOKENS
const THEME_TOKENS: readonly ["font-family", "label-font", "display-font", "label-weight", "display-weight", "label-letter-spacing", "label-shadow", "surface", "surface-pattern", "text", "muted-text", "root-text", "node-text", "node-text-inverse", "color-root", "color-1", "color-2", "color-3", "color-4", "color-5", "color-6", "color-7", "shade-light", "shade-dark", "node-fill-opacity", "moon-opacity", "node-highlight", "node-terminator", "node-shading", "node-stroke", "node-stroke-tint", "node-stroke-width", "badge-stroke", "node-shadow", "node-shadow-tint", "node-shadow-opacity", "node-shadow-offset", "node-shadow-size", "sun-shadow-opacity", "sun-shadow-size", "sun-halo", "sun-halo-tint", "sun-halo-opacity", "sun-halo-width", "sun-halo-dash", "sun-halo-size", "ring-stroke", "ring-tint", "ring-opacity", "ring-width", "ring-dash", "link-stroke", "link-tint", "link-opacity", "link-width", "link-dash", "focus-ring", "note-indicator", "control-background", "control-border", "control-text", "control-muted-text", "control-active-background", "control-active-text", "control-shadow", "control-blur", "tooltip-background", "tooltip-text", "action-background", "action-border", "action-text", "action-shadow", "sheet-background", "sheet-text", "sheet-muted-text", "sheet-border", "sheet-backdrop", "sheet-shadow", "sheet-blur", "chip-background", "chip-text", "link-text", "status-active", "status-done", "status-blocked", "status-todo", "status-neutral", "error-background", "error-border", "error-text"];Theme tokens. Each token is a CSS custom property: set --orbit-<token> on
the map or any ancestor to override it. Presets only provide defaults:
internally every token resolves as var(--orbit-<token>, <preset value>).
Functions
createOrbitMap()
function createOrbitMap(
target,
source,
options?
): OrbitSVGRenderer;Draws a map into target in one call: markdown or YAML source, a parsed
document or a node tree. Returns the renderer, to listen for events
(renderer.on('focus-change', …)), draw new versions (renderer.render(source))
and clean up (renderer.destroy()).
The map fills target, so give it a height.
Parameters
| Parameter | Type |
|---|---|
target |
HTMLElement |
source |
string | OrbitNode | OrbitDocument |
options |
CreateOrbitMapOptions |
Returns
Example
import { createOrbitMap } from '@restless-dreams/orbit';
const map = createOrbitMap(document.querySelector('#map')!, '# Launch\n## Research\n## Build', { theme: 'auto' });
map.on('focus-change', ({ node }) => console.log(node.text));defineOrbitMapElement()
function defineOrbitMapElement(tagName?): void;Registers the <orbit-map> element. Write the map as the element’s
content (indent it however you like, <!-- orbit … --> comments included),
inside a <script type="text/orbit"> child, or in a source attribute.
The map renders in a shadow root, so the raw markdown is never displayed,
and it redraws when the content or an attribute changes.
Parameters
| Parameter | Type | Default value |
|---|---|---|
tagName |
string |
'orbit-map' |
Returns
void
Example
<script type="module">
import { defineOrbitMapElement } from '@restless-dreams/orbit';
defineOrbitMapElement();
</script>
<orbit-map height="420" theme="night">
# Launch
## Research <!-- orbit status: active -->
## Build
</orbit-map>documentToRendererOptions()
function documentToRendererOptions(options): RendererOptions;The renderer options a document asks for in its frontmatter (or YAML
top-level keys). title becomes the map’s accessible label. Container
concerns (height, className) are left to the caller.
Parameters
| Parameter | Type |
|---|---|
options |
OrbitDocumentOptions |
Returns
findNodeById()
function findNodeById(root, id): OrbitNode | null;Parameters
| Parameter | Type |
|---|---|
root |
OrbitNode |
id |
string |
Returns
OrbitNode | null
formatDiagnostic()
function formatDiagnostic(diagnostic): string;Parameters
| Parameter | Type |
|---|---|
diagnostic |
OrbitDiagnostic |
Returns
string
getNodePath()
function getNodePath(root, id): OrbitNode[];Parameters
| Parameter | Type |
|---|---|
root |
OrbitNode |
id |
string |
Returns
isOrbitThemePreset()
function isOrbitThemePreset(value): value is OrbitThemePreset;Whether value names a built-in theme: one of the presets or auto.
Parameters
| Parameter | Type |
|---|---|
value |
unknown |
Returns
value is OrbitThemePreset
isThemeName()
function isThemeName(value): value is string;Whether value names a theme: a built-in one, auto, or a registered one.
Parameters
| Parameter | Type |
|---|---|
value |
unknown |
Returns
value is string
parseOrbit()
function parseOrbit(input, options?): OrbitDocument;Parses an orbit document in either flavor. Markdown is the default; a
document is read as YAML when its first line is a top-level YAML key
(nodes:, title:, view:, …), it has a top-level nodes: list, or its
frontmatter says flavor: yaml. A fenced “`orbit block is unwrapped first.
Problems the parser can work around are listed in diagnostics (each with
a code, line, severity and a message that says how to fix it); pass
{ strict: true } to throw an OrbitParseError on the first one instead.
Parameters
| Parameter | Type |
|---|---|
input |
string |
options |
ParseOptions |
Returns
Example
import { parseOrbit } from '@restless-dreams/orbit';
const { root, diagnostics } = parseOrbit('# Launch\n## Research <!-- orbit status: active -->');
for (const problem of diagnostics ?? []) console.warn(`line ${problem.line}: ${problem.message}`);parseOrbitMarkdown()
function parseOrbitMarkdown(input, options?): OrbitDocument;Parameters
| Parameter | Type |
|---|---|
input |
string |
options |
ParseOptions |
Returns
parseOrbitYAML()
function parseOrbitYAML(input, options?): OrbitDocument;Parameters
| Parameter | Type |
|---|---|
input |
string |
options |
ParseYamlOptions |
Returns
registerAction()
function registerAction(action): () => void;Adds an action to every map. Returns a function that removes it again.
Parameters
| Parameter | Type |
|---|---|
action |
OrbitAction |
Returns
() => void
registerNodeType()
function registerNodeType(name, definition): () => void;Defines a node type for every map: nodes with type: name (any case) take
it. Returns a function that removes it again.
Parameters
| Parameter | Type |
|---|---|
name |
string |
definition |
OrbitNodeType |
Returns
() => void
registerStatus()
function registerStatus(word, style): () => void;Gives a status word its look on every map: one of the tones (active,
done, blocked, todo, neutral) or any CSS color. Returns a function
that removes it again.
Parameters
| Parameter | Type |
|---|---|
word |
string |
style |
OrbitStatusStyle |
Returns
() => void
registerTheme()
function registerTheme(name, theme): () => void;Names a theme for every map, so theme: 'brand' works in options, in a
document’s frontmatter and on <orbit-map theme="brand">. It starts from
preset (a built-in theme or another registered one) and sets its own
tokens. Returns a function that removes it again.
Parameters
| Parameter | Type |
|---|---|
name |
string |
theme |
OrbitRendererTheme |
Returns
() => void
renderOrbitElement()
function renderOrbitElement(element, options?): OrbitSVGRenderer | null;Renders an orbit map into the given element. Problems in the document never
throw: parse warnings go to the console, and a map that can’t be drawn is
replaced by an error card and an orbit-error event on the element.
Callers who later detach the element should invoke
OrbitSVGRenderer.unmount(element) to release RAF loops and the
ResizeObserver. The <orbit-map> web component does this automatically.
Parameters
| Parameter | Type |
|---|---|
element |
Element |
options |
AutoRenderOptions |
Returns
OrbitSVGRenderer | null
renderOrbitMarkdownBlocks()
function renderOrbitMarkdownBlocks(root?, options?): OrbitSVGRenderer[];Renders every orbit block under root (default: the whole document). Each
block is independent: one that fails shows its error card and the rest
still render.
Parameters
| Parameter | Type |
|---|---|
root? |
ParentNode |
options? |
AutoRenderOptions |
Returns
renderToSVGString()
function renderToSVGString(input, options?): string;Renders a map to a standalone SVG string, without a browser: for files, the command line, static sites and server rendering. It draws what the renderer shows at rest, with the theme’s colors resolved to plain values and the labels as SVG text.
Parameters
| Parameter | Type |
|---|---|
input |
string | OrbitNode | OrbitDocument |
options |
RenderToSVGOptions |
Returns
string
Example
import { renderToSVGString } from '@restless-dreams/orbit';
const svg = renderToSVGString('# Launch\n## Research\n## Build', { width: 1200, height: 800, theme: 'cosmos' });serializeOrbitMarkdown()
function serializeOrbitMarkdown(doc): string;Parameters
| Parameter | Type |
|---|---|
doc |
OrbitDocument |
Returns
string
serializeOrbitYAML()
function serializeOrbitYAML(doc): string;Parameters
| Parameter | Type |
|---|---|
doc |
OrbitDocument |
Returns
string
themeNames()
function themeNames(): string[];Every theme name: the built-in ones, auto, then the registered ones.
Returns
string[]
themeTokens()
function themeTokens(name): OrbitThemeTokens;Concrete token values for a theme name, built in or registered, e.g. for exports outside a page. auto resolves to paper.
Parameters
| Parameter | Type |
|---|---|
name |
string | undefined |