@dust-tt/sparkle 0.2.644 → 0.2.646-rc-1
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/cjs/index.js +1 -1
- package/dist/esm/components/DataTable.d.ts +3 -6
- package/dist/esm/components/DataTable.d.ts.map +1 -1
- package/dist/esm/components/DataTable.js +8 -8
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/markdown/BlockquoteBlock.d.ts +3 -1
- package/dist/esm/components/markdown/BlockquoteBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/BlockquoteBlock.js +7 -3
- package/dist/esm/components/markdown/BlockquoteBlock.js.map +1 -1
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.d.ts +4 -2
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.d.ts.map +1 -1
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js +11 -6
- package/dist/esm/components/markdown/CodeBlockWithExtendedSupport.js.map +1 -1
- package/dist/esm/components/markdown/HeaderBlocks.d.ts +24 -0
- package/dist/esm/components/markdown/HeaderBlocks.d.ts.map +1 -0
- package/dist/esm/components/markdown/HeaderBlocks.js +54 -0
- package/dist/esm/components/markdown/HeaderBlocks.js.map +1 -0
- package/dist/esm/components/markdown/InputBlock.d.ts +10 -0
- package/dist/esm/components/markdown/InputBlock.d.ts.map +1 -0
- package/dist/esm/components/markdown/InputBlock.js +26 -0
- package/dist/esm/components/markdown/InputBlock.js.map +1 -0
- package/dist/esm/components/markdown/LinkBlock.d.ts +10 -0
- package/dist/esm/components/markdown/LinkBlock.d.ts.map +1 -0
- package/dist/esm/components/markdown/LinkBlock.js +11 -0
- package/dist/esm/components/markdown/LinkBlock.js.map +1 -0
- package/dist/esm/components/markdown/List.d.ts +17 -3
- package/dist/esm/components/markdown/List.d.ts.map +1 -1
- package/dist/esm/components/markdown/List.js +21 -7
- package/dist/esm/components/markdown/List.js.map +1 -1
- package/dist/esm/components/markdown/Markdown.d.ts +0 -8
- package/dist/esm/components/markdown/Markdown.d.ts.map +1 -1
- package/dist/esm/components/markdown/Markdown.js +39 -62
- package/dist/esm/components/markdown/Markdown.js.map +1 -1
- package/dist/esm/components/markdown/ParagraphBlock.d.ts +3 -1
- package/dist/esm/components/markdown/ParagraphBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/ParagraphBlock.js +7 -3
- package/dist/esm/components/markdown/ParagraphBlock.js.map +1 -1
- package/dist/esm/components/markdown/PreBlock.d.ts +3 -1
- package/dist/esm/components/markdown/PreBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/PreBlock.js +7 -3
- package/dist/esm/components/markdown/PreBlock.js.map +1 -1
- package/dist/esm/components/markdown/TableBlock.d.ts +17 -11
- package/dist/esm/components/markdown/TableBlock.d.ts.map +1 -1
- package/dist/esm/components/markdown/TableBlock.js +18 -14
- package/dist/esm/components/markdown/TableBlock.js.map +1 -1
- package/dist/esm/components/markdown/TextFormattingBlocks.d.ts +10 -0
- package/dist/esm/components/markdown/TextFormattingBlocks.d.ts.map +1 -0
- package/dist/esm/components/markdown/TextFormattingBlocks.js +12 -0
- package/dist/esm/components/markdown/TextFormattingBlocks.js.map +1 -0
- package/dist/esm/components/markdown/index.d.ts +4 -0
- package/dist/esm/components/markdown/index.d.ts.map +1 -1
- package/dist/esm/components/markdown/index.js +4 -0
- package/dist/esm/components/markdown/index.js.map +1 -1
- package/dist/esm/components/markdown/types.d.ts +13 -0
- package/dist/esm/components/markdown/types.d.ts.map +1 -0
- package/dist/esm/components/markdown/types.js +2 -0
- package/dist/esm/components/markdown/types.js.map +1 -0
- package/dist/esm/components/markdown/utils.d.ts +11 -0
- package/dist/esm/components/markdown/utils.d.ts.map +1 -1
- package/dist/esm/components/markdown/utils.js +21 -0
- package/dist/esm/components/markdown/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/components/DataTable.tsx +2 -18
- package/src/components/markdown/BlockquoteBlock.tsx +36 -29
- package/src/components/markdown/CodeBlockWithExtendedSupport.tsx +142 -131
- package/src/components/markdown/HeaderBlocks.tsx +160 -0
- package/src/components/markdown/InputBlock.tsx +60 -0
- package/src/components/markdown/LinkBlock.tsx +36 -0
- package/src/components/markdown/List.tsx +53 -30
- package/src/components/markdown/Markdown.tsx +97 -169
- package/src/components/markdown/ParagraphBlock.tsx +18 -12
- package/src/components/markdown/PreBlock.tsx +28 -18
- package/src/components/markdown/TableBlock.tsx +125 -95
- package/src/components/markdown/TextFormattingBlocks.tsx +31 -0
- package/src/components/markdown/index.ts +4 -0
- package/src/components/markdown/types.ts +5 -0
- package/src/components/markdown/utils.ts +37 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { memo } from "react";
|
|
2
|
+
|
|
3
|
+
import { sameNodePosition } from "@sparkle/components/markdown/utils";
|
|
4
|
+
|
|
5
|
+
import { MarkdownNode } from "./types";
|
|
6
|
+
|
|
7
|
+
interface StrongBlockProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
node?: MarkdownNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MemoStrongBlock = memo(
|
|
13
|
+
({ children }: StrongBlockProps) => {
|
|
14
|
+
return (
|
|
15
|
+
<strong className="s-font-semibold s-text-foreground dark:s-text-foreground-night">
|
|
16
|
+
{children}
|
|
17
|
+
</strong>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
(prev, next) => sameNodePosition(prev.node, next.node)
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
MemoStrongBlock.displayName = "StrongBlock";
|
|
24
|
+
|
|
25
|
+
export const MemoHorizontalRuleBlock = memo(() => {
|
|
26
|
+
return (
|
|
27
|
+
<div className="s-my-6 s-border-b s-border-primary-150 dark:s-border-primary-150-night" />
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
MemoHorizontalRuleBlock.displayName = "HorizontalRuleBlock";
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export * from "./CodeBlock";
|
|
2
2
|
export * from "./CodeBlockWithExtendedSupport";
|
|
3
3
|
export * from "./ContentBlockWrapper";
|
|
4
|
+
export * from "./HeaderBlocks";
|
|
5
|
+
export * from "./InputBlock";
|
|
6
|
+
export * from "./LinkBlock";
|
|
4
7
|
export * from "./Markdown";
|
|
5
8
|
export * from "./MarkdownContentContext";
|
|
6
9
|
export * from "./PrettyJsonViewer";
|
|
7
10
|
export * from "./TableBlock";
|
|
11
|
+
export * from "./TextFormattingBlocks";
|
|
8
12
|
export * from "./utils";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MarkdownNode } from "./types";
|
|
2
|
+
|
|
1
3
|
export function sanitizeContent(str: string): string {
|
|
2
4
|
// (1) Add closing backticks if they are missing such that we render a code block or inline
|
|
3
5
|
// element during streaming.
|
|
@@ -39,3 +41,38 @@ export function detectLanguage(children: React.ReactNode) {
|
|
|
39
41
|
|
|
40
42
|
return "text";
|
|
41
43
|
}
|
|
44
|
+
|
|
45
|
+
export function sameNodePosition(
|
|
46
|
+
prev?: MarkdownNode,
|
|
47
|
+
next?: MarkdownNode
|
|
48
|
+
): boolean {
|
|
49
|
+
if (!(prev?.position || next?.position)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (!(prev?.position && next?.position)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const prevStart = prev.position.start;
|
|
57
|
+
const nextStart = next.position.start;
|
|
58
|
+
const prevEnd = prev.position.end;
|
|
59
|
+
const nextEnd = next.position.end;
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
prevStart?.line === nextStart?.line &&
|
|
63
|
+
prevStart?.column === nextStart?.column &&
|
|
64
|
+
prevEnd?.line === nextEnd?.line &&
|
|
65
|
+
prevEnd?.column === nextEnd?.column
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function sameTextStyling(
|
|
70
|
+
prev: { textColor?: string; textSize?: string; forcedTextSize?: string },
|
|
71
|
+
next: { textColor?: string; textSize?: string; forcedTextSize?: string }
|
|
72
|
+
): boolean {
|
|
73
|
+
return (
|
|
74
|
+
prev.textColor === next.textColor &&
|
|
75
|
+
prev.textSize === next.textSize &&
|
|
76
|
+
prev.forcedTextSize === next.forcedTextSize
|
|
77
|
+
);
|
|
78
|
+
}
|