From: beck-thompson <107373427+beck-thompson@users.noreply.github.com> Date: Mon, 15 Dec 2025 03:19:41 +0000 (-0800) Subject: Fix news console formatting and pda news formating (#41799) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=42e7bad3dfd62ff7484d838e568a036d359866c1;p=space-station-14.git 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 --- diff --git a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs index 2d4d192ea8..f76adfb866 100644 --- a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs +++ b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs @@ -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; diff --git a/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs b/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs index fef94a2bd3..20e23d2359 100644 --- a/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs +++ b/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs @@ -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) diff --git a/Content.Client/Paper/UI/PaperWindow.xaml.cs b/Content.Client/Paper/UI/PaperWindow.xaml.cs index f58a74b8b4..b688e69427 100644 --- a/Content.Client/Paper/UI/PaperWindow.xaml.cs +++ b/Content.Client/Paper/UI/PaperWindow.xaml.cs @@ -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? 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; diff --git a/Content.Client/RichText/UserFormattableTags.cs b/Content.Client/RichText/UserFormattableTags.cs new file mode 100644 index 0000000000..09be4fa2e7 --- /dev/null +++ b/Content.Client/RichText/UserFormattableTags.cs @@ -0,0 +1,25 @@ +using Content.Client.UserInterface.RichText; +using Robust.Client.UserInterface.RichText; + +namespace Content.Client.RichText; + +/// +/// Contains rules for what markup tags are allowed to be used by players. +/// +public static class UserFormattableTags +{ + /// + /// The basic set of "rich text" formatting tags that shouldn't cause any issues. + /// Limit user rich text to these by default. + /// + public static readonly Type[] BaseAllowedTags = + [ + typeof(BoldItalicTag), + typeof(BoldTag), + typeof(BulletTag), + typeof(ColorTag), + typeof(HeadingTag), + typeof(ItalicTag), + typeof(MonoTag), + ]; +}