Skip to main content

SynchronousEditor TypeAlias

A synchronous function that executes a string of JavaScript code to perform a tree-agent edit.

This API is provided as an alpha preview and may change without notice.

To use, import via @fluidframework/tree-agent/alpha.

For more information about our API support guarantees, see here.

Signature​

export type SynchronousEditor<TSchema extends ImplicitFieldSchema> = (tree: ViewOrTree<TSchema>, code: string) => void;

Type Parameters​

ParameterConstraintDescription
TSchemaImplicitFieldSchema

Remarks​

The code expects a variable named context to be in scope, which provides access to the tree and utilities for creating and inspecting nodes. A context can be created for a given tree via the createContext(tree) function.

Example​

// A simple editor implementation that runs the provided code via a JavaScript Function.
new Function("context", code)(createContext(tree));

Error Handling​

Any error thrown by the executed code.