UniverSpreadsheetJsInterop
Interface that provides interoperability with Univer’s spreadsheets and Blazor.
public class UniverSpreadsheetJsInterop : IUniverJsInterop
Remarks
The scoped acts as a bridge between Blazor and Univer spreadsheets via JavaScript interop. It dynamically loads JS libraries, queues actions, and resolves them using JS modules.
Properties
Property | Type | Description |
---|---|---|
moduleTask | Lazy<Task<IJSObjectReference> > | Module to initialize Univer in the component |
actionQueue | Queue<UniverQueueValue> | Action Queue for execution in FacadeAPI for Univer |
Constructor
public UniverSpreadsheetJsInterop(IJSRuntime runtime, IOptions<UniverConfig> options)
Parameter | Type | Description |
---|---|---|
runtime | IJSRuntime | JavaScript runtime from Blazor |
options | IOptions | Configuration options for Univer |
Methods
InitializeAsync
Task<bool> InitializeAsync(string newIdDiv)
Sets all instances of all scripts from Univer according to the version.
Parameter | Type | Description |
---|---|---|
newIdDiv | string | The new Id for the div to execute Univer |
Returns
Task<bool>
— True if initialized correctly
SetAction
IUniverJsInterop SetAction(string action, params object[] args)
Sets an action for the FacadeAPI.
Parameter | Type | Description |
---|---|---|
action | string | Method’s name to execute on the Facade’s API |
args | object[] | Arguments for the method (must be serializable) |
Returns
IUniverJsInterop — Self, for chaining
ResolveAsync
Task ResolveAsync()
Resolves all queued actions through JS interop, throwing if any method cannot be found.
Returns
Task — Completes when queue is processed
ResolveAsync
Task<T> ResolveAsync<T>()
Resolves all queued actions and returns a typed result.
Returns
Task<T>
— Result from JavaScript execution
GetUniverLinks
string[] GetUniverLinks()
Returns all script components required by Univer based on the current config.
Returns
string[] — Array of each Univer library URL to import
ResolveActionAsync
Task<T> ResolveActionAsync<T>(string name, params object[] args)
Executes a direct method call in the JavaScript module and returns a result.
Parameter | Type | Description |
---|---|---|
name | string | Name of the JavaScript function to call |
args | object[] | Arguments to pass to the function |
Returns
Task<T>
— Return value from the JavaScript function
ResolveActionAsync
Task ResolveActionAsync(string name, params object[] args)
Executes a direct JavaScript method that does not return a value.
Parameter | Type | Description |
---|---|---|
name | string | Name of the JavaScript function to call |
args | object[] | Arguments to pass |
Returns
Task — Completes when the JavaScript function finishes