docs
docs copied to clipboard
Help Wanted: Developer docs: Add content around adding prefix to Mattermost posts using `registerPostTypeComponent` to intercept the messages.
Mattermost user justine.geffen
from https://community-daily.mattermost.com has requested the following be documented:
#roughdraft Another thread that may be good as an unofficial developer forum post [<jump to convo>](/core/pl/zrmbowxrotfaunmfrqn5nnr8fy)
Something like
I'm trying to add a prefix to Mattermost posts using registerPostTypeComponent
to intercept the messages. However, as a result, channel mentions like @here
are lost and render as normal text
I checked the docs here (https://developers.mattermost.com/extend/plugins/webapp/reference/#post-utils) and couldn't find anything that would help. Here is the config obj that I use:
const formattedText = PostUtils.formatText(post.message, {
mentionHighlight: true,
atMentions: true,
});
https://community.mattermost.com/files/bwuyhumijprwz8nj4ra9ku5iac/public?h=XKfePelJNKXcz2crxZEboeV9iMnED5ApnMSHYimojvI
ANSWER
The code the webapp uses to generate the channel map is here: https://github.com/mattermost/mattermost-webapp/blob/master/components/markdown/index.ts
You would need to copy, paste and adapt it for your implementation.
If you check markdown.tsx (https://github.com/mattermost/mattermost-webapp/blob/master/components/markdown/markdown.tsx) you will see another use of the formattext, in case you want to add more stuff in there.
```
See the original post [here](https://community-daily.mattermost.com/_redirect/pl/fm3ufano63r9jy56n76g9njkne).
_This issue was generated from [Mattermost](https://mattermost.com) using the [Doc Up](https://github.com/jwilander/mattermost-plugin-docup) plugin._