]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Implement permissive version of AddMarkup and use it for tips (#28204)
authorJulian Giebel <juliangiebel@live.de>
Wed, 22 May 2024 14:23:55 +0000 (16:23 +0200)
committerGitHub <noreply@github.com>
Wed, 22 May 2024 14:23:55 +0000 (10:23 -0400)
* Implement permissive version of \addMarkup
Use permissive \addMarkup for news article input
Use permissive \addMarkup for tips

* Fix doc comment format

Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs
Content.Client/Message/RichTextLabelExt.cs
Content.Client/Tips/TippyUIController.cs

index 7f98e3e0c3db317c680d8b9dd4d16793e4b429f4..5e068f1e9c534663ae955a23989e68048bf18691 100644 (file)
@@ -76,7 +76,7 @@ public sealed partial class ArticleEditorPanel : Control
 
         TextEditPanel.Visible = !_preview;
         PreviewPanel.Visible = _preview;
-        PreviewLabel.SetMarkup(Rope.Collapse(ContentField.TextRope));
+        PreviewLabel.SetMarkupPermissive(Rope.Collapse(ContentField.TextRope));
     }
 
     private void OnCancel(BaseButton.ButtonEventArgs eventArgs)
index ab6d17bf44d53e6ccffb3b48f4f4db07222f8336..7ff6390764b21e0f2e64f7caf3e4d2556d190afd 100644 (file)
@@ -5,9 +5,27 @@ namespace Content.Client.Message;
 
 public static class RichTextLabelExt
 {
+
+
+     /// <summary>
+     /// Sets the labels markup.
+     /// </summary>
+     /// <remarks>
+     /// Invalid markup will cause exceptions to be thrown. Don't use this for user input!
+     /// </remarks>
     public static RichTextLabel SetMarkup(this RichTextLabel label, string markup)
     {
         label.SetMessage(FormattedMessage.FromMarkup(markup));
         return label;
     }
+
+     /// <summary>
+     /// Sets the labels markup.<br/>
+     /// Uses <c>FormatedMessage.FromMarkupPermissive</c> which treats invalid markup as text.
+     /// </summary>
+    public static RichTextLabel SetMarkupPermissive(this RichTextLabel label, string markup)
+    {
+        label.SetMessage(FormattedMessage.FromMarkupPermissive(markup));
+        return label;
+    }
 }
index 67c3ee45a7edb6b4049be9b24f6539aa04979ae9..2cc694d97d469e593af8a71d9a8dae9245385e8f 100644 (file)
@@ -175,7 +175,7 @@ public sealed class TippyUIController : UIController
                     sprite.LayerSetVisible("hiding", false);
                 }
                 sprite.Rotation = 0;
-                tippy.Label.SetMarkup(_currentMessage.Msg);
+                tippy.Label.SetMarkupPermissive(_currentMessage.Msg);
                 tippy.Label.Visible = false;
                 tippy.LabelPanel.Visible = false;
                 tippy.Visible = true;