Socket
Socket
Sign inDemoInstall

@codemirror/legacy-modes

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/legacy-modes

Collection of ported legacy language modes for the CodeMirror code editor


Version published
Weekly downloads
313K
increased by9.42%
Maintainers
2
Weekly downloads
 
Created

What is @codemirror/legacy-modes?

@codemirror/legacy-modes is a package that provides support for legacy modes in CodeMirror 6. It allows users to utilize syntax highlighting and other features from older versions of CodeMirror in the newer version.

What are @codemirror/legacy-modes's main functionalities?

Syntax Highlighting

This code sample demonstrates how to use the @codemirror/legacy-modes package to add Python syntax highlighting to a CodeMirror 6 editor instance.

import { legacyMode } from '@codemirror/legacy-modes';
import { StreamLanguage } from '@codemirror/language';
import { python } from '@codemirror/legacy-modes/mode/python';

const pythonLanguage = StreamLanguage.define(python);

const editor = new EditorView({
  state: EditorState.create({
    doc: 'print("Hello, World!")',
    extensions: [pythonLanguage]
  }),
  parent: document.body
});

Legacy Mode Integration

This code sample shows how to integrate JavaScript syntax highlighting from legacy CodeMirror modes into a CodeMirror 6 editor.

import { legacyMode } from '@codemirror/legacy-modes';
import { StreamLanguage } from '@codemirror/language';
import { javascript } from '@codemirror/legacy-modes/mode/javascript';

const jsLanguage = StreamLanguage.define(javascript);

const editor = new EditorView({
  state: EditorState.create({
    doc: 'console.log("Hello, World!");',
    extensions: [jsLanguage]
  }),
  parent: document.body
});

Other packages similar to @codemirror/legacy-modes

Keywords

FAQs

Package last updated on 15 Aug 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc