unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
9.09k stars 739 forks source link

Support for `RichTextBlock` #81

Open juepiezhongren opened 6 years ago

jeromelaban commented 6 years ago

Markdown viewer from the windows community toolkit requires this.

artemious7 commented 5 years ago

I need to arrange UIElements in the same way as text (being able to set TextAlignment to Left, Center, Justify and to select text). In UWP I would use RichTextBlock and InlineUIContainers for this. While it's not there in Uno, can you suggest any workaround, please?

carldebilly commented 5 years ago

You can simply use the Inlines of a TextBlock... But the enlignment is global to the TextBlock, not specific by Inline... Is it what you want?

davidjohnoliver commented 5 years ago

@artemious7 Not sure to understand your use case very well, but it sounds like you could author a custom Panel to do this.

YBAZAN commented 4 years ago

I don't know if this issue is still relevant as this because RichTextBlock is implemented, but InlineUIContainer still no.

davidjohnoliver commented 4 years ago

@YBAZAN RichTextBlock isn't implemented yet, but it was incorrectly showing up as implemented because it was missing the appropriate attribute. https://github.com/unoplatform/uno/pull/3873

YBAZAN commented 4 years ago

Thank you @davidjohnoliver for the clarification.

So, if I understand correctly, that means that an app using those controls (RichTextBlock, RichEditBox, and other not yet implemented ones) won't run in others platforms than UWP, right ?

If so, do you have any roadmap that could help us to visualize the remaining work ?

davidjohnoliver commented 4 years ago

Strictly speaking, apps using unimplemented APIs will compile and run, but creating those controls will throw a runtime exception (though this can be downgraded to an error message). And obviously the controls won't display anything.

RichTextBlock and RichEditBox don't seem to be planned for the short-term, but if you can upvote (👍 ) the issues, that'll help us prioritize the work.

YBAZAN commented 4 years ago

I guess it's a huge work to support so many platforms. As the same time, Microsoft continues to work on its framework, so it's like an endless work...

As I look the recent PR, seems to be more bug fixes than new stuff (like implementation of controls for example). It could be a brake in the adoption of Uno for professional projects. And behavior issues may affect less than having parts of the interface not showing at all, especially if no release is planned for those missing controls.

By the way, thank very much for your hard work on this wonderful platform. I really enjoy it !!

artemious7 commented 4 years ago

I guess it's a huge work to support so many platforms. As the same time, Microsoft continues to work on its framework, so it's like an endless work...

As I look the recent PR, seems to be more bug fixes than new stuff (like implementation of controls for example). It could be a brake in the adoption of Uno for professional projects. And behavior issues may affect less than having parts of the interface not showing at all, especially if no release is planned for those missing controls.

By the way, thank very much for your hard work on this wonderful platform. I really enjoy it !!

We can still do it the good old way: native controls for each platform our app supports. And if we do, we can share results with the community, even contribute to Uno Platform

sigmarsson commented 3 years ago

Perhaps RichTextBlock isn't essential if one could implement an HTML based solution with WebView2 -on heads applicable - and your own custom control. I would be personaly leaning much further into an HTML approach.

sharpninja commented 1 year ago

This is really important to me.

michael-hawker commented 1 year ago

Markdown viewer from the windows community toolkit requires this.

We have a new version folks are working on in WCT Labs, it still uses RichTextBlock. https://github.com/CommunityToolkit/Labs-Windows/pull/480

Perhaps RichTextBlock isn't essential if one could implement an HTML based solution with WebView2 -on heads applicable - and your own custom control. I would be personaly leaning much further into an HTML approach.

We have had success with WASM at least of relatively easily abstracting to use a web library for something we displayed with RichTextBlock on Windows. We did this for our new Sample App in the Windows Community Toolkit where we use the MarkdownTextBlock on Windows on top of RichTextBlock, but then on WASM instead just inject the HTML from Markdig into the page:

https://github.com/CommunityToolkit/Tooling-Windows-Submodule/blob/main/CommunityToolkit.App.Shared/Renderers/Markdown/MarkdownTextBlock.cs

ShankarBUS commented 2 weeks ago

@michael-hawker, I tried to circumvent the unavailability of RichTextBlock in Uno by simply using a TextBlock for rendering Inlines (ParagraphBlock will be rendered into a TextBlock) and when there is a need to render blocks such as quote, table or lists, it will just use either a TextBlock or StackPanel containing TextBlocks based on the inlines. And for InlineCode and Images, it will use a StackPanel with a Border with the code and an Image control respectively (a messy hack tbh).

TextBlock and Inlines are implemented in Uno (AFAIK?) in all supported platforms. This might be a temporary solution for this, till they implement a proper RichTextBlock.

The following code is a modified version of the MarkdownTextBlock in CommunityToolkit.Labs.WinUI:

https://github.com/symptum/Symptum/tree/main/src/Symptum.UI/Markdown

I would love to have Markdown rendering support in Uno. Hope you can consider this as a workaround.

MartinZikmund commented 1 week ago

@ShankarBUS pretty cool solution!