Skip to content
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

Error when extending a URL: assertNode could not find node #1

Closed
flowirtz opened this issue Aug 3, 2018 · 12 comments
Closed

Error when extending a URL: assertNode could not find node #1

flowirtz opened this issue Aug 3, 2018 · 12 comments

Comments

@flowirtz
Copy link

flowirtz commented Aug 3, 2018

Hey @enzoferey,

nice job with this, exactly what I was looking for! 👏 👍
I am trying to get your url-example running and everything works fine except for one thing:

When I type a URL like http://go.co it gets properly detected, tagged as an Inline and the node gets rendered. If I continue typing then - lets say the character m to finish the URL to be http://go.com I receive an error message in the console:

slate.es.js:7198 Uncaught Error: `Node.assertNode` could not find node with path or key: List [ 0, 2 ]
    at Document.Node.(:3000/anonymous function) [as assertNode] (http://localhost:3000/static/js/bundle.js:57490:13)
    at Document.splitNode (slate.es.js:6849)
    at Document.getFragmentAtRange (slate.es.js:5339)
    at Document.object.(:3000/anonymous function) [as getFragmentAtRange] (http://localhost:3000/static/js/bundle.js:51244:28)
    at Value.get$$1 (slate.es.js:12405)
    at getSelection (index.js:23)
    at getLastWordRec (index.js:31)
    at getLastWord (index.js:50)
    at Object.onKeyDown (index.js:87)
    at Stack$$1.run (slate.es.js:10253)
    at slate-react.es.js:4210
    at Change.call (slate.es.js:14204)
    at Editor.change (slate-react.es.js:4192)
    at Editor.onEvent (slate-react.es.js:4209)
    at Object._this.(:3000/anonymous function) [as onKeyDown] (http://localhost:3000/static/js/bundle.js:49360:23)
    at Content.onEvent (slate-react.es.js:2117)
    at _this.(:3000/anonymous function) (http://localhost:3000/static/js/bundle.js:47400:15)
    at HTMLUnknownElement.callCallback (react-dom.development.js:100)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:138)
    at Object.invokeGuardedCallback (react-dom.development.js:187)
    at Object.invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:201)
    at executeDispatch (react-dom.development.js:461)
    at executeDispatchesInOrder (react-dom.development.js:483)
    at executeDispatchesAndRelease (react-dom.development.js:581)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:592)
    at forEachAccumulated (react-dom.development.js:562)
    at runEventsInBatch (react-dom.development.js:723)
    at runExtractedEventsInBatch (react-dom.development.js:732)
    at handleTopLevel (react-dom.development.js:4476)
    at batchedUpdates$1 (react-dom.development.js:16659)
    at batchedUpdates (react-dom.development.js:2131)
    at dispatchEvent (react-dom.development.js:4555)
    at interactiveUpdates$1 (react-dom.development.js:16714)
    at interactiveUpdates (react-dom.development.js:2150)
    at dispatchInteractiveEvent (react-dom.development.js:4532)

I've been stuck at this point for half an hour now and came to conclude that this either is an issue with your extension or with Slate itself. I'll have a look at your code now, but I just got started with Slate today so that might not be that effective.

Would love it if you could have a look at this. Thanks! 😊

@flowirtz
Copy link
Author

flowirtz commented Aug 3, 2018

edit. hm nvm doesn't seem to be it

@enzoferey
Copy link
Owner

enzoferey commented Aug 3, 2018

Hello @fwirtz ! Thanks for the kind words, glad the plugin is useful to you 👍

The error isn't related to the fragment thing you mentioned, fragment is taken from internal Slate data, not the value object.

Could you tell me which version of Slate are you using ?

@flowirtz
Copy link
Author

flowirtz commented Aug 3, 2018

hey @enzoferey thanks for the fast reply! still stuck with that and trying to debug your sourcecode haha

running

slate:0.36.1
slate-react:0.14.2
slate-instant-replace:0.1.7

Can you reproduce the error?

If not, I attached my setup in the commit below - ignore the removeMe.js it's just my poor attempt to debug your code and try to find out where the error comes from.

flowirtz added a commit to hpi-schul-cloud/edtrio that referenced this issue Aug 3, 2018
Currently still contains a bug, see enzoferey/slate-instant-replace#1.

Add is-url as dependency
Add slate-instant-replace as dependency
@enzoferey
Copy link
Owner

Thanks @fwirtz, I was finishing some stuff IRL, I'm looking at it right now.

@flowirtz
Copy link
Author

flowirtz commented Aug 3, 2018

wow cool thanks so much! esp. given the fact that it's 11pm on a Friday night in madrid as well haha ❤️

@enzoferey
Copy link
Owner

enzoferey commented Aug 3, 2018

This is important for me ;)

I can indeed reproduce the error, I will keep you updated. Probably related to an update of Slate.

@flowirtz
Copy link
Author

flowirtz commented Aug 3, 2018

awesome thank you SO SO SO much!
I've spent all my afternoon trying to figure that out and really started to loose faith in my react skills <.<

@enzoferey
Copy link
Owner

enzoferey commented Aug 3, 2018

Located the error, not sure how to fix it yet. I developed the plugin with slate 0.34.2 (working example here https://codesandbox.io/s/322jv8rxkp) and when using newer version it crashes.

If this is urgent for you, downgrade to 0.34.2 and luckily you won't have other issues with other libs you are using. I will work on a fix asap.

EDIT: the critical upgrade was between Slate 0.34.7 and Slate 0.35.0

EDIT 2: Found a fix, testing it properly and creating a new version 🙌

@enzoferey
Copy link
Owner

enzoferey commented Aug 3, 2018

v0.1.8 published fe04a9b

By the way I had a peerDependency on ^0.34.2 set up, and 0.35.0 was marked as a breaking upgrade by the Slate guys, so it makes a lot of sense 😄

Thank you for pointing it out, I'll close the issue whenever you confirm everything is working. Good night !

@flowirtz
Copy link
Author

flowirtz commented Aug 4, 2018

@enzoferey AWESOME! Just tested it, works like a charm.

Just fyi the slate logger says:

The `value.focusOffset` property is deprecated, please use `selection.focus.offset` instead.

probably because of this:

const offsetCurrentWord = change.value.focusOffset;

you might want to change that as well.
but a warning is not an error, so major win here! 👍

Thanks again!

@enzoferey
Copy link
Owner

enzoferey commented Aug 4, 2018

Good morning @fwirtz !

Slate upgraded to 0.37.0 since last night, bringing those deprecated messages hahaha

There is also:

The `Change.extend` method is deprecated, please use `Change.moveFocusForward` instead.

It seems that decision is here to stay, but I will wait a little bit before upgrading the references so I can fix any new possible API introduced in their next commits, they have backwards compability right now ;)

Closing the issue. Thanks !

@flowirtz
Copy link
Author

flowirtz commented Aug 6, 2018

hahaha no way sorry didn't notice that.
No worries, lgtm so far! Thanks for fixing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants