Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
monaco-volar
Advanced tools
Monaco-volar
has external dependency Onigasm (to highlight code).
pnpm add monaco-volar monaco-editor-core onigasm
# or
yarn add monaco-volar monaco-editor-core onigasm
Import monaco-volar
when you are using monaco. It will register vue as a language automatic.
import 'monaco-editor-core'
import 'monaco-volar'
VSCode are using Onigasm to highlight codes. And we have adapted the Onigasm and monaco. And some pre-defined grammars.
Onigasm needs a wasm module before using. We have to load it first.
import * as onigasm from "onigasm";
import onigasmWasm from "onigasm/lib/onigasm.wasm?url";
function loadOnigasm() {
return onigasm.loadWASM(onigasmWasm);
}
loadOnigasm()
Now we can apply grammars into monaco editor instance.
import { editor } from "monaco-editor-core";
import { loadGrammars, loadTheme } from "monaco-volar";
const theme = loadTheme()
const editorInstance = editor.create(element, {
theme,
/* other options*/
})
loadGrammars(editorInstance);
We need to let monaco know where and how to load out worker when using Vue.
import editorWorker from "monaco-editor-core/esm/vs/editor/editor.worker?worker";
import vueWorker from "monaco-volar/vue.worker?worker";
function loadMonacoEnv() {
(self as any).MonacoEnvironment = {
async getWorker(_: any, label: string) {
if (label === "vue") {
return new vueWorker();
}
return new editorWorker();
},
};
}
loadMonacoEnv()
Now we can just create a model using vue language.
const model = editor.createModel(code, 'vue', uri);
FAQs
Vue support for monaco
The npm package monaco-volar receives a total of 282 weekly downloads. As such, monaco-volar popularity was classified as not popular.
We found that monaco-volar demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.