Visualize Your Ideas With Code
feat: navigate to slide source (#490)
Jacobb5ae4bf37076
diff --git a/packages/core/src/scenes/Slides.ts b/packages/core/src/scenes/Slides.tsindex 47c08f8b..3da0b5fc 100644--- a/packages/core/src/scenes/Slides.ts+++ b/packages/core/src/scenes/Slides.ts@@ -7,6 +7,7 @@ export interface Slide {name: string;time: number;scene: Scene;+ stack?: string;}export class Slides {@@ -80,6 +81,7 @@ export class Slides {name,time: initialTime,scene: this.scene,+ stack: new Error().stack,});}diff --git a/packages/ui/src/components/timeline/SlideTrack.tsx b/packages/ui/src/components/timeline/SlideTrack.tsxindex 1b1ae876..369c2241 100644--- a/packages/ui/src/components/timeline/SlideTrack.tsx+++ b/packages/ui/src/components/timeline/SlideTrack.tsx@@ -2,6 +2,8 @@ import {Scene} from '@motion-canvas/core/lib/scenes';import {useSubscribableValue} from '../../hooks';import styles from './Timeline.module.scss';import clsx from 'clsx';+import {useApplication} from '../../contexts';+import {findAndOpenFirstUserFile} from '../../utils';export interface SlideTrackProps {scene: Scene;@@ -9,6 +11,7 @@ export interface SlideTrackProps {}export function SlideTrack({scene, duration}: SlideTrackProps) {+ const {player} = useApplication();const slides = useSubscribableValue(scene.slides.onChanged);return slides.length > 0 ? (@@ -31,7 +34,23 @@ export function SlideTrack({scene, duration}: SlideTrackProps) {}}><div className={styles.container}>- <div className={styles.name}>{slide.name}</div>+ <div+ title="Go to source"+ className={styles.name}+ onMouseUp={async event => {+ event.stopPropagation();+ if (event.button === 1) {+ player.requestSeek(+ scene.firstFrame ++ player.status.secondsToFrames(slide.time),+ );+ } else if (event.button === 0) {+ await findAndOpenFirstUserFile(slide.stack);+ }+ }}+ >+ {slide.name}+ </div></div></div>))}diff --git a/packages/ui/src/components/timeline/Timeline.module.scss b/packages/ui/src/components/timeline/Timeline.module.scssindex c71dd768..ff94466c 100644--- a/packages/ui/src/components/timeline/Timeline.module.scss+++ b/packages/ui/src/components/timeline/Timeline.module.scss@@ -122,6 +122,7 @@white-space: nowrap;overflow: hidden;text-overflow: ellipsis;+ max-width: min-content;&:hover {text-decoration: underline;