mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: enable code fold on all code blocks
This commit is contained in:
parent
bbf7f3d7ea
commit
fcdef87b2a
1 changed files with 9 additions and 5 deletions
|
|
@ -13,6 +13,10 @@ const selectorOfLineContent = `.blob-code`
|
|||
|
||||
const theCSSClassForToggleElementOnActive = 'gitako-code-fold-active'
|
||||
function init() {
|
||||
document.querySelectorAll(tableSelector).forEach(processTable)
|
||||
}
|
||||
|
||||
function processTable(table: Element) {
|
||||
type LineNumber = number // alias
|
||||
const blocks: LineNumber[] = [] // startLine -> exclusiveEndLine
|
||||
/**
|
||||
|
|
@ -34,8 +38,7 @@ function init() {
|
|||
* 5
|
||||
*/
|
||||
|
||||
const table = document.querySelector(tableSelector)
|
||||
const lineElements = Array.from(document.querySelectorAll([tableSelector, 'tr'].join(' ')))
|
||||
const lineElements = Array.from(table.querySelectorAll('tr'))
|
||||
if (!table || !lineElements.length) return
|
||||
if (table.classList.contains(theCSSClassMark)) {
|
||||
if (table.classList.contains(theCSSClassMarkWhenDisabled)) {
|
||||
|
|
@ -124,7 +127,7 @@ function init() {
|
|||
if (e.target.classList.contains(theCSSClassForToggleElement)) {
|
||||
const tr = e.target.parentElement?.parentElement
|
||||
if (tr) {
|
||||
toggleLine(lineElements.indexOf(tr))
|
||||
toggleLine(lineElements.indexOf(tr as HTMLTableRowElement))
|
||||
e.stopPropagation()
|
||||
}
|
||||
}
|
||||
|
|
@ -133,8 +136,9 @@ function init() {
|
|||
}
|
||||
|
||||
function cancelToggleFeature() {
|
||||
const table = document.querySelector(tableSelector)
|
||||
table?.classList.add(theCSSClassMarkWhenDisabled)
|
||||
document
|
||||
.querySelectorAll(tableSelector)
|
||||
.forEach(table => table.classList.add(theCSSClassMarkWhenDisabled))
|
||||
}
|
||||
|
||||
function getTextLevel(text: string) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue