Skip to content

Commit

Permalink
Add a usage section to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Dec 30, 2024
1 parent 4e47f5c commit 495a461
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@ We aim to be an inclusive, welcoming community. To make that explicit,
we have a [code of
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
to communication around the project.

## Usage

```javascript
import {EditorView} from "@codemirror/view"
import {basicSetup} from "codemirror"

const view = new EditorView({
parent: document.querySelector("#some-node"),
doc: "Content text",
extensions: [basicSetup /* ... */]
})
```

Add additional extensions, such as a [language
mode](https://codemirror.net/#languages), to configure the editor.
Call
[`view.dispatch`](https://codemirror.net/docs/ref/#view.EditorView.dispatch)
to update the editor's state.

0 comments on commit 495a461

Please sign in to comment.