4

I am using the Editor.js library.
I want to have a title section on my edit page that only accepts a Header block. This is the code that I have used to implement that:

const titleEditor = new EditorJS({
  placeholder: "Enter a title...",
  holderId: "title-editor",
  tools: {
    header: {
      class: Header,
      shortcut: "CMD+SHIFT+H",
      config: {
        placeholder: "Enter a Header..."
      }
    }
  }
});

Now, this basically works like I want. However, it allows me to add multiple titles in that editor. That is, if I type a header and hit return, I can then get the plus icon which allows me to add another header --- and another, etc.

But I don't want that. I want one single header for the page. I.e., I want to lock that block to only one instance of the Header block.

Any idea how I can do this?

Christoph Kluge
  • 1,947
  • 8
  • 23
Moshe
  • 6,011
  • 16
  • 60
  • 112

1 Answers1

0

For now, you can use an external textarea for the title and editor.js for article body.

In the future, editor.js will support entry templating that allows you to provide persistent structure of the document

Specc
  • 46
  • 5
  • Instead of using textarea I copied part of the html generated by editor.js and uses `contenteditable=true` `h1`, which looks and behaves much better. – AppleGrew May 05 '22 at 15:34