How to send formatted/HTML message in Nebular chat?

590 views Asked by At

I am using the Nebular chat component and it is working fine.

But I am unable to send HTML message in that. Such as

Hello world Hello World

Can you please help to achieve this in the nebular chat?

Edit 1

This is sample code for send message :

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

Output: Hello world

For sending HTML message I have tried below code

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>

It is printing HTML character in the message

1

There are 1 answers

2
Akif On

Edit 2:

Ok, I got the problem. Nebular wants just string for message. So there is no way to send HTML styled text. But you can find the element and replace it with styled one on ngAfterViewInit.


Old Answer

Have you tried something like this?

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

Edit 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 {
}