A custom element encapsulating a CodeMirror instance.
npm install @bgoodman/code-edit
yarn add @bgoodman/code-edit
<script type="module" src="./dist/index.js"></script>
<code-edit></code-edit>
Specify code type using a language mode. Options include:
"htmlmixed"
- default (html/css/js)"javascript"
"typescript"
"markdown"
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.
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>
Set the editor content.
setValue(code: string): Promise<void>