fix: do not wrap the inline math equation in a new line (#7035)

* fix: do not wrap the inline math equation in new line

* test: inline equation text and inline text align
This commit is contained in:
Lucas 2024-12-24 09:39:24 +08:00 committed by GitHub
parent 20bff9003e
commit d7bda10e6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 7 deletions

View File

@ -147,7 +147,21 @@ void main() {
const text = 'Hello World';
await tester.ime.insertText(text);
expect(find.textContaining(text, findRichText: true), findsOneWidget);
final inlineText = find.textContaining(text, findRichText: true);
expect(inlineText, findsOneWidget);
// the text should be in the same line with the math equation
final inlineMathEquationPosition = tester.getRect(inlineMathEquation);
final textPosition = tester.getRect(inlineText);
// allow 5px difference
expect(
(textPosition.top - inlineMathEquationPosition.top).abs(),
lessThan(5),
);
expect(
(textPosition.bottom - inlineMathEquationPosition.bottom).abs(),
lessThan(5),
);
});
});
}

View File

@ -80,20 +80,18 @@ class _InlineMathEquationState extends State<InlineMathEquation> {
mathFontOptions: const FontOptions(
fontShape: FontStyle.italic,
),
fontSize: 14.0,
fontSize: widget.textStyle?.fontSize ?? 14.0,
color: widget.textStyle?.color ?? theme.colorScheme.onSurface,
),
onErrorFallback: (errmsg) {
return FlowyText(
errmsg.message,
fontSize: widget.textStyle?.fontSize ?? 14.0,
color: widget.textStyle?.color ?? theme.colorScheme.onSurface,
);
},
);
return Row(
children: [
longEq,
],
);
return longEq;
}
}

View File

@ -363,6 +363,7 @@ class EditorStyleCustomizer {
if (formula is String) {
return WidgetSpan(
style: after.style,
alignment: PlaceholderAlignment.middle,
child: InlineMathEquation(
node: node,
index: index,