如何将 monaco-editor 从只读设置为可写?

Joh*_*ton 8 javascript typescript monaco-editor

在我的代码中,我创建了一个编辑器,如下所示:

this.monacoEditor = monaco.editor
  .create(
    document.getElementById('ide'), {
      model: null,
      readOnly: true,
      contextmenu: false,
    }
  );
Run Code Online (Sandbox Code Playgroud)

所以现在该编辑器是只读的。我如何更改this.monacoEditor为可写/可编辑?

Joh*_*ton 13

我想到了。在上面代码的上下文中:

this.monacoEditor.updateOptions({readOnly: false});
Run Code Online (Sandbox Code Playgroud)