{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "single-block-docs",
  "title": "Single Block",
  "description": "Restrict an editor to one root block or one line of text.",
  "files": [
    {
      "path": "../../content/docs/(plugins)/(functionality)/(utils)/single-block.mdx",
      "content": "---\ntitle: Single Block\ndescription: Restrict an editor to one root block or one line of text.\ndocs:\n  - route: /docs/examples/single-block\n    title: Demo\n  - route: /docs/trailing-block\n    title: Trailing Block\n---\n\nSingle Block provides two input constraints: one root block with soft breaks, or one line with no breaks. Both plugins disable `TrailingBlockPlugin` while enabled and collapse extra root blocks during normalization.\n\n<ComponentPreview name=\"single-block-demo\" />\n\n<PackageInfo>\n\n## Features\n\n- `SingleBlockPlugin` keeps one root block and converts Enter to a soft break.\n- `SingleLinePlugin` keeps one root block and removes all line break characters.\n- Root normalization merges extra blocks into the first block.\n- Both plugins disable `TrailingBlockPlugin`.\n- Demo toggle for switching between single-block and single-line behavior.\n\n</PackageInfo>\n\n## Fast Path\n\nUse `SingleBlockPlugin` when the field may contain line breaks.\n\n```tsx\nimport { SingleBlockPlugin } from 'platejs';\nimport { createPlateEditor } from 'platejs/react';\n\nexport const editor = createPlateEditor({\n  plugins: [SingleBlockPlugin],\n});\n```\n\nUse `SingleLinePlugin` when the field must be plain one-line text.\n\n```tsx\nimport { SingleLinePlugin } from 'platejs';\nimport { createPlateEditor } from 'platejs/react';\n\nexport const editor = createPlateEditor({\n  plugins: [SingleLinePlugin],\n});\n```\n\n## Ownership\n\n| Layer | Owner | What It Does |\n|-------|-------|--------------|\n| `SingleBlockPlugin` | `platejs` / `@platejs/utils` | Keeps one root block and preserves line breaks as text. |\n| `SingleLinePlugin` | `platejs` / `@platejs/utils` | Keeps one root block and strips line break characters. |\n| `TrailingBlockPlugin` | `@platejs/utils` | Disabled by both plugins through `override.enabled`. |\n| `single-block-demo` | Registry example | Lets users toggle between single-block and single-line mode. |\n\nThese plugins are editor constraints, not schema validation. They rewrite editor content during normalization.\n\n## Behavior\n\n| Plugin | Enter | Soft Break | Extra Root Blocks | Existing Text Breaks |\n|--------|-------|------------|-------------------|----------------------|\n| `SingleBlockPlugin` | Calls `editor.tf.insertSoftBreak()`. | Preserved as `\\n`. | Merged into the first block with `\\n` separators. | Preserved. |\n| `SingleLinePlugin` | No-op. | No-op. | Merged into the first block with no separator. | Removes `\\r`, `\\n`, `\\r\\n`, `\\u2028`, and `\\u2029`. |\n\nUse single-block mode for descriptions, comments, or titles that may wrap across lines. Use single-line mode for labels, slugs, short titles, and command inputs.\n\n## Normalization\n\nBoth plugins override `normalizeNode`.\n\n| Case | Result |\n|------|--------|\n| Root has one block | Leaves the value alone. |\n| Root has multiple blocks with `SingleBlockPlugin` | Inserts `\\n` at the start of each next block, then merges it into the first block. |\n| Root has multiple blocks with `SingleLinePlugin` | Merges each next block into the first block without a separator. |\n| Text node contains line separators with `SingleLinePlugin` | Replaces the text with the filtered one-line string. |\n\nThe merge happens inside `editor.tf.withoutNormalizing`, so the root collapse finishes as one normalization pass.\n\n## Demo Toggle\n\nThe registry example switches plugins from a checkbox.\n\n```tsx\nimport { SingleBlockPlugin, SingleLinePlugin } from 'platejs';\n\nconst plugins = [\n  isSingleBlock ? SingleBlockPlugin : SingleLinePlugin,\n];\n```\n\n`Single Block Mode` keeps pasted lines as `\\n`. Turning it off switches to single-line mode and removes line breaks.\n\n## API Reference\n\n| API | Package | Use |\n|-----|---------|-----|\n| `SingleBlockPlugin` | `platejs` / `@platejs/utils` | One root block with soft breaks preserved. |\n| `SingleLinePlugin` | `platejs` / `@platejs/utils` | One root block with all line breaks removed. |\n| `KEYS.singleBlock` | `platejs` / `@platejs/utils` | Plugin key for `SingleBlockPlugin`. |\n| `KEYS.singleLine` | `platejs` / `@platejs/utils` | Plugin key for `SingleLinePlugin`. |\n| `override.enabled.trailingBlock` | Plugin override | Set to `false` by both plugins. |\n",
      "type": "registry:file",
      "target": "content/docs/plate/(plugins)/(functionality)/(utils)/single-block.mdx"
    }
  ],
  "type": "registry:file"
}