GrapesJS / export

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

How to include .js in zip directly from path #15

Closed rjjrbatarao closed 2 years ago

rjjrbatarao commented 2 years ago

Iwas trying to add custom.js on exported zip file, adding css works perfectly since its all text while javascript file might contain hex strings and its getting broken when copied to a file. Sample below breaks dues to hex string in my case.

root:{
css: {
 'style.css': '.popup-title{font-family:"Enriqueta"}'
},
'test.js': 'console.log(\"\\t\\n\\v\\f\\r                 \\u2028\\u2029\\ufeff\")'
}

what I am trying below

root:{
css: {
 'style.css': '.popup-title{font-family:"Enriqueta"}'
},
'test.js': 'localhost:80/custom.js'
}
artf commented 2 years ago

The README shows an example of how would you fetch a remote file content

{
  img: async ed => {
    const images = await fetchImagesByStructue(ed.getComponents());
    return images;
    // Where `images` is an object like this:
    // { 'img1.png': '...png content', 'img2.jpg': '...jpg content' }
  },
}