Is there any way to force a composition to apply the marks without waiting for completion or for endComposition to fire?

I noticed that when we try to link some text that’s being type on Android, the anchor tag isn’t inserted into the DOM until the composition ends.

I saw that ProseMirror schedules it to end after 5 seconds of inactivity, and when this occurs the link is inserted into the DOM and if the user types it will continue the composition from there.

But if we (I know inadvisably) use the same internal function (__endComposition) the link gets applied as expected, but the composition cannot be continued like it can when this is called via scheduleComposeEnd - eg you can type but autosuggestions no longer work.

Additionally it seems that the scheduleComposeEnd would still fire after 5 seconds and at that point the text the user was typing is replaced by the next character they type.

I know this is a pretty advanced case but I wondered if anyone might have advice for us.

Thanks for reading!


This works for me. What virtual keyboard are you using? And how are you adding the link?

Thank you very much for your reply @marijn.

We add the link via appendTransaction because InputRules can’t match text after the caret, which is a requirement for our use case. We’re using GBoard on Android 13. The anchor tag gets added to the DOM only after the composition is finalized or ProseMirror times it out.

Ah, no, I was thinking of the case where the link is added in storedMarks. Messing with the content around the cursor during a composition is indeed problematic. If the editor changes the DOM at that point, browser may do weird things. Maybe that’s what happening—the browser overriding the link again with its composition text.

1 Like