documents: lists go on, block lines shift, tables change, matches show, fences color by language
The document carries Markdown's editing tools for ElyMark (MARK-06): Enter continues a list item or ends an empty one, Tab and Shift-Tab shift an open block's lines, table rows and columns come and go as one undo step, a match shows in any mode, replacements are one step, and a fenced block colors by its language. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
2e196a10a7
commit
ce4a1e9cb5
12 files changed
+680
-8
No files matched your search
@@ -12,16 +12,19 @@ use crate::{
|
||||
theme::{ActiveTheme, Radius, TextSize},
|
||||
};
|
||||
|
||||
actions!(markdown_document, [Undo, Redo]);
|
||||
actions!(markdown_document, [Undo, Redo, Indent, Outdent]);
|
||||
|
||||
const CONTEXT: &str = "MarkdownDocument";
|
||||
|
||||
/// Undo and redo while no block is open.
|
||||
/// Undo and redo; Tab shifts an open block's lines.
|
||||
pub(crate) fn bind_keys(cx: &mut App) {
|
||||
let context = Some(CONTEXT);
|
||||
let block = Some("MarkdownDocument > ElyInput");
|
||||
let mut bindings = vec![
|
||||
KeyBinding::new("secondary-z", Undo, context),
|
||||
KeyBinding::new("secondary-shift-z", Redo, context),
|
||||
KeyBinding::new("tab", Indent, block),
|
||||
KeyBinding::new("shift-tab", Outdent, block),
|
||||
];
|
||||
if !cfg!(target_os = "macos") {
|
||||
bindings.push(KeyBinding::new("ctrl-y", Redo, context));
|
||||
@@ -143,7 +146,14 @@ impl Render for MarkdownDocument {
|
||||
.font_weight(FontWeight::NORMAL);
|
||||
let blocks = list(self.list.clone(), cx.processor(Self::item)).size_full();
|
||||
match self.mode {
|
||||
MarkdownMode::Source => root.child(self.editor.clone()).into_any_element(),
|
||||
MarkdownMode::Source => root
|
||||
.capture_action(cx.listener(|document, _: &crate::editor::Newline, _, cx| {
|
||||
if document.source_newline(cx) {
|
||||
cx.stop_propagation();
|
||||
}
|
||||
}))
|
||||
.child(self.editor.clone())
|
||||
.into_any_element(),
|
||||
MarkdownMode::Split => root
|
||||
.flex()
|
||||
.child(div().flex_1().min_w_0().h_full().child(self.editor.clone()))
|
||||
@@ -173,6 +183,17 @@ impl Render for MarkdownDocument {
|
||||
cx.stop_propagation();
|
||||
document.history(true, window, cx);
|
||||
}))
|
||||
.capture_action(cx.listener(|document, _: &forms::Enter, _, cx| {
|
||||
if document.block_newline(cx) {
|
||||
cx.stop_propagation();
|
||||
}
|
||||
}))
|
||||
.on_action(cx.listener(|document, _: &Indent, window, cx| {
|
||||
document.block_shift(true, window, cx);
|
||||
}))
|
||||
.on_action(cx.listener(|document, _: &Outdent, window, cx| {
|
||||
document.block_shift(false, window, cx);
|
||||
}))
|
||||
.capture_action(cx.listener(|document, _: &Up, window, cx| {
|
||||
if document.step(false, window, cx) {
|
||||
cx.stop_propagation();
|
||||
|
||||
Reference in new issue
Block a user