-
Notifications
You must be signed in to change notification settings - Fork 356
Add "Save as HTML" to Command Palette. Resolves #432 #434
Conversation
This is my first attempt at adding a feature. This PR should add the "Save as HTML" command to the command palette along with two tests to check that it works in the following scenarios:
|
AppVeyor job failures seem unrelated to this pull request: https://ci.appveyor.com/project/Atom/markdown-preview/history Is anyone able to let me know if this isn't the case? |
|
||
runs -> | ||
expect(fs.isFileSync(outputPath)).toBe true | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra newline
waitsForPromise -> atom.workspace.open("subdir/simple.markdown") | ||
runs -> atom.commands.dispatch workspaceElement, 'markdown-preview:toggle' | ||
expectPreviewInSplitPane() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra newline
return unless editor.getGrammar().scopeName in grammars | ||
|
||
uri = @uriForEditor(editor) | ||
previewPane = atom.workspace.paneForURI(uri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this markdownPreviewPane to be more explicit (especially since there used to be a Tabs setting called "Preview Panes" or similar).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used previewPane
to retain consistency with lines 75-77:
previewPane = atom.workspace.paneForURI(uri)
if previewPane?
previewPane.destroyItem(previewPane.itemForURI(uri))
Happy to amend the lines relevant to #432 to use markdownPreviewPane
but I assume lines 75-77 should be addressed as part of a new issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, if there's other places using this then let's keep it consistent.
Following code review by @50Wliu I have renamed variables to be more explicit and reduce the possibility of confusion with a previous Tabs setting called "Preview Panes" or similar.
activePane = atom.workspace.getActivePaneItem() | ||
|
||
if isMarkdownPreviewView(activePane) | ||
activePane.saveAs(). then -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the extra space before then
there for a reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No reason at all, a miss on my part. Thanks for highlighting it.
|
||
runs -> | ||
spyOn(atom, 'showSaveDialogSync').andReturn(outputPath) | ||
console.log(outputPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last thing: 🔥 this line.
@billglover You got the other console.log but not the one that my comment was on :P. |
Noted! |
Ideally there should be no uses of console at all, but that code was probably written before the Notifications package was created. Thanks for this! |
No description provided.