mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-13 09:20:56 -06:00
.ai import: open the variable library and data sets from the editing data
Squashed from #5156 onto main.
This commit is contained in:
@@ -140,8 +140,11 @@ fn names_param(p: &Value, cmd: &str, fallback: Option<String>, nothing: &str) ->
|
||||
|
||||
/// Refuse what a variable of `kind` can't be bound to: art that is locked, on a hidden or locked
|
||||
/// layer, or on a locked artboard; a text variable only drives type; an image variable only drives
|
||||
/// an image object.
|
||||
/// an image object; a variable of unknown kind drives nothing.
|
||||
fn check_bindable(doc: &vectorcraft_doc::Document, ids: &[NodeId], kind: VariableKind, cmd: &str) -> Result<()> {
|
||||
if kind == VariableKind::Unknown {
|
||||
return Err(bad(cmd, "a variable of unknown kind can't be bound to objects"));
|
||||
}
|
||||
let locks = doc.locked_artboards();
|
||||
for id in ids {
|
||||
match doc.node(*id) {
|
||||
@@ -189,6 +192,7 @@ fn dataset_value(cmd: &str, var: &str, kind: VariableKind, v: &Value) -> Result<
|
||||
.map(str::trim)
|
||||
.filter(|t| !t.is_empty())
|
||||
.and_then(|t| if t.len() > MAX_GRAPH_CSV { None } else { Some(DataValue::Graph(t.to_string())) }),
|
||||
VariableKind::Unknown => None,
|
||||
}
|
||||
.ok_or_else(|| bad(cmd, format!("value for `{var}` must match its variable kind")))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user