makemd
makemd copied to clipboard
Bug(formula): prop function doesn't detect type of formula fields
Problem
I tried to add number-type formula fields but they were concatenated as strings.
Cause
prop always reads formulas as type fileprop:
https://github.com/Make-md/makemd/blob/10df20706990e77c0180bbfa2488b1ec51910844/src/core/utils/formula/formulas.ts#L814-L823
Instead of parsing it from JSON:
https://github.com/Make-md/makemd/blob/10df20706990e77c0180bbfa2488b1ec51910844/src/core/schemas/parseFieldValue.ts#L36-L42
Solution
You already expose an API to extract types from properties:
https://github.com/Make-md/makemd/blob/10df20706990e77c0180bbfa2488b1ec51910844/src/schemas/mdb.ts#L25-L28
I propose the following fix:
-const type = scope.get('$properties')?.[res[0]]?.type;
+const type = fieldTypeForField(scope.get('$properties'));
Related
I suspect this is similar or the same as #452.