@markdy/astro 0.8.19 → 0.8.21
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 +11 -8
- package/package.json +2 -2
- package/src/Markdy.astro +79 -28
package/README.md
CHANGED
|
@@ -76,16 +76,19 @@ export const code = `
|
|
|
76
76
|
| `height` | `number` | `400` | Placeholder height in pixels |
|
|
77
77
|
| `bg` | `string` | `"white"` | Placeholder background colour |
|
|
78
78
|
| `assets` | `Record<string, string>` | `{}` | Asset URL overrides |
|
|
79
|
-
| `autoplay` | `boolean` | `true` | Start playing on hydration |
|
|
80
|
-
| `loop` | `boolean` | `true` | Loop the animation when it ends |
|
|
81
|
-
| `copyright` | `boolean` | `true` | Show a "Powered by Markdy" badge below the animation |
|
|
82
|
-
| `progressBar` | `boolean` | `true` | Deprecated compatibility flag for the
|
|
83
|
-
| `sceneBoundaryProgress` | `boolean` | `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
79
|
+
| `autoplay` | `boolean` | `plan.meta.autoplay ?? true` | Start playing on hydration |
|
|
80
|
+
| `loop` | `boolean` | `plan.meta.loop ?? true` | Loop the animation when it ends |
|
|
81
|
+
| `copyright` | `boolean` | `plan.meta.copyright ?? true` | Show a "Powered by Markdy" badge below the animation |
|
|
82
|
+
| `progressBar` | `boolean \| string` | `true` | Deprecated compatibility flag for the scene-boundary progress bar |
|
|
83
|
+
| `sceneBoundaryProgress` | `boolean \| string` | `true` | Show boundary progress bar, or pass a custom color/gradient string |
|
|
84
|
+
| `progressColor` | `string` | `plan.meta.progressColor ?? "rainbow"` | Custom progress bar color (e.g. `"#3b82f6"`) or gradient (e.g. `"#ec4899, #8b5cf6"`) |
|
|
85
|
+
| `playbackRate` | `number` | `plan.meta.playbackRate ?? 1` | Normalized timeline speed multiplier; `1` is Markdy's normal pace |
|
|
86
|
+
| `interactiveViewport` | `boolean` | `controls \|\| plan.meta.interactiveViewport` | Enable wheel zoom and drag pan after hydration |
|
|
87
|
+
| `controls` | `boolean` | `plan.meta.controls ?? false` | Show left-aligned footer controls toolbar (play/pause, restart, speed, reset view); also enables viewport interaction |
|
|
87
88
|
| `class` | `string` | — | CSS class for the outer wrapper |
|
|
88
89
|
|
|
90
|
+
> **Self-Contained MarkdyScript:** You can declare `controls true`, `interactive true`, `progressColor "#3b82f6"`, `loop false`, etc. directly inside the `.markdy` code so you only need `<Markdy code={code} />`. Explicit props passed to `<Markdy />` will override in-script directives.
|
|
91
|
+
>
|
|
89
92
|
> **Tip:** Match `width`, `height`, and `bg` props to your `scene` declaration values to avoid a visual flash on hydration.
|
|
90
93
|
|
|
91
94
|
## How It Works
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/astro",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.21",
|
|
4
4
|
"description": "Astro island component for diagram-native animated MarkdyScript architecture diagrams.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@markdy/renderer-dom": "0.8.
|
|
41
|
+
"@markdy/renderer-dom": "0.8.21"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"astro": ">=4.0.0"
|
package/src/Markdy.astro
CHANGED
|
@@ -40,10 +40,14 @@ export interface Props {
|
|
|
40
40
|
loop?: boolean;
|
|
41
41
|
/** Show a small "Powered by Markdy" badge below the animation. Defaults to true. */
|
|
42
42
|
copyright?: boolean;
|
|
43
|
-
/** Show a rainbow progress bar around the viewport border. Defaults to true. */
|
|
44
|
-
progressBar?: boolean;
|
|
45
|
-
/** Preferred flag to show/hide
|
|
46
|
-
sceneBoundaryProgress?: boolean;
|
|
43
|
+
/** Show a rainbow progress bar around the viewport border, or specify a custom color/gradient. Defaults to true. */
|
|
44
|
+
progressBar?: boolean | string;
|
|
45
|
+
/** Preferred flag to show/hide or set a custom color/gradient for the scene-boundary progress bar. Defaults to true. */
|
|
46
|
+
sceneBoundaryProgress?: boolean | string;
|
|
47
|
+
/** Custom progress bar color or gradient (e.g. "#3b82f6", "emerald", "#ec4899, #8b5cf6"). */
|
|
48
|
+
progressColor?: string;
|
|
49
|
+
/** @deprecated Prefer progressColor. */
|
|
50
|
+
progressBarColor?: string;
|
|
47
51
|
/** Playback speed multiplier. Defaults to 1, where 1 is Markdy's normal pace. */
|
|
48
52
|
playbackRate?: number;
|
|
49
53
|
/** Enable wheel zoom and drag pan after hydration. Defaults to false. */
|
|
@@ -70,19 +74,30 @@ const {
|
|
|
70
74
|
height = 400,
|
|
71
75
|
bg = "white",
|
|
72
76
|
assets = {},
|
|
73
|
-
autoplay
|
|
74
|
-
loop
|
|
75
|
-
copyright
|
|
76
|
-
progressBar
|
|
77
|
+
autoplay,
|
|
78
|
+
loop,
|
|
79
|
+
copyright,
|
|
80
|
+
progressBar,
|
|
77
81
|
sceneBoundaryProgress,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
progressColor,
|
|
83
|
+
progressBarColor,
|
|
84
|
+
playbackRate,
|
|
85
|
+
controls,
|
|
86
|
+
interactiveViewport,
|
|
81
87
|
class: className,
|
|
82
88
|
title = "Markdy animation",
|
|
83
89
|
description,
|
|
84
90
|
} = Astro.props;
|
|
85
91
|
|
|
92
|
+
const resolvedProgressColor =
|
|
93
|
+
progressColor ??
|
|
94
|
+
progressBarColor ??
|
|
95
|
+
(typeof sceneBoundaryProgress === "string" && sceneBoundaryProgress !== "true" && sceneBoundaryProgress !== "false"
|
|
96
|
+
? sceneBoundaryProgress
|
|
97
|
+
: typeof progressBar === "string" && progressBar !== "true" && progressBar !== "false"
|
|
98
|
+
? progressBar
|
|
99
|
+
: undefined);
|
|
100
|
+
|
|
86
101
|
// Base64 avoids HTML attribute whitespace normalization, which strips the
|
|
87
102
|
// leading indentation MarkdyScript uses for colon bodies (groups/beats).
|
|
88
103
|
const codeB64 =
|
|
@@ -95,14 +110,15 @@ const codeB64 =
|
|
|
95
110
|
class:list={["markdy-root", className]}
|
|
96
111
|
data-markdy-code-b64={codeB64}
|
|
97
112
|
data-markdy-assets={JSON.stringify(assets)}
|
|
98
|
-
data-markdy-autoplay={String(autoplay)}
|
|
99
|
-
data-markdy-loop={String(loop)}
|
|
100
|
-
data-markdy-copyright={String(copyright)}
|
|
101
|
-
data-markdy-progress-bar={String(progressBar)}
|
|
102
|
-
data-markdy-scene-boundary-progress={String(sceneBoundaryProgress
|
|
103
|
-
data-markdy-
|
|
104
|
-
data-markdy-
|
|
105
|
-
data-markdy-
|
|
113
|
+
data-markdy-autoplay={autoplay !== undefined ? String(autoplay) : undefined}
|
|
114
|
+
data-markdy-loop={loop !== undefined ? String(loop) : undefined}
|
|
115
|
+
data-markdy-copyright={copyright !== undefined ? String(copyright) : undefined}
|
|
116
|
+
data-markdy-progress-bar={progressBar !== undefined ? String(progressBar) : undefined}
|
|
117
|
+
data-markdy-scene-boundary-progress={sceneBoundaryProgress !== undefined ? String(sceneBoundaryProgress) : undefined}
|
|
118
|
+
data-markdy-progress-color={resolvedProgressColor ?? undefined}
|
|
119
|
+
data-markdy-playback-rate={playbackRate !== undefined ? String(playbackRate) : undefined}
|
|
120
|
+
data-markdy-interactive-viewport={interactiveViewport !== undefined ? String(interactiveViewport) : undefined}
|
|
121
|
+
data-markdy-controls={controls !== undefined ? String(controls) : undefined}
|
|
106
122
|
role="img"
|
|
107
123
|
aria-label={title}
|
|
108
124
|
aria-busy="true"
|
|
@@ -273,14 +289,48 @@ const codeB64 =
|
|
|
273
289
|
// Leave assets empty on parse failure — renderer falls back to DSL paths.
|
|
274
290
|
}
|
|
275
291
|
|
|
276
|
-
const autoplay = forcePlay
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
|
|
283
|
-
|
|
292
|
+
const autoplay = forcePlay
|
|
293
|
+
? true
|
|
294
|
+
: el.dataset.markdyAutoplay !== undefined
|
|
295
|
+
? el.dataset.markdyAutoplay === "true"
|
|
296
|
+
: undefined;
|
|
297
|
+
const loop =
|
|
298
|
+
el.dataset.markdyLoop !== undefined
|
|
299
|
+
? el.dataset.markdyLoop === "true"
|
|
300
|
+
: undefined;
|
|
301
|
+
const copyright =
|
|
302
|
+
el.dataset.markdyCopyright !== undefined
|
|
303
|
+
? el.dataset.markdyCopyright === "true"
|
|
304
|
+
: undefined;
|
|
305
|
+
const progressBar =
|
|
306
|
+
el.dataset.markdyProgressBar !== undefined
|
|
307
|
+
? el.dataset.markdyProgressBar !== "false"
|
|
308
|
+
: undefined;
|
|
309
|
+
const rawSceneBoundaryProgress = el.dataset.markdySceneBoundaryProgress;
|
|
310
|
+
const sceneBoundaryProgress =
|
|
311
|
+
rawSceneBoundaryProgress === undefined
|
|
312
|
+
? undefined
|
|
313
|
+
: rawSceneBoundaryProgress === "false"
|
|
314
|
+
? false
|
|
315
|
+
: rawSceneBoundaryProgress !== "true"
|
|
316
|
+
? rawSceneBoundaryProgress
|
|
317
|
+
: true;
|
|
318
|
+
const progressColor = el.dataset.markdyProgressColor || undefined;
|
|
319
|
+
const rawPlaybackRate = el.dataset.markdyPlaybackRate
|
|
320
|
+
? Number(el.dataset.markdyPlaybackRate)
|
|
321
|
+
: undefined;
|
|
322
|
+
const playbackRate =
|
|
323
|
+
rawPlaybackRate !== undefined && Number.isFinite(rawPlaybackRate) && rawPlaybackRate > 0
|
|
324
|
+
? rawPlaybackRate
|
|
325
|
+
: undefined;
|
|
326
|
+
const controls =
|
|
327
|
+
el.dataset.markdyControls !== undefined
|
|
328
|
+
? el.dataset.markdyControls === "true"
|
|
329
|
+
: undefined;
|
|
330
|
+
const interactiveViewport =
|
|
331
|
+
el.dataset.markdyInteractiveViewport !== undefined
|
|
332
|
+
? el.dataset.markdyInteractiveViewport === "true"
|
|
333
|
+
: undefined;
|
|
284
334
|
|
|
285
335
|
// Code-split: renderer-dom is NOT part of the initial page bundle.
|
|
286
336
|
const { createDiagram } = await import("@markdy/renderer-dom");
|
|
@@ -298,7 +348,8 @@ const codeB64 =
|
|
|
298
348
|
copyright,
|
|
299
349
|
progressBar,
|
|
300
350
|
sceneBoundaryProgress,
|
|
301
|
-
|
|
351
|
+
progressColor,
|
|
352
|
+
playbackRate,
|
|
302
353
|
interactiveViewport,
|
|
303
354
|
controls,
|
|
304
355
|
});
|