@stream-mdx/react 0.3.0 → 0.4.0
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/README.md +4 -3
- package/dist/components/index.cjs +8 -4
- package/dist/components/index.d.cts +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.mjs +8 -4
- package/dist/{index-D7px9jug.d.cts → index-D2MYusAM.d.cts} +1 -1
- package/dist/{index-D7px9jug.d.ts → index-D2MYusAM.d.ts} +1 -1
- package/dist/index.cjs +2537 -2522
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +2751 -2736
- package/dist/renderer/node-views.cjs +4 -0
- package/dist/renderer/node-views.d.cts +1 -1
- package/dist/renderer/node-views.d.ts +1 -1
- package/dist/renderer/node-views.mjs +4 -0
- package/dist/renderer.cjs +2734 -2719
- package/dist/renderer.d.cts +13 -12
- package/dist/renderer.d.ts +13 -12
- package/dist/renderer.mjs +2743 -2728
- package/dist/server.cjs +4244 -0
- package/dist/server.d.cts +249 -0
- package/dist/server.d.ts +249 -0
- package/dist/server.mjs +4226 -0
- package/dist/{streaming-markdown-DSC4L0xR.d.cts → streaming-markdown-D-JcByd9.d.cts} +1 -1
- package/dist/{streaming-markdown-Dp1IDgMT.d.ts → streaming-markdown-DOc2uLiP.d.ts} +1 -1
- package/dist/streaming-markdown.cjs +2787 -2772
- package/dist/streaming-markdown.d.cts +2 -2
- package/dist/streaming-markdown.d.ts +2 -2
- package/dist/streaming-markdown.mjs +2753 -2738
- package/dist/utils/inline-html.d.cts +1 -1
- package/dist/utils/inline-html.d.ts +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -42,9 +42,10 @@ export function Demo({ text }: { text: string }) {
|
|
|
42
42
|
|
|
43
43
|
## Docs
|
|
44
44
|
|
|
45
|
-
- API reference:
|
|
46
|
-
- React integration guide:
|
|
47
|
-
- Plugins & worker customization:
|
|
45
|
+
- API reference: https://github.com/kmccleary3301/stream-mdx/blob/main/docs/PUBLIC_API.md
|
|
46
|
+
- React integration guide: https://github.com/kmccleary3301/stream-mdx/blob/main/docs/REACT_INTEGRATION_GUIDE.md
|
|
47
|
+
- Plugins & worker customization: https://github.com/kmccleary3301/stream-mdx/blob/main/docs/STREAMING_MARKDOWN_PLUGINS_COOKBOOK.md
|
|
48
|
+
- Full docs site: https://kmccleary3301.github.io/stream-mdx/
|
|
48
49
|
|
|
49
50
|
## Addons
|
|
50
51
|
|
|
@@ -1054,15 +1054,17 @@ var defaultBlockComponents = {
|
|
|
1054
1054
|
effectiveInlines.length > 0 ? renderInlineNodes(effectiveInlines, defaultInlineComponents) : raw ?? ""
|
|
1055
1055
|
);
|
|
1056
1056
|
},
|
|
1057
|
-
heading: ({ level, inlines, text }) => {
|
|
1057
|
+
heading: ({ level, inlines, text, meta }) => {
|
|
1058
1058
|
const tag = `h${level}`;
|
|
1059
1059
|
const onlyPlainText = Array.isArray(inlines) && inlines.length > 0 && inlines.every((node) => node.kind === "text");
|
|
1060
1060
|
const children = onlyPlainText ? inlines.map((node) => node.kind === "text" ? node.text : "").join("") : renderInlineNodes(inlines, defaultInlineComponents);
|
|
1061
|
+
const headingId = typeof meta?.headingId === "string" && meta.headingId.length > 0 ? meta.headingId : void 0;
|
|
1061
1062
|
return import_react5.default.createElement(
|
|
1062
1063
|
tag,
|
|
1063
1064
|
{
|
|
1064
1065
|
className: `markdown-heading markdown-h${level}`,
|
|
1065
|
-
...text ? { "data-heading-text": text } : {}
|
|
1066
|
+
...text ? { "data-heading-text": text } : {},
|
|
1067
|
+
...headingId ? { id: headingId, "data-heading-id": headingId } : {}
|
|
1066
1068
|
},
|
|
1067
1069
|
children
|
|
1068
1070
|
);
|
|
@@ -1147,7 +1149,7 @@ var defaultBlockComponents = {
|
|
|
1147
1149
|
},
|
|
1148
1150
|
html: ({ __trustedHtml, elements }) => {
|
|
1149
1151
|
const raw = typeof __trustedHtml === "string" ? __trustedHtml : __trustedHtml.toString();
|
|
1150
|
-
const htmlString = (0, import_core.sanitizeHTML)(raw);
|
|
1152
|
+
const htmlString = typeof window === "undefined" ? raw : (0, import_core.sanitizeHTML)(raw);
|
|
1151
1153
|
if (typeof window !== "undefined" && elements) {
|
|
1152
1154
|
const content = mapHtmlToReact(htmlString, elements);
|
|
1153
1155
|
return import_react5.default.createElement("div", { className: "markdown-html" }, content);
|
|
@@ -1505,7 +1507,9 @@ var ComponentRegistry = class {
|
|
|
1505
1507
|
case "html": {
|
|
1506
1508
|
const trusted = block.payload.sanitizedHtml ?? block.payload.raw;
|
|
1507
1509
|
return {
|
|
1508
|
-
|
|
1510
|
+
// Server render should not depend on DOMPurify (which requires a DOM `window`).
|
|
1511
|
+
// In worker-compiled flows, `sanitizedHtml` is already sanitized at the source.
|
|
1512
|
+
__trustedHtml: typeof window === "undefined" ? String(trusted ?? "") : (0, import_core.createTrustedHTML)(String(trusted ?? "")),
|
|
1509
1513
|
elements: this.htmlElements
|
|
1510
1514
|
};
|
|
1511
1515
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@stream-mdx/core';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { C as ComponentRegistry, D as DefaultLinkSafetyModal, L as LinkSafetyModalProps,
|
|
3
|
+
export { C as ComponentRegistry, D as DefaultLinkSafetyModal, L as LinkSafetyModalProps, e as defaultBlockComponents, d as defaultInlineComponents, m as mapHtmlToReact, r as renderInlineNodes, f as renderParagraphMixedSegments } from '../index-D2MYusAM.cjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@stream-mdx/core';
|
|
2
2
|
import 'react';
|
|
3
|
-
export { C as ComponentRegistry, D as DefaultLinkSafetyModal, L as LinkSafetyModalProps,
|
|
3
|
+
export { C as ComponentRegistry, D as DefaultLinkSafetyModal, L as LinkSafetyModalProps, e as defaultBlockComponents, d as defaultInlineComponents, m as mapHtmlToReact, r as renderInlineNodes, f as renderParagraphMixedSegments } from '../index-D2MYusAM.js';
|
|
@@ -1021,15 +1021,17 @@ var defaultBlockComponents = {
|
|
|
1021
1021
|
effectiveInlines.length > 0 ? renderInlineNodes(effectiveInlines, defaultInlineComponents) : raw ?? ""
|
|
1022
1022
|
);
|
|
1023
1023
|
},
|
|
1024
|
-
heading: ({ level, inlines, text }) => {
|
|
1024
|
+
heading: ({ level, inlines, text, meta }) => {
|
|
1025
1025
|
const tag = `h${level}`;
|
|
1026
1026
|
const onlyPlainText = Array.isArray(inlines) && inlines.length > 0 && inlines.every((node) => node.kind === "text");
|
|
1027
1027
|
const children = onlyPlainText ? inlines.map((node) => node.kind === "text" ? node.text : "").join("") : renderInlineNodes(inlines, defaultInlineComponents);
|
|
1028
|
+
const headingId = typeof meta?.headingId === "string" && meta.headingId.length > 0 ? meta.headingId : void 0;
|
|
1028
1029
|
return React4.createElement(
|
|
1029
1030
|
tag,
|
|
1030
1031
|
{
|
|
1031
1032
|
className: `markdown-heading markdown-h${level}`,
|
|
1032
|
-
...text ? { "data-heading-text": text } : {}
|
|
1033
|
+
...text ? { "data-heading-text": text } : {},
|
|
1034
|
+
...headingId ? { id: headingId, "data-heading-id": headingId } : {}
|
|
1033
1035
|
},
|
|
1034
1036
|
children
|
|
1035
1037
|
);
|
|
@@ -1114,7 +1116,7 @@ var defaultBlockComponents = {
|
|
|
1114
1116
|
},
|
|
1115
1117
|
html: ({ __trustedHtml, elements }) => {
|
|
1116
1118
|
const raw = typeof __trustedHtml === "string" ? __trustedHtml : __trustedHtml.toString();
|
|
1117
|
-
const htmlString = sanitizeHTML(raw);
|
|
1119
|
+
const htmlString = typeof window === "undefined" ? raw : sanitizeHTML(raw);
|
|
1118
1120
|
if (typeof window !== "undefined" && elements) {
|
|
1119
1121
|
const content = mapHtmlToReact(htmlString, elements);
|
|
1120
1122
|
return React4.createElement("div", { className: "markdown-html" }, content);
|
|
@@ -1472,7 +1474,9 @@ var ComponentRegistry = class {
|
|
|
1472
1474
|
case "html": {
|
|
1473
1475
|
const trusted = block.payload.sanitizedHtml ?? block.payload.raw;
|
|
1474
1476
|
return {
|
|
1475
|
-
|
|
1477
|
+
// Server render should not depend on DOMPurify (which requires a DOM `window`).
|
|
1478
|
+
// In worker-compiled flows, `sanitizedHtml` is already sanitized at the source.
|
|
1479
|
+
__trustedHtml: typeof window === "undefined" ? String(trusted ?? "") : createTrustedHTML(String(trusted ?? "")),
|
|
1476
1480
|
elements: this.htmlElements
|
|
1477
1481
|
};
|
|
1478
1482
|
}
|
|
@@ -245,4 +245,4 @@ declare class ComponentRegistry {
|
|
|
245
245
|
declare function mapHtmlToReact(html: string, elements: HtmlElements): React.ReactNode;
|
|
246
246
|
declare function renderParagraphMixedSegments(segments: MixedContentSegment[], inlineComponents: InlineComponents, inlineHtmlRenderers: InlineHtmlRendererMap): React.ReactNode[];
|
|
247
247
|
|
|
248
|
-
export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type
|
|
248
|
+
export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type InlineHtmlRendererMap as I, type LinkSafetyModalProps as L, type Renderer as R, type TableElements as T, type InlineComponents as a, type InlineHtmlRenderer as b, type RendererConfig as c, defaultInlineComponents as d, defaultBlockComponents as e, renderParagraphMixedSegments as f, type CodeHighlightRangeRequest as g, mapHtmlToReact as m, renderInlineNodes as r };
|
|
@@ -245,4 +245,4 @@ declare class ComponentRegistry {
|
|
|
245
245
|
declare function mapHtmlToReact(html: string, elements: HtmlElements): React.ReactNode;
|
|
246
246
|
declare function renderParagraphMixedSegments(segments: MixedContentSegment[], inlineComponents: InlineComponents, inlineHtmlRenderers: InlineHtmlRendererMap): React.ReactNode[];
|
|
247
247
|
|
|
248
|
-
export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type
|
|
248
|
+
export { type BlockComponents as B, ComponentRegistry as C, DefaultLinkSafetyModal as D, type HtmlElements as H, type InlineHtmlRendererMap as I, type LinkSafetyModalProps as L, type Renderer as R, type TableElements as T, type InlineComponents as a, type InlineHtmlRenderer as b, type RendererConfig as c, defaultInlineComponents as d, defaultBlockComponents as e, renderParagraphMixedSegments as f, type CodeHighlightRangeRequest as g, mapHtmlToReact as m, renderInlineNodes as r };
|