defineExtension
functionDefine a LexicalExtension from the given object literal. TypeScript will infer Config and Name in most cases, but you may want to use safeCast for config if there are default fields or varying types.
Import
import { defineExtension } from '@modular/sdk/editor';Notes
- returns
- The unmodified extension argument (this is only an inference helper)
- example
- Basic example ```ts export const MyExtension = defineExtension({ // Extension names must be unique in an editor name: "my", nodes: [MyNode], }); ```
- example
- Extension with optional configuration ```ts export interface ConfigurableConfig { optional?: string; required: number; } export const ConfigurableExtension = defineExtension({ name: "configurable", // The Extension's config must satisfy the full config type, // but using the Extension as a dependency never requires // configuration and any partial of the config can be specified config: safeCast<ConfigurableConfig>({ required: 1 }), }); ```
- __NO_SIDE_EFFECTS__
- lexical-inline
- identity