default color, Document.fromDelta, fix isItCut null check

pull/123/head
Xun Gong 4 years ago
parent 60431235bb
commit e8a38a48fa
  1. 5
      lib/models/documents/document.dart
  2. 3
      lib/widgets/default_styles.dart
  3. 6
      lib/widgets/raw_editor.dart
  4. 7
      lib/widgets/text_line.dart

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

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

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

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

Loading…
Cancel
Save