Slate: cmd+a + cmd+x doesn't work in rich text example

Created on 24 Oct 2018  Â·  15Comments  Â·  Source: ianstormtaylor/slate

Do you want to request a _feature_ or report a _bug_?

Bug

What's the current behavior?

cmd+x doesn't work in rich text example

What's the expected behavior?

cmx+x works

ezgif-4-99749bb270d5

P.S. I noticed other similar troubles with corrupted documents in my project too, but not investigated yet.

bug ♥ help

Most helpful comment

I think this has been fixed – can no longer reproduce at https://www.slatejs.org/#/rich-text.

Perhaps this had the same root cause as https://github.com/ianstormtaylor/slate/issues/2291?

All 15 comments

Duplicate of #2279

I find the reason. When delete all, the paragraph will include no leaves. Then moveToStart have no place to move. (Not this reason)

screen shot 2018-10-24 at 11 14 55 am

My fault. I forgot to think about delete all situation in removeText. I will submit a PR to fix.

https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/models/text.js#L509-L511

Not this problem.... I will investigate into the deleteAtRange to check what the problem is.

@zhujinxuan - I believe this rule should prevent empty paragraphs. I suspect it is not being applied. https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/plugins/core.js#L97-L107

I suspect the majority of all issues from the past week are caused by the schema rules not being properly applied. With that in mind, this issue too is probably related to https://github.com/ianstormtaylor/slate/issues/2264

@Slapbox I am unsure how the Ctrl-X and backspace is handled differently. It seems backspace works after C-a, but C-x does not work after C-a

Great point.

Hi @Slapbox @ianstormtaylor Is cmd+x is not defined in slate-hotkeys? I cannot see the binding.

I guess it's not. Looking through the history I guess it's never been. If it was there it would be in as mod+x.

This is the line that crashes things: https://github.com/ianstormtaylor/slate/blob/master/packages/slate-react/src/utils/clone-fragment.js#L133

The description of this block of code is: // Revert to the previous selection right after copying. - Obviously after cutting the selection is not there anymore.

@zhujinxuan here's the code where the copy and cut code starts doing its thing. We need to avoid setting the original range again on cut operations.

https://github.com/ianstormtaylor/slate/blob/master/packages/slate-react/src/plugins/after.js#L201-L241

@Slapbox Oh, I see. It is fixed in https://github.com/ianstormtaylor/slate/pull/2298

This is greatly improved in the latest releases, which include #2298, but it's not perfect.

@kalley

New Behavior:

Cutting the entire contents does not crash the editor, and does copy the contents to clipboard, but it does not clear out the editor and it throws the following error:

Uncaught Error:Node.assertNodecould not find node with path or key: List [ 1 ]

Additionally trying to paste over it all with the copied contents gives:

Uncaught Error:Node.assertNodecould not find node with path or key: List [ 4 ] - This one probably belongs in a new issue

Uncaught Error:Node.assertNodecould not find node with path or key: List [ 1 ]

This is probably https://github.com/ianstormtaylor/slate/issues/2291#issuecomment-432871992

@skogsmaskin I agree. My mistake.

I think this has been fixed – can no longer reproduce at https://www.slatejs.org/#/rich-text.

Perhaps this had the same root cause as https://github.com/ianstormtaylor/slate/issues/2291?

It would appear so!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ianstormtaylor picture ianstormtaylor  Â·  3Comments

ianstormtaylor picture ianstormtaylor  Â·  3Comments

adrianclay picture adrianclay  Â·  3Comments

JSH3R0 picture JSH3R0  Â·  3Comments

vdms picture vdms  Â·  3Comments