Skip to main content

Forced Layout

Allows you to enforce document structure. For example, you can require that the first line is an H1.

Installation#

npm install @udecode/plate-normalizers
npm install @udecode/plate-trailing-block

Usage#

Live Editor
Result

Options#

export interface TrailingBlockPlugin extends QueryNodeOptions {
/**
* Level where the trailing node should be, the first level being 0.
*/
level?: number;
/**
* Type of the trailing block
*/
type?: string;
}
interface Rule {
/**
* Force the type of the node at the given path
*/
strictType?: string;
/**
* Type of the inserted node at the given path if `strictType` is not provided
*/
type?: string;
/**
* Path where the rule applies
*/
path: Path;
}
export interface NormalizeTypesPlugin extends ErrorHandler {
/**
* Set of rules for the types.
* For each rule, provide a `path` and either `strictType` or `type`.
* If there is no node existing at `path`:
* insert a node with `strictType`.
* If there is a node existing at `path` but its type is not `strictType` or `type`:
* set the node type to `strictType` or `type`.
*/
rules?: Rule[];
}

Source Code#