@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.
- package/README.md +80 -10
- package/client/App.tsx +15 -1
- package/client/CodeBlock.tsx +24 -0
- package/client/DocView.tsx +9 -2
- package/client/ListingView.tsx +14 -10
- package/client/MarkdownTable.tsx +190 -0
- package/client/MdSection.tsx +63 -23
- package/client/MdSectionEditor.tsx +208 -2
- package/client/Mermaid.tsx +33 -7
- package/client/Settings.css +17 -0
- package/client/Settings.tsx +132 -0
- package/client/Table.tsx +2 -14
- package/client/app.css +341 -1
- package/client/block-state/README.md +39 -0
- package/client/block-state/storage.ts +73 -0
- package/client/block-state/useBlockState.ts +120 -0
- package/client/builtins/DataTable.tsx +269 -0
- package/client/builtins/chart-data.ts +22 -10
- package/client/builtins/index.ts +10 -0
- package/client/data-table/ColumnMenu.tsx +168 -0
- package/client/data-table/ColumnOptions.tsx +141 -0
- package/client/data-table/TableCell.tsx +76 -0
- package/client/data-table/TableHeaderCell.tsx +94 -0
- package/client/data-table/model.ts +194 -0
- package/client/data-table/navigation.ts +34 -0
- package/client/data-table/table-state.ts +196 -0
- package/client/data-table/useColumnMenu.ts +84 -0
- package/client/data-table/useTableState.ts +36 -0
- package/client/design/base/editor.css +59 -0
- package/client/design/base/prose.css +4 -0
- package/client/diagrams/Dialog.tsx +577 -0
- package/client/diagrams/EditDialog.tsx +67 -0
- package/client/diagrams/Preferences.tsx +213 -0
- package/client/diagrams/edit-block.ts +93 -0
- package/client/diagrams/edit-context.ts +4 -0
- package/client/diagrams/session-id.ts +8 -0
- package/client/diagrams/source.ts +73 -0
- package/client/diagrams/style.css +580 -0
- package/client/doc-module-cache.ts +9 -1
- package/client/editor/ImageDialog.tsx +69 -0
- package/client/editor/LinkDialog.tsx +60 -0
- package/client/editor/blocks.ts +295 -0
- package/client/editor/component-fields.css +57 -0
- package/client/editor/component-fields.ts +128 -0
- package/client/editor/image-dialog.css +44 -0
- package/client/editor/mdx-block.tsx +138 -0
- package/client/editor/slash.ts +166 -0
- package/client/entry.tsx +2 -0
- package/client/head-metadata.ts +32 -0
- package/client/mdx-components-base.ts +2 -2
- package/client/router.ts +56 -17
- package/client/shell/AppShell.tsx +38 -15
- package/client/shell/Sidebar.tsx +20 -2
- package/client/shell/StandaloneShell.tsx +19 -6
- package/client/shell/TocRail.tsx +4 -3
- package/client/shell/TopBar.tsx +17 -5
- package/client/standalone-entry.tsx +11 -2
- package/client/state.ts +14 -0
- package/client/ui/ConfirmDeleteDialog.tsx +48 -91
- package/client/ui/ExpandModal.tsx +63 -104
- package/client/ui/Modal.tsx +123 -0
- package/client/ui/ResizeHandle.tsx +1 -1
- package/client/ui/SearchDialog.tsx +81 -88
- package/client/ui/modal.css +42 -0
- package/dist/cli.js +4644 -2830
- package/dist/diagram-worker.js +17 -0
- package/dist/registry.json +297 -0
- package/package.json +44 -3
- package/skills/mdxserve/SKILL.md +56 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Modal } from "./Modal";
|
|
1
2
|
import {
|
|
2
3
|
useEffect,
|
|
3
4
|
useState,
|
|
@@ -5,10 +6,10 @@ import {
|
|
|
5
6
|
type KeyboardEvent,
|
|
6
7
|
type ReactNode,
|
|
7
8
|
} from "react";
|
|
8
|
-
import {
|
|
9
|
+
import { motion, type MotionProps } from "framer-motion";
|
|
9
10
|
import { Icon } from "./Icon";
|
|
10
11
|
import { Kbd } from "./Kbd";
|
|
11
|
-
import { TRANSITIONS
|
|
12
|
+
import { TRANSITIONS } from "../motion";
|
|
12
13
|
|
|
13
14
|
export interface SearchResult {
|
|
14
15
|
title: ReactNode;
|
|
@@ -49,7 +50,7 @@ function highlight(text: ReactNode, terms: string[] | undefined): ReactNode {
|
|
|
49
50
|
// React still types on `HTMLAttributes`); `Omit` it, along with the
|
|
50
51
|
// motion.div-owned event props, before extending.
|
|
51
52
|
export interface SearchDialogProps extends Omit<
|
|
52
|
-
HTMLAttributes<
|
|
53
|
+
HTMLAttributes<HTMLDialogElement>,
|
|
53
54
|
"results" | "onSelect" | keyof MotionProps
|
|
54
55
|
> {
|
|
55
56
|
open?: boolean;
|
|
@@ -79,7 +80,7 @@ export function SearchDialog({
|
|
|
79
80
|
setHighlighted(0);
|
|
80
81
|
}, [query, results, open]);
|
|
81
82
|
|
|
82
|
-
function handleKeyDown(event: KeyboardEvent<
|
|
83
|
+
function handleKeyDown(event: KeyboardEvent<HTMLDialogElement>) {
|
|
83
84
|
if (event.key === "ArrowDown") {
|
|
84
85
|
event.preventDefault();
|
|
85
86
|
setHighlighted((current) => Math.min(current + 1, Math.max(results.length - 1, 0)));
|
|
@@ -92,96 +93,88 @@ export function SearchDialog({
|
|
|
92
93
|
event.preventDefault();
|
|
93
94
|
onSelect?.(result);
|
|
94
95
|
}
|
|
95
|
-
} else if (event.key === "Escape") {
|
|
96
|
-
event.preventDefault();
|
|
97
|
-
onClose?.();
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
return (
|
|
102
|
-
<
|
|
103
|
-
{open
|
|
104
|
-
|
|
105
|
-
|
|
100
|
+
<Modal
|
|
101
|
+
open={open}
|
|
102
|
+
onClose={onClose}
|
|
103
|
+
placement="top"
|
|
104
|
+
aria-label="Search docs"
|
|
105
|
+
className={"w-[560px] max-w-[calc(100vw-2rem)] overflow-hidden " + (className ?? "")}
|
|
106
|
+
onKeyDown={handleKeyDown}
|
|
107
|
+
{...rest}
|
|
108
|
+
>
|
|
109
|
+
<div className="flex h-12 items-center gap-3 border-b border-border-subtle px-4">
|
|
110
|
+
<Icon name="search" size="md" className="text-text-subtle" />
|
|
111
|
+
<input
|
|
112
|
+
autoFocus
|
|
113
|
+
data-bare-focus
|
|
114
|
+
value={query}
|
|
115
|
+
onChange={(event) => onQueryChange?.(event.target.value)}
|
|
116
|
+
placeholder="Search docs"
|
|
117
|
+
aria-label="Search docs"
|
|
118
|
+
className="min-w-0 flex-1 border-0 bg-transparent text-[18px] font-normal text-text-body outline-none placeholder:text-text-subtle"
|
|
119
|
+
/>
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
aria-label="Close search"
|
|
106
123
|
onClick={onClose}
|
|
107
|
-
|
|
108
|
-
className="fixed inset-0 z-[var(--z-modal)] flex justify-center bg-[var(--scrim)] pt-[10vh] backdrop-blur-sm"
|
|
124
|
+
className="flex h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-md text-text-subtle md:hidden"
|
|
109
125
|
>
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
126
|
+
<Icon name="x" size="sm" />
|
|
127
|
+
</button>
|
|
128
|
+
<span className="hidden md:contents">
|
|
129
|
+
<Kbd>esc</Kbd>
|
|
130
|
+
</span>
|
|
131
|
+
</div>
|
|
132
|
+
<motion.div layout transition={TRANSITIONS.glide} className="max-h-80 overflow-y-auto p-2">
|
|
133
|
+
{results.length === 0 ? (
|
|
134
|
+
<div className="p-6 text-center text-[13px] leading-normal font-medium text-text-subtle">
|
|
135
|
+
No matches
|
|
136
|
+
</div>
|
|
137
|
+
) : (
|
|
138
|
+
results.map((result, index) => {
|
|
139
|
+
const active = index === highlighted;
|
|
140
|
+
return (
|
|
141
|
+
<motion.div
|
|
142
|
+
key={(result.path ?? "") + index}
|
|
143
|
+
layout
|
|
144
|
+
initial={{ opacity: 0, y: 4 }}
|
|
145
|
+
animate={{ opacity: 1, y: 0 }}
|
|
146
|
+
transition={{
|
|
147
|
+
...TRANSITIONS.glide,
|
|
148
|
+
delay: Math.min(index, STAGGER_CAP - 1) * 0.02,
|
|
149
|
+
}}
|
|
150
|
+
onMouseEnter={() => setHighlighted(index)}
|
|
151
|
+
onClick={() => onSelect?.(result)}
|
|
152
|
+
className={
|
|
153
|
+
"flex cursor-pointer items-start gap-3 rounded-md p-2.5 " +
|
|
154
|
+
(active ? "bg-surface-hover" : "bg-transparent")
|
|
155
|
+
}
|
|
156
|
+
>
|
|
157
|
+
<Icon name="file-text" size="sm" className="mt-0.5 text-text-subtle" />
|
|
158
|
+
<div className="min-w-0 flex-1">
|
|
159
|
+
{result.label ? (
|
|
160
|
+
<div className="overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[length:var(--size-2xs)] text-text-subtle">
|
|
161
|
+
{highlight(result.label, result.terms)}
|
|
162
|
+
</div>
|
|
163
|
+
) : null}
|
|
164
|
+
<div className="text-[13px] leading-normal font-semibold text-text-heading">
|
|
165
|
+
{highlight(result.title, result.terms)}
|
|
166
|
+
</div>
|
|
167
|
+
{result.excerpt ? (
|
|
168
|
+
<div className="mt-px overflow-hidden text-ellipsis whitespace-nowrap text-[12px] font-normal text-text-muted">
|
|
169
|
+
{highlight(result.excerpt, result.terms)}
|
|
170
|
+
</div>
|
|
171
|
+
) : null}
|
|
140
172
|
</div>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
layout
|
|
148
|
-
initial={{ opacity: 0, y: 4 }}
|
|
149
|
-
animate={{ opacity: 1, y: 0 }}
|
|
150
|
-
transition={{
|
|
151
|
-
...TRANSITIONS.glide,
|
|
152
|
-
delay: Math.min(index, STAGGER_CAP - 1) * 0.02,
|
|
153
|
-
}}
|
|
154
|
-
onMouseEnter={() => setHighlighted(index)}
|
|
155
|
-
onClick={() => onSelect?.(result)}
|
|
156
|
-
className={
|
|
157
|
-
"flex cursor-pointer items-start gap-3 rounded-md p-2.5 " +
|
|
158
|
-
(active ? "bg-surface-hover" : "bg-transparent")
|
|
159
|
-
}
|
|
160
|
-
>
|
|
161
|
-
<Icon name="file-text" size="sm" className="mt-0.5 text-text-subtle" />
|
|
162
|
-
<div className="min-w-0 flex-1">
|
|
163
|
-
{result.label ? (
|
|
164
|
-
<div className="overflow-hidden text-ellipsis whitespace-nowrap font-mono text-[length:var(--size-2xs)] text-text-subtle">
|
|
165
|
-
{highlight(result.label, result.terms)}
|
|
166
|
-
</div>
|
|
167
|
-
) : null}
|
|
168
|
-
<div className="text-[13px] leading-normal font-semibold text-text-heading">
|
|
169
|
-
{highlight(result.title, result.terms)}
|
|
170
|
-
</div>
|
|
171
|
-
{result.excerpt ? (
|
|
172
|
-
<div className="mt-px overflow-hidden text-ellipsis whitespace-nowrap text-[12px] font-normal text-text-muted">
|
|
173
|
-
{highlight(result.excerpt, result.terms)}
|
|
174
|
-
</div>
|
|
175
|
-
) : null}
|
|
176
|
-
</div>
|
|
177
|
-
</motion.div>
|
|
178
|
-
);
|
|
179
|
-
})
|
|
180
|
-
)}
|
|
181
|
-
</motion.div>
|
|
182
|
-
</motion.div>
|
|
183
|
-
</motion.div>
|
|
184
|
-
) : null}
|
|
185
|
-
</AnimatePresence>
|
|
173
|
+
</motion.div>
|
|
174
|
+
);
|
|
175
|
+
})
|
|
176
|
+
)}
|
|
177
|
+
</motion.div>
|
|
178
|
+
</Modal>
|
|
186
179
|
);
|
|
187
180
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
.modal {
|
|
2
|
+
position: fixed;
|
|
3
|
+
inset: 0;
|
|
4
|
+
margin: auto;
|
|
5
|
+
padding: 0;
|
|
6
|
+
max-width: calc(100vw - 32px);
|
|
7
|
+
max-height: calc(100dvh - 32px);
|
|
8
|
+
border: 1px solid var(--border-default);
|
|
9
|
+
border-radius: var(--radius-xl, 12px);
|
|
10
|
+
background: var(--surface-raised);
|
|
11
|
+
color: var(--text-body);
|
|
12
|
+
box-shadow: 0 28px 100px #0006;
|
|
13
|
+
}
|
|
14
|
+
.modal::backdrop {
|
|
15
|
+
background: var(--scrim);
|
|
16
|
+
backdrop-filter: blur(4px);
|
|
17
|
+
animation: modal-backdrop-in var(--dur-fast) var(--ease-standard) both;
|
|
18
|
+
}
|
|
19
|
+
.modal--top {
|
|
20
|
+
margin-top: 10vh;
|
|
21
|
+
max-height: 80dvh;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.modal[data-exiting]::backdrop {
|
|
25
|
+
animation-name: modal-backdrop-out;
|
|
26
|
+
}
|
|
27
|
+
@keyframes modal-backdrop-in {
|
|
28
|
+
from {
|
|
29
|
+
opacity: 0;
|
|
30
|
+
}
|
|
31
|
+
to {
|
|
32
|
+
opacity: 1;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
@keyframes modal-backdrop-out {
|
|
36
|
+
from {
|
|
37
|
+
opacity: 1;
|
|
38
|
+
}
|
|
39
|
+
to {
|
|
40
|
+
opacity: 0;
|
|
41
|
+
}
|
|
42
|
+
}
|