mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-31 07:39:20 +00:00
M12: a connector end on any part of an object with Cmd/Ctrl (#1733)
This commit is contained in:
1 parent
6bf38fa963
commit
12e9b409ed
22 files changed
+257
-54
No files matched your search
+2
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
**Stage: alpha** · next: beta, ~26 points and ~162–292 h away (one Opus 5.5 agent; ~33–67 h wall-clock with 5 agents)
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated status items removed, and `cargo xtask docs` (in `ci`) fails on a repeated table row or status item; a name typed for a variabLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated statusLine truncated
|
||||
|
||||
FigCraft is a clean-room, open-source, pure-Rust reimplementation of the Figma design workflow,
|
||||
native on macOS, Windows, Linux and FreeBSD and in the browser, fully drivable by agents through
|
||||
@@ -358,6 +358,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md).
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged |
|
||||
| 2026-10-31 | patch | M11: a trackpad or touch tap sends its press and release in one frame, so a plugin panel's field committed in the frame its button was clicked and the value was lost: the Counter's Set count… kept the old count. The plugin now gets both, the field's value first. The `window.figcraft` docs name `screenshot`'s `data`. Numbers unchanged |
|
||||
| 2026-10-31 | patch | M4: Dash and Custom strokes have a Dash cap (None, Round, Square) in the advanced stroke settings and `node.set {dashCap}`, on both ends of every dash on the canvas and in PNG, PDF and SVG. Unset, dashes keep taking the end point caps, so older files look the same; the saved file writes it only when set. Numbers unchanged |
|
||||
| 2026-10-31 | minor | M3, gap 10: library analytics cover styles and variables. A file reports how many of its layers use each of a library's styles and variables, and Show usage (`library.usage`) lists them beside the components, by a Type choice, with their layers and files. Layers inside instances count for their component. Insertions, detachments and modes aren't counted for them yet. Numbers unchanged. Tests: `library_assets_tests`. |
|
||||
|
||||
@@ -25,7 +25,7 @@ fn a_boards_kind_and_its_objects_metadata_sync() {
|
||||
let mut edited = host.document().clone();
|
||||
let c = edited.create(page, NodeKind::Vector { network: Default::default() }, "Connector", 0.0, 0.0, 1.0, 1.0).unwrap();
|
||||
edited.node_mut(c).unwrap().board = Some(BoardItem::Connector(Connector {
|
||||
from: End::Node { node: a, side: Side::Auto },
|
||||
from: End::Node { node: a, side: Side::Auto, at: None },
|
||||
to: End::Point { x: 5.0, y: 5.0 },
|
||||
routing: Routing::Elbow,
|
||||
path: None,
|
||||
@@ -34,7 +34,7 @@ fn a_boards_kind_and_its_objects_metadata_sync() {
|
||||
r.apply(&diff(&host, &edited).unwrap().changes, Mode::Strict).unwrap();
|
||||
let mut moved = r.document().clone();
|
||||
moved.node_mut(c).unwrap().board = Some(BoardItem::Connector(Connector {
|
||||
from: End::Node { node: a, side: Side::Top },
|
||||
from: End::Node { node: a, side: Side::Top, at: None },
|
||||
to: End::Point { x: 9.0, y: 1.0 },
|
||||
routing: Routing::Straight,
|
||||
path: None,
|
||||
|
||||
@@ -577,6 +577,9 @@ pub enum End {
|
||||
node: NodeId,
|
||||
#[serde(default)]
|
||||
side: Side,
|
||||
/// Where on the layer it sits by hand, as fractions of its box (`None`: on its side).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
at: Option<[f64; 2]>,
|
||||
},
|
||||
Point {
|
||||
x: f64,
|
||||
|
||||
@@ -12,12 +12,14 @@ use crate::{ConnectorPath, Routing, Side};
|
||||
pub enum RouteEnd {
|
||||
Point(Point),
|
||||
Box(Rect, Side),
|
||||
/// A point on the object in the box, placed by hand, with the side the route leaves by.
|
||||
On(Rect, Side, Point),
|
||||
}
|
||||
|
||||
impl RouteEnd {
|
||||
fn centre(self) -> Point {
|
||||
match self {
|
||||
RouteEnd::Point(p) => p,
|
||||
RouteEnd::Point(p) | RouteEnd::On(_, _, p) => p,
|
||||
RouteEnd::Box(b, _) => b.center(),
|
||||
}
|
||||
}
|
||||
@@ -166,22 +168,26 @@ fn attach(e: RouteEnd, other: Point) -> (Point, Option<Side>) {
|
||||
match e {
|
||||
RouteEnd::Point(p) => (p, None),
|
||||
RouteEnd::Box(b, side) => {
|
||||
let side = match side {
|
||||
Side::Auto => {
|
||||
let d = other - b.center();
|
||||
// Compare against the box's proportions: a wide box takes the sides more.
|
||||
if d.x.abs() * b.height().max(1e-9) >= d.y.abs() * b.width().max(1e-9) {
|
||||
if d.x >= 0.0 { Side::Right } else { Side::Left }
|
||||
} else if d.y >= 0.0 {
|
||||
Side::Bottom
|
||||
} else {
|
||||
Side::Top
|
||||
}
|
||||
}
|
||||
s => s,
|
||||
};
|
||||
let side = named_or_facing(b, side, other);
|
||||
(side.point(b), Some(side))
|
||||
}
|
||||
RouteEnd::On(b, side, p) => (p, Some(named_or_facing(b, side, other))),
|
||||
}
|
||||
}
|
||||
|
||||
/// `side`, or for [`Side::Auto`] the side of `b` facing `other`.
|
||||
fn named_or_facing(b: Rect, side: Side, other: Point) -> Side {
|
||||
if side != Side::Auto {
|
||||
return side;
|
||||
}
|
||||
let d = other - b.center();
|
||||
// Compare against the box's proportions: a wide box takes the sides more.
|
||||
if d.x.abs() * b.height().max(1e-9) >= d.y.abs() * b.width().max(1e-9) {
|
||||
if d.x >= 0.0 { Side::Right } else { Side::Left }
|
||||
} else if d.y >= 0.0 {
|
||||
Side::Bottom
|
||||
} else {
|
||||
Side::Top
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ fn a_shape_gets_the_next_one_joined_on_each_side() {
|
||||
assert!(matches!(nb.board, Some(BoardItem::Shape { shape: BoardShape::Diamond })), "{side}: the same shape");
|
||||
assert_eq!(colour(&s, b), colour(&s, a), "{side}: the same colour");
|
||||
let k = connector(&s, c);
|
||||
assert_eq!((k.from, k.to), (End::Node { node: a, side: ends.0 }, End::Node { node: b, side: ends.1 }), "{side}");
|
||||
assert_eq!((k.from, k.to), (End::Node { node: a, side: ends.0, at: None }, End::Node { node: b, side: ends.1, at: None }), "{side}");
|
||||
assert_eq!(k.routing, s.tool.board.routing, "{side}: as the connector tool makes one");
|
||||
assert_eq!(s.selection(), vec![b], "{side}: the new one is selected");
|
||||
}
|
||||
@@ -93,7 +93,7 @@ fn the_next_sticky_shortcut_joins_the_next_shape_and_leaves_stickies_as_they_wer
|
||||
let (b, c) = (id(&r, "id"), id(&r, "connector"));
|
||||
assert!(matches!(node(&s, b).board, Some(BoardItem::Shape { shape: BoardShape::Rectangle })));
|
||||
assert_eq!(at(&s, b), (200.0 + CONNECTED_GAP, 0.0));
|
||||
assert_eq!(connector(&s, c).from, End::Node { node: a, side: Side::Right });
|
||||
assert_eq!(connector(&s, c).from, End::Node { node: a, side: Side::Right, at: None });
|
||||
assert_eq!(s.ds().unwrap().history.undo.len(), undo + 1, "one undo step");
|
||||
// Another side, as the command takes one.
|
||||
let r = s.execute("board.nextSticky", &json!({"id": a, "side": "below"})).unwrap();
|
||||
|
||||
@@ -25,7 +25,7 @@ fn three() -> (Session, [figcraft_doc::NodeId; 4]) {
|
||||
fn reattach_moves_one_end_and_undoes() {
|
||||
let (mut s, [a, b, c, k]) = three();
|
||||
s.execute("board.reattach", &json!({"id": k, "end": "to", "target": c, "side": "top"})).unwrap();
|
||||
assert_eq!(connector(&s, k).to, End::Node { node: c, side: Side::Top });
|
||||
assert_eq!(connector(&s, k).to, End::Node { node: c, side: Side::Top, at: None });
|
||||
assert_eq!(connector(&s, k).from.node(), Some(a));
|
||||
assert!(near(*drawn(&s, k).last().unwrap(), Point::new(650.0, 0.0)), "arrives on c's top: {:?}", drawn(&s, k));
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
@@ -257,7 +257,7 @@ fn an_end_dropped_along_a_side_attaches_to_that_side() {
|
||||
let want = (side != Side::Auto).then(|| side.point(bounds)).map(|p| [p.x, p.y]);
|
||||
assert_eq!(lit, want.into_iter().collect::<Vec<_>>(), "{drop:?}");
|
||||
s.pointer(&ev(PointerKind::Up, drop)).unwrap();
|
||||
assert_eq!(connector(&s, k).from, End::Node { node: a, side }, "{drop:?}");
|
||||
assert_eq!(connector(&s, k).from, End::Node { node: a, side, at: None }, "{drop:?}");
|
||||
if side != Side::Auto {
|
||||
assert_eq!(drawn(&s, k)[0], side.point(bounds), "the route leaves from that side");
|
||||
}
|
||||
@@ -277,7 +277,10 @@ fn the_connector_tool_takes_the_side_it_starts_and_ends_on() {
|
||||
s.pointer(&ev(PointerKind::Move, 590.0, 330.0)).unwrap();
|
||||
s.pointer(&ev(PointerKind::Up, 590.0, 330.0)).unwrap();
|
||||
let k = the_connector(&s).unwrap().id;
|
||||
assert_eq!((connector(&s, k).from, connector(&s, k).to), (End::Node { node: a, side: Side::Bottom }, End::Node { node: b, side: Side::Right }));
|
||||
assert_eq!(
|
||||
(connector(&s, k).from, connector(&s, k).to),
|
||||
(End::Node { node: a, side: Side::Bottom, at: None }, End::Node { node: b, side: Side::Right, at: None })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -300,6 +303,9 @@ fn a_connector_end_snaps_to_the_attach_point_under_the_pointer() {
|
||||
s.pointer(&ev(PointerKind::Move, 352.0, 204.0)).unwrap();
|
||||
s.pointer(&ev(PointerKind::Up, 352.0, 204.0)).unwrap();
|
||||
let k = the_connector(&s).unwrap().id;
|
||||
assert_eq!((connector(&s, k).from, connector(&s, k).to), (End::Node { node: a, side: Side::Right }, End::Node { node: b, side: Side::Top }));
|
||||
assert_eq!(
|
||||
(connector(&s, k).from, connector(&s, k).to),
|
||||
(End::Node { node: a, side: Side::Right, at: None }, End::Node { node: b, side: Side::Top, at: None })
|
||||
);
|
||||
assert_eq!(drawn(&s, k), vec![Point::new(100.0, 50.0), Point::new(350.0, 200.0)]);
|
||||
}
|
||||
@@ -71,8 +71,8 @@ fn a_reshaped_connector_keeps_the_sides_it_left_by() {
|
||||
let (portion, at) = handles[handles.len() / 2];
|
||||
reshape(&mut s, k, portion as f64, at.x + 30.0, at.y + 30.0).unwrap();
|
||||
let c = connector(&s, k);
|
||||
assert!(matches!(c.from, End::Node { node, side } if node == a && side != Side::Auto), "{c:?}");
|
||||
assert!(matches!(c.to, End::Node { node, side } if node == b && side != Side::Auto), "{c:?}");
|
||||
assert!(matches!(c.from, End::Node { node, side, .. } if node == a && side != Side::Auto), "{c:?}");
|
||||
assert!(matches!(c.to, End::Node { node, side, .. } if node == b && side != Side::Auto), "{c:?}");
|
||||
}
|
||||
|
||||
/// "For the start and end portions of a connector, dragging can add an extra portion to the path."
|
||||
|
||||
@@ -201,7 +201,12 @@ fn connectors_follow_what_they_join_and_undo_with_it() {
|
||||
fn routes_are_the_same_for_the_same_document() {
|
||||
let mut s = board();
|
||||
let a = id(&s.execute("board.shape", &json!({"x": 0, "y": 0})).unwrap(), "id");
|
||||
let c = Connector { from: End::Node { node: a, side: Side::Bottom }, to: End::Point { x: 300.0, y: 500.0 }, routing: Routing::Elbow, path: None };
|
||||
let c = Connector {
|
||||
from: End::Node { node: a, side: Side::Bottom, at: None },
|
||||
to: End::Point { x: 300.0, y: 500.0 },
|
||||
routing: Routing::Elbow,
|
||||
path: None,
|
||||
};
|
||||
let doc = s.doc().unwrap();
|
||||
let r = route(doc, &c).unwrap();
|
||||
assert_eq!(r, route(&doc.clone(), &c).unwrap());
|
||||
|
||||
@@ -97,7 +97,7 @@ fn routes_take_named_sides_and_free_points() {
|
||||
let b = id(&s.execute("board.shape", &json!({"x": 300, "y": 300, "width": 100, "height": 100})).unwrap(), "id");
|
||||
let doc = s.doc().unwrap();
|
||||
let elbow = |from, to| route(doc, &figcraft_doc::Connector { from, to, routing: figcraft_doc::Routing::Elbow, path: None }).unwrap();
|
||||
let side = |n, side| End::Node { node: n, side };
|
||||
let side = |n, side| End::Node { node: n, side, at: None };
|
||||
let p = |x, y| End::Point { x, y };
|
||||
let pt = Point::new;
|
||||
// Side to side: out, across halfway, in.
|
||||
|
||||
@@ -128,14 +128,14 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
spec!(
|
||||
"board.connector",
|
||||
"Connector",
|
||||
"{from, to (each a layer id or {x, y} on the page), fromSide?, toSide? (auto|top|right|bottom|left), style?: straight|elbow|curved, startCap?, endCap? (none|lineArrow|triangleArrow|circleFilled|diamondFilled…; default an arrow at the end), label?} → {id, label?} a line that follows the layers it joins",
|
||||
"{from, to (each a layer id or {x, y} on the page), fromSide?, toSide? (auto|top|right|bottom|left), fromAt?, toAt? ([x, y] on the layer, fractions of its box), style?: straight|elbow|curved, startCap?, endCap? (none|lineArrow|triangleArrow|circleFilled|diamondFilled…; default an arrow at the end), label?} → {id, label?} a line that follows the layers it joins",
|
||||
true,
|
||||
connector_cmd
|
||||
),
|
||||
spec!(
|
||||
"board.reattach",
|
||||
"Reattach connector",
|
||||
"{id? (a connector; default the selection), end: from|to, target (a layer id, or {x, y} on the page to leave the end free), side? (auto|top|right|bottom|left)} → {id} moves one end of a connector",
|
||||
"{id? (a connector; default the selection), end: from|to, target (a layer id, or {x, y} on the page to leave the end free), side? (auto|top|right|bottom|left), at? ([x, y] on the layer, fractions of its box)} → {id} moves one end of a connector",
|
||||
true,
|
||||
reattach
|
||||
),
|
||||
|
||||
@@ -6,8 +6,21 @@ use super::{
|
||||
VectorNetwork, bad, cap_of, get, id_of, json, num, req_targets, require, routing_of, string,
|
||||
};
|
||||
|
||||
/// One connector end from the params: a layer on this page, or a point.
|
||||
fn end_param(cmd: &str, s: &Session, p: &Value, key: &str, side_key: &str) -> Result<End> {
|
||||
/// Where on a layer a connector end sits, from the params: `[x, y]`, fractions of its box.
|
||||
fn at_param(cmd: &str, p: &Value, key: &str) -> Result<Option<[f64; 2]>> {
|
||||
let Some(v) = get(p, key).filter(|v| !v.is_null()) else { return Ok(None) };
|
||||
match v.as_array().map(Vec::as_slice) {
|
||||
Some([x, y]) => match (x.as_f64().filter(|x| x.is_finite()), y.as_f64().filter(|y| y.is_finite())) {
|
||||
(Some(x), Some(y)) => Ok(Some([x.clamp(0.0, 1.0), y.clamp(0.0, 1.0)])),
|
||||
_ => Err(bad(cmd, format!("`{key}` is [x, y], fractions of the layer's box"))),
|
||||
},
|
||||
_ => Err(bad(cmd, format!("`{key}` is [x, y], fractions of the layer's box"))),
|
||||
}
|
||||
}
|
||||
|
||||
/// One connector end from the params (`keys`: its target, side and place on the layer): a layer on
|
||||
/// this page, or a point.
|
||||
fn end_param(cmd: &str, s: &Session, p: &Value, [key, side_key, at_key]: [&str; 3]) -> Result<End> {
|
||||
let side = match string(p, side_key) {
|
||||
Some(v) => Side::from_id(&v).ok_or_else(|| bad(cmd, format!("`{side_key}` is auto, top, right, bottom or left")))?,
|
||||
None => Side::Auto,
|
||||
@@ -30,7 +43,7 @@ fn end_param(cmd: &str, s: &Session, p: &Value, key: &str, side_key: &str) -> Re
|
||||
if matches!(n.board, Some(BoardItem::Connector(_))) {
|
||||
return Err(bad(cmd, format!("`{key}` can't be another connector")));
|
||||
}
|
||||
Ok(End::Node { node, side })
|
||||
Ok(End::Node { node, side, at: at_param(cmd, p, at_key)? })
|
||||
}
|
||||
None => Err(bad(cmd, format!("`{key}` is required"))),
|
||||
}
|
||||
@@ -39,8 +52,8 @@ fn end_param(cmd: &str, s: &Session, p: &Value, key: &str, side_key: &str) -> Re
|
||||
pub(super) fn connector_cmd(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "board.connector";
|
||||
require(s, cmd)?;
|
||||
let from = end_param(cmd, s, p, "from", "fromSide")?;
|
||||
let to = end_param(cmd, s, p, "to", "toSide")?;
|
||||
let from = end_param(cmd, s, p, ["from", "fromSide", "fromAt"])?;
|
||||
let to = end_param(cmd, s, p, ["to", "toSide", "toAt"])?;
|
||||
if from.node().is_some() && from.node() == to.node() {
|
||||
return Err(bad(cmd, "connect two different layers"));
|
||||
}
|
||||
@@ -106,7 +119,7 @@ pub(super) fn reattach(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Some("to") => false,
|
||||
_ => return Err(bad(cmd, "`end` is from or to")),
|
||||
};
|
||||
let end = end_param(cmd, s, p, "target", "side")?;
|
||||
let end = end_param(cmd, s, p, ["target", "side", "at"])?;
|
||||
let other = if from { c.to } else { c.from };
|
||||
if end.node().is_some() && end.node() == other.node() {
|
||||
return Err(bad(cmd, "connect two different layers"));
|
||||
@@ -141,6 +154,14 @@ pub(super) fn side_json(e: End) -> Value {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a connector end sits on its layer, as the commands take it.
|
||||
pub(super) fn at_json(e: End) -> Value {
|
||||
match e {
|
||||
End::Node { at: Some(at), .. } => json!(at),
|
||||
_ => Value::Null,
|
||||
}
|
||||
}
|
||||
|
||||
/// The end of connector `id` that stays while its other one (`from`: its start) is dragged.
|
||||
pub(super) fn other_end(doc: &Document, id: NodeId, from: bool) -> Option<End> {
|
||||
match &doc.node(id)?.board {
|
||||
|
||||
@@ -297,7 +297,10 @@ pub fn route(doc: &Document, c: &Connector) -> Option<Vec<Point>> {
|
||||
pub(super) fn route_ends(doc: &Document, c: &Connector) -> Option<(RouteEnd, RouteEnd)> {
|
||||
let end = |e: &End| match e {
|
||||
End::Point { x, y } => Some(RouteEnd::Point(Point::new(*x, *y))),
|
||||
End::Node { node, side } => doc.world_bounds(*node).map(|b| RouteEnd::Box(b, *side)),
|
||||
End::Node { node, side, at } => doc.world_bounds(*node).map(|b| match at {
|
||||
Some([x, y]) => RouteEnd::On(b, *side, Point::new(b.x0 + x * b.width(), b.y0 + y * b.height())),
|
||||
None => RouteEnd::Box(b, *side),
|
||||
}),
|
||||
};
|
||||
Some((end(&c.from)?, end(&c.to)?))
|
||||
}
|
||||
@@ -232,7 +232,12 @@ pub(super) fn add_connected(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
None => make_sticky(doc, parent, to_at, "", color, &author)?,
|
||||
Some(shape) => make_shape(doc, parent, to_at, next, shape, "", color)?,
|
||||
};
|
||||
let connector = Connector { from: End::Node { node: from, side: from_side }, to: End::Node { node: id, side: to_side }, routing, path: None };
|
||||
let connector = Connector {
|
||||
from: End::Node { node: from, side: from_side, at: None },
|
||||
to: End::Node { node: id, side: to_side, at: None },
|
||||
routing,
|
||||
path: None,
|
||||
};
|
||||
let line = make(doc, page, connector, CAPS)?;
|
||||
s.set_selection(vec![id]);
|
||||
if boolean(p, "edit") == Some(true) {
|
||||
|
||||
@@ -16,7 +16,7 @@ const MIN_RUN_PX: f64 = 28.0;
|
||||
/// `end` with the side it leaves by named: a reshaped path holds only as long as its ends do.
|
||||
fn pinned(end: End, side: Option<Side>) -> End {
|
||||
match (end, side) {
|
||||
(End::Node { node, .. }, Some(side)) => End::Node { node, side },
|
||||
(End::Node { node, at, .. }, Some(side)) => End::Node { node, side, at },
|
||||
_ => end,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::connectors::{CAPS, end_json, make, other_end, side_json};
|
||||
use super::connectors::{CAPS, at_json, end_json, make, other_end, side_json};
|
||||
use super::derived::{ends_now, route};
|
||||
use super::edit::label_of;
|
||||
use super::items::edit_text;
|
||||
@@ -10,6 +10,11 @@ use super::{
|
||||
/// How near (screen pixels) the pointer must be to the middle of an object's side for a connector
|
||||
/// end to attach there, however small the object is on screen.
|
||||
const ATTACH_PX: f64 = 10.0;
|
||||
|
||||
/// Point `p` as fractions of box `b` (`None`: a box with no area).
|
||||
fn part_at(b: figcraft_geom::Rect, p: Point) -> Option<[f64; 2]> {
|
||||
(b.width() > 0.0 && b.height() > 0.0).then(|| [((p.x - b.x0) / b.width()).clamp(0.0, 1.0), ((p.y - b.y0) / b.height()).clamp(0.0, 1.0)])
|
||||
}
|
||||
/// The sides an object takes a connector end at (their middles are its attach points).
|
||||
const SIDES: [Side; 4] = [Side::Top, Side::Right, Side::Bottom, Side::Left];
|
||||
|
||||
@@ -92,7 +97,8 @@ impl Session {
|
||||
}
|
||||
|
||||
/// What a connector end at the pointer attaches to: the object there (at the side whose middle
|
||||
/// is within [`ATTACH_PX`], else the side [`side_at`] the pointer), or the point.
|
||||
/// is within [`ATTACH_PX`], else the side [`side_at`] the pointer; with Cmd/Ctrl held, right
|
||||
/// there), or the point.
|
||||
fn end_at(&self, ev: &PointerEvent) -> End {
|
||||
let zoom = ev.zoom.max(1e-6);
|
||||
let hit = (|| {
|
||||
@@ -109,7 +115,10 @@ impl Session {
|
||||
let far = |s: &Side| b.map(|b| (s.point(b) - ev.p()).hypot() * zoom).filter(|d| *d <= ATTACH_PX);
|
||||
let near = SIDES.iter().filter_map(|s| Some((*s, far(s)?))).min_by(|x, y| x.1.total_cmp(&y.1)).map(|(s, _)| s);
|
||||
let side = near.or(b.map(|b| side_at(b, ev.p()))).unwrap_or(Side::Auto);
|
||||
Some(End::Node { node: t, side })
|
||||
match b.and_then(|b| part_at(b, ev.p())).filter(|_| ev.cmd) {
|
||||
Some(at) => Some(End::Node { node: t, side: Side::Auto, at: Some(at) }),
|
||||
None => Some(End::Node { node: t, side, at: None }),
|
||||
}
|
||||
})();
|
||||
hit.unwrap_or(End::Point { x: ev.x, y: ev.y })
|
||||
}
|
||||
@@ -128,7 +137,7 @@ impl Session {
|
||||
/// (`at`, else its named side's) lit.
|
||||
fn show_attach(&mut self, end: Option<End>, at: Option<Point>) {
|
||||
let attach = match end {
|
||||
Some(End::Node { node, side }) => self.doc().ok().and_then(|d| d.world_bounds(node)).map(|b| {
|
||||
Some(End::Node { node, side, .. }) => self.doc().ok().and_then(|d| d.world_bounds(node)).map(|b| {
|
||||
let on = at.or_else(|| (side != Side::Auto).then(|| side.point(b)));
|
||||
SIDES.map(|s| s.point(b)).map(|p| ([p.x, p.y], on.is_some_and(|o| (o - p).hypot() < 1e-6))).to_vec()
|
||||
}),
|
||||
@@ -179,7 +188,8 @@ impl Session {
|
||||
self.cancel_interaction()?;
|
||||
let Some(to) = self.drag_end(ev, from, start) else { return Ok(()) };
|
||||
let style = self.tool.board.routing.id();
|
||||
let p = json!({"from": end_json(from), "fromSide": side_json(from), "to": end_json(to), "toSide": side_json(to), "style": style});
|
||||
let (from_at, to_at) = (at_json(from), at_json(to));
|
||||
let p = json!({"from": end_json(from), "fromSide": side_json(from), "fromAt": from_at, "to": end_json(to), "toSide": side_json(to), "toAt": to_at, "style": style});
|
||||
self.execute("board.connector", &p)?;
|
||||
self.board_placed();
|
||||
Ok(())
|
||||
@@ -214,7 +224,7 @@ impl Session {
|
||||
return Ok(());
|
||||
}
|
||||
let end = if from { "from" } else { "to" };
|
||||
self.execute("board.reattach", &json!({"id": id, "end": end, "target": end_json(target), "side": side_json(target)}))?;
|
||||
self.execute("board.reattach", &json!({"id": id, "end": end, "target": end_json(target), "side": side_json(target), "at": at_json(target)}))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
//! A connector end placed on any part of an object: holding Cmd/Ctrl while moving it puts it right
|
||||
//! where the pointer is, and it stays at that part of the object when the object moves or resizes.
|
||||
|
||||
use figcraft_doc::{End, NodeId, Side};
|
||||
use figcraft_geom::Point;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::Session;
|
||||
use crate::board_tests::{board, connector, drawn, id, near};
|
||||
use crate::tools::{PointerEvent, PointerKind};
|
||||
|
||||
/// A board with two 200 × 100 shapes and a straight connector between them: (a, b, connector).
|
||||
fn scene() -> (Session, NodeId, NodeId, NodeId) {
|
||||
let mut s = board();
|
||||
let mut shape = |x: f64| id(&s.execute("board.shape", &json!({"x": x, "y": 0, "width": 200, "height": 100})).unwrap(), "id");
|
||||
let (a, b) = (shape(0.0), shape(500.0));
|
||||
let k = id(&s.execute("board.connector", &json!({"from": a, "to": b, "style": "straight"})).unwrap(), "id");
|
||||
s.execute("select.set", &json!({"ids": [k]})).unwrap();
|
||||
(s, a, b, k)
|
||||
}
|
||||
|
||||
/// Drag the connector's end at `from` to `to`, with Cmd/Ctrl held or not.
|
||||
fn drag_end(s: &mut Session, from: Point, to: Point, cmd: bool) {
|
||||
let ev = |kind, p: Point| PointerEvent { cmd, ..PointerEvent::at(kind, p.x, p.y, 1.0) };
|
||||
s.pointer(&ev(PointerKind::Down, from)).unwrap();
|
||||
s.pointer(&ev(PointerKind::Move, Point::new(300.0, 300.0))).unwrap();
|
||||
s.pointer(&ev(PointerKind::Move, to)).unwrap();
|
||||
s.pointer(&ev(PointerKind::Up, to)).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cmd_puts_an_end_on_any_part_of_the_object() {
|
||||
let (mut s, _, b, k) = scene();
|
||||
let end = *drawn(&s, k).last().unwrap();
|
||||
drag_end(&mut s, end, Point::new(650.0, 25.0), true);
|
||||
assert_eq!(connector(&s, k).to, End::Node { node: b, side: Side::Auto, at: Some([0.75, 0.25]) });
|
||||
assert!(near(*drawn(&s, k).last().unwrap(), Point::new(650.0, 25.0)), "{:?}", drawn(&s, k));
|
||||
// It undoes as one step, back to the side.
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(connector(&s, k).to, End::Node { node: b, side: Side::Auto, at: None });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn without_cmd_an_end_keeps_snapping_to_a_side() {
|
||||
let (mut s, _, b, k) = scene();
|
||||
let end = *drawn(&s, k).last().unwrap();
|
||||
drag_end(&mut s, end, Point::new(650.0, 25.0), false);
|
||||
assert_eq!(connector(&s, k).to, End::Node { node: b, side: Side::Right, at: None });
|
||||
assert!(near(*drawn(&s, k).last().unwrap(), Point::new(700.0, 50.0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_end_stays_on_that_part_when_the_object_moves_or_resizes() {
|
||||
let (mut s, _, b, k) = scene();
|
||||
s.execute("board.reattach", &json!({"id": k, "end": "to", "target": b, "at": [0.5, 0.5]})).unwrap();
|
||||
assert!(near(*drawn(&s, k).last().unwrap(), Point::new(600.0, 50.0)));
|
||||
s.execute("node.set", &json!({"id": b, "props": {"x": 600, "y": 100, "width": 400, "height": 200}})).unwrap();
|
||||
assert!(near(*drawn(&s, k).last().unwrap(), Point::new(800.0, 200.0)), "{:?}", drawn(&s, k));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_end_moved_back_without_cmd_leaves_its_place() {
|
||||
let (mut s, _, b, k) = scene();
|
||||
s.execute("board.reattach", &json!({"id": k, "end": "to", "target": b, "at": [0.5, 0.5]})).unwrap();
|
||||
s.execute("board.reattach", &json!({"id": k, "end": "to", "target": b, "side": "top"})).unwrap();
|
||||
assert_eq!(connector(&s, k).to, End::Node { node: b, side: Side::Top, at: None });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_commands_take_a_place_and_refuse_junk() {
|
||||
let (mut s, a, b, _) = scene();
|
||||
let k = id(&s.execute("board.connector", &json!({"from": a, "to": b, "fromAt": [0.25, 0.5], "toAt": [9, -1]})).unwrap(), "id");
|
||||
assert!(matches!(connector(&s, k).from, End::Node { at: Some([0.25, 0.5]), .. }));
|
||||
assert!(matches!(connector(&s, k).to, End::Node { at: Some([1.0, 0.0]), .. }), "kept on the object");
|
||||
for junk in [json!("middle"), json!([1]), json!([1, 2, 3]), json!(["x", 0]), json!({"x": 0, "y": 0})] {
|
||||
assert!(s.execute("board.reattach", &json!({"id": k, "end": "to", "target": b, "at": junk})).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_reshaped_path_keeps_the_end_where_it_is() {
|
||||
let (mut s, a, b, _) = scene();
|
||||
let k = id(&s.execute("board.connector", &json!({"from": a, "to": b, "style": "curved", "toAt": [0.5, 0.5]})).unwrap(), "id");
|
||||
s.execute("board.reshape", &json!({"id": k, "portion": 0, "x": 350, "y": 200})).unwrap();
|
||||
assert!(matches!(connector(&s, k).to, End::Node { at: Some([0.5, 0.5]), .. }));
|
||||
assert!(near(*drawn(&s, k).last().unwrap(), Point::new(600.0, 50.0)), "{:?}", drawn(&s, k));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_saves_only_when_placed_by_hand() {
|
||||
let (mut s, _, b, k) = scene();
|
||||
let saved = |s: &Session| figcraft_format::to_json(s.doc().unwrap()).unwrap().to_string();
|
||||
assert!(!saved(&s).contains("\"at\":"), "older files stay as they are");
|
||||
s.execute("board.reattach", &json!({"id": k, "end": "to", "target": b, "at": [0.5, 0.25]})).unwrap();
|
||||
assert!(saved(&s).contains("\"at\":[0.5,0.25]"));
|
||||
let bytes = figcraft_format::save_bytes(s.doc().unwrap(), None).unwrap();
|
||||
let (open, _) = figcraft_format::load_bytes(&bytes).unwrap();
|
||||
let kept = open.node(k).and_then(|n| n.board.clone());
|
||||
assert!(matches!(kept, Some(figcraft_doc::BoardItem::Connector(c)) if matches!(c.to, End::Node { at: Some([0.5, 0.25]), .. })));
|
||||
}
|
||||
@@ -263,6 +263,8 @@ mod components_behaviour_tests;
|
||||
#[cfg(test)]
|
||||
mod components_scale_tests;
|
||||
#[cfg(test)]
|
||||
mod connector_anywhere_tests;
|
||||
#[cfg(test)]
|
||||
mod convert_container_tests;
|
||||
#[cfg(test)]
|
||||
mod cursor_tests;
|
||||
|
||||
@@ -87,7 +87,7 @@ impl<'a> Mapper<'a> {
|
||||
};
|
||||
let finite = |p: Point| p.x.is_finite() && p.y.is_finite();
|
||||
let ok = match end {
|
||||
RouteEnd::Point(p) => finite(p),
|
||||
RouteEnd::Point(p) | RouteEnd::On(_, _, p) => finite(p),
|
||||
RouteEnd::Box(b, _) => finite(b.origin()) && finite(Point::new(b.x1, b.y1)),
|
||||
};
|
||||
ok.then_some(end)
|
||||
|
||||
@@ -234,8 +234,8 @@ fn the_next_shape_from_the_keyboard_comes_connected_and_goes_on_typing() {
|
||||
let b = figcraft_engine::board::owner_of_text(doc, te.id).unwrap();
|
||||
assert!(matches!(doc.node(b).unwrap().board, Some(BoardItem::Shape { shape: BoardShape::Diamond })));
|
||||
let joined = doc.nodes().any(|n| {
|
||||
matches!(&n.board, Some(BoardItem::Connector(k)) if k.from == figcraft_doc::End::Node { node: a, side: figcraft_doc::Side::Right }
|
||||
&& k.to == figcraft_doc::End::Node { node: b, side: figcraft_doc::Side::Left })
|
||||
matches!(&n.board, Some(BoardItem::Connector(k)) if k.from == figcraft_doc::End::Node { node: a, side: figcraft_doc::Side::Right, at: None }
|
||||
&& k.to == figcraft_doc::End::Node { node: b, side: figcraft_doc::Side::Left, at: None })
|
||||
});
|
||||
assert!(joined, "a connector from the first shape's right side to the new one's left");
|
||||
}
|
||||
@@ -362,3 +362,39 @@ fn preferences_set_the_board_grid_and_the_default_dots_keep_their_size() {
|
||||
let shapes = flat(&u.frame_output(vec![]).shapes);
|
||||
assert!(has_text(&shapes, "Board grid") && !has_text(&shapes, "Spacing"));
|
||||
}
|
||||
|
||||
/// Moving a selected connector's end with the mouse: it snaps to a side, and with Cmd/Ctrl held it
|
||||
/// goes where the pointer is on the object.
|
||||
#[test]
|
||||
fn cmd_while_moving_a_connector_end_places_it_on_the_object() {
|
||||
let mut u = board();
|
||||
let a = id(&u.app.run("board.shape", json!({"shape": "rectangle", "x": 0, "y": 0, "width": 200, "height": 100})).unwrap());
|
||||
let b = id(&u.app.run("board.shape", json!({"shape": "rectangle", "x": 400, "y": 0, "width": 200, "height": 100})).unwrap());
|
||||
let k = id(&u.app.run("board.connector", json!({"from": a, "to": b, "style": "straight"})).unwrap());
|
||||
u.app.run("select.set", json!({"ids": [k]}));
|
||||
u.frame(vec![]);
|
||||
u.frame(vec![]);
|
||||
let end = |u: &Ui| match &u.app.session.doc().unwrap().node(k).unwrap().board {
|
||||
Some(BoardItem::Connector(c)) => c.to,
|
||||
other => panic!("{other:?}"),
|
||||
};
|
||||
let drag = |u: &mut Ui, mods: Modifiers| {
|
||||
let from = u.app.to_screen(400.0, 50.0);
|
||||
let to = u.app.to_screen(550.0, 25.0);
|
||||
u.frame_with(vec![Event::PointerMoved(from)], mods);
|
||||
let press = |pos, pressed| Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: mods };
|
||||
u.frame_with(vec![press(from, true)], mods);
|
||||
for t in 1..=8 {
|
||||
u.frame_with(vec![Event::PointerMoved(from + (to - from) * (t as f32 / 8.0))], mods);
|
||||
}
|
||||
u.frame_with(vec![press(to, false)], mods);
|
||||
u.frame_with(vec![], mods);
|
||||
};
|
||||
drag(&mut u, Modifiers::COMMAND);
|
||||
assert_eq!(end(&u), figcraft_doc::End::Node { node: b, side: figcraft_doc::Side::Auto, at: Some([0.75, 0.25]) });
|
||||
u.app.run("edit.undo", json!({}));
|
||||
u.app.run("select.set", json!({"ids": [k]}));
|
||||
u.frame(vec![]);
|
||||
drag(&mut u, Modifiers::NONE);
|
||||
assert!(matches!(end(&u), figcraft_doc::End::Node { at: None, side: figcraft_doc::Side::Right, .. }), "{:?}", end(&u));
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# Boards parity
|
||||
|
||||
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-10-30 · **Change:** minor (a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre)
|
||||
> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-10-31 · **Change:** minor (a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre)
|
||||
|
||||
**Breadth ~47%, ready ~29% (estimated, erring low).** A board is a FigCraft file of its own kind
|
||||
(`file.newBoard`) with a dot grid on the page, sticky notes, shapes with text, connectors that
|
||||
@@ -40,6 +40,7 @@ all end with the same geometry.
|
||||
| Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was |
|
||||
| Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before |
|
||||
| Curved connectors, elbows around objects, dragging an end to re-attach | done | `board.setStyle {style: curved}` (and the contextual bar): one curve leaving and arriving along the sides; an elbow whose short way would cross what it joins goes around their boxes, 24 units clear; a selected connector shows its two ends as handles, and dragging one onto an object attaches it there (the object is outlined while dragging), onto empty canvas leaves it free (`board.reattach {id, end, target, side?}`, one undo step) |
|
||||
| A connector end on any part of an object | done | holding Cmd/Ctrl while moving an end places it where the pointer is on the object, as a share of its box, so it follows moves and resizes; the line leaves by the side facing the other end. Without the key an end snaps to a side |
|
||||
| Connector paths reshaped by hand | done | a selected elbow or curved connector shows path handles: one on each run long enough to take one, one in the middle of a curve. Dragging a run moves it, and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins and is saved with the file; changing the style or moving an end to something else goes back to routing itself. No way back by itself otherwise: the public help describes none |
|
||||
| Quick-create handles (drag out a connected copy) | missing | |
|
||||
| Connector waypoints placed by hand | missing | routes are computed from the ends; no bend points of your own |
|
||||
@@ -69,6 +70,7 @@ all end with the same geometry.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged |
|
||||
| 2026-10-31 | patch | M12, #1708: a connector end dropped on the outer half of a shape takes the side it is towards, instead of only within 10 px of a side's middle, so a drop anywhere along an edge chooses that edge (dragging a selected connector's end and with the connector tool, ring included); a drop in the middle of a shape still takes the facing side. |
|
||||
| 2026-10-31 | minor | M12, #1710: a selected elbow or curved connector shows path handles. Dragging a run moves it and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins, is saved with the file, and goes back to routing itself when the style changes or an end moves to something else. |
|
||||
| 2026-10-31 | minor | M12: boards have 23 shapes with text instead of 7: triangle down, parallelogram right and left, trapezoid, pentagon, hexagon, octagon, star, plus, arrow left and right, and the flowchart symbols database, document, predefined process, manual input and internal storage. The toolbar flyout wraps into rows of eight and the selection bar's shape menu is a grid of outlines named on hover. The stale "Quick-create handles: missing" row now says what exists. |
|
||||
|
||||
+6
-4
@@ -483,17 +483,19 @@ one undo step and returns the ids it made:
|
||||
in the app does both).
|
||||
- `board.shape {shape, x, y, width?, height?, text?, color?, parent?}` → `{id, text}`: a shape with centred,
|
||||
wrapping text: `rectangle roundedRectangle ellipse diamond triangle triangleDown parallelogramRight parallelogramLeft trapezoid pentagon hexagon octagon star plus arrowLeft arrowRight chevron speechBubble database document predefinedProcess manualInput internalStorage`.
|
||||
- `board.connector {from, to, fromSide?, toSide?, style?: straight|elbow|curved, startCap?, endCap?, label?}`
|
||||
- `board.connector {from, to, fromSide?, toSide?, fromAt?, toAt?, style?: straight|elbow|curved, startCap?, endCap?, label?}`
|
||||
→ `{id, label?}`: `from`/`to` are layer ids or `{x, y}` page points; sides are `auto` (the side
|
||||
facing the other end) or `top right bottom left`; caps are stroke caps (default an arrow at the
|
||||
facing the other end) or `top right bottom left`; `fromAt`/`toAt` are `[x, y]` fractions of the
|
||||
layer's box that put the end on that part of it (it leaves by `side`); caps are stroke caps (default an arrow at the
|
||||
end). An elbow goes around the objects it joins when the short way would cross them; a curved
|
||||
one leaves and arrives along the sides. The connector re-routes itself whenever what it joins
|
||||
moves or resizes, also when someone else in a live session moves it; a deleted end stays where it
|
||||
was as a point. `board.label {id, text}` sets its label (empty removes it).
|
||||
- `board.reattach {id?, end: from|to, target, side?}` → `{id}`: moves one end of a connector
|
||||
- `board.reattach {id?, end: from|to, target, side?, at?}` → `{id}`: moves one end of a connector
|
||||
(default the selected one; its label stands for it) onto `target`, a layer id or an `{x, y}`
|
||||
page point where the end stays free. Refused when both ends would be on one layer or the target
|
||||
is a connector. Dragging a selected connector's end handle in the app does the same. A path
|
||||
is a connector. Dragging a selected connector's end handle in the app does the same; with Cmd/Ctrl
|
||||
held the end goes where the pointer is on the object (`at`, as in `board.connector`). A path
|
||||
reshaped by hand goes back to routing itself.
|
||||
- `board.reshape {id?, portion, x, y}` → `{id}`: moves one portion of a connector's path to that
|
||||
page point, as dragging a path handle in the app does: run `portion` of an elbow (a first or last
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
# FigCraft roadmap: milestones and what's next
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; compact layer trees with fields and outline (M0.9, part of #996); while a drag only moves a large selection, its outlines, box, slots, spacing and Design panel values are worked out once and shifted, not rebuilt on every move (#1571); an imported orLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-30 · **Change:** minor (a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; compact layer trees with fields and outline (M0.9, part of #996); while a drag only moves a large selection, its outlines, box, sLine truncated
|
||||
|
||||
Forward-looking plan. Where FigCraft stands today: [`ROADMAP.md`](../ROADMAP.md) and
|
||||
[`target-app-parity.md`](target-app-parity.md); the full ranked list: [`gaps.md`](gaps.md). Hours
|
||||
@@ -75,6 +75,7 @@ blockers.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged |
|
||||
| 2026-10-31 | patch | M11: a trackpad or touch tap sends its press and release in one frame, so a plugin panel's field committed in the frame its button was clicked and the value was lost: the Counter's Set count… kept the old count. The plugin now gets both, the field's value first. The `window.figcraft` docs name `screenshot`'s `data`. Numbers unchanged |
|
||||
| 2026-10-31 | patch | M4: Dash and Custom strokes have a Dash cap (None, Round, Square) in the advanced stroke settings and `node.set {dashCap}`, on both ends of every dash on the canvas and in PNG, PDF and SVG. Unset, dashes keep taking the end point caps, so older files look the same; the saved file writes it only when set. Numbers unchanged |
|
||||
| 2026-10-31 | minor | M3, gap 10: library analytics cover styles and variables. A file reports how many of its layers use each of a library's styles and variables, and Show usage (`library.usage`) lists them beside the components, by a Type choice, with their layers and files. Layers inside instances count for their component. Insertions, detachments and modes aren't counted for them yet. Numbers unchanged. Tests: `library_assets_tests`. |
|
||||
|
||||
Reference in new issue
Block a user