Adding support for mobile #242
Replies: 4 comments 9 replies
-
This comment will primarily focus on the Document Editing using the soft keyboard without getting into the specialized APIs. I'll write a separate comment later about the rest. Please let me know if anything isn't clear. Soft Keyboard EditingObjectives:
Background:Before diving into the details, it's important to mention the following: Using
Similarly, Detecting Backspace: This issue originates from In this use case, the zwsp can be used in the following manner:
Dealing with Newlines:
Overview:Despite the limitation of having a single connection to
In order to achieve both objectives, the interactor can be designed to operate in two different modes based on the type of selected node(s):
Each mode is discussed in more details below. Insert/Delete mode onlyIn short:
In this mode, when the selection isn't a single TextNode, the soft keyboard is treated as a regular keyboard. This can be done by reseting the remote * Technically, the value isn't empty since it'll contain the zwsp character with a selection offset = 1 which assists in detecting the backspace event.
Text Editing ModeIn short:
In this mode, the remote The main challenge here is to sync any remote changes to the selected TextNode. This is a challenge because the remote value can have multiple changes in a single event. For instance, when a user selects an auto-correct suggestion, the In order to reflect the remote changes into the selected TextNode, three steps are taken:
In the experiment mentioned in the proposal, a Dart package implementation of Google's diff-patch-match library was used to compute the difference between the remote value and the selected Known Issues with this approach:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
@osaxma do you happen to know how to accomplish the magnifying glass? I started looking into that back in 2018 but then iOS announced they were removing it so I stopped. I think it might use some kind of |
Beta Was this translation helpful? Give feedback.
-
There is a good reason to use It would also be good to use Edit: I think this is the flutter umbrella issue for it. |
Beta Was this translation helpful? Give feedback.
-
Super Editor is committed to delivering document rendering and editing on all platforms, including iOS and Android. This proposal outlines some of the challenges associated with mobile support and how Super Editor might overcome those challenges.
Why Super Editor doesn't support mobile
The primary issue is mobile text input. All text input on iOS and Android devices begins at the keyboard, flows to the IME service, is dispatched to the active application, is piped from the mobile SDK side over to the Flutter/Dart side, and is exposed in Flutter via
TextInput
. To handle text input requests fromTextInput
, one must register as aTextInputClient
. Only a singleTextInputClient
can register to receive information fromTextInput
at any given moment.The current implementation of Super Editor does not use
TextInput
at all. Instead, Super Editor listens for every key press on the user's keyboard with aRawKeyboardListener
and then maps those key presses to an associated editor action. This approach works reasonably well in desktop/web environments. However,RawKeyboardListener
does not function at all on mobile. Despite the fact that the user taps on something that looks like a keyboard on their phone, it isn't really a keyboard, and it doesn't expose individual keypresses as one might expect. Mobile devices intercept keys that the user presses on the keyboard and, possibly, alters the content. Here are some examples to consider:On mobile, text entry requires a back-and-forth conversation between the app and the operating system, because your keyboard is engaged in a back-and-forth conversation with you.
TextInput
andTextInputClient
are the interfaces that Flutter exposes to engage in this 2-way conversation.Challenges to fulfill the
TextInputClient
APIThe greatest challenge, and risk with utilizing the
TextInputClient
API is that we give up a lot of control.Narrow and Specialized APIs
All things considered, the
TextInput
/TextInputConnection
/TextInputClient
APIs are relatively narrow, and some of the APIs are quite specialized. Here is an example of a very specialized API:https://api.flutter.dev/flutter/services/TextInputConnection/setCaretRect.html
Will all
TextInput
requirements make sense for Super Editor, and will Super Editor be able to accomplish all desired edits when using the availableTextInput
APIs?Cross-Boundary Edits
The
TextInput
APIs were designed in a world with independent text fields. In Super Editor, the user might select across part of a paragraph, and across multiple list items, at the same time.Will
TextInput
APIs work as expected when a selection spans multiple text content blocks?Multi-Media Editing
Unlike a typical mobile text field, Super Editor displays images, horizontal rules, and any other desired content within a single document.
Will
TextInput
APIs get in the way of Super Editor's multimedia editing capabilities?Existing Work
@osaxma has experimented with replacing the standard Super Editor interaction system with
TextInputClient
.Here is a demo:
super_editor_mobile_recording_01.mp4
The initial results look promising.
WORK IN PROGRESS
Beta Was this translation helpful? Give feedback.
All reactions