| Crates.io | codemirror |
| lib.rs | codemirror |
| version | 0.2.0 |
| created_at | 2024-08-31 12:34:41.923935+00 |
| updated_at | 2024-08-31 14:48:08.725047+00 |
| description | A wasm-bingen wrapper for CodeMirror |
| homepage | https://github.com/slowtec/codemirror-rs |
| repository | https://github.com/slowtec/codemirror-rs |
| max_upload_size | |
| id | 1358797 |
| size | 10,072 |
A wasm-bindgen wrapper for CodeMirror
Add this to Cargo.toml:
[dependencies]
codemirror = "0.2"
use codemirror::{DocApi, Editor, EditorOptions};
use wasm_bindgen::prelude::*;
use web_sys::{window, HtmlTextAreaElement};
let document = window().unwrap().document().unwrap();
let text_area = document
.create_element("textarea")
.unwrap()
.dyn_into::<HtmlTextAreaElement>()
.unwrap();
document.body().unwrap().append_child(&text_area).unwrap();
let options = EditorOptions::default().line_numbers(true);
let editor = Editor::from_text_area(&text_area, &options);
editor.set_value("Hello from Rust");
editor.on_change(|_editor, _change| {
// value changed
});
Copyright (c) 2024 slowtec GmbH