Integrate MDC syntax with Monaco Editor.
#using yarn
yarn add @nuxtlabs/monarch-mdc
# using npm
npm install @nuxtlabs/monarch-mdc
import * as monaco from 'monaco-editor'
import { language as markdownLanguage } from '@nuxtlabs/monarch-mdc'
// Register language
monaco.languages.register({ id: 'mdc' })
monaco.languages.setMonarchTokensProvider('mdc', markdownLanguage);
const code = `
Your **awesome** markdown
`
// Create monaco model
const model = monaco.editor.createModel(
code,
'mdc'
)
// Create your editor
const el = ... // DOM element
const editor = monaco.editor.create(el, {
model,
// Monaco edito options
// see: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html
})
Checkout the Editor.vue for a complete example.
- Clone repository
- Install dependencies using
pnpm install
- Try playground using
pnpm dev
MIT - Made with 💚