Skip to content

Commit 0e706fd

Browse files
authored
Merge pull request #18 from artf/up-deps
Move to grapesjs-cli and TS
2 parents 687a29b + 3183fc5 commit 0e706fd

File tree

12 files changed

+4225
-6103
lines changed

12 files changed

+4225
-6103
lines changed

dist/grapesjs-plugin-export.min.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

dist/grapesjs-plugin-export.min.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/index.d.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import grapesjs from 'grapesjs';
2+
3+
export declare type Editor = grapesjs.Editor;
4+
export declare type PluginOptions = {
5+
/**
6+
* Type id used to register the new storage.
7+
* You can use this option in case you want to replace the already available storages (eg. `local`).
8+
* @default 'indexeddb'
9+
*/
10+
type?: string;
11+
/**
12+
* Add a button inside the export dialog
13+
* @default true
14+
*/
15+
addExportBtn?: boolean;
16+
/**
17+
* Label of the export button
18+
* @default 'Export to ZIP'
19+
*/
20+
btnLabel?: string;
21+
/**
22+
* ZIP filename prefix
23+
* @default 'grapesjs_template'
24+
*/
25+
filenamePfx?: string;
26+
/**
27+
* Use a function to generate the filename, eg. `filename: editor => 'my-file.zip',`
28+
*/
29+
filename?: (editor: Editor) => string;
30+
/**
31+
* Callback to execute once the export is completed
32+
*/
33+
done?: () => void;
34+
/**
35+
* Callback to execute on export error
36+
*/
37+
onError?: (error: Error) => void;
38+
/**
39+
* Use the root object to create the folder structure of your zip (async functions are supported)
40+
* @example
41+
* root: {
42+
* css: {
43+
* 'style.css': ed => ed.getCss(),
44+
* 'some-file.txt': 'My custom content',
45+
* },
46+
* img: async ed => {
47+
* const images = await fetchImagesByStructue(ed.getComponents());
48+
* return images;
49+
* // Where `images` is an object like this:
50+
* // { 'img1.png': '...png content', 'img2.jpg': '...jpg content' }
51+
* },
52+
* 'index.html': ed => `<body>${ed.getHtml()}</body>`
53+
* }
54+
*/
55+
root?: Record<string, unknown>;
56+
/**
57+
* Custom function for checking if the file content is binary
58+
*/
59+
isBinary?: (content: string, name: string) => boolean;
60+
};
61+
declare const plugin: grapesjs.Plugin<PluginOptions>;
62+
63+
export {
64+
plugin as default,
65+
};
66+
67+
export {};

dist/index.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<title>GrapesJS Plugin Export</title>
66
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
77
<script src="https://unpkg.com/grapesjs"></script>
8-
<script src="dist/grapesjs-plugin-export.min.js"></script>
98
</head>
109
<style>
1110
body, html{ height: 100%; margin: 0;}
@@ -16,17 +15,18 @@
1615
<style>.red {color: red}</style>
1716
</div>
1817
<script type="text/javascript">
19-
var editor = grapesjs.init({
20-
noticeOnUnload: 0,
21-
container : '#gjs',
22-
height: '100%',
23-
fromElement: 1,
24-
storageManager: { autoload: 0 },
25-
plugins: ['grapesjs-plugin-export'],
26-
pluginsOpts: {
27-
'grapesjs-plugin-export': {
28-
}
29-
}
18+
setTimeout(() => {
19+
var editor = grapesjs.init({
20+
noticeOnUnload: 0,
21+
container : '#gjs',
22+
height: '100%',
23+
fromElement: 1,
24+
storageManager: false,
25+
plugins: [
26+
editor => editor.on('log-plugin-export', console.log),
27+
'grapesjs-plugin-export'
28+
],
29+
});
3030
});
3131
</script>
3232
</body>

0 commit comments

Comments
 (0)