@karimsa/mdxserve 0.3.0 → 0.5.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 (69) hide show
  1. package/README.md +80 -10
  2. package/client/App.tsx +15 -1
  3. package/client/CodeBlock.tsx +24 -0
  4. package/client/DocView.tsx +9 -2
  5. package/client/ListingView.tsx +14 -10
  6. package/client/MarkdownTable.tsx +190 -0
  7. package/client/MdSection.tsx +63 -23
  8. package/client/MdSectionEditor.tsx +208 -2
  9. package/client/Mermaid.tsx +33 -7
  10. package/client/Settings.css +17 -0
  11. package/client/Settings.tsx +132 -0
  12. package/client/Table.tsx +2 -14
  13. package/client/app.css +341 -1
  14. package/client/block-state/README.md +39 -0
  15. package/client/block-state/storage.ts +73 -0
  16. package/client/block-state/useBlockState.ts +120 -0
  17. package/client/builtins/DataTable.tsx +269 -0
  18. package/client/builtins/chart-data.ts +22 -10
  19. package/client/builtins/index.ts +10 -0
  20. package/client/data-table/ColumnMenu.tsx +168 -0
  21. package/client/data-table/ColumnOptions.tsx +141 -0
  22. package/client/data-table/TableCell.tsx +76 -0
  23. package/client/data-table/TableHeaderCell.tsx +94 -0
  24. package/client/data-table/model.ts +194 -0
  25. package/client/data-table/navigation.ts +34 -0
  26. package/client/data-table/table-state.ts +196 -0
  27. package/client/data-table/useColumnMenu.ts +84 -0
  28. package/client/data-table/useTableState.ts +36 -0
  29. package/client/design/base/editor.css +59 -0
  30. package/client/design/base/prose.css +4 -0
  31. package/client/diagrams/Dialog.tsx +577 -0
  32. package/client/diagrams/EditDialog.tsx +67 -0
  33. package/client/diagrams/Preferences.tsx +213 -0
  34. package/client/diagrams/edit-block.ts +93 -0
  35. package/client/diagrams/edit-context.ts +4 -0
  36. package/client/diagrams/session-id.ts +8 -0
  37. package/client/diagrams/source.ts +73 -0
  38. package/client/diagrams/style.css +580 -0
  39. package/client/doc-module-cache.ts +9 -1
  40. package/client/editor/ImageDialog.tsx +69 -0
  41. package/client/editor/LinkDialog.tsx +60 -0
  42. package/client/editor/blocks.ts +295 -0
  43. package/client/editor/component-fields.css +57 -0
  44. package/client/editor/component-fields.ts +128 -0
  45. package/client/editor/image-dialog.css +44 -0
  46. package/client/editor/mdx-block.tsx +138 -0
  47. package/client/editor/slash.ts +166 -0
  48. package/client/entry.tsx +2 -0
  49. package/client/head-metadata.ts +32 -0
  50. package/client/mdx-components-base.ts +2 -2
  51. package/client/router.ts +56 -17
  52. package/client/shell/AppShell.tsx +38 -15
  53. package/client/shell/Sidebar.tsx +20 -2
  54. package/client/shell/StandaloneShell.tsx +19 -6
  55. package/client/shell/TocRail.tsx +4 -3
  56. package/client/shell/TopBar.tsx +17 -5
  57. package/client/standalone-entry.tsx +11 -2
  58. package/client/state.ts +14 -0
  59. package/client/ui/ConfirmDeleteDialog.tsx +48 -91
  60. package/client/ui/ExpandModal.tsx +63 -104
  61. package/client/ui/Modal.tsx +123 -0
  62. package/client/ui/ResizeHandle.tsx +1 -1
  63. package/client/ui/SearchDialog.tsx +81 -88
  64. package/client/ui/modal.css +42 -0
  65. package/dist/cli.js +4644 -2830
  66. package/dist/diagram-worker.js +17 -0
  67. package/dist/registry.json +297 -0
  68. package/package.json +44 -3
  69. package/skills/mdxserve/SKILL.md +56 -1
