我正在尝试使用Google环聊api在卡片内发送大量说明;但不幸的是,如果文本太长,则会对其进行修剪。以下是我发送的卡片的示例:
"cards": [{
"sections": [{
"widgets": [{
"keyValue": {
"topLabel": "Label",
"content": "Long Description goes here..."
}
}
]
}
]
}
]
[当我查看漫游器收到的html时,内容是在white-space: nowrap;
中潜水的...我尝试将内容放在div中,并像这样给它white-space: wrap;
"content": "<div style='white-space: wrap;'>Long Description...</div>"
,但是漫游器仅在发送卡片时删除了该div。
[我还注意到,在PC浏览器上,文本被修剪为43个字符,因此我使用正则表达式使用.replace(/.{42}/g, '$&\n')
在每43个字符处添加\ n,这种方法有效,但在移动电话上,卡片似乎可以对消息进行更多修剪。 ..
无论如何,我可以简单地删除烦人的white-space
样式?
编辑
我知道this post,但是它试图增加卡的宽度(从技术上讲,这对我来说是有效的,并且没有解决方案...
无法避免在content
上使用keyValue
的此属性,但是您可以通过某种方式对其进行破解:
"cards": [{
"sections": [{
"widgets": [
{
"keyValue": {
"topLabel": "Label",
"content": " "
}},{
"textParagraph": {
"text": "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."
},
}
]
}
]
}
]
希望它起作用。