
我正在使用 monaco-editor,这个是 monaco 的一个在线测试页面
p>这个是我的配置var editor = monaco.editor.create(document.getElementById("container"), { value: "", language: "sql", lineNumbers: "off", roundedSelection: false, scrollBeyondLastLine: false, readOnly: false, theme: "vs-dark", fontSize: 18, fontWeight: '800', formatOnPaste: true // 粘贴自动格式化的配置 }); 我在右边渲染出的编辑器中粘贴这段代码
select * from abc where abc.a="abc";select * from cba where cba.a="cba"; 发现编辑器并没有进行格式化操作
我应该怎么去正确地使用 formatOnPaste
1 gucheen 2023-06-12 17:33:58 +08:00 monaco 没有内置的 sql 格式化逻辑,你可以自己添加一个 关键词 registerDocumentFormattingEditProvider |
3 yxcoder OP @yxcoder ``` var editor = monaco.editor.create(document.getElementById("container"), { value: "", language: "Javascript", lineNumbers: "off", roundedSelection: false, scrollBeyondLastLine: false, readOnly: false, theme: "vs-dark", fontSize: 18, fontWeight: '800', formatOnPaste: true // 粘贴自动格式化的配置 }); ``` 右侧输入 ``` function hello() {alert('Hello world!');} ``` 一样没有进行格式化操作 |