mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-26 00:28:11 +08:00
Move NumberInput.svelte input processing from JS to Rust (#4274)
* Move NumberInput.svelte input processing from JS to Rust * Fix edge cases
This commit is contained in:
@@ -979,22 +979,3 @@ impl EditorWrapper {
|
||||
self.dispatch(message);
|
||||
}
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// Static functions callable from JavaScript without an Editor instance
|
||||
// ====================================================================
|
||||
|
||||
#[wasm_bindgen(js_name = evaluateMathExpression)]
|
||||
pub fn evaluate_math_expression(expression: &str) -> Option<f64> {
|
||||
let value = math_parser::evaluate(expression)
|
||||
.inspect_err(|err| error!("Math parser error on \"{expression}\": {err}"))
|
||||
.ok()?
|
||||
.0
|
||||
.inspect_err(|err| error!("Math evaluate error on \"{expression}\": {err} "))
|
||||
.ok()?;
|
||||
let Some(real) = value.as_real() else {
|
||||
error!("{value} was not a real; skipping.");
|
||||
return None;
|
||||
};
|
||||
Some(real)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user