Issue #1570Opened November 9, 2018by mrajeshkrossark0 reactions

Not able to customize the Export Plugin options

Question

Hi @artf, I tried to customize the options in the grapesjs editor export plugin. But only two options(addExportBtn, btnLabel) works as expected. Other options such as filenamePfx, filename, root are not working as expected.

My code:

var editor = grapesjs.init({
            container: '#editor-portal',
            fromElement: true,
            clearOnRender: true,
            allowScripts: 1,
            height: '100vh',
            canvas: {
                styles: selectedTemplateExternalStyles,
                scripts: selectedTemplateExternalScripts
            },
            plugins: ['gjs-preset-webpage', 'grapesjs-custom-code'],
            pluginsOpts: {
                'gjs-preset-webpage': {
                    exportOpts: {
                        filenamePfx: 'dummy',
                        filename: 'temp',
                        addExportBtn: 1,
                        btnLabel: 'Export as ZIP',
                        root: {
                            css: {
                                'style.css': ed => ed.getCss(),
                            },
                            html: {
                                'test.html': ed =>
                                    `<!doctype html>
                                 <html lang="en">
                                 <head>
                                 <meta charset="utf-8">
                                 <link rel="stylesheet" href="./css/style.css">
                                    ${ed.Canvas.getConfig().script.map(data=> {debugger;
                                    console.log(data);
                                    return "<script src="+data+"></script>";
                                    })
                                    }
                        </head>
                        <body>${ed.getHtml()}<div>hi</div></body>
                      </html>`
                            }
                        }
                    }
                },
                'grapesjs-custom-code': {

                }
            },
            storageManager: {
                type: null
            },
            assetManager: {
                storageType: '',
                storeOnChange: true,
                storeAfterUpload: true,
                assets: assetImages,
                upload: 0,
                uploadName: 'files',
                uploadFile: function (e) {
                    var reader = new FileReader(),
                        files = e.dataTransfer ? e.dataTransfer.files : e.target.files;
                    reader.readAsDataURL(files[0]);
                    reader.onload = function () {
                        var formData = {};
                        formData.base64 = reader.result;
                        Promise.resolve(agent.WebSiteEditor.saveImages(formData)).then(function (res) {
                            if (res.data !== null && res.data !== 'undefined') {
                                var result = res.data;
                                if (result) {
                                    editor.AssetManager.add(result.fileUrl);
                                } else
                                    return false;
                            } else
                                return false;
                        });
                    };
                    reader.onerror = function (error) {
                        console.log('Error: ', error);
                    };
                },
                embedAsBase64: false,
                disableUpload: false,
                dropzone: false
            }
        });

I just changed addExportBtn variable into 0, the export button not visible in the editor. And changed btnLabel variable from "export to ZIP" into "export as ZIP". The changes are affected. But other than that other options are not able to customize.

Answers (2)

lock[bot]November 9, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.