|
|
@ -5,6 +5,7 @@ import EventEmitter from 'events' |
|
|
|
export class DocViewer extends PluginClient { |
|
|
|
export class DocViewer extends PluginClient { |
|
|
|
mdFile: string |
|
|
|
mdFile: string |
|
|
|
eventEmitter: EventEmitter |
|
|
|
eventEmitter: EventEmitter |
|
|
|
|
|
|
|
refreshId: any |
|
|
|
constructor() { |
|
|
|
constructor() { |
|
|
|
super() |
|
|
|
super() |
|
|
|
this.eventEmitter = new EventEmitter() |
|
|
|
this.eventEmitter = new EventEmitter() |
|
|
@ -14,9 +15,17 @@ export class DocViewer extends PluginClient { |
|
|
|
this.onload() |
|
|
|
this.onload() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async viewDocs(docs: string[]) { |
|
|
|
private async refresh() { |
|
|
|
this.mdFile = docs[0] |
|
|
|
if (!this.mdFile) return clearInterval(this.refreshId) |
|
|
|
const contents = await this.call('fileManager', 'readFile', this.mdFile) |
|
|
|
const contents = await this.call('fileManager', 'readFile', this.mdFile) |
|
|
|
this.eventEmitter.emit('contentsReady', contents) |
|
|
|
this.eventEmitter.emit('contentsReady', contents) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async viewDocs(docs: string[]) { |
|
|
|
|
|
|
|
this.mdFile = docs[0] |
|
|
|
|
|
|
|
this.refresh() |
|
|
|
|
|
|
|
this.refreshId = setInterval(async () => { |
|
|
|
|
|
|
|
this.refresh() |
|
|
|
|
|
|
|
}, 500) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |