electron-prompt
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -23,3 +23,5 @@ const electron = require('electron'); | ||
selectOptions: null, | ||
icon: null | ||
icon: null, | ||
useHtmlLabel: false, | ||
customStylesheet: null | ||
}, | ||
@@ -26,0 +28,0 @@ options || {} |
@@ -0,1 +1,2 @@ | ||
const fs = require('fs'); | ||
const {ipcRenderer} = require('electron'); | ||
@@ -45,7 +46,26 @@ const docReady = require('doc-ready'); | ||
promptOptions = JSON.parse(ipcRenderer.sendSync('prompt-get-options:' + promptId)); | ||
} catch (e) { | ||
return promptError(e); | ||
} catch (error) { | ||
return promptError(error); | ||
} | ||
document.getElementById('label').textContent = promptOptions.label; | ||
if (promptOptions.useHtmlLabel) { | ||
document.getElementById('label').innerHTML = promptOptions.label; | ||
} else { | ||
document.getElementById('label').textContent = promptOptions.label; | ||
} | ||
try { | ||
if (promptOptions.customStylesheet) { | ||
const customStyleContent = fs.readFileSync(promptOptions.customStylesheet); | ||
if (customStyleContent) { | ||
const customStyle = document.createElement('style'); | ||
customStyle.setAttribute('rel', 'stylesheet'); | ||
customStyle.appendChild(document.createTextNode(customStyleContent)); | ||
document.head.appendChild(customStyle); | ||
} | ||
} | ||
} catch (error) { | ||
return promptError(error); | ||
} | ||
document.getElementById('ok').addEventListener('click', () => promptSubmit()); | ||
@@ -52,0 +72,0 @@ document.getElementById('cancel').addEventListener('click', () => promptCancel()); |
{ | ||
"name": "electron-prompt", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Electron helper to prompt for a value via input or select", | ||
@@ -11,5 +11,5 @@ "keywords": [ | ||
"author": { | ||
"name": "p-sam", | ||
"email": "p-sam@users.noreply.github.com", | ||
"url": "https://github.com/p-sam" | ||
"name": "p-sam", | ||
"email": "p-sam@users.noreply.github.com", | ||
"url": "https://github.com/p-sam" | ||
}, | ||
@@ -29,3 +29,6 @@ "repository": { | ||
"esnext": true, | ||
"env": ["node", "browser"] | ||
"env": [ | ||
"node", | ||
"browser" | ||
] | ||
}, | ||
@@ -36,4 +39,4 @@ "dependencies": { | ||
"devDependencies": { | ||
"xo": "^0.21.1" | ||
"xo": "^0.23.0" | ||
} | ||
} |
@@ -28,4 +28,3 @@ # electron-prompt | ||
type: 'url' | ||
}, | ||
type: 'select' | ||
} | ||
}) | ||
@@ -52,3 +51,3 @@ .then((r) => { | ||
| Key | Explaination | | ||
| Key | Explanation | | ||
| ------------- | ------------- | | ||
@@ -64,7 +63,10 @@ | width | (optional, integer) The width of the prompt window. Defaults to 370. | | ||
| selectOptions | (optional, object) The items for the select dropdown if using te 'select' type in the format 'value': 'display text', where the value is what will be given to the then block and the display text is what the user will see. | | ||
| useHtmlLabel | (optional, boolean) Whether the label should be interpreted as HTML or not. 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. | | ||
If not supplied, it uses the defaults listed in the table above. | ||
### parentBrowserWindow | ||
### parentBrowserWindow (optional) | ||
(optional) The window in which to display the prompt on. If not supplied, the parent window of the prompt will be null. | ||
The window in which to display the prompt on. If not supplied, the parent window of the prompt will be null. |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11276
254
70
0
1