mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-19 02:26:48 +00:00
## What this changes `edit.line-paragraph-spacing` was partial: line spacing existed, the space between paragraphs did not. Now a line break in the edited text starts a paragraph, and the paragraphs are set apart: - `BlockStyle.paragraph_spacing: Option<f64>` (points, beyond the line spacing). `rewrite_block` splits the text at line breaks, wraps and justifies each paragraph on its own (the last line of each paragraph is never stretched), and steps down by the line spacing plus the gap before a paragraph's first line; underlines follow. `None` is half the font size when the text has several paragraphs, so a plain Enter already reads as a paragraph; a non-finite value is refused. - The row-model rewrite (`text_regions`) keeps the rows a line break started apart from wrapped ones: the gap goes before those, and a row the page already had sits where it was, shifted by the spacing added above it. - Format text panel: a Paragraph spacing field (points) next to the line spacing; the tool `text_edit` takes `paragraph_spacing`. - Rows for the two labels in all 21 languages; `parity/acrobat-features.toml` `edit.line-paragraph-spacing` → shipped (notes: space before and after as separate values are still missing). ## How you verified it Re-run on 2026-10-15 after merging `main` into the branch (41809cf7, thenafa8e184). The merge needed the language catalogs (upstream's rows and this PR's kept), ATTRIBUTION.toml's checksums and the tests both sides had appended at the same place; the new Vietnamese catalog got this PR's 2 labels (written by an AI model, like the other languages' rows, so a native speaker's review is welcome). Reconciled with #1486 (line breaks kept when editing a multi-line paragraph): the default gap between paragraphs applies to upright text only; turned text keeps its rows where they were unless a spacing is set. #1539 merged without conflict. A needless borrow clippy found on Windows is fixed. Full run on Windows (Rust 1.98) at the branch merged with `main` 41809cf7; after `main`afa8e184was merged, re-checked on macOS (this PR's tests, the `i18n` tests, `cargo clippy --all-targets -- -D warnings` on the changed crates and their dependents (automation, edit, engine, ui-egui, audit, redact, the apps), `cargo xtask assets`): - [x] `cargo fmt --all --check`, `cargo xtask assets`, `cargo xtask layers`, doctests: exit 0 - [x] `cargo clippy --workspace --all-targets -- -D warnings`: clean on Windows; on macOS the only warnings are `main`'s own (`crates/ui-egui/tests/view.rs`: two helpers used only by a non-macOS test) - [x] This PR's tests pass: `paragraph_breaks_get_their_own_spacing`, `the_format_panel_has_a_paragraph_spacing_field`, and `main`'s `turned_paragraph_keeps_its_line_breaks_when_a_word_is_added` - [ ] `cargo nextest run --workspace`: 3422 of 3433 passed on Windows. The 11 failures fail the same way on `main` without this change: the parity file's duplicate keys (also `cargo xtask parity`; #2419 / #2473), the zh-hant duplicates and the Vietnamese coverage tests in `i18n` (none lists this PR's labels), `signing_with_translated_labels_through_tools` (#2429), `canvas::tests::explicit_search_jumps_record_history_and_keep_match_destination`, `view::single_page_swipe_that_reaches_the_edge_does_not_turn_but_a_fresh_one_does`, `editing::files_dropped_beside_the_pages_panel_still_open_as_documents` (intermittent) **Tests.** `paragraph_breaks_get_their_own_spacing` (edit): a one-line source rewritten as "First one\nSecond one" gets the row step alone (15 pt for a 10 pt one-liner), 35 pt with a 20 pt spacing, 15 pt with 0, and a wrapped single paragraph keeps the ordinary 12 pt step. `the_format_panel_has_a_paragraph_spacing_field` (ui-egui): the field is in the panel while a paragraph is being edited. ## Anything a reviewer should look at first - The labels in the 20 non-English language files were written by an AI model from the English wording; a native speaker's review of those rows would be welcome. - Justification now stops at each paragraph's last line (before, only the block's last line was left unstretched); with a single paragraph nothing changes. - **Overlap with #1487** ("M7: line and paragraph spacing", opened the day before this one): it adds the same `BlockStyle.paragraph_spacing`, a spacing field in the Format panel and the `text_edit` argument. On top of that, this PR stops justification at each paragraph's last line, adds a UI test beside the edit-crate test, and carries the label in all 21 catalogs. Whichever you prefer is fine: if #1487 lands first I'll rebase this down to what it adds on top of it, or close it. - **Fits #2249** ("lay out Format text as Acrobat's panel"): that redesign shows paragraph spacing disabled as *Planned* and replaces `edit_text_ui::extras_panel`, where this PR's field lives. This PR supplies what the control would drive (`BlockStyle.paragraph_spacing` applied by `text_regions.rs`); if #2249 lands first I'll move the field into its panel and enable it there. ## Never-crash - [x] No new `unwrap`/`expect`/`panic!` outside tests - [x] The spacing is validated (finite, clamped to 0–14 400 pt); rows are indexed with `get` - [x] No `unsafe` ## Provenance - [x] No asset added; no code from another implementation ## Security - [x] No network access ## Parity and reach - [x] `parity/acrobat-features.toml` updated with what is still missing - [x] Headless through `text_edit` (`paragraph_spacing`) - [x] No documented behaviour changed (`docs/` has no entry for it) - **Merged with main dc41044b** (2026-10-15): #2510's Vietnamese and Lithuanian catalogs added rows beside this branch's in `vi.tsv` and `lt.tsv` (and `ATTRIBUTION.toml`'s sha256 lines), nothing else. Main's rows kept, this branch's rows main lacks after them, hashes recomputed. Re-checked after the merge: `cargo xtask assets` ok, `i18n::tests` 117/117. - **Merged with main 5fdd820b** (2026-10-15): #1895's catalog rows conflicted with this branch's in `es.tsv` and `vi.tsv` (and `ATTRIBUTION.toml`'s sha256 lines), nothing else. Main's rows kept, this branch's rows main lacks after them, hashes recomputed. Re-checked after the merge: `cargo xtask assets` ok, clippy -D warnings on this branch's crates ok, `i18n::tests` 117/117. - **Merged with main bc7a12b9** (2026-10-17): only the translation catalogs' new rows and `ATTRIBUTION.toml`'s hashes met this branch (both sides kept, hashes recomputed). Re-checked on macOS: `cargo check --workspace --all-targets`, `cargo xtask assets`, `i18n::tests` 115/115. - **Merged with main 3f5a784c** (2026-10-17): tests and docs both sides added kept (upstream's first), translation rows and `ATTRIBUTION.toml`'s hashes by key. Re-checked on macOS: `cargo check --workspace --all-targets`, `cargo xtask assets`, `i18n::tests` 115/115. - **Merged with main dab31491** (2026-10-18, in two steps:932bf9c6, thendab31491without conflicts): main and this branch both added tests at the end of `crates/edit/src/tests.rs` and `crates/ui-egui/tests/editing.rs`; both kept, each with its own closing brace (this branch's first), no test lost: the `#[test]` count is main's plus this branch's; and `ATTRIBUTION.toml`'s sha256 lines (main's file kept, every hash recomputed from the merged tree). Re-checked after the merge: `cargo check --workspace --all-targets` ok, `cargo xtask assets` ok, `i18n::tests` 119/119, this branch's tests 2/2. - **CodeRabbit fixes** (2026-10-21): choosing a font family no longer spreads rows apart when no spacing is set, and applying a spacing replaces the gap a paragraph already had instead of adding to it, so repeating it gives the same result. Each has a test in its own file that fails without the fix. - **Merged with main 6dec57bf** (2026-10-21): upstream rebuilt the Format text panel and deleted the function this PR's Paragraph spacing row lived in, so the row moved into the new panel, replacing its disabled placeholder; upstream already had the "Paragraph spacing" label in every catalog, so this PR's duplicate rows were dropped, and ATTRIBUTION.toml took main's copy with the hashes recomputed. - **Merged with main 6898094e** (2026-10-21): only the translation-catalog hashes in ATTRIBUTION.toml met this branch. - **Round-2 CodeRabbit fixes** (2026-10-21): the draft's line breaks are matched to the source rows by where they came from instead of by position, so a break inserted inside a source row puts the spacing before the new paragraph and later rows keep their source steps. Each has a test in its own file. - **Merged with main dbc7130b** (2026-10-21): only the translation-catalog hashes in ATTRIBUTION.toml met this branch. - **Merged with main ffaf3123** (2026-10-21): only the translation-catalog hashes in ATTRIBUTION.toml met this branch. - **Merged with main adea2c90** (2026-10-23): the parity row both sides changed keeps upstream's evidence with this PR's entries on top; this PR's test moved into upstream's new tests/it layout. - **Merged with main 57e531cc** (2026-10-23): only the translation-catalog hashes in ATTRIBUTION.toml met this branch. - **Merged with main a2ec27b4** (2026-10-23): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked. - **Merged with main 6718f1f3** (2026-10-24): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked. - **Merged with main 418ac6a2** (2026-10-25): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked. - **Merged with main 1dd2737b4** (2026-10-27): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked. - **Merged with main 0cba87ae** (2026-11-01): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked. - **Merged with main 3936f93a** (2026-11-02): upstream's changes met this PR in pdfcraft-automation, pdfcraft-edit, pdfcraft-ui-egui; checked.