Skip to main content
Version: 2.0.0

Headings

import { useMemo } from "react";
import { withReact } from "slate-react";
import { withHistory } from "slate-history";

import { 
  createTazeEditor, 
  Taze,
  TDescendant
} from "@taze-editor/taze-core";

import {
  createHeadingOnePlugin,
  createHeadingTwoPlugin,
  createHeadingThreePlugin,
} from "@taze-editor/taze-plugin-basic-elements";

import { Toolbar } from "./Toolbar";

export default function App() {

  const editor = useMemo(() => 
    withReact(
      withHistory(
        createTazeEditor({
          plugins: [
            createHeadingOnePlugin(),
            createHeadingTwoPlugin(),
            createHeadingThreePlugin(),
          ],
        })
      )
    ),
  []);

  const initialValue: TDescendant[] = [{
    type: "p",
    children: [{ text: "This is editable." }],
  }]

  return (
    <div>
      <Taze
        editor={editor} 
        initialValue={initialValue}
        beforeEditable={<Toolbar />}
      />
    </div>
  );
}