editor: keybinding clean

vm: global globals
This commit is contained in:
bordun 2020-03-21 12:41:26 +01:00
parent e250d81088
commit b07158008e
2 changed files with 10 additions and 8 deletions

View file

@ -168,7 +168,8 @@ class Editor {
handleKeyboard(combo, e){
if (e.target && e.target.classList.contains('no-keybinding')) return
if (e.target && (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.tagName === 'SELECT')) return
e.preventDefault()
switch (combo) {

View file

@ -1,5 +1,11 @@
var loopProtect = require('loop-protect'),
{deepCopy} = require('../utils')
{deepCopy} = require('../utils'),
globals = {
screen: {width: screen.width, height: screen.height},
env: deepCopy(ENV),
url: document.location.host,
platform: navigator.platform
}
class Vm {
@ -42,12 +48,7 @@ class Vm {
this.sandbox.contentWindow.setInterval = ()=>{
throw 'setTimeout and setInterval can\'t be used in the JS sandbox'
}
this.sandbox.contentWindow.globals = {
screen: {width: screen.width, height: screen.height},
env: deepCopy(ENV),
url: document.location.host,
platform: navigator.platform
}
this.sandbox.contentWindow.globals = globals
// sanitize globals
for (var imports of ['__protect', 'console', 'setTimeout', 'setInterval', 'globals']) {