Switch back to draft.js from slate.js, requesting some basic features.
See original GitHub issueDo you want to request a feature or report a bug? feature
- A lot of people using draft.js just to render a resizable textarea in React(or at least to start with),But
- draft.js makes it really hard to render a textarea with predetermined text. yes, we have
EditorState.createEmpty()
, but how to create initial state with text? With some digging I findEditorState.createWithContent(ContentState.createFromText(text))
, not obvious to new users. - Also how to extract text from state?
state.getCurrentContent().getPlainText()
When I’m switching back from slate.js(because some bug they are not actively fixing), here’s the comparison:
import { Editor, EditorState, ContentState } from 'draft-js'
const Plain = {
deserialize: text =>
EditorState.createWithContent(ContentState.createFromText(text)),
serialize: state => state.getCurrentContent().getPlainText()
}
compare to import { Editor,Plain } from 'slate'
Is there some way to trim it down to more user friendly api like in slate.js? Or at least inform us on the tutorial starting demo?
-
Also
slate
provide a method on<Editor/>
,onDocumentChange
when the actual content changes. I find it useful asonChange
triggers way to often. -
And they provide a
className
property(makes more sense to me), instead of having to create a wrapperdiv
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Switch back to draft.js from slate.js, requesting some basic features.
Coming soon: A brand new website interface for an even better experience!
Read more >Introduction - Slate
It was inspired by libraries like Draft.js, Prosemirror and Quill. ... Rich text — showing the features you'd expect from a basic editor....
Read more >volto-slate: Documentation | Openbase
Volto's draftjs implementation depends on draft-js-plugins, a third-party project that introduces its own set of bugs and maintanance issues. Slate has a modern ......
Read more >Slate.js: Customizeable rich text library inspired by Draft.js
2. I've had users encounter bugs where the Draft editor will serialize state that it can't read - so you can save something,...
Read more >What is Slate.js, and will it replace Quill and Draft.js?
Quill, no doubt, is a drop-in editor; you can get started without changing anything. If you get beyond the most basic use cases,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@FateRiddle If I may ask, what made you move back? I was considering the switch due to the lack of mobile support in draft.js
I don’t think we’ll be making major changes to the API at the moment.
onDocumentChange
needs you to define what exactly a ‘document’ is. This means different things in different editor use cases. One of the power features of Draft, in my opinion, is the flexibility to customize the input to what you want.onChange
allows you to do that by exposing all the changes and letting you address whichever ones you want.In view of this, I’m closing this issue. Let me know if you have further questions!