fix update vote

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-07-04 23:17:32 +08:00
parent 83459df3b7
commit 0f1665bf08
2 changed files with 9 additions and 7 deletions

View File

@@ -327,7 +327,7 @@ abstract class CommonRichTextPubPageState<T extends CommonRichTextPubPage>
editController
..syncRichText(delta)
..value = newValue.copyWith(selection: editController.newSelection);
..value = newValue;
} else {
editController.value = TextEditingValue(
text: text,

View File

@@ -564,11 +564,15 @@ class _CreateDynPanelState extends CommonRichTextPubPageState<CreateDynPanel> {
);
if (voteInfo != null) {
if (voteItem != null) {
final range = voteItem.range;
final text = ' ${voteInfo.title} ';
final selection = TextSelection.collapsed(
offset: range.start + text.length);
final delta = RichTextEditingDeltaReplacement(
oldText: editController.text,
replacementText: ' ${voteInfo.title} ',
replacedRange: voteItem.range,
selection: editController.selection,
replacementText: text,
replacedRange: range,
selection: selection,
composing: TextRange.empty,
type: RichTextType.vote,
id: voteInfo.voteId.toString(),
@@ -577,9 +581,7 @@ class _CreateDynPanelState extends CommonRichTextPubPageState<CreateDynPanel> {
final newValue = delta.apply(editController.value);
editController
..syncRichText(delta)
..value = newValue.copyWith(
selection: editController.newSelection,
);
..value = newValue;
} else {
onInsertText(
'我发起了一个投票',