EditorProps

Struct EditorProps 

Source
pub struct EditorProps {
Show 20 fields pub value: Signal<String>, pub on_change: Option<Callback<String>>, pub placeholder: Option<String>, pub language: Option<String>, pub read_only: bool, pub show_line_numbers: bool, pub word_wrap: bool, pub tab_size: usize, pub font_size: f32, pub class: Option<String>, pub min_height: Option<String>, pub max_height: Option<String>, pub id: Option<String>, pub on_focus: Option<Callback<()>>, pub on_blur: Option<Callback<()>>, pub on_cursor_change: Option<Callback<(usize, usize)>>, pub on_selection_change: Option<Callback<Option<String>>>, pub autofocus: bool, pub match_brackets: bool, pub highlight_current_line: bool,
}
Available on crate feature editor only.
Expand description

Props for the Editor component.

A production-ready text editor component.

The Editor provides a full-featured text editing experience with:

  • Syntax highlighting (with syntax-highlighting feature)
  • Line numbers
  • Find and replace (with find-replace feature)
  • Undo/redo
  • Multiple cursors (planned)
  • Code folding (with folding feature)

§Example

use leptos::prelude::*;
use longcipher_leptos_components::editor::Editor;

#[component]
fn MyEditor() -> impl IntoView {
    let (content, set_content) = signal(String::new());

    view! {
        <Editor
            value=content
            on_change=move |v| set_content.set(v)
            language="rust"
            show_line_numbers=true
        />
    }
}

§Styling

The editor uses CSS custom properties for theming. Override these in your CSS:

.leptos-editor {
    --editor-bg: #1e1e1e;
    --editor-fg: #d4d4d4;
    --editor-line-number-fg: #858585;
    --editor-selection-bg: #264f78;
    --editor-cursor: #aeafad;
}

§Required Props

§Optional Props

  • on_change: impl Into<Callback<String>>
    • Callback when the value changes
  • placeholder: impl Into<String>
    • Placeholder text shown when editor is empty
  • language: impl Into<String>
    • Programming language for syntax highlighting (e.g., “rust”, “javascript”)
  • read_only: bool
    • Whether the editor is read-only
  • show_line_numbers: bool
    • Whether to show line numbers
  • word_wrap: bool
    • Whether word wrap is enabled
  • tab_size: usize
    • Tab size in spaces
  • font_size: f32
    • Font size in pixels
  • class: impl Into<String>
    • Additional CSS classes to apply
  • min_height: impl Into<String>
    • Minimum height (CSS value like “200px” or “10rem”)
  • max_height: impl Into<String>
    • Maximum height (CSS value like “500px” or “80vh”)
  • id: impl Into<String>
    • ID attribute for the editor element
  • on_focus: impl Into<Callback<()>>
    • Callback when the editor receives focus
  • on_blur: impl Into<Callback<()>>
    • Callback when the editor loses focus
  • on_cursor_change: [impl Into<Callback<(usize, usize)>>](Callback<(usize, usize)>)
    • Callback when cursor position changes (line, column)
  • on_selection_change: impl Into<Callback<Option<String>>>
    • Callback when selection changes (selected text or None)
  • autofocus: bool
    • Whether to auto-focus on mount
  • match_brackets: bool
    • Whether bracket matching is enabled
  • highlight_current_line: bool
    • Whether to highlight the current line

Fields§

§value: Signal<String>

The current value of the editor (controlled)

§on_change: Option<Callback<String>>

Callback when the value changes

§placeholder: Option<String>

Placeholder text shown when editor is empty

§language: Option<String>

Programming language for syntax highlighting (e.g., “rust”, “javascript”)

§read_only: bool

Whether the editor is read-only

§show_line_numbers: bool

Whether to show line numbers

§word_wrap: bool

Whether word wrap is enabled

§tab_size: usize

Tab size in spaces

§font_size: f32

Font size in pixels

§class: Option<String>

Additional CSS classes to apply

§min_height: Option<String>

Minimum height (CSS value like “200px” or “10rem”)

§max_height: Option<String>

Maximum height (CSS value like “500px” or “80vh”)

§id: Option<String>

ID attribute for the editor element

§on_focus: Option<Callback<()>>

Callback when the editor receives focus

§on_blur: Option<Callback<()>>

Callback when the editor loses focus

§on_cursor_change: Option<Callback<(usize, usize)>>

Callback when cursor position changes (line, column)

§on_selection_change: Option<Callback<Option<String>>>

Callback when selection changes (selected text or None)

§autofocus: bool

Whether to auto-focus on mount

§match_brackets: bool

Whether bracket matching is enabled

§highlight_current_line: bool

Whether to highlight the current line

Implementations§

Source§

impl EditorProps

Source

pub fn builder() -> EditorPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building EditorProps. On the builder, call .value(...), .on_change(...)(optional), .placeholder(...)(optional), .language(...)(optional), .read_only(...)(optional), .show_line_numbers(...)(optional), .word_wrap(...)(optional), .tab_size(...)(optional), .font_size(...)(optional), .class(...)(optional), .min_height(...)(optional), .max_height(...)(optional), .id(...)(optional), .on_focus(...)(optional), .on_blur(...)(optional), .on_cursor_change(...)(optional), .on_selection_change(...)(optional), .autofocus(...)(optional), .match_brackets(...)(optional), .highlight_current_line(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of EditorProps.

Trait Implementations§

Source§

impl Props for EditorProps

Source§

type Builder = EditorPropsBuilder

Source§

fn builder() -> Self::Builder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Source§

impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Source§

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<E, T, Encoding, Request> IntoReq<Patch<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Post<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, T, Encoding, Request> IntoReq<Put<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Source§

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Source§

impl<E, Response, Encoding, T> IntoRes<Patch<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Post<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<E, Response, Encoding, T> IntoRes<Put<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Source§

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Source§

impl<T> SerializableKey for T

Source§

fn ser_key(&self) -> String

Serializes the key to a unique string. Read more
Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.