Add direct diagram connections, movable ports, and contextual authoring
This commit is contained in:
@@ -64,6 +64,7 @@ impl Draft {
|
||||
.values()
|
||||
.find_map(|d| d.nodes.get(&selected).map(|n| (d.id, n)))?;
|
||||
let mut value = json!(node);
|
||||
value["port_anchors"] = json!(node.port_anchors);
|
||||
value["diagram"] = json!(diagram);
|
||||
(RecordKind::Node(diagram), value)
|
||||
};
|
||||
@@ -222,6 +223,8 @@ impl Draft {
|
||||
json!({"edge": Id::nil(), "waypoints": [], "label": null})
|
||||
} else if path.ends_with("waypoints") {
|
||||
json!({"x": 0.0, "y": 0.0})
|
||||
} else if path.ends_with("port_anchors") {
|
||||
json!({"port": Id::nil(), "side": "Right", "offset": 0.5})
|
||||
} else {
|
||||
json!(Id::nil())
|
||||
}),
|
||||
@@ -387,6 +390,7 @@ fn reference(path: &str) -> bool {
|
||||
| "represented"
|
||||
| "exchange"
|
||||
| "edge"
|
||||
| "port"
|
||||
| "sender"
|
||||
| "receiver"
|
||||
| "action"
|
||||
@@ -516,6 +520,17 @@ fn reference_choices(draft: &Draft, project: &Project, path: &str, current: Id)
|
||||
|
||||
fn reference_ids(draft: &Draft, project: &Project, path: &str) -> Vec<Id> {
|
||||
let value = draft.materialize().unwrap_or_else(|_| draft.value.clone());
|
||||
if path.starts_with("/port_anchors/") && path.ends_with("/port") {
|
||||
let owner = value
|
||||
.get("element")
|
||||
.and_then(|id| serde_json::from_value::<Id>(id.clone()).ok());
|
||||
return project
|
||||
.elements
|
||||
.values()
|
||||
.filter(|e| e.kind() == Kind::Port && e.parent == owner)
|
||||
.map(|e| e.id)
|
||||
.collect();
|
||||
}
|
||||
let element = (draft.kind == RecordKind::Element)
|
||||
.then(|| serde_json::from_value::<Element>(value.clone()).ok())
|
||||
.flatten()
|
||||
@@ -999,6 +1014,7 @@ fn unit_body(path: &str, value: &Value) -> bool {
|
||||
fn variants(path: &str, value: &Value, kind: RecordKind) -> Vec<(String, Value)> {
|
||||
let field = path.rsplit('/').next().unwrap_or_default();
|
||||
let words: &[&str] = match field {
|
||||
"side" if path.starts_with("/port_anchors/") => &["Left", "Right", "Top", "Bottom"],
|
||||
"layer" => &["Oa", "Sa"],
|
||||
"projection" => &[
|
||||
"Overview",
|
||||
|
||||
Reference in New Issue
Block a user