Skip to content

nuxtlabs/monarch-mdc

Repository files navigation

@nuxtlabs/monarch-mdc

npm version npm downloads License

Integrate MDC syntax with Monaco Editor.

Installation

#using yarn
yarn add @nuxtlabs/monarch-mdc
# using npm
npm install @nuxtlabs/monarch-mdc

Usage

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.

💻 Development

  • Clone repository
  • Install dependencies using pnpm install
  • Try playground using pnpm dev

License

MIT - Made with 💚