Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
});
// replace schema:
// Press Chord Ctrl-K, Ctrl-R => the action will run if it is enabled
editor.addAction({
// An unique identifier of the contributed action.
id: 'replace-meta-schema',
// A label of the action that will be presented to the user.
label: 'Replace Meta Schema',
// An optional array of keybindings for the action.
keybindings: [
monaco.KeyMod.chord(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_K, monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_R)
],
// A precondition for this action.
precondition: null,
// A rule to evaluate on top of the precondition in order to dispatch the keybindings.
keybindingContext: null,
contextMenuGroupId: 'navigation',
contextMenuOrder: 1.5,
// Method that will be executed when the action is triggered.
// @param editor The editor instance is passed in as a convinience
run: (ed) => {
const result = window.prompt("Paste schema to replace current meta schema", "{}");
this.eventHub.emit('modifySettings', {
compileOnChange: !this.settings.compileOnChange
});
this.alertSystem
.notify('Compile on change has been toggled ' + (this.settings.compileOnChange ? 'ON' : 'OFF'), {
group: "togglecompile",
alertClass: this.settings.compileOnChange ? "notification-on" : "notification-off",
dismissTime: 3000
});
}, this)
});
this.editor.addAction({
id: 'clang-format',
label: 'Format text',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F9],
keybindingContext: null,
contextMenuGroupId: 'help',
contextMenuOrder: 1.5,
run: _.bind(this.formatCurrentText, this)
});
this.editor.addAction({
id: 'toggleColourisation',
label: 'Toggle colourisation',
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyMod.Shift | monaco.KeyCode.F1],
keybindingContext: null,
run: _.bind(function () {
this.eventHub.emit('modifySettings', {
colouriseAsm: !this.settings.colouriseAsm
});
}, this)
setTimeout(() => {
if (isStandaloneCodeEditor(editor)) {
editor.addCommand(
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S,
() => {
if (this.props.onDidSave) {
this.props.onDidSave()
}
},
''
)
}
})
}
public componentDidMount() {
this.editor = monaco.editor.create(this.editorElement.current!, {
language: 'javascript',
codeLens: true,
automaticLayout: true,
theme: 'vs-dark',
minimap: { enabled: false },
value: this.props.code ? this.props.code : '',
})
this.editor.createContextKey('cond1', true)
this.editor.createContextKey('cond2', true)
this.disposables.push(this.editor.onDidFocusEditorText(this.handleFocusEditor))
this.editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, this.handleClose, 'cond1')
this.editor.focus()
}