Skip to content

Commit

Permalink
Merge pull request #18 from artf/up-deps
Browse files Browse the repository at this point in the history
Move to grapesjs-cli and TS
  • Loading branch information
artf authored Aug 4, 2022
2 parents 687a29b + 3183fc5 commit 0e706fd
Show file tree
Hide file tree
Showing 12 changed files with 4,225 additions and 6,103 deletions.
13 changes: 0 additions & 13 deletions dist/grapesjs-plugin-export.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/grapesjs-plugin-export.min.js.map

This file was deleted.

67 changes: 67 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import grapesjs from 'grapesjs';

export declare type Editor = grapesjs.Editor;
export declare type PluginOptions = {
/**
* Type id used to register the new storage.
* You can use this option in case you want to replace the already available storages (eg. `local`).
* @default 'indexeddb'
*/
type?: string;
/**
* Add a button inside the export dialog
* @default true
*/
addExportBtn?: boolean;
/**
* Label of the export button
* @default 'Export to ZIP'
*/
btnLabel?: string;
/**
* ZIP filename prefix
* @default 'grapesjs_template'
*/
filenamePfx?: string;
/**
* Use a function to generate the filename, eg. `filename: editor => 'my-file.zip',`
*/
filename?: (editor: Editor) => string;
/**
* Callback to execute once the export is completed
*/
done?: () => void;
/**
* Callback to execute on export error
*/
onError?: (error: Error) => void;
/**
* Use the root object to create the folder structure of your zip (async functions are supported)
* @example
* root: {
* css: {
* 'style.css': ed => ed.getCss(),
* 'some-file.txt': 'My custom 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' }
* },
* 'index.html': ed => `<body>${ed.getHtml()}</body>`
* }
*/
root?: Record<string, unknown>;
/**
* Custom function for checking if the file content is binary
*/
isBinary?: (content: string, name: string) => boolean;
};
declare const plugin: grapesjs.Plugin<PluginOptions>;

export {
plugin as default,
};

export {};
3 changes: 3 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<title>GrapesJS Plugin Export</title>
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="dist/grapesjs-plugin-export.min.js"></script>
</head>
<style>
body, html{ height: 100%; margin: 0;}
Expand All @@ -16,17 +15,18 @@
<style>.red {color: red}</style>
</div>
<script type="text/javascript">
var editor = grapesjs.init({
noticeOnUnload: 0,
container : '#gjs',
height: '100%',
fromElement: 1,
storageManager: { autoload: 0 },
plugins: ['grapesjs-plugin-export'],
pluginsOpts: {
'grapesjs-plugin-export': {
}
}
setTimeout(() => {
var editor = grapesjs.init({
noticeOnUnload: 0,
container : '#gjs',
height: '100%',
fromElement: 1,
storageManager: false,
plugins: [
editor => editor.on('log-plugin-export', console.log),
'grapesjs-plugin-export'
],
});
});
</script>
</body>
Expand Down
Loading

0 comments on commit 0e706fd

Please sign in to comment.