File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 33/// <reference types="vite/client" />
44
55export * from './dist/client/index.js'
6+
7+ declare global {
8+ interface WindowEventMap {
9+ 'vitepress:codeGroupTabActivate' : Event & {
10+ /** code block element that was activated */
11+ detail : Element
12+ }
13+ }
14+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export function useCodeGroups() {
77 Array . from ( el . children ) . forEach ( ( child ) => {
88 child . classList . remove ( 'active' )
99 } )
10- el . children [ 0 ] . classList . add ( 'active' )
10+ activate ( el . children [ 0 ] )
1111 } )
1212 } )
1313 }
@@ -36,11 +36,18 @@ export function useCodeGroups() {
3636 if ( ! next || current === next ) return
3737
3838 current . classList . remove ( 'active' )
39- next . classList . add ( 'active' )
39+ activate ( next )
4040
4141 const label = group ?. querySelector ( `label[for="${ el . id } "]` )
4242 label ?. scrollIntoView ( { block : 'nearest' } )
4343 }
4444 } )
4545 }
4646}
47+
48+ function activate ( el : Element ) : void {
49+ el . classList . add ( 'active' )
50+ window . dispatchEvent (
51+ new CustomEvent ( 'vitepress:codeGroupTabActivate' , { detail : el } )
52+ )
53+ }
Original file line number Diff line number Diff line change 55 "outDir" : " ../../dist/client" ,
66 "declaration" : true ,
77 "declarationDir" : " ../../dist/client-types" ,
8- "types" : [" vite/ client" , " @types/node" ],
8+ "types" : [" ../../ client.d.ts " , " @types/node" ],
99 "paths" : {
1010 "vitepress" : [" index.ts" ],
1111 "vitepress/theme" : [" ../../theme.d.ts" ]
You can’t perform that action at this time.
0 commit comments