Skip to main content

Crate dioxus_codemirror

Crate dioxus_codemirror 

Source
Expand description

A Dioxus web component that wraps the CodeMirror 6 editor.

CodeMirror drives a CodeMirror editor through a single long-lived document::eval channel (the script lives in code_mirror/glue.js). CodeMirror is vendored as a Dioxus folder asset, so there is no JavaScript build step and no runtime CDN dependency. Typed Cmd/Evt messages cross the channel as JSON.

It supports:

  1. Reacting to edits, via a two-way bound CodeMirrorProps::value.
  2. Setting the value when the bound data changes elsewhere on the page.
  3. Connecting to an in-page (WASM) language server, via an LspBridge.

§Example

use dioxus::prelude::*;
use dioxus_codemirror::CodeMirror;

#[component]
fn App() -> Element {
    let value = use_signal(|| "fn main() {}".to_string());
    rsx! {
        CodeMirror { value }
        p { "{value}" }
    }
}

Re-exports§

pub use crate::cmd::Cmd;
pub use crate::code_mirror::CodeMirror;
pub use crate::code_mirror::CodeMirrorProps;
pub use crate::evt::Evt;
pub use crate::language::Language;
pub use crate::lsp::LspBridge;
pub use crate::lsp::LspMessage;
pub use crate::lsp::LspMessageRx;
pub use crate::lsp::LspPusher;
pub use crate::lsp::LspServer;
pub use crate::lsp::LspServerAsync;
pub use crate::theme::Theme;
pub use crate::theme_color::ThemeColor;
pub use crate::theme_colors::ThemeColors;

Modules§

cmd
code_mirror
evt
language
lsp
Plumbing to connect the CodeMirror editor to a language server.
theme
theme_color
theme_colors