Pull request that gives items more control over the save process


#1

I’m working on a pull request to give items more control over the save process, by allowing them to specify the save dialogue options. Does this seem like a reasonable approach?


#2

What does it look like in practice?


#3

The pane item (i.e. TextEditor or some other custom pane item created by an opener) has the option to implement getSaveOptions with returns options that will be used to show the save panel. For example:

getSaveOptions: ->
  {} =
    filters: [
      name: 'Outlines'
      extensions: [ 'opml', 'ftml' ]
    ]

#4

I would recommend documenting the options that are supported.


#5

The options are the same as electron dialog.showsavedialog.

I can document more in the code but I’m unsure right now. I don’t know if it makes sense to make this a public API at this point. Implementing your own pane item already means following lots of undocumented convention… I was thinking this would be a small internal change to how things work that would allow easier control of the save panel using a bit more undocumented convention.

I think eventually the way to document it would be to add a public documented textEditor.getSaveOptions method. Does that seem reasonable?


Also here’s a related request and use case for this request, i.e. it would likely be useful outside of my particular use case:


#6

Even if it isn’t a public API, it can still be documented. Just use the Private: or Experimental: tag at the beginning of the documentation block. Documenting it separately from dialog.showsavedialog would show what you’ve tested (hopefully) and verified works as intended.


#7

Thanks, I’ve documented it by adding a private method comment in TextEditor that describes how it will be used.