Skip to content

Toolbar Drop Down for Headings #1396

Closed Answered by ryanbarr
iwatakeshi asked this question in Q&A
Discussion options

You must be logged in to vote

Define a collection of options and the element types we want to map them to so we can render our dropdown:

const elementOptions = [
  { type: ELEMENT_DEFAULT, label: "Normal" },
  { type: ELEMENT_H1, label: "Heading 1" },
  { type: ELEMENT_H2, label: "Heading 2" },
  { type: ELEMENT_H3, label: "Heading 3" },
  { type: ELEMENT_H4, label: "Heading 4" },
  { type: ELEMENT_H5, label: "Heading 5" },
  { type: ELEMENT_H6, label: "Heading 6" },
];

Now, let's create our select box which is configured to toggle the mark type on change. You'll need to import usePlateEditorRef and getParent:

const LevelSelect = () => {
  const editor = usePlateEditorRef("body");
  const parent = getParent(editor, ed…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@ryanbarr
Comment options

@nmastilovic
Comment options

@zbeyens
Comment options

@nmastilovic
Comment options

Answer selected by zbeyens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants