Refer 65532 to class Embed

pull/602/head
X Code 3 years ago
parent 29c8332dc8
commit d9c7831497
  1. 2
      lib/src/models/documents/nodes/leaf.dart
  2. 7
      lib/src/widgets/raw_editor/raw_editor_state_selection_delegate_mixin.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();

@ -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]);

Loading…
Cancel
Save