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)
- Wrong repository
- Look at the version: https://github.com/artf/grapesjs-preset-webpage/blob/master/package.json#L53
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.
Issue #1057
Countdown time is not working correctly
Hi artf, I have checked on live website, Countdown time is not working correctly as minute column accept only 0,1,2,4,5 digits only means i...
Issue #1660
Content will automatically removed while edit in editor
Hello @artf I am facing an issue with grapes.js while editing any textual content. I am using grapes.js Version 0.14.37 with angular 1.6.1....
Issue #950
Editor.setdevice() not working properly on some browsers.
I am changing the device by using editor.setdevice function by calling it in document.ready function. On most devices it is working fine bu...
Issue #1317
Special characters in minified version
Dear @artf If using grapes.min.js rather than grape.js, Special characters are showing in view code dialog. I think Unicode characters are...
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.