Forced Layout
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.
Installation
npm install @udecode/plate-normalizers
Usage
import { NormalizeTypesPlugin } from '@udecode/plate-normalizers';
import { TrailingBlockPlugin } from '@udecode/plate-trailing-block';
import { ParagraphPlugin } from '@udecode/plate/react';
import { HEADING_KEYS } from '@udecode/plate-heading/react';
const plugins = [
// ...otherPlugins
NormalizeTypesPlugin.configure({
options: {
rules: [{ path: [0], strictType: 'h1' }],
},
}),
];
Plugins
NormalizeTypesPlugin
Options
Collapse all
- Default:
[]
An array of rule objects for normalizing types.
Rule
Attributes
Collapse all
Path where the rule applies.
Force the type of the node at the given path.
Type of the inserted node at the given path if strictType
is not provided.