Syntax validation #16
-
Ola, I need to create a syntax validation (js, html, css) for the monaco-editor in nuxt, I found nothing about it, any tips? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
By setting However, HTML couldn't be checked in this way. Using <script setup>
import HTMLMonacoLinter from 'monaco-html-linter'
const onEditorLoad = (editor) => {
const monaco = useMonaco()
const linter = new HTMLMonacoLinter(editor, monaco)
linter.watch()
}
</script>
<template>
<MonacoEditor lang="html" @load="onEditorLoad" />
</template> If you need to create error markers by yourself, try this with the latest version of const onEditorLoad = (editor) => {
const monaco = useMonaco()
const model = editor.getModel()
monaco.editor.setModelMarkers(model, 'owner', [
{
startLineNumber: 1,
startColumn: 1,
endLineNumber: 1,
endColumn: 5,
message: 'Error!',
severity: monaco.MarkerSeverity.Error
}
])
} |
Beta Was this translation helpful? Give feedback.
-
it does not find the function useMonaco(), it suggests monaco(), but when us change to the suggestion it says it can not be accessed before startup
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Now it worked, I created another project because I can not do the migration following the documentation, do you know how to tell me how to do the best way? Thank you |
Beta Was this translation helpful? Give feedback.
-
Ola my friend, manage to advance in the project by changing the version of nuxt2 to the 3, I saw your examples of la codes on github, thank you very much for the tips. I wanted to ask you if you know any example of code for implement custom functions in the editor, so when the client is going to use the auto-complete be also my functions integrated in the editor |
Beta Was this translation helpful? Give feedback.
By setting
lang
prop of<MonacoEditor>
tojavascript(typescript)
,css
, (or alsojson
), monaco-editor enables syntax checking automatically.However, HTML couldn't be checked in this way. Using
monaco-html-linter
is one of the best ways.If you need to create error markers by yourself, try this with the latest version of
nuxt-monaco-editor
: