@@ -236,6 +236,7 @@ export default function Editor(props: EditorProps) {
236236 backgroundGradientColorStart : props . snippetSettings . bgGradientColorStart ,
237237 backgroundGradientColorEnd : props . snippetSettings . bgGradientColorEnd ,
238238 backgroundGradientDirection : props . snippetSettings . bgGradientDirection ,
239+ lineNumberColor : props . snippetSettings . lineNumberColor ,
239240 } ,
240241 } ,
241242 )
@@ -352,6 +353,50 @@ export default function Editor(props: EditorProps) {
352353 collapsible
353354 defaultValue = { [ 'background' , 'layout' , 'shadow' , 'font' ] }
354355 >
356+ < AccordionItem value = "background" >
357+ < AccordionTrigger > Line Numbers</ AccordionTrigger >
358+ < AccordionContent >
359+ < div class = "flex flex-col gap-4" >
360+ < div class = "flex flex-row items-center justify-between" >
361+ < Label
362+ for = "line-numbers-checkbox"
363+ onClick = { ( ) =>
364+ props . setSnippetSettings (
365+ 'lineNumbersEnabled' ,
366+ ! props . snippetSettings . lineNumbersEnabled ,
367+ )
368+ }
369+ >
370+ Show Line Numbers
371+ </ Label >
372+ < Checkbox
373+ id = "line-numbers-checkbox"
374+ checked = { props . snippetSettings . lineNumbersEnabled }
375+ onChange = { ( ) => {
376+ props . setSnippetSettings (
377+ 'lineNumbersEnabled' ,
378+ ! props . snippetSettings . lineNumbersEnabled ,
379+ )
380+ } }
381+ />
382+ </ div >
383+ < div class = "flex flex-row items-center justify-between" >
384+ < Label for = "line-number-color" class = "font-normal" >
385+ Color
386+ </ Label >
387+ < input
388+ id = "line-number-color"
389+ class = "h-6 w-6 rounded"
390+ type = "color"
391+ value = { props . snippetSettings . lineNumberColor }
392+ onInput = { e => {
393+ props . setSnippetSettings ( 'lineNumberColor' , e . target . value )
394+ } }
395+ />
396+ </ div >
397+ </ div >
398+ </ AccordionContent >
399+ </ AccordionItem >
355400 < AccordionItem value = "background" >
356401 < AccordionTrigger > Background</ AccordionTrigger >
357402 < AccordionContent >
@@ -563,7 +608,7 @@ export default function Editor(props: EditorProps) {
563608 } }
564609 />
565610 </ div >
566-
611+ //
567612 < div class = "flex flex-row items-center justify-between" >
568613 < Label for = "shadow-color-input" class = "font-normal" >
569614 Color
@@ -839,7 +884,7 @@ export default function Editor(props: EditorProps) {
839884 options = { {
840885 duration : 800 ,
841886 stagger : 0 ,
842- lineNumbers : false ,
887+ lineNumbers : props . snippetSettings . lineNumbersEnabled ,
843888 } }
844889 />
845890 { /* The hidden shiki that we use to generate the magic move elements */ }
@@ -859,7 +904,7 @@ export default function Editor(props: EditorProps) {
859904 options = { {
860905 duration : 800 ,
861906 stagger : 0 ,
862- lineNumbers : false ,
907+ lineNumbers : props . snippetSettings . lineNumbersEnabled ,
863908 onAnimationStart : async ( elements , maxContainerDimensions ) => {
864909 if ( elements . length === 0 ) {
865910 return
@@ -1178,6 +1223,7 @@ async function createAnimationFrame(
11781223 height : number = 100 ,
11791224 config : AnimationFrameConfig ,
11801225) {
1226+ console . log ( { elements } )
11811227 const { yPadding, xPadding } = config . layout
11821228 const { shadowEnabled, shadowOffsetY, shadowBlur, shadowColor, shadowOpacity } = config . shadow
11831229 const {
@@ -1189,6 +1235,7 @@ async function createAnimationFrame(
11891235 backgroundGradientColorStart,
11901236 backgroundGradientColorEnd,
11911237 backgroundGradientDirection,
1238+ lineNumberColor,
11921239 } = config . styling
11931240
11941241 const canvas = document . createElement ( 'canvas' )
@@ -1260,10 +1307,16 @@ async function createAnimationFrame(
12601307 const opacity = interpolate ( frame , [ 0 , animationFrames ] , [ el . opacity . start , el . opacity . end ] , {
12611308 easing : Easing . inOut ( Easing . quad ) ,
12621309 } )
1310+
1311+ let fallbackColor = 'rgba(0,0,0,0)'
1312+ if ( el . el . classList . contains ( 'shiki-magic-move-line-number' ) ) {
1313+ fallbackColor = lineNumberColor || '#aaaaaa'
1314+ }
1315+
12631316 const color = interpolateColors (
12641317 frame ,
12651318 [ 0 , animationFrames ] ,
1266- [ el . color . start || 'rgba(0,0,0,0)' , el . color . end || 'rgba(0,0,0,0)' ] ,
1319+ [ el . color . start || fallbackColor , el . color . end || fallbackColor ] ,
12671320 )
12681321
12691322 ctx . font = `${ fontSize } ${ fontFamily } `
0 commit comments