question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Switch back to draft.js from slate.js, requesting some basic features.

See original GitHub issue

Do you want to request a feature or report a bug? feature

  1. 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 find EditorState.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?

  1. Also slate provide a method on <Editor/>, onDocumentChange when the actual content changes. I find it useful as onChange triggers way to often.

  2. And they provide a className property(makes more sense to me), instead of having to create a wrapper div.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
bryanphcommented, Sep 18, 2017

@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

0reactions
niveditccommented, Sep 10, 2018

I don’t think we’ll be making major changes to the API at the moment.

  • PRs to make the docs more beginner-friendly are always welcome.
  • A method like 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.
  • #1713 is open for adding an additional style prop. We’ll try to review that soon.
  • #725 is the umbrella issue for the Android/mobile bugs mentioned here.

In view of this, I’m closing this issue. Let me know if you have further questions!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found