@bgoodman/code-edit
v1.4.1
Published
A custom element encapsulating a CodeMirror instance.
Downloads
4
Maintainers
Readme
code-edit
A custom element encapsulating a CodeMirror instance.
Install
npm install @bgoodman/code-edit
yarn add @bgoodman/code-edit
Usage
<script type="module" src="./dist/index.js"></script>
<code-edit></code-edit>
Attributes
mode
Specify code type using a language mode. Options include:
"htmlmixed"
- default (html/css/js)"javascript"
"typescript"
"markdown"
storage-key
If set, allows the editors value to persist accross sessions using window.localStorage
.
Data is stored as key ${window.location.href}-${this.storageKey}
.
If unset, the editor's value will reset each time the component loads.
Methods
getValue
Get the current editor content. You can pass it an optional argument to specify the string to be used to separate lines (defaults to "\n").
getValue(seperator?: string): Promise<string>
setValue
Set the editor content.
setValue(code: string): Promise<void>