-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please Explain how to set/test a blank state #713
Comments
As I see in this comment, it is |
I think it would be really helpful to document as I for one spent several hours trying to figure this out. Now that you give me the example I feel dumb for not thinking of it, but when you're learning the mind plays a lot of tricks on you. My solution to illustrate was much more involved...
Does the terse flag apply for the Plain serialiser ? |
Nope, only for Raw. @ianstormtaylor What is the recommended way to initialize or set an empty state using Raw? |
Actually I find a potential bug relating to this. My current state constructor function uses the Plain serialiser to create a blank value.
When I added |
Running into the same issue as @thepian at the moment, seems like adding a |
In case anyone stumbles here from Google this worked for me: import Plain from 'slate-plain-serializer';
const emptyState = Plain.deserialize(''); |
The line issue seems to be fixed now (I'm on Slate 0.44.x). And for people that would like to avoid additional dependency, the
|
Update to @DominikSerafin's answer; I use:
Feel free to change the type from |
Is there an example of code anywhere that demonstrates clearly how to clear the editor? |
Hi, so i was looking for a way to clear the editor when a button was pressed. solution was
this uses the default setValue method in the slatejs example |
didn't work for me, got
|
this worked:
|
The only way it works for me: const point = { path [0, 0], offset: 0 };
editor.selection = { anchor: point, focus: point }; // clean up selection
editor.history = { redos: [], undos: [] }; // clean up history
setEditorValue([{ type:"paragraph", children: [{ text:"" }] }]); // reset to empty state From this article |
How do I set state to blank?
How do I test if the state is blank?
The text was updated successfully, but these errors were encountered: