@bgoodman/code-edit

1.4.1 • Public • Published

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>

Package Sidebar

Install

npm i @bgoodman/code-edit

Weekly Downloads

4

Version

1.4.1

License

MIT

Unpacked Size

1.76 MB

Total Files

29

Last publish

Collaborators

  • bgoodman