Vizel API / svelte/src / createVizelComment
Function: createVizelComment()
ts
function createVizelComment(getEditor, options?): CreateVizelCommentResult;Defined in: packages/svelte/src/runes/createVizelComment.svelte.ts:71
Rune for managing document comments and annotations.
Parameters
| Parameter | Type | Description |
|---|---|---|
getEditor | () => Editor | null | undefined | Function that returns the editor instance |
options | VizelCommentOptions | Comment configuration options |
Returns
Comment state and controls
Example
svelte
<script lang="ts">
import { createVizelEditor, createVizelComment } from "@vizel/svelte";
const editor = createVizelEditor({ features: { collaboration: { comments: true } } });
const comment = createVizelComment(() => editor.current, { key: "my-comments" });
</script>
<button onclick={() => comment.addComment("Needs review", "Author")}>
Add Comment
</button>
{#each comment.comments as c}
<div onclick={() => comment.setActiveComment(c.id)}>
{c.text} {c.resolved ? "(resolved)" : ""}
</div>
{/each}