(config?: EditorConfig, components?: Editor['components'])
| 131 | } |
| 132 | |
| 133 | async init(config?: EditorConfig, components?: Editor['components']): Promise<any> { |
| 134 | this.config = config || {} |
| 135 | this.components = components || {} |
| 136 | const { hooks = [], lifeCycles } = this.config |
| 137 | |
| 138 | this.emit(EDITOR_EVENT.BEFORE_INIT) |
| 139 | const init = (lifeCycles && lifeCycles.init) || ((): void => {}) |
| 140 | |
| 141 | try { |
| 142 | await init(this) |
| 143 | // 注册快捷键 |
| 144 | // 注册 hooks |
| 145 | this.registerHooks(hooks) |
| 146 | this.emit(EDITOR_EVENT.AFTER_INIT) |
| 147 | |
| 148 | return true |
| 149 | } catch (err) { |
| 150 | logger.error(err) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | destroy() { |
| 155 | if (!this.config) { |
no test coverage detected