documents: block commands keep text, tasks and list items whole

Round-1 fixes for R4.7: a caret in heading marks splits at the text; a
split closes and reopens bold, italic and strike, refusing inside links,
code, math and HTML; a task's first text takes no block; retype keeps
task boxes and code indent and takes siblings past the list; an alert
in an item keeps the item's opener; paragraph-before moves a holder's
first text below its opener; delete keeps neighbors from joining; a
heading's text keeps closing hashes and block openers escaped; a heading
level is idempotent, as Typora's menu calls it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-14 14:08:40 -04:00
1 parent 58e212d4ec
commit b37031b00b
9 files changed
+438 -153

No files matched your search

+8
View File
@@ -4,6 +4,7 @@ mod heading;
mod insert;
mod list;
mod quote;
mod split;
use std::ops::Range;
@@ -189,6 +190,13 @@ pub(super) fn container(node: &Node) -> bool {
)
}
/// Whether `node` is task item `holder`'s first text.
pub(super) fn task_head(holder: &Node, node: &Node) -> bool {
matches!(holder, Node::ListItem(item)
if item.checked.is_some()
&& item.children.first().is_some_and(|kid| std::ptr::eq(kid, node)))
}
/// Whether the path goes on below `node`.
fn holds(node: &Node) -> bool {
container(node) || matches!(node, Node::Root(_) | Node::List(_))