Bug
If there is a trailing empty block, and we select all with cmd+a and then paste anything, an error occurs:
Uncaught TypeError: Cannot read property 'key' of undefined
at Changes.insertFragmentAtRange (https://npmcdn.com/[email protected]/dist/slate.js:7158:55)
at Change.call (https://npmcdn.com/[email protected]/dist/slate.js:10521:10)
at Change.(anonymous function) [as insertFragmentAtRange] (https://npmcdn.com/[email protected]/dist/slate.js:10580:15)
at Changes.insertFragment (https://npmcdn.com/[email protected]/dist/slate.js:6193:10)
at Change.call (https://npmcdn.com/[email protected]/dist/slate.js:10521:10)
at Change.(anonymous function) [as insertFragment] (https://npmcdn.com/[email protected]/dist/slate.js:10580:15)
at Object.onPaste (https://npmcdn.com/[email protected]/dist/slate-react.js:11554:14)
at Stack.run (https://npmcdn.com/[email protected]/dist/slate.js:16879:38)
at https://npmcdn.com/[email protected]/dist/slate-react.js:9290:20
at Change.call (https://npmcdn.com/[email protected]/dist/slate.js:10521:10)
Issue can be reproduced on the default fiddle: https://jsfiddle.net/fj9dvhom/1/
Here is a gif: https://imgur.com/a/1KENt
Chrome version 62, Ubuntu 17, Slate version 0.31.5
After selecting all with cmd+a, paste should work correctly no matter if there is a trailing empty block or not.
I did a PR for this. It did solve it in my case.
It's not only when pasting though. If you select all, with a trailing empty block, and type something you also get an error. I think @zGrav's fix will solve the pasting issue, but not for when inserting text.
I do not suffer from this issue @tobiasandersen
Oh you're right, I hand't pulled latest, so I guess it was fixed recently :)
I did found out another one though, PR'ing :)
So is this fixed on the latest?
No, sorry if I confused things here. This was recently fixed for when inserting text (i.e. for insertTextAtRange), but it's still an issue for insertFragmentAtRange.
I think this is fixed in the latest version of Slate.
Most helpful comment
No, sorry if I confused things here. This was recently fixed for when inserting text (i.e. for
insertTextAtRange), but it's still an issue forinsertFragmentAtRange.