{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-align-docs",
  "title": "Text Align",
  "description": "Align block content.",
  "files": [
    {
      "path": "../../content/docs/(plugins)/(styles)/text-align.mdx",
      "content": "---\ntitle: Text Align\ndescription: Align block content.\ndocs:\n  - route: /docs/examples/align\n    title: Align Demo\n  - route: /docs/components/align-toolbar-button\n    title: Align Toolbar Button\n---\n\n`TextAlignPlugin` stores block alignment in an `align` property and renders it as CSS `text-align`. Setting the default `start` value removes the property from matching blocks.\n\n<ComponentPreview name=\"align-demo\" />\n\n<PackageInfo>\n\n## Features\n\n- Block-level text alignment.\n- `start`, `left`, `center`, `right`, `end`, and `justify` values.\n- HTML `text-align` style deserialization.\n- Default-value cleanup.\n- Configurable target block types.\n- Registry dropdown toolbar for common alignments.\n\n</PackageInfo>\n\n## Kit Usage\n\n<Steps>\n\n### Add the Kit\n\nUse `AlignKit` for the Plate UI setup. It targets headings, paragraphs, images, and media embeds.\n\n<ComponentSource name=\"align-kit\" />\n\n```tsx\nimport { createPlateEditor } from 'platejs/react';\n\nimport { AlignKit } from '@/components/editor/plugins/align-kit';\n\nexport const editor = createPlateEditor({\n  plugins: [...AlignKit],\n});\n```\n\n### Add the Toolbar Control\n\n`AlignToolbarButton` shows left, center, right, and justify controls.\n\n```tsx\nimport { AlignToolbarButton } from '@/components/ui/align-toolbar-button';\n\nexport function AlignControls() {\n  return <AlignToolbarButton />;\n}\n```\n\n</Steps>\n\n## Manual Usage\n\n<Steps>\n\n### Install Package\n\n```bash\nnpm install @platejs/basic-styles\n```\n\n### Add the Plugin\n\nConfigure the blocks that can store alignment.\n\n```tsx\nimport { TextAlignPlugin } from '@platejs/basic-styles/react';\nimport { KEYS } from 'platejs';\nimport { createPlateEditor } from 'platejs/react';\n\nexport const editor = createPlateEditor({\n  plugins: [\n    TextAlignPlugin.configure({\n      inject: {\n        nodeProps: {\n          defaultNodeValue: 'start',\n          nodeKey: 'align',\n          styleKey: 'textAlign',\n          validNodeValues: [\n            'start',\n            'left',\n            'center',\n            'right',\n            'end',\n            'justify',\n          ],\n        },\n        targetPlugins: [...KEYS.heading, KEYS.p],\n      },\n    }),\n  ],\n});\n```\n\n### Set Alignment\n\nUse the bound transform or the headless utility.\n\n```tsx\nimport { setAlign } from '@platejs/basic-styles';\n\neditor.tf.textAlign.setNodes('center');\n\nsetAlign(editor, 'start', { at: [] });\n```\n\n</Steps>\n\n## Ownership\n\n| Surface | Owner | What It Does |\n|---------|-------|--------------|\n| `BaseTextAlignPlugin` | `@platejs/basic-styles` | Headless plugin that stores alignment, injects block props, and parses HTML text-align styles. |\n| `TextAlignPlugin` | `@platejs/basic-styles/react` | React wrapper around `BaseTextAlignPlugin`. |\n| `setAlign` | `@platejs/basic-styles` | Sets or clears alignment on matching blocks. |\n| `tf.textAlign.setNodes` | `@platejs/basic-styles` | Bound transform exposed by the plugin. |\n| `BaseAlignKit` | Registry kit | Static/headless setup for headings, paragraphs, images, and media embeds. |\n| `AlignKit` | Registry kit | React setup plus toolbar dependency. |\n| `AlignToolbarButton` | Registry UI | Dropdown that writes alignment through `textAlign.setNodes`. |\n\nThe package owns alignment storage and parsing. The registry owns the dropdown UI.\n\n## Behavior\n\n| Behavior | Source |\n|----------|--------|\n| Plugin key | `KEYS.textAlign` |\n| Stored property | `align` |\n| Rendered CSS style | `textAlign` |\n| Default target plugins | `[KEYS.p]` |\n| Registry target plugins | `[...KEYS.heading, KEYS.p, KEYS.img, KEYS.mediaEmbed]` |\n| Default value | `start` |\n| Valid values | `start`, `left`, `center`, `right`, `end`, `justify` |\n| HTML parser | Reads `element.style.textAlign`. |\n| Setting a custom value | Sets `{ align: value }` on matching blocks. |\n| Setting `start` | Unsets the stored alignment property. |\n| Non-target blocks | Are ignored by `setAlign`. |\n\n## HTML\n\nThe plugin injects an HTML deserializer into each target plugin. Pasted HTML with a `text-align` style becomes an `align` prop on matching blocks.\n\n```html\n<p style=\"text-align: center\">Centered text</p>\n```\n\n## API Reference\n\n| API | Package | Use |\n|-----|---------|-----|\n| `TextAlignPlugin` | `@platejs/basic-styles/react` | React alignment plugin. |\n| `BaseTextAlignPlugin` | `@platejs/basic-styles` | Headless alignment plugin. |\n| `editor.tf.textAlign.setNodes(value, options?)` | `@platejs/basic-styles` | Sets or clears alignment on matching blocks. |\n| `setAlign(editor, value, options?)` | `@platejs/basic-styles` | Headless transform behind the bound API. |\n\n## Options\n\n| Option | Surface | Use |\n|--------|---------|-----|\n| `inject.targetPlugins` | `TextAlignPlugin` | Block types that can keep `align`. |\n| `inject.nodeProps.nodeKey` | `TextAlignPlugin` | Stored block property; registry kits use `align`. |\n| `inject.nodeProps.defaultNodeValue` | `TextAlignPlugin` | Value that clears the stored property when selected. |\n| `inject.nodeProps.styleKey` | `TextAlignPlugin` | CSS property used for rendering. |\n| `inject.nodeProps.validNodeValues` | Registry toolbar | Values exposed to alignment UI. |\n| `SetNodesOptions` | `setAlign` | Slate node update options passed to `setNodes` or `unsetNodes`. |\n",
      "type": "registry:file",
      "target": "content/docs/plate/(plugins)/(styles)/text-align.mdx"
    }
  ],
  "type": "registry:file"
}