iced_markdown_editor/lib.rs
1//! # iced-markdown-editor
2//!
3//! A Word-style WYSIWYG CommonMark editor widget for [Iced](https://iced.rs),
4//! with the GFM extensions strikethrough and task lists. Desktop and web.
5//!
6//! ```ignore
7//! use iced_markdown_editor::{markdown_editor, Action, EditorState, Event};
8//!
9//! struct App { editor: EditorState }
10//!
11//! #[derive(Debug, Clone)]
12//! enum Message { Editor(Action) }
13//!
14//! impl App {
15//! fn update(&mut self, message: Message) -> iced::Task<Message> {
16//! match message {
17//! Message::Editor(action) => {
18//! let output = self.editor.update(action);
19//! if output.events.contains(&Event::Changed) {
20//! println!("{}", self.editor.markdown());
21//! }
22//! output.task.map(Message::Editor)
23//! }
24//! }
25//! }
26//!
27//! fn view(&self) -> iced::Element<'_, Message> {
28//! markdown_editor(&self.editor).view().map(Message::Editor)
29//! }
30//!
31//! fn subscription(&self) -> iced::Subscription<Message> {
32//! self.editor.subscription().map(Message::Editor)
33//! }
34//! }
35//! ```
36//!
37//! ## Features
38//!
39//! | Feature | Default | Adds |
40//! |---|---|---|
41//! | `syntect` | off | [`SyntectHighlighter`], a ready-made code highlighter |
42//! | `images` | off | Showing images, and pasting images from the clipboard (desktop) |
43
44#![cfg_attr(docsrs, feature(doc_cfg))]
45
46pub(crate) mod doc;
47pub(crate) mod fonts;
48pub mod highlight;
49pub mod images;
50pub(crate) mod layout;
51mod markdown;
52pub mod page;
53mod render;
54pub mod style;
55mod toolbar;
56pub mod widget;
57pub mod zoom;
58
59#[cfg(feature = "syntect")]
60#[cfg_attr(docsrs, doc(cfg(feature = "syntect")))]
61pub mod syntect;
62
63pub use doc::BlockKind;
64pub use fonts::FONTS;
65pub use highlight::{CodeHighlighter, HighlightRequest, HighlightSpan};
66pub use images::{
67 ImageId, ImageLoader, ImageMode, ImageRejection, ImageSettings, ImageSource, PastedImage,
68};
69pub use markdown::normalize;
70pub use page::{IsoSeries, Margins, Measure, Orientation, PageSize, Paper, ParseError, Unit};
71pub use style::{EditorStyle, Palette, Typography};
72pub use widget::{
73 Action, Command, DEFAULT_TAB_WIDTH, EditorState, Event, Formatting, MarkdownEditor, Mode,
74 Output, markdown_editor,
75};
76pub use zoom::{KeyBinding, ZoomSettings, ZoomShortcuts};
77
78#[cfg(feature = "syntect")]
79#[cfg_attr(docsrs, doc(cfg(feature = "syntect")))]
80pub use crate::syntect::SyntectHighlighter;