emmet-monaco-es
Emmet Support for Monaco Editor, based on vscode-emmet-helper
Advantage
- Almost the same as VSCode's built-in emmet, integrated with completion provider
- Various languages 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 defaultemmetCSS
works for CSS
compatible languages, like LESS
/ SCSS
, for css
only by defaultemmetJSX
works for JSX
compatible languages, like JavaScript
/ TypeScript
/ MDX
, for javascript
only by default
Follow this guide to make Monaco Editor support TSX
Initialize emmet should BEFORE all monaco editor instance creation
ESM
import { emmetHTML, emmetCSS, emmetJSX, expandAbbreviation, registerCustomSnippets } from 'emmet-monaco-es'
const dispose = emmetHTML(
monaco,
['html', 'php'],
)
dispose()
expandAbbreviation('a', { type: 'markup', syntax: 'html' })
expandAbbreviation('fz14', { type: 'stylesheet', syntax: 'css' })
registerCustomSnippets('html', {
ull: 'ul>li[id=${1} class=${2}]*2{ Will work with html, pug, haml and slim }',
oll: '<ol><li id=${1} class=${2}> Will only work in html </ol>',
ran: '{ Wrap plain text in curly braces }',
})
Browser
<script src="https://unpkg.com/emmet-monaco-es/dist/emmet-monaco.min.js"></script>
<script>
emmetMonaco.emmetHTML(monaco)
</script>
Limitation
Does NOT support Emmet for embed CSS inside HTML / JSX / TSX
License
MIT