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).

Installation

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

Usage

import { NormalizersPlugin } from '@udecode/plate-normalizers/react';
import { TrailingBlockPlugin } from '@udecode/plate-trailing-block/react';
import { ParagraphPlugin } from '@udecode/plate/react';
import { HEADING_KEYS } from '@udecode/plate-heading/react';
 
const plugins = [
  // ...otherPlugins
  TrailingBlockPlugin.configure({ options: { type: ParagraphPlugin.key } }),
  NormalizersPlugin.configure({
    options: {
      rules: [{ path: [0], strictType: 'h1' }],
    },
  }),
];

Plugins

TrailingBlockPlugin

Options

Collapse all

    Level where the trailing node should be, the first level being 0.

    • Default: 0

    Type of the trailing block.

    • Default: editor.getType(ParagraphPlugin)

Also extends QueryNodeOptions for additional node querying options.

NormalizeTypesPlugin

Attributes

Collapse all

    Array of rules for normalizing types.

    • Default: []

OptionsRule

Collapse all

    Path where the rule applies.

    Force the type of the node at the given path.

    Type of inserted node if strictType is not provided.