@@ -80,24 +80,26 @@ export class FC2 {
8080 }
8181
8282 // Prepare active clozes: strip cloze when exposed, store hint and hide as required
83- this . content . querySelectorAll ( '.cloze' ) . forEach ( ( ( cloze : HTMLElement ) => {
84- if ( this . expose ( cloze ) ) return
85- if ( this . cfg . front ) {
86- cloze . dataset . hint = cloze . innerHTML === '[...]'
87- ? this . cfg . prompt
88- : this . cfg . hint . replace ( '%h' , cloze . innerHTML . slice ( 1 , cloze . innerHTML . length - 1 ) ) || ""
89- this . hide ( cloze )
90- } else cloze . dataset . hint = this . cfg . prompt
91- } ) as any )
92-
9383 // Prepare inactive clozes: expose from expose char or containing active cloze
94- this . content . querySelectorAll ( '.cloze-inactive' ) . forEach ( ( ( cloze : HTMLElement ) => {
95- if ( this . expose ( cloze ) || cloze . querySelector ( '.cloze' ) ) {
84+ let active_found = false
85+ this . content . querySelectorAll ( '.cloze-inactive, .cloze' ) . forEach ( ( ( cloze : HTMLElement ) => {
86+ const active = cloze . classList . contains ( '.cloze' )
87+ active_found ||= active
88+ if ( this . expose ( cloze ) || ! active && cloze . querySelector ( '.cloze' ) ) {
9689 cloze . classList . remove ( 'cloze-inactive' )
9790 return
9891 }
99- cloze . dataset . hint = this . cfg . prompt
100- if ( ! this . cfg . show . inactive ) this . hide ( cloze )
92+ if ( active && this . cfg . front ) {
93+ cloze . dataset . hint = cloze . innerHTML === '[...]'
94+ ? this . cfg . prompt
95+ : this . cfg . hint . replace ( '%h' , cloze . innerHTML . slice ( 1 , cloze . innerHTML . length - 1 ) ) || ""
96+ this . hide ( cloze )
97+ } else cloze . dataset . hint = this . cfg . prompt
98+ if (
99+ ! active && ( ! this . cfg . show . inactive ||
100+ active_found && this . cfg . show . inactive === 'preceding' )
101+ )
102+ this . hide ( cloze )
101103 } ) as any )
102104
103105 // Show additional fields per default depending on config
0 commit comments