如何在Nebular聊天中发送格式化/HTML消息



我正在使用Nebular聊天组件,它运行良好。

但我无法在其中发送HTML消息。如

你好世界 你好世界

你能在星云聊天中帮助实现这一点吗?

编辑1

这是发送消息的示例代码:

this.messages.push({
text: "Hello world",
date: new Date(),
reply: true,
type: files.length ? 'file' : 'text',
files: files,
user: {
name: 'Jonh Doe',
avatar: 'https://i.gifer.com/no.gif',
},
});

输出:Hello world

对于发送HTML消息,我已经尝试了以下代码

this.messages.push({
text: <b>Hello World</b>,
date: new Date(),
reply: true,
type: files.length ? 'file' : 'text',
files: files,
user: {
name: 'Jonh Doe',
avatar: 'https://i.gifer.com/no.gif',
},
});
Output :<b>Hello world</b>

它正在消息中打印HTML字符

编辑2:

好的,我有问题了。星云只需要字符串来传递信息。因此,无法发送HTML样式的文本。但是您可以在ngAfterViewInit上找到该元素并将其替换为样式化的元素。


旧答案

你试过这样的东西吗?

https://github.com/akveo/ngx-admin/blob/master/src/app/pages/editors/ckeditor/ckeditor.component.ts

编辑1:

import { Component } from '@angular/core';
import './ckeditor.loader';
import 'ckeditor';
@Component({
selector: 'ngx-ckeditor',
template: `
<nb-card>
<nb-card-header>
CKEditor
</nb-card-header>
<nb-card-body>
<ckeditor [config]="{ extraPlugins: 'divarea', height: '320' }"></ckeditor>
</nb-card-body>
</nb-card>
`,
})
export class CKEditorComponent {
}

最新更新