-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAutoWidth.html
38 lines (38 loc) · 1.34 KB
/
AutoWidth.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>monaco-editor auto width</title>
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
<script src="node_modules/monaco-editor/min/vs/loader.js"></script>
<style>
body { background-color: pink; }
</style>
</head>
<body>
<div class="container">
<div id="container" style="height: 400px;"></div>
<script>
var monacoEditor;
//init monaco
require.config({ paths: { 'vs': 'node_modules/monaco-editor/min/vs' } });
require(['vs/editor/editor.main'], function () {
monacoEditor = monaco.editor.create(document.getElementById('container'), {
value: "<div>我是插入的代码</div>",
language: 'html',
wordWrap: "on", //自动换行,注意大小写
wrappingIndent: "indent"
});
});
//自适应宽度
window.onresize = function () {
if (monacoEditor) {
monacoEditor.layout();
}
};
</script>
</div>
</body>
</html>