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