-
Notifications
You must be signed in to change notification settings - Fork 6k
TextEditingDelta Support for the Web #28527
Changes from 1 commit
86885dd
9ef2c43
b93b043
d3201a1
9f99a66
8d69317
3ba145c
728055a
efbdf5b
1c330f3
0dd249a
37b757e
fd1396f
cb6ef96
4f610e0
f772bf1
f6e4d32
704d4f9
577aa59
0dcf1f2
a2e5525
95fe97b
5921215
a2a8b9d
1fbab86
928f186
03d63c3
51eabc8
125580e
26668cb
5a33dbf
e47a3ed
04020c2
13ca351
73c1411
be578c3
2df95b0
5e2b294
ac3407b
fa1d886
6ced401
15868f6
059fe74
26e676a
9196226
38bc244
cc0bb16
b7a91da
a600e9e
98fad47
786a528
3f260ce
b9db35a
41765f8
8ff4f2d
f4a858a
cbb6b6b
b596600
5a8a5f7
6645a0b
da90e99
6217ea9
b5e0b55
7a5aff9
c4c9cf6
9d97c88
0fc279d
fc823e9
6bf2ca7
acbc0de
7722380
0bb7f30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -468,6 +468,23 @@ class TextEditingDeltaState { | |
| this.composingExtent = -1, | ||
|
||
| }); | ||
|
|
||
| /// Infers the correct delta values based on information from the new editing state | ||
| /// and the last editing state. | ||
| /// | ||
| /// For a deletion we calculate the length of the deleted text by comparing the new | ||
| /// and last editing states. We subtract this from the deltaEnd that we set when beforeinput | ||
| /// was fired to determine out deltaStart. | ||
|
||
| /// | ||
| /// For a replacement at a selection we set the deltaStart to be the beginning of the selection | ||
| /// from the last editing state. | ||
| /// | ||
| /// For the composing region we check if a composing range was captured by the compositionupdate event, | ||
| /// we have a non empty deltaText, and that we did not have an active selection. An active selection | ||
| /// would mean we are not composing. | ||
|
||
| /// | ||
| /// We then verify that the delta we collected results in the text contained within the new editing state | ||
| /// when applied to the last editing state. If it is not then we use our new editing state as the source of truth, | ||
| /// and use regex to find the correct deltaStart and deltaEnd. | ||
| static TextEditingDeltaState inferDeltaState(EditingState newEditingState, EditingState? lastEditingState, TextEditingDeltaState lastTextEditingDeltaState) { | ||
| final TextEditingDeltaState newTextEditingDeltaState = lastTextEditingDeltaState.copyWith(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for doing this, I think it's comforting to know there's nothing fancy going on with modifying the inputs when I see this copy. |
||
| final bool previousSelectionWasCollapsed = lastEditingState?.baseOffset == lastEditingState?.extentOffset; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are the names slightly different than the frameworks' TextDelta, is it to match how the browser's events present the information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried to match the
EditingStateparameters in this case.