Vue
<script setup>import { computed, useTemplateRef } from "vue";import { shallowEqual } from "@lumen-timeline/core";import { provideTimeline, Timeline, useEditorSelector } from "@lumen-timeline/vue";import "@lumen-timeline/timeline/style.css";
const { editor, transport, tiles } = defineProps(["editor", "transport", "tiles"]);provideTimeline({ editor, transport });const timeline = useTemplateRef("timeline");const clip = useEditorSelector( editor, ({ snapshot, selection }) => { const found = snapshot.clips.find((c) => c.id === selection.at(-1)); return found ? { name: found.name, take: found.activeTakeId } : null; }, shallowEqual,);</script>
<template> <Timeline ref="timeline" :editor="editor" :transport="transport" :waveforms="tiles" /> <aside>{{ clip ? `${clip.name}: ${clip.take}` : "No clip selected" }}</aside></template><Timeline v-bind="options">renders adivand mounts the view in it on mount.classandstylefall through to thediv. The template ref exposesview, theTimelineViewornull. Props are read raw, so an editor kept in a deeprefstill reaches the view as the object the host made.useEditorSelector(editor, select, isEqual)returns a read-only shallow reference. In a component it subscribes from mount until unmount; elsewhere, from the call until its effect scope ends.editormay be a ref or a getter, and a new editor is followed.useTransportSelector(transport, select, isEqual)does the same for a transport’s snapshot.provideTimeline(value)anduseTimelineContext()hand the host’s editor and transport down.valuemay be a ref or a getter, anduseTimelineContextreturns a computed reference. It throws without a provider.