Fixes for broken Markdown Parsing

This commit is contained in:
David Bomba 2024-02-22 14:36:59 +11:00
parent 55d512b0a5
commit 87df61fa67
6 changed files with 78 additions and 41 deletions

View File

@ -148,6 +148,20 @@ class Product extends BaseModel
return $converter->convert($this->notes ?? '');
}
public static function markdownHelp(string $notes = '')
{
$converter = new CommonMarkConverter([
'allow_unsafe_links' => false,
'renderer' => [
'soft_break' => '<br>',
],
]);
return $converter->convert($notes);
}
public function portalUrl($use_react_url): string
{
return $use_react_url ? config('ninja.react_url') . "/#/products/{$this->hashed_id}/edit" : config('ninja.app_url');

View File

@ -5237,6 +5237,7 @@ $lang = array(
'user_sales' => 'User Sales',
'iframe_url' => 'iFrame URL',
'user_unsubscribed' => 'User unsubscribed from emails :link',
'out_of_stock' => 'Out of stock',
);
return $lang;

View File

@ -1,15 +1,20 @@
<div class="space-y-10">
@unless(empty($subscription->product_ids))
@foreach($subscription->service()->products() as $index => $product)
@isset($context['bundle']['one_time_products'])
@foreach($context['bundle']['one_time_products'] as $key => $entry)
@php
$product = $entry['product'];
@endphp
<div>
<div class="flex items-start justify-between space-x-4">
<div class="flex flex-start">
@if(filter_var($product->product_image, FILTER_VALIDATE_URL))
@if(filter_var($product['product_image'], FILTER_VALIDATE_URL))
<div
class="h-16 w-16 flex-shrink-0 overflow-hidden rounded-md border border-gray-200 mr-2"
>
<img
src="{{ $product->product_image }}"
src="{{ $product['product_image'] }}"
alt=""
class="h-full w-full object-cover object-center border rounded-md"
/>
@ -17,16 +22,35 @@
@endif
<div class="flex flex-col">
<h2 class="text-lg font-medium">{{ $product->product_key }}</h2>
<p class="block text-sm">{{ \App\Utils\Number::formatMoney($product->price, $subscription->company) }}</p>
<h2 class="text-lg font-medium">{{ $product['product_key'] }}</h2>
<p class="block text-sm">{{ \App\Utils\Number::formatMoney($product['price'], $subscription['company']) }}</p>
</div>
</div>
<div class="flex flex-col-reverse space-y-3">
<div class="flex">
@if($subscription->per_seat_enabled)
@if($subscription->use_inventory_management && $product['in_stock_quantity'] <= 0)
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
@else
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
@endif
<select id="{{ $product['hashed_id'] }}" wire:change="quantity($event.target.id, $event.target.value)" class="rounded-md border-gray-300 shadow-sm sm:text-sm" {{ $subscription->use_inventory_management && $product['in_stock_quantity'] < 1 ? 'disabled' : '' }}>
<option {{ $entry['quantity'] == '0' ? 'selected' : '' }} value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], min(100,$product['max_quantity'])) : min(100,$product['max_quantity'])); $i++)
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
@endif
</div>
</div>
</div>
<article class="prose my-3 text-sm">
{!! $product->markdownNotes() !!}
{!! \App\Models\Product::markdownHelp($product['notes']) !!}
</article>
</div>
@endforeach
@endunless
@endisset
</div>

View File

