fix: Resolve textStyle for formula embed

pull/1989/head
Shubham Gupta 10 months ago
parent 376067a52a
commit e405612a61
No known key found for this signature in database
GPG Key ID: CC2235E241BB8F28
  1. 27
      lib/src/widgets/quill/text_line.dart

@ -178,7 +178,7 @@ class _TextLineState extends State<TextLine> {
} }
InlineSpan _getTextSpanForWholeLine() { InlineSpan _getTextSpanForWholeLine() {
final lineStyle = _getLineStyle(widget.styles); var lineStyle = _getLineStyle(widget.styles);
if (!widget.line.hasEmbed) { if (!widget.line.hasEmbed) {
return _buildTextSpan(widget.styles, widget.line.children, lineStyle); return _buildTextSpan(widget.styles, widget.line.children, lineStyle);
} }
@ -198,6 +198,16 @@ class _TextLineState extends State<TextLine> {
child = Embed(CustomBlockEmbed.fromJsonString(child.value.data)) child = Embed(CustomBlockEmbed.fromJsonString(child.value.data))
..applyStyle(child.style); ..applyStyle(child.style);
} }
if (child.value.type == BlockEmbed.formulaType) {
lineStyle = lineStyle.merge(_getInlineTextStyle(
child.style,
widget.styles,
widget.line.style,
false,
));
}
final embedBuilder = widget.embedBuilder(child); final embedBuilder = widget.embedBuilder(child);
final embedWidget = EmbedProxy( final embedWidget = EmbedProxy(
embedBuilder.build( embedBuilder.build(
@ -378,7 +388,7 @@ class _TextLineState extends State<TextLine> {
nodeStyle.attributes[Attribute.link.key]!.value != null; nodeStyle.attributes[Attribute.link.key]!.value != null;
final style = _getInlineTextStyle( final style = _getInlineTextStyle(
textNode, defaultStyles, nodeStyle, lineStyle, isLink); nodeStyle, defaultStyles, lineStyle, isLink);
if (widget.controller.configurations.requireScriptFontFeatures == false && if (widget.controller.configurations.requireScriptFontFeatures == false &&
textNode.value.isNotEmpty) { textNode.value.isNotEmpty) {
@ -401,13 +411,12 @@ class _TextLineState extends State<TextLine> {
} }
TextStyle _getInlineTextStyle( TextStyle _getInlineTextStyle(
leaf.QuillText textNode,
DefaultStyles defaultStyles,
Style nodeStyle, Style nodeStyle,
DefaultStyles defaultStyles,
Style lineStyle, Style lineStyle,
bool isLink) { bool isLink) {
var res = const TextStyle(); // This is inline text style var res = const TextStyle(); // This is inline text style
final color = textNode.style.attributes[Attribute.color.key]; final color = nodeStyle.attributes[Attribute.color.key];
<String, TextStyle?>{ <String, TextStyle?>{
Attribute.bold.key: defaultStyles.bold, Attribute.bold.key: defaultStyles.bold,
@ -446,12 +455,12 @@ class _TextLineState extends State<TextLine> {
res = _merge(res, defaultStyles.inlineCode!.styleFor(lineStyle)); res = _merge(res, defaultStyles.inlineCode!.styleFor(lineStyle));
} }
final font = textNode.style.attributes[Attribute.font.key]; final font = nodeStyle.attributes[Attribute.font.key];
if (font != null && font.value != null) { if (font != null && font.value != null) {
res = res.merge(TextStyle(fontFamily: font.value)); res = res.merge(TextStyle(fontFamily: font.value));
} }
final size = textNode.style.attributes[Attribute.size.key]; final size = nodeStyle.attributes[Attribute.size.key];
if (size != null && size.value != null) { if (size != null && size.value != null) {
switch (size.value) { switch (size.value) {
case 'small': case 'small':
@ -482,13 +491,13 @@ class _TextLineState extends State<TextLine> {
} }
} }
final background = textNode.style.attributes[Attribute.background.key]; final background = nodeStyle.attributes[Attribute.background.key];
if (background != null && background.value != null) { if (background != null && background.value != null) {
final backgroundColor = stringToColor(background.value); final backgroundColor = stringToColor(background.value);
res = res.merge(TextStyle(backgroundColor: backgroundColor)); res = res.merge(TextStyle(backgroundColor: backgroundColor));
} }
res = _applyCustomAttributes(res, textNode.style.attributes); res = _applyCustomAttributes(res, nodeStyle.attributes);
return res; return res;
} }

Loading…
Cancel
Save