Skip to main content

getEditorItems

Factory that returns a fresh array of the default Editor field definitions: a text input plus start, end, and all-day fields. Use it as a starting point when building a custom items list so the built-in fields are preserved without retyping their config.

Usage

getEditorItems(): EditorItem[];

A new array is returned on each call.

Default fields

compkeylabelExtra config
texttextText-
date-time-pickerstartStart datetime: true, config: { buttons: false }
date-time-pickerendEnd datetime: true, config: { buttons: false }
checkboxallDayAll day-

Example

Spread the defaults and append custom fields:

<script lang="ts">
import { Calendar, Editor, getEditorItems, registerEditorItem } from "@wx/svelte-calendar";
import { Comments } from "@wx/svelte-comments";

registerEditorItem("comments", Comments);

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

let api = $state();
</script>

<Calendar bind:this={api} {events} />
{#if api}
<Editor {api} {items} />
{/if}
  • registerEditorItem — bind a Svelte component to a custom comp id.
  • Editor — companion that consumes this items array.
  • Editing — patterns for extending and replacing editor fields.