@dust-tt/sparkle 0.2.646-rc-3 → 0.2.646

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.
Files changed (94) hide show
  1. package/dist/cjs/index.js +1 -1
  2. package/dist/esm/components/DataTable.d.ts +13 -3
  3. package/dist/esm/components/DataTable.d.ts.map +1 -1
  4. package/dist/esm/components/DataTable.js +9 -8
  5. package/dist/esm/components/DataTable.js.map +1 -1
  6. package/dist/esm/components/markdown/BlockquoteBlock.d.ts +1 -3
  7. package/dist/esm/components/markdown/BlockquoteBlock.d.ts.map +1 -1
  8. package/dist/esm/components/markdown/BlockquoteBlock.js +3 -7
  9. package/dist/esm/components/markdown/BlockquoteBlock.js.map +1 -1
  10. package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.d.ts +2 -4
  11. package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.d.ts.map +1 -1
  12. package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js +6 -11
  13. package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js.map +1 -1
  14. package/dist/esm/components/markdown/List.d.ts +3 -17
  15. package/dist/esm/components/markdown/List.d.ts.map +1 -1
  16. package/dist/esm/components/markdown/List.js +7 -21
  17. package/dist/esm/components/markdown/List.js.map +1 -1
  18. package/dist/esm/components/markdown/Markdown.d.ts +9 -2
  19. package/dist/esm/components/markdown/Markdown.d.ts.map +1 -1
  20. package/dist/esm/components/markdown/Markdown.js +66 -45
  21. package/dist/esm/components/markdown/Markdown.js.map +1 -1
  22. package/dist/esm/components/markdown/ParagraphBlock.d.ts +1 -3
  23. package/dist/esm/components/markdown/ParagraphBlock.d.ts.map +1 -1
  24. package/dist/esm/components/markdown/ParagraphBlock.js +3 -7
  25. package/dist/esm/components/markdown/ParagraphBlock.js.map +1 -1
  26. package/dist/esm/components/markdown/PreBlock.d.ts +1 -3
  27. package/dist/esm/components/markdown/PreBlock.d.ts.map +1 -1
  28. package/dist/esm/components/markdown/PreBlock.js +3 -7
  29. package/dist/esm/components/markdown/PreBlock.js.map +1 -1
  30. package/dist/esm/components/markdown/TableBlock.d.ts +11 -17
  31. package/dist/esm/components/markdown/TableBlock.d.ts.map +1 -1
  32. package/dist/esm/components/markdown/TableBlock.js +14 -18
  33. package/dist/esm/components/markdown/TableBlock.js.map +1 -1
  34. package/dist/esm/components/markdown/index.d.ts +0 -4
  35. package/dist/esm/components/markdown/index.d.ts.map +1 -1
  36. package/dist/esm/components/markdown/index.js +0 -4
  37. package/dist/esm/components/markdown/index.js.map +1 -1
  38. package/dist/esm/components/markdown/utils.d.ts +0 -11
  39. package/dist/esm/components/markdown/utils.d.ts.map +1 -1
  40. package/dist/esm/components/markdown/utils.js +0 -21
  41. package/dist/esm/components/markdown/utils.js.map +1 -1
  42. package/dist/esm/stories/DataTable.stories.d.ts +1 -0
  43. package/dist/esm/stories/DataTable.stories.d.ts.map +1 -1
  44. package/dist/esm/stories/DataTable.stories.js +188 -0
  45. package/dist/esm/stories/DataTable.stories.js.map +1 -1
  46. package/dist/esm/styles/global.css +12 -0
  47. package/dist/esm/styles/global_with_tw_base.css +12 -0
  48. package/dist/esm/styles/tailwind.css +11 -0
  49. package/dist/sparkle.css +34 -0
  50. package/package.json +1 -2
  51. package/src/components/DataTable.tsx +31 -2
  52. package/src/components/markdown/BlockquoteBlock.tsx +29 -36
  53. package/src/components/markdown/CodeBlockWithExtendedSupport.tsx +131 -142
  54. package/src/components/markdown/List.tsx +30 -53
  55. package/src/components/markdown/Markdown.tsx +171 -108
  56. package/src/components/markdown/ParagraphBlock.tsx +12 -18
  57. package/src/components/markdown/PreBlock.tsx +18 -28
  58. package/src/components/markdown/TableBlock.tsx +95 -125
  59. package/src/components/markdown/index.ts +0 -4
  60. package/src/components/markdown/utils.ts +0 -37
  61. package/src/stories/DataTable.stories.tsx +235 -0
  62. package/src/styles/global.css +12 -0
  63. package/src/styles/global_with_tw_base.css +12 -0
  64. package/src/styles/tailwind.css +11 -0
  65. package/dist/esm/components/markdown/HeaderBlocks.d.ts +0 -24
  66. package/dist/esm/components/markdown/HeaderBlocks.d.ts.map +0 -1
  67. package/dist/esm/components/markdown/HeaderBlocks.js +0 -54
  68. package/dist/esm/components/markdown/HeaderBlocks.js.map +0 -1
  69. package/dist/esm/components/markdown/InputBlock.d.ts +0 -10
  70. package/dist/esm/components/markdown/InputBlock.d.ts.map +0 -1
  71. package/dist/esm/components/markdown/InputBlock.js +0 -26
  72. package/dist/esm/components/markdown/InputBlock.js.map +0 -1
  73. package/dist/esm/components/markdown/LinkBlock.d.ts +0 -10
  74. package/dist/esm/components/markdown/LinkBlock.d.ts.map +0 -1
  75. package/dist/esm/components/markdown/LinkBlock.js +0 -11
  76. package/dist/esm/components/markdown/LinkBlock.js.map +0 -1
  77. package/dist/esm/components/markdown/TextFormattingBlocks.d.ts +0 -10
  78. package/dist/esm/components/markdown/TextFormattingBlocks.d.ts.map +0 -1
  79. package/dist/esm/components/markdown/TextFormattingBlocks.js +0 -12
  80. package/dist/esm/components/markdown/TextFormattingBlocks.js.map +0 -1
  81. package/dist/esm/components/markdown/types.d.ts +0 -13
  82. package/dist/esm/components/markdown/types.d.ts.map +0 -1
  83. package/dist/esm/components/markdown/types.js +0 -2
  84. package/dist/esm/components/markdown/types.js.map +0 -1
  85. package/dist/esm/components/markdown/useAnimatedText.d.ts +0 -2
  86. package/dist/esm/components/markdown/useAnimatedText.d.ts.map +0 -1
  87. package/dist/esm/components/markdown/useAnimatedText.js +0 -31
  88. package/dist/esm/components/markdown/useAnimatedText.js.map +0 -1
  89. package/src/components/markdown/HeaderBlocks.tsx +0 -160
  90. package/src/components/markdown/InputBlock.tsx +0 -60
  91. package/src/components/markdown/LinkBlock.tsx +0 -36
  92. package/src/components/markdown/TextFormattingBlocks.tsx +0 -31
  93. package/src/components/markdown/types.ts +0 -5
  94. package/src/components/markdown/useAnimatedText.ts +0 -36
@@ -2,6 +2,7 @@
2
2
  import React, { useMemo } from "react";
3
3
  import type { Components } from "react-markdown";
4
4
  import ReactMarkdown from "react-markdown";
5
+ import type { ReactMarkdownProps } from "react-markdown/lib/ast-to-react";
5
6
  import type { PluggableList } from "react-markdown/lib/react-markdown";
6
7
  import rehypeKatex from "rehype-katex";
7
8
  import remarkDirective from "remark-directive";
@@ -9,43 +10,31 @@ import remarkGfm from "remark-gfm";
9
10
  import remarkMath from "remark-math";
10
11
  import { visit } from "unist-util-visit";
11
12
 
12
- import { Chip } from "@sparkle/components";
13
- import { MemoBlockquoteBlock } from "@sparkle/components/markdown/BlockquoteBlock";
14
- import { MemoCodeBlockWithExtendedSupport } from "@sparkle/components/markdown/CodeBlockWithExtendedSupport";
15
- import {
16
- markdownHeaderClasses,
17
- MemoH1Block,
18
- MemoH2Block,
19
- MemoH3Block,
20
- MemoH4Block,
21
- MemoH5Block,
22
- MemoH6Block,
23
- } from "@sparkle/components/markdown/HeaderBlocks";
24
- import { MemoInputBlock } from "@sparkle/components/markdown/InputBlock";
25
- import { MemoLinkBlock } from "@sparkle/components/markdown/LinkBlock";
26
- import {
27
- MemoLiBlock,
28
- MemoOlBlock,
29
- MemoUlBlock,
30
- } from "@sparkle/components/markdown/List";
13
+ import { Checkbox, Chip } from "@sparkle/components";
14
+ import { BlockquoteBlock } from "@sparkle/components/markdown/BlockquoteBlock";
15
+ import { CodeBlockWithExtendedSupport } from "@sparkle/components/markdown/CodeBlockWithExtendedSupport";
16
+ import { LiBlock, OlBlock, UlBlock } from "@sparkle/components/markdown/List";
31
17
  import { MarkdownContentContext } from "@sparkle/components/markdown/MarkdownContentContext";
