add OsuMarkdownQuoteBlock

Reference:
d56352aeef/resources/assets/less/base.less (L7-L10)
This commit is contained in:
Gagah Pangeran Rosfatiputra 2021-04-28 10:11:29 +07:00
parent 6a921af085
commit 736eace00a
No known key found for this signature in database
GPG Key ID: 25F6F17FD29031E2
3 changed files with 57 additions and 0 deletions

View File

@ -75,5 +75,15 @@ public void TestSeparator()
Line below";
});
}
[Test]
public void TestQuote()
{
AddStep("Add quote", () =>
{
markdownContainer.Text =
@"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.";
});
}
}
}

View File

@ -32,6 +32,8 @@ protected override void AddMarkdownComponent(IMarkdownObject markdownObject, Fil
protected override MarkdownSeparator CreateSeparator(ThematicBreakBlock thematicBlock) => new OsuMarkdownSeparator();
protected override MarkdownQuoteBlock CreateQuoteBlock(QuoteBlock quoteBlock) => new OsuMarkdownQuoteBlock(quoteBlock);
protected override MarkdownPipeline CreateBuilder()
=> new MarkdownPipelineBuilder().UseAutoIdentifiers(AutoIdentifierOptions.GitHub)
.UseEmojiAndSmiley()

View File

@ -0,0 +1,45 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using Markdig.Syntax;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers.Markdown;
using osu.Game.Overlays;
namespace osu.Game.Graphics.Containers.Markdown
{
public class OsuMarkdownQuoteBlock : MarkdownQuoteBlock
{
private Drawable background;
public OsuMarkdownQuoteBlock(QuoteBlock quoteBlock)
: base(quoteBlock)
{
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
background.Colour = colourProvider.Content2;
}
protected override Drawable CreateBackground()
{
return background = base.CreateBackground();
}
public override MarkdownTextFlowContainer CreateTextFlow()
{
var textFlow = base.CreateTextFlow();
textFlow.Margin = new MarginPadding
{
Top = 10,
Bottom = 10,
Left = 20,
Right = 20,
};
return textFlow;
}
}
}