mirror of
https://github.com/Qortal/qortal-ui.git
synced 2025-04-27 13:27:51 +00:00
Add spell check to context menu
This commit is contained in:
parent
38d4c38393
commit
521f4ca396
@ -31,8 +31,6 @@ class MainApp extends connect(store)(LitElement) {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
88
electron.js
88
electron.js
@ -3,6 +3,7 @@ const {
|
||||
BrowserWindow,
|
||||
ipcMain,
|
||||
Menu,
|
||||
MenuItem,
|
||||
Notification,
|
||||
Tray,
|
||||
dialog,
|
||||
@ -1133,6 +1134,42 @@ function createWindow() {
|
||||
myWindow.once('ready-to-show', myWindow.show)
|
||||
myWindow.loadURL('http://localhost:12388/app')
|
||||
|
||||
myWindow.webContents.on('context-menu', (event, params) => {
|
||||
event.preventDefault()
|
||||
const menu = new Menu()
|
||||
// Add each spelling suggestion (if any)
|
||||
if (params.dictionarySuggestions && params.dictionarySuggestions.length > 0) {
|
||||
for (const suggestion of params.dictionarySuggestions) {
|
||||
menu.append(new MenuItem({
|
||||
label: suggestion,
|
||||
click: () => myWindow.webContents.replaceMisspelling(suggestion)
|
||||
}))
|
||||
}
|
||||
}
|
||||
// Allow users to add the misspelled word to the dictionary if there is one
|
||||
if (params.misspelledWord) {
|
||||
menu.append(
|
||||
new MenuItem({
|
||||
label: 'Add to dictionary',
|
||||
click: () => myWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord)
|
||||
})
|
||||
)
|
||||
}
|
||||
// Add a separator if we added suggestions or add-to-dictionary items
|
||||
if ((params.dictionarySuggestions && params.dictionarySuggestions.length > 0) || params.misspelledWord) {
|
||||
menu.append(new MenuItem({ type: 'separator' }))
|
||||
}
|
||||
// Now add your existing menu items (like copy, paste, etc.)
|
||||
menu.append(new MenuItem({ role: 'undo' }))
|
||||
menu.append(new MenuItem({ role: 'redo' }))
|
||||
menu.append(new MenuItem({ type: 'separator' }))
|
||||
menu.append(new MenuItem({ role: 'cut' }))
|
||||
menu.append(new MenuItem({ role: 'copy' }))
|
||||
menu.append(new MenuItem({ role: 'paste' }))
|
||||
menu.append(new MenuItem({ role: 'selectAll' }))
|
||||
menu.popup({ window: myWindow })
|
||||
})
|
||||
|
||||
// Save current window config when closing
|
||||
myWindow.on('close', () => {
|
||||
// Save current maximized state
|
||||
@ -1364,57 +1401,6 @@ if (!isLock) {
|
||||
checkOsPlatform()
|
||||
})
|
||||
|
||||
ipcMain.on('show-my-menu', (event) => {
|
||||
let homePageOptions = Menu.buildFromTemplate([
|
||||
{
|
||||
label: i18n.__("electron_translate_35"),
|
||||
role: 'copy'
|
||||
},
|
||||
{
|
||||
label: i18n.__("electron_translate_36"),
|
||||
role: 'paste'
|
||||
},
|
||||
{
|
||||
type: "separator"
|
||||
},
|
||||
{
|
||||
label: i18n.__("electron_translate_37"),
|
||||
submenu: [
|
||||
{
|
||||
label: i18n.__("electron_translate_38"),
|
||||
role: 'zoomIn'
|
||||
},
|
||||
{
|
||||
label: i18n.__("electron_translate_39"),
|
||||
role: 'zoomOut'
|
||||
},
|
||||
{
|
||||
label: i18n.__("electron_translate_40"),
|
||||
role: 'resetZoom'
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
},
|
||||
{
|
||||
label: i18n.__("electron_translate_41"),
|
||||
role: 'togglefullscreen'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "separator"
|
||||
},
|
||||
{
|
||||
label: i18n.__("electron_translate_42"),
|
||||
click: function () {
|
||||
createNewWindow()
|
||||
},
|
||||
}
|
||||
])
|
||||
|
||||
homePageOptions.popup(myWindow)
|
||||
})
|
||||
|
||||
autoUpdater.on('update-available', (event) => {
|
||||
const downloadOpts = {
|
||||
type: 'info',
|
||||
|
@ -4,7 +4,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
setStartCore: () => ipcRenderer.send('set-start-core'),
|
||||
startCore: () => ipcRenderer.send('start-core-electron'),
|
||||
checkForUpdate: () => ipcRenderer.send('check-for-update'),
|
||||
showMyMenu: () => ipcRenderer.send('show-my-menu'),
|
||||
focusApp: () => ipcRenderer.send('focus-app'),
|
||||
clearMyCache: () => ipcRenderer.send('clear-all-cache'),
|
||||
clearCache() {
|
||||
|
@ -95,8 +95,6 @@ class BecomeMinter extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -329,8 +329,6 @@ class QortalInfoView extends LitElement {
|
||||
|
||||
firstUpdated() {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -209,8 +209,6 @@ class DataManagement extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -822,8 +822,6 @@ class GroupManagement extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -252,8 +252,6 @@ class MintingInfo extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -425,8 +425,6 @@ class NameRegistration extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -367,8 +367,6 @@ class NamesMarket extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -204,8 +204,6 @@ class NodeManagement extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,6 @@ class OverviewPage extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -161,8 +161,6 @@ class Puzzles extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -260,8 +260,6 @@ class QApps extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -367,10 +367,6 @@ class Chat extends LitElement {
|
||||
}
|
||||
target = target.parentNode
|
||||
}
|
||||
|
||||
// If it doesn't, show the default Electron context menu
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -258,8 +258,6 @@ class QWebsites extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -242,8 +242,6 @@ class WebBrowser extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -293,8 +293,6 @@ class PublishData extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -243,8 +243,6 @@ class QortalLottery extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -200,8 +200,6 @@ class RewardShare extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -401,8 +401,6 @@ class SponsorshipList extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1021,8 +1021,6 @@ class TradeBotPortal extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -588,8 +588,6 @@ class TradePortal extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2278,8 +2278,6 @@ class MultiWallet extends LitElement {
|
||||
if (!isElectron()) {
|
||||
} else {
|
||||
window.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault()
|
||||
window.parent.electronAPI.showMyMenu()
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user