Skip to content

Commit

Permalink
Update TiptapConverter.php
Browse files Browse the repository at this point in the history
Add depth to heading array
Remove unnecessary if statement
  • Loading branch information
aSeriousDeveloper authored Sep 9, 2024
1 parent db31680 commit b42f2bd
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/TiptapConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,14 @@ public function generateTOCArray(array &$headings, int $parentLevel = 0): array
$heading = [
'id' => $value['id'],
'text' => $value['text'],
'depth' => $currentLevel,
];

// recursive if next heading is higher level
if ($nextLevel > $currentLevel) {
$heading['subs'] = $this->generateTOCArray($headings, $currentLevel);
}

// only add if higher than parent level
if ($currentLevel > $parentLevel) {
$result[] = $heading;
}
$result[] = $heading;

}

Expand Down

0 comments on commit b42f2bd

Please sign in to comment.