Angular with Grapesjs
Question
Hi I want to integrate Grapesjs into my angular application.
Suppose I have a custom dropdown component (containing .ts, .html and .scss files) as shown shown below:
CustomDropdown.html----------------------------------
<div class="cust-dropwodn-container">
<span>Some header</span>
<select *ngIf="shouldDropdownBePresent" class="select-class">
<option *ngFor="let optionVal of optionsArr">
{{ optionVal.value }}
</option>
</select>
<button (onClick)="callEventFunction()">Some event click</button>
</div>
CustomDropdown.ts------------------------------ ---
shouldDropdownBePresent: boolean = false;
@Output() emitToOutsideWorld= new EventEmitter<any>();
ngOnInt() {
//logic to toggle shouldDropdownBePresent value
//get array data for dropdown
}
callEventFunction() {
//emitting event to outside world
emitToOutsideWorld.emit();
}
CustomDropdown.scss------------------------------------
.cust-dropwodn-container {
background: aqua,
.select-class {
border: none,
}
}
Calling this component anywhere in the application, like calling it in SampleComponent would be this way, (SampleComponent's html and typescript file shown below)
SampleComponent.html-------------------------------
<CustomDropdown [someData]="data" (emitToOutsideWorld)="eventHandlerFunction()" />
SampleComponent.ts----------------------------------
eventHandlerFunction() {
//do something when the event fired from CustomDropdown component
}
I'd like to call CustomDropdown component in canvas of Grapes.js, but Grapesjs expects only html, so how to implement this?
And I would like to invoke methods written in typescript file from canvas or panels or blocks.
Above the events are handled as show below in angular:
(emitToOutsideWorld)="eventHandlerFunction()"
Is there any way to emit events from grapesjs and have their handler functions outside?Answers (2)
Any updates @artf?
No @Khan-Uzair by default GrapesJS doesn't read any framework related components... please read more about GrapesJS components here
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1448
Child component not selectable when using custom view
I'm trying to create a custom component that creates it's own view with nested HTML. I do not want this HTML to be rendered as a component...
Issue #460
When the component's view modifies the HTML, text components are no longer editable
I'm trying to build a custom component that contains some lorem ipsum text in the content, for editing once it's on the canvas. But I also...
Issue #1157
Return span randomly in custom component
I have custom component and on trait change wanted to updated html but randomly it returned span/textnode in trait change function insted o...
Issue #2170
[QUESTION] Custom component - how to set editable to true
Hi, I've created a custom component type, but I am having some trouble making it editable. The component is a "span" with component type "t...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.