Composition overhaul

#1

As of today, the master branch of the repository contains a new approach to handling composition (the thing that happens when people use IME to input text in scripts that have too many characters to have a key for each character, but also for pretty much all input on Android).

In the old code, the view would basically stay away from the DOM when composition was in progress, because updating the DOM or DOM selection is likely to disrupt the composition. This meant that no transactions were fired for changes made to the DOM until the composition ended. Changes that were made through the API during composition did not show up on the screen until it ended either.

The new approach removes this freezing—it will only prevent decorations from messing with the text node that has the cursor, to avoid spurious interruptions of composition. Changes made by the composition immediately generate transactions, and changes to the document made in other ways are shown immediately. If such a change replaces the currently focused text node, an end to the composition is forced.

This should generally be less magical and complicated, and solve issues where extensions appeared inoperative during composition because their effect was delayed/frozen. It did involve quite a lot of changes to the prosemirror-view code, so testing for regressions before putting this live is recommended.

The public interface stays unchanged. The fact that more transactions are generated is of course observable by external code, but shouldn’t break well-written code.

The new code is available as prosemirror-view 1.9.0-prerelease3, and will be released as 1.9.0 in a few days.

4 Likes
#2

1.9.0 is out now.

#3

Hello marijn! I’m a chinese developer, when i use chinese input,1.9.0 will generate a large number of invalid steps in my case: image I want input “测试” but i got 6 steps:

1-5 steps is useless for me.

In this way, developers will get a lot of invalid steps in the Chinese environment. Causing a lot of unnecessary operations and taking up database space,this is not make sence. what about put composition into config props?

#4

Use step merging if you’re worried about data size. Transactions are mainly a UI-level thing and having them happen at a fine granularity has a bunch of advantages.

#5

thanks for your suggest