Code Monkey home page Code Monkey logo

emmet-monaco-es's Introduction

emmet-monaco-es

Downloads Version License

Emmet Support for Monaco Editor

Compatibility

Compatible with Monaco Editor v0.22.0 and above.

If you are using old version of Monaco Editor, Please use v4.4.2 of this lib.

Advantage

  • Almost the same as VSCode's built-in emmet, integrated with completion provider
  • Various languages support
  • Treeshaking support

Install

$ npm install emmet-monaco-es

Usage

NOTE

The emmet functionality was bound to language features not to a specific editor instance.

  • emmetHTML works for HTML compatible languages, like PHP, for html only by default
  • emmetCSS works for CSS compatible languages, like LESS / SCSS, for css only by default
  • emmetJSX works for JSX compatible languages, like JavaScript / TypeScript, for javascript only by default

Follow this guide to make Monaco Editor support TSX

ESM

import { emmetHTML, emmetCSS, emmetJSX, expandHTML, expandCSS } from "emmet-monaco-es";

// `emmetHTML` , `emmetCSS` and `emmetJSX` are used the same way
const dispose = emmetHTML(
  // monaco-editor it self. If not provided, will use window.monaco instead.
  // This could make the plugin support both ESM and AMD loaded monaco-editor
  monaco,
  // languages needs to support html markup emmet, should be lower case.
  ['html', 'php']
);

// run it if you want to dispose emmetHTML.
// NOTE: all languages specified will be disposed.
dispose();

// internal expand API, if you want to extend functionality with emmet
expandHTML('a'); // <a href="${1}">${2}</a>
expandCSS('fz14'); // font-size: 14px;

Browser

<script src="https://unpkg.com/emmet-monaco-es/dist/emmet-monaco.min.js"></script>
<script>
  // NOTE: monaco-editor should be loaded first
  // see the above esm example for details
  emmetMonaco.emmetHTML(monaco);
</script>

Limitation

Does NOT support Emmet for embed CSS inside HTML / JSX / TSX

License

MIT

emmet-monaco-es's People

Contributors

chanced avatar dependabot-preview[bot] avatar nishkalkashyap avatar troy351 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.