codex-team / editor.js

A block-style editor with clean JSON output
https://editorjs.io
Apache License 2.0
28.18k stars 2.06k forks source link

How to wrap a simple editorJs plugin around a react component such as material ui Alert? #1384

Open StarAzure opened 3 years ago

StarAzure commented 3 years ago

How to wrap editor js text around a react component such as material ui Alert ?

Something like:

<Alert severity="error">This is the text entered in editor JS</Alert>

import Alert from '@material-ui/lab/Alert';
    class Alert {
      static get toolbox() {
        return {
          title: 'Image',
          icon: 'SomeSVG'
        };
      }

      render(){
        return document.createElement('input');
      }

      save(blockContent){
        return {
          url: blockContent.value
        }
      }
    }
neSpecc commented 3 years ago

Can't understand the question, need more details.

sahilmob commented 2 years ago

I have created a babel plugin that wraps a React component with a block tool class definition for this case. You can check it out here. Though, It is experimental, so use it at your own risk.