Skip to content

Conversation

@matthew-carroll
Copy link
Contributor

@matthew-carroll matthew-carroll commented Oct 22, 2025

Create centralized SuperIme to share IME connections across SuperEditor subtree recreations, includes various other fixes (Resolves #2807)

SuperIme

SuperIme is a singleton, which at any time may or may not have an "owner". The idea is that the "owner" is allowed to open an IME connection, access the IME connection, and clear the IME connection, but non-owners can't.

The "owner" implementation is just a convenience. Nothing stops Flutter code from calling TextInput.attach() on their own and taking control of the whole app's IME. However, all code within super_editor can choose to access the IME through SuperIme, and to honor the ownership paradigm.

The ID of an owner includes two pieces: a role, and an instance. The role differentiates one editor from a completely different editor in the UI. For example, one editor might be used for "chat" and another might be used for "documents".

But sometimes two different widgets are actually the same editor. Specifically, when a SuperEditor is reparented, it results in the entire SuperEditor tree being dispossed and another SuperEditor tree is initialized, for the same editor. So, for a moment, a single "chat" editor will actually have two SuperEditor widgets. In this case, both have the role of "chat", but to further differentiate, an "owner" also includes an "instance". In this case, each State object can pass itself as the "instance" in the owner ID.

The "role" makes it clear when one input wants to take control from another input, and the "instance" makes it clear when an editor tree is going through recreation and should retain the existing IME connection.

IME Fixes

  • DocumentImeInputClient - In the constructor, it seems that we forgot to pass the IME connection through to the super class, which means the document was being sent to the IME upon construction when it should be. Now we pass it through.

Other Fixes

  • Fixed a remaining timing issue for showing an OverlayPortal in a demo, and also in document_gestures_touch_android.dart, and in keyboard_panel_scaffold.dart.
  • Removed an erroneous selection change listener that was registered in didChangeDependencies in document_gestures_touch_android.dart.
  • Changed MessagePageScaffold to support two sheet expansion points. We always had a max height for the bottom sheet. Now we have another max height as the content height grows, but the user has never dragged the sheet up to expand it. This gives the user some level of expansion for intrinsic height (maybe half way up), but then requires the user to opt in to the absolute maximum height by dragging up.
  • Fixed dragging and animating glitches in MessagePageScaffold by only starting a simulation if we're not already at the destination, and by correcting the velocity direction (we had it inverted from what it should be). Also fixed some situations where the sheet was getting stuck at an offset due to the order of some lines of code where the Ticker would stop when it shouldn't be stopped.
  • RenderMessageEditorHeight - Fixed possible NPE when looking up ancestor MessagePageScaffold.
  • Editor - Adjusted some order of operations dealing with when/how transactions are ended, and listeners are notified. This issue was found when implemeing SuperIme. One of the listeners happened to submit a ClearSelectionRequest at just the right time to cause an error with the order that properties were cleaned up at the end of a transaction. The critical change here was to null out the active change list before notifying listeners that the transaction was over. This required holding onto a temporary copy of the list to pass the change list to those listeners, even though we already null'ed out the active change list.
  • Made a convenience change to createDefaultEditor() so that you don't have to pass a document or a composer if you want empty default implementations. I wanted this for a long time and kept putting it off.

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

Successfully merging this pull request may close these issues.

[SuperEditor][IME] - Make IME connection global to avoid losing it on rebuilds

2 participants