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 editController
..syncRichText(delta) ..syncRichText(delta)
..value = newValue.copyWith(selection: editController.newSelection); ..value = newValue;
} else { } else {
editController.value = TextEditingValue( editController.value = TextEditingValue(
text: text, text: text,

View File

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