npm.io
0.14.12 • Published 2 weeks ago

@scalar/use-codemirror

Licence
MIT
Version
0.14.12
Deps
15
Size
71 kB
Vulns
0
Weekly
0
Stars
15.4K

CodeMirror Hook for Vue

Version Downloads License Discord

Installation

npm install @scalar/use-codemirror

Usage

<script setup>
import { useCodeMirror } from '@scalar/use-codemirror'
import { ref } from 'vue'

const editor = ref(null)

const { codeMirror, setCodeMirrorContent } = useCodeMirror({
  codeMirrorRef: editor,
  content: '{ "foo": "bar" }',
  language: 'json',
  lineNumbers: true,
  onChange: (value) => {
    console.log('Content changed:', value)
  },
})
</script>

<template>
  <div ref="editor" />
</template>

Community

We are API nerds. You too? Let's chat on Discord: https://discord.gg/scalar

License

The source code in this repository is licensed under MIT.