Skip to main content

registerEditorItem

Binds a string type to a Svelte component in the global editor registry. Any editor item with comp: type then renders that component. Call once at module load before instantiating any <Editor>.

Usage

registerEditorItem(type: string, handler: Component<any>): void;
ArgumentTypeDescription
typestringIdentifier referenced by editor items via comp
handlerComponent<any>Svelte component to render for that type

Example

Register a third-party field component, then reference it in an editor item:

import { registerEditorItem } from "@svar-ui/svelte-calendar";
import { Comments } from "@wx/svelte-comments";

registerEditorItem("comments", Comments);
<script lang="ts">
import { Editor, getEditorItems } from "@svar-ui/svelte-calendar";

const items = [
...getEditorItems(),
{ comp: "comments", key: "comments", label: "Comments", users, activeUser },
];
</script>

<Editor {api} {items} />

Calling with an existing type id ("text", "date-time-picker", "checkbox") replaces the built-in renderer for every Editor instance in the app.

  • getEditorItems — reuse default fields alongside custom ones.
  • Editor — companion that consumes the registered types.
  • Editing — patterns for extending the editor.