Forced Layout

PreviousNext

Documentation for Forced Layout

Docs
platefile

Preview

Loading preview…
../../docs/(plugins)/(functionality)/(utils)/forced-layout.mdx
---
title: Forced Layout
---

<PackageInfo>

## Features

- Automatically ensures the use of specified elements as required to maintain document structure (e.g., first block should be an H1 element).
- To force a trailing block of a specific type, see [Trailing Block](/docs/trailing-block).

</PackageInfo>

## Usage

```tsx
import { NormalizeTypesPlugin } from 'platejs';

const plugins = [
  // ...otherPlugins
  NormalizeTypesPlugin.configure({
    options: {
      rules: [{ path: [0], strictType: 'h1' }],
    },
  }),
];
```

## Plugins

### NormalizeTypesPlugin

<API name="NormalizeTypesPlugin">
<APIOptions>
<APIItem name="rules" type="Rule[]" optional>
An array of rule objects for normalizing types.

- **Default:** `[]`
</APIItem>
</APIOptions>

<APIOptions type="Rule">
  <APIItem name="path" type="Path">
    Path where the rule applies.
  </APIItem>
  <APIItem name="strictType" type="string" optional>
    Force the type of the node at the given path.
  </APIItem>
  <APIItem name="type" type="string" optional>
    Type of inserted node if `strictType` is not provided.
  </APIItem>
</APIOptions>
</API>

Installation

npx shadcn@latest add @plate/forced-layout-docs

Usage

Usage varies by registry entry. Refer to the registry docs or source files below for details.