@markdy/mdx 0.8.19 → 0.8.20
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 +3 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +32 -26
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -73,6 +73,9 @@ Fenced block metadata is passed as props to `MarkdyDiagram`. Snake-case aliases
|
|
|
73
73
|
|---|---|---|
|
|
74
74
|
| `progress_bar=false` | `progressBar={false}` | Deprecated compatibility flag for the scene-boundary progress bar |
|
|
75
75
|
| `scene_boundary_progress=false` | `sceneBoundaryProgress={false}` | Preferred flag for the scene-boundary progress bar |
|
|
76
|
+
| `progress_color="#3b82f6"` | `progressColor="#3b82f6"` | Custom progress bar color or gradient |
|
|
76
77
|
| `playback_rate=0.5` | `playbackRate={0.5}` | Normalized timeline speed multiplier; `1` is Markdy's normal pace |
|
|
77
78
|
| `interactive_viewport=true` | `interactiveViewport={true}` | Enable wheel zoom and drag pan on the rendered viewport |
|
|
78
79
|
| `controls=true` | `controls={true}` | Show a compact toolbar with play/pause, restart, speed, and view reset controls; also enables viewport interaction |
|
|
80
|
+
|
|
81
|
+
> **Self-Contained MarkdyScript:** You can also declare `controls true`, `interactive true`, `progressColor "#3b82f6"`, `loop false`, etc. directly inside the Markdy code block without needing fence metadata attributes. Fence attributes act as explicit overrides.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ type MarkdyDiagramProps = {
|
|
|
12
12
|
copyright?: boolean | string;
|
|
13
13
|
progressBar?: boolean | string;
|
|
14
14
|
sceneBoundaryProgress?: boolean | string;
|
|
15
|
+
progressColor?: string;
|
|
16
|
+
progressBarColor?: string;
|
|
15
17
|
playbackRate?: number | string;
|
|
16
18
|
interactiveViewport?: boolean | string;
|
|
17
19
|
controls?: boolean | string;
|
|
@@ -19,7 +21,7 @@ type MarkdyDiagramProps = {
|
|
|
19
21
|
title?: string;
|
|
20
22
|
description?: string;
|
|
21
23
|
};
|
|
22
|
-
declare function MarkdyDiagram({ code, width, height, bg, assets, autoplay, loop, copyright, progressBar, sceneBoundaryProgress, playbackRate, controls, interactiveViewport, className, title, description, }: MarkdyDiagramProps): react.JSX.Element;
|
|
24
|
+
declare function MarkdyDiagram({ code, width, height, bg, assets, autoplay, loop, copyright, progressBar, sceneBoundaryProgress, progressColor, progressBarColor, playbackRate, controls, interactiveViewport, className, title, description, }: MarkdyDiagramProps): react.JSX.Element;
|
|
23
25
|
|
|
24
26
|
type MarkdyFenceDefaults = Partial<{
|
|
25
27
|
width: number;
|
package/dist/index.js
CHANGED
|
@@ -12,21 +12,21 @@ function scheduleBackgroundTask(work) {
|
|
|
12
12
|
}
|
|
13
13
|
globalThis.setTimeout(work, 0);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function coerceOptionalBoolean(value) {
|
|
16
16
|
if (typeof value === "boolean") return value;
|
|
17
17
|
if (typeof value === "string") {
|
|
18
|
-
if (value.toLowerCase() === "true") return true;
|
|
19
|
-
if (value.toLowerCase() === "false") return false;
|
|
18
|
+
if (value.toLowerCase() === "true" || value.toLowerCase() === "on") return true;
|
|
19
|
+
if (value.toLowerCase() === "false" || value.toLowerCase() === "off") return false;
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return void 0;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function coerceOptionalNumber(value) {
|
|
24
24
|
if (typeof value === "number") return value;
|
|
25
25
|
if (typeof value === "string") {
|
|
26
26
|
const parsed = Number(value);
|
|
27
|
-
if (!Number.isNaN(parsed)) return parsed;
|
|
27
|
+
if (!Number.isNaN(parsed) && parsed > 0) return parsed;
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return void 0;
|
|
30
30
|
}
|
|
31
31
|
function MarkdyDiagram({
|
|
32
32
|
code,
|
|
@@ -34,28 +34,31 @@ function MarkdyDiagram({
|
|
|
34
34
|
height = 400,
|
|
35
35
|
bg = "#ffffff",
|
|
36
36
|
assets = {},
|
|
37
|
-
autoplay
|
|
38
|
-
loop
|
|
39
|
-
copyright
|
|
40
|
-
progressBar
|
|
37
|
+
autoplay,
|
|
38
|
+
loop,
|
|
39
|
+
copyright,
|
|
40
|
+
progressBar,
|
|
41
41
|
sceneBoundaryProgress,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
progressColor,
|
|
43
|
+
progressBarColor,
|
|
44
|
+
playbackRate,
|
|
45
|
+
controls,
|
|
46
|
+
interactiveViewport,
|
|
45
47
|
className,
|
|
46
48
|
title = "Markdy animation",
|
|
47
49
|
description
|
|
48
50
|
}) {
|
|
49
|
-
const resolvedWidth =
|
|
50
|
-
const resolvedHeight =
|
|
51
|
-
const resolvedAutoplay =
|
|
52
|
-
const resolvedLoop =
|
|
53
|
-
const resolvedCopyright =
|
|
54
|
-
const resolvedProgressBar =
|
|
55
|
-
const resolvedSceneBoundaryProgress =
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
51
|
+
const resolvedWidth = typeof width === "number" ? width : Number(width) || 800;
|
|
52
|
+
const resolvedHeight = typeof height === "number" ? height : Number(height) || 400;
|
|
53
|
+
const resolvedAutoplay = coerceOptionalBoolean(autoplay);
|
|
54
|
+
const resolvedLoop = coerceOptionalBoolean(loop);
|
|
55
|
+
const resolvedCopyright = coerceOptionalBoolean(copyright);
|
|
56
|
+
const resolvedProgressBar = typeof progressBar === "string" && progressBar !== "true" && progressBar !== "false" ? progressBar : coerceOptionalBoolean(progressBar);
|
|
57
|
+
const resolvedSceneBoundaryProgress = typeof sceneBoundaryProgress === "string" && sceneBoundaryProgress !== "true" && sceneBoundaryProgress !== "false" ? sceneBoundaryProgress : coerceOptionalBoolean(sceneBoundaryProgress);
|
|
58
|
+
const resolvedProgressColor = typeof progressColor === "string" ? progressColor : typeof progressBarColor === "string" ? progressBarColor : typeof resolvedSceneBoundaryProgress === "string" ? resolvedSceneBoundaryProgress : typeof resolvedProgressBar === "string" ? resolvedProgressBar : void 0;
|
|
59
|
+
const resolvedPlaybackRate = coerceOptionalNumber(playbackRate);
|
|
60
|
+
const resolvedControls = coerceOptionalBoolean(controls);
|
|
61
|
+
const resolvedInteractiveViewport = coerceOptionalBoolean(interactiveViewport);
|
|
59
62
|
const rootRef = useRef(null);
|
|
60
63
|
const diagramRef = useRef(null);
|
|
61
64
|
const hydratedRef = useRef(false);
|
|
@@ -80,12 +83,13 @@ function MarkdyDiagram({
|
|
|
80
83
|
container: root,
|
|
81
84
|
code,
|
|
82
85
|
assets,
|
|
83
|
-
autoplay: forceAutoplay
|
|
86
|
+
autoplay: forceAutoplay ? true : resolvedAutoplay,
|
|
84
87
|
loop: resolvedLoop,
|
|
85
88
|
copyright: resolvedCopyright,
|
|
86
89
|
progressBar: resolvedProgressBar,
|
|
87
90
|
sceneBoundaryProgress: resolvedSceneBoundaryProgress,
|
|
88
|
-
|
|
91
|
+
progressColor: resolvedProgressColor,
|
|
92
|
+
playbackRate: resolvedPlaybackRate,
|
|
89
93
|
interactiveViewport: resolvedInteractiveViewport,
|
|
90
94
|
controls: resolvedControls
|
|
91
95
|
});
|
|
@@ -135,6 +139,7 @@ function MarkdyDiagram({
|
|
|
135
139
|
resolvedLoop,
|
|
136
140
|
resolvedProgressBar,
|
|
137
141
|
resolvedSceneBoundaryProgress,
|
|
142
|
+
resolvedProgressColor,
|
|
138
143
|
resolvedPlaybackRate,
|
|
139
144
|
resolvedInteractiveViewport,
|
|
140
145
|
resolvedControls
|
|
@@ -235,6 +240,7 @@ function parseMetaValue(raw) {
|
|
|
235
240
|
function normalizeMetaKey(key) {
|
|
236
241
|
if (key === "progress_bar") return "progressBar";
|
|
237
242
|
if (key === "scene_boundary_progress") return "sceneBoundaryProgress";
|
|
243
|
+
if (key === "progress_color" || key === "progress_bar_color") return "progressColor";
|
|
238
244
|
if (key === "playback_rate") return "playbackRate";
|
|
239
245
|
if (key === "interactive_viewport") return "interactiveViewport";
|
|
240
246
|
return key;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/mdx",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.20",
|
|
4
4
|
"description": "MDX plugin and lightweight React component for diagram-native animated Markdy diagrams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"unist-util-visit": "^5.0.0",
|
|
45
|
-
"@markdy/renderer-dom": "0.8.
|
|
45
|
+
"@markdy/renderer-dom": "0.8.20"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=18.0.0",
|