A Vanilla Web Component to embed a CodeMirror editor into a web page
npm i @vanillawc/wc-codemirror
Then import the index.js
file at the root of the package.
<wc-codemirror src="sample.js"></wc-codemirror>
Attributes
src
- load an external source filestyle
- CSS styling (defaultheight:100%;width:100%;
)
Note: The ID attribute is required if there are multiple editors
Properties
value
- get/set the editor's contents
<wc-codemirror src="./assets/sample.js"></wc-codemirror>
Demo: WC-CodeMirror - Basic Usage
<wc-codemirror mode="javascript" src="./assets/sample.js"></wc-codemirror>
Demo: WC-CodeMirror - 'mode' Attribute
The demo can also be run locally with
npm run start