From: Julian Giebel Date: Wed, 22 May 2024 14:23:55 +0000 (+0200) Subject: Implement permissive version of AddMarkup and use it for tips (#28204) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=1fa493e1af0e3f31b53c40bda0d7cefe885af343;p=space-station-14.git Implement permissive version of AddMarkup and use it for tips (#28204) * Implement permissive version of ddMarkup Use permissive ddMarkup for news article input Use permissive ddMarkup for tips * Fix doc comment format --- diff --git a/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs b/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs index 7f98e3e0c3..5e068f1e9c 100644 --- a/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs +++ b/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs @@ -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) diff --git a/Content.Client/Message/RichTextLabelExt.cs b/Content.Client/Message/RichTextLabelExt.cs index ab6d17bf44..7ff6390764 100644 --- a/Content.Client/Message/RichTextLabelExt.cs +++ b/Content.Client/Message/RichTextLabelExt.cs @@ -5,9 +5,27 @@ namespace Content.Client.Message; public static class RichTextLabelExt { + + + /// + /// Sets the labels markup. + /// + /// + /// Invalid markup will cause exceptions to be thrown. Don't use this for user input! + /// public static RichTextLabel SetMarkup(this RichTextLabel label, string markup) { label.SetMessage(FormattedMessage.FromMarkup(markup)); return label; } + + /// + /// Sets the labels markup.
+ /// Uses FormatedMessage.FromMarkupPermissive which treats invalid markup as text. + ///
+ public static RichTextLabel SetMarkupPermissive(this RichTextLabel label, string markup) + { + label.SetMessage(FormattedMessage.FromMarkupPermissive(markup)); + return label; + } } diff --git a/Content.Client/Tips/TippyUIController.cs b/Content.Client/Tips/TippyUIController.cs index 67c3ee45a7..2cc694d97d 100644 --- a/Content.Client/Tips/TippyUIController.cs +++ b/Content.Client/Tips/TippyUIController.cs @@ -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;