{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "api-core-plate-editor-docs",
  "title": "Plate Editor",
  "description": "API reference for the Plate editor runtime.",
  "files": [
    {
      "path": "../../content/docs/api/core/plate-editor.mdx",
      "content": "---\ntitle: Plate Editor\ndescription: API reference for the Plate editor runtime.\n---\n\n`PlateEditor` is the React editor type returned by `createPlateEditor`, `usePlateEditor`, and `withPlate`. It extends the base Slate editor with plugin registries, typed `api` and `tf` surfaces, DOM state, metadata, and plugin option helpers.\n\n## Ownership\n\n| Surface | Owner | Notes |\n| --- | --- | --- |\n| `PlateEditor` | `@platejs/core/react` | React editor type with Plate plugin APIs, transforms, handlers, renders, and hooks. |\n| `SlateEditor` | `@platejs/core` | Non-React editor type used by server-side and static editor paths. |\n| Slate primitives | `@platejs/slate` | `children`, `selection`, `operations`, core `api`, and core `tf` transforms. |\n| Core plugins | `@platejs/core` | Debugging, HTML parsing, parser pipeline, length, node id, history, input rules, and base paragraph behavior. |\n| React core plugins | `@platejs/core/react` | React extension, DOM integration, event editor, navigation feedback, and React paragraph plugin. |\n\nUse `PlateEditor` when a page or component runs inside React. Use `SlateEditor` when you need the headless editor from `createSlateEditor`.\n\n## Editor Shape\n\nThe editor is still a Slate editor. Plate adds typed plugin access, plugin metadata, DOM state, and option stores on top of that shape.\n\n<API name=\"PlateEditor\">\n<APIAttributes>\n  <APIItem name=\"id\" type=\"string\">\n    Unique editor instance id. `withSlate` uses the provided `id`, an existing editor id, or `nanoid()`.\n  </APIItem>\n  <APIItem name=\"children\" type=\"Value\">\n    Current document value.\n  </APIItem>\n  <APIItem name=\"selection\" type=\"TRange | null\">\n    Current Slate selection.\n  </APIItem>\n  <APIItem name=\"operations\" type=\"Operation[]\">\n    Operations applied since Slate last flushed the editor.\n  </APIItem>\n  <APIItem name=\"api\" type=\"EditorApi & CorePluginApi\">\n    Core Slate APIs plus APIs contributed by resolved Plate plugins.\n  </APIItem>\n  <APIItem name=\"tf\" type=\"EditorTransforms & CorePluginTransforms\">\n    Core Slate transforms plus transforms contributed by resolved Plate plugins.\n  </APIItem>\n  <APIItem name=\"transforms\" type=\"PlateEditor['tf']\">\n    Alias for `tf`.\n  </APIItem>\n  <APIItem name=\"plugins\" type=\"Record<string, AnyEditorPlatePlugin>\">\n    Resolved plugin map keyed by plugin key.\n  </APIItem>\n  <APIItem name=\"dom\" type=\"PlateEditor['dom']\">\n    Runtime DOM state owned by the editor instance.\n  </APIItem>\n  <APIItem name=\"meta\" type=\"PlateEditor['meta']\">\n    Runtime metadata and plugin caches built during plugin resolution.\n  </APIItem>\n</APIAttributes>\n</API>\n\n## Runtime State\n\n`editor.dom` is mutable runtime state. It is updated by React integration, event handlers, focus tracking, and read-only setup.\n\n| Field | Type | Set by |\n| --- | --- | --- |\n| `composing` | `boolean` | Composition handlers. |\n| `currentKeyboardEvent` | `KeyboardEventLike \\| null` | `SlateReactExtensionPlugin` while handling keyboard shortcuts. |\n| `focused` | `boolean` | DOM focus integration. |\n| `prevSelection` | `TRange \\| null` | Selection tracking. |\n| `readOnly` | `boolean` | `withSlate({ readOnly })`, then React read-only state. |\n\n`editor.meta` carries plugin resolution output. Most application code reads this indirectly through helpers like `getPlugin`, `getOptions`, and render utilities.\n\n| Field | Type | Notes |\n| --- | --- | --- |\n| `key` | `string` | Internal editor key. `withSlate` creates one with `nanoid()` when missing. |\n| `uid` | `string \\| undefined` | Stable id used by Plate containers across RSC and client hydration. |\n| `userId` | `string \\| null \\| undefined` | Collaborative identity passed through editor options. |\n| `components` | `NodeComponents` | Resolved node components keyed by plugin key. |\n| `isFallback` | `boolean` | `false` for normal editors. Fallback editors are created by the controller layer. |\n| `pluginList` | `AnyEditorPlatePlugin[]` | Ordered resolved plugin list. |\n| `inputRules` | `ResolvedInputRulesMeta` | Input-rule metadata built by the input-rules plugin. |\n| `shortcuts` | `Shortcuts` | Resolved shortcut metadata. |\n| `pluginCache` | `object` | Precomputed plugin key lists for render hooks, handlers, rules, nodes, decorators, and injection. |\n\n## Plugin Access\n\nUse editor helpers when you need the resolved plugin instance, typed plugin API, typed transforms, or live plugin options.\n\n```tsx title=\"Plugin option access\"\nimport { ParagraphPlugin, useEditorPlugin } from 'platejs/react';\n\nexport function ParagraphType() {\n  const { editor } = useEditorPlugin(ParagraphPlugin);\n\n  return <span>{editor.getType(ParagraphPlugin.key)}</span>;\n}\n```\n\n| Helper | Type | Use it for |\n| --- | --- | --- |\n| `getPlugin(plugin)` | `<C>(plugin: WithRequiredKey<C>) => EditorPlatePlugin<C>` | Read the resolved plugin instance after overrides and configuration. |\n| `getApi(plugin?)` | `<C>(plugin?: WithRequiredKey<C>) => editor.api & InferApi<C>` | Get a typed view of editor APIs. The runtime value is `editor.api`. |\n| `getTransforms(plugin?)` | `<C>(plugin?: WithRequiredKey<C>) => editor.tf & InferTransforms<C>` | Get a typed view of editor transforms. The runtime value is `editor.transforms`. |\n| `getType(pluginKey)` | `(pluginKey: string) => string` | Resolve the node type for a plugin key. |\n| `getInjectProps(plugin)` | `(plugin) => InjectNodeProps` | Read injected node props with default `nodeKey` and `styleKey` filled from the plugin type. |\n| `getOptionsStore(plugin)` | `(plugin) => TStateApi` | Read the plugin option store. |\n| `getOptions(plugin)` | `(plugin) => InferOptions<C>` | Read all current options for a plugin. |\n| `getOption(plugin, key, ...args)` | `(plugin, key, ...args) => value` | Read one option or selector result. Missing stored keys report through `editor.api.debug.error`. |\n| `setOption(plugin, key, value)` | `(plugin, key, value) => void` | Update one option in the plugin store. |\n| `setOptions(plugin, options)` | `(plugin, partialOrRecipe) => void` | Merge a partial object or run a mutative recipe against the plugin state. |\n\n## Initialization\n\n`withPlate` wraps `withSlate` with React defaults. It uses `createZustandStore` for plugin option stores and prepends the React core plugins before user plugins.\n\n```tsx title=\"Create a typed editor\"\nimport { usePlateEditor } from 'platejs/react';\nimport { BoldPlugin } from '@platejs/basic-nodes/react';\n\nexport function useBasicEditor() {\n  return usePlateEditor({\n    plugins: [BoldPlugin],\n    value: [\n      {\n        type: 'p',\n        children: [{ text: 'Bold text is ready.' }],\n      },\n    ],\n  });\n}\n```\n\n`withSlate` does the lower-level setup:\n\n| Step | Behavior |\n| --- | --- |\n| Editor identity | Sets `editor.id`, `editor.meta.key`, `editor.meta.isFallback`, `editor.meta.userId`, and `editor.dom`. |\n| Helper methods | Installs `getApi`, `getTransforms`, `getPlugin`, `getType`, option helpers, and injection helpers. |\n| Core plugins | Resolves core plugins, replaces core plugins with custom plugins that share the same key, and resolves the root plugin. |\n| Components | Merges `components` into root-plugin component overrides. |\n| Normalization guard | Wraps `normalizeNode` so `editor.api.shouldNormalizeNode(entry)` can skip a normalization pass. |\n| Initial value | Calls `editor.tf.init({ value, selection, autoSelect, shouldNormalizeEditor, onReady })` unless `skipInitialization` is `true`. |\n\n`value` accepts a Plate value, an HTML string, or a function that returns the value. `onReady` receives `{ editor, isAsync, value }` after initialization completes.\n\n## Core APIs\n\nThese APIs exist on every Plate editor because core plugins are always resolved before user plugins.\n\n<API name=\"Core plugin APIs\">\n<APIMethods>\n  <APIItem name=\"editor.api.debug.log\" type=\"(message: string, type?: DebugErrorType, details?: any) => void\">\n    Log a debug message when debug logging is enabled.\n  </APIItem>\n  <APIItem name=\"editor.api.debug.info\" type=\"(message: string, type?: DebugErrorType, details?: any) => void\">\n    Log an info message when the configured log level allows it.\n  </APIItem>\n  <APIItem name=\"editor.api.debug.warn\" type=\"(message: string, type?: DebugErrorType, details?: any) => void\">\n    Log a warning when the configured log level allows it.\n  </APIItem>\n  <APIItem name=\"editor.api.debug.error\" type=\"(message: unknown, type?: DebugErrorType, details?: any) => void\">\n    Throw a `PlateError` by default in development. Configure `DebugPlugin` to change logging or `throwErrors`.\n  </APIItem>\n  <APIItem name=\"editor.api.html.deserialize\" type=\"(options: { element: HTMLElement | string; collapseWhiteSpace?: boolean; defaultElementPlugin?: WithRequiredKey }) => Descendant[]\">\n    Deserialize an HTML element into Plate nodes. The HTML parser plugin calls this for `text/html` paste data.\n  </APIItem>\n  <APIItem name=\"editor.api.redecorate\" type=\"() => void\">\n    Trigger decoration refresh. The React extension warns through `editor.api.debug.warn` until an integration overrides it.\n  </APIItem>\n  <APIItem name=\"editor.api.navigation.activeTarget\" type=\"() => NavigationFeedbackTarget | null\">\n    Read the current navigation feedback target and clear it if the stored target no longer resolves.\n  </APIItem>\n  <APIItem name=\"editor.api.navigation.clear\" type=\"() => void\">\n    Clear the current navigation feedback target.\n  </APIItem>\n  <APIItem name=\"editor.api.navigation.isTarget\" type=\"(path: Path) => boolean\">\n    Check whether a path matches the active navigation feedback target.\n  </APIItem>\n</APIMethods>\n</API>\n\n## Core Transforms\n\nCore transforms live on `editor.tf` and `editor.transforms`. Plugin docs normally show the plugin-specific transform names, but the editor always includes these runtime transforms.\n\n<API name=\"Core transforms\">\n<APITransforms>\n  <APIItem name=\"editor.tf.init\" type=\"(options: InitOptions) => void\">\n    Initialize value, selection, optional normalization, optional auto-selection, and `onReady`.\n  </APIItem>\n  <APIItem name=\"editor.tf.insertExitBreak\" type=\"(options?: InsertExitBreakOptions) => boolean | undefined\">\n    Insert an exit break for plugins that route to the core exit-break transform.\n  </APIItem>\n  <APIItem name=\"editor.tf.liftBlock\" type=\"(options?: LiftBlockOptions) => boolean | undefined\">\n    Lift the selected block through Plate's block transform wrapper.\n  </APIItem>\n  <APIItem name=\"editor.tf.resetBlock\" type=\"(options?: { at?: Path }) => boolean | undefined\">\n    Reset the selected block to the requested type or default block type.\n  </APIItem>\n  <APIItem name=\"editor.tf.setValue\" type=\"(value?: Value | string) => void\">\n    Replace editor children. Use controlled state patterns when React owns the value.\n  </APIItem>\n  <APIItem name=\"editor.tf.navigation.clear\" type=\"() => void\">\n    Clear navigation feedback state.\n  </APIItem>\n  <APIItem name=\"editor.tf.navigation.flashTarget\" type=\"(options: NavigationFlashTargetOptions) => boolean\">\n    Store a target temporarily so components can render navigation feedback.\n  </APIItem>\n  <APIItem name=\"editor.tf.navigation.navigate\" type=\"(options: NavigationNavigateOptions) => boolean\">\n    Navigate to a target and flash it through the navigation feedback plugin.\n  </APIItem>\n  <APIItem name=\"editor.tf.reset\" type=\"(options?: ResetOptions) => void\">\n    React extension wrapper. It restores focus to the editor when the editor was focused before reset.\n  </APIItem>\n</APITransforms>\n</API>\n\n## Plugin Pipeline Effects\n\nSome core behavior is exposed by overriding existing Slate transforms rather than by adding named methods.\n\n| Plugin | Effect |\n| --- | --- |\n| `ParserPlugin` | Overrides `insertData` and scans plugin parsers in reverse plugin order. Matching parsers transform data, deserialize a fragment, transform the fragment, and insert it. |\n| `LengthPlugin` | Wraps `apply` in `withoutNormalizing` and trims overflow when `maxLength` is configured. |\n| `SlateExtensionPlugin` | Wraps `apply` so `onNodeChange` and `onTextChange` handlers can receive previous and next node or text state. |\n| `SlateReactExtensionPlugin` | Handles line movement, tab, untab, select-all, escape, `currentKeyboardEvent`, focus-preserving reset, and `_memo` cleanup during normalization. |\n| `HtmlPlugin` | Registers the `text/html` parser path and delegates HTML elements to `editor.api.html.deserialize`. |\n| `BaseParagraphPlugin` | Registers the default paragraph element under key `p` and maps HTML `<p>` elements, excluding code-font paragraphs. |\n\n## Type Helpers\n\nUse `TPlateEditor` when you want an editor typed to a specific value and plugin union.\n\n```ts title=\"Typed editor helper\"\nimport type { TPlateEditor } from 'platejs/react';\nimport type { Value } from 'platejs';\nimport { BoldPlugin } from '@platejs/basic-nodes/react';\n\ntype BasicEditor = TPlateEditor<Value, typeof BoldPlugin>;\n```\n\n| Type | Purpose |\n| --- | --- |\n| `PlateEditor` | Runtime editor type with the default Plate core plugin surface. |\n| `TPlateEditor<V, P>` | Typed editor for a specific `Value` and plugin union. |\n| `KeyofPlugins<T>` | String key union for Plate core plugins plus the supplied plugin config union. |\n\n## Related APIs\n\n- [Plate components](/docs/api/core/plate-components) covers `Plate`, `PlateContent`, `PlateView`, and component-layer runtime effects.\n- [PlateController](/docs/api/core/plate-controller) covers active, primary, and fallback editor lookup.\n- [Plate plugin](/docs/api/core/plate-plugin) covers plugin configuration, methods, options, handlers, and render hooks.\n- [Controlled Value](/docs/controlled) covers React-owned value patterns around `editor.tf.setValue`.\n",
      "type": "registry:file",
      "target": "content/docs/plate/api/core/plate-editor.mdx"
    }
  ],
  "type": "registry:file"
}