GrapesJS / export

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

Export images which are used in the editor Canvas #7

Closed mrajeshkrossark closed 5 years ago

mrajeshkrossark commented 5 years ago

Hi @artf ,

 I tried to download the images which are used in the editor canvas but I dont know how to do it. 

Note: I pushed images into asset manager with external links like below, editor.AssetManager.add(result.fileUrl);

My ultimate goal is to download the images which are used in the editor canvas during export and replace the src for the all images with local folder called 'images'.

GrapesJSExportDirectory

My export command function:

editor.Commands.add(exptPluginCommand, {
      run() {
        let zip = new JSZip(),
          cssDir = zip.folder("css"),
          //imgDir = zip.folder("images"),
          fn = "healthcare" + Date.now() + ".zip";
        zip.file(
          "index.html",
          preHeadTag +
          scriptsAndStyles +
          postHeadTag +
          editor.getHtml() +
          postHtml
        );
        cssDir.file("style.css", editor.getCss());
        //imgDir.file("test.png", editor.DomComponents.getWrapper().find("img")[0].get("src"));
        zip
          .generateAsync({
            type: "blob"
          })
          .then(content => {
            FileSaver.saveAs(content, fn);
          });
      }
    });

Please help me to get out of this.. Thanks in advance..

artf commented 5 years ago

https://github.com/artf/grapesjs-plugin-export/issues/5#issuecomment-446952302