Skip to content

createDiffEditor

原文链接

https://microsoft.github.io/monaco-editor/docs.html#functions/editor.createDiffEditor.html

js
const diffEditor = editor.createDiffEditor(
  document.querySelector(".editor"),
  {
    renderSideBySide: true, // renderSideBySide: false 行内比较
  }
);
diffEditor.setModel({
  original: editor.createModel(
    "function add(a, b) { return a + b; }",
    "javascript"
  ),
  modified: editor.createModel(
    "function add(a, b){ return a + b; }",
    "javascript"
  ),
});
  • 输出:

renderSideBySide: false 行内比较

renderSideBySide: true 并排视图比较