Closed mostafa-raafat closed 4 years ago
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import 'grapesjs/dist/css/grapes.min.css';
import grapesJS from 'grapesjs';
import grapesJSMJML from 'grapesjs-mjml';
declare const grapesjs: any;
@Component({
selector: 'app-ejemplo',
template: '<button (click)="crearControl()" >generar</button><div id="gjs" #gjs></div>',
styleUrls: ['./ejemplo.component.scss'],
})
export class EjemploComponent implements OnInit {
constructor() { }
@ViewChild('gjs', { static: true }) private gjs: ElementRef;
ngOnInit() {
}
crearControl(): void {
this.gjs.nativeElement.innerHTML = '<mjml><mj-body><mj-section><mj-column></mj-column></mj-section></mj-body></mjml>';
const editor = grapesJS.init({
container: '#gjs',
fromElement: 1,
plugins: [grapesJSMJML
],
pluginsOpts: {
[grapesJSMJML]: {
}
},
style: '.txt-red{color: red}',
});
}
}
There is 2 issues 1- unknown element
2- if i didn't put this section
i can't drop any component and i get this message in the console