1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! A block-based WYSIWYG Markdown editor for GPUI, built on gpui-kit's
//! public editor host API (`gpui_kit::base::text::editor_host`).
//!
//! The design began as a spike in
//! [longbridge/gpui-kit#3049](https://github.com/longbridge/gpui-kit/pull/3049)
//! and [#3566](https://github.com/longbridge/gpui-kit/pull/3566); see
//! `docs/design.md`. Call [`init`] once, after `gpui_kit::init`.
//!
//! - [`BlockEditorModel`]: the headless model. It has stable [`BlockId`]s,
//! validated [`BlockPosition`]s, normalized inline mark runs, invertible
//! steps grouped into transactions, undo coalescing, commands on nested
//! blocks ([`EditorCommand`]), and a Markdown serializer.
//! - [`BlockEditorState`]: the entity that owns a model, focus, IME and
//! key bindings, and emits [`BlockEditorEvent`]s.
//! - [`BlockEditor`]: the view. It renders through gpui-kit's own text
//! renderer (a direct model-to-node projection) and culls off-screen blocks.
//!
//! ```ignore
//! let scroll = ScrollHandle::new();
//! let editor = cx.new(|cx| {
//! let mut state = BlockEditorState::new(window, cx).with_source("# Hello");
//! // Optional: keep the caret in view inside your scroll container.
//! state.set_scroll_handle(scroll.clone());
//! state
//! });
//! cx.subscribe(&editor, |_, editor, event: &BlockEditorEvent, cx| {
//! if let BlockEditorEvent::Changed { .. } = event {
//! let markdown = editor.read(cx).source();
//! }
//! });
//! // in render:
//! div().id("doc").overflow_y_scroll().track_scroll(&scroll)
//! .child(BlockEditor::new(&editor))
//! ```
//!
//! Keys: Enter, Backspace/Delete, arrows/Home/End (+Shift), Cmd/Ctrl+A, B, I,
//! E, Z, Shift+Z, C, X, V, and Shift+V (plain paste); Tab/Shift+Tab indent
//! list items; Cmd/Ctrl+Alt+0 makes the block (or each selected block) a
//! paragraph. Input rules: `# `..`###### `, `- `, `* `, `+ `, `1. `.
//! The scroll handle is optional: without it, blocks outside the visible
//! area are still culled, but moving the caret never scrolls (a no-op).
pub
pub use ;
pub use ;
pub use BlockEditorModel;
pub use BlockEditor;
pub use ColumnAlign;
pub use InputRule;
pub use ;
pub use BlockEditorStyle;
pub use ;
/// Registers the editor's key bindings. Call once at startup, after `gpui_kit::init`.
/// gpui-kit's own layers first (theme, global state), then the editor.
pub
pub use BlockId;
pub use BlockKind;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Whether image atoms may load resources while the editor presents them.
/// `Placeholder` keeps the atomic document, source and selection but never
/// resolves URLs, decodes data, reads paths or creates image elements.