@soroush.tech/markdown 0.1.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.
Files changed (51) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +179 -0
  3. package/dist/CodeBlock-CVlrvVPP.mjs +159 -0
  4. package/dist/CodeBlock-Cymx1ZAY.cjs +176 -0
  5. package/dist/CodeBlock.cjs +5 -0
  6. package/dist/CodeBlock.d.cts +2 -0
  7. package/dist/CodeBlock.d.mts +2 -0
  8. package/dist/CodeBlock.mjs +2 -0
  9. package/dist/Control.cjs +61 -0
  10. package/dist/Control.d.cts +18 -0
  11. package/dist/Control.d.mts +18 -0
  12. package/dist/Control.mjs +60 -0
  13. package/dist/Editor.cjs +129 -0
  14. package/dist/Editor.d.cts +40 -0
  15. package/dist/Editor.d.mts +40 -0
  16. package/dist/Editor.mjs +128 -0
  17. package/dist/MarkdownContext.cjs +13 -0
  18. package/dist/MarkdownContext.d.cts +2 -0
  19. package/dist/MarkdownContext.d.mts +2 -0
  20. package/dist/MarkdownContext.mjs +11 -0
  21. package/dist/Mermaid-BclI9A7e.mjs +231 -0
  22. package/dist/Mermaid-DqP2Q0bt.cjs +236 -0
  23. package/dist/Mermaid.cjs +3 -0
  24. package/dist/Mermaid.d.cts +2 -0
  25. package/dist/Mermaid.d.mts +2 -0
  26. package/dist/Mermaid.mjs +2 -0
  27. package/dist/Preview-BVT70uXa.cjs +276 -0
  28. package/dist/Preview-C1CwRDj5.mjs +246 -0
  29. package/dist/Preview.cjs +3 -0
  30. package/dist/Preview.d.cts +53 -0
  31. package/dist/Preview.d.mts +53 -0
  32. package/dist/Preview.mjs +2 -0
  33. package/dist/Toolbar-Ba3l-oBU.cjs +600 -0
  34. package/dist/Toolbar-C0SNI-JK.mjs +589 -0
  35. package/dist/Toolbar.cjs +4 -0
  36. package/dist/Toolbar.d.cts +13 -0
  37. package/dist/Toolbar.d.mts +13 -0
  38. package/dist/Toolbar.mjs +2 -0
  39. package/dist/applyAction-BDkgYhOd.cjs +120 -0
  40. package/dist/applyAction-BGWMbUYT.mjs +115 -0
  41. package/dist/index-BO0LyUUG.d.cts +27 -0
  42. package/dist/index-BO0LyUUG.d.mts +27 -0
  43. package/dist/index-BtMTBOcM.d.cts +48 -0
  44. package/dist/index-BtMTBOcM.d.mts +48 -0
  45. package/dist/index-rGZIhUgj.d.cts +76 -0
  46. package/dist/index-rGZIhUgj.d.mts +76 -0
  47. package/dist/index.cjs +19 -0
  48. package/dist/index.d.cts +50 -0
  49. package/dist/index.d.mts +50 -0
  50. package/dist/index.mjs +8 -0
  51. package/package.json +110 -0
