Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initialBlock config not working out with plugins #922

Open
utkarshrai003 opened this issue Oct 19, 2019 · 2 comments
Open

initialBlock config not working out with plugins #922

utkarshrai003 opened this issue Oct 19, 2019 · 2 comments

Comments

@utkarshrai003
Copy link

utkarshrai003 commented Oct 19, 2019

I want to get the header block at the first position of the editor, as soon as it is opened. It should be possible with initialBlock configuration of editorJS, but does not seem to do the job. I get an error saying This block can not be displayed.

Is initialBlock config not meant to do this job ?

@avdkishore
Copy link

The problem is the value you are sending to the initialBlock key. The value should be the key defined in the tools object as a string and not the imported class. You can refer the documentation here

@neSpecc
Copy link
Member

neSpecc commented Dec 9, 2019

The initialBlock is not designed for this purpose, because it is actually the default block that will be created on each Enter press. It is not the thing you want, I think.

If you want to init an empty editor with the header as the first block, pass it as data property:

new EditorJS({
  // other options...
  data: {
    blocks: [
      {
        type: 'header',
        data: {
          text: '',
          level: 2
        }
      },
    ]
  },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants