
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@codemirror/commands
Advanced tools
@codemirror/commands is a package that provides a collection of commands for the CodeMirror code editor. These commands are used to manipulate the editor's content, navigate through the text, and perform various editing operations. The package is designed to be used with the CodeMirror 6 framework.
Basic Editing Commands
This feature includes basic editing commands such as inserting a newline and deleting a character forward. The code sample demonstrates how to bind these commands to specific keys in a CodeMirror editor instance.
import { insertNewline, deleteCharForward } from '@codemirror/commands';
// Example usage in a CodeMirror setup
const editor = new EditorView({
state: EditorState.create({
doc: 'Hello, world!',
extensions: [
keymap.of([{
key: 'Enter', run: insertNewline
}, {
key: 'Delete', run: deleteCharForward
}])
]
}),
parent: document.body
});
Selection Commands
This feature includes commands for selecting text, such as selecting all text or selecting the current line. The code sample shows how to bind these commands to specific key combinations in a CodeMirror editor instance.
import { selectAll, selectLine } from '@codemirror/commands';
// Example usage in a CodeMirror setup
const editor = new EditorView({
state: EditorState.create({
doc: 'Hello, world!',
extensions: [
keymap.of([{
key: 'Ctrl-a', run: selectAll
}, {
key: 'Ctrl-l', run: selectLine
}])
]
}),
parent: document.body
});
Navigation Commands
This feature includes navigation commands such as moving the cursor left or right by one character. The code sample demonstrates how to bind these commands to the arrow keys in a CodeMirror editor instance.
import { cursorCharLeft, cursorCharRight } from '@codemirror/commands';
// Example usage in a CodeMirror setup
const editor = new EditorView({
state: EditorState.create({
doc: 'Hello, world!',
extensions: [
keymap.of([{
key: 'ArrowLeft', run: cursorCharLeft
}, {
key: 'ArrowRight', run: cursorCharRight
}])
]
}),
parent: document.body
});
Monaco Editor is the code editor that powers Visual Studio Code. It provides a rich set of commands for editing, navigating, and managing code. Compared to @codemirror/commands, Monaco Editor offers a more comprehensive and integrated development experience, especially for larger projects.
Ace is a standalone code editor written in JavaScript. It provides a wide range of commands for code editing and navigation. While @codemirror/commands is designed to work with the CodeMirror 6 framework, Ace is a self-contained editor with its own set of features and commands.
CodeMirror is a versatile text editor implemented in JavaScript for the browser. It provides a variety of commands for text editing and navigation. The original CodeMirror (version 5) has a different API and architecture compared to CodeMirror 6 and its @codemirror/commands package.
[ WEBSITE | DOCS | ISSUES | FORUM | CHANGELOG ]
This package implements a collection of editing commands 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.
0.20.0 (2022-04-20)
There is no longer a separate commentKeymap
. Those bindings are now part of defaultKeymap
.
Make cursorPageUp
and cursorPageDown
move by window height when the editor is higher than the window.
Make sure the default behavior of Home/End is prevented, since it could produce unexpected results on macOS.
The exports from @codemirror/comment are now available in this package.
The exports from the @codemirror/history package are now available from this package.
FAQs
Collection of editing commands for the CodeMirror code editor
The npm package @codemirror/commands receives a total of 1,448,203 weekly downloads. As such, @codemirror/commands popularity was classified as popular.
We found that @codemirror/commands demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.