Word Count/Character Count in Editor Using Scripting (JS)

@Sebastian. Thanks for the same.

How do I round the value. Using the wordcount I wish to calculate the reading time of the article

None of these Work in Script Code (All give Javascript Errors) - Please can you refer me to the documentation where I can use basic math functions in script in Squidex

toInteger() :negative_squared_cross_mark:
ctx.data.time.en = toInteger(wordCount(html2Text(ctx.data.body.en))/200)

ctx.data.time.en = Math.round(wordCount(html2Text(ctx.data.body.en))/200)

ctx.data.time.en = round(wordCount(html2Text(ctx.data.body.en))/200)

ctx.data.time.en = stepUp(wordCount(html2Text(ctx.data.body.en))/200)

ctx.data.time.en = ceil(wordCount(html2Text(ctx.data.body.en))/200)

PS: I checked other online word/character counter with basic algos they seem to match your formulas
https://wordcounter.net/ and https://www.chineseconverter.com/en/convert/chinese-character-count

Can you post the exact error? Math is available,

here you can find a list of all functions: https://github.com/sebastienros/jint/blob/dev/Jint/Native/Math/MathInstance.cs#L34

But I recommend not to calculate it inside Squidex, because it is easier and faster to solve in the frontend.

1 Like

Can you create a feature request for the word count improvement?

Hi, I made a first attempt:

Can you have to the tests and see if you will find another use case that should be tested.