contentcollector: Fix collectContentLineText hook

Before, the hook always ignored the return values provided by the hook
functions. Now the hook functions can change the text by either
returning a string or setting `context.text` to the desired value.

Also drop the `styl` and `cls` context properties. They were never
documented and they were always null.
This commit is contained in:
Richard Hansen 2021-01-22 02:06:06 -05:00 committed by John McLear
parent 4e220538a1
commit e3a47e48f9
2 changed files with 21 additions and 18 deletions

View file

@ -421,7 +421,20 @@ Things in context:
4. text - the text for that line
This hook allows you to validate/manipulate the text before it's sent to the
server side. The return value should be the validated/manipulated text.
server side. To change the text, either:
* Set the `text` context property to the desired value and return `undefined`.
* (Deprecated) Return a string. If a hook function changes the `text` context
property, the return value is ignored. If no hook function changes `text` but
multiple hook functions return a string, the first one wins.
Example:
```
exports.collectContentLineText = (hookName, context) => {
context.text = tweakText(context.text);
};
```
## collectContentLineBreak