load md tab

pull/4301/head
yann300 12 months ago
parent 9eaaa5170f
commit e622f8d2b8
  1. 13
      apps/doc-viewer/src/app/docviewer.ts
  2. 1
      apps/remix-ide/src/app/files/fileManager.ts

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

@ -741,6 +741,7 @@ class FileManager extends Plugin {
// TODO: Only keep `this.emit` (issue#2210)
this.emit('currentFileChanged', file)
this.events.emit('currentFileChanged', file)
if (file.endsWith('.md')) await this.call('doc-viewer' as any, 'viewDocs', [file])
return true
}
}

Loading…
Cancel
Save