🍎 Add additional options for Mac's save dialog

Support additional attributes available in macOS's NSSavePanel: message,
nameFieldLabel and showsTagField
This commit is contained in:
Tan Wang Leng 2017-02-01 23:34:21 +08:00
parent 9163b601a4
commit 1d612a12a1
9 changed files with 72 additions and 9 deletions

View file

@ -136,7 +136,8 @@ module.exports = {
}
}
let {buttonLabel, defaultPath, filters, title} = options
let {buttonLabel, defaultPath, filters, title, message, nameFieldLabel,
showsTagField} = options
if (title == null) {
title = ''
@ -160,10 +161,27 @@ module.exports = {
filters = []
}
if (message == null) {
message = ''
} else if (typeof message !== 'string') {
throw new TypeError('Message must be a string')
}
if (nameFieldLabel == null) {
nameFieldLabel = ''
} else if (typeof nameFieldLabel !== 'string') {
throw new TypeError('Name field label must be a string')
}
if (showsTagField == null) {
showsTagField = false
}
const wrappedCallback = typeof callback === 'function' ? function (success, result) {
return callback(success ? result : void 0)
} : null
return binding.showSaveDialog(title, buttonLabel, defaultPath, filters,
message, nameFieldLabel, showsTagField,
window, wrappedCallback)
},