-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c199638
commit 7aa7fc8
Showing
1 changed file
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,45 @@ | ||
const loadMonaco = require('monaco-loader') | ||
const { remote } = require('electron') | ||
const { Menu, app } = remote | ||
|
||
loadMonaco().then((monaco) => { | ||
const element = document.querySelector('#container') | ||
const options = { | ||
language: 'javascript', | ||
theme: 'vs-dark', | ||
automaticLayout: true | ||
automaticLayout: true, | ||
// We'll make our own | ||
contextmenu: false | ||
} | ||
|
||
const editor = monaco.editor.create(element, options) | ||
|
||
// Context menu | ||
const template = [ | ||
{ role: 'cut' }, | ||
{ role: 'copy' }, | ||
{ role: 'paste' }, | ||
{ | ||
label: 'Minimize Window', | ||
click (item, browserWindow, event) { | ||
browserWindow.minimize() | ||
} | ||
}, | ||
{ | ||
type: 'separator' | ||
}, | ||
{ | ||
label: 'Quit', | ||
click () { | ||
app.quit() | ||
} | ||
} | ||
] | ||
|
||
const menu = Menu.buildFromTemplate(template) | ||
|
||
window.addEventListener('contextmenu', (e) => { | ||
e.preventDefault() | ||
menu.popup(remote.getCurrentWindow()) | ||
}, false) | ||
}) |