-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
enhancementrich-textFeatures and bugs related to rich-text resolution.Features and bugs related to rich-text resolution.under consideration
Milestone
Description
Theme:
- Improve rich-text rendering for .NET
Goals:
- improve and unify the link & asset resolution (Support resolution of all data-* attributes of links #258 - resolution of all data-* attributes, Add ability to set custom attributes for links resolved via IContentLinkUrlResolver implementations #243 - other attributes of , Create an Asset Link URL Resolver #193 - asset URLs)
- promote ASP.NET display templates to a best practice
- strengthen the object model (
IRichTextContentwas an early attempt to achieve that but it's far from complete) - separate responsibilities and clean up the code (e.g. bug Problem deserializing one Kontent element into multiple properties of different types #257 - resolving rich-text into different types, Feat: Improve RichText element rendering experience #231 - mixing rendering and resolution approaches)
All related issues: https://github.com/Kentico/kontent-delivery-sdk-net/labels/rich-text
Supported scenarios:
- ASP.NET Display Templates
- Flattening of rich-text for search indexing purposes, etc.
- Provide ways to adjust content before rendering
Current solution:
- We offer two types of rich-text resolution:
- string-based - involves multiple types of resolvers for links, inline items, etc.
IRichTextContent-based - an object-like approach that combines hierarchical approach (for inline content items and assets) and string-based HTML rendering (for links)
Proposed solution:
- Let the
IRichTextContentbe the default type for rich-text elements and provide an additional layer for flattening it to a string.
Detailed proposition:
- Make the logic of
RichTextContentConverterpart of theModelProvider - Adjust the logic of
RichTextContentConverterto treat links as objects (=do not apply string-based resolution) => links, assets, inline content items will be treated the same - as objects - Provide resolution methods for all three type of objects
ContentLinkResolver,ContentAssetResolver,InlineContentItemResolverpublic string ResolveToString(T model)-> ability to flatten the object to stringpublic T Resolve(T model)-> ability to adjust model's properties
- Enrich the existing models for Links and Asset with a collection for supplying additional attributes (such as class or target), also add properties for some of the most common attributes (such as URL)
- Move all string-based resolution from the ModelProvider to a separate class (e.g. HtmlResolver)
- Remove the
--structuredmodeloption from the code generator and leave it true by default
Example code:
var articleResponse = await deliveryClient.GetItemAsync<Article>("on-roasts");
Article article = articleResponse.Item;
IRichTextContent richText = article.Body;
// Contains links, assets, strongly typed inline content items...already processed by `T Resolve(T model)`
// Ready to be passed to ASP.NET MVC Display Templates
IEnumerable<IRichTextBlock> blocks = richText.Blocks;
HtmlResolver resolver = new HtmlResolver(new XYZLinkResolver(), new ABCAssetResolver()...); // Or build via DI
string flattenedHtml = resolver.ToString(blocks, articleResponse.LinkedItems);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementrich-textFeatures and bugs related to rich-text resolution.Features and bugs related to rich-text resolution.under consideration