diff --git a/apps/doc-viewer/src/app/App.tsx b/apps/doc-viewer/src/app/App.tsx index 5f5092eb24..6052af9393 100644 --- a/apps/doc-viewer/src/app/App.tsx +++ b/apps/doc-viewer/src/app/App.tsx @@ -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 ( <>
+
diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index cd19ade6ed..9b80a5fcf7 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -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 } } diff --git a/libs/remix-ui/workspace/src/lib/actions/index.ts b/libs/remix-ui/workspace/src/lib/actions/index.ts index 82f71e40f4..d6d9d3204d 100644 --- a/libs/remix-ui/workspace/src/lib/actions/index.ts +++ b/libs/remix-ui/workspace/src/lib/actions/index.ts @@ -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[]) => {