如何编辑在只读设置为 true 的情况下尝试在 Monaco 编辑器中编辑代码时显示的工具提示?
另一方面,与 readOnly 选项相比,domReadOnly 选项的功能是什么?
用于输入的文本区域是否应该使用 DOM readonly 属性。默认为 false。
我检查了将 readOnly 和 domReadOnly 选项设置为 true 的行为,后者似乎将编辑器设置为 readOnly 而不渲染工具提示。但是我找不到任何有关更改工具提示的样式和内容的信息。
只需使用
domReadOnly: true
var editor = monaco.editor.create(document.getElementById('container'), {
value: "// First line\nfunction hello() {\n\talert('Hello world!');\n}\n// Last line",
language: 'javascript',
lineNumbers: 'off',
roundedSelection: false,
scrollBeyondLastLine: false,
readOnly: true,
domReadOnly: true,
theme: 'vs-dark',
onDidAttemptReadOnlyEdit: () => false
});
有一个名为
readOnlyMessage
的编辑器选项: https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IEditorOptions.html#readOnlyMessage