@@ -26,7 +26,11 @@ function makeid(length = 5) {
2626}
2727
2828const prev = elements .value .length
29- const index = computed (() => Math .min (Math .max (0 , clicks .value - prev ), props .ranges .length - 1 ))
29+ const index = computed (() => {
30+ if (disabled .value )
31+ return props .ranges .length - 1
32+ return Math .min (Math .max (0 , clicks .value - prev ), props .ranges .length - 1 )
33+ })
3034const rangeStr = computed (() => props .ranges [index .value ] || ' ' )
3135if (props .ranges .length >= 2 && ! disabled .value ) {
3236 const id = makeid ()
@@ -43,12 +47,16 @@ onMounted(() => {
4347 watchEffect (() => {
4448 if (! el .value )
4549 return
46- const lines = Array .from (el .value .querySelectorAll (' .line' ))
47- const hightlights: number [] = parseRangeString (lines .length , rangeStr .value )
48- // console.log(hightlights, rangeStr.value)
49- lines .forEach ((line , idx ) => {
50- line .classList .toggle (' opacity-30' , ! hightlights .includes (idx ))
51- })
50+ const duoTone = el .value .querySelector (' .shiki-dark' )
51+ const targets = duoTone ? Array .from (el .value .querySelectorAll (' .shiki' )) : [el .value ]
52+ for (const target of targets ) {
53+ const lines = Array .from (target .querySelectorAll (' .line' ))
54+ const hightlights: number [] = parseRangeString (lines .length , rangeStr .value )
55+ // console.log(hightlights, rangeStr.value)
56+ lines .forEach ((line , idx ) => {
57+ line .classList .toggle (' opacity-30' , ! hightlights .includes (idx ))
58+ })
59+ }
5260 })
5361})
5462 </script >
0 commit comments