fix: format

pull/4574/head
btea 7 months ago
parent 6b1c3b73a6
commit a75c81e380

@ -14,17 +14,26 @@ export function useCodeGroups() {
if (inBrowser) { if (inBrowser) {
function syncMultipleCodeGroups(group: HTMLElement) { function syncMultipleCodeGroups(group: HTMLElement) {
const selector = group.className.split(' ').filter(Boolean).map((c) => `.${c}`).join('') const selector = group.className
let checkTabText = group.querySelector('input:checked')?.nextElementSibling?.textContent || '' .split(' ')
.filter(Boolean)
.map((c) => `.${c}`)
.join('')
let checkTabText =
group.querySelector('input:checked')?.nextElementSibling?.textContent ||
''
document.querySelectorAll(selector).forEach((groupEl) => { document.querySelectorAll(selector).forEach((groupEl) => {
if (group === groupEl) { if (group === groupEl) {
return return
} }
const labels = groupEl.querySelectorAll('label') const labels = groupEl.querySelectorAll('label')
if (!labels.length) return if (!labels.length) return
const targetIndex = Array.from(labels).findIndex((label) => label.textContent === checkTabText) const targetIndex = Array.from(labels).findIndex(
(label) => label.textContent === checkTabText
)
if (targetIndex < 0) return if (targetIndex < 0) return
const input = labels[targetIndex].previousElementSibling as HTMLInputElement const input = labels[targetIndex]
.previousElementSibling as HTMLInputElement
input.checked = true input.checked = true
const blocks = groupEl.querySelector('.blocks') const blocks = groupEl.querySelector('.blocks')
if (!blocks) return if (!blocks) return
@ -34,7 +43,6 @@ export function useCodeGroups() {
child.classList.remove('active') child.classList.remove('active')
}) })
blocks.children[targetIndex].classList.add('active') blocks.children[targetIndex].classList.add('active')
}) })
} }
window.addEventListener('click', (e) => { window.addEventListener('click', (e) => {

Loading…
Cancel
Save