diff --git a/lib/src/models/documents/nodes/leaf.dart b/lib/src/models/documents/nodes/leaf.dart index e260d624..feab276c 100644 --- a/lib/src/models/documents/nodes/leaf.dart +++ b/lib/src/models/documents/nodes/leaf.dart @@ -244,7 +244,9 @@ class Text extends Leaf { class Embed extends Leaf { Embed(Embeddable data) : super.val(data); + // Refer to https://www.fileformat.info/info/unicode/char/fffc/index.htm static const kObjectReplacementCharacter = '\uFFFC'; + static const kObjectReplacementInt = 65532; @override Node newInstance() => throw UnimplementedError(); diff --git a/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart b/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart index 8b83b23d..4982c801 100644 --- a/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart +++ b/lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.dart @@ -3,6 +3,7 @@ import 'dart:math' as math; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; +import '../../models/documents/nodes/leaf.dart'; import '../../utils/delta.dart'; import '../editor.dart'; @@ -26,16 +27,16 @@ mixin RawEditorStateSelectionDelegateMixin on EditorState } String _adjustInsertedText(String text) { - // For clip from editor, it may contain image, a.k.a 65532. + // For clip from editor, it may contain image, a.k.a 65532 or '\uFFFC'. // For clip from browser, image is directly ignore. // Here we skip image when pasting. - if (!text.codeUnits.contains(65532)) { + if (!text.codeUnits.contains(Embed.kObjectReplacementInt)) { return text; } final sb = StringBuffer(); for (var i = 0; i < text.length; i++) { - if (text.codeUnitAt(i) == 65532) { + if (text.codeUnitAt(i) == Embed.kObjectReplacementInt) { continue; } sb.write(text[i]);