@@ -0,0 +1,236 @@
1
+ const require_CodeBlock = require("./CodeBlock-Cymx1ZAY.cjs");
2
+ let react = require("react");
3
+ let react_jsx_runtime = require("react/jsx-runtime");
4
+ let _soroush_tech_design_system_Button = require("@soroush.tech/design-system/Button");
5
+ let _soroush_tech_design_system_Flex = require("@soroush.tech/design-system/Flex");
6
+ let _soroush_tech_design_system_Icon = require("@soroush.tech/design-system/Icon");
7
+ let _soroush_tech_design_system_theme = require("@soroush.tech/design-system/theme");
8
+ let _soroush_tech_design_system_View = require("@soroush.tech/design-system/View");
9
+ let _soroush_tech_design_system_Grid = require("@soroush.tech/design-system/Grid");
10
+ let _soroush_tech_design_system_Modal = require("@soroush.tech/design-system/Modal");
11
+ //#region src/Mermaid/DiagramViewer.tsx
12
+ const MIN_SCALE = .2;
13
+ const MAX_SCALE = 5;
14
+ const ZOOM_STEP = .2;
15
+ const PAN_STEP = 48;
16
+ const MIN_HEIGHT = 180;
17
+ const MAX_HEIGHT = 640;
18
+ const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
19
+ /**
20
+ * Wraps a rendered mermaid diagram in a zoom/pan viewport with a themed control cluster
21
+ * (bottom-right: a pan d-pad around a reset, plus zoom in/out) and an expand control
22
+ * (top-right) that opens the diagram in a fullscreen dialog. Drag-to-pan and wheel-to-zoom
23
+ * work too. Only the diagram layer clips; the controls sit above it, so a short diagram never
24
+ * hides them. Everything is a CSS transform — no dependency.
25
+ */
26
+ function DiagramViewer({ svg, expandable = true, fill = false }) {
27
+ const [scale, setScale] = (0, react.useState)(1);
28
+ const [offset, setOffset] = (0, react.useState)({
29
+ x: 0,
30
+ y: 0
31
+ });
32
+ const [dragging, setDragging] = (0, react.useState)(false);
33
+ const [fullscreen, setFullscreen] = (0, react.useState)(false);
34
+ const [naturalHeight, setNaturalHeight] = (0, react.useState)(0);
35
+ const dragOrigin = (0, react.useRef)(null);
36
+ const contentRef = (0, react.useRef)(null);
37
+ (0, react.useEffect)(() => {
38
+ setNaturalHeight(contentRef.current.offsetHeight);
39
+ }, [svg]);
40
+ const zoomBy = (delta) => setScale((current) => clamp(current + delta, MIN_SCALE, MAX_SCALE));
41
+ const panBy = (dx, dy) => setOffset((current) => ({
42
+ x: current.x + dx,
43
+ y: current.y + dy
44
+ }));
45
+ const reset = () => {
46
+ setScale(1);
47
+ setOffset({
48
+ x: 0,
49
+ y: 0
50
+ });
51
+ };
52
+ const closeFullscreen = () => setFullscreen(false);
53
+ const onWheel = (event) => {
54
+ event.preventDefault();
55
+ zoomBy(event.deltaY < 0 ? ZOOM_STEP : -.2);
56
+ };
57
+ const onMouseDown = (event) => {
58
+ dragOrigin.current = {
59
+ x: event.clientX - offset.x,
60
+ y: event.clientY - offset.y
61
+ };
62
+ setDragging(true);
63
+ };
64
+ const onMouseMove = (event) => {
65
+ if (!dragOrigin.current) return;
66
+ setOffset({
67
+ x: event.clientX - dragOrigin.current.x,
68
+ y: event.clientY - dragOrigin.current.y
69
+ });
70
+ };
71
+ const endDrag = () => {
72
+ dragOrigin.current = null;
73
+ setDragging(false);
74
+ };
75
+ const control = (label, icon, onClick) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Button.Button, {
76
+ type: "button",
77
+ variant: "outlined",
78
+ shape: "rounded",
79
+ size: "sm",
80
+ "aria-label": label,
81
+ onClick,
82
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Icon.Icon, {
83
+ name: icon,
84
+ size: "1.1rem"
85
+ })
86
+ }, label);
87
+ const inlineHeight = Math.max(MIN_HEIGHT, clamp(naturalHeight, MIN_HEIGHT, MAX_HEIGHT) * scale);
88
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_soroush_tech_design_system_View.View, {
89
+ my: fill ? 0 : 2,
90
+ position: "relative",
91
+ maxWidth: "100%",
92
+ borderRadius: "md",
93
+ height: fill ? "100%" : void 0,
94
+ children: [
95
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Flex.Flex, {
96
+ onWheel: fill ? onWheel : void 0,
97
+ onMouseDown,
98
+ onMouseMove,
99
+ onMouseUp: endDrag,
100
+ onMouseLeave: endDrag,
101
+ overflow: "hidden",
102
+ borderRadius: "md",
103
+ alignItems: "center",
104
+ justifyContent: "center",
105
+ height: fill ? "100%" : `${inlineHeight}px`,
106
+ style: {
107
+ cursor: dragging ? "grabbing" : "grab",
108
+ userSelect: "none",
109
+ WebkitUserSelect: "none"
110
+ },
111
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_View.View, {
112
+ ref: contentRef,
113
+ "data-testid": "diagram-transform",
114
+ style: {
115
+ transform: `translate(${offset.x}px, ${offset.y}px) scale(${scale})`,
116
+ transformOrigin: "center",
117
+ transition: dragging ? "none" : "transform 0.12s ease-out"
118
+ },
119
+ dangerouslySetInnerHTML: { __html: svg }
120
+ })
121
+ }),
122
+ expandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_View.View, {
123
+ position: "absolute",
124
+ top: 1,
125
+ right: 1,
126
+ zIndex: 1,
127
+ children: control("Expand diagram", "fullscreen", () => setFullscreen(true))
128
+ }),
129
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_soroush_tech_design_system_Grid.Grid, {
130
+ position: "absolute",
131
+ bottom: 1,
132
+ right: 1,
133
+ zIndex: 1,
134
+ gridTemplateColumns: "repeat(3, auto)",
135
+ gap: .5,
136
+ children: [
137
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { "aria-hidden": true }),
138
+ control("Pan up", "expand_less", () => panBy(0, -48)),
139
+ control("Zoom in", "zoom_in", () => zoomBy(ZOOM_STEP)),
140
+ control("Pan left", "chevron_left", () => panBy(-48, 0)),
141
+ control("Reset view", "refresh", reset),
142
+ control("Pan right", "chevron_right", () => panBy(PAN_STEP, 0)),
143
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { "aria-hidden": true }),
144
+ control("Pan down", "expand_more", () => panBy(0, PAN_STEP)),
145
+ control("Zoom out", "zoom_out", () => zoomBy(-.2))
146
+ ]
147
+ })
148
+ ]
149
+ }), expandable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Modal.Modal, {
150
+ isOpen: fullscreen,
151
+ onClose: closeFullscreen,
152
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_soroush_tech_design_system_Flex.Flex, {
153
+ bg: "paper",
154
+ role: "dialog",
155
+ "aria-label": "Diagram fullscreen",
156
+ position: "fixed",
157
+ top: 0,
158
+ right: 0,
159
+ bottom: 0,
160
+ left: 0,
161
+ p: 2,
162
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_View.View, {
163
+ position: "absolute",
164
+ top: 2,
165
+ right: 2,
166
+ zIndex: 1,
167
+ children: control("Close", "close", closeFullscreen)
168
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Flex.Flex, {
169
+ flex: 1,
170
+ minHeight: 0,
171
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DiagramViewer, {
172
+ svg,
173
+ expandable: false,
174
+ fill: true
175
+ })
176
+ })]
177
+ })
178
+ })] });
179
+ }
180
+ //#endregion
181
+ //#region src/Mermaid/Mermaid.tsx
182
+ async function toSvg(id, chart, theme) {
183
+ const { default: mermaid } = await import("mermaid");
184
+ mermaid.initialize({
185
+ startOnLoad: false,
186
+ securityLevel: "strict",
187
+ suppressErrorRendering: true,
188
+ theme: theme.colorScheme === "dark" ? "dark" : "default",
189
+ themeVariables: {
190
+ darkMode: theme.colorScheme === "dark",
191
+ background: theme.background.paper,
192
+ fontFamily: theme.fonts.body,
193
+ mainBkg: theme.background.primary,
194
+ ...theme.mermaid
195
+ }
196
+ });
197
+ const { svg } = await mermaid.render(id, chart);
198
+ return svg;
199
+ }
200
+ /**
201
+ * Renders a mermaid diagram. Until the client renders the SVG — and if the source is
202
+ * invalid — it falls back to the diagram source in a `CodeBlock`, so server output and
203
+ * no-JS readers still show something useful and hydration stays stable.
204
+ */
205
+ function Mermaid({ chart, diagram }) {
206
+ const theme = (0, _soroush_tech_design_system_theme.useTheme)();
207
+ const id = `mermaid-${(0, react.useId)().replace(/[^a-zA-Z0-9-]/g, "")}`;
208
+ const [svg, setSvg] = (0, react.useState)(null);
209
+ (0, react.useEffect)(() => {
210
+ let active = true;
211
+ toSvg(id, chart, theme).then((rendered) => {
212
+ if (active) setSvg(rendered);
213
+ }).catch(() => {
214
+ if (active) setSvg(null);
215
+ });
216
+ return () => {
217
+ active = false;
218
+ };
219
+ }, [
220
+ chart,
221
+ id,
222
+ theme
223
+ ]);
224
+ if (svg) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DiagramViewer, {
225
+ svg,
226
+ ...diagram
227
+ });
228
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock.CodeBlock, { children: chart });
229
+ }
230
+ //#endregion
231
+ Object.defineProperty(exports, "Mermaid", {
232
+ enumerable: true,
233
+ get: function() {
234
+ return Mermaid;
235
+ }
236
+ });
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_Mermaid = require("./Mermaid-DqP2Q0bt.cjs");
3
+ exports.Mermaid = require_Mermaid.Mermaid;
@@ -0,0 +1,2 @@
1
+ import { n as Mermaid, r as MermaidProps, t as DiagramProps } from "./index-BO0LyUUG.cjs";
2
+ export { DiagramProps, Mermaid, MermaidProps };
@@ -0,0 +1,2 @@
1
+ import { n as Mermaid, r as MermaidProps, t as DiagramProps } from "./index-BO0LyUUG.mjs";
2
+ export { DiagramProps, Mermaid, MermaidProps };
@@ -0,0 +1,2 @@
1
+ import { t as Mermaid } from "./Mermaid-BclI9A7e.mjs";
2
+ export { Mermaid };
@@ -0,0 +1,276 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ //#endregion
23
+ const require_CodeBlock = require("./CodeBlock-Cymx1ZAY.cjs");
24
+ const require_Mermaid = require("./Mermaid-DqP2Q0bt.cjs");
25
+ let react = require("react");
26
+ let react_jsx_runtime = require("react/jsx-runtime");
27
+ let _soroush_tech_design_system_Typography = require("@soroush.tech/design-system/Typography");
28
+ let _soroush_tech_design_system = require("@soroush.tech/design-system");
29
+ let react_markdown = require("react-markdown");
30
+ react_markdown = __toESM(react_markdown, 1);
31
+ let remark_gfm = require("remark-gfm");
32
+ remark_gfm = __toESM(remark_gfm, 1);
33
+ let rehype_highlight = require("rehype-highlight");
34
+ rehype_highlight = __toESM(rehype_highlight, 1);
35
+ let _soroush_tech_design_system_Quote = require("@soroush.tech/design-system/Quote");
36
+ let _soroush_tech_design_system_Checkbox = require("@soroush.tech/design-system/Checkbox");
37
+ let _soroush_tech_design_system_Image = require("@soroush.tech/design-system/Image");
38
+ let _soroush_tech_design_system_Link = require("@soroush.tech/design-system/Link");
39
+ let _soroush_tech_design_system_Table = require("@soroush.tech/design-system/Table");
40
+ let _soroush_tech_design_system_View = require("@soroush.tech/design-system/View");
41
+ function mermaidSource(children) {
42
+ return (Array.isArray(children) ? children.join("") : String(children ?? "")).replace(/\n$/, "");
43
+ }
44
+ function isMermaidBlock(children) {
45
+ if (!(0, react.isValidElement)(children)) return false;
46
+ const { className } = children.props;
47
+ return typeof className === "string" && className.includes("language-mermaid");
48
+ }
49
+ //#endregion
50
+ //#region src/Preview/Preview.tsx
51
+ const remarkPlugins = [remark_gfm.default];
52
+ const rehypePlugins = [[rehype_highlight.default, { ignoreMissing: true }]];
53
+ const PreviewRoot = (0, _soroush_tech_design_system.styled)(_soroush_tech_design_system_View.View, {
54
+ name: "MarkdownPreview",
55
+ label: "MarkdownPreview"
56
+ })({
57
+ minWidth: 0,
58
+ maxWidth: "100%",
59
+ overflowWrap: "break-word"
60
+ });
61
+ const EMPTY_SLOT_PROPS = {};
62
+ const SlotPropsContext = (0, react.createContext)(EMPTY_SLOT_PROPS);
63
+ function slotted(render) {
64
+ function Slotted(props) {
65
+ return render((0, react.useContext)(SlotPropsContext), props);
66
+ }
67
+ return Slotted;
68
+ }
69
+ const components = {
70
+ h1: slotted(({ h1 }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
71
+ mt: 2,
72
+ variant: "h1",
73
+ color: "primary",
74
+ gutterBottom: true,
75
+ ...h1,
76
+ children
77
+ })),
78
+ h2: slotted(({ h2 }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
79
+ mt: 2,
80
+ variant: "h2",
81
+ color: "primary",
82
+ gutterBottom: true,
83
+ ...h2,
84
+ children
85
+ })),
86
+ h3: slotted(({ h3 }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
87
+ mt: 2,
88
+ variant: "h3",
89
+ color: "primary",
90
+ gutterBottom: true,
91
+ ...h3,
92
+ children
93
+ })),
94
+ h4: slotted(({ h4 }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
95
+ mt: 2,
96
+ variant: "h4",
97
+ gutterBottom: true,
98
+ ...h4,
99
+ children
100
+ })),
101
+ h5: slotted(({ h5 }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
102
+ mt: 2,
103
+ variant: "h5",
104
+ gutterBottom: true,
105
+ ...h5,
106
+ children
107
+ })),
108
+ h6: slotted(({ h6 }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
109
+ mt: 2,
110
+ variant: "h6",
111
+ gutterBottom: true,
112
+ ...h6,
113
+ children
114
+ })),
115
+ p: slotted(({ p }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
116
+ variant: "body1",
117
+ color: "secondary",
118
+ mb: 2,
119
+ lineHeight: "relaxed",
120
+ ...p,
121
+ children
122
+ })),
123
+ a: slotted(({ a }, { href, children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Link.Link, {
124
+ href,
125
+ underline: "hover",
126
+ ...a,
127
+ children
128
+ })),
129
+ strong: slotted(({ strong }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
130
+ as: "strong",
131
+ variant: "inherit",
132
+ fontWeight: "extraBold",
133
+ ...strong,
134
+ children
135
+ })),
136
+ em: slotted(({ em }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
137
+ as: "em",
138
+ variant: "inherit",
139
+ fontStyle: "italic",
140
+ ...em,
141
+ children
142
+ })),
143
+ ul: slotted(({ ul }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_View.View, {
144
+ as: "ul",
145
+ pl: 3,
146
+ mb: 2,
147
+ ...ul,
148
+ children
149
+ })),
150
+ ol: slotted(({ ol }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_View.View, {
151
+ as: "ol",
152
+ pl: 3,
153
+ mb: 2,
154
+ ...ol,
155
+ children
156
+ })),
157
+ li: slotted(({ li }, { children, className }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
158
+ as: "li",
159
+ color: "secondary",
160
+ lineHeight: "base",
161
+ variant: "body1",
162
+ gutterBottom: true,
163
+ style: className?.includes("task-list-item") ? { listStyleType: "none" } : void 0,
164
+ ...li,
165
+ children
166
+ })),
167
+ input: slotted(({ input }, { checked }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Checkbox.Checkbox, {
168
+ checked: Boolean(checked),
169
+ disabled: true,
170
+ color: "primary",
171
+ size: "sm",
172
+ "aria-label": "Task item",
173
+ mr: 1,
174
+ ...input
175
+ })),
176
+ blockquote: slotted(({ blockquote }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Quote.Quote, {
177
+ as: "blockquote",
178
+ pl: 3,
179
+ py: 1,
180
+ my: 2,
181
+ ...blockquote,
182
+ children
183
+ })),
184
+ code: slotted(({ code, mermaid }, { className, children }) => {
185
+ const classes = className ?? "";
186
+ if (classes.includes("language-mermaid")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Mermaid.Mermaid, {
187
+ chart: mermaidSource(children),
188
+ ...mermaid
189
+ });
190
+ const isBlock = classes.includes("language-");
191
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Typography.Typography, {
192
+ as: "code",
193
+ color: "initial",
194
+ variant: "inherit",
195
+ fontFamily: "mono",
196
+ display: isBlock ? "block" : "inline",
197
+ bg: isBlock ? "transparent" : "paper",
198
+ px: isBlock ? 0 : 1,
199
+ borderRadius: "sm",
200
+ ...code,
201
+ children
202
+ });
203
+ }),
204
+ pre: slotted(({ pre }, { children }) => isMermaidBlock(children) ? children : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_CodeBlock.CodeBlock, {
205
+ ...pre,
206
+ children
207
+ })),
208
+ table: slotted(({ table }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Table.TableContainer, {
209
+ my: 2,
210
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Table.Table, {
211
+ bg: "terminal",
212
+ borderRadius: "md",
213
+ ...table,
214
+ children
215
+ })
216
+ })),
217
+ thead: slotted(({ thead }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Table.TableHead, {
218
+ bg: "grid",
219
+ color: "primary",
220
+ ...thead,
221
+ children
222
+ })),
223
+ tbody: slotted(({ tbody }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Table.TableBody, {
224
+ ...tbody,
225
+ children
226
+ })),
227
+ tr: slotted(({ tr }, { children }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Table.TableRow, {
228
+ isHoverable: true,
229
+ ...tr,
230
+ children
231
+ })),
232
+ th: slotted(({ th }, { children, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Table.TableCell, {
233
+ style,
234
+ ...th,
235
+ children
236
+ })),
237
+ td: slotted(({ td }, { children, style }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Table.TableCell, {
238
+ style,
239
+ ...td,
240
+ children
241
+ })),
242
+ hr: slotted(({ hr }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_View.View, {
243
+ as: "hr",
244
+ my: 2,
245
+ height: "1px",
246
+ bg: "grid",
247
+ width: "100%",
248
+ border: "none",
249
+ ...hr
250
+ })),
251
+ img: slotted(({ img }, { src, alt }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_soroush_tech_design_system_Image.Image, {
252
+ src,
253
+ alt,
254
+ maxWidth: "100%",
255
+ ...img
256
+ }))
257
+ };
258
+ /** Renders a markdown string with every element mapped to a design-system primitive. */
259
+ function Preview({ children, slotProps }) {
260
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PreviewRoot, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SlotPropsContext.Provider, {
261
+ value: slotProps ?? EMPTY_SLOT_PROPS,
262
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_markdown.default, {
263
+ components,
264
+ remarkPlugins,
265
+ rehypePlugins,
266
+ children
267
+ })
268
+ }) });
269
+ }
270
+ //#endregion
271
+ Object.defineProperty(exports, "Preview", {
272
+ enumerable: true,
273
+ get: function() {
274
+ return Preview;
275
+ }
276
+ });