Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@codemirror/view

Package Overview
Dependencies
3
Maintainers
2
Versions
177
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @codemirror/view

DOM view component for the CodeMirror code editor


Version published
Maintainers
2
Install size
1.50 MB
Created

Package description

What is @codemirror/view?

The @codemirror/view package is a part of the CodeMirror 6 code editor ecosystem. It provides the view layer for the editor, which is responsible for rendering the document and handling user interactions. It is designed to be extensible and customizable, allowing developers to create sophisticated code editing interfaces.

What are @codemirror/view's main functionalities?

Editor View Creation

This feature allows you to create a new editor view and attach it to the DOM. The 'parent' option specifies the DOM element to which the editor should be appended.

import { EditorView } from '@codemirror/view';

const view = new EditorView({
  parent: document.body
});

Customizing the Appearance

This feature enables customization of the editor's appearance using decorations and extensions, such as highlighting special characters, drawing selections, and showing a drop cursor.

import { EditorView, highlightSpecialChars, drawSelection, dropCursor } from '@codemirror/view';

const view = new EditorView({
  parent: document.body,
  decorations: EditorView.decorations.of(highlightSpecialChars()),
  extensions: [drawSelection(), dropCursor()]
});

Handling User Input

This feature involves handling user input through keymaps, which define how keyboard events are handled. The 'defaultKeymap' provides a set of standard key bindings for common editor actions.

import { EditorView, keymap } from '@codemirror/view';
import { defaultKeymap } from '@codemirror/commands';

const view = new EditorView({
  parent: document.body,
  extensions: [keymap.of(defaultKeymap)]
});

Other packages similar to @codemirror/view

Changelog

Source

6.26.0 (2024-03-14)

Bug fixes

Avoid the editor getting confused when iOS autocorrects on pressing Enter and does the correction and the break insertion in two different events.

Fix the pasting of copied URIs in iOS.

Fix a bug where a scaled editor could keep performing unnecessary updates due to tiny differences in geometry values returned by the browser.

Fix a bug where, on iOS with a physical keyboard, the modifiers for some keys weren't being passed to the keymaps.

Work around the fact that Mobile Safari makes DOM changes before firing a key event when typing ctrl-d on an external keyboard.

Fix an issue where some commands didn't properly scroll the cursor into view on Mobile Safari.

Re-measure the document when print settings are changed on Chrome.

New features

The EditorView.scrollHandler facet can be used to override or extend the behavior of the editor when things are scrolled into view.

Readme

Source

@codemirror/view NPM version

[ WEBSITE | DOCS | ISSUES | FORUM | CHANGELOG ]

This package implements the DOM view component for the CodeMirror code editor.

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 14 Mar 2024

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