electron-prompt
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -8,2 +8,5 @@ const electron = require('electron'); | ||
const DEFAULT_WIDTH = 370; | ||
const DEFAULT_HEIGHT = 160; | ||
function electronPrompt(options, parentWindow) { | ||
@@ -15,4 +18,6 @@ return new Promise((resolve, reject) => { | ||
{ | ||
width: 370, | ||
height: 130, | ||
width: DEFAULT_WIDTH, | ||
height: DEFAULT_HEIGHT, | ||
minWidth: DEFAULT_WIDTH, | ||
minHeight: DEFAULT_HEIGHT, | ||
resizable: false, | ||
@@ -27,3 +32,4 @@ title: 'Prompt', | ||
useHtmlLabel: false, | ||
customStylesheet: null | ||
customStylesheet: null, | ||
menuBarVisible: false | ||
}, | ||
@@ -40,2 +46,4 @@ options || {} | ||
height: opts.height, | ||
minWidth: opts.minWidth, | ||
minHeight: opts.minHeight, | ||
resizable: opts.resizable, | ||
@@ -45,3 +53,3 @@ parent: parentWindow, | ||
alwaysOnTop: opts.alwaysOnTop, | ||
useContentSize: true, | ||
useContentSize: opts.resizable, | ||
modal: Boolean(parentWindow), | ||
@@ -56,2 +64,3 @@ title: opts.title, | ||
promptWindow.setMenu(null); | ||
promptWindow.setMenuBarVisibility(opts.menuBarVisible); | ||
@@ -58,0 +67,0 @@ const getOptionsListener = event => { |
@@ -99,8 +99,7 @@ const fs = require('fs'); | ||
dataEl.addEventListener('keyup', e => { | ||
e.which = e.which || e.keyCode; | ||
if (e.which === 13) { | ||
if (e.key === 'Enter') { | ||
promptSubmit(); | ||
} | ||
if (e.which === 27) { | ||
if (e.key === 'Escape') { | ||
promptCancel(); | ||
@@ -107,0 +106,0 @@ } |
{ | ||
"name": "electron-prompt", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Electron helper to prompt for a value via input or select", | ||
@@ -37,4 +37,4 @@ "keywords": [ | ||
"devDependencies": { | ||
"xo": "^0.24.0" | ||
"xo": "^0.25.3" | ||
} | ||
} |
@@ -28,3 +28,4 @@ # electron-prompt | ||
type: 'url' | ||
} | ||
}, | ||
type: 'input' | ||
}) | ||
@@ -53,5 +54,2 @@ .then((r) => { | ||
| ------------- | ------------- | | ||
| width | (optional, integer) The width of the prompt window. Defaults to 370. | | ||
| height | (optional, integer) The height of the prompt window. Defaults to 130. | | ||
| resizable | (optional, boolean) Whether the prompt window can be resized or not. Defaults to false. | | ||
| title | (optional, string) The title of the prompt window. Defaults to 'Prompt'. | | ||
@@ -64,4 +62,11 @@ | label | (optional, string) The label which appears on the prompt for the input field. Defaults to 'Please input a value:'. | | ||
| useHtmlLabel | (optional, boolean) Whether the label should be interpreted as HTML or not. Defaults to false. | | ||
| width | (optional, integer) The width of the prompt window. Defaults to 370. | | ||
| minWidth | (optional, integer) The minimum allowed width for the prompt window. Same default value as width. | | ||
| height | (optional, integer) The height of the prompt window. Defaults to 130. | | ||
| minHeight | (optional, integer) The minimum allowed height for the prompt window. Same default value as height. | | ||
| resizable | (optional, boolean) Whether the prompt window can be resized or not (also sets useContentSize). Defaults to false. | | ||
| alwaysOnTop | (optional, boolean) Whether the window should always stay on top of other windows. Defaults to false | | ||
| icon | (optional, string) The path to an icon image to use in the title bar. Defaults to null and uses electron's icon. | | ||
| customStylesheet | (optional, string) The local path of a CSS file to stylize the prompt window. Defaults to null. | | ||
| menuBarVisible | (optional, boolean) Whether to show the menubar or not. Defaults to false. | | ||
@@ -68,0 +73,0 @@ If not supplied, it uses the defaults listed in the table above. |
Sorry, the diff of this file is not supported yet
12043
264
75