mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-27 11:57:36 -06:00
cargo fmt
This commit is contained in:
@@ -355,9 +355,11 @@ fn remove_toc(s: &mut Session, start: usize, end: usize) -> Result<usize, CmdErr
|
||||
start
|
||||
}
|
||||
};
|
||||
let titled = start.checked_sub(1).and_then(|i| s.doc.body.get(i)).and_then(|b| b.as_para()).is_some_and(|p| {
|
||||
p.props.style.as_deref() == Some("TOCHeading") && p.section.is_none() && toc_field(p).is_none()
|
||||
});
|
||||
let titled = start
|
||||
.checked_sub(1)
|
||||
.and_then(|i| s.doc.body.get(i))
|
||||
.and_then(|b| b.as_para())
|
||||
.is_some_and(|p| p.props.style.as_deref() == Some("TOCHeading") && p.section.is_none() && toc_field(p).is_none());
|
||||
if titled {
|
||||
s.doc.remove_block(StoryRef::Body, &Path::top(start - 1))?;
|
||||
return Ok(at - 1);
|
||||
|
||||
@@ -142,9 +142,19 @@ fn new_comment(s: &mut Session, v: &Value) -> CmdResult {
|
||||
let id = comment_id(s)?;
|
||||
let initials = s.user_initials();
|
||||
let now = now_iso();
|
||||
s.doc
|
||||
.comments
|
||||
.insert(id, Comment { author: s.author.clone(), initials, date: now.clone(), date_utc: Some(now), parent: None, resolved: false, part, ..Default::default() });
|
||||
s.doc.comments.insert(
|
||||
id,
|
||||
Comment {
|
||||
author: s.author.clone(),
|
||||
initials,
|
||||
date: now.clone(),
|
||||
date_utc: Some(now),
|
||||
parent: None,
|
||||
resolved: false,
|
||||
part,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let props = Default::default();
|
||||
s.doc.insert_object(&b, InlineObject::CommentEnd { id }, &props)?;
|
||||
s.doc.insert_object(&a, InlineObject::CommentStart { id }, &props)?;
|
||||
@@ -174,7 +184,16 @@ fn reply(s: &mut Session, v: &Value) -> CmdResult {
|
||||
let now = now_iso();
|
||||
s.doc.comments.insert(
|
||||
id,
|
||||
Comment { author: s.author.clone(), initials, date: now.clone(), date_utc: Some(now), parent: Some(parent), resolved: false, part, ..Default::default() },
|
||||
Comment {
|
||||
author: s.author.clone(),
|
||||
initials,
|
||||
date: now.clone(),
|
||||
date_utc: Some(now),
|
||||
parent: Some(parent),
|
||||
resolved: false,
|
||||
part,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
Ok(json!({"id": id}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user