getElements($textRun); if (count($textRunElements)) { foreach ($textRunElements as $index => $element) { try { $handler = $this->getHandler($element); $data = $handler->handle($element); if ($data) { $styleName = $textRun->getParagraphStyle()->getStyleName(); if ($index === 0) { $result[] = [ 'content' => $handler->handle($element), 'type' => 'textRun', 'depth' => $textRun->getDepth(), 'styleDepth' => $this->getStyleListDepth($styleName), 'styleName' => $styleName, 'index' => $textRun->getElementIndex(), 'children' => [] ]; } else { if (isset($result[ count($result) - 1 ])) { $result[ count($result) - 1 ][ 'content' ][ 'content' ] .= ' '.$data[ 'content' ]; } else { $result[] = [ 'content' => $data, 'type' => 'textRun', 'depth' => (int) $textRun->getDepth(), 'styleDepth' => $this->getStyleListDepth($styleName), 'styleName' => $styleName, 'index' => $textRun->getElementIndex(), 'children' => [] ]; } } } } catch (Exception $e) { dd($e, 2); throw new Exception($e->getMessage()); } } if ($result) { if (count($result) === 1) { $result = reset($result); $result[ 'content' ][ 'content' ] = '

'.$result[ 'content' ][ 'content' ].'

'; } } } return $result; } }