diff --git a/frontend/src/app/render_wasm/api.cljs b/frontend/src/app/render_wasm/api.cljs index ac1372037c..38326e410e 100644 --- a/frontend/src/app/render_wasm/api.cljs +++ b/frontend/src/app/render_wasm/api.cljs @@ -791,6 +791,7 @@ (rx/subs! (fn [_] (clear-drawing-cache) (request-render "pending-finished") + (h/call wasm/internal-module "_update_shape_text_layout_for_all") (.dispatchEvent ^js js/document event)))) (do (clear-drawing-cache) diff --git a/render-wasm/src/state/shapes_pool.rs b/render-wasm/src/state/shapes_pool.rs index 125a80a141..e349594742 100644 --- a/render-wasm/src/state/shapes_pool.rs +++ b/render-wasm/src/state/shapes_pool.rs @@ -78,4 +78,13 @@ impl ShapesPool { let idx = *self.shapes_uuid_to_idx.get(id)?; Some(&self.shapes[idx]) } + + #[allow(dead_code)] + pub fn iter(&self) -> std::slice::Iter<'_, Shape> { + self.shapes.iter() + } + + pub fn iter_mut(&mut self) -> std::slice::IterMut<'_, Shape> { + self.shapes.iter_mut() + } } diff --git a/render-wasm/src/wasm/text.rs b/render-wasm/src/wasm/text.rs index 14c955af88..01d70dcfdc 100644 --- a/render-wasm/src/wasm/text.rs +++ b/render-wasm/src/wasm/text.rs @@ -384,6 +384,17 @@ pub extern "C" fn update_shape_text_layout_for(a: u32, b: u32, c: u32, d: u32) { }); } +#[no_mangle] +pub extern "C" fn update_shape_text_layout_for_all() { + with_state_mut!(state, { + for shape in state.shapes.iter_mut() { + if let Type::Text(text_content) = &mut shape.shape_type { + text_content.update_layout(shape.selrect); + } + } + }); +} + #[no_mangle] pub extern "C" fn get_caret_position_at(x: f32, y: f32) -> i32 { with_current_shape!(state, |shape: &Shape| {