Skip to content

Vizel API / svelte/src / setVizelContext

Function: setVizelContext()

ts
function setVizelContext(accessor): VizelContextAccessor;

Defined in: packages/svelte/src/components/VizelContext.ts:34

Publish the editor accessor to descendants through Svelte context.

Call this typed wrapper instead of setContext(VIZEL_CONTEXT_KEY, ...) so the key and the VizelContextAccessor value type stay paired at every call site. setVizelContext / getVizelContext are the Svelte context idiom; <Vizel> and <VizelProvider> both publish the editor through this function.

Parameters

ParameterTypeDescription
accessorVizelContextAccessorReactive accessor whose current getter returns the live editor instance, or null before mount.

Returns

VizelContextAccessor

The accessor, so a caller can publish and reuse it in one expression.

Released under the MIT License.