forked from joshuabenuck/wiki-electrified
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreload.js
39 lines (34 loc) · 1.17 KB
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const {SpellCheckHandler, ContextMenuListener, ContextMenuBuilder} = require('electron-spellchecker')
window.spellCheckHandler = new SpellCheckHandler();
window.spellCheckHandler.attachToInput();
window.spellCheckHandler.switchLanguage('en-US');
let contextMenuBuilder = new ContextMenuBuilder(window.spellCheckHandler);
let contextMenuListener = new ContextMenuListener((info) => {
contextMenuBuilder.showPopupMenu(info);
});
window.prompt = (promptText) => {
let input = document.getElementById('dialogAnswer')
if (input && input.value) {
let answer = input.value
input.value = ''
return answer
}
let dialog = document.getElementById('prompt')
if (!dialog) {
dialog = document.createElement('dialog')
dialog.setAttribute('id', 'prompt')
dialog.innerHTML = `
<div>${promptText}</div>
<form method='dialog'>
<input id='dialogAnswer' type='text' style='width: 100%'></input>
</form>
`
document.body.append(dialog)
let dialogOK = document.getElementById('dialogOK')
dialog.addEventListener('close', () => {
let lock = document.getElementById('show-security-dialog')
lock.click()
})
}
dialog.showModal()
}