Skip to content

Commit fd66368

Browse files
author
CatHood0
committed
Chore: used old implementation for web since the new one does not work as expected
1 parent 6ceef54 commit fd66368

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/src/editor/raw_editor/input/ime/on_non_update_text.dart

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Future<void> onNonTextUpdate(
66
TextEditingDeltaNonTextUpdate nonTextUpdate,
77
QuillController controller,
88
) async {
9-
// update the selection on Windows
10-
//
119
// when typing characters with CJK IME on Windows, a non-text update is sent
1210
// with the selection range.
1311
if (Platform.isWindows) {

lib/src/editor/raw_editor/input/raw_editor_state_input_client_mixin.dart

+24
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart' show ValueNotifier, kIsWeb;
66
import 'package:flutter/material.dart' show Theme;
77
import 'package:flutter/scheduler.dart' show SchedulerBinding;
88
import 'package:flutter/services.dart';
9+
import '../../../delta/delta_diff.dart';
10+
import '../../../document/document.dart';
911
import '../raw_editor.dart';
1012
import 'diff_services.dart';
1113
import 'formatters/text_editing_delta_formatters.dart';
@@ -222,6 +224,28 @@ mixin RawEditorStateTextInputClientMixin on EditorState
222224
return;
223225
}
224226

227+
if (kIsWeb) {
228+
final effectiveLastKnownValue = _lastKnownRemoteTextEditingValue!;
229+
_lastKnownRemoteTextEditingValue = value;
230+
final oldText = effectiveLastKnownValue.text;
231+
final text = value.text;
232+
final cursorPosition = value.isComposingRangeValid
233+
? value.composing.end
234+
: value.selection.extentOffset;
235+
final diff = getDiff(oldText, text, cursorPosition);
236+
if (diff.deleted.isEmpty && diff.inserted.isEmpty) {
237+
widget.controller.updateSelection(value.selection, ChangeSource.local);
238+
} else {
239+
widget.controller.replaceText(
240+
diff.start,
241+
diff.deleted.length,
242+
diff.inserted,
243+
value.selection,
244+
);
245+
}
246+
return;
247+
}
248+
225249
final textEditingDlta = getTextEditingDelta(currentTextEditingValue, value);
226250
_lastKnownRemoteTextEditingValue = value;
227251
_apply([textEditingDlta]);

0 commit comments

Comments
 (0)