From b42f2bdabe39bb70ba8a70459a0d35b49a04310c Mon Sep 17 00:00:00 2001 From: Rob Lyons <39706150+aSeriousDeveloper@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:46:13 +0100 Subject: [PATCH] Update TiptapConverter.php Add depth to heading array Remove unnecessary if statement --- src/TiptapConverter.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/TiptapConverter.php b/src/TiptapConverter.php index c96c770..e183704 100644 --- a/src/TiptapConverter.php +++ b/src/TiptapConverter.php @@ -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; }