Apply only inline styles for inline (#1539)

Co-authored-by: Miroslav Sobotka <miroslav@T0326.local>
pull/1547/head
Miroslav Sobotka 1 year ago committed by GitHub
parent 792cb4eb19
commit f01f935907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      lib/src/models/documents/nodes/line.dart

@ -317,6 +317,14 @@ base class Line extends Container<Leaf?> {
void _insertSafe(int index, Object data, Style? style) { void _insertSafe(int index, Object data, Style? style) {
assert(index == 0 || (index > 0 && index < length)); assert(index == 0 || (index > 0 && index < length));
var inlineStyles = style;
if (style != null) {
final nonInlineStyles =
style.attributes.values.where((v) => !v.isInline).toSet();
final styleToApply = style.removeAll(nonInlineStyles);
inlineStyles = styleToApply;
}
if (data is String) { if (data is String) {
assert(!data.contains('\n')); assert(!data.contains('\n'));
if (data.isEmpty) { if (data.isEmpty) {
@ -327,10 +335,10 @@ base class Line extends Container<Leaf?> {
if (isEmpty) { if (isEmpty) {
final child = Leaf(data); final child = Leaf(data);
add(child); add(child);
child.format(style); child.format(inlineStyles);
} else { } else {
final result = queryChild(index, true); final result = queryChild(index, true);
result.node!.insert(result.offset, data, style); result.node!.insert(result.offset, data, inlineStyles);
} }
} }

Loading…
Cancel
Save