How can I display carriage return in the editor, if I have ‘\r’ in my content then I have to display cr in the editor, else I can code that my manipulating the Monaco dom but I need to get the dom node for a particular line, in which layer I can access getDomNodeForLine()
,
currently, I’m hard coding like this but Its not working properly
const configureEndOfLine = (editor: MonacoEditor) => {
const createSpan = () => {
let span = document.createElement('span');
span.className = 'mtkw';
span.innerText = 'cr';
return span;
}
const appendCr = () => {
let content = editor.getControl().getValue()
let arr = content.split('\n')
let lines = editor.node.getElementsByClassName('view-line');
for (let i = 0; i < lines.length; i++) {
let line = lines.item(i);
let lineCon = arr[i];
if (!lineCon.endsWith('\r')) continue;
if (line.children[0].children.length > 0 && line.children[0].children[line.children[0].children.length - 1].innerHTML !== 'cr')
line.children[0].appendChild(createSpan());
}
}
editor.onCursorPositionChanged(() => appendCr())
editor.onDocumentContentChanged(() => appendCr())
editor.onFocusChanged(() => appendCr())
editor.onScrollChanged(() => appendCr())
}