makemd icon indicating copy to clipboard operation
makemd copied to clipboard

Bug(formula): prop function doesn't detect type of formula fields

Open texastoland opened this issue 8 months ago • 0 comments

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.

texastoland avatar Apr 02 '25 05:04 texastoland