-
-
Notifications
You must be signed in to change notification settings - Fork 125
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
Updating attributes is not working when there is no text content and using a custom document content expression #30
Comments
I suspect that your taskList item needs textual content. If a y-prosemirror detects that the content doesn't conform to the schema, then the node is marked as invalid and the previous operation is reversed (in this case the operation to check the taskList apparantly leads to an invalid ProseMirror state). The above editor detects that an attribute changes and probably propagates that change to the below editor. Could you please check the ProseMirror state of both editors and print them here? Could you try to create taskItem without textual content? Does it conform to your ProseMirror schema? It's really hard to debug such an issue without something reproducible. I'm just guessing here. Could you please share a repository or a stackblitz? (you could fork this https://stackblitz.com/edit/y-prosemirror) |
Oh, and what a beautiful editor that is 😉 |
It occurs not only for nodes with text. First I noticed the problem when I wanted to update an atom node when using such a content expression for the doc: |
Okay here it is: |
I was able to reproduce the issue. Here is a screenshot of the ProseMirror state. The state is synchronized among clients at all times, but it seems that the view is not properly updated. I don't think that's an issue with y-prosemirror. y-prosemirror only guarantees that the states are synced. It is probably related to the change event or ProseMirrors inner workings. I guess what is happening is that the FYI: I think the There is also a meta property on the ySyncPlugin that is defined when the current transaction originates from a remote client. Just a lot of thoughts. Hopefully, they were helpful. But I don't think this is related to y-prosemirror. Feel free to continue the discussion & reopen if you think it is. |
Hey, sorry but I still don’t get it 😅 When updating the checkbox the prosemirror state is updated correctly and should be persisted correctly on the websocket server. (added some logging here: https://stackblitz.com/edit/y-prosemirror-hacaxk?file=index.ts) |
Instead of logging, could you check the state just before you reload the window? You might log the state before it is changed. |
I fixed it for you. It should have been 1. https://stackblitz.com/edit/y-prosemirror-q4vspn?file=index.ts The state synchronized properly. But the view did not after reload because of 1. So when you reloaded the window, you were able to read When you update the checkbox via mouse-click and then via state-update (in your case setAttribute('checked', 'checked')) then the view starts to fall apart. By using the checked property (as in 2.) you fix this problem. FYI: Spec is pretty unclear on this. But it should probably be If you still can reproduce the issue, try checking the state after reloading the window. It should be the same as before reloading it. There might still be rendering issues. Also don't use the |
That looks more like a sync issue. Or maybe the prosemirror-dispatch is only called after text content is added. Can you please check the ProseMirror state when you are in an invalid state? For comparison, can you please also log the Possible bugs are
I'm flying blind here, because my adaptation fixed the problem for me. I exchanged y-websocket for y-webrtc so we don't have to care about the regular demo-server outages. Let's use the following template now: https://stackblitz.com/edit/y-prosemirror-kbalw8?file=index.ts |
Through more guesswork, I was able to reproduce an issue by starting with a fresh document and then clicking the checkbox. In this case, the Yjs state should be updated. But it is not. Working on it.. |
I think y-prosemirror@1.0.3 should fix the second and the first issue. The issue was due to the comparison I do when checking if the "starting state" should be updated. Can you verify this here? https://stackblitz.com/edit/y-prosemirror-kbalw8?file=index.ts |
Hey, sorry if I was unclear. I don't fully understand how y.js works under the hood, so it’s hard for me to debug correctly for you. But with y-prosemirror@1.0.3 everything works as expected – for both cases. Thank you very much! 🙌 |
Great to hear!
I come to realize that it is an art to write reproducible steps. In this case it was a simple misunderstanding.
Looking forward to using your editor :)
…-------- Original Message --------
On Dec 8, 2020, 6:15 PM, Philipp Kühn wrote:
Hey, sorry if I was unclear. I don't fully understand how y.js works under the hood, so it’s hard for me to debug correctly for you. But with ***@***.*** everything works as expected – for both cases. Thank you very much! 🙌
—
You are receiving this because you modified the open/close state.
Reply to this email directly, [view it on GitHub](#30 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ABKL4XOPUPG2UYK54BSF7JLSTZNJ5ANCNFSM4UQHJAMQ).
|
Describe the bug
Updating attributes is not working when there is no text content. But this only happens when using a custom document content expression. In my example (gif below) I’m using
content: 'taskList'
. When using the defaultcontent: 'block+'
everything works as expected.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Attributes should always be synced.
Screenshots
Environment Information
The text was updated successfully, but these errors were encountered: