ignore color:inherit and convert double to int for level

pull/830/head
li3317 3 years ago
parent c59d37878f
commit c40faa47e2
  1. 5
      lib/src/utils/color.dart
  2. 7
      lib/src/widgets/raw_editor.dart

@ -112,6 +112,11 @@ Color stringToColor(String? s) {
int.parse(arr[2]), double.parse(arr[3]));
}
// TODO: take care of "color": "inherit"
if (s.startsWith('inherit')) {
return Colors.black;
}
if (!s.startsWith('#')) {
throw 'Color code not supported';
}

@ -504,7 +504,12 @@ class RawEditorState extends EditorState
Line line, DefaultStyles? defaultStyles) {
final attrs = line.style.attributes;
if (attrs.containsKey(Attribute.header.key)) {
final int? level = attrs[Attribute.header.key]!.value;
int level;
if (attrs[Attribute.header.key]!.value is double) {
level = attrs[Attribute.header.key]!.value.toInt();
} else {
level = attrs[Attribute.header.key]!.value;
}
switch (level) {
case 1:
return defaultStyles!.h1!.verticalSpacing;

Loading…
Cancel
Save