Socket
Socket
Sign inDemoInstall

codemirror

Package Overview
Dependencies
13
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    codemirror

Basic configuration for the CodeMirror code editor


Version published
Weekly downloads
1.9M
decreased by-6.22%
Maintainers
1
Install size
2.41 MB
Created
Weekly downloads
 

Package description

What is codemirror?

CodeMirror is a versatile text editor implemented in JavaScript for the browser. It is specialized for editing code and comes with a number of language modes and addons that implement more advanced editing functionality. A rich programming API and a CSS theming system are available for customizing CodeMirror to fit the needs of the project.

What are codemirror's main functionalities?

Syntax highlighting

This feature allows for syntax highlighting of code written in various programming languages. The example code initializes a CodeMirror instance with JavaScript syntax highlighting.

var editor = CodeMirror.fromTextArea(document.getElementById('code'), {mode: 'javascript'});

Code editing

CodeMirror provides a rich text editor for code, with features like auto-indentation, line numbers, and bracket matching. The example code creates an editor instance with some JavaScript code pre-filled.

var editor = CodeMirror(document.body, {value: 'function myScript(){return 100;}', mode: 'javascript'});

Autocompletion

Autocompletion can be enabled to suggest completions for the current token. The example code sets up an event listener to trigger autocompletion on certain inputs.

editor.on('inputRead', function onChange(editor, input) { if (input.text[0] === ';' || input.text[0] === ' ') { return; } CodeMirror.commands.autocomplete(editor); });

Themes

CodeMirror supports various themes to customize the appearance of the editor. The example code initializes a CodeMirror instance with the Monokai theme.

var editor = CodeMirror.fromTextArea(document.getElementById('code'), {mode: 'javascript', theme: 'monokai'});

Addons

CodeMirror has a variety of addons that can extend its functionality, such as displaying line numbers or matching brackets. The example code enables line numbers and bracket matching for the editor.

var editor = CodeMirror.fromTextArea(document.getElementById('code'), {mode: 'javascript', lineNumbers: true, matchBrackets: true});

Other packages similar to codemirror

Changelog

Source

6.0.1 (2022-06-30)

Bug fixes

Work around limitations in tree-shaking software that prevented basicSetup from being removed when unused.

Readme

Source

codemirror NPM version

[ WEBSITE | DOCS | ISSUES | FORUM | CHANGELOG ]

This package provides an example configuration for the CodeMirror code editor. The actual editor is implemented in the various packages under the @codemirror scope, which this package depends on.

The project page has more information, a number of examples and the documentation.

This code is released under an MIT license.

We aim to be an inclusive, welcoming community. To make that explicit, we have a code of conduct that applies to communication around the project.

Keywords

FAQs

Last updated on 30 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc