Skip to content

Instantly share code, notes, and snippets.

@nojaja
Last active June 19, 2017 15:33
Show Gist options
  • Save nojaja/5043c6a5dcc997395685f121a9efe12e to your computer and use it in GitHub Desktop.
Save nojaja/5043c6a5dcc997395685f121a9efe12e to your computer and use it in GitHub Desktop.
Monaco-Editor component
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Frontpage layout example - UIkit documentation</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.12.0/css/uikit.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/jquery-migrate-3.0.0.js"></script>
<script src="./node_modules/monaco-editor/min/vs/loader.js"></script>
</head>
<body>
<div>
<MonacoEditor id="test" style="height: 800px;" />
</div>
<element name="Monaco-Editor">
<script language='es6'>
componentDidMount() {
var $container = document.getElementById(this.props.id);
require.config({ paths: { vs: "./node_modules/monaco-editor/min/vs" }});
require(['vs/editor/editor.main'], function() {
var editor = monaco.editor.create($container, {
automaticLayout: true,
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
});
});
}
</script>
<template>
<div id={this.props.id} style={this.props.style} ></div>
</template>
</element>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment