Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

Making bullet points in Draft.js

You can turn any text block to bullet points with RichUtils of draft-js. Here is how you can do it:

// button to turn text block to bullet points
<button onClick={this.toggleBulletPoints}>Bullet points</button>

toggleBulletPoints(){
    this.setState({
        RichUtils.toggleBlockType(
            this.state.editorState,
            'unordered-list-item'
        )
    })
}

Here is the complete example of to change inline styles and block types in draft-js editor: https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/rich/rich.html

Tags:

Reactjs

Draftjs

Related

Understanding Firebase Storage tokens How to support RTL and LTR in sass Mutating function in Julia (function that modifies its arguments) How to initialize const member requiring computations to be performed? How to block +,-,e in input type Number? C Preprocessor Remove Trailing Comma Firebase Auth - get provider ID What's platformBuildVersionCode and platformBuildVersionName in Extracted Apk's Django: Not Found static/admin/css JavaScript:output symbols and special characters Why can't I use operator bool() for std::ofstream Bootstrap data-toggle collapses div after second click, not first

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy