Skip to content

Commit 5e39c74

Browse files
authored
Merge pull request #37 from artf/v1-update
Migrate to TS and grapesjs-cli
2 parents 8e625a8 + 53f5d23 commit 5e39c74

11 files changed

+5004
-6140
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_modules/
44
.eslintrc
55
*.log
66
_index.html
7+
dist/

README.md

+8-20
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ Add the [TOAST UI Image Editor](https://ui.toast.com/tui-image-editor/) on Image
77
![Preview](https://user-images.githubusercontent.com/11614725/52981724-c195f800-33e1-11e9-98a9-f071a2721761.png)
88

99

10-
11-
12-
1310
## Summary
1411

1512
* Plugin name: `grapesjs-tui-image-editor`
1613
* Commands
17-
* `tui-image-editor` - Open the modal with the image editor
14+
* `tui-image-editor` - Open the modal with the image editor.
1815
Options:
19-
* `target` - component on which to get and update the image
16+
* `target` - component from which to get and update the image
2017

2118

2219

@@ -33,14 +30,13 @@ Add the [TOAST UI Image Editor](https://ui.toast.com/tui-image-editor/) on Image
3330
|`height`|Default editor height|`650px`|
3431
|`width`|Default editor width|`100%`|
3532
|`commandId`|Id to use to create the image editor command|`tui-image-editor`|
36-
|`toolbarIcon`|Icon used in the component toolbar|`<svg ....`|
33+
|`toolbarIcon`|Icon used in the image component toolbar. Pass an empty string to avoid adding the icon.|`<svg ....`|
3734
|`hideHeader`|Hide the default editor header|`true`|
3835
|`onApply`|By default, GrapesJS takes the modified image, adds it to the Asset Manager and update the target. If you need some custom logic you can use this custom 'onApply' function. `onApply: (imageEditor, imageModel) => {...}`|`null`|
3936
|`addToAssets`|If no custom `onApply` is passed and this option is `true`, the result image will be added to assets|`true`|
4037
|`upload`|If no custom `onApply` is passed, on confirm, the edited image, will be passed to the AssetManager's uploader and the result (eg. instead of having the dataURL you'll have the URL) will be passed to the default `onApply` process (update target, etc.)|`false`|
4138
|`onApplyButton`|The apply button (HTMLElement) will be passed as an argument to this function, once created. This will allow you a higher customization.|`null`|
42-
|`icons`| The TOAST UI editor isn't compiled with icons, so generally, you should download them and indicate the local path in the `includeUI.theme` configurations. Use this option to change them or set it to `false` to keep what is come in `includeUI.theme`. By default, the plugin will try to use the editor's remote icons (which involves a cross-origin async request, indicated as unsafe by most of the browsers) |`{'menu.normalIcon.path': ...`|
43-
|`script`|Scripts to load dynamically in case no TOAST UI editor constructor is found|`['...fabric.js', '...tui-code-snippet.js', '...tui-color-picker.js', '...tui-image-editor.min.js']`|
39+
|`script`|Scripts to load dynamically in case no TOAST UI editor constructor is found|`['...tui-code-snippet.js', '...tui-color-picker.js', '...tui-image-editor.min.js']`|
4440
|`style`|In case the `script` is loaded this style will be loaded too|`['...tui-color-picker.css', '...tui-image-editor.css']`|
4541

4642

@@ -82,14 +78,6 @@ Directly in the browser
8278
initMenu: 'filter',
8379
},
8480
},
85-
icons: {
86-
'menu.normalIcon.path': '../icon-d.svg',
87-
'menu.activeIcon.path': '../icon-b.svg',
88-
'menu.disabledIcon.path': '../icon-a.svg',
89-
'menu.hoverIcon.path': '../icon-c.svg',
90-
'submenu.normalIcon.path': '../icon-d.svg',
91-
'submenu.activeIcon.path': '../icon-c.svg',
92-
},
9381
}
9482
}
9583
});
@@ -99,18 +87,18 @@ Directly in the browser
9987
Modern javascript
10088
```js
10189
import grapesjs from 'grapesjs';
102-
import tUIImageEditor from 'grapesjs-tui-image-editor';
90+
import plugin from 'grapesjs-tui-image-editor';
10391

10492
const editor = grapesjs.init({
10593
container : '#gjs',
10694
// ...
107-
plugins: [tUIImageEditor],
95+
plugins: [plugin],
10896
pluginsOpts: {
109-
[tUIImageEditor]: { /* options */ }
97+
[plugin]: { /* options */ }
11098
}
11199
// or
112100
plugins: [
113-
editor => tUIImageEditor(editor, { /* options */ }),
101+
editor => plugin(editor, { /* options */ }),
114102
],
115103
});
116104
```

dist/grapesjs-tui-image-editor.min.js

-3
This file was deleted.

dist/grapesjs-tui-image-editor.min.js.map

-1
This file was deleted.

index.html

+10-14
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
77
<script src="https://unpkg.com/grapesjs"></script>
88
<script src="https://unpkg.com/grapesjs-blocks-basic"></script>
9-
<script src="dist/grapesjs-tui-image-editor.min.js"></script>
109
<style>
1110
body,
1211
html {
@@ -26,20 +25,17 @@
2625

2726

2827
<script type="text/javascript">
29-
var editor = grapesjs.init({
30-
height: '100%',
31-
showOffsets: 1,
32-
noticeOnUnload: 0,
33-
storageManager: { autoload: 0 },
34-
container: '#gjs',
35-
fromElement: true,
36-
37-
plugins: ['grapesjs-blocks-basic', 'grapesjs-tui-image-editor'],
38-
pluginsOpts: {
39-
'grapesjs-tui-image-editor': { some: 'value' }
40-
}
28+
setTimeout(() => {
29+
window.editor = grapesjs.init({
30+
height: '100%',
31+
showOffsets: true,
32+
noticeOnUnload: false,
33+
storageManager: false,
34+
container: '#gjs',
35+
fromElement: true,
36+
plugins: ['gjs-blocks-basic', 'grapesjs-tui-image-editor'],
37+
});
4138
});
42-
window.editor = editor;
4339
</script>
4440
</body>
4541
</html>

0 commit comments

Comments
 (0)