yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
335 stars 116 forks source link

feat: handle composition #107

Open vincentdchan opened 2 years ago

vincentdchan commented 2 years ago

Why?

When the user inputs with IME, the middle process will be committed, that's unnecessary. This PR wants to optimize this behaviour. When the editor is in the composing state, Yjs don't need to commit the changes. When the composition was finished, the plugin commits the changes.

Before

2022-05-07 22 34 31

After

2022-05-07 22 31 58

dmonad commented 2 years ago

Hi @vincentdchan, thank you for this!

I'm wondering how this workaround behaves in a collaborative environment. I expect that remote changes will delete the composing state which is probably worse than committing the composing state.

Would it be possible for you to test if this works reliably when other people are editing the same document / paragraph?

cqh963852 commented 2 years ago

I have create a project with y-prosemirror. It use vincentdchan:feat/ime branch.

It has some problem. While delete a some content. The user is under composing, cursor comes wrong.

I have check the shimo's behavior. During composing, It much like a offline editor.

cqh963852 commented 2 years ago
  1. type 123456
  2. image
  3. insert between 34 with composing aa
  4. image

cursor data received by another user 3baeb6547606f644f94dc097a46d0f4

cqh963852 commented 2 years ago

😀I have implement a custom provider based on socket.io. While composing, I make sync suspense. Just like disconnect. After composing, I send a sync message. It works fine. You can check the demo at http://43.134.196.209:3000/cl7a7opuy0028drwid01c38vf

😔I tried modify the demo in y-prosemirror, but the disconnect action in y-webrtc provider not works fine.