@php $activeClass = isset($activeId) && $shortcode['id'] == $activeId ? 'active' : ''; $previewText = ''; if (!empty($shortcode['attributes'])) { $attrs = collect($shortcode['attributes']) ->take(2) ->map(function ($val, $key) { // Convert arrays or objects to string representation if (is_array($val)) { $val = json_encode($val); } elseif (is_object($val)) { $val = (string) $val; } return "$key: $val"; }) ->join(', '); $previewText = $attrs ?: $shortcode['name']; } else { $previewText = $shortcode['name']; } @endphp