Skip to content

Commit a440004

Browse files
committed
Documents ufmFilter extension type
1 parent dc703e8 commit a440004

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

15/umbraco-cms/reference/umbraco-flavored-markdown.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,39 @@ export { MyCustomUfmComponentApi as api };
142142
Using the syntax `{myCustom: myCustomText}` would render the markup `<ufm-custom-component text="myCustomText">`. Then inside the `ufm-custom-component` component code, you can perform any logic to render your required markup.
143143

144144

145+
### Custom UFM filters
146+
147+
If you wish to develop your own custom UFM filter, you can use the `ufmFilter` extension type:
148+
149+
```json
150+
{
151+
type: 'ufmFilter',
152+
alias: 'My.UfmFilter.Reverse',
153+
name: 'Reverse UFM Filter',
154+
api: () => import('./reverse.filter.js'),
155+
meta: {
156+
alias: 'reverse'
157+
}
158+
}
159+
```
160+
161+
The corresponding JavaScript/TypeScript API would contain a function to transform the value.
162+
163+
```js
164+
import { UmbUfmFilterBase } from '@umbraco-cms/backoffice/ufm';
165+
166+
class UmbUfmReverseFilterApi extends UmbUfmFilterBase {
167+
filter(str?: string) {
168+
return str?.split("").reverse().join("");
169+
}
170+
}
171+
172+
export { UmbUfmReverseFilterApi as api };
173+
```
174+
175+
Using the syntax `{umbValue: headline | reverse}`, e.g. where `headline` having a value of `Hello world` would be transform to `dlrow olleH`.
176+
177+
145178
## Post-processing and sanitization
146179
147180
When the markdown has been converted to HTML, the markup will be run through post-processing sanitization to ensure security and consistency within the backoffice.

0 commit comments

Comments
 (0)