forked from GrapesJS/mjml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.js
49 lines (43 loc) · 1.11 KB
/
commands.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import tglImagesCommand from './toggleImagesCommand';
import importCommand from './command-import-mjml';
import exportCommand from './command-export-mjml';
export default (editor, opt = {}) => {
const cmd = editor.Commands;
const exportName = opt.overwriteExport ? 'export-template' : 'mjml-export';
cmd.add('mjml-import', importCommand(editor, opt));
cmd.add('mjml-import:change', {
run() {
const code = editor.getHtml();
return code.trim();
}
});
cmd.add(exportName, exportCommand(editor, opt));
cmd.add(opt.cmdTglImages, tglImagesCommand(opt));
cmd.add('undo', {
run(editor, sender) {
sender.set('active', 0);
editor.UndoManager.undo(1);
}
});
cmd.add('redo', {
run(editor, sender) {
sender.set('active', 0);
editor.UndoManager.redo(1);
}
});
cmd.add('set-device-desktop', {
run(editor) {
editor.setDevice('Desktop');
}
});
cmd.add('set-device-tablet', {
run(editor) {
editor.setDevice('Tablet');
}
});
cmd.add('set-device-mobile', {
run(editor) {
editor.setDevice('Mobile portrait');
}
});
};