Studio extension points
The SheetForge.Editor.Studio namespace holds four contracts that mount your own UI in the Data Studio. It also holds four tools that a mounted widget may use.
When to use these contracts
Anything expressible as data belongs in the Core ISheetForgeStudioPlugin vocabulary instead. That vocabulary renders in the browser too. The contracts on this page cover what a description cannot say, and they put no limit on the UI you build.
The contracts are editor-side because they hand back UIElements or touch window state. ISheetSourceProvider is editor-side for the same reason.
For worked examples, see Studio extensions and Authoring surfaces.
Discovery and isolation
TypeCache discovers all four contracts. An implementation needs a parameterless constructor. There is no registration call.
All four contracts are called inside try/catch.
The window itself (DataStudioWindow) is internal.
Contracts
| Type | Kind | Role |
|---|---|---|
IStudioGraphWidget | interface | A domain strip above the record canvas |
StudioGraphContext | sealed class | What a graph widget reads |
IStudioCellEditorProvider | interface | Draws one grid cell for a named type |
StudioCellEditorContext | sealed class | What the cell widget gets |
IStudioInspectorAction | interface | An extra button on the node inspector |
StudioInspectorContext | sealed class | What an inspector action reads and stages |
IStudioPanelProvider | interface | An arbitrary UIToolkit panel in the right-hand pane |
IStudioGraphWidget
IStudioGraphWidget draws a domain strip above the record canvas. Core ships none.
bool AppliesTo(StudioGraphContext)VisualElement Create(StudioGraphContext)
The element is re-created each time the canvas is rebuilt, so hold no state in it. Returning null adds nothing.
StudioGraphContext
StudioGraphContext is read-only. It has no way to stage an edit, because widgets display only. The constructor is internal, and the window assembles the context.
TabandFocusRecordIdname the terminus, the record the canvas is opened on.SheetRecord FocusRecordis null when unresolved.Tables·ReferenceIndex References·CodeRegistries
Retired context axes
Two retired axes remain on StudioGraphContext for signature compatibility. Both are marked [Obsolete].
| Member | Value |
|---|---|
ShapeId | Always "record" |
ModeId | Always empty |
Comparing either one compiles and is never true. The compiler says so instead of leaving a dead branch. Delete the check.
IStudioCellEditorProvider
IStudioCellEditorProvider draws one grid cell for a named type.
string TypeNamematches aCellParserRegistrytype or wrapper name, Ordinal. An empty name opts out.VisualElement CreateEditor(StudioCellEditorContext)returns the widget. Returningnulldeclines that cell, and the built-in widget takes over.
A duplicate claim on the same type name warns and keeps the first found.
StudioCellEditorContext
StudioCellEditorContext is what the cell widget gets. The constructor is internal, and the window assembles the context.
Tab·FieldName·TypeToken TypeCurrentRawTextis the canonical text with staging applied.Action<string> Commitis a one-shot act. It is its own undo step.Action<string> CommitTypingis a keystroke burst. It coalesces per cell.Func<string,IReadOnlyList<string>> ReferenceKeysreturns the same candidate keys the built-in picker offers.
Both commits pass the window's staging gate.
IStudioInspectorAction
IStudioInspectorAction adds an extra button on the node inspector.
string LabelKeyis a Loc key. An unregistered key is shown verbatim. An empty key shows the type name.bool AppliesTo(StudioInspectorContext)void Execute(StudioInspectorContext)
StudioInspectorContext
StudioInspectorContext gives an action three groups of members.
| Group | Members |
|---|---|
| Read | Tab · RecordId · SheetRecord Record · Tables · References · CodeRegistries |
| Mediated mutation | Action<string,string,string,string> StageCell · Action<IReadOnlyList<EdgeCellWrite>> StageCells |
| Services | Action<string,int,string> FocusCell · Action RequestRebuild |
The AuthoringSession is not exposed. An action changes data only through the two staging delegates.
Staging delegates
StageCell takes tab, recordId, field and canonical raw text. The window registers the Undo step, increments the projection's generation counter and stages the logical address.
StageCells does the same for several cells that must change together. It is one native Undo step, all-or-nothing. If any one cell cannot be staged, the session is not touched at all.
Staging failures
A failure is silent on screen either way. Only the gate explains itself.
The gate writes its reason to the console in three cases:
- A read-only source.
- A pipeline already running.
- An xlsx-backed tab, which is a tab read from an xlsx file.
Three other cases do nothing and say nothing:
- An empty list.
- A write missing its tab or field.
- A record key that resolves to no row.
IStudioPanelProvider
IStudioPanelProvider draws an arbitrary UIToolkit panel in the Studio's right-hand pane. It is the escape hatch beside the declarative StudioPanelDescriptor.
string Id·string TitleKeybool AppliesTo(StudioSurfaceContext)VisualElement CreatePanel(StudioSurfaceContext)returns the panel. Returningnulldraws nothing this tick.
The element lives one recompute tick, so it holds no state.
Pair a panel with a declarative one
Register a declarative panel under the same Id. Each host then takes what it can draw:
- The editor prefers the
IStudioPanelProviderpanel. - The browser draws the declarative panel.
The browser draws what the declarative panel can say, and the editor draws your rich panel. Neither host needs a second contract.
Tools for a mounted widget
These four types are not contracts. They are tools a mounted widget may use.
| Type | Kind | Role |
|---|---|---|
StudioPalette | static class | Read-only color, spacing and type values |
StudioTheme | static class | Category tone, safe text and the mono font |
StudioKeyPicker | static class | The key drop-down |
StudioPluginRegistry | static class | The discovery-cache reset |
The tools serve three purposes:
- The window's own read-only skin values let a widget look like it belongs.
- The key drop-down lets a cell widget pick keys the same way the built-in cell does.
- The discovery-cache reset lets your own tests re-discover a probe.
StudioPalette
StudioPalette holds the read-only color, spacing and type values the window itself paints with. A widget you mount matches the window instead of hard-coding hex.
Each slot resolves at read time, so widgets follow the brightness mode and color preset without extra code.
Choosing the values stays internal. That covers presets, brightness and defaults. Widgets follow the palette. They do not repaint it.
StudioPalette members
- 33 color slots:
Canvas·Panel·Band·Chrome·Surface·Chip·Selection·PendingCell·Line·LineSoft·GridLine·LineHover·Text·TextMuted·TextFaint·RefText·OnAccent·Accent·AccentDim·Warning·Danger·Ok·SheetTone·CodeTone·EditedCell·NewRowCell·NewRowLine·DangerChip·DangerPanel·Scrim·Wire·WireDot·GridDot. IsDark.- Spacing:
SectionSpace·RowSpace·RuleHeight·ButtonHeight·PrimaryButtonHeight·GlyphWidth. - Type sizes:
HeadingFontSize·SectionFontSize·CaptionFontSize. FromRgb(uint)·ToHex(uint).
StudioTheme
StudioTheme has four members only. Everything else on this type is internal.
CategoryColor(category)returns the same deterministic tone the window gives that category.Np(text)makes text safe to interpolate into a rich-text label.Mono/ApplyMono(element)carry the mono-font policy.
The mono-font policy is keys, addresses and numbers only. Mono fonts have no CJK glyphs.
StudioKeyPicker
StudioKeyPicker has one member:
Show(Rect screenAnchor, string targetTab, IReadOnlyList<string> candidates, Action<string> picked, string acceptsLabel = null)
It opens the same drop-down the built-in reference cell opens. It is for a cell widget that has to reach a key inside its own notation. It picks one key from the candidates you supply and hands it back.
picked is required. A missing picked throws ArgumentNullException before any window is made.
With no candidates and nothing to offer, it logs instead of opening an empty list.
The window type itself stays internal.
What the key picker leaves out
Four behaviors are the built-in reference cell's own rules. They are not on this facade:
- Creating a record.
- Leaving the cell empty.
- Multi-toggling a list.
- Asking which port receives the pick.
StudioPluginRegistry
StudioPluginRegistry has one public member, InvalidateCache(). It drops the per-reload discovery cache, so a probe your own tests just enabled is found again. PluginRegistry and SourceProviderRegistry offer the same reset.
The discovered lists stay internal. Nothing outside can read or replace what the window will mount.
Next steps
- Studio extensions
Write a graph widget, an inspector action or a cell widget.
- Authoring surfaces
Describe a panel as data, then add a panel provider.
- Canvas and surfaces
The declarative authoring surface types in Core.
- Editor assembly
The rest of the editor-side public types.