2021-05-17 02:08:02 +08:00
|
|
|
// 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.
|
|
|
|
|
2021-05-21 17:04:08 +08:00
|
|
|
using Markdig.Extensions.Yaml;
|
|
|
|
using Markdig.Syntax;
|
2021-05-25 13:14:07 +08:00
|
|
|
using Markdig.Syntax.Inlines;
|
2021-05-21 17:04:08 +08:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-05-02 23:02:06 +08:00
|
|
|
using osu.Framework.Graphics.Containers.Markdown;
|
2021-05-17 02:08:02 +08:00
|
|
|
using osu.Game.Graphics.Containers.Markdown;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Wiki.Markdown
|
|
|
|
{
|
|
|
|
public class WikiMarkdownContainer : OsuMarkdownContainer
|
|
|
|
{
|
|
|
|
public string CurrentPath
|
|
|
|
{
|
|
|
|
set => Schedule(() => DocumentUrl += $"wiki/{value}");
|
|
|
|
}
|
2021-05-21 17:04:08 +08:00
|
|
|
|
|
|
|
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
|
|
|
|
{
|
|
|
|
switch (markdownObject)
|
|
|
|
{
|
|
|
|
case YamlFrontMatterBlock yamlFrontMatterBlock:
|
|
|
|
container.Add(CreateNotice(yamlFrontMatterBlock));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
base.AddMarkdownComponent(markdownObject, container, level);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-02 23:02:06 +08:00
|
|
|
public override MarkdownTextFlowContainer CreateTextFlow() => new WikiMarkdownTextFlowContainer();
|
|
|
|
|
2021-05-02 23:22:22 +08:00
|
|
|
protected override MarkdownParagraph CreateParagraph(ParagraphBlock paragraphBlock, int level) => new WikiMarkdownParagraph(paragraphBlock);
|
|
|
|
|
2021-05-21 17:04:08 +08:00
|
|
|
protected virtual FillFlowContainer CreateNotice(YamlFrontMatterBlock yamlFrontMatterBlock) => new WikiNoticeContainer(yamlFrontMatterBlock);
|
2021-05-25 13:14:07 +08:00
|
|
|
|
|
|
|
private class WikiMarkdownTextFlowContainer : OsuMarkdownTextFlowContainer
|
|
|
|
{
|
|
|
|
protected override void AddImage(LinkInline linkInline) => AddDrawable(new WikiMarkdownImage(linkInline));
|
|
|
|
}
|
2021-05-17 02:08:02 +08:00
|
|
|
}
|
|
|
|
}
|