@elecmonkey/monaco-cpp-editor
v0.1.0
Published
A Monaco-based C/C++ editor component.
Maintainers
Readme
Monaco C++ Editor
A Monaco-based C/C++ editor component for Vue 3 with Tree-sitter syntax analysis.
✨ Features
- 🎨 Monaco Editor Integration - Full Monaco Editor functionality
- 🔍 Syntax Highlighting - Enhanced C/C++ syntax highlighting
- ⚡ Real-time Error Detection - Tree-sitter powered syntax analysis
- 📝 Code Completion - Smart code completion for C/C++
- 🎯 Type-Safe - Written in TypeScript
- 🚀 Vue 3 Native - Built with Vue 3 Composition API
- 📦 Self-Contained - No external dependencies needed
📦 Installation
pnpm add monaco-cpp-editor
# or
npm install monaco-cpp-editor
# or
yarn add monaco-cpp-editor🚀 Quick Start
<script setup lang="ts">
import { ref } from 'vue'
import { MonacoCppEditor } from 'monaco-cpp-editor'
const code = ref(`#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
`)
</script>
<template>
<MonacoCppEditor v-model="code" />
</template>📖 API
Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| modelValue | string | '' | Editor content (v-model) |
| language | 'cpp' \| 'c' | 'cpp' | Programming language |
| theme | 'vs' \| 'vs-dark' \| 'hc-black' | 'vs-dark' | Editor theme |
| readOnly | boolean | false | Whether editor is read-only |
| minimap | boolean | false | Show minimap |
| fontSize | number | 14 | Font size |
| markers | EditorMarker[] | [] | Error/warning markers |
| monacoOptions | monaco.editor.IStandaloneEditorConstructionOptions | {} | Additional Monaco options |
Events
| Event | Payload | Description |
|-------|---------|-------------|
| update:modelValue | string | Emitted when content changes |
| ready | monaco.editor.IStandaloneCodeEditor | Emitted when editor is ready |
| change | string | Emitted when content changes |
Exposed Methods
const editorRef = ref<InstanceType<typeof MonacoCppEditor>>()
// Get current value
const value = editorRef.value?.getValue()
// Set value
editorRef.value?.setValue('new code')
// Get position at offset
const pos = editorRef.value?.getPositionAt(100)🛠️ Development
Install dependencies
pnpm installRun playground
pnpm run playgroundRun tests
pnpm run testBuild library
pnpm run buildType check
pnpm run typecheck📄 License
MIT
