mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-16 23:34:01 +00:00
Merge pull request #2851 from MMexicann/patch-10
fix: preserve selections when resolving tracked changes
This commit is contained in:
2 files changed
+98
-5
No files matched your search
+3
-1
@@ -4,7 +4,7 @@
|
||||
- 2026-10-23: placed-artwork layer options survive IDML and native round trips per placement, independently of shared assets. Unsupported visibility overrides are explicit import/preflight/PDF warnings; format 4 prevents older native readers from silently discarding them. Rendering parity is still open; see [graphic-layer-options.md](docs/graphic-layer-options.md).
|
||||
- FID1: PDF export normalizes mixed emitted gradient color spaces to RGB with an explicit warning; homogeneous device-space gradients retain their components. Linear/radial, midpoint, archival and print policies have synthetic regression coverage.
|
||||
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-06 · **Change:** minor (Pages panel parents and alternate layouts; File ▸ Export Layouts and Versions; placed graphic layer-option preservation and explicit rendering warnings; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text; automation roots refuse superscript COM/LPT names and a device name before a colon) · **Target:** Adobe InDesign 2026
|
||||
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-15 · **Change:** minor (tracked-change selection mapping; Pages panel parents and alternate layouts; File ▸ Export Layouts and Versions; placed graphic layer-option preservation and explicit rendering warnings; File ▸ Open Recent; .indd and .indt open through indd-utils; text threads by hand; the alpha gate waits on Primary Text Frame page fixes; Japanese print, import and table controls localized; Live corners (#186); Optical kerning from outlines (#181); window and menu quit confirmation; failed writes preserve live save and collection state; spring-loaded Zoom navigation; orderly native exit recovery; Pages panel parents; cancelable macOS Dock Quit; text stroke behind fill; Based on Parent; object styles carry effects; table anchors keep their own paragraphs; grouped HTML/EPUB reading order; Links source paths; XLSX cached cell values retain numeric precision and text; automation roots refuse superscript COM/LPT names and a device name before a colon) · **Target:** Adobe InDesign 2026
|
||||
- AR1.1: Kashida justification tests verify space fallback without Tatweel fonts using an isolated font database, while retaining elongation assertions when fonts support it.
|
||||
|
||||
- AR1: Arabic IDML controls now retain character direction, kashida switches, diacritic offsets/forms, paragraph policy values and independent story/table directions. Shaping preserves joining context and script/language selection; paragraph-level bidi, contextual digit conversion, mark-safe elongation, RTL columns/tables and physical column insertion have regression coverage. Vendor-specific justification and diacritic presets remain explicit preflight warnings; see docs/arabic-typography.md.
|
||||
@@ -395,6 +395,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m
|
||||
|
||||
## Progress log
|
||||
|
||||
- **2026-11-15** · Accepting tracked deletions or rejecting insertions follows body-text selections through the removed text, including resolving all changes, and preserves independent cell and footnote insertion points. No readiness percentage change.
|
||||
- **2026-11-14** · `object.stroke` refuses a tint or gap tint outside 0 to 1, a weight outside 0 to 1000 pt, a miter limit outside 1 to 500, a gap overprint that isn't true or false, and an alignment, cap, join or arrowhead name it doesn't have, instead of clamping the numbers and skipping the names. The Stroke panel's Weight and Miter Limit fields keep their values in those ranges. No readiness percentage change.
|
||||
- **2026-11-14** · Photo books no longer freeze the canvas (#1411; based on #2051 by texjer). The image cache keeps only the mip level each image is drawn at, for every format and display quality: a TIFF, PNG, PSD or CMYK JPEG used to keep its full decode too (48 MB for a 12 MP photo), so after about a dozen photos each edit evicted and decoded them again on the render thread. The canvas no longer waits for decodes: an image not cached at its size shows a light box or another cached level and decodes on one of three background threads (within the same in-flight memory limit as the decodes ahead of a render), and finished decodes are drawn in batches, at most one canvas render every 250 ms. Zooming into an image decodes it at most twice. Thumbnails and exports still wait for every image. No readiness percentage change.
|
||||
- **2026-11-14** · IDML export keeps each endnote reference as its number in superscript text, as the endnote frame lists it, instead of dropping it; the endnotes are still written as plain text, without IDML's endnote elements (#2753). No readiness percentage change.
|
||||
@@ -877,6 +878,7 @@ Newest first.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-15 | minor | Track Changes resolution maps body selections through removed text and preserves nested text positions |
|
||||
| 2026-10-12 | minor | Manual text threading landed; alpha distance 15–25 h → 5–7 h (Primary Text Frame page fixes, #165) |
|
||||
| 2026-10-11 | minor | Localized Japanese print, import and table controls; readiness estimates unchanged |
|
||||
| 2026-10-10 | minor | Full number 42% → 47% (plain weighted sum, no new evidence); readiness table with hours per audience |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Type › Track Changes: record edits as inserted / deleted text; accept or reject them.
|
||||
|
||||
use designcraft_doc::{ChangeMark, Document, Story, StoryId};
|
||||
use designcraft_doc::{ChangeMark, Document, Selection, Story, StoryId};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use super::{CommandSpec, cmd, has_doc};
|
||||
@@ -46,7 +46,7 @@ fn ranges(st: &Story, mark: ChangeMark) -> Vec<std::ops::Range<usize>> {
|
||||
}
|
||||
|
||||
/// Accept (or reject) every change in `sid`.
|
||||
fn resolve(d: &mut Document, sid: StoryId, accept: bool) -> usize {
|
||||
fn resolve(d: &mut Document, sel: &mut Selection, sid: StoryId, accept: bool) -> usize {
|
||||
let (remove, keep) = if accept { (ChangeMark::Deleted, ChangeMark::Inserted) } else { (ChangeMark::Inserted, ChangeMark::Deleted) };
|
||||
let (removed, keep_count) = {
|
||||
let st = match d.story(sid) {
|
||||
@@ -68,6 +68,7 @@ fn resolve(d: &mut Document, sid: StoryId, accept: bool) -> usize {
|
||||
});
|
||||
}
|
||||
for r in removed {
|
||||
super::notes::follow_delete(sel, sid, r.clone());
|
||||
d.adjust_text_ranges(sid, r, 0);
|
||||
}
|
||||
n
|
||||
@@ -96,10 +97,12 @@ fn one(s: &mut Session, p: &Value, accept: bool) -> Result<Value> {
|
||||
}
|
||||
}
|
||||
if delete {
|
||||
super::notes::follow_delete(sel, sid, r.clone());
|
||||
d.adjust_text_ranges(sid, r.clone(), 0);
|
||||
}
|
||||
if let Some(t) = &mut sel.text
|
||||
&& t.story == sid
|
||||
&& t.cell.is_none()
|
||||
{
|
||||
let len = d.story(sid).map_or(0, |x| x.len());
|
||||
t.anchor = t.anchor.min(len);
|
||||
@@ -163,10 +166,11 @@ fn all(s: &mut Session, p: &Value, accept: bool) -> Result<Value> {
|
||||
let ids: Vec<StoryId> = d.stories.keys().copied().filter(|id| only.is_none_or(|o| o == *id)).collect();
|
||||
let mut n = 0;
|
||||
for id in ids {
|
||||
n += resolve(d, id, accept);
|
||||
n += resolve(d, sel, id, accept);
|
||||
}
|
||||
// The caret may now be past the end.
|
||||
// A body-text edit must not clamp a cell or note caret against the body length.
|
||||
if let Some(t) = &mut sel.text
|
||||
&& t.cell.is_none()
|
||||
&& let Some(st) = d.story(t.story)
|
||||
{
|
||||
t.anchor = t.anchor.min(st.len());
|
||||
@@ -220,4 +224,91 @@ mod tests {
|
||||
assert_eq!(text(&s), "The dog sat");
|
||||
assert!(s.execute("changes.list", &json!({})).unwrap().as_array().unwrap().is_empty());
|
||||
}
|
||||
|
||||
/// Removing a tracked run follows the selected text by UTF-8 byte offsets, including undo.
|
||||
#[test]
|
||||
fn resolving_a_removed_change_follows_the_text_selection() {
|
||||
use designcraft_doc::ChangeMark;
|
||||
|
||||
for (command, mark) in [
|
||||
("changes.accept", ChangeMark::Deleted),
|
||||
("changes.reject", ChangeMark::Inserted),
|
||||
("changes.acceptAll", ChangeMark::Deleted),
|
||||
("changes.rejectAll", ChangeMark::Inserted),
|
||||
] {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({})).unwrap();
|
||||
let sid = s.execute("frame.create", &json!({"rect": [72, 72, 400, 200], "content": "text", "text": "ab猫cdéfg"})).unwrap()["story"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
s.edit(|d, _| {
|
||||
d.story_mut(designcraft_doc::StoryId(sid)).unwrap().format_chars(2..5, |f| f.over.change = Some(mark));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("text.select", &json!({"story": sid, "anchor": 9, "focus": 5})).unwrap();
|
||||
let params = if command.ends_with("All") { json!({"story": sid}) } else { json!({"story": sid, "start": 2}) };
|
||||
s.execute(command, ¶ms).unwrap();
|
||||
assert_eq!(s.doc().unwrap().doc.story(designcraft_doc::StoryId(sid)).unwrap().text, "abcdéfg", "{command}");
|
||||
let selected = s.doc().unwrap().selection.text.unwrap();
|
||||
assert_eq!((selected.anchor, selected.focus), (6, 2), "{command}");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
let selected = s.doc().unwrap().selection.text.unwrap();
|
||||
assert_eq!((selected.anchor, selected.focus), (9, 5), "undo {command}");
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
let selected = s.doc().unwrap().selection.text.unwrap();
|
||||
assert_eq!((selected.anchor, selected.focus), (6, 2), "redo {command}");
|
||||
}
|
||||
}
|
||||
|
||||
/// All-change resolution removes disjoint runs from the end and maps each one once.
|
||||
#[test]
|
||||
fn resolving_all_changes_follows_multiple_removed_runs() {
|
||||
use designcraft_doc::ChangeMark;
|
||||
|
||||
for (command, mark) in [("changes.acceptAll", ChangeMark::Deleted), ("changes.rejectAll", ChangeMark::Inserted)] {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({})).unwrap();
|
||||
let sid = s.execute("frame.create", &json!({"rect": [72, 72, 400, 200], "content": "text", "text": "a猫bécδd"})).unwrap()["story"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
s.edit(|d, _| {
|
||||
let story = d.story_mut(designcraft_doc::StoryId(sid)).unwrap();
|
||||
story.format_chars(1..4, |f| f.over.change = Some(mark));
|
||||
story.format_chars(5..7, |f| f.over.change = Some(mark));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
s.execute("text.select", &json!({"story": sid, "anchor": 10, "focus": 4})).unwrap();
|
||||
s.execute(command, &json!({"story": sid})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().doc.story(designcraft_doc::StoryId(sid)).unwrap().text, "abcδd", "{command}");
|
||||
let selected = s.doc().unwrap().selection.text.unwrap();
|
||||
assert_eq!((selected.anchor, selected.focus), (5, 1), "{command}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A body-story change leaves the independent footnote insertion point alone.
|
||||
#[test]
|
||||
fn resolving_body_changes_keeps_a_footnote_caret() {
|
||||
for command in ["changes.accept", "changes.acceptAll"] {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({})).unwrap();
|
||||
let sid = s.execute("frame.create", &json!({"rect": [72, 72, 400, 200], "content": "text", "text": "abcd"})).unwrap()["story"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
s.execute("text.select", &json!({"story": sid, "anchor": 4, "focus": 4})).unwrap();
|
||||
s.execute("footnote.insert", &json!({"text": "Footnote text beyond body"})).unwrap();
|
||||
let before = s.doc().unwrap().selection.text.unwrap();
|
||||
s.edit(|d, _| {
|
||||
d.story_mut(designcraft_doc::StoryId(sid))
|
||||
.unwrap()
|
||||
.format_chars(0..1, |f| f.over.change = Some(designcraft_doc::ChangeMark::Deleted));
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let params = if command.ends_with("All") { json!({"story": sid}) } else { json!({"story": sid, "start": 0}) };
|
||||
s.execute(command, ¶ms).unwrap();
|
||||
assert_eq!(s.doc().unwrap().selection.text.unwrap(), before, "{command}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user