Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TextBlock inlines support #6953

Merged
merged 2 commits into from
Feb 24, 2022

Conversation

Gillibald
Copy link
Contributor

@Gillibald Gillibald commented Nov 16, 2021

What does the pull request do?

Screenshot 2021-11-16 075812
Screenshot 2021-11-16 075854

With updated XamlIl

Screenshot 2021-12-02 082430

<TextBlock Margin="10" TextWrapping="Wrap">
	This <Span FontWeight="Bold">is</Span> a
	<Span Background="Silver" Foreground="Maroon">TextBlock</Span>
	with <Span TextDecorations="Underline">several</Span>
	<Span FontStyle="Italic">Span</Span> elements,
	<Span Foreground="Blue">
		using a <Bold>variety</Bold> of <Italic>styles</Italic>
	</Span>.
</TextBlock>

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

Fixes #3737 #2619

@Gillibald Gillibald force-pushed the feature/textBlockInlines branch 2 times, most recently from e941c1e to 0e398a1 Compare November 16, 2021 08:30
Copy link
Member

@jmacato jmacato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some nits but lgtm! :D

src/Avalonia.Controls/Documents/Bold.cs Show resolved Hide resolved
src/Avalonia.Controls/Documents/Inline.cs Outdated Show resolved Hide resolved
src/Avalonia.Controls/Documents/Italic.cs Show resolved Hide resolved
src/Avalonia.Controls/Documents/Span.cs Show resolved Hide resolved
src/Avalonia.Controls/Documents/Underline.cs Show resolved Hide resolved
@robloo
Copy link
Contributor

robloo commented Nov 16, 2021

Question: With this level of support for text formatting do you think it's feasible to start looking at RichTextBox (from WPF) or MarkdownTextBox (from UWP toolkit) control ports? Not asking you to look into it, just do you think it's going to be possible soon?

It would be great to see those controls eventually at least in 3rd party libraries to start and it seems with all your text improvements it's getting close to possible.

@Gillibald
Copy link
Contributor Author

Gillibald commented Nov 16, 2021

To be able to port RichtTextBox we need #5461 that introduces all the required infrastructure.

MarkdownTextBlock needs InlineUIContainer support. That will be added soon.

src/Avalonia.Controls/Documents/TextElement.cs Outdated Show resolved Hide resolved
/// <summary>
/// Raises the <see cref="Invalidate"/> event.
/// </summary>
protected void Invalidate() => Invalidated?.Invoke(this, EventArgs.Empty);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A system of Debouncing could be implemented, so that when there are changes in rapid succession the event is called only once.

@Gillibald Gillibald force-pushed the feature/textBlockInlines branch from f2c24f2 to 4b89cb6 Compare November 17, 2021 14:49
@Gillibald Gillibald changed the title [WIP] Add TextBlock inlines support Add TextBlock inlines support Nov 17, 2021
@Mikolaytis
Copy link
Contributor

Mikolaytis commented Nov 24, 2021

Good job, @Gillibald ! Awesome news! I will merge this to our app fork and will provide a feedback from our QA Team in a week or so.

@Gillibald
Copy link
Contributor Author

Gillibald commented Nov 24, 2021

Please note that XamlX needs to be updated to deal with inlines properly.

@Mikolaytis
Copy link
Contributor

In WPF if there is any empty space between Run tags - space is added between inlines.
This PR is missing this, is it intended? To make a space between inlines you have to create a trash Run with space in Text.

@Mikolaytis
Copy link
Contributor

Foreground property of Run is not working with DynamicResourceExtension to SolidColorBrush. Foreground in this case are now acquired from parent TextBlock.

@robloo
Copy link
Contributor

robloo commented Dec 2, 2021

In WPF if there is any empty space between Run tags - space is added between inlines.

#2619

@Gillibald
Copy link
Contributor Author

I will add some unit tests that use Static/DynamicResource for some inlines properties.

@Mikolaytis
Copy link
Contributor

Mikolaytis commented Dec 10, 2021