32
- import { MemoParagraphBlock } from "@sparkle/components/markdown/ParagraphBlock";
33
- import { MemoPreBlock } from "@sparkle/components/markdown/PreBlock";
18
+ import { ParagraphBlock } from "@sparkle/components/markdown/ParagraphBlock";
19
+ import { PreBlock } from "@sparkle/components/markdown/PreBlock";
34
20
  import {
35
- MemoTableBlock,
36
- MemoTableBodyBlock,
37
- MemoTableDataBlock,
38
- MemoTableHeadBlock,
39
- MemoTableHeaderBlock,
21
+ TableBlock,
22
+ TableBodyBlock,
23
+ TableDataBlock,
24
+ TableHeadBlock,
25
+ TableHeaderBlock,
40
26
  } from "@sparkle/components/markdown/TableBlock";
41
- import {
42
- MemoHorizontalRuleBlock,
43
- MemoStrongBlock,
44
- } from "@sparkle/components/markdown/TextFormattingBlocks";
45
27
  import { sanitizeContent } from "@sparkle/components/markdown/utils";
46
28
  import { cn } from "@sparkle/lib/utils";
47
29
 
48
- import { useAnimatedText } from "./useAnimatedText";
30
+ export const markdownHeaderClasses = {
31
+ h1: "s-heading-2xl",
32
+ h2: "s-heading-xl",
33
+ h3: "s-heading-lg",
34
+ h4: "s-text-base s-font-semibold",
35
+ h5: "s-text-sm s-font-semibold",
36
+ h6: "s-text-sm s-font-regular s-italic",
37
+ };
49
38
 