@@ -1,4 +1,24 @@
1
- import { useEffect, useState, type KeyboardEvent, type MouseEvent } from "react";
1
+ import {
2
+ findDiagram,
3
+ replaceDiagram,
4
+ mermaidEditButtons,
5
+ type DiagramEditTarget,
6
+ } from "./diagrams/edit-block";
7
+ import type { ExistingDiagram } from "./diagrams/edit-context";
8
+ import { blockSlash } from "./editor/slash";
9
+ import { MdxBlock } from "./editor/mdx-block";
10
+ import { ImageDialog } from "./editor/ImageDialog";
11
+ import { LinkDialog } from "./editor/LinkDialog";
12
+ import { MermaidDialog } from "./diagrams/Dialog";
13
+ import type { Range } from "@tiptap/core";
14
+ import {
15
+ useEffect,
16
+ useState,
17
+ useRef,
18
+ useCallback,
19
+ type KeyboardEvent,
20
+ type MouseEvent,
21
+ } from "react";
2
22
  import type { Editor } from "@tiptap/core";
3
23
  import type { Mark } from "@tiptap/pm/model";
4
24
  import { EditorContent, useEditor } from "@tiptap/react";
@@ -7,7 +27,7 @@ import { TaskItem, TaskList } from "@tiptap/extension-list";
7
27
  import { TableKit } from "@tiptap/extension-table";
8
28
  import { Image } from "@tiptap/extension-image";
9
29
  import { Markdown } from "@tiptap/markdown";
10
- import { motion } from "framer-motion";
30
+ import { AnimatePresence, motion } from "framer-motion";
11
31
  import { isTRPCClientError } from "@trpc/client";
12
32
  import { trpcClient } from "./api";
13
33
  import { TRANSITIONS } from "./motion";
@@ -25,6 +45,7 @@ const hint = {
25
45
  };
26
46
 
