@karimsa/mdxserve 0.4.0 → 0.5.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/README.md +25 -0
- package/client/App.tsx +15 -1
- package/client/MdSection.tsx +8 -3
- package/client/MdSectionEditor.tsx +62 -3
- package/client/app.css +2 -0
- package/client/design/base/editor.css +59 -0
- package/client/diagrams/style.css +0 -19
- 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/head-metadata.ts +32 -0
- package/client/router.ts +48 -16
- package/client/standalone-entry.tsx +11 -2
- package/dist/cli.js +4306 -3869
- package/package.json +5 -2
- package/client/diagrams/slash.ts +0 -94
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karimsa/mdxserve",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Serve a directory of Markdown/MDX files, like `serve` but for docs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"lint": "oxlint",
|
|
34
34
|
"test": "vitest run",
|
|
35
35
|
"prepack": "yarn build",
|
|
36
|
-
"smoke": "bash scripts/smoke-pack.sh"
|
|
36
|
+
"smoke": "bash scripts/smoke-pack.sh",
|
|
37
|
+
"changelog": "tsx scripts/changelog.ts"
|
|
37
38
|
},
|
|
38
39
|
"packageManager": "yarn@4.18.0",
|
|
39
40
|
"engines": {
|
|
@@ -127,6 +128,7 @@
|
|
|
127
128
|
"update-notifier": "7.3.1",
|
|
128
129
|
"vfile-message": "4.0.3",
|
|
129
130
|
"vite": "8.2.1",
|
|
131
|
+
"yaml": "2.9.1",
|
|
130
132
|
"zod": "4.4.3",
|
|
131
133
|
"zx": "8.8.5"
|
|
132
134
|
},
|
|
@@ -145,6 +147,7 @@
|
|
|
145
147
|
"@yarnpkg/types": "4.0.1",
|
|
146
148
|
"esbuild": "0.28.2",
|
|
147
149
|
"fast-check": "4.9.0",
|
|
150
|
+
"git-cliff": "2.14.2",
|
|
148
151
|
"oxlint": "1.77.0",
|
|
149
152
|
"prettier": "3.9.6",
|
|
150
153
|
"tsx": "4.23.12",
|
package/client/diagrams/slash.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { Extension, type Range } from "@tiptap/core";
|
|
2
|
-
import Suggestion from "@tiptap/suggestion";
|
|
3
|
-
import { PluginKey } from "@tiptap/pm/state";
|
|
4
|
-
|
|
5
|
-
export function mermaidSlash(enabled: () => boolean, onOpen: (range: Range) => void) {
|
|
6
|
-
return Extension.create({
|
|
7
|
-
name: "mermaidSlash",
|
|
8
|
-
addProseMirrorPlugins() {
|
|
9
|
-
return [
|
|
10
|
-
Suggestion({
|
|
11
|
-
editor: this.editor,
|
|
12
|
-
pluginKey: new PluginKey("mermaidSlash"),
|
|
13
|
-
char: "/",
|
|
14
|
-
startOfLine: true,
|
|
15
|
-
allow: ({ editor, state, range }) =>
|
|
16
|
-
enabled() &&
|
|
17
|
-
editor.isEditable &&
|
|
18
|
-
state.selection.empty &&
|
|
19
|
-
!state.selection.$from.marks().some((mark) => mark.type.name === "code") &&
|
|
20
|
-
state.doc.resolve(range.from).parent.type.name === "paragraph" &&
|
|
21
|
-
state.doc.resolve(range.from).parent.textContent ===
|
|
22
|
-
state.doc.textBetween(range.from, range.to),
|
|
23
|
-
items: ({ query }) =>
|
|
24
|
-
["mermaid", "diagram", "er", "image"].some((term) =>
|
|
25
|
-
term.startsWith(query.toLowerCase()),
|
|
26
|
-
)
|
|
27
|
-
? ["mermaid"]
|
|
28
|
-
: [],
|
|
29
|
-
command: ({ range }) => onOpen(range),
|
|
30
|
-
render: () => {
|
|
31
|
-
let menu: HTMLDivElement | undefined;
|
|
32
|
-
let choose: (() => void) | undefined;
|
|
33
|
-
return {
|
|
34
|
-
onStart(props) {
|
|
35
|
-
menu = document.createElement("div");
|
|
36
|
-
menu.className = "diagram-slash-menu";
|
|
37
|
-
menu.hidden = props.items.length === 0;
|
|
38
|
-
menu.setAttribute("role", "listbox");
|
|
39
|
-
menu.setAttribute("aria-label", "Insert block");
|
|
40
|
-
const button = document.createElement("button");
|
|
41
|
-
button.type = "button";
|
|
42
|
-
button.setAttribute("role", "option");
|
|
43
|
-
button.setAttribute("aria-selected", "true");
|
|
44
|
-
button.textContent = "Mermaid diagram";
|
|
45
|
-
button.onmousedown = (event) => {
|
|
46
|
-
event.preventDefault();
|
|
47
|
-
choose?.();
|
|
48
|
-
menu?.remove();
|
|
49
|
-
menu = undefined;
|
|
50
|
-
};
|
|
51
|
-
menu.append(button);
|
|
52
|
-
document.body.append(menu);
|
|
53
|
-
choose = () => props.command("mermaid");
|
|
54
|
-
const rect = props.clientRect?.();
|
|
55
|
-
if (rect) {
|
|
56
|
-
menu.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - 260))}px`;
|
|
57
|
-
menu.style.top = `${Math.min(rect.bottom + 6, window.innerHeight - 70)}px`;
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
onUpdate(props) {
|
|
61
|
-
choose = () => props.command("mermaid");
|
|
62
|
-
if (menu) menu.hidden = props.items.length === 0;
|
|
63
|
-
},
|
|
64
|
-
onKeyDown({ event }) {
|
|
65
|
-
if (event.key === "Escape") {
|
|
66
|
-
menu?.remove();
|
|
67
|
-
menu = undefined;
|
|
68
|
-
event.preventDefault();
|
|
69
|
-
event.stopPropagation();
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
if (menu && !menu.hidden && ["Enter", "ArrowDown", "ArrowUp"].includes(event.key)) {
|
|
73
|
-
event.preventDefault();
|
|
74
|
-
event.stopPropagation();
|
|
75
|
-
if (event.key === "Enter") {
|
|
76
|
-
choose?.();
|
|
77
|
-
menu.remove();
|
|
78
|
-
menu = undefined;
|
|
79
|
-
}
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
return false;
|
|
83
|
-
},
|
|
84
|
-
onExit() {
|
|
85
|
-
menu?.remove();
|
|
86
|
-
menu = undefined;
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
];
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
}
|