@Gillibald I want to merge your fixes and test them but auto-build is failed. so I'm a bit scarry to invest a time into this.

@Gillibald
Copy link
Contributor Author

The build fails because of one Xaml test that is failing. So it should not affect you.

@Mikolaytis
Copy link
Contributor

Mikolaytis commented Dec 13, 2021

after merging this into avalonia master - getting crash in control catalog.
here is repro. REason - new hamburger menu...
Screenshot 2021-12-14 at 00 53 28
I fixed this by commenting transitions in a file. Looks like an error in xamlX
We don't use transitions yet so this is not an issue at all for us.

@Mikolaytis
Copy link
Contributor

Mikolaytis commented Dec 14, 2021

Also here is another bug: xamlil counts comment as content. produces this error (see error msg in the bottom of the screenshot):
Screenshot 2021-12-14 at 04 47 56
to fix this I've removed the comment.

@Gillibald
Copy link
Contributor Author

Thanks for testing. So we need to add a test for comments and get transitions working.

@Gillibald Gillibald force-pushed the feature/textBlockInlines branch from 0536858 to eb5ad8e Compare December 15, 2021 15:04
@Gillibald
Copy link
Contributor Author

@Mikolaytis Everything should work now

@Mikolaytis
Copy link
Contributor

@Gillibald one more thing is broken We've found - TextAlignment=Right on a textbox now broken. Text Measure looks like returning a 0 width.

@Mikolaytis
Copy link
Contributor

also we're still testing and it's possible we will find something more this year.

@Gillibald
Copy link
Contributor Author

@Gillibald one more thing is broken We've found - TextAlignment=Right on a textbox now broken. Text Measure looks like returning a 0 width.

I wonder how that is possible. Will investigate.

@Gillibald Gillibald force-pushed the feature/textBlockInlines branch from 1862494 to e190f91 Compare February 1, 2022 15:04
@Takoooooo Takoooooo added this to the 11.0 milestone Feb 21, 2022
@Gillibald Gillibald force-pushed the feature/textBlockInlines branch from eec8721 to 9e2773e Compare February 22, 2022 18:17
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 0.10.999-cibuild0018894-beta. (feed url: https://nuget.avaloniaui.net/repository/avalonia-all/index.json) [PRBUILDID]

@Gillibald Gillibald force-pushed the feature/textBlockInlines branch from 52d78df to 95769ff Compare February 23, 2022 14:01
@Gillibald Gillibald requested a review from a team February 23, 2022 14:09
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 0.10.999-cibuild0018907-beta. (feed url: https://nuget.avaloniaui.net/repository/avalonia-all/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 0.10.999-cibuild0018910-beta. (feed url: https://nuget.avaloniaui.net/repository/avalonia-all/index.json) [PRBUILDID]

1 similar comment
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 0.10.999-cibuild0018910-beta. (feed url: https://nuget.avaloniaui.net/repository/avalonia-all/index.json) [PRBUILDID]

@Gillibald Gillibald enabled auto-merge February 24, 2022 16:10
@Gillibald Gillibald dismissed jmacato’s stale review February 24, 2022 16:11

Not available at the moment

@Gillibald Gillibald merged commit 237a9a4 into AvaloniaUI:master Feb 24, 2022
@Gillibald Gillibald deleted the feature/textBlockInlines branch February 24, 2022 16:11
@Whiletru3
Copy link
Contributor

Is there a chance to backport this in 0.10.x ?
Is there a timeline for 0.11 ? :)

@maxkatz6
Copy link
Member

maxkatz6 commented Jun 3, 2022

Is there a chance to backport this in 0.10.x ?

No, too many breaking changes to get this work with whole new text layout system.
And we don't backport new big features to the 0.10 anymore to keep it...stable. We are busy with the master branch and 11.0, so we don't need to fix new bugs in the stable branch.

Is there a timeline for 0.11 ? :)

Hopefully, first preview will be in the end of this month or beginning of the next. Expected to get first third party libraries to support this version too.
Nightly builds of 11.0 version is already available, but with no support from third party libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Textformating With Run Text=......
10 participants