@ -29,26 +29,24 @@
<div class="flex flex-col-reverse space-y-3">
<div class="flex">
@if($subscription->per_seat_enabled)
@if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0)
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
@else
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
@endif
<select id="{{ $product['hashed_id'] }}" wire:change="quantity($event.target.id, $event.target.value)" class="rounded-md border-gray-300 shadow-sm sm:text-sm" @if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0) disabled @endif>
<option {{ $entry['quantity'] == '0' ? 'selected' : '' }} value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], max(100,$product['max_quantity'])) : max(100,$product['max_quantity'])); $i++)
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
@if($subscription->use_inventory_management && $product['in_stock_quantity'] <= 0)
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
@else
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
@endif
<select id="{{ $product['hashed_id'] }}" wire:change="quantity($event.target.id, $event.target.value)" class="rounded-md border-gray-300 shadow-sm sm:text-sm" {{ $subscription->use_inventory_management && $product['in_stock_quantity'] < 1 ? 'disabled' : '' }}>
<option {{ $entry['quantity'] == '0' ? 'selected' : '' }} value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], min(100,$product['max_quantity'])) : min(100,$product['max_quantity'])); $i++)
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
</div>
</div>
</div>
<article class="prose my-3 text-sm">
{!! $product['notes'] !!}
{!! \App\Models\Product::markdownHelp($product['notes']) !!}
</article>
</div>
@endforeach

View File

@ -29,26 +29,26 @@
<div class="flex flex-col-reverse space-y-3">
<div class="flex">
@if($subscription->per_seat_enabled)
@if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0)
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
@else
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
@endif
<select id="{{ $product['hashed_id'] }}" wire:change="quantity($event.target.id, $event.target.value)" class="rounded-md border-gray-300 shadow-sm sm:text-sm" @if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0) disabled @endif>
<option {{ $entry['quantity'] == '0' ? 'selected' : '' }} value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], max(100,$product['max_quantity'])) : max(100,$product['max_quantity'])); $i++)
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
@if($subscription->use_inventory_management && $product['in_stock_quantity'] <= 0)
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
@else
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
@endif
<select id="{{ $product['hashed_id'] }}" wire:change="quantity($event.target.id, $event.target.value)" class="rounded-md border-gray-300 shadow-sm sm:text-sm" {{ $subscription->use_inventory_management && $product['in_stock_quantity'] < 1 ? 'disabled' : '' }}>
<option {{ $entry['quantity'] == '0' ? 'selected' : '' }} value="0" selected="selected">0</option>
@for ($i = 1; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], min(100,$product['max_quantity'])) : min(100,$product['max_quantity'])); $i++)
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
@endfor
</select>
</div>
</div>
</div>
<article class="prose my-3 text-sm">
{!! $product['notes'] !!}
{!! \App\Models\Product::markdownHelp($product['notes']) !!}
</article>
</div>
@endforeach

View File

@ -30,7 +30,7 @@
<div class="flex flex-col-reverse space-y-3">
<div class="flex">
@if($subscription->per_seat_enabled)
@if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0)
@if($subscription->use_inventory_management && $product['in_stock_quantity'] < 1)
<p class="text-sm font-light text-red-500 text-right mr-2 mt-2">{{ ctrans('texts.out_of_stock') }}</p>
@else
<p class="text-sm font-light text-gray-700 text-right mr-2 mt-2">{{ ctrans('texts.qty') }}</p>
@ -40,7 +40,7 @@
id="{{ $product['hashed_id'] }}"
class="rounded-md border-gray-300 shadow-sm sm:text-sm"
wire:change="quantity($event.target.id, $event.target.value)"
@if($subscription->use_inventory_management && $product['in_stock_quantity'] == 0) disabled @endif
{{ $subscription->use_inventory_management && $product['in_stock_quantity'] < 1 ? 'disabled' : '' }}
>
<option {{ $entry['quantity'] == '1' ? 'selected' : '' }} value="1">1</option>
@ -49,7 +49,7 @@
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
@endfor
@else
@for ($i = 2; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], max(100,$product['max_quantity'])) : max(100,$product['max_quantity'])); $i++)
@for ($i = 2; $i <= ($subscription->use_inventory_management ? min($product['in_stock_quantity'], min(100,$product['max_quantity'])) : min(100,$product['max_quantity'])); $i++)
<option {{ $entry['quantity'] == $i ? 'selected' : '' }} value="{{ $i }}">{{ $i }}</option>
@endfor
@endif
@ -60,7 +60,7 @@
</div>
<article class="prose my-3 text-sm">
{!! $product['notes'] !!}
{!! \App\Models\Product::markdownHelp($product['notes']) !!}
</article>
</div>
@endforeach