From 495a461d55d58140fa2fc8cf9b130c71ef54c357 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 30 Dec 2024 19:37:10 +0100 Subject: [PATCH] Add a usage section to readme --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 5db7098..c92c232 100644 --- a/README.md +++ b/README.md @@ -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.