Closed StephenTangCook closed 1 day ago
Yeah, I will add support for them.
Hey @StephenTangCook,
The reason why I commented out the existing code is I have reactnode support currently for hooks, but technically we can't pass reactnode directly to the slack_text_parser library because all it does is just replace certain strings with given strings.
One solution could be is allowing passing a string html to replace user, channel etc. Also that would be little hectic for the user too, because anyway it won't support any interactivity but the user will be able to pass a custom wrapper with their own classes.
Let me know if that is what you were thinking as a solution.
Hm, good question! The slack-markdown
library assumes you're always working with stringified HTML which unfortunately isn't a good fit for building a react component tree.
Your suggestion for passing in stringified HTML would probably be sufficient for my requirements, but I agree it is a bit messy. Would these be a separate set of function hooks?
Let's also talk about the ideal solution. Would the best option be to convert the mrkdwn to blocks first, then continue your processing on the blocks? If so, maybe there's a library out there we can reuse. Here are some I found:
I'm not sure if any of these can be used out-of-the-box. Some don't look like they've been maintained recently and may be missing some block compatibility... will investigate!
@StephenTangCook This will do the job! - https://github.com/themashcodee/slack-blocks-to-jsx/pull/14
The hook functions used for customizing the output of certain Slack mentions (users, channels, @here, dates, etc), should also be used when parsing
mrkdwn
elements, since they can also live in those elements:https://github.com/themashcodee/slack-blocks-to-jsx/blob/9d462cad3719baa2ef7ed85f5243d5c1cfb6616a/src/utils/slack_text_to_jsx.tsx#L29-L61