slack-blocks-to-jsx 0.3.9 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -10
- package/dist/index.mjs +29 -35
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1103,7 +1103,7 @@ type Hooks = {
|
|
|
1103
1103
|
atChannel?: () => ReactNode;
|
|
1104
1104
|
atEveryone?: () => ReactNode;
|
|
1105
1105
|
atHere?: () => ReactNode;
|
|
1106
|
-
emoji?: (name: string) =>
|
|
1106
|
+
emoji?: (name: string, parse: (name: string) => string) => ReactNode;
|
|
1107
1107
|
date?: (data: {
|
|
1108
1108
|
timestamp: string;
|
|
1109
1109
|
format: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1103,7 +1103,7 @@ type Hooks = {
|
|
|
1103
1103
|
atChannel?: () => ReactNode;
|
|
1104
1104
|
atEveryone?: () => ReactNode;
|
|
1105
1105
|
atHere?: () => ReactNode;
|
|
1106
|
-
emoji?: (name: string) =>
|
|
1106
|
+
emoji?: (name: string, parse: (name: string) => string) => ReactNode;
|
|
1107
1107
|
date?: (data: {
|
|
1108
1108
|
timestamp: string;
|
|
1109
1109
|
format: string;
|
package/dist/index.js
CHANGED
|
@@ -4029,11 +4029,8 @@ var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
|
4029
4029
|
var SlackEmoji = (props) => {
|
|
4030
4030
|
const { element } = props;
|
|
4031
4031
|
const { hooks } = useGlobalData();
|
|
4032
|
-
if (hooks.emoji)
|
|
4033
|
-
|
|
4034
|
-
if (custom_emoji !== "fallback")
|
|
4035
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: custom_emoji });
|
|
4036
|
-
}
|
|
4032
|
+
if (hooks.emoji)
|
|
4033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "slack_emoji", children: hooks.emoji(element.value, (name) => parseEmojis(`:${name}:`)) });
|
|
4037
4034
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "slack_emoji", children: parseEmojis(`:${element.value}:`) });
|
|
4038
4035
|
};
|
|
4039
4036
|
|
|
@@ -4910,7 +4907,7 @@ var parse6 = function(api) {
|
|
|
4910
4907
|
parse: (tokens) => tokens.map((token) => {
|
|
4911
4908
|
const nodePoints = api.getNodePoints();
|
|
4912
4909
|
const fullString = (0, import_character12.calcStringFromNodePoints)(nodePoints, token.startIndex, token.endIndex);
|
|
4913
|
-
const emojiPattern = /^:([
|
|
4910
|
+
const emojiPattern = /^:([a-zA-Z0-9_\-+']+):$/;
|
|
4914
4911
|
const match7 = emojiPattern.exec(fullString);
|
|
4915
4912
|
let value = fullString;
|
|
4916
4913
|
if (match7)
|
|
@@ -5674,10 +5671,7 @@ var RichTextSectionEmoji = (props) => {
|
|
|
5674
5671
|
const { name } = props;
|
|
5675
5672
|
const { hooks } = useGlobalData();
|
|
5676
5673
|
if (hooks.emoji) {
|
|
5677
|
-
|
|
5678
|
-
if (custom_emoji !== "fallback") {
|
|
5679
|
-
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "slack_blocks_to_jsx__rich_text_section_element_emoji", children: custom_emoji });
|
|
5680
|
-
}
|
|
5674
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "slack_blocks_to_jsx__rich_text_section_element_emoji", children: hooks.emoji(name, (name2) => parseEmojis(`:${name2}:`)) });
|
|
5681
5675
|
}
|
|
5682
5676
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "slack_blocks_to_jsx__rich_text_section_element_emoji", children: parseEmojis(`:${name}:`) });
|
|
5683
5677
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -3992,29 +3992,26 @@ var date_token_to_label = (inputDate, formatString) => {
|
|
|
3992
3992
|
};
|
|
3993
3993
|
|
|
3994
3994
|
// src/utils/markdown_parser/sub_elements/slack_emoji.tsx
|
|
3995
|
-
import {
|
|
3995
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
3996
3996
|
var SlackEmoji = (props) => {
|
|
3997
3997
|
const { element } = props;
|
|
3998
3998
|
const { hooks } = useGlobalData();
|
|
3999
|
-
if (hooks.emoji)
|
|
4000
|
-
|
|
4001
|
-
if (custom_emoji !== "fallback")
|
|
4002
|
-
return /* @__PURE__ */ jsx2(Fragment2, { children: custom_emoji });
|
|
4003
|
-
}
|
|
3999
|
+
if (hooks.emoji)
|
|
4000
|
+
return /* @__PURE__ */ jsx2("span", { className: "slack_emoji", children: hooks.emoji(element.value, (name) => parseEmojis(`:${name}:`)) });
|
|
4004
4001
|
return /* @__PURE__ */ jsx2("span", { className: "slack_emoji", children: parseEmojis(`:${element.value}:`) });
|
|
4005
4002
|
};
|
|
4006
4003
|
|
|
4007
4004
|
// src/utils/markdown_parser/sub_elements/slack_broadcast.tsx
|
|
4008
|
-
import { Fragment as
|
|
4005
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
4009
4006
|
var SlackBroadcast = (props) => {
|
|
4010
4007
|
const { element } = props;
|
|
4011
4008
|
const { hooks } = useGlobalData();
|
|
4012
4009
|
if (element.value === "here" && hooks.atHere)
|
|
4013
|
-
return /* @__PURE__ */ jsx3(
|
|
4010
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children: hooks.atHere() });
|
|
4014
4011
|
if (element.value === "everyone" && hooks.atEveryone)
|
|
4015
|
-
return /* @__PURE__ */ jsx3(
|
|
4012
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children: hooks.atEveryone() });
|
|
4016
4013
|
if (element.value === "channel" && hooks.atChannel)
|
|
4017
|
-
return /* @__PURE__ */ jsx3(
|
|
4014
|
+
return /* @__PURE__ */ jsx3(Fragment2, { children: hooks.atChannel() });
|
|
4018
4015
|
return /* @__PURE__ */ jsxs("span", { className: "slack_broadcast", children: [
|
|
4019
4016
|
"@",
|
|
4020
4017
|
element.value
|
|
@@ -4022,7 +4019,7 @@ var SlackBroadcast = (props) => {
|
|
|
4022
4019
|
};
|
|
4023
4020
|
|
|
4024
4021
|
// src/utils/markdown_parser/sub_elements/slack_channel_mention.tsx
|
|
4025
|
-
import { Fragment as
|
|
4022
|
+
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
4026
4023
|
var SlackChannelMention = (props) => {
|
|
4027
4024
|
const { element } = props;
|
|
4028
4025
|
const { hooks, channels } = useGlobalData();
|
|
@@ -4030,7 +4027,7 @@ var SlackChannelMention = (props) => {
|
|
|
4030
4027
|
const channel = channels.find((u) => u.id === channel_id || u.name === channel_id);
|
|
4031
4028
|
const label = (channel == null ? void 0 : channel.name) || channel_id;
|
|
4032
4029
|
if (hooks.channel)
|
|
4033
|
-
return /* @__PURE__ */ jsx4(
|
|
4030
|
+
return /* @__PURE__ */ jsx4(Fragment3, { children: hooks.channel(channel || { id: channel_id, name: label }) });
|
|
4034
4031
|
return /* @__PURE__ */ jsxs2("span", { className: "slack_channel", "data-channel-id": (channel == null ? void 0 : channel.id) || channel_id, children: [
|
|
4035
4032
|
"#",
|
|
4036
4033
|
label
|
|
@@ -4038,7 +4035,7 @@ var SlackChannelMention = (props) => {
|
|
|
4038
4035
|
};
|
|
4039
4036
|
|
|
4040
4037
|
// src/utils/markdown_parser/sub_elements/slack_user_group_mention.tsx
|
|
4041
|
-
import { Fragment as
|
|
4038
|
+
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
4042
4039
|
var SlackUserGroupMention = (props) => {
|
|
4043
4040
|
const { element } = props;
|
|
4044
4041
|
const { hooks, user_groups } = useGlobalData();
|
|
@@ -4046,7 +4043,7 @@ var SlackUserGroupMention = (props) => {
|
|
|
4046
4043
|
const group = user_groups.find((u) => u.id === group_id || u.name === group_id);
|
|
4047
4044
|
const label = (group == null ? void 0 : group.name) || group_id;
|
|
4048
4045
|
if (hooks.usergroup)
|
|
4049
|
-
return /* @__PURE__ */ jsx5(
|
|
4046
|
+
return /* @__PURE__ */ jsx5(Fragment4, { children: hooks.usergroup(group || { id: group_id, name: label }) });
|
|
4050
4047
|
return /* @__PURE__ */ jsxs3("span", { "data-usergroup-id": (group == null ? void 0 : group.id) || group_id, className: "slack_user_group", children: [
|
|
4051
4048
|
"@",
|
|
4052
4049
|
label
|
|
@@ -4054,14 +4051,14 @@ var SlackUserGroupMention = (props) => {
|
|
|
4054
4051
|
};
|
|
4055
4052
|
|
|
4056
4053
|
// src/utils/markdown_parser/sub_elements/slack_user_mention.tsx
|
|
4057
|
-
import { Fragment as
|
|
4054
|
+
import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
4058
4055
|
var SlackUserMention = (props) => {
|
|
4059
4056
|
const { element } = props;
|
|
4060
4057
|
const { hooks, users } = useGlobalData();
|
|
4061
4058
|
const user_id = element.value;
|
|
4062
4059
|
const user = users.find((u) => u.id === user_id || u.name === user_id);
|
|
4063
4060
|
if (hooks.user)
|
|
4064
|
-
return /* @__PURE__ */ jsx6(
|
|
4061
|
+
return /* @__PURE__ */ jsx6(Fragment5, { children: hooks.user(user || { id: user_id, name: user_id }) });
|
|
4065
4062
|
const label = (user == null ? void 0 : user.name) || user_id;
|
|
4066
4063
|
return /* @__PURE__ */ jsxs4("span", { className: "slack_user", "data-user-id": (user == null ? void 0 : user.id) || user_id, children: [
|
|
4067
4064
|
"@",
|
|
@@ -4177,10 +4174,10 @@ var Link = (props) => {
|
|
|
4177
4174
|
};
|
|
4178
4175
|
|
|
4179
4176
|
// src/utils/markdown_parser/elements/paragraph.tsx
|
|
4180
|
-
import { Fragment as
|
|
4177
|
+
import { Fragment as Fragment6, jsx as jsx13 } from "react/jsx-runtime";
|
|
4181
4178
|
var Paragraph = (props) => {
|
|
4182
4179
|
const { element } = props;
|
|
4183
|
-
return /* @__PURE__ */ jsx13(
|
|
4180
|
+
return /* @__PURE__ */ jsx13(Fragment6, { children: element.children.map((subelement, i) => {
|
|
4184
4181
|
if (subelement.type === "text")
|
|
4185
4182
|
return /* @__PURE__ */ jsx13(Text, { element: subelement }, i);
|
|
4186
4183
|
if (subelement.type === "emphasis")
|
|
@@ -4210,10 +4207,10 @@ var Paragraph = (props) => {
|
|
|
4210
4207
|
};
|
|
4211
4208
|
|
|
4212
4209
|
// src/utils/markdown_parser/elements/blockquote.tsx
|
|
4213
|
-
import { Fragment as
|
|
4210
|
+
import { Fragment as Fragment7, jsx as jsx14 } from "react/jsx-runtime";
|
|
4214
4211
|
var Blockquote = (props) => {
|
|
4215
4212
|
const { element } = props;
|
|
4216
|
-
return /* @__PURE__ */ jsx14(
|
|
4213
|
+
return /* @__PURE__ */ jsx14(Fragment7, { children: element.children.map((para) => {
|
|
4217
4214
|
return /* @__PURE__ */ jsx14(Paragraph, { element: para });
|
|
4218
4215
|
}) });
|
|
4219
4216
|
};
|
|
@@ -4877,7 +4874,7 @@ var parse6 = function(api) {
|
|
|
4877
4874
|
parse: (tokens) => tokens.map((token) => {
|
|
4878
4875
|
const nodePoints = api.getNodePoints();
|
|
4879
4876
|
const fullString = calcStringFromNodePoints6(nodePoints, token.startIndex, token.endIndex);
|
|
4880
|
-
const emojiPattern = /^:([
|
|
4877
|
+
const emojiPattern = /^:([a-zA-Z0-9_\-+']+):$/;
|
|
4881
4878
|
const match7 = emojiPattern.exec(fullString);
|
|
4882
4879
|
let value = fullString;
|
|
4883
4880
|
if (match7)
|
|
@@ -5579,16 +5576,16 @@ var RichTextListWrapper = (props) => {
|
|
|
5579
5576
|
};
|
|
5580
5577
|
|
|
5581
5578
|
// src/components/blocks/rich_text/rich_text_section_broadcast.tsx
|
|
5582
|
-
import { Fragment as
|
|
5579
|
+
import { Fragment as Fragment8, jsx as jsx32, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5583
5580
|
var RichTextSectionBroadcast = (props) => {
|
|
5584
5581
|
const { range, style } = props;
|
|
5585
5582
|
const { hooks } = useGlobalData();
|
|
5586
5583
|
if (range === "channel" && hooks.atChannel)
|
|
5587
|
-
return /* @__PURE__ */ jsx32(
|
|
5584
|
+
return /* @__PURE__ */ jsx32(Fragment8, { children: hooks.atChannel() });
|
|
5588
5585
|
if (range === "everyone" && hooks.atEveryone)
|
|
5589
|
-
return /* @__PURE__ */ jsx32(
|
|
5586
|
+
return /* @__PURE__ */ jsx32(Fragment8, { children: hooks.atEveryone() });
|
|
5590
5587
|
if (range === "here" && hooks.atHere)
|
|
5591
|
-
return /* @__PURE__ */ jsx32(
|
|
5588
|
+
return /* @__PURE__ */ jsx32(Fragment8, { children: hooks.atHere() });
|
|
5592
5589
|
return /* @__PURE__ */ jsxs13(
|
|
5593
5590
|
"span",
|
|
5594
5591
|
{
|
|
@@ -5608,14 +5605,14 @@ var RichTextSectionBroadcast = (props) => {
|
|
|
5608
5605
|
};
|
|
5609
5606
|
|
|
5610
5607
|
// src/components/blocks/rich_text/rich_text_section_channel.tsx
|
|
5611
|
-
import { Fragment as
|
|
5608
|
+
import { Fragment as Fragment9, jsx as jsx33, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5612
5609
|
var RichTextSectionChannel = (props) => {
|
|
5613
5610
|
const { channel_id, style } = props;
|
|
5614
5611
|
const { channels, hooks } = useGlobalData();
|
|
5615
5612
|
const channel = channels.find((u) => u.id === channel_id || u.name === channel_id);
|
|
5616
5613
|
const label = (channel == null ? void 0 : channel.name) || channel_id;
|
|
5617
5614
|
if (hooks.channel)
|
|
5618
|
-
return /* @__PURE__ */ jsx33(
|
|
5615
|
+
return /* @__PURE__ */ jsx33(Fragment9, { children: hooks.channel(channel || { id: channel_id, name: label }) });
|
|
5619
5616
|
return /* @__PURE__ */ jsxs14(
|
|
5620
5617
|
"span",
|
|
5621
5618
|
{
|
|
@@ -5641,23 +5638,20 @@ var RichTextSectionEmoji = (props) => {
|
|
|
5641
5638
|
const { name } = props;
|
|
5642
5639
|
const { hooks } = useGlobalData();
|
|
5643
5640
|
if (hooks.emoji) {
|
|
5644
|
-
|
|
5645
|
-
if (custom_emoji !== "fallback") {
|
|
5646
|
-
return /* @__PURE__ */ jsx34("span", { className: "slack_blocks_to_jsx__rich_text_section_element_emoji", children: custom_emoji });
|
|
5647
|
-
}
|
|
5641
|
+
return /* @__PURE__ */ jsx34("span", { className: "slack_blocks_to_jsx__rich_text_section_element_emoji", children: hooks.emoji(name, (name2) => parseEmojis(`:${name2}:`)) });
|
|
5648
5642
|
}
|
|
5649
5643
|
return /* @__PURE__ */ jsx34("span", { className: "slack_blocks_to_jsx__rich_text_section_element_emoji", children: parseEmojis(`:${name}:`) });
|
|
5650
5644
|
};
|
|
5651
5645
|
|
|
5652
5646
|
// src/components/blocks/rich_text/rich_text_section_user.tsx
|
|
5653
|
-
import { Fragment as
|
|
5647
|
+
import { Fragment as Fragment10, jsx as jsx35, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
5654
5648
|
var RichTextSectionUser = (props) => {
|
|
5655
5649
|
const { user_id, style } = props;
|
|
5656
5650
|
const { users, hooks } = useGlobalData();
|
|
5657
5651
|
const user = users.find((u) => u.id === user_id || u.name === user_id);
|
|
5658
5652
|
const label = (user == null ? void 0 : user.name) || user_id;
|
|
5659
5653
|
if (hooks.user)
|
|
5660
|
-
return /* @__PURE__ */ jsx35(
|
|
5654
|
+
return /* @__PURE__ */ jsx35(Fragment10, { children: hooks.user(user || { id: user_id, name: label }) });
|
|
5661
5655
|
return /* @__PURE__ */ jsxs15(
|
|
5662
5656
|
"span",
|
|
5663
5657
|
{
|
|
@@ -5678,14 +5672,14 @@ var RichTextSectionUser = (props) => {
|
|
|
5678
5672
|
};
|
|
5679
5673
|
|
|
5680
5674
|
// src/components/blocks/rich_text/rich_text_section_user_group.tsx
|
|
5681
|
-
import { Fragment as
|
|
5675
|
+
import { Fragment as Fragment11, jsx as jsx36, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
5682
5676
|
var RichTextSectionUserGroup = (props) => {
|
|
5683
5677
|
const { usergroup_id, style } = props;
|
|
5684
5678
|
const { user_groups, hooks } = useGlobalData();
|
|
5685
5679
|
const group = user_groups.find((u) => u.id === usergroup_id || u.name === usergroup_id);
|
|
5686
5680
|
const label = (group == null ? void 0 : group.name) || usergroup_id;
|
|
5687
5681
|
if (hooks.usergroup)
|
|
5688
|
-
return /* @__PURE__ */ jsx36(
|
|
5682
|
+
return /* @__PURE__ */ jsx36(Fragment11, { children: hooks.usergroup(group || { id: usergroup_id, name: label }) });
|
|
5689
5683
|
return /* @__PURE__ */ jsxs16(
|
|
5690
5684
|
"span",
|
|
5691
5685
|
{
|
package/package.json
CHANGED