Skip to main content

Crate iced_markdown_editor

Crate iced_markdown_editor 

Source
Expand description

§iced-markdown-editor

A Word-style WYSIWYG CommonMark editor widget for Iced, with the GFM extensions strikethrough and task lists. Desktop and web.

ⓘ
use iced_markdown_editor::{markdown_editor, Action, EditorState, Event};

struct App { editor: EditorState }

#[derive(Debug, Clone)]
enum Message { Editor(Action) }

impl App {
    fn update(&mut self, message: Message) -> iced::Task<Message> {
        match message {
            Message::Editor(action) => {
                let output = self.editor.update(action);
                if output.events.contains(&Event::Changed) {
                    println!("{}", self.editor.markdown());
                }
                output.task.map(Message::Editor)
            }
        }
    }

    fn view(&self) -> iced::Element<'_, Message> {
        markdown_editor(&self.editor).view().map(Message::Editor)
    }

    fn subscription(&self) -> iced::Subscription<Message> {
        self.editor.subscription().map(Message::Editor)
    }
}

§Features

FeatureDefaultAdds
syntectoffSyntectHighlighter, a ready-made code highlighter
imagesoffShowing images, and pasting images from the clipboard (desktop)

Re-exports§

pub use highlight::CodeHighlighter;
pub use highlight::HighlightRequest;
pub use highlight::HighlightSpan;
pub use images::ImageId;
pub use images::ImageLoader;
pub use images::ImageMode;
pub use images::ImageRejection;
pub use images::ImageSettings;
pub use images::ImageSource;
pub use images::PastedImage;
pub use page::IsoSeries;
pub use page::Margins;
pub use page::Measure;
pub use page::Orientation;
pub use page::PageSize;
pub use page::Paper;
pub use page::ParseError;
pub use page::Unit;
pub use style::EditorStyle;
pub use style::Palette;
pub use style::Typography;
pub use widget::Action;
pub use widget::Command;
pub use widget::DEFAULT_TAB_WIDTH;
pub use widget::EditorState;
pub use widget::Event;
pub use widget::Formatting;
pub use widget::MarkdownEditor;
pub use widget::Mode;
pub use widget::Output;
pub use widget::markdown_editor;
pub use zoom::KeyBinding;
pub use zoom::ZoomSettings;
pub use zoom::ZoomShortcuts;
pub use crate::syntect::SyntectHighlighter;syntect

Modules§

highlight
Code highlighting plugin interface.
images
Images: paste, drop and insert; embed in the Markdown or hand them to the application; display.
page
Paper setup: page size, orientation and margins.
style
Theming.
syntectsyntect
Code highlighter based on syntect (Sublime Text grammars). Available with the syntect feature.
widget
The public widget API.
zoom
Zoom settings and key bindings.

Enums§

BlockKind
Paragraph-level formatting as offered in the toolbar and the API.

Constants§

FONTS
All bundled font files. Register them with your application:

Functions§

normalize
Parses and writes Markdown again, in the form the editor saves it.