Function text_editor

Source
pub fn text_editor(
    args: impl Into<TextEditorArgs>,
    state: Arc<RwLock<TextEditorState>>,
)
Expand description

A text editor component with two-layer architecture:

  • surface layer: provides visual container, minimum size, and click area
  • Core layer: handles text rendering and editing logic

This design solves the issue where empty text editors had zero width and couldn’t be clicked.

§Example

use tessera_ui_basic_components::text_editor::{text_editor, TextEditorArgs, TextEditorArgsBuilder, TextEditorState};
use tessera_ui::{Dp, DimensionValue, Px};
use std::sync::Arc;
use parking_lot::RwLock;

let args = TextEditorArgsBuilder::default()
    .width(Some(DimensionValue::Fixed(Px(300))))
    .height(Some(DimensionValue::Fill { min: Some(Px(50)), max: Some(Px(500)) }))
    .build()
    .unwrap();

let state = Arc::new(RwLock::new(TextEditorState::new(Dp(12.0), None)));
// text_editor(args, state);