Skip to content
D
Documentation

Ext — Components

reference
4 min readUpdated

Import these from @grafloria/renderer.

Functions

attachCanvasPlugins

ts
function attachCanvasPlugins(
  instance: CanvasPluginHost,
  options: CanvasPluginOptions = {}
): CanvasPlugins

createBackground

Create the background grid inside root, tracking viewport.

ts
function createBackground(
  root: HTMLElement,
  viewport: ViewportController,
  options: BackgroundOptions = {}
): BackgroundHandle

createControls

ts
function createControls(
  root: HTMLElement,
  viewport: ViewportController,
  options: ControlsOptions = {}
): ControlsHandle

createMiniMap

ts
function createMiniMap(
  root: HTMLElement,
  viewport: ViewportController,
  getModel: () => DiagramModel,
  options: MiniMapOptions = {}
): MiniMapHandle

Constants

BACKGROUND_LAYER_CLASS

ts
const BACKGROUND_LAYER_CLASS: "grafloria-background-layer"

Interfaces

BackgroundHandle

ts
interface BackgroundHandle

Properties

NameTypeDefaultDescription
elementSVGSVGElement

Members

  • update(options: Partial<BackgroundOptions>): void — Change any option; re-renders immediately.
  • setVisible(visible: boolean): void — Show/hide without tearing down (this is what gridEnabled drives).
  • isVisible(): boolean
  • dispose(): void

BackgroundOptions

ts
interface BackgroundOptions

Properties

NameTypeDefaultDescription
variant?BackgroundVariantPattern style. Default 'dots'.
gap?numberGrid spacing in WORLD units. Default 20.
size?numberDot radius / line thickness in CSS px. Default 1 (dots) or 1 (lines).
color?stringPattern colour. Default a theme-neutral grey.
backgroundColor?stringPage colour painted under the pattern. Default transparent.
majorEvery?numberDraw a heavier line every N cells (graph-paper look). 0 = off (default). Only meaningful for 'lines' / 'cross'.
majorColor?stringColour of the major lines. Defaults to color at higher opacity.
minZoom?numberHide the grid below this zoom, so it does not turn into visual mud when you zoom way out. Default 0.25. Set 0 to always draw.
idSuffix?stringUnique-ish suffix for the pattern id, when several diagrams share a page.

CanvasPluginHost

The structural surface the plugins actually need. DiagramInstance satisfies it; so does any framework canvas that keeps a live ViewportController (the Angular wrapper builds exactly this adapter).

ts
interface CanvasPluginHost

Properties

NameTypeDefaultDescription
containerHTMLElement
viewportDiagramInstance['viewport']

Members

  • getModel(): DiagramModel
  • getEngine(): DiagramEngine
  • fitView(padding?: number): void

CanvasPluginOptions

ts
interface CanvasPluginOptions

Properties

NameTypeDefaultDescription
background?boolean | BackgroundOptionsBackground grid. true = defaults; an object = options; omitted/false = off. When the engine's gridEnabled flag is present it OVERRIDES visibility.
minimap?boolean | MiniMapOptionsMiniMap. Visibility is additionally gated by the store's showMinimap.
controls?boolean | ControlsOptionsZoom/fit/lock toolbar.
bindToStore?booleanHonour DiagramStore.gridEnabled / showMinimap and keep them in sync. Default true — this is what makes the flags real. Turn it off if you want the component visibility to be purely declarative.

CanvasPlugins

ts
interface CanvasPlugins

Properties

NameTypeDefaultDescription
background?BackgroundHandle
minimap?MiniMapHandle
controls?ControlsHandle
disposeDisposer

ControlsHandle

ts
interface ControlsHandle

Properties

NameTypeDefaultDescription
portalPortal
elementHTMLElement

Members

  • setVisible(visible: boolean): void
  • isVisible(): boolean
  • setLocked(locked: boolean): void — Reflect a lock state changed elsewhere (keeps aria-pressed honest).
  • dispose(): void

ControlsOptions

ts
interface ControlsOptions

Properties

NameTypeDefaultDescription
placement?PortalPlacement
offset?number
showZoom?booleanWhich buttons to show. Default: all except lock.
showFitView?boolean
showLock?boolean
orientation?'vertical' | 'horizontal'Lay the buttons out horizontally instead of vertically.
zoomStep?numberZoom step per click (multiplicative). Default 1.2.
onFitView?()Called when "fit view" is pressed. Wire this to instance.fitView().
onToggleLock?(locked: boolean)Called when the lock is toggled. Return/ignore as you like.
locked?booleanInitial lock state.

MiniMapHandle

ts
interface MiniMapHandle

Properties

NameTypeDefaultDescription
portalPortal
elementSVGSVGElement

Members

  • refresh(): void — Rebuild the node layer (call when the model changed).
  • setVisible(visible: boolean): void
  • isVisible(): boolean
  • update(options: Partial<MiniMapOptions>): void
  • dispose(): void

MiniMapOptions

ts
interface MiniMapOptions

Properties

NameTypeDefaultDescription
placement?PortalPlacement
offset?number
width?number
height?number
padding?numberPadding (world units) around the content in the minimap's viewBox.
nodeColor?string | ((node: NodeModel)Node fill. A function lets you colour-code by type/state.
maskColor?stringFill of the camera rectangle.
maskStroke?stringStroke of the camera rectangle.
panelBackground?string
panelBorder?string
interactive?booleanAllow click/drag-to-pan and wheel-to-zoom. Default true.
showLinks?booleanDraw links too. Default false (nodes carry the shape of a diagram).
linkColor?string
ariaLabel?stringARIA label on the panel.

Types

BackgroundVariant

ts
type BackgroundVariant = 'dots' | 'lines' | 'cross' | 'none';

Was this page helpful?