opening md files, update flow

pull/5370/head
yann300 12 months ago
parent 78097a4045
commit a2f7301d7c
  1. 5
      apps/doc-viewer/src/app/App.tsx
  2. 1
      apps/remix-ide/src/app/files/fileManager.ts
  3. 5
      libs/remix-ui/workspace/src/lib/actions/index.ts

@ -12,9 +12,14 @@ export default function App() {
setContents(fileContents) setContents(fileContents)
}) })
}, []) }, [])
const edit = () => {
if (!client.mdFile) return
client.call('fileManager', 'open' as any, client.mdFile)
}
return ( return (
<> <>
<div className="m-5 p-2"> <div className="m-5 p-2">
<button className="btn btn-secondary mb-2" onClick={edit}>EDIT</button>
<ReactMarkdown children={contents} remarkPlugins={[remarkGfm]} /> <ReactMarkdown children={contents} remarkPlugins={[remarkGfm]} />
</div> </div>
</> </>

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

@ -344,8 +344,13 @@ export const emitContextMenuEvent = async (cmd: customAction) => {
} }
export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => { export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => {
if (type === 'file' && path.endsWith('.md')) {
// just opening the preview
await plugin.call('doc-viewer' as any, 'viewDocs', [path])
} else {
await plugin.fileManager.open(path) await plugin.fileManager.open(path)
dispatch(focusElement([{ key: path, type }])) dispatch(focusElement([{ key: path, type }]))
}
} }
export const handleExpandPath = (paths: string[]) => { export const handleExpandPath = (paths: string[]) => {

Loading…
Cancel
Save