fix(composer): table insert moves from the button row to the format toolbar
- Composer row keeps emoji and attach only - "Insert table" is the last group of the format toolbar, like the table group in the Teams format bar - Deviation: Teams shows it in the expanded format bar, ours appears on a selection only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -947,6 +947,10 @@ impl Composer {
947
947
FormatButton::Bulleted => self.toggle_lines(LineKind::Bullet(0), window, cx),
948
948
FormatButton::Numbered => self.toggle_lines(LineKind::Numbered(0), window, cx),
949
949
FormatButton::Quote => self.toggle_lines(LineKind::Quote, window, cx),
950
FormatButton::Table => {
951
self.toolbar_dismissed = Some(self.selection(cx));
952
self.open_table_picker(cx);
953
}
950
954
}
951
955
}
952
956
@@ -967,6 +971,8 @@ impl Composer {
967
971
FormatButton::Bulleted => self.draft.line_state(range, &LineKind::Bullet(0)),
968
972
FormatButton::Numbered => self.draft.line_state(range, &LineKind::Numbered(0)),
969
973
FormatButton::Quote => self.draft.line_state(range, &LineKind::Quote),
974
FormatButton::Table if self.table_picker.is_some() => FormatState::On,
975
FormatButton::Table => FormatState::Off,
970
976
}
971
977
}
972
978
@@ -2573,24 +2579,6 @@ impl Render for Composer {
2573
2579
))
2574
2580
.on_click(cx.listener(|this, _, window, cx| this.open_picker(window, cx)))
2575
2581
});
2576
let table_button = can_attach.then(|| {
2577
div()
2578
.id("composer-table")
2579
.size(px(COMPOSER_BUTTON_SIZE))
2580
.flex_none()
2581
.flex()
2582
.items_center()
2583
.justify_center()
2584
.rounded(px(8.))
2585
.cursor_pointer()
2586
.hover(|button| button.bg(theme::popup_hover()))
2587
.when(self.table_picker.is_some(), |button| {
2588
button.bg(theme::popup_hover())
2589
})
2590
.tooltip(|window, cx| Tooltip::new("Insert table").build(window, cx))
2591
.child(symbol("table", COMPOSER_ICON_SIZE, theme::text_muted()))
2592
.on_click(cx.listener(|this, _, _, cx| this.open_table_picker(cx)))
2593
});
2594
2582
let composer = cx.weak_entity();
2595
2583
let tokens_composer = composer.clone();
2596
2584
let input = Textarea::new(&self.input)
@@ -2969,8 +2957,7 @@ impl Render for Composer {
2969
2957
.flex_none()
2970
2958
.gap(px(COMPOSER_BUTTON_INSET))
2971
2959
.children(fun)
2972
.children(attach)
2973
.children(table_button),
2960
.children(attach),
2974
2961
)
2975
2962
})
2976
2963
.child(
@@ -947,6 +947,10 @@ impl Composer {947
FormatButton::Bulleted => self.toggle_lines(LineKind::Bullet(0), window, cx),947
FormatButton::Bulleted => self.toggle_lines(LineKind::Bullet(0), window, cx),948
FormatButton::Numbered => self.toggle_lines(LineKind::Numbered(0), window, cx),948
FormatButton::Numbered => self.toggle_lines(LineKind::Numbered(0), window, cx),949
FormatButton::Quote => self.toggle_lines(LineKind::Quote, window, cx),949
FormatButton::Quote => self.toggle_lines(LineKind::Quote, window, cx),950
FormatButton::Table => {951
self.toolbar_dismissed = Some(self.selection(cx));952
self.open_table_picker(cx);953
}950
}954
}951
}955
}952
956
@@ -967,6 +971,8 @@ impl Composer {967
FormatButton::Bulleted => self.draft.line_state(range, &LineKind::Bullet(0)),971
FormatButton::Bulleted => self.draft.line_state(range, &LineKind::Bullet(0)),968
FormatButton::Numbered => self.draft.line_state(range, &LineKind::Numbered(0)),972
FormatButton::Numbered => self.draft.line_state(range, &LineKind::Numbered(0)),969
FormatButton::Quote => self.draft.line_state(range, &LineKind::Quote),973
FormatButton::Quote => self.draft.line_state(range, &LineKind::Quote),974
FormatButton::Table if self.table_picker.is_some() => FormatState::On,975
FormatButton::Table => FormatState::Off,970
}976
}971
}977
}972
978
@@ -2573,24 +2579,6 @@ impl Render for Composer {2573
))2579
))2574
.on_click(cx.listener(|this, _, window, cx| this.open_picker(window, cx)))2580
.on_click(cx.listener(|this, _, window, cx| this.open_picker(window, cx)))2575
});2581
});2576
let table_button = can_attach.then(|| {2577
div()2578
.id("composer-table")2579
.size(px(COMPOSER_BUTTON_SIZE))2580
.flex_none()2581
.flex()2582
.items_center()2583
.justify_center()2584
.rounded(px(8.))2585
.cursor_pointer()2586
.hover(|button| button.bg(theme::popup_hover()))2587
.when(self.table_picker.is_some(), |button| {2588
button.bg(theme::popup_hover())2589
})2590
.tooltip(|window, cx| Tooltip::new("Insert table").build(window, cx))2591
.child(symbol("table", COMPOSER_ICON_SIZE, theme::text_muted()))2592
.on_click(cx.listener(|this, _, _, cx| this.open_table_picker(cx)))2593
});2594
let composer = cx.weak_entity();2582
let composer = cx.weak_entity();2595
let tokens_composer = composer.clone();2583
let tokens_composer = composer.clone();2596
let input = Textarea::new(&self.input)2584
let input = Textarea::new(&self.input)@@ -2969,8 +2957,7 @@ impl Render for Composer {2969
.flex_none()2957
.flex_none()2970
.gap(px(COMPOSER_BUTTON_INSET))2958
.gap(px(COMPOSER_BUTTON_INSET))2971
.children(fun)2959
.children(fun)2972
.children(attach)2960
.children(attach),2973
.children(table_button),2974
)2961
)2975
})2962
})2976
.child(2963
.child(@@ -42,9 +42,10 @@ pub enum FormatButton {
42
42
Bulleted,
43
43
Numbered,
44
44
Quote,
45
Table,
45
46
}
46
47
47
pub const GROUPS: [&[FormatButton]; 5] = [
48
pub const GROUPS: [&[FormatButton]; 6] = [
48
49
&[
49
50
FormatButton::Bold,
50
51
FormatButton::Italic,
@@ -63,6 +64,7 @@ pub const GROUPS: [&[FormatButton]; 5] = [
63
64
FormatButton::Numbered,
64
65
FormatButton::Quote,
65
66
],
67
&[FormatButton::Table],
66
68
];
67
69
68
70
impl FormatButton {
@@ -82,6 +84,7 @@ impl FormatButton {
82
84
FormatButton::Bulleted => "Bulleted list",
83
85
FormatButton::Numbered => "Numbered list",
84
86
FormatButton::Quote => "Quote",
87
FormatButton::Table => "Insert table",
85
88
}
86
89
}
87
90
@@ -102,6 +105,7 @@ impl FormatButton {
102
105
FormatButton::Bulleted => symbol("format_list_bulleted", 18., color).into_any_element(),
103
106
FormatButton::Numbered => symbol("format_list_numbered", 18., color).into_any_element(),
104
107
FormatButton::Quote => symbol("format_quote", 18., color).into_any_element(),
108
FormatButton::Table => symbol("table", 18., color).into_any_element(),
105
109
}
106
110
}
107
111
}
@@ -353,7 +357,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {
353
357
mod tests {
354
358
use gpui_kit::px;
355
359
356
use super::{ARROW_MARGIN, BUTTON, GROUPS, bar_width, place};
360
use super::{ARROW_MARGIN, BUTTON, FormatButton, GROUPS, bar_width, place};
357
361
358
362
#[test]
359
363
fn the_bar_centers_over_the_selection() {
@@ -381,8 +385,9 @@ mod tests {
381
385
}
382
386
383
387
#[test]
384
fn the_bar_holds_fourteen_buttons_in_five_groups() {
385
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 14);
386
assert!(bar_width() > 14. * BUTTON);
388
fn the_bar_holds_fifteen_buttons_in_six_groups_with_the_table_last() {
389
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 15);
390
assert_eq!(GROUPS.last().copied(), Some(&[FormatButton::Table][..]));
391
assert!(bar_width() > 15. * BUTTON);
387
392
}
388
393
}
@@ -42,9 +42,10 @@ pub enum FormatButton {42
Bulleted,42
Bulleted,43
Numbered,43
Numbered,44
Quote,44
Quote,45
Table,45
}46
}46
47
47
pub const GROUPS: [&[FormatButton]; 5] = [48
pub const GROUPS: [&[FormatButton]; 6] = [48
&[49
&[49
FormatButton::Bold,50
FormatButton::Bold,50
FormatButton::Italic,51
FormatButton::Italic,@@ -63,6 +64,7 @@ pub const GROUPS: [&[FormatButton]; 5] = [63
FormatButton::Numbered,64
FormatButton::Numbered,64
FormatButton::Quote,65
FormatButton::Quote,65
],66
],67
&[FormatButton::Table],66
];68
];67
69
68
impl FormatButton {70
impl FormatButton {@@ -82,6 +84,7 @@ impl FormatButton {82
FormatButton::Bulleted => "Bulleted list",84
FormatButton::Bulleted => "Bulleted list",83
FormatButton::Numbered => "Numbered list",85
FormatButton::Numbered => "Numbered list",84
FormatButton::Quote => "Quote",86
FormatButton::Quote => "Quote",87
FormatButton::Table => "Insert table",85
}88
}86
}89
}87
90
@@ -102,6 +105,7 @@ impl FormatButton {102
FormatButton::Bulleted => symbol("format_list_bulleted", 18., color).into_any_element(),105
FormatButton::Bulleted => symbol("format_list_bulleted", 18., color).into_any_element(),103
FormatButton::Numbered => symbol("format_list_numbered", 18., color).into_any_element(),106
FormatButton::Numbered => symbol("format_list_numbered", 18., color).into_any_element(),104
FormatButton::Quote => symbol("format_quote", 18., color).into_any_element(),107
FormatButton::Quote => symbol("format_quote", 18., color).into_any_element(),108
FormatButton::Table => symbol("table", 18., color).into_any_element(),105
}109
}106
}110
}107
}111
}@@ -353,7 +357,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {353
mod tests {357
mod tests {354
use gpui_kit::px;358
use gpui_kit::px;355
359
356
use super::{ARROW_MARGIN, BUTTON, GROUPS, bar_width, place};360
use super::{ARROW_MARGIN, BUTTON, FormatButton, GROUPS, bar_width, place};357
361
358
#[test]362
#[test]359
fn the_bar_centers_over_the_selection() {363
fn the_bar_centers_over_the_selection() {@@ -381,8 +385,9 @@ mod tests {381
}385
}382
386
383
#[test]387
#[test]384
fn the_bar_holds_fourteen_buttons_in_five_groups() {388
fn the_bar_holds_fifteen_buttons_in_six_groups_with_the_table_last() {385
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 14);389
assert_eq!(GROUPS.iter().map(|group| group.len()).sum::<usize>(), 15);386
assert!(bar_width() > 14. * BUTTON);390
assert_eq!(GROUPS.last().copied(), Some(&[FormatButton::Table][..]));391
assert!(bar_width() > 15. * BUTTON);387
}392
}388
}393
}