Skip to main content

registerEditorItem

Binds a string type to a React 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>React 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/react-calendar";
import { Comments } from "@wx/react-comments";

registerEditorItem("comments", Comments);
import { Editor, getEditorItems } from "@svar-ui/react-calendar";

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

return <Editor api={api} items={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.