当代理发送包含链接的消息时,会发生以下两种情况之一的问题。
在没有 markdownit 的情况下,写为“www.google.com”的链接将作为未呈现的 HTML 传递给用户:
<a href="www.google.com">www.google.com</a>
如果添加了 markdownit ( https://cdnjs.cloudflare.com/ajax/libs/markdown-it/10.0.0/markdown-it.js?ver=3.3.7 ) 和 html: true, linkify: true, 使用,然后链接被正确呈现并传递给用户,但消息中的所有其他文本都被删除。不知道为什么...
例如,如果代理发送“点击此处:www.google.com”,用户收到的只是一个可点击的链接:www.google.com
不熟悉这些东西,但我很不知道为什么它会剥离常规文本,但发送链接很好。
我的部分设置:
const markdownIt = window.markdownit({ html: true, linkify: true, typographer: false });
window.WebChat.renderWebChat(
{
directLine: window.WebChat.createDirectLine({ token }),
renderMarkdown: markdownIt.render.bind(markdownIt),
styleOptions: {
hideUploadButton: true
},
username: 'Web User',
locale: $locale,
store
},
document.getElementById('webchat')
);
document.querySelector('#webchat').focus();
也有这样的:
renderMarkdown: text => markdownIt.render(text),
任何想法为什么它会剥离文本?我尝试切换 html false、linkify true 和反之亦然,以及打字员选项,但没有组合产生预期的结果。可以发送链接,可以发送文本,但不能合并。先谢谢了~
将此用作一些参考:botframework web chat V4 build and generate custom CSS and JS File
互动表: