mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-14 19:29:53 +01:00
Fix news console formatting and pda news formating (#41799)
* Fix news console formatting * another fix * Fix review Un-copy-paste. Twice. *sigh* --------- Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
using Content.Client.Message;
|
||||
using Content.Client.RichText;
|
||||
using Content.Client.UserInterface.RichText;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.RichText;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Client.CartridgeLoader.Cartridges;
|
||||
|
||||
@@ -31,16 +35,17 @@ public sealed partial class NewsReaderUiFragment : BoxContainer
|
||||
Author.Visible = true;
|
||||
|
||||
PageName.Text = article.Title;
|
||||
PageText.SetMarkupPermissive(article.Content);
|
||||
PageText.SetMessage(FormattedMessage.FromMarkupPermissive(article.Content), UserFormattableTags.BaseAllowedTags);
|
||||
|
||||
PageNum.Text = $"{targetNum}/{totalNum}";
|
||||
|
||||
NotificationSwitch.Text = Loc.GetString(notificationOn ? "news-read-ui-notification-on" : "news-read-ui-notification-off");
|
||||
|
||||
string shareTime = article.ShareTime.ToString(@"hh\:mm\:ss");
|
||||
var shareTime = article.ShareTime.ToString(@"hh\:mm\:ss");
|
||||
ShareTime.SetMarkup(Loc.GetString("news-read-ui-time-prefix-text") + " " + shareTime);
|
||||
|
||||
Author.SetMarkup(Loc.GetString("news-read-ui-author-prefix") + " " + (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author")));
|
||||
var author = Loc.GetString("news-read-ui-author-prefix") + " " + (article.Author ?? Loc.GetString("news-read-ui-no-author"));
|
||||
Author.SetMessage(FormattedMessage.FromMarkupPermissive(author), UserFormattableTags.BaseAllowedTags);
|
||||
|
||||
Prev.Disabled = targetNum <= 1;
|
||||
Next.Disabled = targetNum >= totalNum;
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using Content.Client.Message;
|
||||
using Content.Client.RichText;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Client.UserInterface.RichText;
|
||||
using Content.Shared.MassMedia.Systems;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.RichText;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -81,7 +84,9 @@ public sealed partial class ArticleEditorPanel : Control
|
||||
|
||||
TextEditPanel.Visible = !_preview;
|
||||
PreviewPanel.Visible = _preview;
|
||||
PreviewLabel.SetMarkupPermissive(Rope.Collapse(ContentField.TextRope));
|
||||
|
||||
var articleBody = Rope.Collapse(ContentField.TextRope);
|
||||
PreviewLabel.SetMessage(FormattedMessage.FromMarkupPermissive(articleBody), UserFormattableTags.BaseAllowedTags);
|
||||
}
|
||||
|
||||
private void OnCancel(BaseButton.ButtonEventArgs eventArgs)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Numerics;
|
||||
using Content.Client.RichText;
|
||||
using Content.Shared.Paper;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -38,16 +39,6 @@ namespace Content.Client.Paper.UI
|
||||
// we're able to resize this UI or not. Default to everything enabled:
|
||||
private DragMode _allowedResizeModes = ~DragMode.None;
|
||||
|
||||
private readonly Type[] _allowedTags = new Type[] {
|
||||
typeof(BoldItalicTag),
|
||||
typeof(BoldTag),
|
||||
typeof(BulletTag),
|
||||
typeof(ColorTag),
|
||||
typeof(HeadingTag),
|
||||
typeof(ItalicTag),
|
||||
typeof(MonoTag)
|
||||
};
|
||||
|
||||
public event Action<string>? OnSaved;
|
||||
|
||||
private int _MaxInputLength = -1;
|
||||
@@ -280,7 +271,7 @@ namespace Content.Client.Paper.UI
|
||||
{
|
||||
msg.AddMarkupPermissive("\r\n");
|
||||
}
|
||||
WrittenTextLabel.SetMessage(msg, _allowedTags, DefaultTextColor);
|
||||
WrittenTextLabel.SetMessage(msg, UserFormattableTags.BaseAllowedTags, DefaultTextColor);
|
||||
|
||||
WrittenTextLabel.Visible = !isEditing && state.Text.Length > 0;
|
||||
BlankPaperIndicator.Visible = !isEditing && state.Text.Length == 0;
|
||||
|
||||
25
Content.Client/RichText/UserFormattableTags.cs
Normal file
25
Content.Client/RichText/UserFormattableTags.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Content.Client.UserInterface.RichText;
|
||||
using Robust.Client.UserInterface.RichText;
|
||||
|
||||
namespace Content.Client.RichText;
|
||||
|
||||
/// <summary>
|
||||
/// Contains rules for what markup tags are allowed to be used by players.
|
||||
/// </summary>
|
||||
public static class UserFormattableTags
|
||||
{
|
||||
/// <summary>
|
||||
/// The basic set of "rich text" formatting tags that shouldn't cause any issues.
|
||||
/// Limit user rich text to these by default.
|
||||
/// </summary>
|
||||
public static readonly Type[] BaseAllowedTags =
|
||||
[
|
||||
typeof(BoldItalicTag),
|
||||
typeof(BoldTag),
|
||||
typeof(BulletTag),
|
||||
typeof(ColorTag),
|
||||
typeof(HeadingTag),
|
||||
typeof(ItalicTag),
|
||||
typeof(MonoTag),
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user