code-edit
lightweight (~5kb) code editor custom element with syntax highlighting
Install
$ npm i code-edit
API
Table of Contents
CodeEditElement
Extends HTMLElement
CodeEdit custom element
import { CodeEditElement } from 'code-edit'
customElements.define('code-edit', CodeEditElement)
<code-edit autofocus autoresize language="js" theme="deep"> ... code-edit>
HTMLCodeEditElement
CodeEdit HTML/JSX Interface
value
The editor's value
Type: string
language
Language for syntax highlighting
Type: string
syntax
Passing a syntax definition regexp manually
Type: (SyntaxDefinition | Promise<{default: SyntaxDefinition}>)
theme
Theme to use
Type: string
tabsize
Tab size
Type: number
tabstyle
Tab style
Type: ("tabs"
| "spaces"
)
comments
Comments are defined as a tuple-like string: '// /* */' first item is single comment and second third are multiline comments
Type: string
autofocus
Autofocus to the element when page loads
Type: boolean
autoresize
Whether to autoresize to the height of the contents
Type: boolean
Contribute
All contributions are welcome!
License
MIT © 2022 stagas