From 5ae38289e3ba438b1a16e8537e91eef9c9e0372a Mon Sep 17 00:00:00 2001 From: Simon Oxtoby Date: Sat, 20 Apr 2024 09:15:02 +1000 Subject: [PATCH] Updating RichTextBlock elements RichTextStyle properties are ignored when false Resolves #196 --- SlackNet/Blocks/RichTextBlock.cs | 83 ++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/SlackNet/Blocks/RichTextBlock.cs b/SlackNet/Blocks/RichTextBlock.cs index 5d45976..2600bc6 100644 --- a/SlackNet/Blocks/RichTextBlock.cs +++ b/SlackNet/Blocks/RichTextBlock.cs @@ -3,6 +3,10 @@ namespace SlackNet.Blocks; +/// +/// Displays formatted, structured representation of text. +/// +/// See the Slack documentation for more information. [SlackType("rich_text")] public class RichTextBlock : Block { @@ -18,6 +22,10 @@ public abstract class RichTextElement public string Type { get; set; } } +/// +/// Section element. +/// +/// See the Slack documentation for more information. public class RichTextSection : RichTextElement { public RichTextSection(): base("rich_text_section") { } @@ -122,34 +130,101 @@ public RichTextBroadcast() : base("broadcast") { } public RichTextStyle Style { get; set; } = new(); } +/// +/// List element. +/// +/// See the Slack documentation for more information. public class RichTextList : RichTextElement { public RichTextList() : base("rich_text_list") { } - public IList Elements { get; set; } = []; - public string Style { get; set; } + /// + /// An array of objects. + /// + public IList Elements { get; set; } = []; + + /// + /// Either or , the latter meaning a numbered list. + /// + public RichTextListStyle Style { get; set; } + + /// + /// Levels of indentation. + /// public int Indent { get; set; } + + /// + /// Number of pixels to offset the list. + /// + public int Offset { get; set; } + + /// + /// Number of pixels of border thickness. + /// public int Border { get; set; } } +public enum RichTextListStyle +{ + Bullet, + Ordered +} + +/// +/// Quote element. +/// +/// See the Slack documentation for more information. public class RichTextQuote : RichTextElement { public RichTextQuote() : base("rich_text_quote") { } + /// + /// An array of rich text elements. + /// public IList Elements { get; set; } = []; + + /// + /// Number of pixels of border thickness. + /// + public int Border { get; set; } } +/// +/// Preformatted code block element. +/// +/// See the Slack documentation for more information. public class RichTextPreformatted : RichTextElement { public RichTextPreformatted() : base("rich_text_preformatted") { } + /// + /// An array of rich text elements. + /// public IList Elements { get; set; } = []; + + /// + /// Number of pixels of border thickness. + /// + public int Border { get; set; } } +/// +/// Rich text styling. Note that not all properties are supported by all elements. +/// public class RichTextStyle { + [IgnoreIfDefault] public bool Bold { get; set; } - public bool Code { get; set; } + [IgnoreIfDefault] public bool Italic { get; set; } + [IgnoreIfDefault] public bool Strike { get; set; } -} + [IgnoreIfDefault] + public bool Code { get; set; } + [IgnoreIfDefault] + public bool Highlight { get; set; } + [IgnoreIfDefault] + public bool ClientHighlight { get; set; } + [IgnoreIfDefault] + public bool Unlink { get; set; } +} \ No newline at end of file