| 28 | |
| 29 | export default class EditorController extends SubController { |
| 30 | constructor(port) { |
| 31 | super(port); |
| 32 | if (!port) { |
| 33 | this.mainType = 'editor'; |
| 34 | this.id = getUUID(); |
| 35 | } |
| 36 | this.state = { |
| 37 | popupId: null, |
| 38 | popupOpenerTabId: null, |
| 39 | keyringId: null, |
| 40 | integration: false, |
| 41 | userInfo: null |
| 42 | }; |
| 43 | this.peerType = 'editorController'; |
| 44 | this.popup = null; |
| 45 | this.signKeyFpr = null; |
| 46 | this.pgpMIME = false; |
| 47 | this.options = {}; |
| 48 | // register event handlers |
| 49 | this.on('editor-mount', this.onEditorMount); |
| 50 | this.on('editor-load', this.onEditorLoad); |
| 51 | this.on('editor-plaintext', this.onEditorPlaintext); |
| 52 | this.on('editor-user-input', this.onEditorUserInput); |
| 53 | this.on('key-lookup', this.onKeyLookup); |
| 54 | // standalone editor only |
| 55 | this.on('editor-close', this.onEditorClose); |
| 56 | this.on('sign-only', this.onSignOnly); |
| 57 | // API only |
| 58 | this.on('editor-container-encrypt', this.onEditorContainerEncrypt); |
| 59 | this.on('editor-container-create-draft', this.onEditorContainerCreateDraft); |
| 60 | this.on('editor-options', this.onEditorOptions); |
| 61 | this.on('open-app', ({fragment}) => this.openApp(fragment)); |
| 62 | } |
| 63 | |
| 64 | async onEditorMount() { |
| 65 | this.ports.editor.emit('set-mode', { |