File size: 753 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import CodeModeCommand from './codeMode.command';

export default class CodeModeButton {
  editor;

  /**
   * Add close button with save for Mautic
   */
  constructor(editor) {
    if (!editor) {
      throw new Error('no editor');
    }
    this.editor = editor;
  }

  addButton() {
    this.editor.Panels.addButton('options', [
      {
        id: 'code-edit',
        className: 'ri-edit-line',
        attributes: {
          title: Mautic.translate('grapesjsbuilder.sourceEditModalTitle'),
        },
        command: CodeModeCommand.name,
      },
    ]);
  }

  addCommand() {
    this.editor.Commands.add(CodeModeCommand.name, {
      run: CodeModeCommand.launchCodeEditorModal,
      stop: CodeModeCommand.stopCodeEditorModal,
    });
  }
}