https://github.com/bazingaedward/monaco-editor-vue3
Monaco Editor for Vue3
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 7 committers (14.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.0%) to scientific vocabulary
Keywords
Repository
Monaco Editor for Vue3
Basic Info
- Host: GitHub
- Owner: bazingaedward
- License: mit
- Language: TypeScript
- Default Branch: main
- Homepage: https://bazingaedward.github.io/monaco-editor-vue3/
- Size: 1.43 MB
Statistics
- Stars: 105
- Watchers: 2
- Forks: 15
- Open Issues: 8
- Releases: 2
Topics
Metadata Files
README.md
Monaco Editor Vue3
Monaco Editor is the code editor that powers VS Code, now it's available as Vue 3 components <CodeEditor> and <DiffEditor> with full TypeScript support and modern Vue 3 features.
✨ Features
- 🎯 Full TypeScript Support - Built with TypeScript for better development experience
- 🎨 Rich Code Editing - Syntax highlighting, auto-completion, IntelliSense
- 🌍 Multi-Language Support - 20+ programming languages including JavaScript, TypeScript, Python, Java
- 🎭 Theme Customization - Built-in themes (VS, VS Dark, High Contrast) with custom theme support
- 🔄 Two-Way Binding - Full v-model support for seamless Vue 3 integration
- 📦 Lightweight - Tree-shakable and optimized for production
- 🛠 Developer Friendly - Comprehensive error handling, loading states, and lifecycle hooks
- 🎪 Advanced Features - Dual editor support (CodeEditor + DiffEditor), Hooks API, custom components
📚 Documentation
📦 Install
```bash
Using pnpm (recommended)
pnpm add monaco-editor-vue3 monaco-editor
Using yarn
yarn add monaco-editor-vue3 monaco-editor
Using npm
npm install monaco-editor-vue3 monaco-editor ```
🎨 Styles Import
Important: You need to import the CSS styles for Monaco Editor Vue3 to work properly:
ts
// In your main.ts or App.vue
import 'monaco-editor-vue3/dist/style.css'
Or in your CSS file:
css
@import 'monaco-editor-vue3/dist/style.css';
Note: The CSS file contains essential styles for the editor's loading states, error boundaries, and layout. Without it, the editor may not display correctly.
🚀 Quick Start
Basic CodeEditor
```vue
```
DiffEditor for Code Comparison
```vue
```
⚙️ Build Tool Integration
Webpack
Use monaco-editor-webpack-plugin:
```js // webpack.config.js const MonacoEditorPlugin = require('monaco-editor-webpack-plugin');
module.exports = { plugins: [ new MonacoEditorPlugin({ // https://github.com/Microsoft/monaco-editor-webpack-plugin#options // Include a subset of languages support // Some language extensions like typescript are so huge that may impact build performance // e.g. Build full languages support with webpack 4.0 takes over 80 seconds // Languages are loaded on demand at runtime languages: ['javascript', 'css', 'html', 'typescript'], }), ], module: { rules: [ { test: /.css$/, use: ['style-loader', 'css-loader'] } ] } }; ```
Don't forget to import the styles in your main entry file:
js
// main.js or main.ts
import 'monaco-editor-vue3/dist/style.css';
Vite
For Vite projects, the CSS import is handled automatically. Just import the styles in your main file:
```ts // main.ts import { createApp } from 'vue'; import App from './App.vue'; import 'monaco-editor-vue3/dist/style.css'; // Import styles
createApp(App).mount('#app'); ```
Check out our live demo for a complete Vite setup.
Rollup
Use rollup-plugin-monaco-editor:
```js // rollup.config.js import { nodeResolve } from '@rollup/plugin-node-resolve'; import postcss from 'rollup-plugin-postcss'; import commonjs from '@rollup/plugin-commonjs'; import monaco from 'rollup-plugin-monaco-editor';
export default { output: { format: 'es', dir: 'dist', }, // ...other config plugins: [ // ...other plugins // Handle .css files (important for Monaco Editor Vue3 styles) postcss({ extract: true, minimize: true, }), monaco({ languages: ['json'], }), nodeResolve(), commonjs(), ], }; ```
Make sure to import the CSS in your application:
js
// main.js
import 'monaco-editor-vue3/dist/style.css';
🎨 Supported Languages & Themes
Programming Languages
Monaco Editor Vue3 supports 20+ programming languages:
| Language | Identifier | Features |
|----------|------------|----------|
| JavaScript | javascript | ✅ Syntax highlighting, IntelliSense, Error detection |
| TypeScript | typescript | ✅ Syntax highlighting, IntelliSense, Type checking |
| JSON | json | ✅ Syntax highlighting, Validation, Formatting |
| HTML | html | ✅ Syntax highlighting, Auto-completion |
| CSS | css | ✅ Syntax highlighting, Color decorators |
| Python | python | ✅ Syntax highlighting, Basic IntelliSense |
| Java | java | ✅ Syntax highlighting, Basic IntelliSense |
| C++ | cpp | ✅ Syntax highlighting |
| SQL | sql | ✅ Syntax highlighting, Keywords |
| Markdown | markdown | ✅ Syntax highlighting, Preview |
And many more: xml, yaml, shell, php, go, rust, swift, etc.
Built-in Themes
| Theme | Identifier | Description |
|-------|------------|-------------|
| VS Light | vs | Light theme similar to VS Code light |
| VS Dark | vs-dark | Dark theme similar to VS Code dark |
| High Contrast Black | hc-black | High contrast dark theme |
| High Contrast Light | hc-light | High contrast light theme |
Custom Themes
```vue ```
🎮 API Overview
CodeEditor Props
| Property | Type | Default | Description |
|----------|------|---------|-------------|
| value | string | '' | Editor content (supports v-model) |
| language | string | 'javascript' | Programming language |
| theme | string | 'vs' | Editor theme |
| width | string \| number | '100%' | Editor width |
| height | string \| number | '100%' | Editor height |
| options | EditorOptions | {} | Monaco editor options |
Events
editorWillMount
- Params:
monaco- Monaco module - Description: Called before mounting the editor
editorDidMount
- Params:
editor- IStandaloneCodeEditor for CodeEditor, IStandaloneDiffEditor for DiffEditor - Description: Called when the editor is mounted
change
- Params:
value- New editor valueevent- The event from onDidChangeModelContent
- Description: Editor value is updated
Advanced Features
Loading State & Error Handling
```vue <CodeEditor v-model:value="code" language="javascript" :lifecycle="lifecycleHooks" @error="handleError" @ready="handleReady" @loading="handleLoading"
<!-- Custom loading slot --> <template #loading="{ loading, progress }"> <div>Loading... {{ progress }}%</div> </template>
<!-- Custom error slot -->
<template #error="{ error, retry }">
<div>Error: {{ error.message }}</div>
<button @click="retry">Retry</button>
</template>
```
Hooks API
```vue ```
🔧 TypeScript Support
Monaco Editor Vue3 is built with TypeScript and provides comprehensive type definitions out of the box.
Auto Type Inference
```vue ```
Editor Instance Types
```ts import type { IStandaloneCodeEditor, IStandaloneDiffEditor } from 'monaco-editor';
// CodeEditor instance type const handleCodeEditorMount = (editor: IStandaloneCodeEditor) => { editor.focus(); };
// DiffEditor instance type
const handleDiffEditorMount = (editor: IStandaloneDiffEditor) => {
editor.getOriginalEditor().focus();
};
```
Custom Type Declaration (if needed)
If you encounter any type issues, create types/monaco-editor-vue3.d.ts:
ts
declare module 'monaco-editor-vue3' {
// Custom type declarations
}
🔧 Troubleshooting
Editor Not Displaying Correctly
If the Monaco Editor appears broken or unstyled, make sure you have imported the required CSS:
ts
// In your main.ts/main.js or component
import 'monaco-editor-vue3/dist/style.css';
Common Issues
| Issue | Solution |
|-------|----------|
| Editor container is empty | Import monaco-editor-vue3/dist/style.css |
| Loading spinner not showing | Ensure CSS is imported and container has height |
| Error boundary not styled | Import the CSS file in your main entry point |
| Custom themes not working | Check if Monaco Editor worker files are loaded correctly |
Build Issues
If you encounter build issues:
- Webpack: Ensure you're using
monaco-editor-webpack-plugin - Vite: Configure worker files properly (see our live demo)
- Rollup: Use
rollup-plugin-monaco-editorandpostcssfor CSS processing
🤝 Contributing
We welcome contributions from the community! Here's how you can help:
Development Setup
```bash
Clone the repository
git clone https://github.com/bazingaedward/monaco-editor-vue3.git cd monaco-editor-vue3
Install dependencies
pnpm install
Start development server
pnpm dev
Run tests
pnpm test
Build the project
pnpm build ```
Development Workflow
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Ensure all tests pass:
pnpm test - Lint your code:
pnpm lint:fix - Commit your changes:
pnpm commit(uses conventional commits) - Push to the branch:
git push origin feature/amazing-feature - Submit a pull request
Documentation
To contribute to documentation:
```bash
Start docs development server
pnpm docs:dev
Build documentation
pnpm docs:build ```
📄 License
This project is licensed under the MIT License.
🙏 Acknowledgments
- Monaco Editor - The amazing code editor that powers VS Code
- Vue.js - The progressive JavaScript framework
- All contributors who have helped make this project better
💬 Community & Support
Made with ❤️ by bazingaedward and contributors.
Owner
- Name: Edward Qiu
- Login: bazingaedward
- Kind: user
- Location: 中国
- Repositories: 86
- Profile: https://github.com/bazingaedward
开源社区贡献者
GitHub Events
Total
- Release event: 1
- Issues event: 7
- Watch event: 16
- Issue comment event: 12
- Push event: 9
Last Year
- Release event: 1
- Issues event: 7
- Watch event: 16
- Issue comment event: 12
- Push event: 9
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| bazingaedward | b****d@2****g | 21 |
| kaixiang.qiu | k****u@g****m | 8 |
| qiukaixiang | q****g@b****m | 4 |
| Josef Friedrich | j****f@f****s | 2 |
| Qasim | q****2@c****k | 1 |
| LiarOnce | l****e@h****m | 1 |
| Sam Borick | s****k@o****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 31
- Total pull requests: 5
- Average time to close issues: 5 months
- Average time to close pull requests: 4 months
- Total issue authors: 29
- Total pull request authors: 4
- Average comments per issue: 1.71
- Average comments per pull request: 0.4
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 5
- Pull requests: 0
- Average time to close issues: 5 days
- Average time to close pull requests: N/A
- Issue authors: 5
- Pull request authors: 0
- Average comments per issue: 0.4
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Xiangzi529 (3)
- adamjimenez (2)
- nanfb (2)
- MarkOdey (1)
- Shimada666 (1)
- rdvo (1)
- heshimang (1)
- gsisinna (1)
- jchalex (1)
- jinxinkai (1)
- sharebravery (1)
- NoroleakIng (1)
- flymeonce (1)
- ghost (1)
- MC-YCY (1)
Pull Request Authors
- Josef-Friedrich (2)
- LiarOnce (2)
- mibzman (1)
- QasimRazvi (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- npm 15,828 last-month
- Total dependent packages: 5
- Total dependent repositories: 13
- Total versions: 11
- Total maintainers: 1
npmjs.org: monaco-editor-vue3
   
- Homepage: https://github.com/bazingaedward/monaco-editor-vue3#readme
- License: MIT
-
Latest release: 0.1.10
published about 2 years ago
Rankings
Maintainers (1)
Dependencies
- @babel/cli ^7.14.5 development
- @babel/core ^7.14.6 development
- @babel/plugin-proposal-class-properties ^7.14.5 development
- @babel/plugin-transform-modules-commonjs ^7.14.5 development
- @babel/preset-env ^7.14.7 development
- @rollup/plugin-commonjs ^19.0.0 development
- @rollup/plugin-node-resolve ^13.0.0 development
- @vitejs/plugin-vue ^2.3.3 development
- @vue/compiler-sfc ^3.1.2 development
- @vue/test-utils ^2.0.0-rc.8 development
- babel-jest 26 development
- conventional-changelog-cli ^2.1.1 development
- jest 26 development
- jest-css-modules ^2.1.0 development
- postcss ^8.4.14 development
- rollup ^2.76.0 development
- rollup-plugin-monaco-editor ^0.0.7 development
- rollup-plugin-postcss ^4.0.0 development
- sass ^1.35.1 development
- vite ^2.9.14 development
- vue-jest ^5.0.0-alpha.10 development
- monaco-editor ^0.33.0
- vite-plugin-monaco-editor ^1.1.0
- vue ^3.2.37
- 818 dependencies