| 106 | } |
| 107 | |
| 108 | async save() { |
| 109 | const value: any = {}; |
| 110 | const editorViews = this.resource.editorViews; |
| 111 | if (!editorViews) { |
| 112 | return; |
| 113 | } |
| 114 | for (let i = 0; i < editorViews.length; i++) { |
| 115 | const name = editorViews[i].viewName; |
| 116 | const saveResult = await this.editorViews.get(name)?.save(); |
| 117 | value[name] = saveResult; |
| 118 | } |
| 119 | const result = await this.resource.save(value); |
| 120 | this.emitter.emit('handle.save'); |
| 121 | |
| 122 | return result; |
| 123 | } |
| 124 | |
| 125 | onSave(fn: () => void) { |
| 126 | this.emitter.on('handle.save', fn); |