Uh oh!
There was an error while loading. Please reload this page.
[flutter_markdown] Pass parent TextStyle down to MarkdownElementBuilder.visitElementAfter - #3281
Conversation
IchordeDionysos
commented
Feb 23, 2023
@domesticmouse, how do we deal with the breaking change of the PR? |
domesticmouse
commented
Feb 23, 2023
@stuartmorgan thoughts? |
IchordeDionysos
commented
Feb 24, 2023
I've also exposed now the Which is a very hacky workaround and has it's own drawbacks 🙈 @overrideWidgetvisitElementAfter(md.Element element, TextStyle? preferredStyle) {
returnRichText(
text:TextSpan(
children: [
WidgetSpan(
child:Builder(
builder: (context) {
returnText(
innerText,
style: preferredStyle
);
},
),
),
],
),
);
}Feels free to leave any suggestions/feedback/change requests! |
stuartmorgan-g
commented
Feb 24, 2023
Does it have to be a breaking change? What about a new method with a default implementation that calls the existing method (discarding the extra parameters)? |
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
IchordeDionysos
commented
Mar 7, 2023
@stuartmorgan thanks for the hint, I've just implemented it, not sure yet about the name of the new function 🤔 /cc @domesticmouse |
IchordeDionysos
commented
Mar 21, 2023
@domesticmouse if you find the time to give this a review here that would be awesome :) It's no longer a breaking change so should be easier to merge |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
CI is failing the autoformat check, so the code will need to be autoformatted.
| ## NEXT | ||
| ## 0.6.15 | ||
| * Introduce a new `MarkdownElementBuilder.visitElementAfterWithContext()` method passing the widget `BuildContext` and |
There was a problem hiding this comment.
"Introduces"
See the CHANGELOG style guide linked from the PR descirption.
| * Introduce a new `MarkdownElementBuilder.visitElementAfterWithContext()` method passing the widget `BuildContext` and | ||
| the parent texts' `TextStyle`. | ||
| This should allow custom syntax implementations to get data from the current context, as well as properly style any |
There was a problem hiding this comment.
The changelog should just describe the change (the first sentence); it doesn't need to provide the motivation for it.
| ## 0.6.15 | ||
| * Introduce a new `MarkdownElementBuilder.visitElementAfterWithContext()` method passing the widget `BuildContext` and | ||
| the parent texts' `TextStyle`. |
| /// Called when an Element has been reached, after its children have been | ||
| /// visited. | ||
| /// | ||
| /// If [MarkdownWidget.styleSheet] has a style of this tag, will passing |
There was a problem hiding this comment.
This doesn't parse as a sentence. I'm assuming this should say something like "has a style for this tag, it will be passed as [preferredStyle]."?
| /// If [MarkdownWidget.styleSheet] has a style of this tag, will passing | ||
| /// to [preferredStyle]. | ||
| /// | ||
| /// If parent element has [TextStyle]'s set, it will be passed as |
There was a problem hiding this comment.
"has a [TextStyle] set"
stuartmorgan-g
commented
May 2, 2023
@IchordeDionysos Are you still planning on updating this based on the last round of feedback? |
stuartmorgan-g
commented
May 23, 2023
I'm making this a draft just to get it off of the review queue; please mark it as ready for review once you've had a chance to update. Thanks! |
stuartmorgan-g
commented
Jul 6, 2023
@tarrinneal to adopt, per triage meeting. |
tarrinneal
commented
Jul 7, 2023
Closing and moving changes over to #4393 as I cannot make changes to this pr. |
…er.visitElementAfter (#4393) The parent `TextStyle` should be passed down to the `MarkdownElementBuilder.visitElementAfter` method to allow custom markdown tags to override only part of the text style, e.g. the color, but keep all the rest of the styles the same. This is especially useful when trying to color markdown headers in a certain color, as the parent font size, font family, etc. all are passed down and can be kept, while only the color is overridden. This will unfortunately lead to a breaking change, due to the nature of how the class is typically used. As all usages of the class are sub-classes any change to the method schema will result in a breaking change! Enables the following flutter/flutter#105571 replaces #3281
…er.visitElementAfter (flutter#4393) The parent `TextStyle` should be passed down to the `MarkdownElementBuilder.visitElementAfter` method to allow custom markdown tags to override only part of the text style, e.g. the color, but keep all the rest of the styles the same. This is especially useful when trying to color markdown headers in a certain color, as the parent font size, font family, etc. all are passed down and can be kept, while only the color is overridden. This will unfortunately lead to a breaking change, due to the nature of how the class is typically used. As all usages of the class are sub-classes any change to the method schema will result in a breaking change! Enables the following flutter/flutter#105571 replaces flutter#3281
…er.visitElementAfter (flutter#4393) The parent `TextStyle` should be passed down to the `MarkdownElementBuilder.visitElementAfter` method to allow custom markdown tags to override only part of the text style, e.g. the color, but keep all the rest of the styles the same. This is especially useful when trying to color markdown headers in a certain color, as the parent font size, font family, etc. all are passed down and can be kept, while only the color is overridden. This will unfortunately lead to a breaking change, due to the nature of how the class is typically used. As all usages of the class are sub-classes any change to the method schema will result in a breaking change! Enables the following flutter/flutter#105571 replaces flutter#3281
The parent
TextStyleshould be passed down to theMarkdownElementBuilder.visitElementAftermethod to allow custom markdown tags to override only part of the text style, e.g. the color, but keep all the rest of the styles the same.This is especially useful when trying to color markdown headers in a certain color, as the parent font size, font family, etc. all are passed down and can be kept, while only the color is overridden.
This will unfortunately lead to a breaking change, due to the nature of how the class is typically used. As all usages of the class are sub-classes any change to the method schema will result in a breaking change!
Enables the following flutter/flutter#105571
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.