Draw paged top floats with their text float separation
This commit is contained in:
1 parent
aa081e3dc6
commit
c5b3493998
3 files changed
+31
-9
No files matched your search
+7
-6
@@ -81,7 +81,7 @@ pub fn project_preview_json(project_id: &str, source: &str) -> Result<String, St
|
||||
(engine, changed, recomputed)
|
||||
}
|
||||
};
|
||||
let json = render_json(&engine, Some((&changed, recomputed)));
|
||||
let json = render_json(&document, &engine, Some((&changed, recomputed)));
|
||||
sessions.insert(
|
||||
project_id.to_string(),
|
||||
ProjectSession { paragraphs, engine },
|
||||
@@ -138,7 +138,7 @@ pub fn preview_json(source: &str) -> Result<String, String> {
|
||||
let paragraphs = paragraphs(source)?;
|
||||
let document = build_document(¶graphs);
|
||||
let engine = Engine::layout(&document);
|
||||
let json = render_json(&engine, None);
|
||||
let json = render_json(&document, &engine, None);
|
||||
// Keep the layout so a following `/edit` request can diff against it and
|
||||
// reuse page checkpoints instead of starting from a no-op document.
|
||||
ROUTE_D_SESSION.with(|slot| {
|
||||
@@ -159,7 +159,8 @@ pub fn pdf_bytes(source: &str) -> Result<Vec<u8>, String> {
|
||||
.pages()
|
||||
.iter()
|
||||
.map(|page| {
|
||||
let mut list = page.display_list();
|
||||
let mut list =
|
||||
page.display_list_with_layout(document.page_goal, document.text_float_sep);
|
||||
list.width = list.width.max(PAGE_WIDTH_PT * SCALE);
|
||||
list.height = list.height.max(PAGE_HEIGHT_PT * SCALE);
|
||||
list
|
||||
@@ -195,7 +196,7 @@ pub fn edit_json(source: &str, unit: usize) -> Result<String, String> {
|
||||
engine.edit(&next, unit as u64, paragraphs[unit].text.clone());
|
||||
let changed = engine.changed_pages().to_vec();
|
||||
let recomputed = engine.recomputed_pages();
|
||||
let json = render_json(&engine, Some((&changed, recomputed)));
|
||||
let json = render_json(&next, &engine, Some((&changed, recomputed)));
|
||||
*slot = Some((next, engine));
|
||||
Ok(json)
|
||||
})
|
||||
@@ -430,11 +431,11 @@ fn build_document(paragraphs: &[SourceParagraph]) -> Document {
|
||||
Document::new(700 * SCALE, units)
|
||||
}
|
||||
|
||||
fn render_json(engine: &Engine, edit: Option<(&[usize], usize)>) -> String {
|
||||
fn render_json(document: &Document, engine: &Engine, edit: Option<(&[usize], usize)>) -> String {
|
||||
let mut json = String::new();
|
||||
json.push_str("{\"status\":\"ok\",\"pageWidthMm\":215.90,\"pageHeightMm\":279.40,\"pages\":[");
|
||||
for (index, page) in engine.pages().iter().enumerate() {
|
||||
let mut list = page.display_list();
|
||||
let mut list = page.display_list_with_layout(document.page_goal, document.text_float_sep);
|
||||
list.width = list.width.max(PAGE_WIDTH_PT * SCALE);
|
||||
list.height = list.height.max(PAGE_HEIGHT_PT * SCALE);
|
||||
if index > 0 {
|
||||
|
||||
Reference in new issue
Block a user