@particle-academy/fancy-slides 0.5.1 → 0.6.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/dist/index.d.cts CHANGED
@@ -106,7 +106,12 @@ interface SlideViewerProps {
106
106
  autoAdvanceMs?: number;
107
107
  /** Hide the bottom progress bar + slide counter. */
108
108
  hideChrome?: boolean;
109
- /** Optional custom renderer for element types Slide doesn't render natively (chart/code/table/embed). */
109
+ /**
110
+ * Custom renderer for element types Slide doesn't render natively
111
+ * (chart/code/table/embed). Defaults to the built-in
112
+ * `defaultElementRegistry` so decks play fully out of the box; pass your
113
+ * own to override.
114
+ */
110
115
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
111
116
  /** Extra classes on the viewer wrapper. */
112
117
  className?: string;
@@ -176,6 +181,16 @@ interface SlideThumbnailProps {
176
181
  * presenter view, and anywhere else a deck wants to show its slides as
177
182
  * thumbnails. Re-uses the shared <Slide> so the layout matches the viewer
178
183
  * exactly — no second rendering path.
184
+ *
185
+ * The slide is rendered at its full DESIGN width and the whole thing is
186
+ * CSS-`scale()`d down to the thumbnail size (the same approach fancy-artboard
187
+ * uses for its piece previews). Scaling the rendered output — rather than
188
+ * rendering the slide *at* the thumbnail width — is what makes heavy embedded
189
+ * surfaces (ECharts charts, the fancy-code editor) shrink proportionally:
190
+ * those render at fixed internal font sizes that ignore `slideWidthPx`, so a
191
+ * directly-undersized render leaves them oversized in the thumb. A uniform
192
+ * transform shrinks everything identically, so the thumb is a faithful
193
+ * miniature of the live slide.
179
194
  */
180
195
  declare function SlideThumbnail({ slide, theme, width, active, onClick, onContextMenu, renderElement, className, style, }: SlideThumbnailProps): react_jsx_runtime.JSX.Element;
181
196
 
@@ -190,7 +205,14 @@ interface DeckEditorProps {
190
205
  /** Controlled selected slide id. Uncontrolled by default. */
191
206
  selectedSlideId?: string | null;
192
207
  onSelectedSlideChange?: (id: string | null) => void;
193
- /** Optional renderer for chart / code / table / embed elements (the elements this package doesn't render natively). */
208
+ /**
209
+ * Renderer for chart / code / table / embed elements (the elements this
210
+ * package doesn't render natively). Defaults to the built-in
211
+ * `defaultElementRegistry` so the editor is full out of the box; pass your
212
+ * own to override (it wins entirely). The optional-peer hosts (chart/code)
213
+ * load fancy-echarts/fancy-code via guarded dynamic imports, so the base
214
+ * bundle never statically requires them.
215
+ */
194
216
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
195
217
  /** Hide the slide rail (e.g. for embedded use). */
196
218
  hideRail?: boolean;
package/dist/index.d.ts CHANGED
@@ -106,7 +106,12 @@ interface SlideViewerProps {
106
106
  autoAdvanceMs?: number;
107
107
  /** Hide the bottom progress bar + slide counter. */
108
108
  hideChrome?: boolean;
109
- /** Optional custom renderer for element types Slide doesn't render natively (chart/code/table/embed). */
109
+ /**
110
+ * Custom renderer for element types Slide doesn't render natively
111
+ * (chart/code/table/embed). Defaults to the built-in
112
+ * `defaultElementRegistry` so decks play fully out of the box; pass your
113
+ * own to override.
114
+ */
110
115
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
111
116
  /** Extra classes on the viewer wrapper. */
112
117
  className?: string;
@@ -176,6 +181,16 @@ interface SlideThumbnailProps {
176
181
  * presenter view, and anywhere else a deck wants to show its slides as
177
182
  * thumbnails. Re-uses the shared <Slide> so the layout matches the viewer
178
183
  * exactly — no second rendering path.
184
+ *
185
+ * The slide is rendered at its full DESIGN width and the whole thing is
186
+ * CSS-`scale()`d down to the thumbnail size (the same approach fancy-artboard
187
+ * uses for its piece previews). Scaling the rendered output — rather than
188
+ * rendering the slide *at* the thumbnail width — is what makes heavy embedded
189
+ * surfaces (ECharts charts, the fancy-code editor) shrink proportionally:
190
+ * those render at fixed internal font sizes that ignore `slideWidthPx`, so a
191
+ * directly-undersized render leaves them oversized in the thumb. A uniform
192
+ * transform shrinks everything identically, so the thumb is a faithful
193
+ * miniature of the live slide.
179
194
  */
180
195
  declare function SlideThumbnail({ slide, theme, width, active, onClick, onContextMenu, renderElement, className, style, }: SlideThumbnailProps): react_jsx_runtime.JSX.Element;
181
196
 
@@ -190,7 +205,14 @@ interface DeckEditorProps {
190
205
  /** Controlled selected slide id. Uncontrolled by default. */
191
206
  selectedSlideId?: string | null;
192
207
  onSelectedSlideChange?: (id: string | null) => void;
193
- /** Optional renderer for chart / code / table / embed elements (the elements this package doesn't render natively). */
208
+ /**
209
+ * Renderer for chart / code / table / embed elements (the elements this
210
+ * package doesn't render natively). Defaults to the built-in
211
+ * `defaultElementRegistry` so the editor is full out of the box; pass your
212
+ * own to override (it wins entirely). The optional-peer hosts (chart/code)
213
+ * load fancy-echarts/fancy-code via guarded dynamic imports, so the base
214
+ * bundle never statically requires them.
215
+ */
194
216
  renderElement?: (element: SlideElement, slideWidthPx: number) => ReactNode | undefined;
195
217
  /** Hide the slide rail (e.g. for embedded use). */
196
218
  hideRail?: boolean;
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { defaultElementRegistry } from './chunk-YEJZYKVB.js';
1
2
  import { isDarkColor, SlideContext } from './chunk-WIUXPQAK.js';
2
3
  export { useIsDarkSlide, useSlideContext, useSlideTheme } from './chunk-WIUXPQAK.js';
3
4
  import { useId, useRef, useState, useEffect, useMemo, useCallback } from 'react';
@@ -916,7 +917,7 @@ function SlideViewer({
916
917
  onExit,
917
918
  autoAdvanceMs,
918
919
  hideChrome = false,
919
- renderElement,
920
+ renderElement = defaultElementRegistry,
920
921
  className
921
922
  }) {
922
923
  const isControlled = controlledIndex !== void 0;
@@ -1406,6 +1407,11 @@ function SlideThumbnail({
1406
1407
  className,
1407
1408
  style
1408
1409
  }) {
1410
+ const resolved = resolveTheme(theme);
1411
+ const ratio = resolved.aspectRatio ?? 16 / 9;
1412
+ const designWidth = resolved.slideWidth ?? 1280;
1413
+ const scale = width / designWidth;
1414
+ const height = width / ratio;
1409
1415
  return /* @__PURE__ */ jsx(
1410
1416
  "div",
1411
1417
  {
@@ -1418,12 +1424,27 @@ function SlideThumbnail({
1418
1424
  boxShadow: active ? "0 0 0 3px rgba(139, 92, 246, 0.2)" : "0 1px 2px rgba(0,0,0,0.05)",
1419
1425
  background: "#ffffff",
1420
1426
  width,
1427
+ height,
1421
1428
  ...style
1422
1429
  },
1423
1430
  onClick,
1424
1431
  onContextMenu,
1425
1432
  "data-fancy-slides-thumbnail": slide.id,
1426
- children: /* @__PURE__ */ jsx(Slide, { slide, theme, width, renderElement })
1433
+ children: /* @__PURE__ */ jsx(
1434
+ "div",
1435
+ {
1436
+ style: {
1437
+ width: designWidth,
1438
+ height: designWidth / ratio,
1439
+ transform: `scale(${scale})`,
1440
+ transformOrigin: "top left",
1441
+ // The thumb owns interaction — charts/code/iframes inside the
1442
+ // scaled slide shouldn't capture clicks.
1443
+ pointerEvents: "none"
1444
+ },
1445
+ children: /* @__PURE__ */ jsx(Slide, { slide, theme, width: designWidth, renderElement })
1446
+ }
1447
+ )
1427
1448
  }
1428
1449
  );
1429
1450
  }
@@ -2677,7 +2698,7 @@ function DeckEditor({
2677
2698
  onPresent,
2678
2699
  selectedSlideId: controlledSlideId,
2679
2700
  onSelectedSlideChange,
2680
- renderElement,
2701
+ renderElement = defaultElementRegistry,
2681
2702
  hideRail = false,
2682
2703
  hideNotes = false,
2683
2704
  hideToolbar = false,