markdown_preview.rs

 1use gpui::{App, actions};
 2use workspace::Workspace;
 3
 4pub mod markdown_preview_view;
 5
 6pub use zed_actions::preview::markdown::{OpenPreview, OpenPreviewToTheSide};
 7
 8actions!(
 9    markdown,
10    [
11        /// Scrolls up by one page in the markdown preview.
12        #[action(deprecated_aliases = ["markdown::MovePageUp"])]
13        ScrollPageUp,
14        /// Scrolls down by one page in the markdown preview.
15        #[action(deprecated_aliases = ["markdown::MovePageDown"])]
16        ScrollPageDown,
17        /// Scrolls up by approximately one visual line.
18        ScrollUp,
19        /// Scrolls down by approximately one visual line.
20        ScrollDown,
21        /// Scrolls up by one markdown element in the markdown preview
22        ScrollUpByItem,
23        /// Scrolls down by one markdown element in the markdown preview
24        ScrollDownByItem,
25        /// Scrolls to the top of the markdown preview.
26        ScrollToTop,
27        /// Scrolls to the bottom of the markdown preview.
28        ScrollToBottom,
29        /// Opens a following markdown preview that syncs with the editor.
30        OpenFollowingPreview
31    ]
32);
33
34pub fn init(cx: &mut App) {
35    cx.observe_new(|workspace: &mut Workspace, window, cx| {
36        let Some(window) = window else {
37            return;
38        };
39        markdown_preview_view::MarkdownPreviewView::register(workspace, window, cx);
40    })
41    .detach();
42}