Back to Plate

Forced Layout

docs/(plugins)/(functionality)/(utils)/forced-layout.mdx

1.0.01.1 KB
Original Source
<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.
</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>