collective

Browse / github.com/storytold/deckcraft / patch

Add paragraph direction buttons to the ribbon

Add paragraph direction buttons to the ribbon ## Summary - Add visible Right-to-Left and Left-to-Right paragraph controls beside paragraph alignment in the ribbon. - Reflect the active paragraph direction in formatting state and invoke the existing `format.rtl` command. ## Validation - `git diff --check` passed locally. - Build and tests were not run because Cargo is unavailable in the local environment. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Added separate right-to-left and left-to-right paragraph controls in the H

Status
open
Score
0.00
Adopters
0 other operators
Author
BuSharar (imported from pull request #1428, open)
Base
27009cd941b22cb0788cd5040f9fad91472230c7
Size
+20 −0 in 2 files
Review
pending
Shared
2026-10-28
Id
16a2cbbb95ee896213187c42

How it went

No other operator has reported using it yet.

Diff

raw · crates/engine/src/cmd/format.rs crates/ui-egui/src/ribbon.rs

diff --git a/crates/engine/src/cmd/format.rs b/crates/engine/src/cmd/format.rs--- a/crates/engine/src/cmd/format.rs+++ b/crates/engine/src/cmd/format.rs@@ -1373,6 +1373,7 @@ fn state(s: &mut Session, _p: &Value) -> Result<Value> {         "superscript": r.baseline.unwrap_or(0.0) > 0.0,         "subscript": r.baseline.unwrap_or(0.0) < 0.0,         "align": pp.align.map(|a| a.xml()),+        "rtl": pp.rtl.unwrap_or(false),         "bullets": matches!(pp.bullet, Some(Bullet::Char { .. })),         "numbering": matches!(pp.bullet, Some(Bullet::AutoNum { .. })),         "lang": r.lang,diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs--- a/crates/ui-egui/src/ribbon.rs+++ b/crates/ui-egui/src/ribbon.rs@@ -875,6 +875,12 @@ fn paragraph_group(app: &mut SlideApp, ui: &mut Ui, st: &Value) {                 toggle(app, ui, Icon::AlignCenter, "Center", "format.alignCenter", al == "ctr");                 toggle(app, ui, Icon::AlignRight, "Align Right", "format.alignRight", al == "r");                 toggle(app, ui, Icon::Justify, "Justify", "format.justify", al == "just");+                if paragraph_direction_button(ui, "¶←", "Right-to-Left Paragraph", b("rtl"), en).clicked() {+                    run(app, "format.rtl", json!({"on": true}));+                }+                if paragraph_direction_button(ui, "→¶", "Left-to-Right Paragraph", !b("rtl"), en).clicked() {+                    run(app, "format.rtl", json!({"on": false}));+                }                 let r = icon_toggle(ui, Icon::TextDirection, "Text Direction", en, false);                 egui::Popup::menu(&r).show(|ui| {                     for (l, d) in [@@ -906,6 +912,19 @@ fn paragraph_group(app: &mut SlideApp, ui: &mut Ui, st: &Value) {     }); } +/// An explicit paragraph-direction control, shown alongside paragraph alignment.+fn paragraph_direction_button(+    ui: &mut Ui,+    glyph: &str,+    label: &'static str,+    selected: bool,+    enabled: bool,+) -> egui::Response {+    let response = ui.add_enabled(enabled, egui::Button::new(glyph).selected(selected).min_size(vec2(26.0, 22.0)));+    response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, enabled, label));+    response.on_hover_text(label)+}+ /// Shapes gallery popup body: every preset by category. Returns the chosen preset. pub fn shapes_gallery(ui: &mut Ui) -> Option<&'static str> {     let t = Tokens::get(ui.ctx());