@adecore/editor-core
v0.26.1
Published
[](https://www.npmjs.com/package/@adecore/editor-core) [](https://adecore.dev/editor-core/)
Readme
@adecore/editor-core
The document model of a code editor, with no DOM and no dependencies. DocumentModel holds the text, the selections, an undo history and the editing commands: typing with bracket pairing, smart Enter, comment toggles, line moves, multiple carets, search and folding. It runs in a browser, Bun and Node. @adecore/editor draws it on screen.
Install
bun add @adecore/editor-coreUse
import { DocumentModel } from '@adecore/editor-core';
const document = new DocumentModel('const greeting = "hello";\n');
document.setSelections([{ anchor: 26, head: 26 }]);
document.typeText('(', { language: 'typescript' }); // the closer comes along
document.undo();Offsets are UTF-16 code units, lines and columns zero-based. A batch of edits is simultaneous, in the coordinates of the text before it.
Documentation
| Page | What it covers |
|---|---|
| Overview | Coordinates, limits and provenance |
| Documents and edits | Text, selections, edit batches, revisions, history and change events |
| Typing and commands | typeText, paste, execute and their options |
| Search and folding | Find and replace, folding ranges and roles |
| API reference | The helpers and types next to the model |
License
FSL-1.1-MIT, except the word-boundary predicates in src/words.ts, which are adapted from the IntelliJ Platform (EditorActionUtil.java of JetBrains/intellij-community at 7184b03af6c5370e79a01ded0df68cf56d7669da, lines 934 through 982) under Apache 2.0. NOTICE and LICENSE.apache-2.0.txt ship with the package.
