feat(portable_text): per-subtree config via PortableTextTheme - #1
Closed
Ortes wants to merge 2 commits into
Closed
Conversation
Add PortableTextConfig.of(context) + copyWith and a PortableTextTheme InheritedWidget (plus PortableTextStyleOverride) so a subtree can override the rendering config without mutating the global shared instance. Render paths resolve the config from context, falling back to shared. Mark deserialization stays on the context-free shared registry.
…pendency use Lets the package resolve standalone when consumed as a git/path dependency outside the vyuh workspace. Fork-only; not intended for upstream.
Author
|
Superseded by the upstream contribution vyuh-tech#57. A fork-internal PR isn't the point — the feature goes upstream. The Fullphysio app consumes the change via a pinned git override on the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the ability to render different Portable Text subtrees with different configurations, instead of every widget sharing the single global
PortableTextConfig.shared.This mirrors Flutter's own
Themepattern:PortableTextConfig.of(context)— resolves the nearest config from the tree, falling back tosharedwhen none is present (likeTheme.of/ThemeData.fallback).PortableTextConfig.copyWith(...)— returns a derived config. Map fields (styles,blocks,blockContainers,markDefs) are merged (provided keys win, the rest are kept); scalars are replaced. Deliberately differs fromThemeData.copyWithbecause these maps are additive registries.PortableTextTheme— anInheritedWidgetthat supplies a config to its subtree.PortableTextStyleOverride— ergonomic helper: pass per-styleTextStyle → TextStyledeltas (e.g.{'normal': (s) => s.copyWith(fontSize: s.fontSize! - 2)}); it wraps the inherited builders internally (no recursion, no boilerplate).The render paths (
PortableTextBlock,defaultListBuilder,defaultBulletRenderer) now readPortableTextConfig.of(context)instead of.shareddirectly.Backward compatibility
Fully non-breaking. With no
PortableTextThemeancestor,of(context)returnsshared, so existing apps render identically. The constructor is made public so additional configs can be created.Note on mark deserialization
_markDefsFromJsonruns at JSON-parse time with noBuildContext, so it intentionally keeps reading the context-freeshared.markDefsregistry. Mark styling is still resolved per subtree at render time. This is documented inline.Commits
feat— the per-subtree config support (the actual change; upstream-ready).chore— dropsresolution: workspaceso the package resolves standalone when consumed as a git/path dependency outside the vyuh workspace. Fork-only — should not be merged upstream.