ShadowEditor/ShadowEditor.ScriptEditor
2018-11-15 22:14:02 +08:00
..
2018-11-15 07:39:39 +08:00
2018-11-14 21:48:51 +08:00
2018-11-15 07:39:39 +08:00
2018-11-14 21:48:51 +08:00
2018-11-15 22:14:02 +08:00
2018-11-15 22:14:02 +08:00
2018-11-14 20:32:02 +08:00

ShadowEditor.ScriptEditor

脚本编辑器,支持javascriptvertexShaderfragmentShaderjson,支持代码智能提示。

使用方法

var container = document.getElementById('container');
var editor = new Shadow.ScriptEditor(container);

editor.setValue(`function HelloWorld() {\r\n  alert('Hello, world!'); \r\n}\r\n\r\nHelloWorld();`, 'javascript');

console.log(editor.getValue());

API参考

new Shadow.ScriptEditor(container); // 创建脚本编辑器

editor.setValue(
    source = '', 
    mode = 'javascript', 
    cursorPosition = { line: 0, ch: 0 }, 
    scrollInfo = { left: 0, top: 0 }
    ) // 设置代码

editor.getValue() // 获取代码

editor.clear(); // 清空代码