I am very new to CodeMirror and am struggling with the markers. What I want to archive are error and warning messages like here in CM6: https://codemirror.net/demo/lint.html
I am building a json schema validator and want to show error messages myself so I am looking for a function to add a marker to a specific line number. Could someone help?
thanks for the quick hint. I checked out lint and if you have the “start” and “end” of the error this is very convenient to use. That is what I used for testing:
function validationErrorMarker(view) {
let diagnostics = [];
diagnostics.push({
from: 70, to: 76,
severity: "error",
message: `Invalid type. Expected Integer, Null but got String.`
});
return diagnostics
}
let json_editor = new EditorView({
state: EditorState.create({
doc: '',
extensions: [
basicSetup,
json(),
updateListenerExtension,
linter(validationErrorMarker),
lintGutter()
]
}),
parent: document.getElementById('json')
})