Validate supplied Figma SVG clipboard geometry

This commit is contained in:
Dandaedre 2026-11-15 17:05:14 +01:00
parent dfa3fa7ee4
commit f3d00009c3
6 changed files with 51 additions and 1 deletions

View File

@ -0,0 +1,11 @@
# Figma SVG clipboard sample
Supplied by the user on 2026-11-15 as Figma clipboard text. The fixture removes
chat Markdown escaping before XML tags and restores the Markdown-linked namespace
to the literal `http://www.w3.org/2000/svg`. Geometry and element order are unchanged.
The Figma version, platform and exact copy command were not supplied.
Expected result: two 640 × 360 rectangles, at (0, 0) and (1040, 0), in a
1680 × 360 SVG viewport. Neither rectangle is a background. This validates SVG
text through the paste parser, not Figma's native binary/HTML clipboard formats
or live operating-system clipboard delivery.

View File

@ -0,0 +1 @@
<svg width="1680" height="360" viewBox="0 0 1680 360" fill="none" xmlns="http://www.w3.org/2000/svg"><g><path transform="matrix(1 0 0 1 0 0)" d="M0 0L640 0L640 360L0 360Z" fill="#D9D9D9"/></g><g><path transform="matrix(1 0 0 1 1040 0)" d="M0 0L640 0L640 360L0 360Z" fill="#D9D9D9"/></g></svg>

After

Width:  |  Height:  |  Size: 293 B

View File

@ -9,6 +9,28 @@ fn close(a: f64, b: f64) {
assert!((a - b).abs() < 1e-7, "{a} != {b}");
}
#[test]
fn supplied_figma_svg_clipboard_preserves_rectangle_order_and_translation() {
let doc = parse_values(include_str!("fixtures/figma-rectangles.svg")).unwrap();
assert!(doc.svg);
assert_eq!(doc.shapes.len(), 2);
for (shape, x) in doc.shapes.iter().zip([0.0, 1040.0]) {
let expected = Geometry {
x,
y: 0.0,
width: 640.0,
height: 360.0,
};
assert_eq!(shape.geometry, expected);
assert!(!shape.background);
assert!(!shape.background_only);
assert_eq!(shape.outline, [0.0, 0.0]);
assert_eq!(
shape.paste_geometry(expected, true, true).unwrap(),
expected
);
}
}
#[test]
fn svg_detects_rectangles_background_names_transforms_and_outlines() {
let doc=parse_svg(&svg(r#"<rect id="background" width="100%" height="100%" fill="black"/><g transform="translate(12 20) scale(2 3)" stroke="white" stroke-width="4"><rect id="presenter" x="10" y="30" width="100" height="50"/><rect id="slides" x="150" y="30" width="100" height="50"/></g>"#)).unwrap();
assert_eq!(doc.shapes.len(), 3);

View File

@ -4,6 +4,11 @@
## Unreleased
- Preserve the supplied Figma SVG clipboard sample as a regression fixture for
ordered rectangular paths and matrix translations through the paste parser.
Existing SVG parsing handles it; native Figma clipboard formats and live
clipboard delivery remain unverified.
- Add a sourced presentation-switcher adapter survey, ranked by public control
documentation with separate geometry feasibility assessments, and a stretch
goal to consider selected families. Research only; no new support is enabled.

View File

@ -67,6 +67,15 @@ styles for predictable results. Files are limited to 16 MiB, 256 rectangles plus
64 levels of nesting. SVG imports retain the same outline and position-only
choices as draw.io imports.
### Figma SVG clipboard text
The supplied [Figma SVG sample](../../../crates/canvas-pilot/tests/fixtures/figma-rectangles.svg)
works through the existing SVG/value paste parser: two 640 × 360 rectangular
paths at (0, 0) and (1040, 0), including their matrix translations and order.
Paste SVG text and review the detected shapes in the mapping dialog.
This evidence covers the supplied SVG text only; native Figma binary/HTML
clipboard formats and live clipboard delivery have not been validated.
### draw.io clipboard
The draw.io adapter accepts single-page `.drawio`/`.xml` files (including native

View File

@ -73,7 +73,9 @@ device readback and physical-screen acceptance.
and direct linked send/load are implemented; further changes await specifications.
- [ ] **Additional native clipboard adapters.** Obtain actual software/version
clipboard samples before implementing or claiming Inkscape, Illustrator, Figma,
etc. clipboard support. File import is not native clipboard compatibility.
etc. native clipboard support. The supplied Figma SVG-text sample is covered
by a paste-parser regression test; native clipboard formats and live delivery
remain unverified. File import is not native clipboard compatibility.
- [ ] **Non-Centered/masked Midra layer import.** Expand conversion only after
verifying those semantics. Source routing synchronization remains separate
from the opt-in shared-input settings editor.