我正在为一些自动通知创建一个 slackbot,我收到了一个请求,让通知占据整个 slack 窗口的宽度,这看起来更干净。我发现块似乎占据了指定的宽度,并且不会水平拉伸超过该点。我想知道是否有一种解决方法可以消除似乎正在发生的最大宽度
我使用这样的东西作为我的格式块:
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Testing if a longer message will force the update box to be wider Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Button",
"emoji": true
},
"value": "click_me_123"
}
}
Run Code Online (Sandbox Code Playgroud)
这是块套件/松弛 api 的限制吗?或者有没有办法消除这个宽度限制?
小智 9
Slack 似乎有一种没有特别详细记录的块类型,称为rich_text
填充 Slack 消息面板的宽度。
{
"blocks": [
{
"type": "rich_text",
"elements": [
{
"type": "rich_text_preformatted",
"elements": [
{
"type": "text",
"text": "+---------+---------+---------+---------+---------+---------+---------+---------+\n
| column1 | column2 | column3 | column4 | column5 | column6 | column7 | column8 |\n
+---------+---------+---------+---------+---------+---------+---------+---------+\n
| row1c1 | row1c2 | row1c3 | row1c4 | row1c5 | row1c6 | row1c7 | row1c8 |\n
+---------+---------+---------+---------+---------+---------+---------+---------+"
}
]
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
不,您无法定义 Slack 消息/块的确切宽度。每个消息元素的宽度是预定义的,并且取决于渲染消息的客户端。这是设计使然,因为 Slack 旨在独立于客户端。
归档时间: |
|
查看次数: |
2583 次 |
最近记录: |