Skip to content

Commit

Permalink
opening md files, update flow
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 committed Dec 6, 2023
1 parent c9ac6bd commit 2e36d4c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions apps/doc-viewer/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ export default function App() {
setContents(fileContents)
})
}, [])
const edit = () => {
if (!client.mdFile) return
client.call('fileManager', 'open' as any, client.mdFile)
}
return (
<>
<div className="m-5 p-2">
<button className="btn btn-secondary mb-2" onClick={edit}>EDIT</button>
<ReactMarkdown children={contents} remarkPlugins={[remarkGfm]} />
</div>
</>
Expand Down
1 change: 0 additions & 1 deletion apps/remix-ide/src/app/files/fileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ 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
}
}
Expand Down
9 changes: 7 additions & 2 deletions libs/remix-ui/workspace/src/lib/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,13 @@ export const emitContextMenuEvent = async (cmd: customAction) => {
}

export const handleClickFile = async (path: string, type: 'file' | 'folder' | 'gist') => {
await plugin.fileManager.open(path)
dispatch(focusElement([{ key: path, type }]))
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)
dispatch(focusElement([{ key: path, type }]))
}
}

export const handleExpandPath = (paths: string[]) => {
Expand Down

0 comments on commit 2e36d4c

Please sign in to comment.