Skip to content

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

ParameterTypeDescription
getEditor() => Editor | null | undefinedFunction that returns the editor instance
optionsVizelCommentOptionsComment configuration options

Returns

CreateVizelCommentResult

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}

Released under the MIT License.