Slack 块嵌套项目符号列表

问题描述 投票:0回答:1

我需要向 slack 发送一个 API 请求,其中包含一条包含嵌套项目符号点列表的消息。我找到了现有问题的以下答案:https://stackoverflow.com/a/68483110/16659015但遗憾的是这仅显示了没有嵌套的正常项目符号点列表。

我找不到此

rich_text
rich_text_list
类型的任何资源或文档,并且在尝试不同的订单时,块套件构建器抛出错误。

如何利用带有 rich_text 的块来创建嵌套的项目符号列表?

(我知道有解决方法,但如果通过块存在一维项目符号,那么嵌套也应该可以以某种方式实现)

slack slack-api slack-block-kit
1个回答
0
投票

对于像我这样在未来寻找这个的人来说,这里是解决方案:

您可以在此处查看其记录:https://api.slack.com/tutorials/tracks/rich-text-tutorial

您可以在此处查看区块生成器中的 演示

这是从文档复制的示例代码。诀窍只是在当前列表块下方创建一个单独的列表块并使用缩进属性:

{
"type": "rich_text",
"elements": [
    {
        "type": "rich_text_section",
        "elements": [
            {
                "type": "emoji",
                "name": "office"
            },
            {
                "type": "text",
                "text": " Company business",
                "style": {
                    "bold": true
                }
            }
        ]
    },
    {
        "type": "rich_text_list",
        "style": "bullet",
        "elements": [
            {
                "type": "rich_text_section",
                "elements": [
                    {
                        "type": "text",
                        "text": "Fill out your W-2"
                    }
                ]
            },
            {
                "type": "rich_text_section",
                "elements": [
                    {
                        "type": "text",
                        "text": "Enroll in "
                    },
                    {
                        "type": "link",
                        "text": "benefits",
                        "url": "https://salesforcebenefits.com"
                    }
                ]
            },
            {
                "type": "rich_text_section",
                "elements": [
                    {
                        "type": "text",
                        "text": "Fill out your Slack profile, including:"
                    }
                ]
            }
        ]
    },
    {
        "type": "rich_text_list",
        "style": "ordered",
        "indent": 1,
        "elements": [
            {
                "type": "rich_text_section",
                "elements": [
                    {
                        "type": "text",
                        "text": "Time zone"
                    }
                ]
            },
            {
                "type": "rich_text_section",
                "elements": [
                    {
                        "type": "text",
                        "text": "Pronouns"
                    }
                ]
            }
        ]
    }
]

},

© www.soinside.com 2019 - 2024. All rights reserved.