Skip to content

Basic Examples

This page demonstrates the basic usage of Monaco Editor Vue3 components, including common use cases for the single-file editor and diff editor.

Diff Editor

The DiffEditor is used to compare two versions of code, supporting side-by-side display and highlighting changes.

Key Features:

  • Side-by-side diff comparison
  • Highlighting of added, deleted, and modified content
  • Syntax highlighting for various programming languages
  • Responsive layout

JavaScript / TypeScript Editor

Full support for JavaScript and TypeScript syntax highlighting, intelligent suggestions, and error checking.

Key Features:

  • Syntax highlighting and auto-completion
  • Real-time error checking
  • Code formatting
  • Smart refactoring suggestions

Configuration Explanation

The above examples use a unified editor configuration:

OptionValueDescription
colorDecoratorstrueEnable color decorators for CSS preview
lineHeight24Set line height to 24px
tabSize2Set tab to 2 spaces
automaticLayouttrueEnable automatic layout adjustment
lineNumbers'on'Show line numbers
foldingtrueEnable code folding
matchBrackets'always'Always highlight matching brackets
scrollBeyondLastLinefalsePrevent scrolling beyond the last line

For more options, see the Monaco Editor official docs.

JSON Editor

Optimized for editing JSON data, providing syntax validation, formatting, and folding features.

Key Features:

  • JSON syntax validation and error hints
  • Auto-formatting and beautification
  • Folding for objects and arrays
  • Smart bracket matching

CSS / Less / Sass Editor

Supports modern CSS preprocessors, with property suggestions and color preview features.

Key Features:

  • CSS property suggestions
  • Color value preview and selector
  • Less/Sass syntax support
  • Auto-completion for CSS selectors

HTML / Handlebars / Razor Editor

Supports HTML and template engines, with tag completion and attribute suggestions.

Key Features:

  • HTML tag and attribute auto-completion
  • Template syntax highlighting (Handlebars, Razor)
  • Auto-indentation for nested tags
  • Real-time HTML validation

SQL Editor

Professional SQL query editor supporting multiple database dialects.

Key Features:

  • SQL keyword highlighting
  • Table and field name suggestions
  • Query syntax validation
  • Support for multiple database dialects

Released under the MIT License.