default color, Document.fromDelta, fix isItCut null check (#123)

* default color, Document.fromDelta, fix isItCut null check

* fix merge conflict
pull/132/head
hyouuu 4 years ago committed by GitHub
parent f0dcca00d9
commit 047d0f729b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      lib/models/documents/document.dart
  2. 3
      lib/widgets/default_styles.dart
  3. 6
      lib/widgets/raw_editor.dart
  4. 9
      lib/widgets/text_line.dart

@ -43,6 +43,10 @@ class Document {
_loadDocument(_delta);
}
Document.fromDelta(Delta delta) : _delta = delta {
_loadDocument(delta);
}
Delta insert(int index, Object? data) {
assert(index >= 0);
assert(data is String || data is Embeddable);

@ -52,6 +52,7 @@ class DefaultStyles {
final TextStyle? sizeLarge; // 'large'
final TextStyle? sizeHuge; // 'huge'
final TextStyle? link;
final Color? color;
final DefaultTextBlockStyle? placeHolder;
final DefaultTextBlockStyle? lists;
final DefaultTextBlockStyle? quote;
@ -69,6 +70,7 @@ class DefaultStyles {
this.underline,
this.strikeThrough,
this.link,
this.color,
this.placeHolder,
this.lists,
this.quote,
@ -197,6 +199,7 @@ class DefaultStyles {
underline: other.underline ?? underline,
strikeThrough: other.strikeThrough ?? strikeThrough,
link: other.link ?? link,
color: other.color ?? color,
placeHolder: other.placeHolder ?? placeHolder,
lists: other.lists ?? lists,
quote: other.quote ?? quote,

@ -1087,8 +1087,10 @@ class RawEditorState extends EditorState
}
Future<bool> __isItCut(TextEditingValue value) async {
final ClipboardData data = await (Clipboard.getData(Clipboard.kTextPlain)
as FutureOr<ClipboardData>);
ClipboardData? data = await Clipboard.getData(Clipboard.kTextPlain);
if (data == null) {
return false;
}
return textEditingValue.text.length - value.text.length ==
data.text!.length;
}

@ -165,8 +165,13 @@ class TextLine extends StatelessWidget {
Attribute? color = textNode.style.attributes[Attribute.color.key];
if (color != null && color.value != null) {
final textColor = stringToColor(color.value);
res = res.merge(TextStyle(color: textColor));
var textColor = defaultStyles.color;
if (color.value is String) {
textColor = stringToColor(color.value);
}
if (textColor != null) {
res = res.merge(TextStyle(color: textColor));
}
}
Attribute? background = textNode.style.attributes[Attribute.background.key];

Loading…
Cancel
Save