monaco-editor npm version: Latest
Is there an API to render multiple cursors?
I'd like these secondary cursors disconnected from keyboard input. They would be for display only.
If you'd want to add something for display purposes only, you can use decorations. You can create decorations that look like cursors.
e.g.
You can run the following at https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-line-and-inline-decorations by replacing the JS/CSS parts with:
var jsCode = [
'"use strict";',
'function Person(age) {',
' if (age) {',
' this.age = age;',
' }',
'}',
'Person.prototype.getAge = function () {',
' return this.age;',
'};'
].join('\n');
var editor = monaco.editor.create(document.getElementById("container"), {
value: jsCode,
language: "javascript"
});
var decorations = editor.deltaDecorations([], [
{ range: new monaco.Range(3, 1, 3, 2), options: { className: 'my-cursor'} },
]);
.my-cursor {
background: black;
width: 2px !important;
}
The vertical line on line 3 is not a cursor:

Most helpful comment
If you'd want to add something for display purposes only, you can use decorations. You can create decorations that look like cursors.
e.g.
You can run the following at https://microsoft.github.io/monaco-editor/playground.html#interacting-with-the-editor-line-and-inline-decorations by replacing the JS/CSS parts with:
The vertical line on line 3 is not a cursor: