GrapesJS / export

Export GrapesJS templates in a zip archive
BSD 3-Clause "New" or "Revised" License
76 stars 68 forks source link

Including data-gjs-type in exported html #16

Closed benjgrad closed 2 years ago

benjgrad commented 2 years ago

I recently tried exporting the html and css of my sample site to load it back into grapesjs as the index.html. (I'm making a custom plugin and wanted to make a site to demo it.) After some troubleshooting, it seems like the components won't register without including the data-gjs-type.

Is it possible to configure the export so the generated html includes these data-gjs-type attributes?

Thanks in advance.

artf commented 2 years ago

I'd suggest you export the project data JSON in order to be able to reimport the project easily.

root: {
 // ...
 'project.json': (editor) => JSON.stringify(editor.getProjectData()),
}
benjgrad commented 2 years ago

Thanks. I created a basic storage server/db, and I'm using it to hold the json data.

I think there are genuine use cases for preserving the data-gjs-type attributes in the html though... Below, I linked an issue ticket where people are editing the html in a modal, and the attributes are being deleted.

https://github.com/artf/grapesjs/issues/324

If you're looking for a demo, you can use https://editor.gradyserver.com/issue (I know the load time sucks, but it's just a static html file, so you can see all of the code.)

Edit: Created a feature request (in grapesjs instead of grapesjs-plugin-export), with code to PR.

https://github.com/artf/grapesjs/discussions/4518