]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix news console formatting and pda news formating (#41799)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Mon, 15 Dec 2025 03:19:41 +0000 (19:19 -0800)
committerGitHub <noreply@github.com>
Mon, 15 Dec 2025 03:19:41 +0000 (03:19 +0000)
* Fix news console formatting

* another fix

* Fix review

Un-copy-paste. Twice. *sigh*

---------

Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com>
Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs
Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs
Content.Client/Paper/UI/PaperWindow.xaml.cs
Content.Client/RichText/UserFormattableTags.cs [new file with mode: 0644]

index 2d4d192ea8ad4fc78a60c487c511845d15e05a50..f76adfb8661fe4cc860ae27c1ffca265a33b8936 100644 (file)
@@ -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;
index fef94a2bd32c7276b07ceb47624ca91974860b8d..20e23d2359a0b34be99c4bbaba3bdbfd9a16f94a 100644 (file)
@@ -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)
index f58a74b8b41684c0aedcb841ccdf631308ab19dd..b688e694279119c15809ac687d07481b2152f20b 100644 (file)
@@ -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;
diff --git a/Content.Client/RichText/UserFormattableTags.cs b/Content.Client/RichText/UserFormattableTags.cs
new file mode 100644 (file)
index 0000000..09be4fa
--- /dev/null
@@ -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),
+    ];
+}