50
39
  const sizes = {
51
40
  p: "s-copy-sm @sm:s-text-base @sm:s-leading-7",
@@ -67,7 +56,6 @@ function showUnsupportedDirective() {
67
56
  export function Markdown({
68
57
  content,
69
58
  isStreaming = false,
70
- shouldHaveStreamingAnimation = false,
71
59
  textColor = "s-text-foreground dark:s-text-foreground-night",
72
60
  forcedTextSize,
73
61
  isLastMessage = false,
@@ -76,7 +64,6 @@ export function Markdown({
76
64
  }: {
77
65
  content: string;
78
66
  isStreaming?: boolean;
79
- shouldHaveStreamingAnimation?: boolean;
80
67
  textColor?: string;
81
68
  isLastMessage?: boolean;
82
69
  forcedTextSize?: string;
@@ -85,11 +72,6 @@ export function Markdown({
85
72
  }) {
86
73
  const processedContent = useMemo(() => sanitizeContent(content), [content]);
87
74
 
88
- const markdownContent = useAnimatedText(
89
- processedContent,
90
- isStreaming && shouldHaveStreamingAnimation
91
- );
92
-
93
75
  // Note on re-renderings. A lot of effort has been put into preventing rerendering across markdown
94
76
  // AST parsing rounds (happening at each token being streamed).
95
77
  //
@@ -107,113 +89,123 @@ export function Markdown({
107
89
  // Memoize markdown components to avoid unnecessary re-renders that disrupt text selection
108
90
  const markdownComponents: Components = useMemo(() => {
109
91
  return {
110
- pre: ({ children, node }) => (
111
- <MemoPreBlock node={node}>{children}</MemoPreBlock>
112
- ),
113
- a: MemoLinkBlock,
114
- ul: ({ children, node }) => (
115
- <MemoUlBlock
92
+ pre: ({ children }) => <PreBlock>{children}</PreBlock>,
93
+ a: LinkBlock,
94
+ ul: ({ children }) => (
95
+ <UlBlock
116
96
  textSize={forcedTextSize ? forcedTextSize : sizes.p}
117
97
  textColor={textColor}
118
- node={node}
119
98
  >
120
99
  {children}
121
- </MemoUlBlock>
100
+ </UlBlock>
122
101
  ),
123
- ol: ({ children, start, node }) => (
124
- <MemoOlBlock
102
+ ol: ({ children, start }) => (
103
+ <OlBlock
125
104
  start={start}
126
105
  textColor={textColor}
127
106
  textSize={forcedTextSize ? forcedTextSize : sizes.p}
128
- node={node}
129
107
  >
130
108
  {children}
131
- </MemoOlBlock>
109
+ </OlBlock>
132
110
  ),
133
- li: ({ children, node }) => (
134
- <MemoLiBlock
111
+ li: ({ children }) => (
112
+ <LiBlock
135
113
  textColor={textColor}
136
114
  textSize={forcedTextSize ? forcedTextSize : sizes.p}
137
- node={node}
138
115
  >
139
116
  {children}
140
- </MemoLiBlock>
117
+ </LiBlock>
141
118
  ),
142
- p: ({ children, node }) => (
143
- <MemoParagraphBlock
119
+ p: ({ children }) => (
120
+ <ParagraphBlock
144
121
  textColor={textColor}
145
122
  textSize={forcedTextSize ? forcedTextSize : sizes.p}
146
- node={node}
147
123
  >
148
124
  {children}
149
- </MemoParagraphBlock>
125
+ </ParagraphBlock>
150
126
  ),
151
- table: MemoTableBlock,
152
- thead: MemoTableHeadBlock,
153
- tbody: MemoTableBodyBlock,
154
- th: MemoTableHeaderBlock,
155
- td: MemoTableDataBlock,
156
- h1: ({ children, node }) => (
157
- <MemoH1Block
158
- textColor={textColor}
159
- forcedTextSize={forcedTextSize}
160
- node={node}
127
+ table: TableBlock,
128
+ thead: TableHeadBlock,
129
+ tbody: TableBodyBlock,
130
+ th: TableHeaderBlock,
131
+ td: TableDataBlock,
132
+ h1: ({ children }) => (
133
+ <h1
134
+ className={cn(
135
+ "s-pb-2 s-pt-4",
136
+ forcedTextSize ? forcedTextSize : sizes.h1,
137
+ textColor
138
+ )}
161
139
  >
162
140
  {children}
163
- </MemoH1Block>
141
+ </h1>
164
142
  ),
165
- h2: ({ children, node }) => (
166
- <MemoH2Block
167
- textColor={textColor}
168
- forcedTextSize={forcedTextSize}
169
- node={node}
143
+ h2: ({ children }) => (
144
+ <h2
145
+ className={cn(
146
+ "s-pb-2 s-pt-4",
147
+ forcedTextSize ? forcedTextSize : sizes.h2,
148
+ textColor
149
+ )}
170
150
  >
171
151
  {children}
172
- </MemoH2Block>
152
+ </h2>
173
153
  ),
174
- h3: ({ children, node }) => (
175
- <MemoH3Block
176
- textColor={textColor}
177
- forcedTextSize={forcedTextSize}
178
- node={node}
154
+ h3: ({ children }) => (
155
+ <h3
156
+ className={cn(
157
+ "s-pb-2 s-pt-4",
158
+ forcedTextSize ? forcedTextSize : sizes.h3,
159
+ textColor
160
+ )}
179
161
  >
180
162
  {children}
181
- </MemoH3Block>
163
+ </h3>
182
164
  ),
183
- h4: ({ children, node }) => (
184
- <MemoH4Block
185
- textColor={textColor}
186
- forcedTextSize={forcedTextSize}
187
- node={node}
165
+ h4: ({ children }) => (
166
+ <h4
167
+ className={cn(
168
+ "s-pb-2 s-pt-3",
169
+ forcedTextSize ? forcedTextSize : sizes.h4,
170
+ textColor
171
+ )}
188
172
  >
189
173
  {children}
190
- </MemoH4Block>
174
+ </h4>
191
175
  ),
192
- h5: ({ children, node }) => (
193
- <MemoH5Block
194
- textColor={textColor}
195
- forcedTextSize={forcedTextSize}
196
- node={node}
176
+ h5: ({ children }) => (
177
+ <h5
178
+ className={cn(
179
+ "s-pb-1.5 s-pt-2.5",
180
+ forcedTextSize ? forcedTextSize : sizes.h5,
181
+ textColor
182
+ )}
197
183
  >
198
184
  {children}
199
- </MemoH5Block>
185
+ </h5>
200
186
  ),
201
- h6: ({ children, node }) => (
202
- <MemoH6Block
203
- textColor={textColor}
204
- forcedTextSize={forcedTextSize}
205
- node={node}
187
+ h6: ({ children }) => (
188
+ <h6
189
+ className={cn(
190
+ "s-pb-1.5 s-pt-2.5",
191
+ forcedTextSize ? forcedTextSize : sizes.h6,
192
+ textColor
193
+ )}
206
194
  >
207
195
  {children}
208
- </MemoH6Block>
196
+ </h6>
197
+ ),
198
+ strong: ({ children }) => (
199
+ <strong className="s-font-semibold s-text-foreground dark:s-text-foreground-night">
200
+ {children}
201
+ </strong>
209
202
  ),
210
- strong: ({ children, node }) => (
211
- <MemoStrongBlock node={node}>{children}</MemoStrongBlock>
203
+ input: Input,
204
+ blockquote: BlockquoteBlock,
205
+ hr: () => (
206
+ <div className="s-my-6 s-border-b s-border-primary-150 dark:s-border-primary-150-night" />
212
207
  ),
213
- input: MemoInputBlock,
214
- blockquote: MemoBlockquoteBlock,
215
- hr: MemoHorizontalRuleBlock,
216
- code: MemoCodeBlockWithExtendedSupport,
208
+ code: CodeBlockWithExtendedSupport,
217
209
  ...additionalMarkdownComponents,
218
210
  };
219
211
  }, [textColor, additionalMarkdownComponents]);
@@ -233,7 +225,7 @@ export function Markdown({
233
225
 
234
226
  try {
235
227
  return (
236
- <div className={cn("s-w-full")}>
228
+ <div className={cn("s-w-full", isStreaming ? "s-blinking-cursor" : "")}>
237
229
  <MarkdownContentContext.Provider
238
230
  value={{
239
231
  content: processedContent,
@@ -247,14 +239,14 @@ export function Markdown({
247
239
  remarkPlugins={markdownPlugins}
248
240
  rehypePlugins={rehypePlugins}
249
241
  >
250
- {markdownContent}
242
+ {processedContent}
251
243
  </ReactMarkdown>
252
244
  </MarkdownContentContext.Provider>
253
245
  </div>
254
246
  );
255
247
  } catch (error) {
256
248
  return (
257
- <div className={cn("s-w-full")}>
249
+ <div className={cn("s-w-full", isStreaming ? "s-blinking-cursor" : "")}>
258
250
  <Chip color="warning">
259
251
  There was an error parsing this markdown content
260
252
  </Chip>
@@ -263,3 +255,74 @@ export function Markdown({
263
255
  );
264
256
  }
265
257
  }
258
+
259
+ function LinkBlock({
260
+ href,
261
+ children,
262
+ }: {
263
+ href?: string;
264
+ children: React.ReactNode;
265
+ }) {
266
+ return (
267
+ <a
268
+ href={href}
269
+ target="_blank"
270
+ rel="noopener noreferrer"
271
+ className={cn(
272
+ "s-break-all s-font-semibold s-transition-all s-duration-200 s-ease-in-out hover:s-underline",
273
+ "s-text-highlight dark:s-text-highlight-night",
274
+ "hover:s-text-highlight-400 dark:hover:s-text-highlight-400-night",
275
+ "active:s-text-highlight-dark dark:active:s-text-highlight-dark-night"
276
+ )}
277
+ >
278
+ {children}
279
+ </a>
280
+ );
281
+ }
282
+
283
+ type InputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "ref"> &
284
+ ReactMarkdownProps & {
285
+ ref?: React.Ref<HTMLInputElement>;
286
+ };
287
+
288
+ function Input({
289
+ type,
290
+ checked,
291
+ className,
292
+ onChange,
293
+ ref,
294
+ ...props
295
+ }: InputProps) {
296
+ const inputRef = React.useRef<HTMLInputElement>(null);
297
+ React.useImperativeHandle(ref, () => inputRef.current!);
298
+
299
+ if (type !== "checkbox") {
300
+ return (
301
+ <input
302
+ ref={inputRef}
303
+ type={type}
304
+ checked={checked}
305
+ className={className}
306
+ {...props}
307
+ />
308
+ );
309
+ }
310
+
311
+ const handleCheckedChange = (isChecked: boolean) => {
312
+ onChange?.({
313
+ target: { type: "checkbox", checked: isChecked },
314
+ } as React.ChangeEvent<HTMLInputElement>);
315
+ };
316
+
317
+ return (
318
+ <div className="s-inline-flex s-items-center">
319
+ <Checkbox
320
+ ref={inputRef as React.Ref<HTMLButtonElement>}
321
+ size="xs"
322
+ checked={checked}
323
+ className="s-translate-y-[3px]"
324
+ onCheckedChange={handleCheckedChange}
325
+ />
326
+ </div>
327
+ );
328
+ }
@@ -1,11 +1,8 @@
1
1
  import { cva } from "class-variance-authority";
2
- import React, { memo } from "react";
2
+ import React from "react";
3
3
 
4
4
  import { cn } from "@sparkle/lib";
5
5
 
6
- import { MarkdownNode } from "./types";
7
- import { sameNodePosition, sameTextStyling } from "./utils";
8
-
9
6
  export const paragraphBlockVariants = cva([
10
7
  "s-whitespace-pre-wrap s-break-words s-font-normal first:s-pt-0 last:s-pb-0",
11
8
  "s-py-1 @md:s-py-2 @md:s-leading-7",
@@ -15,19 +12,16 @@ interface ParagraphBlockProps {
15
12
  children: React.ReactNode;
16
13
  textColor: string;
17
14
  textSize: string;
18
- node?: MarkdownNode;
19
15
  }
20
16
 
21
- export const MemoParagraphBlock = memo(
22
- ({ children, textColor, textSize }: ParagraphBlockProps) => {
23
- return (
24
- <div className={cn(paragraphBlockVariants(), textSize, textColor)}>
25
- {children}
26
- </div>
27
- );
28
- },
29
- (prev, next) =>
30
- sameNodePosition(prev.node, next.node) && sameTextStyling(prev, next)
31
- );
32
-
33
- MemoParagraphBlock.displayName = "ParagraphBlock";
17
+ export function ParagraphBlock({
18
+ children,
19
+ textColor,
20
+ textSize,
21
+ }: ParagraphBlockProps) {
22
+ return (
23
+ <div className={cn(paragraphBlockVariants(), textSize, textColor)}>
24
+ {children}
25
+ </div>
26
+ );
27
+ }
@@ -1,8 +1,5 @@
1
1
  import { cva } from "class-variance-authority";
2
- import React, { memo } from "react";
3
-
4
- import { MarkdownNode } from "./types";
5
- import { sameNodePosition } from "./utils";
2
+ import React from "react";
6
3
 
7
4
  export const preBlockVariants = cva(
8
5
  [
@@ -21,32 +18,25 @@ export const preBlockVariants = cva(
21
18
  interface PreBlockProps {
22
19
  children: React.ReactNode;
23
20
  variant?: "surface";
24
- node?: MarkdownNode;
25
21
  }
26
22
 
27
- export const MemoPreBlock = memo(
28
- ({ children, variant = "surface" }: PreBlockProps) => {
29
- const validChildrenContent =
23
+ export function PreBlock({ children, variant = "surface" }: PreBlockProps) {
24
+ const validChildrenContent =
25
+ Array.isArray(children) && children[0]
26
+ ? children[0].props.children[0]
27
+ : null;
28
+
29
+ let fallbackData: string | null = null;
30
+ if (!validChildrenContent) {
31
+ fallbackData =
30
32
  Array.isArray(children) && children[0]
31
- ? children[0].props.children[0]
33
+ ? children[0].props?.node?.data?.meta
32
34
  : null;
35
+ }
33
36
 
34
- let fallbackData: string | null = null;
35
- if (!validChildrenContent) {
36
- fallbackData =
37
- Array.isArray(children) && children[0]
38
- ? children[0].props?.node?.data?.meta
39
- : null;
40
- }
41
-
42
- return (
43
- <pre className={preBlockVariants({ variant })}>
44
- {validChildrenContent ? children : fallbackData || children}
45
- </pre>
46
- );
47
- },
48
- (prev, next) =>
49
- sameNodePosition(prev.node, next.node) && prev.variant === next.variant
50
- );
51
-
52
- MemoPreBlock.displayName = "PreBlock";
37
+ return (
38
+ <pre className={preBlockVariants({ variant })}>
39
+ {validChildrenContent ? children : fallbackData || children}
40
+ </pre>
41
+ );
42
+ }