Add Markdown Preview Toggle (#15215)
Add a "Preview Markdown" button to the quick action bar when in a markdown editor. While it isn't my favorite, I went with the basic eye icon to be a bit more generic so we can extend this control to allow opening other previews such as SVGs like @jansol mentioned.  https://github.com/user-attachments/assets/5980272c-eab9-4f69-86b6-0c593c25b525 --- Release Notes: - Added a button to preview Markdown files in the toolbar. `Option|Alt+Click` will open the preview to the side.
This commit is contained in:
parent
73d682c010
commit
05825e9804
9 changed files with 93 additions and 21 deletions
|
@ -21,16 +21,18 @@ use workspace::{
|
|||
};
|
||||
|
||||
mod repl_menu;
|
||||
mod toggle_markdown_preview;
|
||||
|
||||
pub struct QuickActionBar {
|
||||
buffer_search_bar: View<BufferSearchBar>,
|
||||
repl_menu: Option<View<ContextMenu>>,
|
||||
toggle_settings_menu: Option<View<ContextMenu>>,
|
||||
toggle_selections_menu: Option<View<ContextMenu>>,
|
||||
active_item: Option<Box<dyn ItemHandle>>,
|
||||
_inlay_hints_enabled_subscription: Option<Subscription>,
|
||||
workspace: WeakView<Workspace>,
|
||||
active_item: Option<Box<dyn ItemHandle>>,
|
||||
buffer_search_bar: View<BufferSearchBar>,
|
||||
platform_style: PlatformStyle,
|
||||
repl_menu: Option<View<ContextMenu>>,
|
||||
show: bool,
|
||||
toggle_selections_menu: Option<View<ContextMenu>>,
|
||||
toggle_settings_menu: Option<View<ContextMenu>>,
|
||||
workspace: WeakView<Workspace>,
|
||||
}
|
||||
|
||||
impl QuickActionBar {
|
||||
|
@ -40,14 +42,15 @@ impl QuickActionBar {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let mut this = Self {
|
||||
buffer_search_bar,
|
||||
toggle_settings_menu: None,
|
||||
toggle_selections_menu: None,
|
||||
repl_menu: None,
|
||||
active_item: None,
|
||||
_inlay_hints_enabled_subscription: None,
|
||||
workspace: workspace.weak_handle(),
|
||||
active_item: None,
|
||||
buffer_search_bar,
|
||||
platform_style: PlatformStyle::platform(),
|
||||
repl_menu: None,
|
||||
show: true,
|
||||
toggle_selections_menu: None,
|
||||
toggle_settings_menu: None,
|
||||
workspace: workspace.weak_handle(),
|
||||
};
|
||||
this.apply_settings(cx);
|
||||
cx.observe_global::<SettingsStore>(|this, cx| this.apply_settings(cx))
|
||||
|
@ -300,22 +303,19 @@ impl Render for QuickActionBar {
|
|||
|
||||
h_flex()
|
||||
.id("quick action bar")
|
||||
.gap(Spacing::Large.rems(cx))
|
||||
.gap(Spacing::XXLarge.rems(cx))
|
||||
.child(
|
||||
h_flex()
|
||||
.gap(Spacing::Medium.rems(cx))
|
||||
.children(self.render_repl_menu(cx))
|
||||
.children(self.render_toggle_markdown_preview(self.workspace.clone(), cx))
|
||||
.children(search_button)
|
||||
.when(
|
||||
AssistantSettings::get_global(cx).enabled
|
||||
&& AssistantSettings::get_global(cx).button,
|
||||
|bar| bar.child(assistant_button),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
.gap(Spacing::Medium.rems(cx))
|
||||
.children(search_button),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
.gap(Spacing::Medium.rems(cx))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue