Skip to content

A wasm-bingen wrapper for CodeMirror

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

slowtec/codemirror-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codemirror-rs

A wasm-bindgen wrapper for CodeMirror

Usage

Add this to Cargo.toml:

[dependencies]
codemirror = "0.2"

Minimal Example

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
});

License

Copyright (c) 2024 slowtec GmbH

About

A wasm-bingen wrapper for CodeMirror

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published