1

我正在尝试使用 google hangout api 在卡片内发送大量描述;但不幸的是,文本太长时会被修剪。以下是我发送的卡片样本:

"cards": [{
        "sections": [{
                "widgets": [{
                        "keyValue": {
                            "topLabel": "Label",
                            "content": "Long Description goes here..."
                        }
                    }
                ]
            }
        ]
    }
]

当我查看机器人接收到的 html 时,内容 与white-space: nowrap;......white-space: wrap;"content": "<div style='white-space: wrap;'>Long Description...</div>"

我还注意到,在 pc 浏览器上,文本被修剪为 43 个字符,所以我使用正则表达式在每 43 个字符处添加 \n .replace(/.{42}/g, '$&\n'),这很有效,但在移动设备上,卡片似乎更修剪消息......

无论如何,我可以简单地删除那种烦人white-space的风格??

编辑

我知道这篇文章,但它试图增加卡片的宽度(这在技术上对我有用),并且没有解决方案......

4

1 回答 1

2

这是可能的,而且非常简单:

您只需添加contentMultiline: true到您的KeyValue财产。

"cards": [{
        "sections": [{
                "widgets": [{
                        "keyValue": {
                            "topLabel": "Label",
                            "content": "The working day is thus not a constant, but a variable quantity. One of its parts, certainly, is determined by the working-time required for the reproduction of the labour-power of the labourer himself. But its total amount varies with the duration of the surplus labour. The working day is, therefore, determinable, but is, per se, indeterminate.",
                            "contentMultiline": true,
                        }
                     },
                 ]
            }
        ]
    }
]

在这里您可以找到KeyValue字段的文档:

https://developers.google.com/hangouts/chat/reference/rest/v1/cards#keyvalue

于 2019-12-04T10:52:34.220 回答