微软开源代码编辑器monaco-editor
官网上给出:”The Monaco Editor is the code editor that powers VS Code. A good page describing the code editor's features is here.
It is licensed under the MIT License and supports IE 9/10/11, Edge, Chrome, Firefox, Safari and Opera.“
Monaco Editor 展现还是非常牛的,直接上图:

https://microsoft.github.io/monaco-editor/
下面给出一个入门教程:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</head>
<body> <div id="container" style="width:800px;height:600px;border:1px solid grey"></div>
<div id="container2" style="width:800px;height:600px;border:1px solid grey"></div>
<script src="min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'min/vs' }});
require(['vs/editor/editor.main'], function() {
var editor = monaco.editor.create(document.getElementById('container'), {
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
}); var editor2 = monaco.editor.create(document.getElementById('container2'), {
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'csharp',
theme:'vs-dark'
}); }); function changeTheme(theme) {
var newTheme = (theme === 1 ? 'vs-dark' : ( theme === 0 ? 'vs' : 'hc-black' ));
if (editor) {
editor.updateOptions({ 'theme' : newTheme });
}
if (diffEditor) {
diffEditor.updateOptions({ 'theme': newTheme });
}
}
</script>
</body>
</html>

对Javascript语言是有智能提示的,如上图所示。

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</head>
<body> <div id="diff-editor" style="width:800px;height:600px;border:1px solid grey"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js" integrity="sha256-wS9gmOZBqsqWxgIVgA8Y9WcQOa7PgSIX+rPA0VL2rbQ=" crossorigin="anonymous"></script>
<script src="min/vs/loader.js"></script>
<script> // $(document).ready(function() {
// require.config({ paths: { 'vs': 'min/vs' }});
// require(['vs/editor/editor.main'], function() { // var editor = monaco.editor.create(document.getElementById('container'), {
// value: [
// 'function x() {',
// '\tconsole.log("Hello world!");',
// '}'
// ].join('\n'),
// language: 'csharp',
// theme:'vs-dark'
// }); // }); // window.onresize = function () {
// if (editor) {
// editor.layout();
// }
// if (diffEditor) {
// diffEditor.layout();
// }
// };
// });
var preloaded = {}; function xhr(url, cb) {
if (preloaded[url]) {
return cb(null, preloaded[url]);
}
$.ajax({
type: 'GET',
url: url,
dataType: 'text',
error: function () {
cb(this, null);
}
}).done(function(data) {
cb(null, data);
});
}
function loadDiffSample() { var onError = function() {
// $('.loading.diff-editor').fadeOut({ duration: 200 });
// $('#diff-editor').append('<p class="alert alert-error">Failed to load diff editor sample</p>');
}; var lhsData = null, rhsData = null, jsMode = null; xhr('txt/diff.lhs.txt', function(err, data) {
if (err) {
return onError();
}
lhsData = data;
onProgress();
})
xhr('txt/diff.rhs.txt', function(err, data) {
if (err) {
return onError();
}
rhsData = data;
onProgress();
}) function onProgress() {
if (lhsData && rhsData) {
require.config({ paths: { 'vs': 'min/vs' }});
require(['vs/editor/editor.main'], function() {
diffEditor = monaco.editor.createDiffEditor(document.getElementById('diff-editor'), {
enableSplitViewResizing: false
}); var lhsModel = monaco.editor.createModel(lhsData, 'text/javascript');
var rhsModel = monaco.editor.createModel(rhsData, 'text/javascript'); diffEditor.setModel({
original: lhsModel,
modified: rhsModel
});
});
//$('.loading.diff-editor').fadeOut({ duration: 300 });
}
}
}
function changeTheme(theme) {
var newTheme = (theme === 1 ? 'vs-dark' : ( theme === 0 ? 'vs' : 'hc-black' ));
if (editor) {
editor.updateOptions({ 'theme' : newTheme });
}
if (diffEditor) {
diffEditor.updateOptions({ 'theme': newTheme });
}
} loadDiffSample();
</script>
</body>
</html>

