mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
add markdown paragraph with image block
This commit is contained in:
@ -32,6 +32,8 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
|||||||
|
|
||||||
public override MarkdownTextFlowContainer CreateTextFlow() => new WikiMarkdownTextFlowContainer();
|
public override MarkdownTextFlowContainer CreateTextFlow() => new WikiMarkdownTextFlowContainer();
|
||||||
|
|
||||||
|
protected override MarkdownParagraph CreateParagraph(ParagraphBlock paragraphBlock, int level) => new WikiMarkdownParagraph(paragraphBlock);
|
||||||
|
|
||||||
protected virtual FillFlowContainer CreateNotice(YamlFrontMatterBlock yamlFrontMatterBlock) => new WikiNoticeContainer(yamlFrontMatterBlock);
|
protected virtual FillFlowContainer CreateNotice(YamlFrontMatterBlock yamlFrontMatterBlock) => new WikiNoticeContainer(yamlFrontMatterBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
40
osu.Game/Overlays/Wiki/Markdown/WikiMarkdownParagraph.cs
Normal file
40
osu.Game/Overlays/Wiki/Markdown/WikiMarkdownParagraph.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using Markdig.Syntax;
|
||||||
|
using Markdig.Syntax.Inlines;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers.Markdown;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Wiki.Markdown
|
||||||
|
{
|
||||||
|
public class WikiMarkdownParagraph : MarkdownParagraph
|
||||||
|
{
|
||||||
|
private readonly ParagraphBlock paragraphBlock;
|
||||||
|
|
||||||
|
public WikiMarkdownParagraph(ParagraphBlock paragraphBlock)
|
||||||
|
: base(paragraphBlock)
|
||||||
|
{
|
||||||
|
this.paragraphBlock = paragraphBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
MarkdownTextFlowContainer textFlow;
|
||||||
|
InternalChild = textFlow = CreateTextFlow();
|
||||||
|
textFlow.AddInlineText(paragraphBlock.Inline);
|
||||||
|
|
||||||
|
// Check if paragraph only contains an image.
|
||||||
|
if (paragraphBlock.Inline.Count() == 1 && paragraphBlock.Inline.FirstChild is LinkInline { IsImage: true } linkInline)
|
||||||
|
{
|
||||||
|
textFlow.TextAnchor = Anchor.TopCentre;
|
||||||
|
textFlow.Spacing = new Vector2(0, 5);
|
||||||
|
textFlow.AddText($"\n{linkInline.Title}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user