Plate.js Rich Text Editor Framework

52.3.21 · active · verified Sun Apr 19

Plate.js is a comprehensive framework for building rich text editors on the web, leveraging the power and flexibility of Slate.js. It provides a highly extensible, plugin-based architecture that simplifies the development of complex editor features, from basic formatting to advanced elements like tables, images, and AI integrations. The current stable version is 52.3.21, with frequent patch releases (often daily) indicating active development. Plate.js differentiates itself through its extensive collection of pre-built plugins, robust TypeScript support, and a focus on abstracting away much of the underlying Slate complexity, allowing developers to quickly assemble sophisticated editor experiences without deep knowledge of Slate's internal workings. It aims to reduce boilerplate and offer a batteries-included approach for common rich text editor functionalities.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes a basic Plate.js editor with paragraph, basic elements, alignment, and basic mark plugins (bold, italic). It demonstrates the minimal setup for a functional editor component.

import React, { useMemo } from 'react';
import { createPlateEditor } from '@platejs/core';
import { Plate, usePlateEditorRef, PlateContent } from '@platejs/react';
import { createParagraphPlugin } from '@platejs/paragraph';
import { createBasicElementsPlugin } from '@platejs/elements';
import { createAlignPlugin } from '@platejs/alignment';
import { createBoldPlugin, createItalicPlugin } from '@platejs/basic-marks';

const initialValue = [
  { type: 'p', children: [{ text: 'Hello, Plate.js!' }] },
  { type: 'p', children: [{ text: 'Start typing here...' }] },
];

function MyEditor() {
  const plugins = useMemo(
    () => [
      createParagraphPlugin(),
      createBasicElementsPlugin(),
      createAlignPlugin({ options: { align: 'left' } }),
      createBoldPlugin(),
      createItalicPlugin(),
    ],
    []
  );

  const editor = useMemo(() => createPlateEditor(), []);

  return (
    <Plate editor={editor} plugins={plugins} initialValue={initialValue}>
      <PlateContent
        className="p-4 min-h-[200px] border border-gray-300 rounded-md"
        placeholder="Type something..."
      />
    </Plate>
  );
}

export default MyEditor;

view raw JSON →