Contextual editing with the Svelte SDK
Developer preview
This feature is in developer preview. Use with caution as it may change unexpectedly. For more information, contact us.
The SDK provides built-in support for Uniform's visual/contextual editing. When a composition is opened in the Uniform Canvas editor, the SDK automatically:
- Listens for composition update messages from the editor
- Re-renders the component tree with the updated data
- Enables inline editing for
UniformTextandUniformRichTextcomponents - Annotates components with editing attributes for the Canvas UI
getUniformContextualEditing#
For custom contextual editing setups, use getUniformContextualEditing directly:
<script lang="ts">
import { getUniformContextualEditing } from '@uniformdev/canvas-svelte';
const { composition, isContextualEditing } = getUniformContextualEditing({
initialCompositionValue: compositionData,
enhance: (message) => message.composition,
});
</script>
| Return Value | Type | Description |
|---|---|---|
composition | reactive RootComponentInstance | The current composition (updates during editing) |
isContextualEditing | reactive boolean | Whether the app is in contextual editing mode |