44 CodeStep ,
55} from "../smooth-code"
66import React from "react"
7+ import { codeToText } from "utils"
78
89export type CodeFile = CodeStep & {
910 name : string
@@ -37,6 +38,8 @@ type OutputPanel = {
3738type Transition = {
3839 northPanel : OutputPanel
3940 southPanel ?: OutputPanel | null
41+ northContent : string
42+ southContent : string
4043}
4144
4245type TabsSnapshot = Record <
@@ -110,6 +113,7 @@ export function useTransition(
110113 )
111114
112115 return {
116+ northContent : getContentFromFile ( nextNorthFile ) ,
113117 northPanel : {
114118 tabs : northTabs ,
115119 style : northStyle ,
@@ -126,6 +130,7 @@ export function useTransition(
126130 />
127131 ) ,
128132 } ,
133+ southContent : getContentFromFile ( nextSouthFile ) ,
129134 southPanel : inputSouthPanel && {
130135 tabs : southTabs ! ,
131136 style : southStyle ! ,
@@ -162,6 +167,7 @@ function startingPosition(
162167 } = getStepFiles ( prev , next , true )
163168
164169 return {
170+ northContent : getContentFromFile ( prevNorthFile ) ,
165171 northPanel : {
166172 tabs : inputNorthPanel . tabs . map ( title => ( {
167173 title,
@@ -182,6 +188,7 @@ function startingPosition(
182188 />
183189 ) ,
184190 } ,
191+ southContent : getContentFromFile ( prevSouthFile ) ,
185192 southPanel : inputSouthPanel && {
186193 tabs : inputSouthPanel . tabs . map ( title => ( {
187194 title,
@@ -229,6 +236,7 @@ function endingPosition(
229236 }
230237
231238 return {
239+ northContent : getContentFromFile ( nextNorthFile ) ,
232240 northPanel : {
233241 tabs : inputNorthPanel . tabs . map ( title => ( {
234242 title,
@@ -249,6 +257,7 @@ function endingPosition(
249257 />
250258 ) ,
251259 } ,
260+ southContent : getContentFromFile ( nextSouthFile ) ,
252261 southPanel : inputSouthPanel && {
253262 tabs : inputSouthPanel . tabs . map ( title => ( {
254263 title,
@@ -305,6 +314,10 @@ function CodeTransition({
305314 )
306315}
307316
317+ function getContentFromFile ( file ?: CodeFile ) {
318+ return file ? codeToText ( file . code ) : ""
319+ }
320+
308321/**
309322 * Get the StepFiles for a transition
310323 * in each panel, if the prev and next active files are the same
0 commit comments