##What I want to do
When I open a markdown file, I want Atom to automatically toggle the markdown-preview mode.
##What I did so far
Content of my
atom.workspace.onDidAddPaneItem (event) -> if event.item.getGrammar().name is 'GitHub Markdown' atom.commands.dispatch(atom.views.getView(atom.workspace), 'markdown-preview:toggle')
##What could help to solve the problem
If the markdown file tab is open and I run the atom.commands.dispatch(atom.views.getView(atom.workspace), ‘markdown-preview:toggle’) command, it will work.
I think there are 2 possible approaches to do this, I juste need to figure out how to do this:
Switch current tab to the one displaying the markdown file and run the toggle command
Get the markdown tab and apply the toggle command
I’m fairly new to the Atom API. Your help will be appreciated! Thanks.