All Projects → vanillawc → wc-codemirror

vanillawc / wc-codemirror

Licence: MIT license
CodeMirror as a vanilla web component

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to wc-codemirror

Mcscript
A programming language for Minecraft Vanilla
Stars: ✭ 124 (+300%)
Mutual labels:  vanilla
Tobi
An accessible, open-source lightbox with no dependencies.
Stars: ✭ 195 (+529.03%)
Mutual labels:  vanilla
Medium Zoom
🔎🖼 A JavaScript library for zooming images like Medium
Stars: ✭ 2,799 (+8929.03%)
Mutual labels:  vanilla
Parvus
An accessible, open-source image lightbox with no dependencies.
Stars: ✭ 124 (+300%)
Mutual labels:  vanilla
Vanilla Back To Top
Simple and smooth Back To Top button
Stars: ✭ 179 (+477.42%)
Mutual labels:  vanilla
Javascript Todo List Tutorial
✅ A step-by-step complete beginner example/tutorial for building a Todo List App (TodoMVC) from scratch in JavaScript following Test Driven Development (TDD) best practice. 🌱
Stars: ✭ 212 (+583.87%)
Mutual labels:  vanilla
Sharer.js
🔛 🔖 Create your own social share buttons. No jquery.
Stars: ✭ 1,624 (+5138.71%)
Mutual labels:  vanilla
Instantsearch.js
⚡️ A JavaScript library for building performant and instant search experiences with Algolia.
Stars: ✭ 2,799 (+8929.03%)
Mutual labels:  vanilla
Vanillawc
Vanilla Web Components. A place for framework-free, transpiler-free, scaffolding-free web components.
Stars: ✭ 181 (+483.87%)
Mutual labels:  vanilla
Pfui
A User Interface Replacement for World of Warcraft: Vanilla & TBC
Stars: ✭ 226 (+629.03%)
Mutual labels:  vanilla
Filepond
🌊 A flexible and fun JavaScript file upload library
Stars: ✭ 11,869 (+38187.1%)
Mutual labels:  vanilla
Jsontree
A lightweight vanilla Javascript micro-library for making collapsible trees with JSON
Stars: ✭ 170 (+448.39%)
Mutual labels:  vanilla
Ryzen Hackintosh
OpenCore EFI for AMD Ryzen Hackintosh
Stars: ✭ 217 (+600%)
Mutual labels:  vanilla
Woofmark
🐕 Barking up the DOM tree. A modular, progressive, and beautiful Markdown and HTML editor
Stars: ✭ 1,594 (+5041.94%)
Mutual labels:  vanilla
Arcgis Rest Js
compact, modular JavaScript wrappers for the ArcGIS REST API
Stars: ✭ 231 (+645.16%)
Mutual labels:  vanilla
Ivid
🔴 (cyoa) interactive video player 🔵
Stars: ✭ 122 (+293.55%)
Mutual labels:  vanilla
Vanilla Tilt.js
A smooth 3D tilt javascript library.
Stars: ✭ 2,851 (+9096.77%)
Mutual labels:  vanilla
Lunaunitframes
Unit Frames for WoW Classic
Stars: ✭ 252 (+712.9%)
Mutual labels:  vanilla
Keen Slider
The HTML touch slider carousel with the most native feeling
Stars: ✭ 3,097 (+9890.32%)
Mutual labels:  vanilla
Enoki
ultralight tools for creating p2p sites
Stars: ✭ 222 (+616.13%)
Mutual labels:  vanilla

<wc-codemirror> Easily embed a CodeMirror editor

GitHub Releases NPM Releases Bundlephobia Latest Status Release Status

Discord Published on WebComponents.org

Setup

Install and import from NPM

npm i @vanillawc/wc-codemirror
<script type="module" src="[node_modules]/@vanillawc/wc-codemirror/index.js"></script>

Import from CDN

<script type="module" src="https://cdn.jsdelivr.net/gh/vanillawc/wc-codemirror@1/index.js"></script>

Demo

Try it on WebComponents.dev

Usage

Attributes

  • src - load an external source file
  • style - CSS styling (default height:100%;width:100%;)
  • viewport-margin1 - sets the viewportMargin option of the CodeMirrror editor instance (default 10)
  • readonly - sets the codemirror's "readOnly" configuration attribute to true, you may set readonly="nocursor" if you want to disable the cursor and not let the user copy the text inside

1Setting viewport-margin to infinity will auto-resize the editor to its contents. To see this in action, check out the CodeMirror Auto-Resize Demo.

Properties

  • editor - the CodeMirror editor instance
  • value - get/set the editor's contents

Note: The ID attribute is required when multiple editors instances are present

Basic Usage

An empty tag loads a basic CodeMirror editor pane

<wc-codemirror></wc-codemirror>

Inline Source

Inline source can be loaded by including a <script> of type wc-content in the body of the component. The <script> wrapper is necessary so '<' and '>' chars in the source are not interpreted as HTML.

<wc-codemirror mode="javascript">
  <script type="wc-content">
  function myGoodPerson(){
     return "what can I do for you ?"
  }
  </script>
</wc-codemirror>

Note: </script> cannot be used inside of <script type="wc-content"> until it's the angle brackets are escaped (ie &lt; and &gt;)

External Source

Load an external source file with the src attribute

<wc-codemirror src="sample.txt"></wc-codemirror>

Syntax Highlighting

Syntax highlighting requires importing a mode module for the language

<script type="module" src="[wc-codemirror]/mode/javascript/javascript.js"></script>

Then specify the language with the mode attribute

<wc-codemirror mode="javascript"></wc-codemirror>

Theming

Theming requires importing an editor theme stylesheet within wc-codemirror tag. You can import few themes this way and switch them with the theme attribute.

<wc-codemirror mode="javascript" theme="monokai">
  <link rel="stylesheet" href="[wc-codemirror]/theme/monokai.css">
</wc-codemirror>

Note: Check out the CodeMirror Theme Demo to try sample the full selection of editor themes.

Contributing

See CONTRIBUTING.md

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].