How to get the external plugin CSS, JS and HTML through GrapesJS export feature?
Question
I have used an external plugin javascript version of @fullCalendar into the GrapesJS. I am able to render the calendar on the canvas but I am unable to use GrapesJS export feature to get JS, CSS and HTML of the following.
I tried using
1) var html = editor.getHtml();
2) var css = editor.getCss();
3) var js = editor.getJs();
4) editor.on('component:mount', comp => console.log(comp.toHtml()));
**Calendar rendered on Canvas -**

**Export of GrapesJs Editor -**

Kindly help me!
Thanks in advance ...Answers (3)
. But we are unable to show users the calendar on the canvas after drag and drop with render function in MODEL that is why we used OnRender in the VIEW.
Did you try the component type definition i posted for you? it has been tested and it is working:

So, is the MODEL alone sufficient to render as well as add HTML to export feature? If yes could you please explain how?
yes. it will render the component in the canvas, and include the final code in final html.
if you need any further help for your specific case, i would appreciate a fiddle. cheers!
Thanks a lot, @pouyamiralayi. The code you gave was working. Our code was not able to pick the dom element to render the calendar. Now it is working as expected.
Thanks a lot for helping us out !!!! :-p
Hi there! what you are looking for is using js inside components.
just include the required js and css in the canvas scripts and styles section:
canvas: {
styles: [
'https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/core/main.css',
'https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/daygrid/main.css',
],
scripts: [
'https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/core/main.js',
'https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/4.2.0/daygrid/main.js',
],
},
after that build your own custom type component:
model: {
defaults: {
ccid:'',
tagName: 'div',
resizable:true,
script: function(){
const id = '{[ ccid ]}'
var calendarEl = document.getElementById(id);
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'dayGrid' ]
});
calendar.render();
}
},
},
view:{
init(){
this.model.set('ccid',this.model.ccid)
}
}
then on code preview you will see the result script:

cheers!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2416
Unable to display template from database to grapesjs
Able to fetch my remote HTML file using load URL and getting status ok, how can I load this fetched HTML AND CSS into editor? currently I'm...
Issue #3238
[Question]: How to load external javascript,i tried all methods,Useless
I write html strings as blocks, and need to introduce a lot of external scripts and styles, but I tried all the methods, when I drag the bl...
Issue #3347
How can I get Uncompressed JS code for me to edit?
Hi, thank you for reviewing my problem. I want to use my own JSEditor to edit html、css and js. 1、First, I use getHtml, getCss, getJs to dis...
Issue #966
[QUESTION] How to load external CSS file into Grapes Editor?
Hey, During my editor = grapesjs.init(), I want to load an external CSS file into the canvas using @import url(...). So when I use my custo...
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.