Class: Slack::BlockKit::Layout::RichText
- Inherits:
-
Object
- Object
- Slack::BlockKit::Layout::RichText
show all
- Defined in:
- lib/slack/block_kit/layout/rich_text.rb,
lib/slack/block_kit/layout/rich_text/rich_text_list.rb,
lib/slack/block_kit/layout/rich_text/rich_text_quote.rb,
lib/slack/block_kit/layout/rich_text/rich_text_section.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements.rb,
lib/slack/block_kit/layout/rich_text/rich_text_preformatted.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements/link.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements/text.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements/user.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements/emoji.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements/channel.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements/usergroup.rb,
lib/slack/block_kit/layout/rich_text/rich_text_elements/style_helper.rb
Overview
Displays formatted, structured representation of text.
It is also the output of the Slack client’s WYSIWYG message composer, so all messages sent by end-users will have this format. Use this block to include user-defined formatted text in your Block Kit payload. While it is possible to format text with mrkdwn, rich_text is strongly preferred and allows greater flexibility.
api.slack.com/reference/block-kit/blocks#rich_text
Defined Under Namespace
Modules: RichTextElements
Classes: RichTextList, RichTextPreformatted, RichTextQuote, RichTextSection
Constant Summary
collapse
- TYPE =
'rich_text'
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(block_id: nil) {|_self| ... } ⇒ RichText
Returns a new instance of RichText.
18
19
20
21
22
23
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 18
def initialize(block_id: nil)
@block_id = block_id
@elements = []
yield(self) if block_given?
end
|
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
16
17
18
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 16
def elements
@elements
end
|
Instance Method Details
#append(element) ⇒ Object
57
58
59
60
61
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 57
def append(element)
@elements << element
self
end
|
#as_json ⇒ Object
63
64
65
66
67
68
69
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 63
def as_json(*)
{
type: TYPE,
elements: @elements.map(&:as_json),
block_id: @block_id
}.compact
end
|
#rich_text_list(style: 'bullet', indent: nil, offset: nil, border: nil) {|element| ... } ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 33
def rich_text_list(style: 'bullet', indent: nil, offset: nil, border: nil)
element = RichTextList.new(style: style, indent: indent, offset: offset, border: border)
yield(element) if block_given?
append(element)
end
|
#rich_text_preformatted(border: nil) {|element| ... } ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 41
def rich_text_preformatted(border: nil)
element = RichTextPreformatted.new(border: border)
yield(element) if block_given?
append(element)
end
|
#rich_text_quote(border: nil) {|element| ... } ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 49
def rich_text_quote(border: nil)
element = RichTextQuote.new(border: border)
yield(element) if block_given?
append(element)
end
|
#rich_text_section {|element| ... } ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/slack/block_kit/layout/rich_text.rb', line 25
def rich_text_section
element = RichTextSection.new
yield(element) if block_given?
append(element)
end
|