Skip to content

Commit

Permalink
fix: 🐛 fix emoji hook n update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
themashcodee committed Jun 29, 2024
1 parent 2e1300b commit 7928492
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"repository": "https://github.com/themashcodee/slack-blocks-to-jsx.git",
"license": "MIT",
"version": "0.3.3",
"version": "0.3.4",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
Expand Down
10 changes: 9 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ This is the main component that renders the entire Slack message. It supports va
- `unstyled?`: If true, disables all included styles. Default to false.
- `withoutWrapper?`: If true, renders only the Slack blocks without any wrapper. Default to false.
- `hooks?`: custom handlers for user, channel, broadcast, usergroup, emoji etc.
- user?: (input: { id: string; name: string }) = ReactNode
- channel?: (input: { id: string; name: string }) = ReactNode
- usergroup?: (input: { id: string; name: string }) = ReactNode
- atChannel?: () = ReactNode
- atEveryone?: () = ReactNode
- atHere?: () = ReactNode
- emoji?: (text:string) => string
- date?: (NOT SUPPORTED)
- `data?`: optionally pass an array or users, channels and user groups to automatically be replaced with the user, channel and user group mentions.
- `showBlockKitDebug?`: Show a link to open the message in the Slack Block Kit Builder, for debugging purposes. Defaults to false.

Expand All @@ -81,7 +89,7 @@ Each Slack block type has a corresponding component:
- `File` (❌ not supported yet)
- `Header` (✅ supported)
- `Input` (🟨 partially supported)
- `RichText` (✅ supported)
- `RichText` (✅ supported, except [date parser](https://github.com/themashcodee/slack-blocks-to-jsx/issues/15))
- `Video` (✅ supported)

If you want a support of a particular block or element which is not supported yet so please raise a github issue or mail me at codeemash@gmail.com. I will try to push it asap.
Expand Down
10 changes: 9 additions & 1 deletion src/components/composition_objects/text_object.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ export const TextObject = (props: TextObjectProps) => {
// TODO: HANDLE VERBATIM

let emoji_parsed =
type == "mrkdwn" ? parseEmojis(text) : emoji === false ? text : parseEmojis(text);
type == "mrkdwn"
? hooks.emoji
? hooks.emoji(text)
: parseEmojis(text)
: emoji === false
? text
: hooks.emoji
? hooks.emoji(text)
: parseEmojis(text);

// BASIC MARKDOWN PARSING
emoji_parsed = emoji_parsed.replace(/&gt;/g, "> ").replace(/&lt;/g, "<");
Expand Down
2 changes: 1 addition & 1 deletion src/store/useGlobalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type Hooks = {
atChannel?: () => ReactNode;
atEveryone?: () => ReactNode;
atHere?: () => ReactNode;
emoji?: (emoji_text: string) => ReactNode;
emoji?: (emoji_text: string) => string;
date?: (data: {
timestamp: string;
format: string;
Expand Down

0 comments on commit 7928492

Please sign in to comment.