INotebookPanel Interface#
Contributes a panel to the notebook UI, shown alongside the notebook body and toggled from the host's panel controls. Implement this to surface information or actions that belong next to the notebook rather than inside a cell.
public interface INotebookPanel : Verso.Abstractions.IExtension
Implements IExtension
Remarks#
A panel's identity is the (ExtensionId, PanelId) pair, so two extensions
may use the same PanelId without colliding. Registering two panels
with the same pair is an error.
Panels describe their content rather than draw it. RenderAsync(IPanelContext)
returns representations of the same content in preference order, and each host
renders the first one it understands. No host is obliged to support any
particular media type, so a panel that offers only text/html is simply
unavailable on a host that does not render HTML. Offering a plain-text
alternative is the cheapest way to stay useful everywhere.
To respond to user actions in the panel, implement IPanelInteractionHandler on the same class or on a sibling class that shares this PanelId.
Properties#
DisplayName Property#
Human-readable name shown as the panel's title and as the accessible name of its toggle control.
string DisplayName { get; }
Property Value#
Remarks#
A toggle shows an icon at rest, so the name alone may be the first and only thing a reader gets. Hosts show Description beneath it in the toggle's tooltip, which is where to say what the panel contains.
IconMarkup Property#
Optional host-specific icon markup used in place of IconName
by hosts that understand it. An escape hatch for panels that need a custom
icon and accept that other hosts will fall back. Defaults to null.
string? IconMarkup { get; }
Property Value#
IconName Property#
Name of an icon from the host's icon set, which the host maps to whatever
glyph it draws with. Returning null, or a name the host does not
recognize, falls back to IconMarkup and then to
DisplayName.
string? IconName { get; }
Property Value#
Remarks#
The names hosts are expected to recognize are: document, list,
puzzle, braces, gear, search, layout,
compare, info, warning, flag, check,
clock, tag, chart, table, folder, and
link. Hosts that cannot draw a given name fall back rather than fail.
Order Property#
Sort order among the host's panel controls. Lower values appear first. The built-in panels occupy 100 through 500 in steps of 100, so a value between them places a panel among them and a larger value places it after.
int Order { get; }
Property Value#
PanelId Property#
Identifier for this panel, unique within the owning extension (e.g. "findings", "profiler").
string PanelId { get; }
Property Value#
Methods#
IsAvailableAsync(IPanelContext) Method#
Determines whether the panel should be offered at all in the current state.
A panel that returns false is omitted from the host's panel controls,
and is closed if it was open. Called when the host builds its panel list,
which happens on notebook load and whenever the layout or the set of loaded
extensions changes, so implementations should be cheap.
System.Threading.Tasks.Task<bool> IsAvailableAsync(Verso.Abstractions.IPanelContext context);
Parameters#
context IPanelContext
Context providing notebook state and Verso services.
Returns#
System.Threading.Tasks.Task<System.Boolean>
true if the panel should be available; otherwise false.
Remarks#
Availability is not re-evaluated on every cell selection. A panel whose content depends on the selection should stay available and say so in RenderAsync(IPanelContext), which the host does call on selection change.
RenderAsync(IPanelContext) Method#
Produces the panel's content as one or more representations, ordered from richest to simplest. The host renders the first entry whose MimeType it supports and ignores the rest. Returning an empty list renders the panel as empty.
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Verso.Abstractions.RenderResult>> RenderAsync(Verso.Abstractions.IPanelContext context);
Parameters#
context IPanelContext
Context providing notebook state and Verso services.
Returns#
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<RenderResult>>
Representations of the panel's content in preference order.