File size: 828 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 CodeEditor from './codeEditor';

export default class CodeModeCommand {
  /**
   * The command to run on button click
   */
  static name = 'preset-mautic:code-edit';

  static codeEditor;

  static launchCodeEditorModal(editor, sender, opts) {
    if (!editor) {
      throw new Error('no editor');
    }

    CodeModeCommand.codeEditor = new CodeEditor(editor, opts);

    if (sender) {
      sender.set('active', 0);
    }

    CodeModeCommand.codeEditor.showCodePopup(editor);

    // Transform DC Component to token
    editor.runCommand('preset-mautic:dynamic-content-components-to-tokens');
  }

  static stopCodeEditorModal(editor) {
    if (!editor) {
      throw new Error('no editor');
    }
    // Transform Token to Components
    editor.runCommand('preset-mautic:update-dc-components-from-dc-store');
  }
}