0

I am using draftjs for editor. I could parse html code that comes from api to markup. But how can i display a html button so that when clicked on it, it should allow to write html code.

How can i do it so?

Here is my code. I am using react-draft-wysiwyg

<div>
  <Editor
    tabIndex={0}
    hashtag={{}}
    editorState={editorState}
    initialContentState={this.props.htmlMarkup}
    toolbarClassName="home-toolbar"
    wrapperClassName="home-wrapper"
    editorClassName="home-editor"
    onEditorStateChange={this.onEditorStateChange}
    decorators={decorator}
    // toolbarOnFocus
    toolbar={{
      history: { inDropdown: true },
      inline: { inDropdown: false },
      list: { inDropdown: true },
      link: { showOpenOptionOnHover: true },
      textAlign: { inDropdown: true },
      image: {
        uploadCallback: this.imageUploadCallBack,
        defaultSize: { height: "auto", width: "50%" }
      }
    }}
    onContentStateChange={this.onEditorChange}
    placeholder="write text here..."
    spellCheck
    onChange={this.handleChange}
    onBlur={this.handleBlur}
  />
</div>
milan
  • 2,409
  • 2
  • 34
  • 71
  • Did you check these things out import { convertFromHTML, ContentState, convertToRaw } from 'draft-js';? – Manish Jangir Jun 20 '17 at 09:33
  • 1
    I want the button html and preview where html will show the content in html and preview will show the content in markup. When html button is clicked, get the content from the editor and convert the content to Raw if its not html and if its html convert it to markup using convertFromHTML? – milan Jun 20 '17 at 10:10

0 Answers0