🎉 Set DOM text editor element caret

This commit is contained in:
Aitor Moreno
2025-09-22 15:47:23 +02:00
parent 9a5efe8671
commit 7ca8bf32b2
31 changed files with 2262 additions and 1326 deletions

View File

@@ -2,7 +2,9 @@ use skia_safe::{self as skia, textlayout::FontCollection, Path, Point};
use std::collections::HashMap;
mod shapes_pool;
mod text_editor;
pub use shapes_pool::*;
pub use text_editor::*;
use crate::render::RenderState;
use crate::shapes::Shape;
@@ -19,6 +21,7 @@ use crate::shapes::modifiers::grid_layout::grid_cell_data;
/// must not be shared between different Web Workers.
pub(crate) struct State {
pub render_state: RenderState,
pub text_editor_state: TextEditorState,
pub current_id: Option<Uuid>,
pub shapes: ShapesPool,
pub modifiers: HashMap<Uuid, skia::Matrix>,
@@ -30,6 +33,7 @@ impl State {
pub fn new(width: i32, height: i32) -> Self {
State {
render_state: RenderState::new(width, height),
text_editor_state: TextEditorState::new(),
current_id: None,
shapes: ShapesPool::new(),
modifiers: HashMap::new(),
@@ -50,6 +54,16 @@ impl State {
&self.render_state
}
#[allow(dead_code)]
pub fn text_editor_state_mut(&mut self) -> &mut TextEditorState {
&mut self.text_editor_state
}
#[allow(dead_code)]
pub fn text_editor_state(&self) -> &TextEditorState {
&self.text_editor_state
}
pub fn render_from_cache(&mut self) {
self.render_state
.render_from_cache(&self.shapes, &self.modifiers, &self.structure);