🍎 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:
parent
9163b601a4
commit
1d612a12a1
9 changed files with 72 additions and 9 deletions
|
@ -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)
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue