ILayoutEngine Interface#
Manages the spatial arrangement of cells within a notebook. Layout engines support different paradigms such as linear (top-to-bottom), grid, or freeform canvas layouts.
public interface ILayoutEngine : Verso.Abstractions.IExtension
Implements IExtension
Properties#
Capabilities Property#
Declares the capabilities of this layout engine (e.g. drag-and-drop, resizing, nesting).
Verso.Abstractions.LayoutCapabilities Capabilities { get; }
Property Value#
DisplayName Property#
Human-readable name shown in the layout picker.
string DisplayName { get; }
Property Value#
Icon Property#
Optional icon name or path representing this layout style.
string? Icon { get; }
Property Value#
LayoutId Property#
Unique identifier for this layout engine (e.g. "linear", "grid", "freeform").
string LayoutId { get; }
Property Value#
RendererIsolation Property#
Indicates how the layout's renderer relates to the host's UI execution context. Defaults to Inline. Layouts that need a private execution context should return Isolated and ship a renderer module via GetRendererPackageAsync(IVersoContext).
Verso.Abstractions.LayoutRendererIsolation RendererIsolation { get; }
Property Value#
RequiresCustomRenderer Property#
Indicates whether this layout requires a custom renderer (e.g. a webview panel) instead of the standard notebook cell-by-cell rendering.
bool RequiresCustomRenderer { get; }
Property Value#
SupportedVisibilityStates Property#
Declares the set of CellVisibilityState values this layout handles.
The properties panel uses this to present only the states the layout supports.
Defaults to { Visible } (no filtering).
System.Collections.Generic.IReadOnlySet<Verso.Abstractions.CellVisibilityState> SupportedVisibilityStates { get; }
Property Value#
System.Collections.Generic.IReadOnlySet<CellVisibilityState>
SupportsPropertiesPanel Property#
Indicates whether this layout supports the cell properties panel in the sidebar.
Defaults to false.
bool SupportsPropertiesPanel { get; }
Property Value#
Methods#
ApplyLayoutMetadata(Dictionary<string,object>, IVersoContext) Method#
Restores layout state from previously persisted metadata.
System.Threading.Tasks.Task ApplyLayoutMetadata(System.Collections.Generic.Dictionary<string,object> metadata, Verso.Abstractions.IVersoContext context);
Parameters#
metadata System.Collections.Generic.Dictionary<System.String,System.Object>
The metadata dictionary previously returned by GetLayoutMetadata().
context IVersoContext
Verso context providing theme, dimensions, and services.
Returns#
System.Threading.Tasks.Task
A task that completes when the layout state has been restored.
GetCellContainerAsync(Guid, IVersoContext) Method#
Returns container information for a specific cell, describing its position and bounds within the layout.
System.Threading.Tasks.Task<Verso.Abstractions.CellContainerInfo> GetCellContainerAsync(System.Guid cellId, Verso.Abstractions.IVersoContext context);
Parameters#
cellId System.Guid
The unique identifier of the cell.
context IVersoContext
Verso context providing theme, dimensions, and services.
Returns#
System.Threading.Tasks.Task<CellContainerInfo>
Container information describing the cell's placement in the layout.
GetLayoutMetadata() Method#
Returns layout-specific metadata (e.g. grid dimensions, cell positions) for persistence.
System.Collections.Generic.Dictionary<string,object> GetLayoutMetadata();
Returns#
System.Collections.Generic.Dictionary<System.String,System.Object>
A dictionary of metadata key-value pairs describing the current layout state.
GetRendererPackageAsync(IVersoContext) Method#
Returns the package required to instantiate the layout's renderer in the client.
Only consulted when RendererIsolation is
Isolated; returning null signals that no
package is available, in which case the host falls back to its default rendering path.
System.Threading.Tasks.Task<Verso.Abstractions.LayoutRendererPackage?> GetRendererPackageAsync(Verso.Abstractions.IVersoContext context);
Parameters#
context IVersoContext
Returns#
System.Threading.Tasks.Task<LayoutRendererPackage>
GetStaticAssetsAsync(IVersoContext, LayoutHostCapabilities) Method#
Returns the layout-scoped static assets (CSS today; future content types as the host adds them) that the host should load whenever this layout is active. The engine receives the host's LayoutHostCapabilities and is expected to return only assets whose content type the host advertised; the host filters defensively on receipt.
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Verso.Abstractions.LayoutStaticAsset>?> GetStaticAssetsAsync(Verso.Abstractions.IVersoContext context, Verso.Abstractions.LayoutHostCapabilities hostCapabilities);
Parameters#
context IVersoContext
Verso context providing theme, dimensions, and services.
hostCapabilities LayoutHostCapabilities
Content types the host can consume.
Returns#
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<LayoutStaticAsset>>
The assets to load alongside the layout, or null when the engine has none.
An empty list is treated the same as null.
Remarks#
Targets layouts with RendererIsolation equal to Inline. Isolated layouts continue to carry their assets through Files.
OnCellAddedAsync(Guid, int, IVersoContext) Method#
Notifies the layout engine that a new cell has been added at the specified index.
System.Threading.Tasks.Task OnCellAddedAsync(System.Guid cellId, int index, Verso.Abstractions.IVersoContext context);
Parameters#
cellId System.Guid
The unique identifier of the added cell.
index System.Int32
The zero-based index where the cell was inserted.
context IVersoContext
Verso context providing theme, dimensions, and services.
Returns#
System.Threading.Tasks.Task
A task that completes when the layout has been updated.
OnCellMovedAsync(Guid, int, IVersoContext) Method#
Notifies the layout engine that a cell has been moved to a new index.
System.Threading.Tasks.Task OnCellMovedAsync(System.Guid cellId, int newIndex, Verso.Abstractions.IVersoContext context);
Parameters#
cellId System.Guid
The unique identifier of the moved cell.
newIndex System.Int32
The zero-based destination index.
context IVersoContext
Verso context providing theme, dimensions, and services.
Returns#
System.Threading.Tasks.Task
A task that completes when the layout has been updated.
OnCellRemovedAsync(Guid, IVersoContext) Method#
Notifies the layout engine that a cell has been removed.
System.Threading.Tasks.Task OnCellRemovedAsync(System.Guid cellId, Verso.Abstractions.IVersoContext context);
Parameters#
cellId System.Guid
The unique identifier of the removed cell.
context IVersoContext
Verso context providing theme, dimensions, and services.
Returns#
System.Threading.Tasks.Task
A task that completes when the layout has been updated.
RenderLayoutAsync(IReadOnlyList<CellModel>, IVersoContext) Method#
Renders the full layout for the given cells.
System.Threading.Tasks.Task<Verso.Abstractions.RenderResult> RenderLayoutAsync(System.Collections.Generic.IReadOnlyList<Verso.Abstractions.CellModel> cells, Verso.Abstractions.IVersoContext context);
Parameters#
cells System.Collections.Generic.IReadOnlyList<CellModel>
The ordered list of cell models to arrange.
context IVersoContext
Verso context providing theme, dimensions, and services.
Returns#
System.Threading.Tasks.Task<RenderResult>
A render result containing the complete layout output.