微软开源代码编辑器monaco-editor的更多相关文章
- VSCode, 当今最流行的免费开源代码编辑器,微软出品,必属精品
什么是VSCode? Visual Studio Code是一个轻量级但功能强大的源代码编辑器,可在您的桌面上运行,并且可用于Windows,macOS和Linux.它内置了对JavaScript,T ...
- 秒杀Sublime Text的微软开源代码编辑工具Visual Studio Code
1. 下载链接: https://code.visualstudio.com/ 2. 秒开一个ASP.NET网站源码 3.编辑CSS颜色支持 4.Git支持 5.常用快捷键 Ctrl+Shift+P ...
- Asp.Net Core 使用Monaco Editor 实现代码编辑器
在项目中经常有代码在线编辑的需求,比如修改基于Xml的配置文件,编辑Json格式的测试数据等.我们可以使用微软开源的在线代码编辑器Monaco Editor实现这些功能.Monaco Editor是著 ...
- NanUI for Winform 使用示例【第一集】——山寨个代码编辑器
NanUI for Winform从昨天写博客发布到现在获得了和多朋友的关注,首先感谢大家的关注和支持!请看昨天本人的博文<NanUI for Winform发布,让Winform界面设计拥有无 ...
- Monaco Editor 使用入门
以前项目是用ace编辑器的,但是总有些不敬人意的地方.前端事件看见的VS Code编辑器Monaco Editor准备更换下,下面介绍一些使用中遇到的一点问题.代码提示 1.项目引用 import * ...
- 微软良心之作——Visual Studio Code 开源免费跨平台代码编辑器
微软良心之作——Visual Studio Code 开源免费跨平台代码编辑器 在 Build 2015 大会上,微软除了发布了 Microsoft Edge 浏览器和新的 Windows 10 预览 ...
- Vue cli2.0 项目中使用Monaco Editor编辑器
monaco-editor 是微软出的一条开源web在线编辑器支持多种语言,代码高亮,代码提示等功能,与Visual Studio Code 功能几乎相同. 在项目中可能会用带代码编辑功能,或者展示代 ...
- ACE 1.1.9 发布,开源云端代码编辑器
点这里 ACE 1.1.9 发布,开源云端代码编辑器 oschina 发布于: 2015年04月06日 (1评) 分享到: 收藏 +25 4月18日 武汉 源创会开始报名,送华为开发板 ACE ...
- Github Atom开源文本代码编辑器- 由 Github 打造的下一代编程开发利器
个人理解:Github 热度超凡的一个项目Atom,electron是整个atom的核心,对于electron可以理解成 electron =io.js + Chromium 通过 Electr ...
随机推荐
- AutoMapper随笔记
平台之大势何人能挡? 带着你的Net飞奔吧! http://www.cnblogs.com/dunitian/p/4822808.html#skill 先看效果:(完整Demo:https://git ...
- Java 8五大主要功能为开发者提供了哪些便利?
两年前当Java 8发布后,立即受到了业界的欢迎,因为它大大提高了Java的性能.它独特的卖点是,顾及了编程语言的每一个方面,包括JVM(Java虚拟机)和编译器,并且改良了其它帮助系统. Java是 ...
- 界面设计技法之css布局
css布局之于页面就如同ECMAScript之于JS一般,细想一番,html就如同语文,css就如同数学,js呢,就是物理,有些扯远,这里就先不展开了. 回到主题,从最开始的css到如今的sass(l ...
- css_02之盒模型、渐变
1.框模型:盒模型,①对象实际宽度=左右外边距+左右边框+左右内边距 + width:②对象实际高度=上下外边距+上下边框+上下内边距 + height: 2.外边距:margin:取值:①top(上 ...
- 【干货分享】流程DEMO-出差申请单
流程名: 出差申请 业务描述: 员工出差前发起流程申请,流程发起时,会检查预算,如果预算不够,将不允许发起费用申请,如果预算够用,将发起流程,同时占用相应金额的预算,但撤销流程会释放相应金额的预算. ...
- css实现文本框和下拉框结合的案例
html 代码部分 <div id="list-name-input" class="list-name-input"> <select ty ...
- 超全面的.NET GDI+图形图像编程教程
本篇主题内容是.NET GDI+图形图像编程系列的教程,不要被这个滚动条吓到,为了查找方便,我没有分开写,上面加了目录了,而且很多都是源码和图片~ (*^_^*) 本人也为了学习深刻,另一方面也是为了 ...
- AutoMapper使用中的问题
指定值只会执行一次 public class MomanBaseProfile : Profile { public MomanBaseProfile() { CreateMap<Request ...
- SEO:权重如何做到从0到1
SEO:权重如何做到从0到1 [写于2016年9月]我真的好久好久没到我的博客上去看过了,今天突然登上 seo.chinaz.com,搜索 dkplus.iteye.com,发现自己的博客在百度收录中 ...
- nuget常用命令
nuget命令的用法: 一.安装 1.安装指定版本类库install-package <程序包名> -version <版本号> 2.安装到指定的项目install-packa ...