27
47
  export interface MdSectionEditorProps {
48
+ initialDiagram?: ExistingDiagram;
28
49
  /** Raw markdown for exactly [startLine, endLine], sliced by MdSection.tsx. */
29
50
  source: string;
30
51
  /** Version token for the whole file at the moment `source` was fetched — the save's stale-write guard. */
@@ -81,6 +102,7 @@ function unwrapSoftBreaks(editor: Editor): void {
81
102
  * `@tiptap/extension-link` install is needed to configure `link`.
82
103
  */
83
104
  export default function MdSectionEditor({
105
+ initialDiagram,
84
106
  source,
85
107
  version,
86
108
  path,
@@ -89,6 +111,41 @@ export default function MdSectionEditor({
89
111
  onDone,
90
112
  }: MdSectionEditorProps) {
91
113
  const [saving, setSaving] = useState(false);
114
+ const diagramEnabled = useRef(false);
115
+ const [diagramReady, setDiagramReady] = useState(false);
116
+ const [editTarget, setEditTarget] = useState<DiagramEditTarget | null>(null);
117
+ const openedDiagram = useRef(false);
118
+ const [diagramRange, setDiagramRange] = useState<Range | null>(null);
119
+ const [imageRange, setImageRange] = useState<Range | null>(null);
120
+ const [linkRange, setLinkRange] = useState<Range | null>(null);
121
+ const openDiagram = useRef<(range: Range) => void>(() => {});
122
+ openDiagram.current = setDiagramRange;
123
+ useEffect(() => {
124
+ let active = true;
125
+ const refresh = () => {
126
+ void trpcClient.getDiagramPreferences
127
+ .query({})
128
+ .then((settings) => {
129
+ if (active) {
130
+ diagramEnabled.current = settings.agent !== "disabled";
131
+ setDiagramReady(diagramEnabled.current);
132
+ if (!diagramEnabled.current) {
133
+ setDiagramRange(null);
134
+ setEditTarget(null);
135
+ }
136
+ }
137
+ })
138
+ .catch(() => {
139
+ diagramEnabled.current = false;
140
+ });
141
+ };
142
+ refresh();
143
+ window.addEventListener("mdxserve-diagram-preferences", refresh);
144
+ return () => {
145
+ active = false;
146
+ window.removeEventListener("mdxserve-diagram-preferences", refresh);
147
+ };
148
+ }, []);
92
149
  // Drives the hints' entrance. Not framer's `initial`/`animate` on mount:
93
150
  // this component mounts through Suspense inside a transition, and its
94
151
  // first commit can happen while the subtree is still hidden, so a
@@ -99,6 +156,14 @@ export default function MdSectionEditor({
99
156
 
100
157
  const editor = useEditor({
101
158
  extensions: [
159
+ mermaidEditButtons(() => diagramEnabled.current, setEditTarget),
160
+ blockSlash(
161
+ () => diagramEnabled.current,
162
+ (range) => openDiagram.current(range),
163
+ setImageRange,
164
+ setLinkRange,
165
+ ),
166
+ MdxBlock,
102
167
  StarterKit.configure({
103
168
  heading: { levels: [1, 2, 3, 4, 5, 6] },
104
169
  link: { openOnClick: false },
@@ -131,6 +196,44 @@ export default function MdSectionEditor({
131
196
  setEntered(true);
132
197
  }, [editor]);
133
198
 
199
+ useEffect(() => {
200
+ if (!editor || editor.isDestroyed || !initialDiagram || openedDiagram.current) return;
201
+ openedDiagram.current = true;
202
+ const target = findDiagram(editor, initialDiagram);
203
+ if (target) setEditTarget(target);
204
+ else
205
+ pushToast({
206
+ tone: "warn",
207
+ text: "Diagram changed on disk. Reopen the section before editing.",
208
+ });
209
+ }, [editor, initialDiagram]);
210
+
211
+ useEffect(() => {
212
+ if (!editor || editor.isDestroyed || !diagramReady || openedDiagram.current) return;
213
+ openedDiagram.current = true;
214
+ const document = editor.state.doc;
215
+ const block = document.firstChild;
216
+ // Tiptap adds an empty trailing paragraph after a code block.
217
+ const onlyDiagram =
218
+ document.childCount === 1 ||
219
+ (document.childCount === 2 &&
220
+ document.lastChild?.type.name === "paragraph" &&
221
+ document.lastChild.content.size === 0);
222
+ if (onlyDiagram && block?.type.name === "codeBlock" && block.attrs.language === "mermaid") {
223
+ setEditTarget({ range: { from: 0, to: block.nodeSize }, source: block.textContent });
224
+ }
225
+ }, [editor, diagramReady]);
226
+
227
+ useEffect(() => {
228
+ if (editor && !editor.isDestroyed) editor.view.dispatch(editor.state.tr);
229
+ }, [editor, diagramReady]);
230
+
231
+ const closeDiagram = useCallback(() => {
232
+ setDiagramRange(null);
233
+ setEditTarget(null);
234
+ editor?.commands.focus();
235
+ }, [editor]);
236
+
134
237
  async function save() {
135
238
  if (!editor || saving) return;
136
239
  setSaving(true);
@@ -187,6 +290,7 @@ export default function MdSectionEditor({
187
290
  }
188
291
 
189
292
  function onKeyDown(event: KeyboardEvent<HTMLDivElement>) {
293
+ if (diagramRange || editTarget || imageRange || linkRange) return;
190
294
  if ((event.metaKey || event.ctrlKey) && event.key === "s") {
191
295
  event.preventDefault();
192
296
  void save();
@@ -207,6 +311,105 @@ export default function MdSectionEditor({
207
311
  return (
208
312
  <div className="mdx-section" data-editing onClick={onClick} onKeyDown={onKeyDown}>
209
313
  <EditorContent editor={editor} />
314
+ {linkRange && (
315
+ <LinkDialog
316
+ onClose={() => {
317
+ setLinkRange(null);
318
+ editor.commands.focus();
319
+ }}
320
+ onInsert={({ href, text }) => {
321
+ if (linkRange.to > editor.state.doc.content.size) return;
322
+ editor
323
+ .chain()
324
+ .focus()
325
+ .insertContentAt(linkRange, {
326
+ type: "text",
327
+ text,
328
+ marks: [{ type: "link", attrs: { href } }],
329
+ })
330
+ .run();
331
+ setLinkRange(null);
332
+ }}
333
+ />
334
+ )}
335
+ {imageRange && (
336
+ <ImageDialog
337
+ onClose={() => {
338
+ setImageRange(null);
339
+ editor.commands.focus();
340
+ }}
341
+ onInsert={(attrs) => {
342
+ if (imageRange.to > editor.state.doc.content.size) return;
343
+ const position = editor.state.doc.resolve(imageRange.from);
344
+ if (
345
+ position.parent.type.name !== "paragraph" ||
346
+ position.parent.textContent !==
347
+ editor.state.doc.textBetween(imageRange.from, imageRange.to)
348
+ )
349
+ return;
350
+ editor
351
+ .chain()
352
+ .focus()
353
+ .insertContentAt({ from: position.before(), to: position.after() }, [
354
+ { type: "image", attrs },
355
+ { type: "paragraph" },
356
+ ])
357
+ .run();
358
+ setImageRange(null);
359
+ }}
360
+ />
361
+ )}
362
+ <AnimatePresence>
363
+ {(diagramRange || editTarget) && (
364
+ <MermaidDialog
365
+ initialSource={editTarget?.source}
366
+ onClose={closeDiagram}
367
+ onInsert={(source) => {
368
+ if (editTarget) {
369
+ if (!replaceDiagram(editor, editTarget, source)) {
370
+ pushToast({
371
+ tone: "warn",
372
+ text: "Diagram changed. Reopen it before applying changes.",
373
+ });
374
+ return;
375
+ }
376
+ closeDiagram();
377
+ return;
378
+ }
379
+ if (!diagramRange) return;
380
+ if (diagramRange.to > editor.state.doc.content.size) {
381
+ closeDiagram();
382
+ return;
383
+ }
384
+ const from = editor.state.doc.resolve(diagramRange.from);
385
+ if (
386
+ from.parent.type.name !== "paragraph" ||
387
+ from.parent.textContent !==
388
+ editor.state.doc.textBetween(diagramRange.from, diagramRange.to)
389
+ ) {
390
+ pushToast({
391
+ tone: "warn",
392
+ text: "Insertion location changed. Close the dialog and choose a new block.",
393
+ });
394
+ return;
395
+ }
396
+ editor
397
+ .chain()
398
+ .focus()
399
+ .insertContentAt(
400
+ { from: from.before(), to: from.after() },
401
+ {
402
+ type: "codeBlock",
403
+ attrs: { language: "mermaid" },
404
+ content: [{ type: "text", text: source }],
405
+ },
406
+ )
407
+ .run();
408
+ closeDiagram();
409
+ }}
410
+ />
411
+ )}
412
+ </AnimatePresence>
210
413
  {/* Keyboard is the only way out of edit mode (no buttons), so the hints
211
414
  float in the right gutter beside the frame, out of the text flow —
212
415
  the section keeps its read-mode box exactly. pointer-events-none so
@@ -218,6 +421,9 @@ export default function MdSectionEditor({
218
421
  initial="initial"
219
422
  animate={entered ? "animate" : "initial"}
220
423
  >
424
+ <motion.span variants={hint} className="flex items-center gap-1.5">
425
+ <Kbd>/</Kbd> to add a block
426
+ </motion.span>
221
427
  <motion.span variants={hint} className="flex items-center gap-1.5">
222
428
  <Kbd>{isApplePlatform() ? "⌘S" : "Ctrl S"}</Kbd> to save
223
429
  </motion.span>
@@ -131,7 +131,17 @@ function useThemeTick(): number {
131
131
  * mirrored into the expanded modal's header so view controls that live in the
132
132
  * code frame (the flow-direction toggle) stay reachable at full size.
133
133
  */
134
- export function MermaidDiagram({ source, toolbar }: { source: string; toolbar?: ReactNode }) {
134
+ export function MermaidDiagram({
135
+ source,
136
+ toolbar,
137
+ onRender,
138
+ fill = false,
139
+ }: {
140
+ source: string;
141
+ toolbar?: ReactNode;
142
+ onRender?: (source: string, valid: boolean) => void;
143
+ fill?: boolean;
144
+ }) {
135
145
  // Seeded from the source so a chart-diagram fence never shows the
136
146
  // "Rendering diagram…" placeholder — there is nothing to load for it.
137
147
  const [state, setState] = useState<State>(() => {
@@ -177,7 +187,10 @@ export function MermaidDiagram({ source, toolbar }: { source: string; toolbar?:
177
187
  return mermaid.render(renderId, source);
178
188
  })
179
189
  .then(({ svg }) => {
180
- if (!cancelled) setState({ kind: "ok", svg });
190
+ if (!cancelled) {
191
+ setState({ kind: "ok", svg });
192
+ onRender?.(source, true);
193
+ }
181
194
  })
182
195
  .catch((error: unknown) => {
183
196
  // mermaid.render() draws into a temporary `<div id="d<renderId>">` it
@@ -191,11 +204,12 @@ export function MermaidDiagram({ source, toolbar }: { source: string; toolbar?:
191
204
  if (cancelled) return;
192
205
  const message = error instanceof Error ? error.message : String(error);
193
206
  setState({ kind: "error", message });
207
+ onRender?.(source, false);
194
208
  });
195
209
  return () => {
196
210
  cancelled = true;
197
211
  };
198
- }, [source, id, themeTick]);
212
+ }, [source, id, themeTick, onRender]);
199
213
 
200
214
  return (
201
215
  <AnimatePresence mode="wait" initial={false}>
@@ -230,8 +244,12 @@ export function MermaidDiagram({ source, toolbar }: { source: string; toolbar?:
230
244
  </DiagramNoticeBody>
231
245
  </motion.div>
232
246
  ) : (
233
- <motion.div key="ok" {...VARIANTS.fade}>
234
- <ExpandableDiagram svg={state.svg} toolbar={toolbar} />
247
+ <motion.div key="ok" {...VARIANTS.fade} className={fill ? "h-full w-full" : undefined}>
248
+ {fill ? (
249
+ <PanZoomSvg svg={state.svg} viewportClassName="h-full" />
250
+ ) : (
251
+ <ExpandableDiagram svg={state.svg} toolbar={toolbar} />
252
+ )}
235
253
  </motion.div>
236
254
  )}
237
255
  </AnimatePresence>
@@ -384,6 +402,7 @@ function PanZoomSvg({
384
402
  */
385
403
  function ExpandableDiagram({ svg, toolbar }: { svg: string; toolbar?: ReactNode }) {
386
404
  const [expanded, setExpanded] = useState(false);
405
+ const [closing, setClosing] = useState(false);
387
406
  return (
388
407
  <>
389
408
  {/* Only one copy of the markup is live at a time. Mermaid doesn't namespace
@@ -392,7 +411,7 @@ function ExpandableDiagram({ svg, toolbar }: { svg: string; toolbar?: ReactNode
392
411
  SVG — the one svg-pan-zoom has already wrapped and transformed. The
393
412
  card sits behind the scrim while expanded, so the placeholder that
394
413
  holds its height never shows. */}
395
- {expanded ? (
414
+ {expanded || closing ? (
396
415
  <div className="h-96 w-full" aria-hidden="true" />
397
416
  ) : (
398
417
  <PanZoomSvg svg={svg} viewportClassName="h-96" onExpand={() => setExpanded(true)} />
@@ -401,7 +420,11 @@ function ExpandableDiagram({ svg, toolbar }: { svg: string; toolbar?: ReactNode
401
420
  open={expanded}
402
421
  svg={svg}
403
422
  toolbar={toolbar}
404
- onClose={() => setExpanded(false)}
423
+ onClose={() => {
424
+ setClosing(true);
425
+ setExpanded(false);
426
+ }}
427
+ onExitComplete={() => setClosing(false)}
405
428
  />
406
429
  </>
407
430
  );
@@ -412,16 +435,19 @@ function DiagramModal({
412
435
  svg,
413
436
  toolbar,
414
437
  onClose,
438
+ onExitComplete,
415
439
  }: {
416
440
  open: boolean;
417
441
  svg: string;
418
442
  toolbar?: ReactNode;
419
443
  onClose: () => void;
444
+ onExitComplete: () => void;
420
445
  }) {
421
446
  return (
422
447
  <ExpandModal
423
448
  open={open}
424
449
  onClose={onClose}
450
+ onExitComplete={onExitComplete}
425
451
  icon="image"
426
452
  title="Diagram"
427
453
  hint="Drag to pan · scroll to zoom"
@@ -0,0 +1,17 @@
1
+ @media (max-width: 639px) {
2
+ .diagram-settings .diagram-settings-body section {
3
+ padding: 20px;
4
+ }
5
+
6
+ .diagram-settings .diagram-setting-row {
7
+ flex-direction: column;
8
+ align-items: stretch;
9
+ gap: 10px;
10
+ }
11
+
12
+ .diagram-settings .diagram-setting-row .diagram-agent-select,
13
+ .diagram-settings .diagram-setting-row select {
14
+ width: 100%;
15
+ min-width: 0;
16
+ }
17
+ }
@@ -0,0 +1,132 @@
1
+ import { useAtom } from "jotai";
2
+ import { useState, type ReactNode } from "react";
3
+ import ChevronDown from "lucide-react/dist/esm/icons/chevron-down.mjs";
4
+ import Network from "lucide-react/dist/esm/icons/network.mjs";
5
+ import PanelsTopLeft from "lucide-react/dist/esm/icons/panels-top-left.mjs";
6
+ import SettingsIcon from "lucide-react/dist/esm/icons/settings.mjs";
7
+ import CloseIcon from "lucide-react/dist/esm/icons/x.mjs";
8
+ import { contentLayoutAtom, tocVisibleAtom, type ContentLayout } from "./state";
9
+ import { Modal } from "./ui/Modal";
10
+
11
+ export function Settings({
12
+ onClose,
13
+ diagrams,
14
+ status,
15
+ saving = false,
16
+ }: {
17
+ onClose: () => void;
18
+ diagrams?: ReactNode;
19
+ status?: ReactNode;
20
+ saving?: boolean;
21
+ }) {
22
+ const [category, setCategory] = useState<"diagrams" | "layout">(diagrams ? "diagrams" : "layout");
23
+ const [layout, setLayout] = useAtom(contentLayoutAtom);
24
+ const [tocVisible, setTocVisible] = useAtom(tocVisibleAtom);
25
+ return (
26
+ <Modal
27
+ open
28
+ onClose={onClose}
29
+ dismissible={!saving}
30
+ className="diagram-dialog diagram-settings"
31
+ aria-label="Settings"
32
+ >
33
+ <header className="diagram-navbar">
34
+ <div className="diagram-title">
35
+ <SettingsIcon size={17} />
36
+ <h2>Settings</h2>
37
+ </div>
38
+ <button
39
+ type="button"
40
+ className="diagram-icon-button"
41
+ aria-label="Close settings"
42
+ disabled={saving}
43
+ onClick={onClose}
44
+ >
45
+ <CloseIcon size={18} />
46
+ </button>
47
+ </header>
48
+ <div className="diagram-settings-body">
49
+ <aside>
50
+ <button
51
+ type="button"
52
+ className="diagram-settings-category"
53
+ aria-pressed={category === "layout"}
54
+ onClick={() => setCategory("layout")}
55
+ >
56
+ <PanelsTopLeft size={15} />
57
+ Layout
58
+ </button>
59
+ {diagrams && (
60
+ <button
61
+ type="button"
62
+ className="diagram-settings-category"
63
+ aria-pressed={category === "diagrams"}
64
+ onClick={() => setCategory("diagrams")}
65
+ >
66
+ <Network size={15} />
67
+ Diagrams
68
+ </button>
69
+ )}
70
+ </aside>
71
+ {category === "layout" ? (
72
+ <section>
73
+ <h3>Layout</h3>
74
+ <p>Choose how content fills the available space.</p>
75
+ <label className="diagram-setting-row" htmlFor="content-layout">
76
+ <span>
77
+ <strong>Content layout</strong>
78
+ <small>
79
+ {layout === "flexible"
80
+ ? "Drag the bars to resize content."
81
+ : "Content automatically fills the available width."}
82
+ </small>
83
+ </span>
84
+ <span className="diagram-agent-select">
85
+ <select
86
+ id="content-layout"
87
+ value={layout}
88
+ onChange={(event) => setLayout(event.target.value as ContentLayout)}
89
+ >
90
+ <option value="flexible">Flexible</option>
91
+ <option value="full-width">Full width</option>
92
+ </select>
93
+ <ChevronDown size={14} aria-hidden="true" />
94
+ </span>
95
+ </label>
96
+ <label className="diagram-setting-row" htmlFor="toc-visibility">
97
+ <span>
98
+ <strong>Table of contents</strong>
99
+ <small>Show the “On this page” navigation beside documents.</small>
100
+ </span>
101
+ <span className="diagram-agent-select">
102
+ <select
103
+ id="toc-visibility"
104
+ value={tocVisible ? "visible" : "hidden"}
105
+ onChange={(event) => setTocVisible(event.target.value === "visible")}
106
+ >
107
+ <option value="visible">Visible</option>
108
+ <option value="hidden">Hidden</option>
109
+ </select>
110
+ <ChevronDown size={14} aria-hidden="true" />
111
+ </span>
112
+ </label>
113
+ </section>
114
+ ) : (
115
+ diagrams
116
+ )}
117
+ </div>
118
+ <footer className="diagram-settings-footer">
119
+ <span>
120
+ {category === "layout" ? (
121
+ "Saved in this browser."
122
+ ) : (
123
+ <>
124
+ Also available through <code>mdxserve setup</code>
125
+ </>
126
+ )}
127
+ </span>
128
+ {status ?? <span role="status">Settings save automatically.</span>}
129
+ </footer>
130
+ </Modal>
131
+ );
132
+ }
package/client/Table.tsx CHANGED
@@ -1,14 +1,2 @@
1
- import type { TableHTMLAttributes } from "react";
2
-
3
- /**
4
- * MDXProvider `table` override. Tables with long cells (paths, code) can't
5
- * shrink below their content, so without this they'd overflow the prose column
6
- * and run under the TOC rail. Each table scrolls inside its own container.
7
- */
8
- export function Table(props: TableHTMLAttributes<HTMLTableElement>) {
9
- return (
10
- <div className="mdx-table-scroll">
11
- <table {...props} />
12
- </div>
13
- );
14
- }
1
+ // Compatibility export; native Markdown tables use the shared DataTable renderer.
2
+ export { MarkdownTable as Table } from "./MarkdownTable";