mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-18 08:20:12 +08:00
fix RichTextField text delete
Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
@@ -652,6 +652,9 @@ class RichTextEditingController extends TextEditingController {
|
||||
}
|
||||
|
||||
case TextEditingDeltaNonTextUpdate e:
|
||||
if (!_isSelectionValid(e.selection, items.lastOrNull?.range.end ?? 0)) {
|
||||
return;
|
||||
}
|
||||
newSelection = e.selection;
|
||||
if (newSelection.isCollapsed) {
|
||||
final newPos = dragOffset(newSelection.base);
|
||||
@@ -684,6 +687,10 @@ class RichTextEditingController extends TextEditingController {
|
||||
}
|
||||
}
|
||||
|
||||
static bool _isSelectionValid(TextSelection selection, int length) {
|
||||
return selection.start <= length && selection.end <= length;
|
||||
}
|
||||
|
||||
TextStyle? composingStyle;
|
||||
TextStyle? richStyle;
|
||||
|
||||
|
||||
@@ -3568,10 +3568,12 @@ class EditableTextState extends State<EditableText>
|
||||
remoteValue = delta.apply(remoteValue);
|
||||
}
|
||||
|
||||
final plainText = widget.controller.plainText;
|
||||
final composing = textEditingDeltas.last.composing;
|
||||
final newValue = TextEditingValue(
|
||||
text: widget.controller.plainText,
|
||||
text: plainText,
|
||||
selection: widget.controller.newSelection,
|
||||
composing: textEditingDeltas.last.composing,
|
||||
composing: composing.end <= plainText.length ? composing : .empty,
|
||||
);
|
||||
|
||||
updateEditingValue(newValue, remoteValue: remoteValue);
|
||||
|
||||
Reference in New Issue
Block a user