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

问题描述

我正在使用Nebular chat component,它工作正常。

但是我无法发送HTML消息。如

你好世界 Hello World

您能帮忙在神经聊天中实现这一目标吗?

编辑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>,});

Output :<b>Hello world</b>

它正在消息中打印HTML字符

解决方法

编辑2:

好,我明白了。 Nebular只需要字符串作为消息。因此,无法发送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 {
}