Rich text editing with Draft.js

30
Rich text editing with Draft.js

Transcript of Rich text editing with Draft.js

Page 1: Rich text editing with Draft.js

Rich text editing with

Draft.js

Page 2: Rich text editing with Draft.js

@nikgraf

Nik Graf

@nikgraf

[email protected]

Open Source Carte Blanche DraftJS Plugins Belle

Page 3: Rich text editing with Draft.js

You are bornPretty exciting!

time

happiness

Page 4: Rich text editing with Draft.js

You are bornPretty exciting!

Becoming a teenager

time

happiness

Page 5: Rich text editing with Draft.js

You are bornPretty exciting!

Becoming a teenager

First kiss

time

happiness

Page 6: Rich text editing with Draft.js

You are bornPretty exciting!

Becoming a teenager

First kiss

First breakup: Why me?

time

happiness

Page 7: Rich text editing with Draft.js

You are bornPretty exciting!

Becoming a teenager

First kiss

First breakup: Why me?

DraftJS released

time

happiness

Page 8: Rich text editing with Draft.js

@nikgraf

DraftJS

DraftJS is a framework for building rich text editors in React built & used within Facebook.

It got released at ReactConf in February and powers editing of comments, notes and status updates within Facebook.

Page 9: Rich text editing with Draft.js

@nikgraf

Page 10: Rich text editing with Draft.js

@nikgraf

Page 11: Rich text editing with Draft.js

@nikgraf

<div contenteditable=“true"> This text can be edited by the user. </div>

Page 12: Rich text editing with Draft.js

@nikgraf

Page 13: Rich text editing with Draft.js

@nikgraf

Structure

EditorState

• ContentState

• SelectionState

Page 14: Rich text editing with Draft.js

@nikgraf

Lorem ipsum dolor sit amet

Lorem ipsum #dolor sit amet

Lorem ipsum dolor sit amet

ContentStateBlock Text - Character

ContentState

Page 15: Rich text editing with Draft.js

@nikgraf

Page 16: Rich text editing with Draft.js

@nikgraf

Page 17: Rich text editing with Draft.js

@nikgraf

Page 18: Rich text editing with Draft.js

@nikgraf

Page 19: Rich text editing with Draft.js

@nikgraf

Page 20: Rich text editing with Draft.js

@nikgraf

Page 21: Rich text editing with Draft.js

@nikgraf

Manipulation

• decorators (wrap text with a Component)

• “React” -> “React🎉”

• blockStyleFn (apply class to a whole block)

• blockRendererFn (render custom block)

Page 22: Rich text editing with Draft.js

@nikgraf

Decorator

Page 23: Rich text editing with Draft.js

@nikgraf

Decorator

Page 24: Rich text editing with Draft.js

@nikgraf

Decorator

Page 25: Rich text editing with Draft.js

@nikgraf

blockRendererFn

Page 26: Rich text editing with Draft.js

@nikgraf

blockRendererFn

Page 27: Rich text editing with Draft.js

@nikgraf

blockRendererFn

Page 28: Rich text editing with Draft.js

@nikgraf

Page 29: Rich text editing with Draft.js
Page 30: Rich text editing with Draft.js

@nikgraf

The End

Thanks for listening!

https://github.com/nikgraf

https://twitter.com/nikgraf

http://www.meetup.com/Vienna-ReactJS-Meetup/