2020-04-27 01:04:08 +00:00
|
|
|
const _ = require('lodash')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
async init($, config) {
|
|
|
|
for (let i = 1; i < 6; i++) {
|
|
|
|
$(`h${i}.tabset`).each((idx, elm) => {
|
|
|
|
let content = `<tabset>`
|
|
|
|
let tabs = []
|
|
|
|
let tabContents = []
|
|
|
|
$(elm).nextUntil(_.times(i, t => `h${t + 1}`).join(', '), `h${i + 1}`).each((hidx, hd) => {
|
2020-04-27 01:18:51 +00:00
|
|
|
tabs.push(`<li>${$(hd).html()}</li>`)
|
2020-04-27 01:04:08 +00:00
|
|
|
let tabContent = ''
|
|
|
|
$(hd).nextUntil(_.times(i + 1, t => `h${t + 1}`).join(', ')).each((cidx, celm) => {
|
|
|
|
tabContent += $.html(celm)
|
|
|
|
$(celm).remove()
|
|
|
|
})
|
|
|
|
console.info(tabContent)
|
|
|
|
tabContents.push(`<div class="tabset-panel">${tabContent}</div>`)
|
|
|
|
$(hd).remove()
|
|
|
|
})
|
|
|
|
content += `<template v-slot:tabs>${tabs.join('')}</template>`
|
|
|
|
content += `<template v-slot:content>${tabContents.join('')}</template>`
|
|
|
|
content += `</tabset>`
|
|
|
|
$(elm).replaceWith($(content))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|